import { Component, ElementRef, Input, ViewChild } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { ZuiE } from '@material-zui/core';
export class ZuiPdfComponent {
    // count = 0
    // @HostListener('window:beforeunload') goToPage(e: any) {
    //   console.log('beforeunload', e)
    //   e.preventDefault()
    // }
    constructor(sanitizer) {
        this.sanitizer = sanitizer;
        this.width = '100%';
        this.height = '500px';
        this.type = 'iframe';
        // ngAfterViewInit(): void {
        //   // $(window).bind({
        //   //   beforeunload: e => {
        //   //     e.preventDefault()
        //   //   },
        //   //   unload: e => {
        //   //     e.preventDefault()
        //   //   },
        //   // })
        //   window.addEventListener('beforeunload', event => {
        //     console.log('beforeunload', event)
        //     event.stopPropagation()
        //     event.preventDefault()
        //     return false
        //   })
        // }
        this.load = (e) => {
            // console.log('e', e)
            // this.safeSrc = null
        };
    }
    ngOnChanges() {
        if (this.src) {
            this.safeSrc = this.sanitizer.bypassSecurityTrustResourceUrl(this.src);
        }
        else {
            throw ZuiE.error({ src: this.src });
        }
    }
}
ZuiPdfComponent.decorators = [
    { type: Component, args: [{
                selector: 'zui-pdf',
                template: "<ng-container *ngIf=\"src && safeSrc\">\n  <iframe\n    *ngIf=\"type === 'iframe'\"\n    [src]=\"safeSrc\"\n    [width]=\"width\"\n    [height]=\"height\"\n    frameBorder=\"0\"\n    scrolling=\"auto\"\n    allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\"\n    allowfullscreen\n    (load)=\"load($event)\"\n  ></iframe>\n  <!-- <iframe\n  *ngIf=\"type === 'iframe'\"\n  [src]=\"safeSrc\"\n  [width]=\"width\"\n  [height]=\"height\"\n  frameBorder=\"0\"\n  scrolling=\"auto\"\n  allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\"\n  allowfullscreen\n  (load)=\"load($event)\"\n></iframe> -->\n  <embed *ngIf=\"type === 'embed'\" [src]=\"safeSrc\" type=\"application/pdf\" [width]=\"width\" [height]=\"height\" />\n</ng-container>\n",
                styles: [":host{display:block}"]
            },] }
];
ZuiPdfComponent.ctorParameters = () => [
    { type: DomSanitizer }
];
ZuiPdfComponent.propDecorators = {
    src: [{ type: Input }],
    width: [{ type: Input }],
    height: [{ type: Input }],
    type: [{ type: Input }],
    container: [{ type: ViewChild, args: ['container',] }]
};
//# sourceMappingURL=index.component.js.map