UNPKG

ngx-extended-pdf-viewer

Version:

Embedding PDF files in your Angular application. Highly configurable viewer including the toolbar, sidebar, and all the features you're used to.

22 lines 325 kB
window.ngxZone.runOutsideAngular(() => { /** * @licstart The following is the entire license notice for the * JavaScript code in this page * * Copyright 2022 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @licend The above is the entire license notice for the * JavaScript code in this page */(()=>{"use strict";var e=[,(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.compatibilityParams=t.OptionKind=t.AppOptions=void 0;const i=Object.create(null);t.compatibilityParams=i;{const e=navigator.userAgent||"",t=navigator.platform||"",n=navigator.maxTouchPoints||1,s=/Android/.test(e),r=/\b(iPad|iPhone|iPod)(?=;)/.test(e)||"MacIntel"===t&&n>1;!function checkCanvasSizeLimitation(){(r||s)&&(i.maxCanvasPixels=5242880)}()}const n={VIEWER:2,API:4,WORKER:8,PREFERENCE:128};t.OptionKind=n;const s={annotationEditorMode:{value:-1,kind:n.VIEWER+n.PREFERENCE},annotationMode:{value:2,kind:n.VIEWER+n.PREFERENCE},cursorToolOnLoad:{value:0,kind:n.VIEWER+n.PREFERENCE},defaultZoomValue:{value:"",kind:n.VIEWER+n.PREFERENCE},disableHistory:{value:!1,kind:n.VIEWER},disablePageLabels:{value:!1,kind:n.VIEWER+n.PREFERENCE},enablePermissions:{value:!1,kind:n.VIEWER+n.PREFERENCE},enablePrintAutoRotate:{value:!0,kind:n.VIEWER+n.PREFERENCE},enableScripting:{value:!0,kind:n.VIEWER+n.PREFERENCE},externalLinkRel:{value:"noopener noreferrer nofollow",kind:n.VIEWER},externalLinkTarget:{value:0,kind:n.VIEWER+n.PREFERENCE},historyUpdateUrl:{value:!1,kind:n.VIEWER+n.PREFERENCE},ignoreDestinationZoom:{value:!1,kind:n.VIEWER+n.PREFERENCE},imageResourcesPath:{value:"./images/",kind:n.VIEWER},maxCanvasPixels:{value:16777216,kind:n.VIEWER},forcePageColors:{value:!1,kind:n.VIEWER+n.PREFERENCE},pageColorsBackground:{value:"Canvas",kind:n.VIEWER+n.PREFERENCE},pageColorsForeground:{value:"CanvasText",kind:n.VIEWER+n.PREFERENCE},pdfBugEnabled:{value:!1,kind:n.VIEWER+n.PREFERENCE},printResolution:{value:150,kind:n.VIEWER},removePageBorders:{value:!1,kind:n.VIEWER+n.PREFERENCE},sidebarViewOnLoad:{value:-1,kind:n.VIEWER+n.PREFERENCE},scrollModeOnLoad:{value:-1,kind:n.VIEWER+n.PREFERENCE},spreadModeOnLoad:{value:-1,kind:n.VIEWER+n.PREFERENCE},textLayerMode:{value:1,kind:n.VIEWER+n.PREFERENCE},useOnlyCssZoom:{value:!1,kind:n.VIEWER+n.PREFERENCE},viewerCssTheme:{value:0,kind:n.VIEWER+n.PREFERENCE},viewOnLoad:{value:0,kind:n.VIEWER+n.PREFERENCE},cMapPacked:{value:!0,kind:n.API},cMapUrl:{value:"../web/cmaps/",kind:n.API},disableAutoFetch:{value:!1,kind:n.API+n.PREFERENCE},disableFontFace:{value:!1,kind:n.API+n.PREFERENCE},disableRange:{value:!1,kind:n.API+n.PREFERENCE},disableStream:{value:!1,kind:n.API+n.PREFERENCE},docBaseUrl:{value:"",kind:n.API},enableXfa:{value:!0,kind:n.API+n.PREFERENCE},fontExtraProperties:{value:!1,kind:n.API},isEvalSupported:{value:!0,kind:n.API},maxImageSize:{value:-1,kind:n.API},pdfBug:{value:!1,kind:n.API},standardFontDataUrl:{value:"../web/standard_fonts/",kind:n.API},verbosity:{value:1,kind:n.API},workerPort:{value:null,kind:n.WORKER},workerSrc:{value:"./assets/pdf.worker.js",kind:n.WORKER}};s.defaultUrl={value:"compressed.tracemonkey-pldi-09.pdf",kind:n.VIEWER};s.disablePreferences={value:!1,kind:n.VIEWER};s.locale={value:navigator.language||"en-US",kind:n.VIEWER};s.renderer={value:"canvas",kind:n.VIEWER+n.PREFERENCE};s.sandboxBundleSrc={value:"../build/pdf.sandbox.js",kind:n.VIEWER};const r=Object.create(null);if(globalThis.pdfDefaultOptions)for(const e in globalThis.pdfDefaultOptions)r[e]=globalThis.pdfDefaultOptions[e];t.AppOptions=class AppOptions{constructor(){throw new Error("Cannot initialize AppOptions.")}static get(e){const t=r[e];if(void 0!==t)return t;const n=s[e];return void 0!==n?i[e]??n.value:void 0}static getAll(e=null){const t=Object.create(null);for(const o in s){const a=s[o];if(e){if(0==(e&a.kind))continue;if(e===n.PREFERENCE){const e=a.value,i=typeof e;if("boolean"===i||"string"===i||"number"===i&&Number.isInteger(e)){t[o]=e;continue}throw new Error(`Invalid type for preference: ${o}`)}}const l=r[o];t[o]=void 0!==l?l:i[o]??a.value}return t}static set(e,t){r[e]=t}static setAll(e){for(const t in e)r[t]=e[t]}static remove(e){delete r[e]}static _hasUserOptions(){return Object.keys(r).length>0}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFViewerApplication=t.PDFPrintServiceFactory=t.DefaultExternalServices=void 0;var n=i(3),s=i(4),r=i(1),o=i(5),a=i(6),l=i(8),h=i(9),d=i(10),c=i(11),u=i(12),g=i(14),p=i(15),f=i(16),m=i(20),w=i(21),v=i(22),b=i(23),_=i(24),P=i(25),y=i(26),S=i(27),E=i(28),C=i(30),T=i(44),x=i(45),L=i(46);const I=-1,M=1,A={AUTOMATIC:0,LIGHT:1,DARK:2},D=["1.0","1.1","1.2","1.3","1.4","1.5","1.6","1.7","1.8","1.9","2.0","2.1","2.2","2.3"],B=["acrobat distiller","acrobat pdfwriter","adobe livecycle","adobe pdf library","adobe photoshop","ghostscript","tcpdf","cairo","dvipdfm","dvips","pdftex","pdfkit","itext","prince","quarkxpress","mac os x","microsoft","openoffice","oracle","luradocument","pdf-xchange","antenna house","aspose.cells","fpdf"];class DefaultExternalServices{constructor(){throw new Error("Cannot initialize DefaultExternalServices.")}static updateFindControlState(e){}static updateFindMatchesCount(e){}static initPassiveLoading(e){}static reportTelemetry(e){}static createDownloadManager(e){throw new Error("Not implemented: createDownloadManager")}static createPreferences(){throw new Error("Not implemented: createPreferences")}static createL10n(e){throw new Error("Not implemented: createL10n")}static createScripting(e){throw new Error("Not implemented: createScripting")}static get supportsIntegratedFind(){return(0,s.shadow)(this,"supportsIntegratedFind",!1)}static get supportsDocumentFonts(){return(0,s.shadow)(this,"supportsDocumentFonts",!0)}static get supportedMouseWheelZoomModifierKeys(){return(0,s.shadow)(this,"supportedMouseWheelZoomModifierKeys",{ctrlKey:!0,metaKey:!0})}static get isInAutomation(){return(0,s.shadow)(this,"isInAutomation",!1)}static updateEditorStates(e){throw new Error("Not implemented: updateEditorStates")}}t.DefaultExternalServices=DefaultExternalServices;const N={initialBookmark:document.location.hash.substring(1),_initializedCapability:(0,s.createPromiseCapability)(),appConfig:null,pdfDocument:null,pdfLoadingTask:null,printService:null,pdfViewer:null,pdfThumbnailViewer:null,pdfRenderingQueue:null,pdfPresentationMode:null,pdfDocumentProperties:null,pdfLinkService:null,pdfHistory:null,pdfSidebar:null,pdfSidebarResizer:null,pdfOutlineViewer:null,pdfAttachmentViewer:null,pdfLayerViewer:null,pdfCursorTools:null,pdfScriptingManager:null,store:null,downloadManager:null,overlayManager:null,preferences:null,toolbar:null,secondaryToolbar:null,eventBus:null,l10n:null,annotationEditorParams:null,isInitialViewSet:!1,downloadComplete:!1,isViewerEmbedded:window.parent!==window,url:"",baseUrl:"",_downloadUrl:"",externalServices:DefaultExternalServices,_boundEvents:Object.create(null),documentInfo:null,metadata:null,_contentDispositionFilename:null,_contentLength:null,_saveInProgress:!1,_docStats:null,_wheelUnusedTicks:0,_idleCallbacks:new Set,_PDFBug:null,_printAnnotationStoragePromise:null,async initialize(e){this.preferences=this.externalServices.createPreferences();this.appConfig=e;await this._readPreferences();await this._parseHashParameters();this._forceCssTheme();await this._initializeL10n();this.isViewerEmbedded&&r.AppOptions.get("externalLinkTarget")===l.LinkTarget.NONE&&r.AppOptions.set("externalLinkTarget",l.LinkTarget.TOP);await this._initializeViewerComponents();this.bindEvents();this.bindWindowEvents();const t=e.appContainer||document.documentElement;this.l10n.translate(t).then((()=>{this.eventBus.dispatch("localized",{source:this})}));this._initializedCapability.resolve();this.initializeLoadingBar()},async _readPreferences(){if(!r.AppOptions.get("disablePreferences")){r.AppOptions._hasUserOptions()&&Window.ngxConsole.warn('_readPreferences: The Preferences may override manually set AppOptions; please use the "disablePreferences"-option in order to prevent that.');try{r.AppOptions.setAll(await this.preferences.getAll())}catch(e){Window.ngxConsole.error(`_readPreferences: "${e?.message}".`)}}},async _parseHashParameters(){if(!r.AppOptions.get("pdfBugEnabled"))return;const e=document.location.hash.substring(1);if(!e)return;const{mainContainer:t,viewerContainer:i}=this.appConfig,o=(0,n.parseQueryString)(e);if("true"===o.get("disableworker"))try{await async function loadFakeWorker(){s.GlobalWorkerOptions.workerSrc||=r.AppOptions.get("workerSrc");"Function"===s.GlobalWorkerOptions.workerSrc.constructor.name&&(s.GlobalWorkerOptions.workerSrc=s.GlobalWorkerOptions.workerSrc());await(0,s.loadScript)(s.PDFWorker.workerSrc)}()}catch(e){console.error(`_parseHashParameters: "${e.message}".`)}o.has("disablerange")&&r.AppOptions.set("disableRange","true"===o.get("disablerange"));o.has("disablestream")&&r.AppOptions.set("disableStream","true"===o.get("disablestream"));o.has("disableautofetch")&&r.AppOptions.set("disableAutoFetch","true"===o.get("disableautofetch"));o.has("disablefontface")&&r.AppOptions.set("disableFontFace","true"===o.get("disablefontface"));o.has("disablehistory")&&r.AppOptions.set("disableHistory","true"===o.get("disablehistory"));o.has("verbosity")&&r.AppOptions.set("verbosity",0|o.get("verbosity"));if(o.has("textlayer"))switch(o.get("textlayer")){case"off":r.AppOptions.set("textLayerMode",n.TextLayerMode.DISABLE);break;case"visible":case"shadow":case"hover":i.classList.add(`textLayer-${o.get("textlayer")}`);try{await loadPDFBug(this);this._PDFBug.loadCSS()}catch(e){console.error(`_parseHashParameters: "${e.message}".`)}}if(o.has("pdfbug")){r.AppOptions.set("pdfBug",!0);r.AppOptions.set("fontExtraProperties",!0);const e=o.get("pdfbug").split(",");try{await loadPDFBug(this);this._PDFBug.init({OPS:s.OPS},t,e)}catch(e){console.error(`_parseHashParameters: "${e.message}".`)}}o.has("locale")&&r.AppOptions.set("locale",o.get("locale"))},async _initializeL10n(){this.l10n=this.externalServices.createL10n({locale:r.AppOptions.get("locale")});const e=await this.l10n.getDirection();document.getElementsByTagName("html")[0].dir=e},_forceCssTheme(){const e=r.AppOptions.get("viewerCssTheme");if(e!==A.AUTOMATIC&&Object.values(A).includes(e))try{const t=document.styleSheets[0],i=t?.cssRules||[];for(let n=0,s=i.length;n<s;n++){const s=i[n];if(s instanceof CSSMediaRule&&"(prefers-color-scheme: dark)"===s.media?.[0]){if(e===A.LIGHT){t.deleteRule(n);return}const i=/^@media \(prefers-color-scheme: dark\) {\n\s*([\w\s-.,:;/\\{}()]+)\n}$/.exec(s.cssText);if(i?.[1]){t.deleteRule(n);t.insertRule(i[1],n)}return}}}catch(e){Window.ngxConsole.error(`_forceCssTheme: "${e?.message}".`)}},async _initializeViewerComponents(){const{appConfig:e,externalServices:t}=this,i=t.isInAutomation?new o.AutomationEventBus:new o.EventBus;this.eventBus=i;this.overlayManager=new d.OverlayManager;const n=new _.PDFRenderingQueue;n.onIdle=this._cleanup.bind(this);this.pdfRenderingQueue=n;const L=new l.PDFLinkService({eventBus:i,externalLinkTarget:r.AppOptions.get("externalLinkTarget"),externalLinkRel:r.AppOptions.get("externalLinkRel"),ignoreDestinationZoom:r.AppOptions.get("ignoreDestinationZoom")});this.pdfLinkService=L;const I=t.createDownloadManager();this.downloadManager=I;const M=new f.PDFFindController({linkService:L,eventBus:i,pageViewMode:r.AppOptions.get("pageViewMode")});this.findController=M;const A=new P.PDFScriptingManager({eventBus:i,sandboxBundleSrc:r.AppOptions.get("sandboxBundleSrc"),scriptingFactory:t,docPropertiesLookup:this._scriptingDocProperties.bind(this)});this.pdfScriptingManager=A;const D=e.mainContainer,B=e.viewerContainer,N=r.AppOptions.get("annotationEditorMode"),V=r.AppOptions.get("forcePageColors")||window.matchMedia("(forced-colors: active)").matches?{background:r.AppOptions.get("pageColorsBackground"),foreground:r.AppOptions.get("pageColorsForeground")}:null;this.pdfViewer=new C.PDFViewer({container:D,viewer:B,eventBus:i,renderingQueue:n,linkService:L,downloadManager:I,findController:M,scriptingManager:r.AppOptions.get("enableScripting")&&A,renderer:r.AppOptions.get("renderer"),l10n:this.l10n,textLayerMode:r.AppOptions.get("textLayerMode"),annotationMode:r.AppOptions.get("annotationMode"),annotationEditorMode:N,imageResourcesPath:r.AppOptions.get("imageResourcesPath"),removePageBorders:r.AppOptions.get("removePageBorders"),enablePrintAutoRotate:r.AppOptions.get("enablePrintAutoRotate"),useOnlyCssZoom:r.AppOptions.get("useOnlyCssZoom"),maxCanvasPixels:r.AppOptions.get("maxCanvasPixels"),pageViewMode:r.AppOptions.get("pageViewMode"),enablePermissions:r.AppOptions.get("enablePermissions"),pageColors:V});n.setViewer(this.pdfViewer);L.setViewer(this.pdfViewer);A.setViewer(this.pdfViewer);this.pdfThumbnailViewer=new E.PDFThumbnailViewer({container:e.sidebar.thumbnailView,eventBus:i,renderingQueue:n,linkService:L,l10n:this.l10n,pageColors:V});n.setThumbnailViewer(this.pdfThumbnailViewer);if(!this.isViewerEmbedded&&!r.AppOptions.get("disableHistory")){this.pdfHistory=new m.PDFHistory({linkService:L,eventBus:i});L.setHistory(this.pdfHistory)}this.supportsIntegratedFind||(this.findBar=new p.PDFFindBar(e.findBar,i,this.l10n));if(N!==s.AnnotationEditorType.DISABLE){this.annotationEditorParams=new h.AnnotationEditorParams(e.annotationEditorParams,i);for(const e of[document.getElementById("editorModeButtons"),document.getElementById("editorModeSeparator")])e.classList.remove("hidden")}this.pdfDocumentProperties=new g.PDFDocumentProperties(e.documentProperties,this.overlayManager,i,this.l10n,(()=>this._docFilename));this.pdfCursorTools=new a.PDFCursorTools({container:D,eventBus:i,cursorToolOnLoad:r.AppOptions.get("cursorToolOnLoad")});this.toolbar=new x.Toolbar(e.toolbar,i,this.l10n);this.secondaryToolbar=new T.SecondaryToolbar(e.secondaryToolbar,i);this.supportsFullscreen&&(this.pdfPresentationMode=new b.PDFPresentationMode({container:D,pdfViewer:this.pdfViewer,eventBus:i}));let O=r.AppOptions.get("passwordPrompt");O||(O=new c.PasswordPrompt(e.passwordOverlay,this.overlayManager,this.l10n,this.isViewerEmbedded));this.passwordPrompt=O;this.pdfOutlineViewer=new v.PDFOutlineViewer({container:e.sidebar.outlineView,eventBus:i,linkService:L});this.pdfAttachmentViewer=new u.PDFAttachmentViewer({container:e.sidebar.attachmentsView,eventBus:i,downloadManager:I});this.pdfLayerViewer=new w.PDFLayerViewer({container:e.sidebar.layersView,eventBus:i,l10n:this.l10n});this.pdfSidebar=new y.PDFSidebar({elements:e.sidebar,pdfViewer:this.pdfViewer,pdfThumbnailViewer:this.pdfThumbnailViewer,eventBus:i,l10n:this.l10n});this.pdfSidebar.onToggled=this.forceRendering.bind(this);this.pdfSidebarResizer=new S.PDFSidebarResizer(e.sidebarResizer,i,this.l10n)},run(e){this.initialize(e).then(webViewerInitialized)},get initialized(){return this._initializedCapability.settled},get initializedPromise(){return this._initializedCapability.promise},zoomIn(e){this.pdfViewer.isInPresentationMode||this.pdfViewer.increaseScale(e)},zoomOut(e){this.pdfViewer.isInPresentationMode||this.pdfViewer.decreaseScale(e)},zoomReset(){this.pdfViewer.isInPresentationMode||(this.pdfViewer.currentScaleValue=n.DEFAULT_SCALE_VALUE)},get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0},get page(){return this.pdfViewer.currentPageNumber},set page(e){this.pdfViewer.currentPageNumber=e},get supportsPrinting(){return R.instance.supportsPrinting},get supportsFullscreen(){return(0,s.shadow)(this,"supportsFullscreen",document.fullscreenEnabled)},get supportsIntegratedFind(){return this.externalServices.supportsIntegratedFind},get supportsDocumentFonts(){return this.externalServices.supportsDocumentFonts},initializeLoadingBar(){const e=new n.ProgressBar("loadingBar");e.hide();return(0,s.shadow)(this,"loadingBar",e)},get supportedMouseWheelZoomModifierKeys(){return this.externalServices.supportedMouseWheelZoomModifierKeys},initPassiveLoading(){throw new Error("Not implemented: initPassiveLoading")},setTitleUsingUrl(e="",t=null){this.url=e;this.baseUrl=e.split("#")[0];t&&(this._downloadUrl=t===e?this.baseUrl:t.split("#")[0]);let i=(0,s.getPdfFilenameFromUrl)(e,"");if(!i)try{i=decodeURIComponent((0,s.getFilenameFromUrl)(e))||e}catch(t){i=e}this.setTitle(i)},setTitle(e){this.isViewerEmbedded||(document.title=e)},get _docFilename(){return this._contentDispositionFilename||(0,s.getPdfFilenameFromUrl)(this.url)},_hideViewBookmark(){const{toolbar:e,secondaryToolbar:t}=this.appConfig;e.viewBookmark.hidden=!0;t.viewBookmarkButton.hidden=!0},_cancelIdleCallbacks(){if(this._idleCallbacks.size){for(const e of this._idleCallbacks)window.cancelIdleCallback(e);this._idleCallbacks.clear()}},async close(){this._unblockDocumentLoadEvent();this._hideViewBookmark();const{container:e}=this.appConfig.errorWrapper;e.hidden=!0;if(!this.pdfLoadingTask)return;if(this.pdfDocument?.annotationStorage.size>0&&this._annotationStorageModified)try{await this.save()}catch(e){}const t=[];t.push(this.pdfLoadingTask.destroy());this.pdfLoadingTask=null;if(this.pdfDocument){this.pdfDocument=null;this.pdfThumbnailViewer.setDocument(null);this.pdfViewer.setDocument(null);this.pdfLinkService.setDocument(null);this.pdfDocumentProperties.setDocument(null)}this.pdfLinkService.externalLinkEnabled=!0;this.store=null;this.isInitialViewSet=!1;this.downloadComplete=!1;this.url="";this.baseUrl="";this._downloadUrl="";this.documentInfo=null;this.metadata=null;this._contentDispositionFilename=null;this._contentLength=null;this._saveInProgress=!1;this._docStats=null;this._cancelIdleCallbacks();t.push(this.pdfScriptingManager.destroyPromise);this.pdfSidebar.reset();this.pdfOutlineViewer.reset();this.pdfAttachmentViewer.reset();this.pdfLayerViewer.reset();this.pdfHistory?.reset();this.findBar?.reset();this.toolbar.reset();this.secondaryToolbar.reset();this._PDFBug?.cleanup();await Promise.all(t)},async open(e,t){window.adjacentPagesLoader=void 0;window.ngxZone.runOutsideAngular((async()=>{this.pdfLoadingTask&&await this.close();const i=r.AppOptions.getAll(r.OptionKind.WORKER);for(const e in i)s.GlobalWorkerOptions[e]=i[e];const n=Object.create(null);if("string"==typeof e){this.setTitleUsingUrl(e,e);n.url=e}else if(e&&"byteLength"in e)n.data=e;else if(e.url&&e.originalUrl){this.setTitleUsingUrl(e.originalUrl,e.url);n.url=e.url}const o=r.AppOptions.getAll(r.OptionKind.API);for(const e in o){let t=o[e];n[e]=t}if(t)for(const e in t)n[e]=t[e];const a=(0,s.getDocument)(n);this.pdfLoadingTask=a;a.onPassword=(e,t)=>{this.pdfLinkService.externalLinkEnabled=!1;this.passwordPrompt.setUpdateCallback(e,t);this.passwordPrompt.open()};a.onProgress=({loaded:e,total:t})=>{this.progress(e/t);this.eventBus.dispatch("progress",{source:this,type:"load",total:t,loaded:e,percent:100*e/t})};a.onUnsupportedFeature=this.fallback.bind(this);this.loadingBar.show();return a.promise.then((e=>{this.load(e)}),(e=>{if(a!==this.pdfLoadingTask)return;let t="loading_error";e instanceof s.InvalidPDFException?t="invalid_file_error":e instanceof s.MissingPDFException?t="missing_file_error":e instanceof s.UnexpectedResponseException&&(t="unexpected_response_error");N.onError&&N.onError(e);return this.l10n.get(t).then((t=>{this._documentError(t,{message:e?.message});throw e}))}))}))},_ensureDownloadComplete(){if(!this.pdfDocument||!this.downloadComplete)throw new Error("PDF document not downloaded.")},async download(){const e=this._downloadUrl,t=this._docFilename;try{this._ensureDownloadComplete();const i=await this.pdfDocument.getData(),n=new Blob([i],{type:"application/pdf"});await this.downloadManager.download(n,e,t)}catch(i){await this.downloadManager.downloadUrl(e,t)}},async save(){if(this._saveInProgress)return;this._saveInProgress=!0;await this.pdfScriptingManager.dispatchWillSave();const e=this._downloadUrl,t=this._docFilename;try{this._ensureDownloadComplete();const i=await this.pdfDocument.saveDocument(),n=new Blob([i],{type:"application/pdf"});await this.downloadManager.download(n,e,t)}catch(e){Window.ngxConsole.error(`Error when saving the document: ${e.message}`);await this.download()}finally{await this.pdfScriptingManager.dispatchDidSave();this._saveInProgress=!1}this.pdfDocument?.annotationStorage.hasAnnotationEditors&&this.externalServices.reportTelemetry({type:"editing",data:{type:"save"}})},downloadOrSave(){this.pdfDocument?.annotationStorage.size>0?this.save():this.download()},fallback(e){this.externalServices.reportTelemetry({type:"unsupportedFeature",featureId:e})},_documentError(e,t=null){this._unblockDocumentLoadEvent();this._otherError(e,t);this.eventBus.dispatch("documenterror",{source:this,message:e,reason:t?.message??null})},_otherError(e,t=null){const i=[this.l10n.get("error_version_info",{version:s.version||"?",build:s.build||"?"})];if(t){i.push(this.l10n.get("error_message",{message:t.message}));if(t.stack)i.push(this.l10n.get("error_stack",{stack:t.stack}));else{t.filename&&i.push(this.l10n.get("error_file",{file:t.filename}));t.lineNumber&&i.push(this.l10n.get("error_line",{line:t.lineNumber}))}}const r=this.appConfig.errorWrapper,o=r.container;o.hidden=!1;r.errorMessage.textContent=e;const a=r.closeButton;a.onclick=function(){o.hidden=!0};const l=r.errorMoreInfo,h=r.moreInfoButton,d=r.lessInfoButton;h.onclick=function(){l.hidden=!1;h.hidden=!0;d.hidden=!1;l.style.height=l.scrollHeight+"px"};d.onclick=function(){l.hidden=!0;h.hidden=!1;d.hidden=!0};h.oncontextmenu=n.noContextMenuHandler;d.oncontextmenu=n.noContextMenuHandler;a.oncontextmenu=n.noContextMenuHandler;h.hidden=!1;d.hidden=!0;Promise.all(i).then((e=>{l.value=e.join("\n")}))},progress(e){if(this.downloadComplete)return;const t=Math.round(100*e);if(t<=this.loadingBar.percent)return;this.loadingBar.percent=t;if((this.pdfDocument?.loadingParams.disableAutoFetch??r.AppOptions.get("disableAutoFetch"))&&!isNaN(t)){if(this.disableAutoFetchLoadingBarTimeout){clearTimeout(this.disableAutoFetchLoadingBarTimeout);this.disableAutoFetchLoadingBarTimeout=null}this.loadingBar.show();this.disableAutoFetchLoadingBarTimeout=setTimeout((()=>{this.loadingBar.hide();this.disableAutoFetchLoadingBarTimeout=null}),5e3)}},load(e){this.pdfDocument=e;e.getDownloadInfo().then((({length:e})=>{this._contentLength=e;this.downloadComplete=!0;this.loadingBar.hide();l.then((()=>{this.eventBus.dispatch("documentloaded",{source:this})}))}));const t=e.getPageLayout().catch((function(){})),i=e.getPageMode().catch((function(){})),s=e.getOpenAction().catch((function(){}));this.toolbar.setPagesCount(e.numPages,!1);this.secondaryToolbar.setPagesCount(e.numPages);let o;o=null;this.pdfLinkService.setDocument(e,null);this.pdfDocumentProperties.setDocument(e);const a=this.pdfViewer;a.setDocument(e);const{firstPagePromise:l,onePageRendered:h,pagesPromise:d}=a;this.pdfThumbnailViewer.setDocument(e);const c=(this.store=new L.ViewHistory(e.fingerprints[0])).getMultiple({page:null,zoom:n.DEFAULT_SCALE_VALUE,scrollLeft:"0",scrollTop:"0",rotation:null,sidebarView:n.SidebarView.UNKNOWN,scrollMode:n.ScrollMode.UNKNOWN,spreadMode:n.SpreadMode.UNKNOWN}).catch((()=>Object.create(null)));l.then((o=>{this.loadingBar.setWidth(this.appConfig.viewerContainer);this._initializeAnnotationStorageCallbacks(e);Promise.all([n.animationStarted,c,t,i,s]).then((async([t,i,s,o,l])=>{const h=r.AppOptions.get("viewOnLoad");this._initializePdfHistory({fingerprint:e.fingerprints[0],viewOnLoad:h,initialDest:l?.dest});const c=this.initialBookmark,u=r.AppOptions.get("defaultZoomValue");let g=u?`zoom=${u}`:null,p=null,f=r.AppOptions.get("sidebarViewOnLoad"),m=r.AppOptions.get("scrollModeOnLoad"),w=r.AppOptions.get("spreadModeOnLoad");if(i.page&&h!==M){g=`page=${i.page}&zoom=${u||i.zoom},${i.scrollLeft},${i.scrollTop}`;p=parseInt(i.rotation,10);f===n.SidebarView.UNKNOWN&&(f=0|i.sidebarView);m===n.ScrollMode.UNKNOWN&&(m=0|i.scrollMode);w===n.SpreadMode.UNKNOWN&&(w=0|i.spreadMode)}o&&f===n.SidebarView.UNKNOWN&&(f=(0,n.apiPageModeToSidebarView)(o));if(s&&m===n.ScrollMode.UNKNOWN&&w===n.SpreadMode.UNKNOWN){w=(0,n.apiPageLayoutToViewerModes)(s).spreadMode}this.setInitialView(g,{rotation:p,sidebarView:f,scrollMode:m,spreadMode:w});this.eventBus.dispatch("documentinit",{source:this});this.isViewerEmbedded||a.focus();await Promise.race([d,new Promise((e=>{setTimeout(e,10)}))]);if((c||g)&&!a.hasEqualPageSizes){this.initialBookmark=c;a.currentScaleValue=a.currentScaleValue;this.setInitialView(g)}})).catch((()=>{this.setInitialView()})).then((function(){a.update()}))}));d.then((()=>{this._unblockDocumentLoadEvent();this._initializeAutoPrint(e,s)}),(e=>{N.onError&&N.onError(e);this.l10n.get("loading_error").then((t=>{this._documentError(t,{message:e?.message})}))}));h.then((t=>{this.externalServices.reportTelemetry({type:"pageInfo",timestamp:t.timestamp});e.getOutline().then((t=>{e===this.pdfDocument&&this.pdfOutlineViewer.render({outline:t,pdfDocument:e})}));e.getAttachments().then((t=>{e===this.pdfDocument&&this.pdfAttachmentViewer.render({attachments:t})}));a.optionalContentConfigPromise.then((t=>{e===this.pdfDocument&&this.pdfLayerViewer.render({optionalContentConfig:t,pdfDocument:e})}));if("requestIdleCallback"in window){const t=window.requestIdleCallback((()=>{this._collectTelemetry(e);this._idleCallbacks.delete(t)}),{timeout:1e3});this._idleCallbacks.add(t)}}));this._initializePageLabels(e);this._initializeMetadata(e)},async _scriptingDocProperties(e){if(!this.documentInfo){await new Promise((e=>{this.eventBus._on("metadataloaded",e,{once:!0})}));if(e!==this.pdfDocument)return null}if(!this._contentLength){await new Promise((e=>{this.eventBus._on("documentloaded",e,{once:!0})}));if(e!==this.pdfDocument)return null}return{...this.documentInfo,baseURL:this.baseUrl,filesize:this._contentLength,filename:this._docFilename,metadata:this.metadata?.getRaw(),authors:this.metadata?.get("dc:creator"),numPages:this.pagesCount,URL:this.url}},async _collectTelemetry(e){const t=await this.pdfDocument.getMarkInfo();if(e!==this.pdfDocument)return;const i=t?.Marked||!1;this.externalServices.reportTelemetry({type:"tagged",tagged:i})},async _initializeAutoPrint(e,t){const[i,r]=await Promise.all([t,this.pdfViewer.enableScripting?null:e.getJavaScript()]);if(e!==this.pdfDocument)return;let o=!1;"Print"===i?.action&&(o=!0);if(r){r.some((e=>{if(!e)return!1;Window.ngxConsole.warn("Warning: JavaScript support is not enabled");this.fallback(s.UNSUPPORTED_FEATURES.javaScript);return!0}));if(!o)for(const e of r)if(e&&n.AutoPrintRegExp.test(e)){o=!0;break}}o&&this.triggerPrinting()},async _initializeMetadata(e){const{info:t,metadata:i,contentDispositionFilename:n,contentLength:r}=await e.getMetadata();if(e!==this.pdfDocument)return;this.documentInfo=t;this.metadata=i;this._contentDispositionFilename??=n;this._contentLength??=r;const o=window.PDFViewerApplicationOptions;if(!o||o.get("verbosity")>0){Window.ngxConsole.log("PDF viewer: ngx-extended-pdf-viewer running on pdf.js "+(window["pdfjs-dist/build/pdf"]?window["pdfjs-dist/build/pdf"].version:" developer version (?)"));Window.ngxConsole.log(`PDF ${e.fingerprints[0]} [${t.PDFFormatVersion} ${(t.Producer||"-").trim()} / ${(t.Creator||"-").trim()}] (PDF.js: ${s.version||"-"}`+(this.pdfViewer.enableWebGL?" [WebGL]":"")+") modified by ngx-extended-pdf-viewer)")}let a=t?.Title;const l=i?.get("dc:title");l&&("Untitled"===l||/[\uFFF0-\uFFFF]/g.test(l)||(a=l));a?this.setTitle(`${a} - ${this._contentDispositionFilename||document.title}`):this._contentDispositionFilename&&this.setTitle(this._contentDispositionFilename);if(!t.IsXFAPresent||t.IsAcroFormPresent||e.isPureXfa){if((t.IsAcroFormPresent||t.IsXFAPresent)&&!this.pdfViewer.renderForms){Window.ngxConsole.warn("Warning: Interactive form support is not enabled");this.fallback(s.UNSUPPORTED_FEATURES.forms)}}else{e.loadingParams.enableXfa?Window.ngxConsole.warn("Warning: XFA Foreground documents are not supported"):Window.ngxConsole.warn("Warning: XFA support is not enabled");this.fallback(s.UNSUPPORTED_FEATURES.forms)}if(t.IsSignaturesPresent){Window.ngxConsole.warn("Warning: Digital signatures validation is not supported");this.fallback(s.UNSUPPORTED_FEATURES.signatures)}let h="other";D.includes(t.PDFFormatVersion)&&(h=`v${t.PDFFormatVersion.replace(".","_")}`);let d="other";if(t.Producer){const e=t.Producer.toLowerCase();B.some((function(t){if(!e.includes(t))return!1;d=t.replace(/[ .-]/g,"_");return!0}))}let c=null;t.IsXFAPresent?c="xfa":t.IsAcroFormPresent&&(c="acroform");this.externalServices.reportTelemetry({type:"documentInfo",version:h,generator:d,formType:c});this.eventBus.dispatch("metadataloaded",{source:this})},async _initializePageLabels(e){const t=await e.getPageLabels();if(e!==this.pdfDocument)return;if(!t||r.AppOptions.get("disablePageLabels"))return;const i=t.length;let n=0,s=0;for(let e=0;e<i;e++){const i=t[e];if(i===(e+1).toString())n++;else{if(""!==i)break;s++}}if(n>=i||s>=i)return;const{pdfViewer:o,pdfThumbnailViewer:a,toolbar:l}=this;o.setPageLabels(t);a.setPageLabels(t);l.setPagesCount(i,!0);l.setPageNumber(o.currentPageNumber,o.currentPageLabel)},_initializePdfHistory({fingerprint:e,viewOnLoad:t,initialDest:i=null}){if(this.pdfHistory){this.pdfHistory.initialize({fingerprint:e,resetHistory:t===M,updateUrl:r.AppOptions.get("historyUpdateUrl")});if(this.pdfHistory.initialBookmark){this.initialBookmark=this.pdfHistory.initialBookmark;this.initialRotation=this.pdfHistory.initialRotation}if(i&&!this.initialBookmark&&t===I){this.initialBookmark=JSON.stringify(i);this.pdfHistory.push({explicitDest:i,pageNumber:null})}}},_initializeAnnotationStorageCallbacks(e){if(e!==this.pdfDocument)return;const{annotationStorage:t}=e;t.onSetModified=()=>{window.addEventListener("beforeunload",beforeUnload);this._annotationStorageModified=!0};t.onResetModified=()=>{window.removeEventListener("beforeunload",beforeUnload);delete this._annotationStorageModified};t.onAnnotationEditor=e=>{this.externalServices.reportTelemetry({type:"editing",data:{type:e}})}},setInitialView(e,{rotation:t,sidebarView:i,scrollMode:s,spreadMode:r}={}){const setRotation=e=>{(0,n.isValidRotation)(e)&&(this.pdfViewer.pagesRotation=e)};this.isInitialViewSet=!0;this.pdfSidebar.setInitialView(i);((e,t)=>{(0,n.isValidScrollMode)(e)&&(this.pdfViewer.scrollMode=e);(0,n.isValidSpreadMode)(t)&&(this.pdfViewer.spreadMode=t)})(s,r);if(this.initialBookmark){setRotation(this.initialRotation);delete this.initialRotation;this.pdfLinkService.setHash(this.initialBookmark);this.initialBookmark=null}else if(e){setRotation(t);this.pdfLinkService.setHash(e)}this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber,this.pdfViewer.currentPageLabel);this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);if(!this.pdfViewer.currentScaleValue){const e=PDFViewerApplicationOptions.get("defaultZoomValue");e&&(this.pdfViewer.currentScaleValue=e)}},_cleanup(){if(this.pdfDocument){this.pdfViewer.cleanup();this.pdfThumbnailViewer.cleanup();this.pdfDocument.cleanup(this.pdfViewer.renderer===n.RendererType.SVG)}},forceRendering(){this.pdfRenderingQueue.printing=!!this.printService;this.pdfRenderingQueue.isThumbnailViewEnabled=this.pdfSidebar.visibleView===n.SidebarView.THUMBS;this.pdfRenderingQueue.renderHighestPriority()},beforePrint(){this._printAnnotationStoragePromise=this.pdfScriptingManager.dispatchWillPrint().catch((()=>{})).then((()=>this.pdfDocument?.annotationStorage.print));if(this.printService)return;if(!this.supportsPrinting){this.l10n.get("printing_not_supported").then((e=>{this._otherError(e)}));return}if(!this.pdfViewer.pageViewsReady){this.l10n.get("printing_not_ready").then((e=>{window.alert(e)}));return}const e=this.pdfViewer.getPagesOverview(),t=this.appConfig.printContainer,i=r.AppOptions.get("printResolution"),n=this.pdfViewer.optionalContentConfigPromise,s=R.instance.createPrintService(this.pdfDocument,e,t,i,n,this._printAnnotationStoragePromise,this.l10n,this.pdfViewer.eventBus);this.printService=s;this.forceRendering();s.layout();this.externalServices.reportTelemetry({type:"print"});this.pdfDocument?.annotationStorage.hasAnnotationEditors&&this.externalServices.reportTelemetry({type:"editing",data:{type:"print"}})},afterPrint(){if(this._printAnnotationStoragePromise){this._printAnnotationStoragePromise.then((()=>{this.pdfScriptingManager.dispatchDidPrint()}));this._printAnnotationStoragePromise=null}if(this.printService){this.printService.destroy();this.printService=null;this.pdfDocument?.annotationStorage.resetModified()}this.forceRendering()},rotatePages(e){this.pdfViewer.pagesRotation+=e},requestPresentationMode(){this.pdfPresentationMode?.request()},triggerPrinting(){this.supportsPrinting&&window.printPDF()},bindEvents(){const{eventBus:e,_boundEvents:t}=this;t.beforePrint=this.beforePrint.bind(this);t.afterPrint=this.afterPrint.bind(this);e._on("resize",webViewerResize);e._on("hashchange",webViewerHashchange);e._on("beforeprint",t.beforePrint);e._on("afterprint",t.afterPrint);e._on("pagerendered",webViewerPageRendered);e._on("updateviewarea",webViewerUpdateViewarea);e._on("pagechanging",webViewerPageChanging);e._on("scalechanging",webViewerScaleChanging);e._on("rotationchanging",webViewerRotationChanging);e._on("sidebarviewchanged",webViewerSidebarViewChanged);e._on("pagemode",webViewerPageMode);e._on("namedaction",webViewerNamedAction);e._on("presentationmodechanged",webViewerPresentationModeChanged);e._on("presentationmode",webViewerPresentationMode);e._on("switchannotationeditormode",webViewerSwitchAnnotationEditorMode);e._on("switchannotationeditorparams",webViewerSwitchAnnotationEditorParams);e._on("print",webViewerPrint);e._on("download",webViewerDownload);e._on("firstpage",webViewerFirstPage);e._on("lastpage",webViewerLastPage);e._on("nextpage",webViewerNextPage);e._on("previouspage",webViewerPreviousPage);e._on("zoomin",webViewerZoomIn);e._on("zoomout",webViewerZoomOut);e._on("zoomreset",webViewerZoomReset);e._on("pagenumberchanged",webViewerPageNumberChanged);e._on("scalechanged",webViewerScaleChanged);e._on("rotatecw",webViewerRotateCw);e._on("rotateccw",webViewerRotateCcw);e._on("optionalcontentconfig",webViewerOptionalContentConfig);e._on("switchscrollmode",webViewerSwitchScrollMode);e._on("scrollmodechanged",webViewerScrollModeChanged);e._on("switchspreadmode",webViewerSwitchSpreadMode);e._on("spreadmodechanged",webViewerSpreadModeChanged);e._on("documentproperties",webViewerDocumentProperties);e._on("findfromurlhash",webViewerFindFromUrlHash);e._on("updatefindmatchescount",webViewerUpdateFindMatchesCount);e._on("updatefindcontrolstate",webViewerUpdateFindControlState);if(r.AppOptions.get("pdfBug")){t.reportPageStatsPDFBug=reportPageStatsPDFBug;e._on("pagerendered",t.reportPageStatsPDFBug);e._on("pagechanging",t.reportPageStatsPDFBug)}e._on("fileinputchange",webViewerFileInputChange);e._on("openfile",webViewerOpenFile)},bindWindowEvents(){const{eventBus:e,_boundEvents:t}=this;t.windowResize=()=>{e.dispatch("resize",{source:window})};t.windowHashChange=()=>{e.dispatch("hashchange",{source:window,hash:document.location.hash.substring(1)})};t.windowBeforePrint=()=>{e.dispatch("beforeprint",{source:window})};t.windowAfterPrint=()=>{e.dispatch("afterprint",{source:window})};t.windowUpdateFromSandbox=t=>{e.dispatch("updatefromsandbox",{source:window,detail:t.detail})};window.addEventListener("visibilitychange",webViewerVisibilityChange);window.addEventListener("wheel",webViewerWheel,{passive:!1});window.addEventListener("click",webViewerClick);window.addEventListener("keydown",webViewerKeyDown);window.addEventListener("resize",t.windowResize);window.addEventListener("hashchange",t.windowHashChange);window.addEventListener("beforeprint",t.windowBeforePrint);window.addEventListener("afterprint",t.windowAfterPrint);window.addEventListener("updatefromsandbox",t.windowUpdateFromSandbox)},unbindEvents(){const{eventBus:e,_boundEvents:t}=this;e._off("resize",webViewerResize);e._off("hashchange",webViewerHashchange);e._off("beforeprint",t.beforePrint);e._off("afterprint",t.afterPrint);e._off("pagerendered",webViewerPageRendered);e._off("updateviewarea",webViewerUpdateViewarea);e._off("pagechanging",webViewerPageChanging);e._off("scalechanging",webViewerScaleChanging);e._off("rotationchanging",webViewerRotationChanging);e._off("sidebarviewchanged",webViewerSidebarViewChanged);e._off("pagemode",webViewerPageMode);e._off("namedaction",webViewerNamedAction);e._off("presentationmodechanged",webViewerPresentationModeChanged);e._off("presentationmode",webViewerPresentationMode);e._off("print",webViewerPrint);e._off("download",webViewerDownload);e._off("firstpage",webViewerFirstPage);e._off("lastpage",webViewerLastPage);e._off("nextpage",webViewerNextPage);e._off("previouspage",webViewerPreviousPage);e._off("zoomin",webViewerZoomIn);e._off("zoomout",webViewerZoomOut);e._off("zoomreset",webViewerZoomReset);e._off("pagenumberchanged",webViewerPageNumberChanged);e._off("scalechanged",webViewerScaleChanged);e._off("rotatecw",webViewerRotateCw);e._off("rotateccw",webViewerRotateCcw);e._off("optionalcontentconfig",webViewerOptionalContentConfig);e._off("switchscrollmode",webViewerSwitchScrollMode);e._off("scrollmodechanged",webViewerScrollModeChanged);e._off("switchspreadmode",webViewerSwitchSpreadMode);e._off("spreadmodechanged",webViewerSpreadModeChanged);e._off("documentproperties",webViewerDocumentProperties);e._off("findfromurlhash",webViewerFindFromUrlHash);e._off("updatefindmatchescount",webViewerUpdateFindMatchesCount);e._off("updatefindcontrolstate",webViewerUpdateFindControlState);if(t.reportPageStatsPDFBug){e._off("pagerendered",t.reportPageStatsPDFBug);e._off("pagechanging",t.reportPageStatsPDFBug);t.reportPageStatsPDFBug=null}e._off("fileinputchange",webViewerFileInputChange);e._off("openfile",webViewerOpenFile);t.beforePrint=null;t.afterPrint=null},unbindWindowEvents(){const{_boundEvents:e}=this;window.removeEventListener("visibilitychange",webViewerVisibilityChange);window.removeEventListener("wheel",webViewerWheel,{passive:!1});window.removeEventListener("click",webViewerClick);window.removeEventListener("keydown",webViewerKeyDown);window.removeEventListener("resize",e.windowResize);window.removeEventListener("hashchange",e.windowHashChange);window.removeEventListener("beforeprint",e.windowBeforePrint);window.removeEventListener("afterprint",e.windowAfterPrint);window.removeEventListener("updatefromsandbox",e.windowUpdateFromSandbox);e.windowResize=null;e.windowHashChange=null;e.windowBeforePrint=null;e.windowAfterPrint=null;e.windowUpdateFromSandbox=null},accumulateWheelTicks(e){(this._wheelUnusedTicks>0&&e<0||this._wheelUnusedTicks<0&&e>0)&&(this._wheelUnusedTicks=0);this._wheelUnusedTicks+=e;const t=Math.sign(this._wheelUnusedTicks)*Math.floor(Math.abs(this._wheelUnusedTicks));this._wheelUnusedTicks-=t;return t},_unblockDocumentLoadEvent(){document.blockUnblockOnload?.(!1);this._unblockDocumentLoadEvent=()=>{}},_reportDocumentStatsTelemetry(){const{stats:e}=this.pdfDocument;if(e!==this._docStats){this._docStats=e;this.externalServices.reportTelemetry({type:"documentStats",stats:e})}},get scriptingReady(){return this.pdfScriptingManager.ready}};t.PDFViewerApplication=N;let V;{const e=["null","http://mozilla.github.io","https://mozilla.github.io"];V=function(t){if(t)try{const i=new URL(window.location.href).origin||"null";if(e.includes(i))return;if(new URL(t,window.location.href).origin!==i)throw new Error("file origin does not match viewer's")}catch(e){N.onError&&N.onError(e);N.l10n.get("loading_error").then((t=>{N._documentError(t,{message:e?.message})}));throw e}}}async function loadPDFBug(e){const{debuggerScriptPath:t}=e.appConfig,{PDFBug:i}=await import(t);e._PDFBug=i}function reportPageStatsPDFBug({pageNumber:e}){if(!globalThis.Stats?.enabled)return;const t=N.pdfViewer.getPageView(e-1);globalThis.Stats.add(e,t?.pdfPage?.stats)}function webViewerInitialized(){const{appConfig:e,eventBus:t}=N;let i;const s=document.location.search.substring(1);i=(0,n.parseQueryString)(s).get("file")??r.AppOptions.get("defaultUrl");V(i);const o=e.openFileInput;o.value=null;o.addEventListener("change",(function(e){const{files:i}=e.target;i&&0!==i.length&&t.dispatch("fileinputchange",{source:this,fileInput:e.target})}));e.mainContainer.addEventListener("dragover",(function(e){if(r.AppOptions.get("enableDragAndDrop")){e.preventDefault();e.dataTransfer.dropEffect="copy"===e.dataTransfer.effectAllowed?"copy":"move"}}));e.mainContainer.addEventListener("drop",(function(e){if(r.AppOptions.get("enableDragAndDrop")){e.preventDefault();const{files:t}=e.dataTransfer;if(!t||0===t.length)return;N.eventBus.dispatch("fileinputchange",{source:this,fileInput:e.dataTransfer,dropEvent:e})}}));if(!N.supportsDocumentFonts){r.AppOptions.set("disableFontFace",!0);N.l10n.get("web_fonts_disabled").then((e=>{Window.ngxConsole.warn(e)}))}if(!N.supportsPrinting){e.toolbar.print.classList.add("hidden");e.secondaryToolbar.printButton.classList.add("hidden")}if(!N.supportsFullscreen){e.toolbar.presentationModeButton.classList.add("hidden");e.secondaryToolbar.presentationModeButton.classList.add("hidden")}N.supportsIntegratedFind&&e.toolbar.viewFind.classList.add("hidden");e.mainContainer.addEventListener("transitionend",(function(e){e.target===this&&t.dispatch("resize",{source:this})}),!0);try{i?N.open(i):N._hideViewBookmark()}catch(e){N.onError&&N.onError(e);N.l10n.get("loading_error").then((t=>{N._documentError(t,e)}))}}function webViewerPageRendered({pageNumber:e,error:t}){e===N.page&&N.toolbar.updateLoadingIndicatorState(!1);if(N.pdfSidebar.visibleView===n.SidebarView.THUMBS){const t=N.pdfViewer.getPageView(e-1),i=N.pdfThumbnailViewer.getThumbnail(e-1);t&&i&&i.setImage(t)}t&&N.l10n.get("rendering_error").then((e=>{N._otherError(e,t)}));N._reportDocumentStatsTelemetry()}function webViewerPageMode({mode:e}){let t;switch(e){case"thumbs":t=n.SidebarView.THUMBS;break;case"bookmarks":case"outline":t=n.SidebarView.OUTLINE;break;case"attachments":t=n.SidebarView.ATTACHMENTS;break;case"layers":t=n.SidebarView.LAYERS;break;case"none":t=n.SidebarView.NONE;break;default:Window.ngxConsole.error('Invalid "pagemode" hash parameter: '+e);return}N.pdfSidebar.switchView(t,!0)}function webViewerNamedAction(e){switch(e.action){case"GoToPage":N.appConfig.toolbar.pageNumber.select();break;case"Find":N.supportsIntegratedFind||N.findBar.toggle();break;case"Print":N.triggerPrinting();break;case"SaveAs":N.downloadOrSave()}}function webViewerPresentationModeChanged(e){N.pdfViewer.presentationModeState=e.state}function webViewerSidebarViewChanged({view:e}){N.pdfRenderingQueue.isThumbnailViewEnabled=e===n.SidebarView.THUMBS;N.isInitialViewSet&&N.store?.set("sidebarView",e).catch((()=>{}))}function webViewerUpdateViewarea({location:e}){if(N.isInitialViewSet){const t={};void 0===e.pageNumber&&null===e.pageNumber||(t.page=e.pageNumber);e.scale&&(t.zoom=e.scale);e.left&&(t.scrollLeft=e.left);e.top&&(t.scrollTop=e.top);void 0===e.rotation&&null===e.rotation||(t.rotation=e.rotation);N.store?.setMultiple(t).catch((()=>{}))}const t=N.pdfLinkService.getAnchorUrl(e.pdfOpenParams);N.appConfig.toolbar.viewBookmark.href=t;N.appConfig.secondaryToolbar.viewBookmarkButton.href=t;const i=N.pdfViewer.getPageView(N.page-1)?.renderingState!==n.RenderingStates.FINISHED;N.toolbar.updateLoadingIndicatorState(i)}function webViewerScrollModeChanged(e){N.isInitialViewSet&&N.store?.set("scrollMode",e.mode).catch((()=>{}))}function webViewerSpreadModeChanged(e){N.isInitialViewSet&&N.store?.set("spreadMode",e.mode).catch((()=>{}))}function webViewerResize(){const{pdfDocument:e,pdfViewer:t}=N;t.updateContainerHeightCss();if(!e)return;const i=t.currentScaleValue;"auto"!==i&&"page-fit"!==i&&"page-width"!==i||(t.currentScaleValue=i);t.update()}function webViewerHashchange(e){const t=e.hash;t&&(N.isInitialViewSet?N.pdfHistory?.popStateInProgress||N.pdfLinkService.setHash(t):N.initialBookmark=t)}var webViewerFileInputChange=function(e){if(N.pdfViewer?.isInPresentationMode)return;const t=e.fileInput.files[0];let i=URL.createObjectURL(t);t.name&&(i={url:i,originalUrl:t.name});N.open(i);window.setNgxExtendedPdfViewerSource&&window.setNgxExtendedPdfViewerSource(t.name?t.name:i)},webViewerOpenFile=function(e){N.appConfig.openFileInput.click()};function webViewerPresentationMode(){N.requestPresentationMode()}function webViewerSwitchAnnotationEditorMode(e){N.pdfViewer.annotationEditorMode=e.mode}function webViewerSwitchAnnotationEditorParams(e){N.pdfViewer.annotationEditorParams=e}function webViewerPrint(){N.triggerPrinting()}function webViewerDownload(){N.downloadOrSave()}function webViewerFirstPage(){N.pdfDocument&&(N.page=1)}function webViewerLastPage(){N.pdfDocument&&(N.page=N.pagesCount)}function webViewerNextPage(){N.pdfViewer.nextPage()}function webViewerPreviousPage(){N.pdfViewer.previousPage()}function webViewerZoomIn(){N.zoomIn()}function webViewerZoomOut(){N.zoomOut()}function webViewerZoomReset(){N.zoomReset()}function webViewerPageNumberChanged(e){const t=N.pdfViewer;""!==e.value&&N.pdfLinkService.goToPage(e.value);e.value!==t.currentPageNumber.toString()&&e.value!==t.currentPageLabel&&N.toolbar.setPageNumber(t.currentPageNumber,t.currentPageLabel)}function webViewerScaleChanged(e){N.pdfViewer.currentScaleValue=e.value}function webViewerRotateCw(){N.rotatePages(90)}function webViewerRotateCcw(){N.rotatePages(-90)}function webViewerOptionalContentConfig(e){N.pdfViewer.optionalContentConfigPromise=e.promise}function webViewerSwitchScrollMode(e){N.pdfViewer.scrollMode=e.mode}function webViewerSwitchSpreadMode(e){N.pdfViewer.spreadMode=e.mode}function webViewerDocumentProperties(){N.pdfDocumentProperties.open()}function webViewerFindFromUrlHash(e){N.eventBus.dispatch("find",{source:e.source,type:"",query:e.query,phraseSearch:e.phraseSearch,caseSensitive:!1,entireWord:!1,ignoreAccents:!1,fuzzySearch:!1,highlightAll:!0,findPrevious:!1,matchDiacritics:!0})}function webViewerUpdateFindMatchesCount({matchesCount:e}){N.supportsIntegratedFind?N.externalServices.updateFindMatchesCount(e):N.findBar.updateResultsCount(e)}function webViewerUpdateFindControlState({state:e,previous:t,matchesCount:i,rawQuery:n}){N.supportsIntegratedFind?N.externalServices.updateFindControlState({result:e,findPrevious:t,matchesCount:i,rawQuery:n}):N.findBar.updateUIState(e,t,i)}function webViewerScaleChanging(e){N.toolbar.setPageScale(e.presetValue,e.scale);N.pdfViewer.update()}function webViewerRotationChanging(e){N.pdfThumbnailViewer.pagesRotation=e.pagesRotation;N.forceRendering();N.pdfViewer.currentPageNumber=e.pageNumber}function webViewerPageChanging({pageNumber:e,pageLabel:t}){N.toolbar.setPageNumber(e,t);N.secondaryToolbar.setPageNumber(e);N.pdfSidebar.visibleView===n.SidebarView.THUMBS&&N.pdfThumbnailViewer.scrollThumbnailIntoView(e);const i=document.getElementById("pageNumber");if(i){const e=new CustomEvent("page-change");i.dispatchEvent(e)}}function webViewerVisibilityChange(e){"visible"===document.visibilityState&&setZoomDisabledTimeout()}let O=null;function setZoomDisabledTimeout(){O&&clearTimeout(O);O=setTimeout((function(){O=null}),1e3)}function webViewerWheel(e){const t=document.getElementById("viewerContainer");if(t.parentNode.querySelector(":hover")!==t)return;const{pdfViewer:i,supportedMouseWheelZoomModifierKeys:s}=N;if(i.isInPresentationMode)return;const o=(e.ctrlKey?1:0)|(e.altKey?2:0)|(e.shiftKey?4:0)|(e.metaKey?8:0);if(window.isKeyIgnored&&window.isKeyIgnored(o,"WHEEL"))return;const a=r.AppOptions.get("wheelAction");if(e.ctrlKey&&s.ctrlKey||e.metaKey&&s.metaKey?"zoom"!==a:"zoom"===a){e.preventDefault();if(O||"hidden"===document.visibilityState)return;const t=e.deltaMode,s=(0,n.normalizeWheelEventDirection)(e),r=i.currentScale;let o=0;if(t===WheelEvent.DOM_DELTA_LINE||t===WheelEvent.DOM_DELTA_PAGE)o=Math.abs(s)>=1?Math.sign(s):N.accumulateWheelTicks(s);else{const e=30;o=N.accumulateWheelTicks(s/e)}o<0?N.zoomOut(-o):o>0&&N.zoomIn(o);const a=i.currentScale;if(r!==a){const t=a/r-1,n=i.container.getBoundingClientRect(),s=e.clientX-n.left,o=e.clientY-n.top;i.container.scrollLeft+=s*t;i.container.scrollTop+=o*t}}else setZoomDisabledTimeout()}function webViewerClick(e){if(!N.secondaryToolbar.isOpen)return;const t=N.appConfig;if(N.pdfViewer.containsElement(e.target)||t.toolbar.container.contains(e.target)&&e.target!==t.secondaryToolbar.toggleButton){if(e.target&&e.target.parentElement===t.secondaryToolbar.toggleButton)return;if(e.target&&e.target.parentElement&&e.target.parentElement.parentElement===t.secondaryToolbar.toggleButton)return;N.secondaryToolbar.close()}}function webViewerKeyDown(e){if(N.overlayManager.active)return;const{eventBus:t,pdfViewer:i}=N,s=i.isInPresentationMode;let r=!1,o=!1;const l=(e.ctrlKey?1:0)|(e.altKey?2:0)|(e.shiftKey?4:0)|(e.metaKey?8:0);if(window.isKeyIgnored&&window.isKeyIgnored(l,e.keyCode))return;if(1===l||8===l||5===l||12===l)switch(e.keyCode){case 70:if(!N.supportsIntegratedFind&&!e.shiftKey){N.findBar.open();r=!0}break;case 71:if(!N.supportsIntegratedFind){const{state:e}=N.findController;if(e){const i=Object.assign(Object.create(null),e,{source:window,type:"again",findPrevious:5===l||12===l});t.dispatch("find",i)}r=!0}break;case 61:case 107:case 187:case 171:s||N.zoomIn();r=!0;break;case 173:case 109:case 189:s||N.zoomOut();r=!0;break;case 48:case 96:if(!s){setTimeout((function(){N.zoomReset()}));r=!1}break;case 38:if(s||N.page>1){N.page=1;r=!0;o=!0}break;case 40:if(s||N.page<N.pagesCount){N.page=N.pagesCount;r=!0;o=!0}}if(1===l||8===l)switch(e.keyCode){case 83:t.dispatch("download",{source:window});r=!0;break;case 79:t.dispatch("openfile",{source:window});r=!0}if(3===l||10===l)switch(e.keyCode){case 80:N.requestPresentationMode();r=!0;break;ca