import { AfterViewInit, Component, Inject, ViewChild } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import WebViewer from '@pdftron/webviewer';

@Component({
    selector: 'app-webviewer',
    templateUrl: './webviewer.component.html',
    styleUrl: './webviewer.component.css',
    standalone: false
})
export class WebviewerComponent implements AfterViewInit {
  @ViewChild('viewer') viewerRef: any;

  constructor(
    public dialogRef: MatDialogRef<any>,
    @Inject(MAT_DIALOG_DATA) public data: any
  ) { }

  ngAfterViewInit() {
    WebViewer(
      {
        path: '../assets/lib',
        initialDoc: this.data.url,
      },
      this.viewerRef.nativeElement
    ).then((instance: any) => {
      instance.UI.disableElements([
        'toolbarGroup-Shapes',
        'toolbarGroup-Edit',
        'toolbarGroup-Insert',
        'toolbarGroup-Annotate',
        'toolbarGroup-Forms',
        'notesPanel',
        'viewControlsButton',
        'selectToolButton',
        'toggleNotesButton',
        'freeTextToolGroupButton',
        'crossStampToolButton',
        'checkStampToolButton',
        'dotStampToolButton',
        'rubberStampToolGroupButton',
        'dateFreeTextToolButton',
        'eraserToolButton',
        'signatureToolGroupButton',
        'viewControlsOverlay',
        'toolbarGroup-View',
        'settingsButton',
      ]);
    });
  }
}
