text: /**
   * skylark-pdfjs-viewer - A version of video.js that ported to running on skylarkjs.
   * @author Hudaokeji Co.,Ltd
   * @version v0.9.0
   * @link www.skylarkjs.org
   * @license MIT
   */
  define(["skylark-pdfjs-display","./pdfjs_dev","./ui_utils","./pdf_rendering_queue","./annotation_layer_builder","./pdf_page_view","./pdf_link_service","./text_layer_builder"],function(e,t,i,s,n,r,a,o){const{createPromiseCapability:h,version:l}=e,{CSS_UNITS:c,DEFAULT_SCALE:u,DEFAULT_SCALE_VALUE:g,getVisibleElements:d,isPortraitOrientation:p,isValidRotation:_,isValidScrollMode:f,isValidSpreadMode:m,MAX_AUTO_SCALE:P,moveToEndOfArray:b,NullL10n:v,PresentationModeState:w,RendererType:S,SCROLLBAR_PADDING:C,scrollIntoView:N,ScrollMode:M,SpreadMode:L,TextLayerMode:V,UNKNOWN_SCALE:y,VERTICAL_PADDING:D,watchScroll:R}=i,{PDFRenderingQueue:I,RenderingStates:E}=s,{AnnotationLayerBuilder:A}=n,{PDFPageView:B}=r,{SimpleLinkService:O}=a,{TextLayerBuilder:x}=o,k=10;class F{constructor(e){if(this.constructor===F)throw new Error("Cannot initialize BaseViewer.");const i=void 0!==t?t.eval("BUNDLE_VERSION"):null;if(l!==i)throw new Error(`The API version "${l}" does not match the Viewer version "${i}".`);if(this._name=this.constructor.name,this.container=e.container,this.viewer=e.viewer||e.container.firstElementChild,void 0===t||t.test("!PRODUCTION || GENERIC")){if(!this.container||"DIV"!==this.container.tagName.toUpperCase()||!this.viewer||"DIV"!==this.viewer.tagName.toUpperCase())throw new Error("Invalid `container` and/or `viewer` option.");if("absolute"!==getComputedStyle(this.container).position)throw new Error("The `container` must be absolutely positioned.")}this.eventBus=e.eventBus,this.linkService=e.linkService||new O,this.downloadManager=e.downloadManager||null,this.findController=e.findController||null,this.removePageBorders=e.removePageBorders||!1,this.textLayerMode=Number.isInteger(e.textLayerMode)?e.textLayerMode:V.ENABLE,this.imageResourcesPath=e.imageResourcesPath||"",this.renderInteractiveForms="boolean"!=typeof e.renderInteractiveForms||e.renderInteractiveForms,this.enablePrintAutoRotate=e.enablePrintAutoRotate||!1,this.renderer=e.renderer||S.CANVAS,this.enableWebGL=e.enableWebGL||!1,this.useOnlyCssZoom=e.useOnlyCssZoom||!1,this.maxCanvasPixels=e.maxCanvasPixels,this.l10n=e.l10n||v,this.enableScripting=e.enableScripting||!1,this._mouseState=e.mouseState||null,this.defaultRenderingQueue=!e.renderingQueue,this.defaultRenderingQueue?(this.renderingQueue=new I,this.renderingQueue.setViewer(this)):this.renderingQueue=e.renderingQueue,this.scroll=R(this.container,this._scrollUpdate.bind(this)),this.presentationModeState=w.UNKNOWN,this._onBeforeDraw=this._onAfterDraw=null,this._resetView(),this.removePageBorders&&this.viewer.classList.add("removePageBorders"),Promise.resolve().then(()=>{this.eventBus.dispatch("baseviewerinit",{source:this})})}get pagesCount(){return this._pages.length}getPageView(e){return this._pages[e]}get pageViewsReady(){return!!this._pagesCapability.settled&&this._pages.every(function(e){return e&&e.pdfPage})}get currentPageNumber(){return this._currentPageNumber}set currentPageNumber(e){if(!Number.isInteger(e))throw new Error("Invalid page number.");this.pdfDocument&&(this._setCurrentPageNumber(e,!0)||console.error(`${this._name}.currentPageNumber: "${e}" is not a valid page.`))}_setCurrentPageNumber(e,t=!1){if(this._currentPageNumber===e)return t&&this._resetCurrentPageView(),!0;if(!(0<e&&e<=this.pagesCount))return!1;const i=this._currentPageNumber;return this._currentPageNumber=e,this.eventBus.dispatch("pagechanging",{source:this,pageNumber:e,pageLabel:this._pageLabels&&this._pageLabels[e-1],previous:i}),t&&this._resetCurrentPageView(),!0}get currentPageLabel(){return this._pageLabels&&this._pageLabels[this._currentPageNumber-1]}set currentPageLabel(e){if(!this.pdfDocument)return;let t=0|e;if(this._pageLabels){const i=this._pageLabels.indexOf(e);i>=0&&(t=i+1)}this._setCurrentPageNumber(t,!0)||console.error(`${this._name}.currentPageLabel: "${e}" is not a valid page.`)}get currentScale(){return this._currentScale!==y?this._currentScale:u}set currentScale(e){if(isNaN(e))throw new Error("Invalid numeric scale.");this.pdfDocument&&this._setScale(e,!1)}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(e){this.pdfDocument&&this._setScale(e,!1)}get pagesRotation(){return this._pagesRotation}set pagesRotation(e){if(!_(e))throw new Error("Invalid pages rotation angle.");if(!this.pdfDocument)return;if(this._pagesRotation===e)return;this._pagesRotation=e;const t=this._currentPageNumber;for(let t=0,i=this._pages.length;t<i;t++){const i=this._pages[t];i.update(i.scale,e)}this._currentScaleValue&&this._setScale(this._currentScaleValue,!0),this.eventBus.dispatch("rotationchanging",{source:this,pagesRotation:e,pageNumber:t}),this.defaultRenderingQueue&&this.update()}get firstPagePromise(){return this.pdfDocument?this._firstPageCapability.promise:null}get onePageRendered(){return this.pdfDocument?this._onePageRenderedCapability.promise:null}get pagesPromise(){return this.pdfDocument?this._pagesCapability.promise:null}get _viewerElement(){throw new Error("Not implemented: _viewerElement")}_onePageRenderedOrForceFetch(){return this.container.offsetParent&&0!==this._getVisiblePages().views.length?this._onePageRenderedCapability.promise:Promise.resolve()}setDocument(e){if(this.pdfDocument&&(this.eventBus.dispatch("pagesdestroy",{source:this}),this._cancelRendering(),this._resetView(),this.findController&&this.findController.setDocument(null)),this.pdfDocument=e,!e)return;const t=e.numPages,i=e.getPage(1),s=e.getOptionalContentConfig();this._pagesCapability.promise.then(()=>{this.eventBus.dispatch("pagesloaded",{source:this,pagesCount:t})}),this._onBeforeDraw=(e=>{const t=this._pages[e.pageNumber-1];t&&this._buffer.push(t)}),this.eventBus._on("pagerender",this._onBeforeDraw),this._onAfterDraw=(e=>{e.cssTransform||this._onePageRenderedCapability.settled||(this._onePageRenderedCapability.resolve(),this.eventBus._off("pagerendered",this._onAfterDraw),this._onAfterDraw=null)}),this.eventBus._on("pagerendered",this._onAfterDraw),i.then(i=>{this._firstPageCapability.resolve(i),this._optionalContentConfigPromise=s;const n=this.currentScale,r=i.getViewport({scale:n*c}),a=this.textLayerMode!==V.DISABLE?this:null;for(let e=1;e<=t;++e){const t=new B({container:this._viewerElement,eventBus:this.eventBus,id:e,scale:n,defaultViewport:r.clone(),optionalContentConfigPromise:s,renderingQueue:this.renderingQueue,textLayerFactory:a,textLayerMode:this.textLayerMode,annotationLayerFactory:this,imageResourcesPath:this.imageResourcesPath,renderInteractiveForms:this.renderInteractiveForms,renderer:this.renderer,enableWebGL:this.enableWebGL,useOnlyCssZoom:this.useOnlyCssZoom,maxCanvasPixels:this.maxCanvasPixels,l10n:this.l10n,enableScripting:this.enableScripting});this._pages.push(t)}const o=this._pages[0];o&&(o.setPdfPage(i),this.linkService.cachePageRef(1,i.ref)),this._spreadMode!==L.NONE&&this._updateSpreadMode(),this._onePageRenderedOrForceFetch().then(()=>{if(this.findController&&this.findController.setDocument(e),e.loadingParams.disableAutoFetch||t>7500)return void this._pagesCapability.resolve();let i=t-1;if(i<=0)this._pagesCapability.resolve();else for(let s=2;s<=t;++s)e.getPage(s).then(e=>{const t=this._pages[s-1];t.pdfPage||t.setPdfPage(e),this.linkService.cachePageRef(s,e.ref),0==--i&&this._pagesCapability.resolve()},e=>{console.error(`Unable to get page ${s} to initialize viewer`,e),0==--i&&this._pagesCapability.resolve()})}),this.eventBus.dispatch("pagesinit",{source:this}),this.defaultRenderingQueue&&this.update()}).catch(e=>{console.error("Unable to initialize viewer",e)})}setPageLabels(e){if(this.pdfDocument){e?Array.isArray(e)&&this.pdfDocument.numPages===e.length?this._pageLabels=e:(this._pageLabels=null,console.error(`${this._name}.setPageLabels: Invalid page labels.`)):this._pageLabels=null;for(let e=0,t=this._pages.length;e<t;e++){const t=this._pages[e],i=this._pageLabels&&this._pageLabels[e];t.setPageLabel(i)}}}_resetView(){this._pages=[],this._currentPageNumber=1,this._currentScale=y,this._currentScaleValue=null,this._pageLabels=null,this._buffer=new function(e){const t=[];this.push=function(i){const s=t.indexOf(i);s>=0&&t.splice(s,1),t.push(i),t.length>e&&t.shift().destroy()},this.resize=function(i,s){if(e=i,s){const e=new Set;for(let t=0,i=s.length;t<i;++t)e.add(s[t].id);b(t,function(t){return e.has(t.id)})}for(;t.length>e;)t.shift().destroy()},this.has=function(e){return t.includes(e)}}(k),this._location=null,this._pagesRotation=0,this._optionalContentConfigPromise=null,this._pagesRequests=new WeakMap,this._firstPageCapability=h(),this._onePageRenderedCapability=h(),this._pagesCapability=h(),this._scrollMode=M.VERTICAL,this._spreadMode=L.NONE,this._onBeforeDraw&&(this.eventBus._off("pagerender",this._onBeforeDraw),this._onBeforeDraw=null),this._onAfterDraw&&(this.eventBus._off("pagerendered",this._onAfterDraw),this._onAfterDraw=null),this._resetScriptingEvents(),this.viewer.textContent="",this._updateScrollMode()}_scrollUpdate(){0!==this.pagesCount&&this.update()}_scrollIntoView({pageDiv:e,pageSpot:t=null,pageNumber:i=null}){N(e,t)}_setScaleUpdatePages(e,t,i=!1,s=!1){if(this._currentScaleValue=t.toString(),function(e,t){return t===e||Math.abs(t-e)<1e-15}(this._currentScale,e))s&&this.eventBus.dispatch("scalechanging",{source:this,scale:e,presetValue:t});else{for(let t=0,i=this._pages.length;t<i;t++)this._pages[t].update(e);if(this._currentScale=e,!i){let e,t=this._currentPageNumber;!this._location||this.isInPresentationMode||this.isChangingPresentationMode||(t=this._location.pageNumber,e=[null,{name:"XYZ"},this._location.left,this._location.top,null]),this.scrollPageIntoView({pageNumber:t,destArray:e,allowNegativeOffset:!0})}this.eventBus.dispatch("scalechanging",{source:this,scale:e,presetValue:s?t:void 0}),this.defaultRenderingQueue&&this.update()}}get _pageWidthScaleFactor(){return this.spreadMode===L.NONE||this.scrollMode===M.HORIZONTAL||this.isInPresentationMode?1:2}_setScale(e,t=!1){let i=parseFloat(e);if(i>0)this._setScaleUpdatePages(i,e,t,!1);else{const s=this._pages[this._currentPageNumber-1];if(!s)return;const n=this.isInPresentationMode||this.removePageBorders;let r=n?0:C,a=n?0:D;!n&&this._isScrollModeHorizontal&&([r,a]=[a,r]);const o=(this.container.clientWidth-r)/s.width*s.scale/this._pageWidthScaleFactor,h=(this.container.clientHeight-a)/s.height*s.scale;switch(e){case"page-actual":i=1;break;case"page-width":i=o;break;case"page-height":i=h;break;case"page-fit":i=Math.min(o,h);break;case"auto":const t=p(s)?o:Math.min(h,o);i=Math.min(P,t);break;default:return void console.error(`${this._name}._setScale: "${e}" is an unknown zoom value.`)}this._setScaleUpdatePages(i,e,t,!0)}}_resetCurrentPageView(){this.isInPresentationMode&&this._setScale(this._currentScaleValue,!0);const e=this._pages[this._currentPageNumber-1];this._scrollIntoView({pageDiv:e.div})}pageLabelToPageNumber(e){if(!this._pageLabels)return null;const t=this._pageLabels.indexOf(e);return t<0?null:t+1}scrollPageIntoView({pageNumber:e,destArray:t=null,allowNegativeOffset:i=!1,ignoreDestinationZoom:s=!1}){if(!this.pdfDocument)return;const n=Number.isInteger(e)&&this._pages[e-1];if(!n)return void console.error(`${this._name}.scrollPageIntoView: `+`"${e}" is not a valid pageNumber parameter.`);if(this.isInPresentationMode||!t)return void this._setCurrentPageNumber(e,!0);let r,a,o=0,h=0,l=0,u=0;const d=n.rotation%180!=0,p=(d?n.height:n.width)/n.scale/c,_=(d?n.width:n.height)/n.scale/c;let f=0;switch(t[1].name){case"XYZ":o=t[2],h=t[3],f=t[4],o=null!==o?o:0,h=null!==h?h:_;break;case"Fit":case"FitB":f="page-fit";break;case"FitH":case"FitBH":f="page-width",null===(h=t[2])&&this._location?(o=this._location.left,h=this._location.top):"number"!=typeof h&&(h=_);break;case"FitV":case"FitBV":o=t[2],l=p,u=_,f="page-height";break;case"FitR":o=t[2],h=t[3],l=t[4]-o,u=t[5]-h;const e=this.removePageBorders?0:C,i=this.removePageBorders?0:D;r=(this.container.clientWidth-e)/l/c,a=(this.container.clientHeight-i)/u/c,f=Math.min(Math.abs(r),Math.abs(a));break;default:return void console.error(`${this._name}.scrollPageIntoView: `+`"${t[1].name}" is not a valid destination type.`)}if(s||(f&&f!==this._currentScale?this.currentScaleValue=f:this._currentScale===y&&(this.currentScaleValue=g)),"page-fit"===f&&!t[4])return void this._scrollIntoView({pageDiv:n.div,pageNumber:e});const m=[n.viewport.convertToViewportPoint(o,h),n.viewport.convertToViewportPoint(o+l,h+u)];let P=Math.min(m[0][0],m[1][0]),b=Math.min(m[0][1],m[1][1]);i||(P=Math.max(P,0),b=Math.max(b,0)),this._scrollIntoView({pageDiv:n.div,pageSpot:{left:P,top:b},pageNumber:e})}_updateLocation(e){const t=this._currentScale,i=this._currentScaleValue,s=parseFloat(i)===t?Math.round(1e4*t)/100:i,n=e.id;let r="#page="+n;r+="&zoom="+s;const a=this._pages[n-1],o=this.container,h=a.getPagePoint(o.scrollLeft-e.x,o.scrollTop-e.y),l=Math.round(h[0]),c=Math.round(h[1]);r+=","+l+","+c,this._location={pageNumber:n,scale:s,top:c,left:l,rotation:this._pagesRotation,pdfOpenParams:r}}_updateHelper(e){throw new Error("Not implemented: _updateHelper")}update(){const e=this._getVisiblePages(),t=e.views,i=t.length;if(0===i)return;const s=Math.max(k,2*i+1);this._buffer.resize(s,t),this.renderingQueue.renderHighestPriority(e),this._updateHelper(t),this._updateLocation(e.first),this.eventBus.dispatch("updateviewarea",{source:this,location:this._location})}containsElement(e){return this.container.contains(e)}focus(){this.container.focus()}get _isScrollModeHorizontal(){return!this.isInPresentationMode&&this._scrollMode===M.HORIZONTAL}get _isContainerRtl(){return"rtl"===getComputedStyle(this.container).direction}get isInPresentationMode(){return this.presentationModeState===w.FULLSCREEN}get isChangingPresentationMode(){return this.presentationModeState===w.CHANGING}get isHorizontalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollWidth>this.container.clientWidth}get isVerticalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollHeight>this.container.clientHeight}_getCurrentVisiblePage(){if(!this.pagesCount)return{views:[]};const e=this._pages[this._currentPageNumber-1],t=e.div,i={id:e.id,x:t.offsetLeft+t.clientLeft,y:t.offsetTop+t.clientTop,view:e};return{first:i,last:i,views:[i]}}_getVisiblePages(){return d({scrollEl:this.container,views:this._pages,sortByVisibility:!0,horizontal:this._isScrollModeHorizontal,rtl:this._isScrollModeHorizontal&&this._isContainerRtl})}isPageVisible(e){return!!this.pdfDocument&&(Number.isInteger(e)&&e>0&&e<=this.pagesCount?this._getVisiblePages().views.some(function(t){return t.id===e}):(console.error(`${this._name}.isPageVisible: "${e}" is not a valid page.`),!1))}isPageCached(e){if(!this.pdfDocument||!this._buffer)return!1;if(!(Number.isInteger(e)&&e>0&&e<=this.pagesCount))return console.error(`${this._name}.isPageCached: "${e}" is not a valid page.`),!1;const t=this._pages[e-1];return!!t&&this._buffer.has(t)}cleanup(){for(let e=0,t=this._pages.length;e<t;e++)this._pages[e]&&this._pages[e].renderingState!==E.FINISHED&&this._pages[e].reset()}_cancelRendering(){for(let e=0,t=this._pages.length;e<t;e++)this._pages[e]&&this._pages[e].cancelRendering()}_ensurePdfPageLoaded(e){if(e.pdfPage)return Promise.resolve(e.pdfPage);if(this._pagesRequests.has(e))return this._pagesRequests.get(e);const t=this.pdfDocument.getPage(e.id).then(t=>(e.pdfPage||e.setPdfPage(t),this._pagesRequests.delete(e),t)).catch(t=>{console.error("Unable to get page for page view",t),this._pagesRequests.delete(e)});return this._pagesRequests.set(e,t),t}forceRendering(e){const t=e||this._getVisiblePages(),i=this._isScrollModeHorizontal?this.scroll.right:this.scroll.down,s=this.renderingQueue.getHighestPriority(t,this._pages,i);return!!s&&(this._ensurePdfPageLoaded(s).then(()=>{this.renderingQueue.renderView(s)}),!0)}createTextLayerBuilder(e,t,i,s=!1,n){return new x({textLayerDiv:e,eventBus:n,pageIndex:t,viewport:i,findController:this.isInPresentationMode?null:this.findController,enhanceTextSelection:!this.isInPresentationMode&&s})}createAnnotationLayerBuilder(e,t,i=null,s="",n=!1,r=v,a=!1,o=null,h=null){return new A({pageDiv:e,pdfPage:t,annotationStorage:i||this.pdfDocument&&this.pdfDocument.annotationStorage,imageResourcesPath:s,renderInteractiveForms:n,linkService:this.linkService,downloadManager:this.downloadManager,l10n:r,enableScripting:a,hasJSActionsPromise:o||this.pdfDocument&&this.pdfDocument.hasJSActions(),mouseState:h||this._mouseState})}get hasEqualPageSizes(){const e=this._pages[0];for(let t=1,i=this._pages.length;t<i;++t){const i=this._pages[t];if(i.width!==e.width||i.height!==e.height)return!1}return!0}getPagesOverview(){const e=this._pages.map(function(e){const t=e.pdfPage.getViewport({scale:1});return{width:t.width,height:t.height,rotation:t.rotation}});return this.enablePrintAutoRotate?e.map(function(e){return p(e)?e:{width:e.height,height:e.width,rotation:(e.rotation+90)%360}}):e}get optionalContentConfigPromise(){return this.pdfDocument?this._optionalContentConfigPromise?this._optionalContentConfigPromise:this.pdfDocument.getOptionalContentConfig():Promise.resolve(null)}set optionalContentConfigPromise(e){if(!(e instanceof Promise))throw new Error(`Invalid optionalContentConfigPromise: ${e}`);if(this.pdfDocument&&this._optionalContentConfigPromise){this._optionalContentConfigPromise=e;for(const t of this._pages)t.update(t.scale,t.rotation,e);this.update(),this.eventBus.dispatch("optionalcontentconfigchanged",{source:this,promise:e})}}get scrollMode(){return this._scrollMode}set scrollMode(e){if(this._scrollMode!==e){if(!f(e))throw new Error(`Invalid scroll mode: ${e}`);this._scrollMode=e,this.eventBus.dispatch("scrollmodechanged",{source:this,mode:e}),this._updateScrollMode(this._currentPageNumber)}}_updateScrollMode(e=null){const t=this._scrollMode,i=this.viewer;i.classList.toggle("scrollHorizontal",t===M.HORIZONTAL),i.classList.toggle("scrollWrapped",t===M.WRAPPED),this.pdfDocument&&e&&(this._currentScaleValue&&isNaN(this._currentScaleValue)&&this._setScale(this._currentScaleValue,!0),this._setCurrentPageNumber(e,!0),this.update())}get spreadMode(){return this._spreadMode}set spreadMode(e){if(this._spreadMode!==e){if(!m(e))throw new Error(`Invalid spread mode: ${e}`);this._spreadMode=e,this.eventBus.dispatch("spreadmodechanged",{source:this,mode:e}),this._updateSpreadMode(this._currentPageNumber)}}_updateSpreadMode(e=null){if(!this.pdfDocument)return;const t=this.viewer,i=this._pages;if(t.textContent="",this._spreadMode===L.NONE)for(let e=0,s=i.length;e<s;++e)t.appendChild(i[e].div);else{const e=this._spreadMode-1;let s=null;for(let n=0,r=i.length;n<r;++n)null===s?((s=document.createElement("div")).className="spread",t.appendChild(s)):n%2===e&&(s=s.cloneNode(!1),t.appendChild(s)),s.appendChild(i[n].div)}e&&(this._currentScaleValue&&isNaN(this._currentScaleValue)&&this._setScale(this._currentScaleValue,!0),this._setCurrentPageNumber(e,!0),this.update())}_getPageAdvance(e,t=!1){if(this.isInPresentationMode)return 1;switch(this._scrollMode){case M.WRAPPED:{const{views:i}=this._getVisiblePages(),s=new Map;for(const{id:e,y:t,percent:n,widthPercent:r}of i){if(0===n||r<100)continue;let i=s.get(t);i||s.set(t,i=[]),i.push(e)}for(const i of s.values()){const s=i.indexOf(e);if(-1===s)continue;const n=i.length;if(1===n)break;if(t)for(let t=s-1,n=0;t>=n;t--){const s=i[t],n=i[t+1]-1;if(s<n)return e-n}else for(let t=s+1,r=n;t<r;t++){const s=i[t],n=i[t-1]+1;if(s>n)return n-e}if(t){const t=i[0];if(t<e)return e-t+1}else{const t=i[n-1];if(t>e)return t-e+1}break}break}case M.HORIZONTAL:break;case M.VERTICAL:{if(this._spreadMode===L.NONE)break;const i=this._spreadMode-1;if(t&&e%2!==i)break;if(!t&&e%2===i)break;const{views:s}=this._getVisiblePages(),n=t?e-1:e+1;for(const{id:e,percent:t,widthPercent:i}of s)if(e===n){if(t>0&&100===i)return 2;break}break}}return 1}nextPage(){const e=this._currentPageNumber,t=this.pagesCount;if(e>=t)return!1;const i=this._getPageAdvance(e,!1)||1;return this.currentPageNumber=Math.min(e+i,t),!0}previousPage(){const e=this._currentPageNumber;if(e<=1)return!1;const t=this._getPageAdvance(e,!0)||1;return this.currentPageNumber=Math.max(e-t,1),!0}initializeScriptingEvents(){if(!this.enableScripting||this._pageOpenPendingSet)return;const e=this.eventBus,t=this._pageOpenPendingSet=new Set,i=this._scriptingEvents||(this._scriptingEvents=Object.create(null)),s=i=>{t.has(i)||e.dispatch("pageclose",{source:this,pageNumber:i})},n=i=>{const s=this._pages[i-1];s&&s.renderingState===E.FINISHED?(t.delete(i),e.dispatch("pageopen",{source:this,pageNumber:i,actionsPromise:s.pdfPage&&s.pdfPage.getJSActions()})):t.add(i)};i.onPageChanging=(({pageNumber:e,previous:t})=>{e!==t&&(s(t),n(e))}),e._on("pagechanging",i.onPageChanging),i.onPageRendered=(({pageNumber:e})=>{t.has(e)&&e===this._currentPageNumber&&n(e)}),e._on("pagerendered",i.onPageRendered),i.onPagesDestroy=(()=>{s(this._currentPageNumber)}),e._on("pagesdestroy",i.onPagesDestroy),n(this._currentPageNumber)}_resetScriptingEvents(){if(!this.enableScripting||!this._pageOpenPendingSet)return;const e=this.eventBus,t=this._scriptingEvents;e._off("pagechanging",t.onPageChanging),t.onPageChanging=null,e._off("pagerendered",t.onPageRendered),t.onPageRendered=null,e._off("pagesdestroy",t.onPagesDestroy),t.onPagesDestroy=null,this._pageOpenPendingSet=null}}return{BaseViewer:F}});
  //# sourceMappingURL=sourcemaps/base_viewer.js.map
  