@pdfslick/react 2.1.4-next.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("react/jsx-runtime"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react/jsx-runtime","react-dom"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).PDFSlickReact={},t.React,t.jsxRuntime,t.ReactDOM)}(this,(function(t,e,i,s){"use strict";var n="undefined"!=typeof document?document.currentScript:null;function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var a,o,l,h={exports:{}},d={},c={exports:{}},u={};function p(){return o||(o=1,c.exports=function(){if(a)return u;a=1;var t=e,i="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},s=t.useState,n=t.useEffect,r=t.useLayoutEffect,o=t.useDebugValue;function l(t){var e=t.getSnapshot;t=t.value;try{var s=e();return!i(t,s)}catch(t){return!0}}var h="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,e){var i=e(),a=s({inst:{value:i,getSnapshot:e}}),h=a[0].inst,d=a[1];return r((function(){h.value=i,h.getSnapshot=e,l(h)&&d({inst:h})}),[t,i,e]),n((function(){return l(h)&&d({inst:h}),t((function(){l(h)&&d({inst:h})}))}),[t]),o(i),i};return u.useSyncExternalStore=void 0!==t.useSyncExternalStore?t.useSyncExternalStore:h,u}()),c.exports}
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("react/jsx-runtime"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react/jsx-runtime","react-dom"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).PDFSlickReact={},t.React,t.jsxRuntime,t.ReactDOM)}(this,(function(t,e,i,s){"use strict";var n="undefined"!=typeof document?document.currentScript:null;function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var a,o,l,h,d={exports:{}},c={},u={exports:{}},p={};function g(){return o||(o=1,u.exports=function(){if(a)return p;a=1;var t=e,i="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},s=t.useState,n=t.useEffect,r=t.useLayoutEffect,o=t.useDebugValue;function l(t){var e=t.getSnapshot;t=t.value;try{var s=e();return!i(t,s)}catch(t){return!0}}var h="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,e){var i=e(),a=s({inst:{value:i,getSnapshot:e}}),h=a[0].inst,d=a[1];return r((function(){h.value=i,h.getSnapshot=e,l(h)&&d({inst:h})}),[t,i,e]),n((function(){return l(h)&&d({inst:h}),t((function(){l(h)&&d({inst:h})}))}),[t]),o(i),i};return p.useSyncExternalStore=void 0!==t.useSyncExternalStore?t.useSyncExternalStore:h,p}()),u.exports}
2
2
  /**
3
3
  * @license React
4
4
  * use-sync-external-store-shim/with-selector.production.js
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */h.exports=function(){if(l)return d;l=1;var t=e,i=p(),s="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},n=i.useSyncExternalStore,r=t.useRef,a=t.useEffect,o=t.useMemo,h=t.useDebugValue;return d.useSyncExternalStoreWithSelector=function(t,e,i,l,d){var c=r(null);if(null===c.current){var u={hasValue:!1,value:null};c.current=u}else u=c.current;c=o((function(){function t(t){if(!a){if(a=!0,n=t,t=l(t),void 0!==d&&u.hasValue){var e=u.value;if(d(e,t))return r=e}return r=t}if(e=r,s(n,t))return e;var i=l(t);return void 0!==d&&d(e,i)?(n=t,e):(n=t,r=i)}var n,r,a=!1,o=void 0===i?null:i;return[function(){return t(e())},null===o?void 0:function(){return t(o())}]}),[e,i,l,d]);var p=n(t,c[0],c[1]);return a((function(){u.hasValue=!0,u.value=p}),[p]),h(p),p},d}();var g=r(h.exports);const f=t=>{let e;const i=new Set,s=(t,s)=>{const n="function"==typeof t?t(e):t;if(!Object.is(n,e)){const t=e;e=(null!=s?s:"object"!=typeof n||null===n)?n:Object.assign({},e,n),i.forEach((i=>i(e,t)))}},n=()=>e,r={setState:s,getState:n,getInitialState:()=>a,subscribe:t=>(i.add(t),()=>i.delete(t))},a=e=t(s,n,r);return r},{useSyncExternalStoreWithSelector:m}=g,b=t=>t;
10
+ */var f=(h||(h=1,d.exports=function(){if(l)return c;l=1;var t=e,i=g(),s="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},n=i.useSyncExternalStore,r=t.useRef,a=t.useEffect,o=t.useMemo,h=t.useDebugValue;return c.useSyncExternalStoreWithSelector=function(t,e,i,l,d){var c=r(null);if(null===c.current){var u={hasValue:!1,value:null};c.current=u}else u=c.current;c=o((function(){function t(t){if(!a){if(a=!0,n=t,t=l(t),void 0!==d&&u.hasValue){var e=u.value;if(d(e,t))return r=e}return r=t}if(e=r,s(n,t))return e;var i=l(t);return void 0!==d&&d(e,i)?(n=t,e):(n=t,r=i)}var n,r,a=!1,o=void 0===i?null:i;return[function(){return t(e())},null===o?void 0:function(){return t(o())}]}),[e,i,l,d]);var p=n(t,c[0],c[1]);return a((function(){u.hasValue=!0,u.value=p}),[p]),h(p),p},c}()),d.exports),m=r(f);const b=t=>{let e;const i=new Set,s=(t,s)=>{const n="function"==typeof t?t(e):t;if(!Object.is(n,e)){const t=e;e=(null!=s?s:"object"!=typeof n||null===n)?n:Object.assign({},e,n),i.forEach((i=>i(e,t)))}},n=()=>e,r={setState:s,getState:n,getInitialState:()=>a,subscribe:t=>(i.add(t),()=>i.delete(t))},a=e=t(s,n,r);return r},{useSyncExternalStoreWithSelector:v}=m,w=t=>t;
11
11
  /**
12
12
  * @licstart The following is the entire license notice for the
13
13
  * JavaScript code in this page
@@ -28,4 +28,4 @@
28
28
  *
29
29
  * @licend The above is the entire license notice for the
30
30
  * JavaScript code in this page
31
- */var v={d:(t,e)=>{for(var i in e)v.o(e,i)&&!v.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},w=globalThis.pdfjsLib={};v.d(w,{AbortException:()=>It,AnnotationEditorLayer:()=>_n,AnnotationEditorParamsType:()=>R,AnnotationEditorType:()=>D,AnnotationEditorUIManager:()=>me,AnnotationLayer:()=>sn,AnnotationMode:()=>L,ColorPicker:()=>pn,DOMSVGFactory:()=>Ss,DrawLayer:()=>xn,FeatureTest:()=>Nt,GlobalWorkerOptions:()=>Si,ImageKind:()=>z,InvalidPDFException:()=>Pt,MissingPDFException:()=>Mt,OPS:()=>pt,OutputScale:()=>oe,PDFDataRangeTransport:()=>ls,PDFDateString:()=>ee,PDFWorker:()=>us,PasswordResponses:()=>gt,PermissionFlag:()=>N,PixelsPerInch:()=>Ut,RenderingCancelledException:()=>Gt,TextLayer:()=>Ji,TouchManager:()=>ve,UnexpectedResponseException:()=>Tt,Util:()=>Ot,VerbosityLevel:()=>ut,XfaLayer:()=>Cs,build:()=>ws,createValidAbsoluteUrl:()=>_t,fetchData:()=>$t,getDocument:()=>rs,getFilenameFromUrl:()=>Kt,getPdfFilenameFromUrl:()=>Yt,getXfaPageViewport:()=>ie,isDataScheme:()=>qt,isPdfFile:()=>Xt,noContextMenu:()=>Zt,normalizeUnicode:()=>Vt,setLayerDimensions:()=>ae,shadow:()=>xt,stopEvent:()=>te,version:()=>vs});const y=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),A=[1,0,0,1,0,0],_=[.001,0,0,.001,0,0],x=1.35,S=1,C=2,E=4,P=16,M=32,T=64,k=128,I=256,L={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},D={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},R={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},N={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},F=0,O=1,B=2,j=3,V=3,H=4,z={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},U=1,$=2,W=3,G=4,q=5,X=6,K=7,Y=8,Q=9,J=10,Z=11,tt=12,et=13,it=14,st=15,nt=16,rt=17,at=20,ot=1,lt=2,ht=3,dt=4,ct=5,ut={ERRORS:0,WARNINGS:1,INFOS:5},pt={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},gt={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let ft=ut.WARNINGS;function mt(t){Number.isInteger(t)&&(ft=t)}function bt(){return ft}function vt(t){ft>=ut.INFOS&&console.log(`Info: ${t}`)}function wt(t){ft>=ut.WARNINGS&&console.log(`Warning: ${t}`)}function yt(t){throw new Error(t)}function At(t,e){t||yt(e)}function _t(t,e=null,i=null){if(!t)return null;try{if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch{}}const s=e?new URL(t,e):new URL(t);if(function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s))return s}catch{}return null}function xt(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}const St=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class Ct extends St{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Et extends St{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}let Pt=class extends St{constructor(t){super(t,"InvalidPDFException")}},Mt=class extends St{constructor(t){super(t,"MissingPDFException")}},Tt=class extends St{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}};class kt extends St{constructor(t){super(t,"FormatError")}}let It=class extends St{constructor(t){super(t,"AbortException")}};function Lt(t){"object"==typeof t&&void 0!==t?.length||yt("Invalid argument for bytesToString");const e=t.length,i=8192;if(e<i)return String.fromCharCode.apply(null,t);const s=[];for(let n=0;n<e;n+=i){const r=Math.min(n+i,e),a=t.subarray(n,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function Dt(t){"string"!=typeof t&&yt("Invalid argument for stringToBytes");const e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}function Rt(t){const e=Object.create(null);for(const[i,s]of t)e[i]=s;return e}class Nt{static get isLittleEndian(){return xt(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return xt(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return xt(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return xt(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){return"undefined"!=typeof navigator&&"string"==typeof navigator?.platform?xt(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof navigator?.userAgent&&navigator.userAgent.includes("Firefox")}):xt(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return xt(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const Ft=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));let Ot=class{static makeHexColor(t,e,i){return`#${Ft[t]}${Ft[e]}${Ft[i]}`}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){const i=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/i,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/i]}static getAxialAlignedBoundingBox(t,e){const i=this.applyTransform(t,e),s=this.applyTransform(t.slice(2,4),e),n=this.applyTransform([t[0],t[3]],e),r=this.applyTransform([t[2],t[1]],e);return[Math.min(i[0],s[0],n[0],r[0]),Math.min(i[1],s[1],n[1],r[1]),Math.max(i[0],s[0],n[0],r[0]),Math.max(i[1],s[1],n[1],r[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],i=t[0]*e[0]+t[1]*e[2],s=t[0]*e[1]+t[1]*e[3],n=t[2]*e[0]+t[3]*e[2],r=t[2]*e[1]+t[3]*e[3],a=(i+r)/2,o=Math.sqrt((i+r)**2-4*(i*r-n*s))/2,l=a+o||1,h=a-o||1;return[Math.sqrt(l),Math.sqrt(h)]}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[i,n,s,r]}static#t(t,e,i,s,n,r,a,o,l,h){if(l<=0||l>=1)return;const d=1-l,c=l*l,u=c*l,p=d*(d*(d*t+3*l*e)+3*c*i)+u*s,g=d*(d*(d*n+3*l*r)+3*c*a)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static#e(t,e,i,s,n,r,a,o,l,h,d,c){if(Math.abs(l)<1e-12)return void(Math.abs(h)>=1e-12&&this.#t(t,e,i,s,n,r,a,o,-d/h,c));const u=h**2-4*d*l;if(u<0)return;const p=Math.sqrt(u),g=2*l;this.#t(t,e,i,s,n,r,a,o,(-h+p)/g,c),this.#t(t,e,i,s,n,r,a,o,(-h-p)/g,c)}static bezierBoundingBox(t,e,i,s,n,r,a,o,l){return l?(l[0]=Math.min(l[0],t,a),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,a),l[3]=Math.max(l[3],e,o)):l=[Math.min(t,a),Math.min(e,o),Math.max(t,a),Math.max(e,o)],this.#e(t,i,n,a,e,s,r,o,3*(3*(i-n)-t+a),6*(t-2*i+n),3*(i-t),l),this.#e(t,i,n,a,e,s,r,o,3*(3*(s-r)-e+o),6*(e-2*s+r),3*(s-e),l),l}};let Bt=null,jt=null;function Vt(t){return Bt||(Bt=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,jt=new Map([["ſt","ſt"]])),t.replaceAll(Bt,((t,e,i)=>e?e.normalize("NFKC"):jt.get(i)))}const Ht="pdfjs_internal_id_";"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise((i=>{i(t(...e))}))});const zt="http://www.w3.org/2000/svg";let Ut=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function $t(t,e="text"){if(Jt(t,document.baseURI)){const i=await fetch(t);if(!i.ok)throw new Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise(((i,s)=>{const n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType=e,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE)if(200!==n.status&&0!==n.status)s(new Error(n.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void i(n.response)}i(n.responseText)}},n.send(null)}))}class Wt{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=n,this.offsetY=r,i*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let h,d,c,u,p,g,f,m;switch((s%=360)<0&&(s+=360),s){case 180:h=-1,d=0,c=0,u=1;break;case 90:h=0,d=1,c=1,u=0;break;case 270:h=0,d=-1,c=-1,u=0;break;case 0:h=1,d=0,c=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(c=-c,u=-u),0===h?(p=Math.abs(l-t[1])*i+n,g=Math.abs(o-t[0])*i+r,f=(t[3]-t[1])*i,m=(t[2]-t[0])*i):(p=Math.abs(o-t[0])*i+n,g=Math.abs(l-t[1])*i+r,f=(t[2]-t[0])*i,m=(t[3]-t[1])*i),this.transform=[h*i,d*i,c*i,u*i,p-h*i*o-c*i*l,g-d*i*o-u*i*l],this.width=f,this.height=m}get rawDims(){const{userUnit:t,viewBox:e}=this,i=e.map((e=>e*t));return xt(this,"rawDims",{pageWidth:i[2]-i[0],pageHeight:i[3]-i[1],pageX:i[0],pageY:i[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new Wt({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){return Ot.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=Ot.applyTransform([t[0],t[1]],this.transform),i=Ot.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){return Ot.applyInverseTransform([t,e],this.transform)}}let Gt=class extends St{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};function qt(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function Xt(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function Kt(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function Yt(t,e="document.pdf"){if("string"!=typeof t)return e;if(qt(t))return wt('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const i=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t);let n=i.exec(s[1])||i.exec(s[2])||i.exec(s[3]);if(n&&(n=n[0],n.includes("%")))try{n=i.exec(decodeURIComponent(n))[0]}catch{}return n||e}class Qt{started=Object.create(null);times=[];time(t){t in this.started&&wt(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||wt(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:t}of this.times)e=Math.max(t.length,e);for(const{name:i,start:s,end:n}of this.times)t.push(`${i.padEnd(e)} ${n-s}ms\n`);return t.join("")}}function Jt(t,e){try{const{protocol:i}=e?new URL(t,e):new URL(t);return"http:"===i||"https:"===i}catch{return!1}}function Zt(t){t.preventDefault()}function te(t){t.preventDefault(),t.stopPropagation()}let ee=class{static#i;static toDateObject(t){if(!t||"string"!=typeof t)return null;this.#i||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#i.exec(t);if(!e)return null;const i=parseInt(e[1],10);let s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const l=e[7]||"Z";let h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,"-"===l?(r+=h,a+=d):"+"===l&&(r-=h,a-=d),new Date(Date.UTC(i,s,n,r,a,o))}};function ie(t,{scale:e=1,rotation:i=0}){const{width:s,height:n}=t.attributes.style,r=[0,0,parseInt(s),parseInt(n)];return new Wt({viewBox:r,userUnit:1,scale:e,rotation:i})}function se(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map((t=>parseInt(t))):t.startsWith("rgba(")?t.slice(5,-1).split(",").map((t=>parseInt(t))).slice(0,3):(wt(`Not a valid color format: "${t}"`),[0,0,0])}function ne(t){const{a:e,b:i,c:s,d:n,e:r,f:a}=t.getTransform();return[e,i,s,n,r,a]}function re(t){const{a:e,b:i,c:s,d:n,e:r,f:a}=t.getTransform().invertSelf();return[e,i,s,n,r,a]}function ae(t,e,i=!1,s=!0){if(e instanceof Wt){const{pageWidth:s,pageHeight:n}=e.rawDims,{style:r}=t,a=Nt.isCSSRoundSupported,o=`var(--scale-factor) * ${s}px`,l=`var(--scale-factor) * ${n}px`,h=a?`round(down, ${o}, var(--scale-round-x, 1px))`:`calc(${o})`,d=a?`round(down, ${l}, var(--scale-round-y, 1px))`:`calc(${l})`;i&&e.rotation%180!=0?(r.width=d,r.height=h):(r.width=h,r.height=d)}s&&t.setAttribute("data-main-rotation",e.rotation)}let oe=class{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}};class le{#s=null;#n=null;#r;#a=null;#o=null;static#l=null;constructor(t){this.#r=t,le.#l||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"})}render(){const t=this.#s=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#r._uiManager._signal;t.addEventListener("contextmenu",Zt,{signal:e}),t.addEventListener("pointerdown",le.#h,{signal:e});const i=this.#a=document.createElement("div");i.className="buttons",t.append(i);const s=this.#r.toolbarPosition;if(s){const{style:e}=t,i="ltr"===this.#r._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=100*i+"%",e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return this.#d(),t}get div(){return this.#s}static#h(t){t.stopPropagation()}#c(t){this.#r._focusEventsAllowed=!1,te(t)}#u(t){this.#r._focusEventsAllowed=!0,te(t)}#p(t){const e=this.#r._uiManager._signal;t.addEventListener("focusin",this.#c.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Zt,{signal:e})}hide(){this.#s.classList.add("hidden"),this.#n?.hideDropdown()}show(){this.#s.classList.remove("hidden"),this.#o?.shown()}#d(){const{editorType:t,_uiManager:e}=this.#r,i=document.createElement("button");i.className="delete",i.tabIndex=0,i.setAttribute("data-l10n-id",le.#l[t]),this.#p(i),i.addEventListener("click",(t=>{e.delete()}),{signal:e._signal}),this.#a.append(i)}get#g(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#p(e),this.#a.prepend(e,this.#g),this.#o=t}addColorPicker(t){this.#n=t;const e=t.renderButton();this.#p(e),this.#a.prepend(e,this.#g)}remove(){this.#s.remove(),this.#n?.destroy(),this.#n=null}}class he{#a=null;#s=null;#f;constructor(t){this.#f=t}#m(){const t=this.#s=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",Zt,{signal:this.#f._signal});const e=this.#a=document.createElement("div");return e.className="buttons",t.append(e),this.#b(),t}#v(t,e){let i=0,s=0;for(const n of t){const t=n.y+n.height;if(t<i)continue;const r=n.x+(e?n.width:0);t>i?(s=r,i=t):e?r>s&&(s=r):r<s&&(s=r)}return[e?1-s:s,i]}show(t,e,i){const[s,n]=this.#v(e,i),{style:r}=this.#s||=this.#m();t.append(this.#s),r.insetInlineEnd=100*s+"%",r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#s.remove()}#b(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const i=this.#f._signal;t.addEventListener("contextmenu",Zt,{signal:i}),t.addEventListener("click",(()=>{this.#f.highlightSelection("floating_button")}),{signal:i}),this.#a.append(t)}}function de(t,e,i){for(const s of i)e.addEventListener(s,t[s].bind(t))}class ce{#w=0;get id(){return"pdfjs_internal_editor_"+this.#w++}}class ue{#y=function(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),Lt(t)}();#w=0;#A=null;static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>';return xt(this,"_isSVGFittingCanvas",e.decode().then((()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]))))}async#_(t,e){this.#A||=new Map;let i=this.#A.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#y}_${this.#w++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await $t(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=ue._isSVGFittingCanvas,s=new FileReader,n=new Image,r=new Promise(((t,r)=>{n.onload=()=>{i.bitmap=n,i.isSvg=!0,t()},s.onload=async()=>{const t=i.svgUrl=s.result;n.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},n.onerror=s.onerror=r}));s.readAsDataURL(t),await r}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){wt(t),i=null}return this.#A.set(t,i),i&&this.#A.set(i.id,i),i}async getFromFile(t){const{lastModified:e,name:i,size:s,type:n}=t;return this.#_(`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return this.#_(t,t)}async getFromBlob(t,e){const i=await e;return this.#_(t,i)}async getFromId(t){this.#A||=new Map;const e=this.#A.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#A||=new Map;let i=this.#A.get(t);if(i?.bitmap)return i.refCounter+=1,i;const s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#y}_${this.#w++}`,refCounter:1,isSvg:!1},this.#A.set(t,i),this.#A.set(i.id,i),i}getSvgUrl(t){const e=this.#A.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#A||=new Map;const e=this.#A.get(t);if(!e)return;if(e.refCounter-=1,0!==e.refCounter)return;const{bitmap:i}=e;if(!e.url&&!e.file){const t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=t.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#y}_`)}}class pe{#x=[];#S=!1;#C;#E=-1;constructor(t=128){this.#C=t}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(s&&t(),this.#S)return;const o={cmd:t,undo:e,post:i,type:n};if(-1===this.#E)return this.#x.length>0&&(this.#x.length=0),this.#E=0,void this.#x.push(o);if(r&&this.#x[this.#E].type===n)return a&&(o.undo=this.#x[this.#E].undo),void(this.#x[this.#E]=o);const l=this.#E+1;l===this.#C?this.#x.splice(0,1):(this.#E=l,l<this.#x.length&&this.#x.splice(l)),this.#x.push(o)}undo(){if(-1===this.#E)return;this.#S=!0;const{undo:t,post:e}=this.#x[this.#E];t(),e?.(),this.#S=!1,this.#E-=1}redo(){if(this.#E<this.#x.length-1){this.#E+=1,this.#S=!0;const{cmd:t,post:e}=this.#x[this.#E];t(),e?.(),this.#S=!1}}hasSomethingToUndo(){return-1!==this.#E}hasSomethingToRedo(){return this.#E<this.#x.length-1}cleanType(t){if(-1!==this.#E){for(let e=this.#E;e>=0;e--)if(this.#x[e].type!==t)return this.#x.splice(e+1,this.#E-e),void(this.#E=e);this.#x.length=0,this.#E=-1}}destroy(){this.#x=null}}class ge{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=Nt.platform;for(const[i,s,n={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1)))}}#P(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const i=this.callbacks.get(this.#P(e));if(!i)return;const{callback:s,options:{bubbles:n=!1,args:r=[],checker:a=null}}=i;a&&!a(t,e)||(s.bind(t,...r,e)(),n||te(e))}}class fe{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",document.body.append(e);for(const i of t.keys()){e.style.color=i;const s=window.getComputedStyle(e).color;t.set(i,se(s))}e.remove()}(t),xt(this,"_colors",t)}convert(t){const e=se(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[t,i]of this._colors)if(i.every(((t,i)=>t===e[i])))return fe._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?Ot.makeHexColor(...e):t}}let me=class t{#M=new AbortController;#T=null;#k=new Map;#I=new Map;#L=null;#D=null;#R=null;#N=new pe;#F=null;#O=null;#B=0;#j=new Set;#V=null;#H=null;#z=new Set;_editorUndoBar=null;#U=!1;#$=!1;#W=!1;#G=null;#q=null;#X=null;#K=null;#Y=!1;#Q=null;#J=new ce;#Z=!1;#tt=!1;#et=null;#it=null;#st=null;#nt=null;#rt=D.NONE;#at=new Set;#ot=null;#lt=null;#ht=null;#dt={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#ct=[0,0];#ut=null;#pt=null;#gt=null;#ft=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const e=t.prototype,i=t=>t.#pt.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),s=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},n=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return xt(this,"_keyboardManager",new ge([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],e.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:s}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#pt.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#pt.contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-n,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-r,0],checker:i}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[n,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[r,0],checker:i}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-n],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-r],checker:i}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,n],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,r],checker:i}]]))}constructor(t,e,i,s,n,r,a,o,l,h,d,c,u){const p=this._signal=this.#M.signal;this.#pt=t,this.#gt=e,this.#L=i,this._eventBus=s,s._on("editingaction",this.onEditingAction.bind(this),{signal:p}),s._on("pagechanging",this.onPageChanging.bind(this),{signal:p}),s._on("scalechanging",this.onScaleChanging.bind(this),{signal:p}),s._on("rotationchanging",this.onRotationChanging.bind(this),{signal:p}),s._on("setpreference",this.onSetPreference.bind(this),{signal:p}),s._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:p}),this.#mt(),this.#bt(),this.#vt(),this.#D=n.annotationStorage,this.#G=n.filterFactory,this.#lt=r,this.#K=a||null,this.#U=o,this.#$=l,this.#W=h,this.#nt=d||null,this.viewParameters={realScale:Ut.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=c||null,this._supportsPinchToZoom=!1!==u}destroy(){this.#ft?.resolve(),this.#ft=null,this.#M?.abort(),this.#M=null,this._signal=null;for(const t of this.#I.values())t.destroy();this.#I.clear(),this.#k.clear(),this.#z.clear(),this.#T=null,this.#at.clear(),this.#N.destroy(),this.#L?.destroy(),this.#Q?.hide(),this.#Q=null,this.#q&&(clearTimeout(this.#q),this.#q=null),this.#ut&&(clearTimeout(this.#ut),this.#ut=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#nt}get useNewAltTextFlow(){return this.#$}get useNewAltTextWhenAddingImage(){return this.#W}get hcmFilter(){return xt(this,"hcmFilter",this.#lt?this.#G.addHCMFilter(this.#lt.foreground,this.#lt.background):"none")}get direction(){return xt(this,"direction",getComputedStyle(this.#pt).direction)}get highlightColors(){return xt(this,"highlightColors",this.#K?new Map(this.#K.split(",").map((t=>t.split("=").map((t=>t.trim()))))):null)}get highlightColorNames(){return xt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#O=t}setMainHighlightColorPicker(t){this.#st=t}editAltText(t,e=!1){this.#L?.editAltText(this,t,e)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){if("enableNewAltTextWhenAddingImage"===t)this.#W=e}onPageChanging({pageNumber:t}){this.#B=t-1}focusMainContainer(){this.#pt.focus()}findParent(t,e){for(const i of this.#I.values()){const{x:s,y:n,width:r,height:a}=i.div.getBoundingClientRect();if(t>=s&&t<=s+r&&e>=n&&e<=n+a)return i}return null}disableUserSelect(t=!1){this.#gt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#z.add(t)}removeShouldRescale(t){this.#z.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Ut.PDF_TO_CSS_UNITS;for(const t of this.#z)t.onScaleChanging();this.#O?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#wt({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#yt(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const e of this.#I.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r}=e,a=e.toString(),o=this.#wt(e).closest(".textLayer"),l=this.getSelectionBoxes(o);if(!l)return;e.empty();const h=this.#yt(o),d=this.#rt===D.NONE,c=()=>{h?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:l,anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r,text:a}),d&&this.showAllEditors("highlight",!0,!0)};d?this.switchToMode(D.HIGHLIGHT,c):c()}#At(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#wt(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#Q||=new he(this),this.#Q.show(e,i,"ltr"===this.direction))}addToAnnotationStorage(t){t.isEmpty()||!this.#D||this.#D.has(t.id)||this.#D.setValue(t.id,t)}#_t(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#ot&&(this.#Q?.hide(),this.#ot=null,this.#xt({hasSelectedText:!1})));const{anchorNode:e}=t;if(e===this.#ot)return;const i=this.#wt(t).closest(".textLayer");if(i){if(this.#Q?.hide(),this.#ot=e,this.#xt({hasSelectedText:!0}),(this.#rt===D.HIGHLIGHT||this.#rt===D.NONE)&&(this.#rt===D.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#Y=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#rt===D.HIGHLIGHT?this.#yt(i):null;t?.toggleDrawing();const e=new AbortController,s=this.combinedSignal(e),n=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#St("main_toolbar"))};window.addEventListener("pointerup",n,{signal:s}),window.addEventListener("blur",n,{signal:s})}}else this.#ot&&(this.#Q?.hide(),this.#ot=null,this.#xt({hasSelectedText:!1}))}#St(t=""){this.#rt===D.HIGHLIGHT?this.highlightSelection(t):this.#U&&this.#At()}#mt(){document.addEventListener("selectionchange",this.#_t.bind(this),{signal:this._signal})}#Ct(){if(this.#X)return;this.#X=new AbortController;const t=this.combinedSignal(this.#X);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#Et(){this.#X?.abort(),this.#X=null}blur(){if(this.isShiftKeyDown=!1,this.#Y&&(this.#Y=!1,this.#St("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#at)if(e.div.contains(t)){this.#it=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#it)return;const[t,e]=this.#it;this.#it=null,e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}#vt(){if(this.#et)return;this.#et=new AbortController;const t=this.combinedSignal(this.#et);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#Pt(){this.#et?.abort(),this.#et=null}#Mt(){if(this.#F)return;this.#F=new AbortController;const t=this.combinedSignal(this.#F);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#Tt(){this.#F?.abort(),this.#F=null}#bt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#vt(),this.#Mt()}removeEditListeners(){this.#Pt(),this.#Tt()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of this.#H)if(i.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const i of this.#H)if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#T?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const t of this.#at){const i=t.serialize(!0);i&&e.push(i)}0!==e.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const t of e.items)for(const e of this.#H)if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){return void wt(`paste: "${t.message}".`)}if(!Array.isArray(i))return;this.unselectAll();const s=this.currentLayer;try{const t=[];for(const e of i){const i=await s.deserialize(e);if(!i)return;t.push(i)}const e=()=>{for(const e of t)this.#kt(e);this.#It(t)},n=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:n,mustExec:!0})}catch(t){wt(`paste: "${t.message}".`)}}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0),this.#rt===D.NONE||this.isEditorHandlingKeyboard||t._keyboardManager.exec(this,e)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#Y&&(this.#Y=!1,this.#St("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#xt(t){Object.entries(t).some((([t,e])=>this.#dt[t]!==e))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#dt,t)}),this.#rt===D.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#Lt([[R.HIGHLIGHT_FREE,!0]]))}#Lt(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#Ct(),this.#Mt(),this.#xt({isEditing:this.#rt!==D.NONE,isEmpty:this.#Dt(),hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:this.#N.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Et(),this.#Tt(),this.#xt({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#H){this.#H=t;for(const t of this.#H)this.#Lt(t.defaultPropertiesToUpdate)}}getId(){return this.#J.id}get currentLayer(){return this.#I.get(this.#B)}getLayer(t){return this.#I.get(t)}get currentPageIndex(){return this.#B}addLayer(t){this.#I.set(t.pageIndex,t),this.#Z?t.enable():t.disable()}removeLayer(t){this.#I.delete(t.pageIndex)}async updateMode(t,e=null,i=!1){if(this.#rt!==t&&(!this.#ft||(await this.#ft.promise,this.#ft))){if(this.#ft=Promise.withResolvers(),this.#rt=t,t===D.NONE)return this.setEditingState(!1),this.#Rt(),this._editorUndoBar?.hide(),void this.#ft.resolve();this.setEditingState(!0),await this.#Nt(),this.unselectAll();for(const e of this.#I.values())e.updateMode(t);if(!e)return i&&this.addNewEditorFromKeyboard(),void this.#ft.resolve();for(const t of this.#k.values())t.annotationElementId===e?(this.setSelected(t),t.enterInEditMode()):t.unselect();this.#ft.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#rt&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#H){switch(t){case R.CREATE:return void this.currentLayer.addNewEditor();case R.HIGHLIGHT_DEFAULT_COLOR:this.#st?.updateColor(e);break;case R.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#ht||=new Map).set(t,e),this.showAllEditors("highlight",e)}for(const i of this.#at)i.updateParams(t,e);for(const i of this.#H)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(const i of this.#k.values())i.editorType===t&&i.show(e);(this.#ht?.get(R.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#Lt([[R.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#tt!==t){this.#tt=t;for(const e of this.#I.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#Nt(){if(!this.#Z){this.#Z=!0;const t=[];for(const e of this.#I.values())t.push(e.enable());await Promise.all(t);for(const t of this.#k.values())t.enable()}}#Rt(){if(this.unselectAll(),this.#Z){this.#Z=!1;for(const t of this.#I.values())t.disable();for(const t of this.#k.values())t.disable()}}getEditors(t){const e=[];for(const i of this.#k.values())i.pageIndex===t&&e.push(i);return e}getEditor(t){return this.#k.get(t)}addEditor(t){this.#k.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#q&&clearTimeout(this.#q),this.#q=setTimeout((()=>{this.focusMainContainer(),this.#q=null}),0)),this.#k.delete(t.id),this.unselect(t),t.annotationElementId&&this.#j.has(t.annotationElementId)||this.#D?.remove(t.id)}addDeletedAnnotationElement(t){this.#j.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#j.has(t)}removeDeletedAnnotationElement(t){this.#j.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#kt(t){const e=this.#I.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#T!==t&&(this.#T=t,t&&this.#Lt(t.propertiesToUpdate))}get#Ft(){let t=null;for(t of this.#at);return t}updateUI(t){this.#Ft===t&&this.#Lt(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#Lt(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#at.has(t))return this.#at.delete(t),t.unselect(),void this.#xt({hasSelectedEditor:this.hasSelection});this.#at.add(t),t.select(),this.#Lt(t.propertiesToUpdate),this.#xt({hasSelectedEditor:!0})}setSelected(t){this.#O?.commitOrRemove();for(const e of this.#at)e!==t&&e.unselect();this.#at.clear(),this.#at.add(t),t.select(),this.#Lt(t.propertiesToUpdate),this.#xt({hasSelectedEditor:!0})}isSelected(t){return this.#at.has(t)}get firstSelectedEditor(){return this.#at.values().next().value}unselect(t){t.unselect(),this.#at.delete(t),this.#xt({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#at.size}get isEnterHandled(){return 1===this.#at.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#N.undo(),this.#xt({hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Dt()}),this._editorUndoBar?.hide()}redo(){this.#N.redo(),this.#xt({hasSomethingToUndo:!0,hasSomethingToRedo:this.#N.hasSomethingToRedo(),isEmpty:this.#Dt()})}addCommands(t){this.#N.add(t),this.#xt({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Dt()})}cleanUndoStack(t){this.#N.cleanType(t)}#Dt(){if(0===this.#k.size)return!0;if(1===this.#k.size)for(const t of this.#k.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...this.#at],i=()=>{for(const t of e)this.#kt(t)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(i,1===e.length?e[0].editorType:e.length);for(const t of e)t.remove()},undo:i,mustExec:!0})}commitOrRemove(){this.#T?.commitOrRemove()}hasSomethingToControl(){return this.#T||this.hasSelection}#It(t){for(const t of this.#at)t.unselect();this.#at.clear();for(const e of t)e.isEmpty()||(this.#at.add(e),e.select());this.#xt({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#at)t.commit();this.#It(this.#k.values())}unselectAll(){if((!this.#T||(this.#T.commitOrRemove(),this.#rt===D.NONE))&&!this.#O?.commitOrRemove()&&this.hasSelection){for(const t of this.#at)t.unselect();this.#at.clear(),this.#xt({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#ct[0]+=t,this.#ct[1]+=e;const[s,n]=this.#ct,r=[...this.#at];this.#ut&&clearTimeout(this.#ut),this.#ut=setTimeout((()=>{this.#ut=null,this.#ct[0]=this.#ct[1]=0,this.addCommands({cmd:()=>{for(const t of r)this.#k.has(t.id)&&t.translateInPage(s,n)},undo:()=>{for(const t of r)this.#k.has(t.id)&&t.translateInPage(-s,-n)},mustExec:!1})}),1e3);for(const i of r)i.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#V=new Map;for(const t of this.#at)this.#V.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#V)return!1;this.disableUserSelect(!1);const t=this.#V;this.#V=null;let e=!1;for(const[{x:i,y:s,pageIndex:n},r]of t)r.newX=i,r.newY=s,r.newPageIndex=n,e||=i!==r.savedX||s!==r.savedY||n!==r.savedPageIndex;if(!e)return!1;const i=(t,e,i,s)=>{if(this.#k.has(t.id)){const n=this.#I.get(s);n?t._setParentAndPosition(n,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(const[e,{newX:s,newY:n,newPageIndex:r}]of t)i(e,s,n,r)},undo:()=>{for(const[e,{savedX:s,savedY:n,savedPageIndex:r}]of t)i(e,s,n,r)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#V)for(const i of this.#V.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#at.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#T===t}getActive(){return this.#T}getMode(){return this.#rt}get imageManager(){return xt(this,"imageManager",new ue)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let i=0,s=e.rangeCount;i<s;i++)if(!t.contains(e.getRangeAt(i).commonAncestorContainer))return null;const{x:i,y:s,width:n,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(t,e,a,o)=>({x:(e-s)/r,y:1-(t+a-i)/n,width:o/r,height:a/n});break;case"180":a=(t,e,a,o)=>({x:1-(t+a-i)/n,y:1-(e+o-s)/r,width:a/n,height:o/r});break;case"270":a=(t,e,a,o)=>({x:1-(e+o-s)/r,y:(t-i)/n,width:o/r,height:a/n});break;default:a=(t,e,a,o)=>({x:(t-i)/n,y:(e-s)/r,width:a/n,height:o/r})}const o=[];for(let t=0,i=e.rangeCount;t<i;t++){const i=e.getRangeAt(t);if(!i.collapsed)for(const{x:t,y:e,width:s,height:n}of i.getClientRects())0!==s&&0!==n&&o.push(a(t,e,s,n))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#R||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#R?.delete(t)}renderAnnotationElement(t){const e=this.#R?.get(t.data.id);if(!e)return;const i=this.#D.getRawValue(e);i&&(this.#rt!==D.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}};class be{#o=null;#Ot=!1;#Bt=null;#jt=null;#Vt=null;#Ht=null;#zt=!1;#Ut=null;#r=null;#$t=null;#Wt=null;#Gt=!1;static#qt=null;static _l10n=null;constructor(t){this.#r=t,this.#Gt=t._uiManager.useNewAltTextFlow,be.#qt||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){be._l10n??=t}async render(){const t=this.#Bt=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#jt=document.createElement("span");t.append(e),this.#Gt?(t.classList.add("new"),t.setAttribute("data-l10n-id",be.#qt.missing),e.setAttribute("data-l10n-id",be.#qt["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const i=this.#r._uiManager._signal;t.addEventListener("contextmenu",Zt,{signal:i}),t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:i});const s=t=>{t.preventDefault(),this.#r._uiManager.editAltText(this.#r),this.#Gt&&this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#Xt}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",(e=>{e.target===t&&"Enter"===e.key&&(this.#zt=!0,s(e))}),{signal:i}),await this.#Kt(),t}get#Xt(){return(this.#o?"added":null===this.#o&&this.guessedText&&"review")||"missing"}finish(){this.#Bt&&(this.#Bt.focus({focusVisible:this.#zt}),this.#zt=!1)}isEmpty(){return this.#Gt?null===this.#o:!this.#o&&!this.#Ot}hasData(){return this.#Gt?null!==this.#o||!!this.#$t:this.isEmpty()}get guessedText(){return this.#$t}async setGuessedText(t){null===this.#o&&(this.#$t=t,this.#Wt=await be._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#Kt())}toggleAltTextBadge(t=!1){if(!this.#Gt||this.#o)return this.#Ut?.remove(),void(this.#Ut=null);if(!this.#Ut){const t=this.#Ut=document.createElement("div");t.className="noAltTextBadge",this.#r.div.append(t)}this.#Ut.classList.toggle("hidden",!t)}serialize(t){let e=this.#o;return t||this.#$t!==e||(e=this.#Wt),{altText:e,decorative:this.#Ot,guessedText:this.#$t,textWithDisclaimer:this.#Wt}}get data(){return{altText:this.#o,decorative:this.#Ot}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:n=!1}){i&&(this.#$t=i,this.#Wt=s),this.#o===t&&this.#Ot===e||(n||(this.#o=t,this.#Ot=e),this.#Kt())}toggle(t=!1){this.#Bt&&(!t&&this.#Ht&&(clearTimeout(this.#Ht),this.#Ht=null),this.#Bt.disabled=!t)}shown(){this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#Xt}})}destroy(){this.#Bt?.remove(),this.#Bt=null,this.#jt=null,this.#Vt=null,this.#Ut?.remove(),this.#Ut=null}async#Kt(){const t=this.#Bt;if(!t)return;if(this.#Gt){if(t.classList.toggle("done",!!this.#o),t.setAttribute("data-l10n-id",be.#qt[this.#Xt]),this.#jt?.setAttribute("data-l10n-id",be.#qt[`${this.#Xt}-label`]),!this.#o)return void this.#Vt?.remove()}else{if(!this.#o&&!this.#Ot)return t.classList.remove("done"),void this.#Vt?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#Vt;if(!e){this.#Vt=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#r.id}`;const i=100,s=this.#r._uiManager._signal;s.addEventListener("abort",(()=>{clearTimeout(this.#Ht),this.#Ht=null}),{once:!0}),t.addEventListener("mouseenter",(()=>{this.#Ht=setTimeout((()=>{this.#Ht=null,this.#Vt.classList.add("show"),this.#r._reportTelemetry({action:"alt_text_tooltip"})}),i)}),{signal:s}),t.addEventListener("mouseleave",(()=>{this.#Ht&&(clearTimeout(this.#Ht),this.#Ht=null),this.#Vt?.classList.remove("show")}),{signal:s})}this.#Ot?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#o),e.parentNode||t.append(e);const i=this.#r.getImageForAltText();i?.setAttribute("aria-describedby",e.id)}}let ve=class t{#pt;#Yt=!1;#Qt=null;#Jt;#Zt;#te;#ee;#ie;#se=null;#ne;#re=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:r=null,signal:a}){this.#pt=t,this.#Qt=i,this.#Jt=e,this.#Zt=s,this.#te=n,this.#ee=r,this.#ne=new AbortController,this.#ie=AbortSignal.any([a,this.#ne.signal]),t.addEventListener("touchstart",this.#ae.bind(this),{passive:!1,signal:this.#ie})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return xt(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#ae(t){if(this.#Jt?.()||t.touches.length<2)return;if(!this.#re){this.#re=new AbortController;const t=AbortSignal.any([this.#ie,this.#re.signal]),e=this.#pt,i={signal:t,passive:!1};e.addEventListener("touchmove",this.#oe.bind(this),i),e.addEventListener("touchend",this.#le.bind(this),i),e.addEventListener("touchcancel",this.#le.bind(this),i),this.#Zt?.()}if(te(t),2!==t.touches.length||this.#Qt?.())return void(this.#se=null);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#se={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#oe(e){if(!this.#se||2!==e.touches.length)return;let[i,s]=e.touches;i.identifier>s.identifier&&([i,s]=[s,i]);const{screenX:n,screenY:r}=i,{screenX:a,screenY:o}=s,l=this.#se,{touch0X:h,touch0Y:d,touch1X:c,touch1Y:u}=l,p=c-h,g=u-d,f=a-n,m=o-r,b=Math.hypot(f,m)||1,v=Math.hypot(p,g)||1;if(!this.#Yt&&Math.abs(v-b)<=t.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=n,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,e.preventDefault(),!this.#Yt)return void(this.#Yt=!0);const w=[(n+a)/2,(r+o)/2];this.#te?.(w,v,b)}#le(t){this.#re.abort(),this.#re=null,this.#ee?.(),this.#se&&(t.preventDefault(),this.#se=null,this.#Yt=!1)}destroy(){this.#ne?.abort(),this.#ne=null}};class we{#he=null;#de=null;#o=null;#ce=!1;#ue=null;#pe="";#ge=!1;#fe=null;#me=null;#be=null;#ve=null;#we="";#ye=!1;#Ae=null;#_e=!1;#xe=!1;#Se=!1;#Ce=null;#Ee=0;#Pe=0;#Me=null;#Te=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#ke=!1;#Ie=we._zIndex++;static _borderLineWidth=-1;static _colorManager=new fe;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=we.prototype._resizeWithKeyboard,e=me.TRANSLATE_SMALL,i=me.TRANSLATE_BIG;return xt(this,"_resizerKeyboardManager",new ge([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],we.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[n,r];const[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return xt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new ye({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(we._l10n??=t,we._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),-1!==we._borderLineWidth)return;const i=getComputedStyle(document.documentElement);we._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){yt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#ke}set _isDraggable(t){this.#ke=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#Ie}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#Le(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#ye?this.#ye=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const e=t.relatedTarget;e?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){const[n,r]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/r,this.fixAndSetPosition()}#De([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#De(this.parentDimensions,t,e)}translateInPage(t,e){this.#Ae||=[this.x,this.y,this.width,this.height],this.#De(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#Ae||=[this.x,this.y,this.width,this.height];const{div:i,parentDimensions:[s,n]}=this;if(this.x+=t/s,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:a}=this;const[o,l]=this.getBaseTranslation();r+=o,a+=l;const{style:h}=i;h.left=`${(100*r).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#Ae&&(this.#Ae[0]!==this.x||this.#Ae[1]!==this.y)}get _hasBeenResized(){return!!this.#Ae&&(this.#Ae[2]!==this.width||this.#Ae[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=we,s=i/t,n=i/e;switch(this.rotation){case 90:return[-s,n];case 180:return[s,n];case 270:return[s,-n];default:return[-s,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[i,s]}=this;let{x:n,y:r,width:a,height:o}=this;if(a*=i,o*=s,n*=i,r*=s,this._mustFixPosition)switch(t){case 0:n=Math.max(0,Math.min(i-a,n)),r=Math.max(0,Math.min(s-o,r));break;case 90:n=Math.max(0,Math.min(i-o,n)),r=Math.min(s,Math.max(a,r));break;case 180:n=Math.min(i,Math.max(a,n)),r=Math.min(s,Math.max(o,r));break;case 270:n=Math.min(i,Math.max(o,n)),r=Math.max(0,Math.min(s-a,r))}this.x=n/=i,this.y=r/=s;const[l,h]=this.getBaseTranslation();n+=l,r+=h,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#Re(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return we.#Re(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return we.#Re(t,e,360-this.parentRotation)}#Ne(t){switch(t){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(t,e){const[i,s]=this.parentDimensions,{style:n}=this.div;n.width=`${(100*t/i).toFixed(2)}%`,this.#ge||(n.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:i}=t,s=i.endsWith("%"),n=!this.#ge&&e.endsWith("%");if(s&&n)return;const[r,a]=this.parentDimensions;s||(t.width=`${(100*parseFloat(i)/r).toFixed(2)}%`),this.#ge||n||(t.height=`${(100*parseFloat(e)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#Fe(){if(this.#fe)return;this.#fe=document.createElement("div"),this.#fe.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const i of t){const t=document.createElement("div");this.#fe.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#Oe.bind(this,i),{signal:e}),t.addEventListener("contextmenu",Zt,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#fe)}#Oe(t,e){e.preventDefault();const{isMac:i}=Nt.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#o?.toggle(!1);const s=this._isDraggable;this._isDraggable=!1,this.#me=[e.screenX,e.screenY];const n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#Be.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",te,{passive:!1,signal:r}),window.addEventListener("contextmenu",Zt,{signal:r}),this.#be={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const l=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#o?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#je()};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}#Ve(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e;const[n,r]=this.parentDimensions;this.setDims(n*i,r*s),this.fixAndSetPosition(),this._onResized()}_onResized(){}#je(){if(!this.#be)return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#be;this.#be=null;const n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===i&&o===s||this.addCommands({cmd:this.#Ve.bind(this,n,r,a,o),undo:this.#Ve.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#Be(t,e){const[i,s]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,l=we.MIN_SIZE/i,h=we.MIN_SIZE/s,d=this.#Ne(this.rotation),c=(t,e)=>[d[0]*t+d[2]*e,d[1]*t+d[3]*e],u=this.#Ne(360-this.rotation);let p,g,f=!1,m=!1;switch(t){case"topLeft":f=!0,p=(t,e)=>[0,0],g=(t,e)=>[t,e];break;case"topMiddle":p=(t,e)=>[t/2,0],g=(t,e)=>[t/2,e];break;case"topRight":f=!0,p=(t,e)=>[t,0],g=(t,e)=>[0,e];break;case"middleRight":m=!0,p=(t,e)=>[t,e/2],g=(t,e)=>[0,e/2];break;case"bottomRight":f=!0,p=(t,e)=>[t,e],g=(t,e)=>[0,0];break;case"bottomMiddle":p=(t,e)=>[t/2,e],g=(t,e)=>[t/2,0];break;case"bottomLeft":f=!0,p=(t,e)=>[0,e],g=(t,e)=>[t,0];break;case"middleLeft":m=!0,p=(t,e)=>[0,e/2],g=(t,e)=>[t,e/2]}const b=p(a,o),v=g(a,o);let w=c(...v);const y=we._round(n+w[0]),A=we._round(r+w[1]);let _,x,S=1,C=1;if(e.fromKeyboard)({deltaX:_,deltaY:x}=e);else{const{screenX:t,screenY:i}=e,[s,n]=this.#me;[_,x]=this.screenToPageTranslation(t-s,i-n),this.#me[0]=t,this.#me[1]=i}var E,P;if([_,x]=(E=_/i,P=x/s,[u[0]*E+u[2]*P,u[1]*E+u[3]*P]),f){const t=Math.hypot(a,o);S=C=Math.max(Math.min(Math.hypot(v[0]-b[0]-_,v[1]-b[1]-x)/t,1/a,1/o),l/a,h/o)}else m?S=Math.max(l,Math.min(1,Math.abs(v[0]-b[0]-_)))/a:C=Math.max(h,Math.min(1,Math.abs(v[1]-b[1]-x)))/o;const M=we._round(a*S),T=we._round(o*C);w=c(...g(M,T));const k=y-w[0],I=A-w[1];this.#Ae||=[this.x,this.y,this.width,this.height],this.width=M,this.height=T,this.x=k,this.y=I,this.setDims(i*M,s*T),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#o?.finish()}async addEditToolbar(){return this._editToolbar||this.#xe||(this._editToolbar=new le(this),this.div.append(this._editToolbar.render()),this.#o&&await this._editToolbar.addAltText(this.#o)),this._editToolbar}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#o?.destroy())}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#o||(be.initialize(we._l10n),this.#o=new be(this),this.#he&&(this.#o.data=this.#he,this.#he=null),await this.addEditToolbar())}get altTextData(){return this.#o?.data}set altTextData(t){this.#o&&(this.#o.data=t)}get guessedAltText(){return this.#o?.guessedText}async setGuessedAltText(t){await(this.#o?.setGuessedText(t))}serializeAltText(t){return this.#o?.serialize(t)}hasAltText(){return!!this.#o&&!this.#o.isEmpty()}hasAltTextData(){return this.#o?.hasData()??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#ce?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#He();const[t,e]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);const[i,s]=this.getInitialTranslation();return this.translate(i,s),de(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#Te||=new ve({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#ze.bind(this),onPinching:this.#Ue.bind(this),onPinchEnd:this.#$e.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#ze(){this.#be={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#o?.toggle(!1),this.parent.togglePointerEvents(!1)}#Ue(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;const n=this.#Ne(this.rotation),r=(t,e)=>[n[0]*t+n[2]*e,n[1]*t+n[3]*e],[a,o]=this.parentDimensions,l=this.x,h=this.y,d=this.width,c=this.height,u=we.MIN_SIZE/a,p=we.MIN_SIZE/o;s=Math.max(Math.min(s,1/d,1/c),u/d,p/c);const g=we._round(d*s),f=we._round(c*s);if(g===d&&f===c)return;this.#Ae||=[l,h,d,c];const m=r(d/2,c/2),b=we._round(l+m[0]),v=we._round(h+m[1]),w=r(g/2,f/2);this.x=b-w[0],this.y=v-w[1],this.width=g,this.height=f,this.setDims(a*g,o*f),this.fixAndSetPosition(),this._onResizing()}#$e(){this.#o?.toggle(!0),this.parent.togglePointerEvents(!0),this.#je()}pointerdown(t){const{isMac:e}=Nt.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#ye=!0,this._isDraggable?this.#We(t):this.#Ge(t))}get isSelected(){return this._uiManager.isSelected(this)}#Ge(t){const{isMac:e}=Nt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#We(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const s=new AbortController,n=this._uiManager.combinedSignal(s),r={capture:!0,passive:!1,signal:n},a=t=>{s.abort(),this.#ue=null,this.#ye=!1,this._uiManager.endDragSession()||this.#Ge(t),i&&this._onStopDragging()};e&&(this.#Ee=t.clientX,this.#Pe=t.clientY,this.#ue=t.pointerId,this.#pe=t.pointerType,window.addEventListener("pointermove",(t=>{i||(i=!0,this._onStartDragging());const{clientX:e,clientY:s,pointerId:n}=t;if(n!==this.#ue)return void te(t);const[r,a]=this.screenToPageTranslation(e-this.#Ee,s-this.#Pe);this.#Ee=e,this.#Pe=s,this._uiManager.dragSelectedEditors(r,a)}),r),window.addEventListener("touchmove",te,r),window.addEventListener("pointerdown",(t=>{t.pointerType===this.#pe&&(this.#Te||t.isPrimary)&&a(t),te(t)}),r));const o=t=>{this.#ue&&this.#ue!==t.pointerId?te(t):a(t)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#Ce&&clearTimeout(this.#Ce),this.#Ce=setTimeout((()=>{this.#Ce=null,this.parent?.moveEditorInDOM(this)}),0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){const s=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/s,h=e/s,d=this.x*n,c=this.y*r,u=this.width*n,p=this.height*r;switch(i){case 0:return[d+l+a,r-c-h-p+o,d+l+u+a,r-c-h+o];case 90:return[d+h+a,r-c+l+o,d+h+p+a,r-c+l+u+o];case 180:return[d-l-u+a,r-c+h+o,d-l+a,r-c+h+p+o];case 270:return[d-h-p+a,r-c-l-u+o,d-h+a,r-c-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,s,n,r]=t,a=n-i,o=r-s;switch(this.rotation){case 0:return[i,e-r,a,o];case 90:return[i,e-s,o,a];case 180:return[n,e-s,a,o];case 270:return[n,e-r,o,a];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){this.#xe=!0}disableEditMode(){this.#xe=!1}isInEditMode(){return this.#xe}shouldGetKeyboardEvents(){return this.#Se}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&s>0&&t<n&&i>0}#He(){if(this.#ve||!this.div)return;this.#ve=new AbortController;const t=this._uiManager.combinedSignal(this.#ve);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#He()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){yt("An editor must be serializable")}static async deserialize(t,e,i){const s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i});s.rotation=t.rotation,s.#he=t.accessibilityData;const[n,r]=s.pageDimensions,[a,o,l,h]=s.getRectInCurrentCoords(t.rect,r);return s.x=a/n,s.y=o/r,s.width=l/n,s.height=h/r,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#ve?.abort(),this.#ve=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#Ce&&(clearTimeout(this.#Ce),this.#Ce=null),this.#Le(),this.removeEditToolbar(),this.#Me){for(const t of this.#Me.values())clearTimeout(t);this.#Me=null}this.parent=null,this.#Te?.destroy(),this.#Te=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#Fe(),this.#fe.classList.remove("hidden"),de(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#be={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#fe.children;if(!this.#de){this.#de=Array.from(e);const t=this.#qe.bind(this),i=this.#Xe.bind(this),s=this._uiManager._signal;for(const e of this.#de){const n=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#Ke.bind(this,n),{signal:s}),e.setAttribute("data-l10n-id",we._l10nResizer[n])}}const i=this.#de[0];let s=0;for(const t of e){if(t===i)break;s++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#de.length/4);if(n!==s){if(n<s)for(let t=0;t<s-n;t++)this.#fe.append(this.#fe.firstChild);else if(n>s)for(let t=0;t<n-s;t++)this.#fe.firstChild.before(this.#fe.lastChild);let t=0;for(const i of e){const e=this.#de[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",we._l10nResizer[e])}}this.#Ye(0),this.#Se=!0,this.#fe.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#qe(t){we._resizerKeyboardManager.exec(this,t)}#Xe(t){this.#Se&&t.relatedTarget?.parentNode!==this.#fe&&this.#Le()}#Ke(t){this.#we=this.#Se?t:""}#Ye(t){if(this.#de)for(const e of this.#de)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#Se&&this.#Be(this.#we,{deltaX:t,deltaY:e,fromKeyboard:!0})}#Le(){this.#Se=!1,this.#Ye(-1),this.#je()}_stopResizingWithKeyboard(){this.#Le(),this.div.focus()}select(){this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#o?.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()}))}unselect(){this.#fe?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#o?.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#_e}set isEditing(t){this.#_e=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#ge=!0;const i=t/e,{style:s}=this.div;s.aspectRatio=i,s.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#Me||=new Map;const{action:e}=t;let i=this.#Me.get(e);return i&&clearTimeout(i),i=setTimeout((()=>{this._reportTelemetry(t),this.#Me.delete(e),0===this.#Me.size&&(this.#Me=null)}),we._telemetryTimeout),void this.#Me.set(e,i)}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#ce=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#ce=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===e?.nodeName&&e.classList.contains("annotationContent")&&e.remove()}}class ye extends we{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Ae=3285377520,_e=4294901760,xe=65535;class Se{constructor(t){this.h1=t?4294967295&t:Ae,this.h2=t?4294967295&t:Ae}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,n=t.length;s<n;s++){const n=t.charCodeAt(s);n<=255?e[i++]=n:(e[i++]=n>>>8,e[i++]=255&n)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),i=e.byteLength}const s=i>>2,n=i-4*s,r=new Uint32Array(e.buffer,0,s);let a=0,o=0,l=this.h1,h=this.h2;const d=3432918353,c=461845907,u=11601,p=13715;for(let t=0;t<s;t++)1&t?(a=r[t],a=a*d&_e|a*u&xe,a=a<<15|a>>>17,a=a*c&_e|a*p&xe,l^=a,l=l<<13|l>>>19,l=5*l+3864292196):(o=r[t],o=o*d&_e|o*u&xe,o=o<<15|o>>>17,o=o*c&_e|o*p&xe,h^=o,h=h<<13|h>>>19,h=5*h+3864292196);switch(a=0,n){case 3:a^=e[4*s+2]<<16;case 2:a^=e[4*s+1]<<8;case 1:a^=e[4*s],a=a*d&_e|a*u&xe,a=a<<15|a>>>17,a=a*c&_e|a*p&xe,1&s?l^=a:h^=a}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&_e|36045*t&xe,e=4283543511*e&_e|(2950163797*(e<<16|t>>>16)&_e)>>>16,t^=e>>>1,t=444984403*t&_e|60499*t&xe,e=3301882366*e&_e|(3120437893*(e<<16|t>>>16)&_e)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Ce=Object.freeze({map:null,hash:"",transfer:void 0});class Ee{#Qe=!1;#Je=null;#Ze=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=this.#Ze.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#Ze.get(t)}remove(t){if(this.#Ze.delete(t),0===this.#Ze.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of this.#Ze.values())if(t instanceof we)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=this.#Ze.get(t);let s=!1;if(void 0!==i)for(const[t,n]of Object.entries(e))i[t]!==n&&(s=!0,i[t]=n);else s=!0,this.#Ze.set(t,e);s&&this.#ti(),e instanceof we&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#Ze.has(t)}getAll(){return this.#Ze.size>0?Rt(this.#Ze):null}setAll(t){for(const[e,i]of Object.entries(t))this.setValue(e,i)}get size(){return this.#Ze.size}#ti(){this.#Qe||(this.#Qe=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#Qe&&(this.#Qe=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new Pe(this)}get serializable(){if(0===this.#Ze.size)return Ce;const t=new Map,e=new Se,i=[],s=Object.create(null);let n=!1;for(const[i,r]of this.#Ze){const a=r instanceof we?r.serialize(!1,s):r;a&&(t.set(i,a),e.update(`${i}:${JSON.stringify(a)}`),n||=!!a.bitmap)}if(n)for(const e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:Ce}get editorStats(){let t=null;const e=new Map;for(const i of this.#Ze.values()){if(!(i instanceof we))continue;const s=i.telemetryFinalData;if(!s)continue;const{type:n}=s;e.has(n)||e.set(n,Object.getPrototypeOf(i).constructor),t||=Object.create(null);const r=t[n]||=new Map;for(const[t,e]of Object.entries(s)){if("type"===t)continue;let i=r.get(t);i||(i=new Map,r.set(t,i));const s=i.get(e)??0;i.set(e,s+1)}}for(const[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#Je=null}get modifiedIds(){if(this.#Je)return this.#Je;const t=[];for(const e of this.#Ze.values())e instanceof we&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return this.#Je={ids:new Set(t),hash:t.join(",")}}}class Pe extends Ee{#ei;constructor(t){super();const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);this.#ei={map:n,hash:i,transfer:s}}get print(){yt("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ei}get modifiedIds(){return xt(this,"modifiedIds",{ids:new Set,hash:""})}}class Me{#ii=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#ii.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(t&&!this.#ii.has(t.loadedName))if(At(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:s,style:n}=t,r=new FontFace(i,s,n);this.addNativeFontFace(r);try{await r.load(),this.#ii.add(i),e?.(t)}catch{wt(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}}else yt("Not implemented: loadSystemFont without the Font Loading API.")}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void await this.loadSystemFont(t);if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw wt(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise((e=>{const i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)}))}}get isFontLoadingAPISupported(){return xt(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let t=!1;return(y||"undefined"!=typeof navigator&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),xt(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){const{loadingRequests:e}=this,i={done:!1,complete:function(){for(At(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;){const t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(i),i}get _loadTestFont(){return xt(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function i(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function s(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let n,r;const a=this._document.createElement("canvas");a.width=1,a.height=1;const o=a.getContext("2d");let l=0;const h=`lt${Date.now()}${this.loadTestFontId++}`;let d=this._loadTestFont;d=s(d,976,h.length,h);const c=1482184792;let u=i(d,16);for(n=0,r=h.length-3;n<r;n+=4)u=u-c+i(h,n)|0;var p;n<h.length&&(u=u-c+i(h+"XXX",n)|0),d=s(d,16,4,(p=u,String.fromCharCode(p>>24&255,p>>16&255,p>>8&255,255&p)));const g=`@font-face {font-family:"${h}";src:${`url(data:font/opentype;base64,${btoa(d)});`}}`;this.insertRule(g);const f=this._document.createElement("div");f.style.visibility="hidden",f.style.width=f.style.height="10px",f.style.position="absolute",f.style.top=f.style.left="0px";for(const e of[t.loadedName,h]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,f.append(t)}this._document.body.append(f),function t(e,i){if(++l>30)return wt("Load test font never loaded."),void i();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?i():setTimeout(t.bind(null,e,i))}(h,(()=>{f.remove(),e.complete()}))}}class Te{constructor(t,{disableFontFace:e=!1,fontExtraProperties:i=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const e in t)this[e]=t[e];this.disableFontFace=!0===e,this.fontExtraProperties=!0===i,this._inspectFont=s}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${e=this.data,Uint8Array.prototype.toBase64?e.toBase64():btoa(Lt(e))});`;var e;let i;if(this.cssFontInfo){let e=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(e+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),i=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${e}src:${t}}`}else i=`@font-face {font-family:"${this.loadedName}";src:${t}}`;return this._inspectFont?.(this,t),i}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];const i=this.loadedName+"_path_"+e;let s;try{s=t.get(i)}catch(t){wt(`getPathGenerator - ignoring character: "${t}".`)}const n=new Path2D(s||"");return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=n}}const ke=1,Ie=2,Le=1,De=2,Re=3,Ne=4,Fe=5,Oe=6,Be=7,je=8;function Ve(){}function He(t){if(t instanceof It||t instanceof Pt||t instanceof Mt||t instanceof Ct||t instanceof Tt||t instanceof Et)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||yt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new It(t.message);case"InvalidPDFException":return new Pt(t.message);case"MissingPDFException":return new Mt(t.message);case"PasswordException":return new Ct(t.message,t.code);case"UnexpectedResponseException":return new Tt(t.message,t.status);case"UnknownErrorException":return new Et(t.message,t.details)}return new Et(t.message,t.toString())}class ze{#si=new AbortController;constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),i.addEventListener("message",this.#ni.bind(this),{signal:this.#si.signal})}#ni({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#ri(t);if(t.callback){const e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],t.callback===ke)i.resolve(t.data);else{if(t.callback!==Ie)throw new Error("Unexpected callback case");i.reject(He(t.reason))}return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const i=this.sourceName,s=t.sourceName,n=this.comObj;Promise.try(e,t.data).then((function(e){n.postMessage({sourceName:i,targetName:s,callback:ke,callbackId:t.callbackId,data:e})}),(function(e){n.postMessage({sourceName:i,targetName:s,callback:Ie,callbackId:t.callbackId,reason:He(e)})}))}else t.streamId?this.#ai(t):e(t.data)}on(t,e){const i=this.actionHandler;if(i[t])throw new Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){const s=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[s]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(t){n.reject(t)}return n.promise}sendWithStream(t,e,i,s){const n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{const l=Promise.withResolvers();return this.streamControllers[n]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:i.desiredSize},s),l.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[n].pullCall=e,o.postMessage({sourceName:r,targetName:a,stream:Oe,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{At(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[n].cancelCall=e,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:Le,streamId:n,reason:He(t)}),e.promise}},i)}#ai(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(t,r=1,a){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=r,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:i,targetName:s,stream:Ne,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Re,streamId:e}),delete r.streamSinks[e])},error(t){At(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Fe,streamId:e,reason:He(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(a,t.data,o).then((function(){n.postMessage({sourceName:i,targetName:s,stream:je,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:je,streamId:e,reason:He(t)})}))}#ri(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case je:t.success?r.startCall.resolve():r.startCall.reject(He(t.reason));break;case Be:t.success?r.pullCall.resolve():r.pullCall.reject(He(t.reason));break;case Oe:if(!a){n.postMessage({sourceName:i,targetName:s,stream:Be,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||Ve).then((function(){n.postMessage({sourceName:i,targetName:s,stream:Be,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Be,streamId:e,reason:He(t)})}));break;case Ne:if(At(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case Re:if(At(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#oi(r,e);break;case Fe:At(r,"error should have stream controller"),r.controller.error(He(t.reason)),this.#oi(r,e);break;case De:t.success?r.cancelCall.resolve():r.cancelCall.reject(He(t.reason)),this.#oi(r,e);break;case Le:if(!a)break;const o=He(t.reason);Promise.try(a.onCancel||Ve,o).then((function(){n.postMessage({sourceName:i,targetName:s,stream:De,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:De,streamId:e,reason:He(t)})})),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#oi(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#si?.abort(),this.#si=null}}class Ue{#li=!1;constructor({enableHWA:t=!1}){this.#li=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#li})}}reset(t,e,i){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){yt("Abstract method `_createCanvas` called.")}}class $e{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then((t=>({cMapData:t,isCompressed:this.isCompressed}))).catch((t=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)}))}async _fetch(t){yt("Abstract method `_fetch` called.")}}class We extends $e{async _fetch(t){const e=await $t(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):Dt(e)}}class Ge{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,s,n){return"none"}destroy(t=!1){}}class qe{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch((t=>{throw new Error(`Unable to load font data at: ${e}`)}))}async _fetch(t){yt("Abstract method `_fetch` called.")}}class Xe extends qe{async _fetch(t){const e=await $t(t,"arraybuffer");return new Uint8Array(e)}}async function Ke(t){const e=process.getBuiltinModule("fs"),i=await e.promises.readFile(t);return new Uint8Array(i)}y&&wt("Please use the `legacy` build in Node.js environments.");const Ye="Fill",Qe="Stroke",Je="Shading";function Ze(t,e){if(!e)return;const i=e[2]-e[0],s=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],i,s),t.clip(n)}class ti{getPattern(){yt("Abstract method `getPattern` called.")}}class ei extends ti{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;"axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const t of this._colorStops)e.addColorStop(t[0],t[1]);return e}getPattern(t,e,i,s){let n;if(s===Qe||s===Ye){const r=e.current.getClippedPathBoundingBox(s,ne(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,l=e.cachedCanvases.getCanvas("pattern",a,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-r[0],-r[1]),i=Ot.transform(i,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),Ze(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),n=t.createPattern(l.canvas,"no-repeat");const d=new DOMMatrix(i);n.setTransform(d)}else Ze(t,this._bbox),n=this._createGradient(t);return n}}function ii(t,e,i,s,n,r,a,o){const l=e.coords,h=e.colors,d=t.data,c=4*t.width;let u;l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=r,r=a,a=u),l[s+1]>l[n+1]&&(u=s,s=n,n=u,u=a,a=o,o=u),l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=r,r=a,a=u);const p=(l[i]+e.offsetX)*e.scaleX,g=(l[i+1]+e.offsetY)*e.scaleY,f=(l[s]+e.offsetX)*e.scaleX,m=(l[s+1]+e.offsetY)*e.scaleY,b=(l[n]+e.offsetX)*e.scaleX,v=(l[n+1]+e.offsetY)*e.scaleY;if(g>=v)return;const w=h[r],y=h[r+1],A=h[r+2],_=h[a],x=h[a+1],S=h[a+2],C=h[o],E=h[o+1],P=h[o+2],M=Math.round(g),T=Math.round(v);let k,I,L,D,R,N,F,O;for(let t=M;t<=T;t++){if(t<m){const e=t<g?0:(g-t)/(g-m);k=p-(p-f)*e,I=w-(w-_)*e,L=y-(y-x)*e,D=A-(A-S)*e}else{let e;e=t>v?1:m===v?0:(m-t)/(m-v),k=f-(f-b)*e,I=_-(_-C)*e,L=x-(x-E)*e,D=S-(S-P)*e}let e;e=t<g?0:t>v?1:(g-t)/(g-v),R=p-(p-b)*e,N=w-(w-C)*e,F=y-(y-E)*e,O=A-(A-P)*e;const i=Math.round(Math.min(k,R)),s=Math.round(Math.max(k,R));let n=c*t+4*i;for(let t=i;t<=s;t++)e=(k-t)/(k-R),e<0?e=0:e>1&&(e=1),d[n++]=I-(I-N)*e|0,d[n++]=L-(L-F)*e|0,d[n++]=D-(D-O)*e|0,d[n++]=255}}function si(t,e,i){const s=e.coords,n=e.colors;let r,a;switch(e.type){case"lattice":const o=e.verticesPerRow,l=Math.floor(s.length/o)-1,h=o-1;for(r=0;r<l;r++){let e=r*o;for(let r=0;r<h;r++,e++)ii(t,i,s[e],s[e+1],s[e+o],n[e],n[e+1],n[e+o]),ii(t,i,s[e+o+1],s[e+1],s[e+o],n[e+o+1],n[e+1],n[e+o])}break;case"triangles":for(r=0,a=s.length;r<a;r+=3)ii(t,i,s[r],s[r+1],s[r+2],n[r],n[r+1],n[r+2]);break;default:throw new Error("illegal figure")}}class ni extends ti{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,i){const s=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-s,a=Math.ceil(this._bounds[3])-n,o=Math.min(Math.ceil(Math.abs(r*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(a*t[1]*1.1)),3e3),h=r/o,d=a/l,c={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-n,scaleX:1/h,scaleY:1/d},u=o+4,p=l+4,g=i.getCanvas("mesh",u,p),f=g.context,m=f.createImageData(o,l);if(e){const t=m.data;for(let i=0,s=t.length;i<s;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}for(const t of this._figures)si(m,t,c);f.putImageData(m,2,2);return{canvas:g.canvas,offsetX:s-2*h,offsetY:n-2*d,scaleX:h,scaleY:d}}getPattern(t,e,i,s){let n;if(Ze(t,this._bbox),s===Je)n=Ot.singularValueDecompose2dScale(ne(t));else if(n=Ot.singularValueDecompose2dScale(e.baseTransform),this.matrix){const t=Ot.singularValueDecompose2dScale(this.matrix);n=[n[0]*t[0],n[1]*t[1]]}const r=this._createMeshCanvas(n,s===Je?null:this._background,e.cachedCanvases);return s!==Je&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class ri extends ti{getPattern(){return"hotpink"}}const ai=1,oi=2;class li{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s,n){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=i,this.canvasGraphicsFactory=s,this.baseTransform=n}createPatternCanvas(t){const{bbox:e,operatorList:i,paintType:s,tilingType:n,color:r,canvasGraphicsFactory:a}=this;let{xstep:o,ystep:l}=this;o=Math.abs(o),l=Math.abs(l),vt("TilingType: "+n);const h=e[0],d=e[1],c=e[2],u=e[3],p=c-h,g=u-d,f=Ot.singularValueDecompose2dScale(this.matrix),m=Ot.singularValueDecompose2dScale(this.baseTransform),b=f[0]*m[0],v=f[1]*m[1];let w=p,y=g,A=!1,_=!1;const x=Math.ceil(o*b),S=Math.ceil(l*v);x>=Math.ceil(p*b)?w=o:A=!0,S>=Math.ceil(g*v)?y=l:_=!0;const C=this.getSizeAndScale(w,this.ctx.canvas.width,b),E=this.getSizeAndScale(y,this.ctx.canvas.height,v),P=t.cachedCanvases.getCanvas("pattern",C.size,E.size),M=P.context,T=a.createCanvasGraphics(M);if(T.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(T,s,r),M.translate(-C.scale*h,-E.scale*d),T.transform(C.scale,0,0,E.scale,0,0),M.save(),this.clipBbox(T,h,d,c,u),T.baseTransform=ne(T.ctx),T.executeOperatorList(i),T.endDrawing(),M.restore(),A||_){const e=P.canvas;A&&(w=o),_&&(y=l);const i=this.getSizeAndScale(w,this.ctx.canvas.width,b),s=this.getSizeAndScale(y,this.ctx.canvas.height,v),n=i.size,r=s.size,a=t.cachedCanvases.getCanvas("pattern-workaround",n,r),c=a.context,u=A?Math.floor(p/o):0,f=_?Math.floor(g/l):0;for(let t=0;t<=u;t++)for(let i=0;i<=f;i++)c.drawImage(e,n*t,r*i,n,r,0,0,n,r);return{canvas:a.canvas,scaleX:i.scale,scaleY:s.scale,offsetX:h,offsetY:d}}return{canvas:P.canvas,scaleX:C.scale,scaleY:E.scale,offsetX:h,offsetY:d}}getSizeAndScale(t,e,i){const s=Math.max(li.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*i);return n>=s?n=s:i=n/t,{scale:i,size:n}}clipBbox(t,e,i,s,n){const r=s-e,a=n-i;t.ctx.rect(e,i,r,a),t.current.updateRectMinMax(ne(t.ctx),[e,i,s,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const s=t.ctx,n=t.current;switch(e){case ai:const t=this.ctx;s.fillStyle=t.fillStyle,s.strokeStyle=t.strokeStyle,n.fillColor=t.fillStyle,n.strokeColor=t.strokeStyle;break;case oi:const r=Ot.makeHexColor(i[0],i[1],i[2]);s.fillStyle=r,s.strokeStyle=r,n.fillColor=r,n.strokeColor=r;break;default:throw new kt(`Unsupported paint type: ${e}`)}}getPattern(t,e,i,s){let n=i;s!==Je&&(n=Ot.transform(n,e.baseTransform),this.matrix&&(n=Ot.transform(n,this.matrix)));const r=this.createPatternCanvas(e);let a=new DOMMatrix(n);a=a.translate(r.offsetX,r.offsetY),a=a.scale(1/r.scaleX,1/r.scaleY);const o=t.createPattern(r.canvas,"repeat");return o.setTransform(a),o}}function hi({src:t,srcPos:e=0,dest:i,width:s,height:n,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=Nt.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],d=s>>3,c=7&s,u=t.length;i=new Uint32Array(i.buffer);let p=0;for(let s=0;s<n;s++){for(const s=e+d;e<s;e++){const s=e<u?t[e]:255;i[p++]=128&s?h:l,i[p++]=64&s?h:l,i[p++]=32&s?h:l,i[p++]=16&s?h:l,i[p++]=8&s?h:l,i[p++]=4&s?h:l,i[p++]=2&s?h:l,i[p++]=1&s?h:l}if(0===c)continue;const s=e<u?t[e++]:255;for(let t=0;t<c;t++)i[p++]=s&1<<7-t?h:l}return{srcPos:e,destPos:p}}const di=16;class ci{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let s;return void 0!==this.cache[t]?(s=this.cache[t],this.canvasFactory.reset(s,e,i)):(s=this.canvasFactory.create(e,i),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function ui(t,e,i,s,n,r,a,o,l,h){const[d,c,u,p,g,f]=ne(t);if(0===c&&0===u){const m=a*d+g,b=Math.round(m),v=o*p+f,w=Math.round(v),y=(a+l)*d+g,A=Math.abs(Math.round(y)-b)||1,_=(o+h)*p+f,x=Math.abs(Math.round(_)-w)||1;return t.setTransform(Math.sign(d),0,0,Math.sign(p),b,w),t.drawImage(e,i,s,n,r,0,0,A,x),t.setTransform(d,c,u,p,g,f),[A,x]}if(0===d&&0===p){const m=o*u+g,b=Math.round(m),v=a*c+f,w=Math.round(v),y=(o+h)*u+g,A=Math.abs(Math.round(y)-b)||1,_=(a+l)*c+f,x=Math.abs(Math.round(_)-w)||1;return t.setTransform(0,Math.sign(c),Math.sign(u),0,b,w),t.drawImage(e,i,s,n,r,0,0,x,A),t.setTransform(d,c,u,p,g,f),[x,A]}t.drawImage(e,i,s,n,r,a,o,l,h);return[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class pi{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=A,this.textMatrixScale=1,this.fontMatrix=_,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=F,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,i){[e,i]=Ot.applyTransform([e,i],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,i),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,i)}updateRectMinMax(t,e){const i=Ot.applyTransform(e,t),s=Ot.applyTransform(e.slice(2),t),n=Ot.applyTransform([e[0],e[3]],t),r=Ot.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,i[0],s[0],n[0],r[0]),this.minY=Math.min(this.minY,i[1],s[1],n[1],r[1]),this.maxX=Math.max(this.maxX,i[0],s[0],n[0],r[0]),this.maxY=Math.max(this.maxY,i[1],s[1],n[1],r[1])}updateScalingPathMinMax(t,e){Ot.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,i,s,n,r,a,o,l,h){const d=Ot.bezierBoundingBox(e,i,s,n,r,a,o,l,h);h||this.updateRectMinMax(t,d)}getPathBoundingBox(t=Ye,e=null){const i=[this.minX,this.minY,this.maxX,this.maxY];if(t===Qe){e||yt("Stroke bounding box must include transform.");const t=Ot.singularValueDecompose2dScale(e),s=t[0]*this.lineWidth/2,n=t[1]*this.lineWidth/2;i[0]-=s,i[1]-=n,i[2]+=s,i[3]+=n}return i}updateClipFromPath(){const t=Ot.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=Ye,e=null){return Ot.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function gi(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,s=e.width,n=i%di,r=(i-n)/di,a=0===n?r:r+1,o=t.createImageData(s,di);let l,h=0;const d=e.data,c=o.data;let u,p,g,f;if(e.kind===z.GRAYSCALE_1BPP){const e=d.byteLength,i=new Uint32Array(c.buffer,0,c.byteLength>>2),f=i.length,m=s+7>>3,b=4294967295,v=Nt.isLittleEndian?4278190080:255;for(u=0;u<a;u++){for(g=u<r?di:n,l=0,p=0;p<g;p++){const t=e-h;let n=0;const r=t>m?s:8*t-7,a=-8&r;let o=0,c=0;for(;n<a;n+=8)c=d[h++],i[l++]=128&c?b:v,i[l++]=64&c?b:v,i[l++]=32&c?b:v,i[l++]=16&c?b:v,i[l++]=8&c?b:v,i[l++]=4&c?b:v,i[l++]=2&c?b:v,i[l++]=1&c?b:v;for(;n<r;n++)0===o&&(c=d[h++],o=128),i[l++]=c&o?b:v,o>>=1}for(;l<f;)i[l++]=0;t.putImageData(o,0,u*di)}}else if(e.kind===z.RGBA_32BPP){for(p=0,f=s*di*4,u=0;u<r;u++)c.set(d.subarray(h,h+f)),h+=f,t.putImageData(o,0,p),p+=di;u<a&&(f=s*n*4,c.set(d.subarray(h,h+f)),t.putImageData(o,0,p))}else{if(e.kind!==z.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=di,f=s*g,u=0;u<a;u++){for(u>=r&&(g=n,f=s*g),l=0,p=f;p--;)c[l++]=d[h++],c[l++]=d[h++],c[l++]=d[h++],c[l++]=255;t.putImageData(o,0,u*di)}}}function fi(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,s=e.width,n=i%di,r=(i-n)/di,a=0===n?r:r+1,o=t.createImageData(s,di);let l=0;const h=e.data,d=o.data;for(let e=0;e<a;e++){const i=e<r?di:n;({srcPos:l}=hi({src:h,srcPos:l,dest:d,width:s,height:i,nonBlackColor:0})),t.putImageData(o,0,e*di)}}function mi(t,e){const i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of i)void 0!==t[s]&&(e[s]=t[s]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function bi(t){if(t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0),!y){const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}}function vi(t,e){if(e)return!0;const i=Ot.singularValueDecompose2dScale(t);i[0]=Math.fround(i[0]),i[1]=Math.fround(i[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*Ut.PDF_TO_CSS_UNITS);return i[0]<=s&&i[1]<=s}const wi=["butt","round","square"],yi=["miter","round","bevel"],Ai={},_i={};class xi{constructor(t,e,i,s,n,{optionalContentConfig:r,markedContentStack:a=null},o,l){this.ctx=t,this.current=new pi(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=n,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=r,this.cachedCanvases=new ci(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,i){const t=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...ne(this.compositeCtx))}this.ctx.save(),bi(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=ne(this.ctx)}executeOperatorList(t,e,i,s){const n=t.argsArray,r=t.fnArray;let a=e||0;const o=n.length;if(o===a)return a;const l=o-a>10&&"function"==typeof i,h=l?Date.now()+15:0;let d=0;const c=this.commonObjs,u=this.objs;let p;for(;;){if(void 0!==s&&a===s.nextBreakPoint)return s.breakIt(a,i),a;if(p=r[a],p!==pt.dependency)this[p].apply(this,n[a]);else for(const t of n[a]){const e=t.startsWith("g_")?c:u;if(!e.has(t))return e.get(t,i),a}if(a++,a===o)return a;if(l&&++d>10){if(Date.now()>h)return i(),a;d=0}}}#hi(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#hi(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#di()}#di(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const i=t.width??t.displayWidth,s=t.height??t.displayHeight;let n,r,a=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=i,h=s,d="prescale1";for(;a>2&&l>1||o>2&&h>1;){let e=l,i=h;a>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),a/=l/e),o>2&&h>1&&(i=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/i),n=this.cachedCanvases.getCanvas(d,e,i),r=n.context,r.clearRect(0,0,e,i),r.drawImage(t,0,0,l,h,0,0,e,i),t=n.canvas,l=e,h=i,d="prescale1"===d?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t){const e=this.ctx,{width:i,height:s}=t,n=this.current.fillColor,r=this.current.patternFill,a=ne(e);let o,l,h,d;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;l=JSON.stringify(r?a:[a.slice(0,4),n]),o=this._cachedBitmapsMap.get(e),o||(o=new Map,this._cachedBitmapsMap.set(e,o));const i=o.get(l);if(i&&!r){return{canvas:i,offsetX:Math.round(Math.min(a[0],a[2])+a[4]),offsetY:Math.round(Math.min(a[1],a[3])+a[5])}}h=i}h||(d=this.cachedCanvases.getCanvas("maskCanvas",i,s),fi(d.context,t));let c=Ot.transform(a,[1/i,0,0,-1/s,0,0]);c=Ot.transform(c,[1,0,0,1,0,-s]);const[u,p,g,f]=Ot.getAxialAlignedBoundingBox([0,0,i,s],c),m=Math.round(g-u)||1,b=Math.round(f-p)||1,v=this.cachedCanvases.getCanvas("fillCanvas",m,b),w=v.context,y=u,A=p;w.translate(-y,-A),w.transform(...c),h||(h=this._scaleImage(d.canvas,re(w)),h=h.img,o&&r&&o.set(l,h)),w.imageSmoothingEnabled=vi(ne(w),t.interpolate),ui(w,h,0,0,h.width,h.height,0,0,i,s),w.globalCompositeOperation="source-in";const _=Ot.transform(re(w),[1,0,0,1,-y,-A]);return w.fillStyle=r?n.getPattern(e,this,_,Ye):n,w.fillRect(0,0,i,s),o&&!r&&(this.cachedCanvases.delete("fillCanvas"),o.set(l,v.canvas)),{canvas:v.canvas,offsetX:Math.round(y),offsetY:Math.round(A)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=wi[t]}setLineJoin(t){this.ctx.lineJoin=yi[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const i=this.ctx;void 0!==i.setLineDash&&(i.setLineDash(t),i.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,i]of t)switch(e){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i[0],i[1]);break;case"CA":this.current.strokeAlpha=i;break;case"ca":this.current.fillAlpha=i,this.ctx.globalAlpha=i;break;case"BM":this.ctx.globalCompositeOperation=i;break;case"SMask":this.current.activeSMask=i?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(i,t,e);this.suspendedCtx=this.ctx,this.ctx=s.context;const n=this.ctx;n.setTransform(...ne(this.suspendedCtx)),mi(this.suspendedCtx,n),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,i){e.translate(t,i),this.__originalTranslate(t,i)},t.scale=function(t,i){e.scale(t,i),this.__originalScale(t,i)},t.transform=function(t,i,s,n,r,a){e.transform(t,i,s,n,r,a),this.__originalTransform(t,i,s,n,r,a)},t.setTransform=function(t,i,s,n,r,a){e.setTransform(t,i,s,n,r,a),this.__originalSetTransform(t,i,s,n,r,a)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,i){e.moveTo(t,i),this.__originalMoveTo(t,i)},t.lineTo=function(t,i){e.lineTo(t,i),this.__originalLineTo(t,i)},t.bezierCurveTo=function(t,i,s,n,r,a){e.bezierCurveTo(t,i,s,n,r,a),this.__originalBezierCurveTo(t,i,s,n,r,a)},t.rect=function(t,i,s,n){e.rect(t,i,s,n),this.__originalRect(t,i,s,n)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(n,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),mi(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,i,s){const n=s[0],r=s[1],a=s[2]-n,o=s[3]-r;0!==a&&0!==o&&(this.genericComposeSMask(e.context,i,a,o,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,s,n,r,a,o,l,h,d){let c=t.canvas,u=o-h,p=l-d;if(r){const e=Ot.makeHexColor(...r);if(u<0||p<0||u+i>c.width||p+s>c.height){const t=this.cachedCanvases.getCanvas("maskExtension",i,s),n=t.context;n.drawImage(c,-u,-p),n.globalCompositeOperation="destination-atop",n.fillStyle=e,n.fillRect(0,0,i,s),n.globalCompositeOperation="source-over",c=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const n=new Path2D;n.rect(u,p,i,s),t.clip(n),t.globalCompositeOperation="destination-atop",t.fillStyle=e,t.fillRect(u,p,i,s),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===n&&a?e.filter=this.filterFactory.addAlphaFilter(a):"Luminosity"===n&&(e.filter=this.filterFactory.addLuminosityFilter(a));const g=new Path2D;g.rect(o,l,i,s),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(c,u,p,i,s,o,l,i,s),e.restore()}save(){this.inSMaskMode?(mi(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),mi(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,i,s,n,r){this.ctx.transform(t,e,i,s,n,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i){const s=this.ctx,n=this.current;let r,a,o=n.x,l=n.y;const h=ne(s),d=0===h[0]&&0===h[3]||0===h[1]&&0===h[2],c=d?i.slice(0):null;for(let i=0,u=0,p=t.length;i<p;i++)switch(0|t[i]){case pt.rectangle:o=e[u++],l=e[u++];const t=e[u++],i=e[u++],p=o+t,g=l+i;s.moveTo(o,l),0===t||0===i?s.lineTo(p,g):(s.lineTo(p,l),s.lineTo(p,g),s.lineTo(o,g)),d||n.updateRectMinMax(h,[o,l,p,g]),s.closePath();break;case pt.moveTo:o=e[u++],l=e[u++],s.moveTo(o,l),d||n.updatePathMinMax(h,o,l);break;case pt.lineTo:o=e[u++],l=e[u++],s.lineTo(o,l),d||n.updatePathMinMax(h,o,l);break;case pt.curveTo:r=o,a=l,o=e[u+4],l=e[u+5],s.bezierCurveTo(e[u],e[u+1],e[u+2],e[u+3],o,l),n.updateCurvePathMinMax(h,r,a,e[u],e[u+1],e[u+2],e[u+3],o,l,c),u+=6;break;case pt.curveTo2:r=o,a=l,s.bezierCurveTo(o,l,e[u],e[u+1],e[u+2],e[u+3]),n.updateCurvePathMinMax(h,r,a,o,l,e[u],e[u+1],e[u+2],e[u+3],c),o=e[u+2],l=e[u+3],u+=4;break;case pt.curveTo3:r=o,a=l,o=e[u+2],l=e[u+3],s.bezierCurveTo(e[u],e[u+1],o,l,o,l),n.updateCurvePathMinMax(h,r,a,e[u],e[u+1],o,l,o,l,c),u+=4;break;case pt.closePath:s.closePath()}d&&n.updateScalingPathMinMax(h,c),n.setCurrentPoint(o,l)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,i=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof i&&i?.getPattern?(e.save(),e.strokeStyle=i.getPattern(e,this,re(e),Qe),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){const e=this.ctx,i=this.current.fillColor;let s=!1;this.current.patternFill&&(e.save(),e.fillStyle=i.getPattern(e,this,re(e),Ye),s=!0);const n=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==n&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),s&&e.restore(),t&&this.consumePath(n)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Ai}eoClip(){this.pendingClip=_i}beginText(){this.current.textMatrix=A,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(void 0===t)return void e.beginPath();const i=new Path2D,s=e.getTransform().invertSelf();for(const{transform:e,x:n,y:r,fontSize:a,path:o}of t)i.addPath(o,new DOMMatrix(e).preMultiplySelf(s).translate(n,r).scale(a,-a));e.clip(i),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){const i=this.commonObjs.get(t),s=this.current;if(!i)throw new Error(`Can't find font for ${t}`);if(s.fontMatrix=i.fontMatrix||_,0!==s.fontMatrix[0]&&0!==s.fontMatrix[3]||wt("Invalid font matrix for font "+t),e<0?(e=-e,s.fontDirection=-1):s.fontDirection=1,this.current.font=i,this.current.fontSize=e,i.isType3Font)return;const n=i.loadedName||"sans-serif",r=i.systemFontInfo?.css||`"${n}", ${i.fallbackName}`;let a="normal";i.black?a="900":i.bold&&(a="bold");const o=i.italic?"italic":"normal";let l=e;e<16?l=16:e>100&&(l=100),this.current.fontSizeScale=e/l,this.ctx.font=`${o} ${a} ${l}px ${r}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,i,s,n,r){this.current.textMatrix=[t,e,i,s,n,r],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#ci(t,e,i){const s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,n){const r=this.ctx,a=this.current,o=a.font,l=a.textRenderingMode,h=a.fontSize/a.fontSizeScale,d=l&V,c=!!(l&H),u=a.patternFill&&!o.missingFile,p=a.patternStroke&&!o.missingFile;let g;if((o.disableFontFace||c||u||p)&&(g=o.getPathGenerator(this.commonObjs,t)),o.disableFontFace||u||p){if(r.save(),r.translate(e,i),r.scale(h,-h),d===F||d===B)if(s){const t=r.getTransform();r.setTransform(...s),r.fill(this.#ci(g,t,s))}else r.fill(g);if(d===O||d===B)if(n){const t=r.getTransform();r.setTransform(...n),r.stroke(this.#ci(g,t,n))}else r.lineWidth/=h,r.stroke(g);r.restore()}else d!==F&&d!==B||r.fillText(t,e,i),d!==O&&d!==B||r.strokeText(t,e,i);if(c){(this.pendingTextPaths||=[]).push({transform:ne(r),x:e,y:i,fontSize:h,path:g})}}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let i=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){i=!0;break}return xt(this,"isFontSubpixelAAEnabled",i)}showText(t){const e=this.current,i=e.font;if(i.isType3Font)return this.showType3Text(t);const s=e.fontSize;if(0===s)return;const n=this.ctx,r=e.fontSizeScale,a=e.charSpacing,o=e.wordSpacing,l=e.fontDirection,h=e.textHScale*l,d=t.length,c=i.vertical,u=c?1:-1,p=i.defaultVMetrics,g=s*e.fontMatrix[0],f=e.textRenderingMode===F&&!i.disableFontFace&&!e.patternFill;let m,b;if(n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),l>0?n.scale(h,-1):n.scale(h,1),e.patternFill){n.save();const t=e.fillColor.getPattern(n,this,re(n),Ye);m=ne(n),n.restore(),n.fillStyle=t}if(e.patternStroke){n.save();const t=e.strokeColor.getPattern(n,this,re(n),Qe);b=ne(n),n.restore(),n.strokeStyle=t}let v=e.lineWidth;const w=e.textMatrixScale;if(0===w||0===v){const t=e.textRenderingMode&V;t!==O&&t!==B||(v=this.getSinglePixelWidth())}else v/=w;if(1!==r&&(n.scale(r,r),v/=r),n.lineWidth=v,i.isInvalidPDFjsFont){const i=[];let s=0;for(const e of t)i.push(e.unicode),s+=e.width;return n.fillText(i.join(""),0,0),e.x+=s*g*h,n.restore(),void this.compose()}let y,A=0;for(y=0;y<d;++y){const e=t[y];if("number"==typeof e){A+=u*e*s/1e3;continue}let h=!1;const d=(e.isSpace?o:0)+a,v=e.fontChar,w=e.accent;let _,x,S=e.width;if(c){const t=e.vmetric||p,i=-(e.vmetric?t[1]:.5*S)*g,s=t[2]*g;S=t?-t[0]:S,_=i/r,x=(A+s)/r}else _=A/r,x=0;if(i.remeasure&&S>0){const t=1e3*n.measureText(v).width/s*r;if(S<t&&this.isFontSubpixelAAEnabled){const e=S/t;h=!0,n.save(),n.scale(e,1),_/=e}else S!==t&&(_+=(S-t)/2e3*s/r)}if(this.contentVisible&&(e.isInFont||i.missingFile))if(f&&!w)n.fillText(v,_,x);else if(this.paintChar(v,_,x,m,b),w){const t=_+s*w.offset.x/r,e=x-s*w.offset.y/r;this.paintChar(w.fontChar,t,e,m,b)}A+=c?S*g-d*l:S*g+d*l,h&&n.restore()}c?e.y-=A:e.x+=A*h,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,i=this.current,s=i.font,n=i.fontSize,r=i.fontDirection,a=s.vertical?1:-1,o=i.charSpacing,l=i.wordSpacing,h=i.textHScale*r,d=i.fontMatrix||_,c=t.length;let u,p,g,f;if(!(i.textRenderingMode===j)&&0!==n){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...i.textMatrix),e.translate(i.x,i.y),e.scale(h,r),u=0;u<c;++u){if(p=t[u],"number"==typeof p){f=a*p*n/1e3,this.ctx.translate(f,0),i.x+=f*h;continue}const r=(p.isSpace?l:0)+o,c=s.charProcOperatorList[p.operatorListId];if(!c){wt(`Type3 character "${p.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=p,this.save(),e.scale(n,n),e.transform(...d),this.executeOperatorList(c),this.restore());g=Ot.applyTransform([p.width,0],d)[0]*n+r,e.translate(g,0),i.x+=g*h}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,i,s,n,r){this.ctx.rect(i,s,n-i,r-s),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){const i=t[1],s=this.baseTransform||ne(this.ctx),n={createCanvasGraphics:t=>new xi(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new li(t,i,this.ctx,n,s)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,i){this.ctx.strokeStyle=this.current.strokeColor=Ot.makeHexColor(t,e,i),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,i){this.ctx.fillStyle=this.current.fillColor=Ot.makeHexColor(t,e,i),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let i;return this.cachedPatterns.has(t)?i=this.cachedPatterns.get(t):(i=function(t){switch(t[0]){case"RadialAxial":return new ei(t);case"Mesh":return new ni(t);case"Dummy":return new ri}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,i)),e&&(i.matrix=e),i}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const i=this._getPattern(t);e.fillStyle=i.getPattern(e,this,re(e),Je);const s=re(e);if(s){const{width:t,height:i}=e.canvas,[n,r,a,o]=Ot.getAxialAlignedBoundingBox([0,0,t,i],s);this.ctx.fillRect(n,r,a-n,o-r)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){yt("Should not call beginInlineImage")}beginImageData(){yt("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=ne(this.ctx),e)){const t=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],t,i),this.current.updateRectMinMax(ne(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||vt("TODO: Support non-isolated groups."),t.knockout&&wt("Knockout groups not supported.");const i=ne(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let s=Ot.getAxialAlignedBoundingBox(t.bbox,ne(e));const n=[0,0,e.canvas.width,e.canvas.height];s=Ot.intersect(s,n)||[0,0,0,0];const r=Math.floor(s[0]),a=Math.floor(s[1]),o=Math.max(Math.ceil(s[2])-r,1),l=Math.max(Math.ceil(s[3])-a,1);this.current.startNewPathAndClipBox([0,0,o,l]);let h="groupAt"+this.groupLevel;t.smask&&(h+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(h,o,l),c=d.context;c.translate(-r,-a),c.transform(...i),t.smask?this.smaskStack.push({canvas:d.canvas,context:c,offsetX:r,offsetY:a,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(r,a),e.save()),mi(e,c),this.ctx=c,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const t=ne(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const i=Ot.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(t,e,i,s,n){if(this.#hi(),bi(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const s=e[2]-e[0],r=e[3]-e[1];if(n&&this.annotationCanvasMap){(i=i.slice())[4]-=e[0],i[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=s,e[3]=r;const[n,a]=Ot.singularValueDecompose2dScale(ne(this.ctx)),{viewportScale:o}=this,l=Math.ceil(s*this.outputScaleX*o),h=Math.ceil(r*this.outputScaleY*o);this.annotationCanvas=this.canvasFactory.create(l,h);const{canvas:d,context:c}=this.annotationCanvas;this.annotationCanvasMap.set(t,d),this.annotationCanvas.savedCtx=this.ctx,this.ctx=c,this.ctx.save(),this.ctx.setTransform(n,0,0,-a,0,r*a),bi(this.ctx)}else bi(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],s,r),this.ctx.clip(),this.ctx.beginPath()}this.current=new pi(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#di(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;(t=this.getObject(t.data,t)).count=e;const i=this.ctx,s=this.processingType3;if(s&&(void 0===s.compiled&&(s.compiled=function(t){const{width:e,height:i}=t;if(e>1e3||i>1e3)return null;const s=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=e+1;let r,a,o,l=new Uint8Array(n*(i+1));const h=e+7&-8;let d=new Uint8Array(h*i),c=0;for(const e of t.data){let t=128;for(;t>0;)d[c++]=e&t?0:255,t>>=1}let u=0;for(c=0,0!==d[c]&&(l[0]=1,++u),a=1;a<e;a++)d[c]!==d[c+1]&&(l[a]=d[c]?2:1,++u),c++;for(0!==d[c]&&(l[a]=2,++u),r=1;r<i;r++){c=r*h,o=r*n,d[c-h]!==d[c]&&(l[o]=d[c]?1:8,++u);let t=(d[c]?4:0)+(d[c-h]?8:0);for(a=1;a<e;a++)t=(t>>2)+(d[c+1]?4:0)+(d[c-h+1]?8:0),s[t]&&(l[o+a]=s[t],++u),c++;if(d[c-h]!==d[c]&&(l[o+a]=d[c]?2:4,++u),u>1e3)return null}for(c=h*(i-1),o=r*n,0!==d[c]&&(l[o]=8,++u),a=1;a<e;a++)d[c]!==d[c+1]&&(l[o+a]=d[c]?4:8,++u),c++;if(0!==d[c]&&(l[o+a]=4,++u),u>1e3)return null;const p=new Int32Array([0,n,-1,0,-n,0,0,0,1]),g=new Path2D;for(r=0;u&&r<=i;r++){let t=r*n;const i=t+e;for(;t<i&&!l[t];)t++;if(t===i)continue;g.moveTo(t%n,r);const s=t;let a=l[t];do{const e=p[a];do{t+=e}while(!l[t]);const i=l[t];5!==i&&10!==i?(a=i,l[t]=0):(a=i&51*a>>4,l[t]&=a>>2|a<<2),g.lineTo(t%n,t/n|0),l[t]||--u}while(s!==t);--r}return d=null,l=null,function(t){t.save(),t.scale(1/e,-1/i),t.translate(0,-i),t.fill(g),t.beginPath(),t.restore()}}(t)),s.compiled))return void s.compiled(i);const n=this._createMaskCanvas(t),r=n.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(r,n.offsetX,n.offsetY),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i=0,s=0,n,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);const a=this.ctx;a.save();const o=ne(a);a.transform(e,i,s,n,0,0);const l=this._createMaskCanvas(t);a.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(let t=0,h=r.length;t<h;t+=2){const h=Ot.transform(o,[e,i,s,n,r[t],r[t+1]]),[d,c]=Ot.applyTransform([0,0],h);a.drawImage(l.canvas,d,c)}a.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,i=this.current.fillColor,s=this.current.patternFill;for(const n of t){const{data:t,width:r,height:a,transform:o}=n,l=this.cachedCanvases.getCanvas("maskCanvas",r,a),h=l.context;h.save();fi(h,this.getObject(t,n)),h.globalCompositeOperation="source-in",h.fillStyle=s?i.getPattern(h,this,re(e),Ye):i,h.fillRect(0,0,r,a),h.restore(),e.save(),e.transform(...o),e.scale(1,-1),ui(e,l.canvas,0,0,r,a,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):wt("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s){if(!this.contentVisible)return;const n=this.getObject(t);if(!n)return void wt("Dependent image isn't ready yet");const r=n.width,a=n.height,o=[];for(let t=0,n=s.length;t<n;t+=2)o.push({transform:[e,0,0,i,s[t],s[t+1]],x:0,y:0,w:r,h:a});this.paintInlineImageXObjectGroup(n,o)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;const{bitmap:e,width:i,height:s}=t,n=this.cachedCanvases.getCanvas("inlineImage",i,s),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,i=t.height,s=this.ctx;if(this.save(),!y){const{filter:t}=s;"none"!==t&&""!==t&&(s.filter="none")}let n;if(s.scale(1/e,-1/i),t.bitmap)n=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)n=t;else{const s=this.cachedCanvases.getCanvas("inlineImage",e,i).context;gi(s,t),n=this.applyTransferMapsToCanvas(s)}const r=this._scaleImage(n,re(s));s.imageSmoothingEnabled=vi(ne(s),t.interpolate),ui(s,r.img,0,0,r.paintWidth,r.paintHeight,0,-i,e,i),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const i=this.ctx;let s;if(t.bitmap)s=t.bitmap;else{const e=t.width,i=t.height,n=this.cachedCanvases.getCanvas("inlineImage",e,i).context;gi(n,t),s=this.applyTransferMapsToCanvas(n)}for(const t of e)i.save(),i.transform(...t.transform),i.scale(1,-1),ui(i,s,t.x,t.y,t.w,t.h,0,-1,1,1),i.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const i=this.ctx;this.pendingClip&&(e||(this.pendingClip===_i?i.clip("evenodd"):i.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),i.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=ne(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:i,c:s,d:n}=this.ctx.getTransform();let r,a;if(0===i&&0===s){const i=Math.abs(e),s=Math.abs(n);if(i===s)if(0===t)r=a=1/i;else{const e=i*t;r=a=e<1?1/e:1}else if(0===t)r=1/i,a=1/s;else{const e=i*t,n=s*t;r=e<1?1/e:1,a=n<1?1/n:1}}else{const o=Math.abs(e*n-i*s),l=Math.hypot(e,i),h=Math.hypot(s,n);if(0===t)r=h/o,a=l/o;else{const e=t*o;r=h>e?h/e:1,a=l>e?l/e:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:i}=this.current,[s,n]=this.getScaleForStroking();if(e.lineWidth=i||1,1===s&&1===n)return void e.stroke();const r=e.getLineDash();if(t&&e.save(),e.scale(s,n),r.length>0){const t=Math.max(s,n);e.setLineDash(r.map((e=>e/t))),e.lineDashOffset/=t}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const t in pt)void 0!==xi.prototype[t]&&(xi.prototype[pt[t]]=xi.prototype[t]);let Si=class{static#ui=null;static#pi="";static get workerPort(){return this.#ui}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#ui=t}static get workerSrc(){return this.#pi}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#pi=t}};class Ci{#gi;#fi;constructor({parsedData:t,rawData:e}){this.#gi=t,this.#fi=e}getRaw(){return this.#fi}get(t){return this.#gi.get(t)??null}getAll(){return Rt(this.#gi)}has(t){return this.#gi.has(t)}}const Ei=Symbol("INTERNAL");class Pi{#mi=!1;#bi=!1;#vi=!1;#wi=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){this.#mi=!!(t&C),this.#bi=!!(t&E),this.name=e,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(this.#vi)return this.#wi;if(!this.#wi)return!1;const{print:t,view:e}=this.usage;return this.#mi?"OFF"!==e?.viewState:!this.#bi||"OFF"!==t?.printState}_setVisible(t,e,i=!1){t!==Ei&&yt("Internal method `_setVisible` called."),this.#vi=i,this.#wi=e}}class Mi{#yi=null;#Ai=new Map;#_i=null;#xi=null;constructor(t,e=C){if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#xi=t.order;for(const i of t.groups)this.#Ai.set(i.id,new Pi(e,i));if("OFF"===t.baseState)for(const t of this.#Ai.values())t._setVisible(Ei,!1);for(const e of t.on)this.#Ai.get(e)._setVisible(Ei,!0);for(const e of t.off)this.#Ai.get(e)._setVisible(Ei,!1);this.#_i=this.getHash()}}#Si(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let s=1;s<e;s++){const e=t[s];let n;if(Array.isArray(e))n=this.#Si(e);else{if(!this.#Ai.has(e))return wt(`Optional content group not found: ${e}`),!0;n=this.#Ai.get(e).visible}switch(i){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return"And"===i}isVisible(t){if(0===this.#Ai.size)return!0;if(!t)return vt("Optional content group not defined."),!0;if("OCG"===t.type)return this.#Ai.has(t.id)?this.#Ai.get(t.id).visible:(wt(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#Si(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return wt(`Optional content group not found: ${e}`),!0;if(this.#Ai.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return wt(`Optional content group not found: ${e}`),!0;if(!this.#Ai.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return wt(`Optional content group not found: ${e}`),!0;if(!this.#Ai.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return wt(`Optional content group not found: ${e}`),!0;if(this.#Ai.get(e).visible)return!1}return!0}return wt(`Unknown optional content policy ${t.policy}.`),!0}return wt(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){const s=this.#Ai.get(t);if(s){if(i&&e&&s.rbGroups.length)for(const e of s.rbGroups)for(const i of e)i!==t&&this.#Ai.get(i)?._setVisible(Ei,!1,!0);s._setVisible(Ei,!!e,!0),this.#yi=null}else wt(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let i;for(const s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}const t=this.#Ai.get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}this.#yi=null}get hasInitialVisibility(){return null===this.#_i||this.getHash()===this.#_i}getOrder(){return this.#Ai.size?this.#xi?this.#xi.slice():[...this.#Ai.keys()]:null}getGroups(){return this.#Ai.size>0?Rt(this.#Ai):null}getGroup(t){return this.#Ai.get(t)||null}getHash(){if(null!==this.#yi)return this.#yi;const t=new Se;for(const[e,i]of this.#Ai)t.update(`${e}:${i.visible}`);return this.#yi=t.hexdigest()}}class Ti{constructor(t,{disableRange:e=!1,disableStream:i=!1}){At(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:n,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,n?.length>0){const t=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener(((t,e)=>{this._onReceiveData({begin:t,chunk:e})})),t.addProgressListener(((t,e)=>{this._onProgress({loaded:t,total:e})})),t.addProgressiveReadListener((t=>{this._onReceiveData({chunk:t})})),t.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(void 0===t)this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i);else{At(this._rangeReaders.some((function(e){return e._begin===t&&(e._enqueue(i),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){void 0===t.total?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){At(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new ki(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Ii(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class ki{constructor(t,e,i=!1,s=null){this._stream=t,this._done=i||!1,this._filename=Xt(s)?s:null,this._queuedChunks=e||[],this._loaded=0;for(const t of this._queuedChunks)this._loaded+=t.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._queuedChunks.push(t);this._loaded+=t.byteLength}}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0){return{value:this._queuedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Ii{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Li(t,e){const i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(const t in e){const s=e[t];void 0!==s&&i.append(t,s)}return i}function Di(t){try{return new URL(t).origin}catch{}return null}function Ri({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){const n={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(r))return n;if(n.suggestedLength=r,r<=2*i)return n;if(s||!e)return n;if("bytes"!==t.get("Accept-Ranges"))return n;return"identity"!==(t.get("Content-Encoding")||"identity")||(n.allowRangeRequests=!0),n}function Ni(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){i=i[1];let t=a(i);return t=unescape(t),t=o(t),t=l(t),r(t)}if(i=function(t){const e=[];let i;const n=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=n.exec(t));){let[,t,s,n]=i;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[s,n]}const r=[];for(let t=0;t<e.length&&t in e;++t){let[i,s]=e[t];s=a(s),i&&(s=unescape(s),0===t&&(s=o(s))),r.push(s)}return r.join("")}(t),i)return r(l(i));if(i=s("filename","i").exec(t),i){i=i[1];let t=a(i);return t=l(t),r(t)}function s(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function n(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const s=new TextDecoder(t,{fatal:!0}),n=Dt(i);i=s.decode(n),e=!1}catch{}}return i}function r(t){return e&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),e&&(t=n("iso-8859-1",t))),t}function a(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){const e=t.indexOf("'");return-1===e?t:n(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(t,e,i,s){if("q"===i||"Q"===i)return n(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))})));try{s=atob(s)}catch{}return n(e,s)}))}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(Xt(t))return t}return null}function Fi(t,e){return 404===t||0===t&&e.startsWith("file:")?new Mt('Missing PDF "'+e+'".'):new Tt(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t)}function Oi(t){return 200===t||206===t}function Bi(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function ji(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(wt(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class Vi{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=Li(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return At(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Hi(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new zi(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Hi{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const i=new Headers(t.headers),s=e.url;fetch(s,Bi(i,this._withCredentials,this._abortController)).then((e=>{if(t._responseOrigin=Di(e.url),!Oi(e.status))throw Fi(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();const i=e.headers,{allowRangeRequests:n,suggestedLength:r}=Ri({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=r||this._contentLength,this._filename=Ni(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new It("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:ji(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class zi{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;const n=new Headers(t.headers);n.append("Range",`bytes=${e}-${i-1}`);const r=s.url;fetch(r,Bi(n,this._withCredentials,this._abortController)).then((e=>{const i=Di(e.url);if(i!==t._responseOrigin)throw new Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!Oi(e.status))throw Fi(e.status,r);this._readCapability.resolve(),this._reader=e.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:ji(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Ui{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Li(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,i=this.currXhrId++,s=this.pendingRequests[i]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[t,i]of this.headers)e.setRequestHeader(t,i);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.expectedStatus=206):s.expectedStatus=200,e.responseType="arraybuffer",At(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){const i=this.pendingRequests[t];i&&i.onProgress?.(e)}onStateChange(t,e){const i=this.pendingRequests[t];if(!i)return;const s=i.xhr;if(s.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==s.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===s.status&&this.isHttp)return void i.onError(s.status);const n=s.status||200;if(!(200===n&&206===i.expectedStatus)&&n!==i.expectedStatus)return void i.onError(s.status);const r=function(t){const e=t.response;return"string"!=typeof e?e:Dt(e).buffer}(s);if(206===n){const t=s.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?i.onDone({begin:parseInt(e[1],10),chunk:r}):(wt('Missing or invalid "Content-Range" header.'),i.onError(0))}else r?i.onDone({begin:0,chunk:r}):i.onError(s.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class $i{constructor(t){this._source=t,this._manager=new Ui(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return At(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Wi(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new Gi(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Wi{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=Di(e.responseURL);const i=e.getAllResponseHeaders(),s=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((t=>{const[e,...i]=t.split(": ");return[e,i.join(": ")]})):[]),{allowRangeRequests:n,suggestedLength:r}=Ri({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=Ni(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t)if(this._requests.length>0){this._requests.shift().resolve({value:t.chunk,done:!1})}else this._cachedChunks.push(t.chunk);if(this._done=!0,!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Fi(t,this._url),this._headersCapability.reject(this._storedError);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0){return{value:this._cachedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Gi{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const t=Di(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunk=e;this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??=Fi(t,this._url);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const qi=/^[a-z][a-z0-9\-+.]+:/i;class Xi{constructor(t){this.source=t,this.url=function(t){if(qi.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),At("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return At(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Ki(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Yi(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Ki{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=process.getBuiltinModule("fs");i.promises.lstat(this._url).then((t=>{this._contentLength=t.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()}),(t=>{"ENOENT"===t.code&&(t=new Mt(`Missing PDF "${this._url}".`)),this._storedError=t,this._headersCapability.reject(t)}))}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new It("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Yi{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const s=t.source;this._isStreamingSupported=!s.disableStream;const n=process.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:e,end:i-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),this._storedError&&this._readableStream.destroy(this._storedError)}}const Qi=30;let Ji=class t{#Ci=Promise.withResolvers();#pt=null;#Ei=!1;#Pi=!!globalThis.FontInspector?.enabled;#Mi=null;#Ti=null;#ki=0;#Ii=0;#Li=null;#Di=null;#Ri=0;#Ni=0;#Fi=Object.create(null);#Oi=[];#Bi=null;#ji=[];#Vi=new WeakMap;#Hi=null;static#zi=new Map;static#Ui=new Map;static#$i=new WeakMap;static#Wi=null;static#Gi=new Set;constructor({textContentSource:e,container:i,viewport:s}){if(e instanceof ReadableStream)this.#Bi=e;else{if("object"!=typeof e)throw new Error('No "textContentSource" parameter specified.');this.#Bi=new ReadableStream({start(t){t.enqueue(e),t.close()}})}this.#pt=this.#Di=i,this.#Ni=s.scale*(globalThis.devicePixelRatio||1),this.#Ri=s.rotation,this.#Ti={div:null,properties:null,ctx:null};const{pageWidth:n,pageHeight:r,pageX:a,pageY:o}=s.rawDims;this.#Hi=[1,0,0,-1,-a,o+r],this.#Ii=n,this.#ki=r,t.#qi(),ae(i,s),this.#Ci.promise.finally((()=>{t.#Gi.delete(this),this.#Ti=null,this.#Fi=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=Nt.platform;return xt(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const e=()=>{this.#Li.read().then((({value:t,done:i})=>{i?this.#Ci.resolve():(this.#Mi??=t.lang,Object.assign(this.#Fi,t.styles),this.#Xi(t.items),e())}),this.#Ci.reject)};return this.#Li=this.#Bi.getReader(),t.#Gi.add(this),e(),this.#Ci.promise}update({viewport:e,onBefore:i=null}){const s=e.scale*(globalThis.devicePixelRatio||1),n=e.rotation;if(n!==this.#Ri&&(i?.(),this.#Ri=n,ae(this.#Di,{rotation:n})),s!==this.#Ni){i?.(),this.#Ni=s;const e={div:null,properties:null,ctx:t.#Ki(this.#Mi)};for(const t of this.#ji)e.properties=this.#Vi.get(t),e.div=t,this.#Yi(e)}}cancel(){const t=new It("TextLayer task cancelled.");this.#Li?.cancel(t).catch((()=>{})),this.#Li=null,this.#Ci.reject(t)}get textDivs(){return this.#ji}get textContentItemsStr(){return this.#Oi}#Xi(e){if(this.#Ei)return;this.#Ti.ctx??=t.#Ki(this.#Mi);const i=this.#ji,s=this.#Oi;for(const t of e){if(i.length>1e5)return wt("Ignoring additional textDivs for performance reasons."),void(this.#Ei=!0);if(void 0!==t.str)s.push(t.str),this.#Qi(t);else if("beginMarkedContentProps"===t.type||"beginMarkedContent"===t.type){const e=this.#pt;this.#pt=document.createElement("span"),this.#pt.classList.add("markedContent"),null!==t.id&&this.#pt.setAttribute("id",`${t.id}`),e.append(this.#pt)}else"endMarkedContent"===t.type&&(this.#pt=this.#pt.parentNode)}}#Qi(e){const i=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,fontSize:0};this.#ji.push(i);const n=Ot.transform(this.#Hi,e.transform);let r=Math.atan2(n[1],n[0]);const a=this.#Fi[e.fontName];a.vertical&&(r+=Math.PI/2);let o=this.#Pi&&a.fontSubstitution||a.fontFamily;o=t.fontFamilyMap.get(o)||o;const l=Math.hypot(n[2],n[3]),h=l*t.#Ji(o,this.#Mi);let d,c;0===r?(d=n[4],c=n[5]-h):(d=n[4]+h*Math.sin(r),c=n[5]-h*Math.cos(r));const u="calc(var(--scale-factor)*",p=i.style;this.#pt===this.#Di?(p.left=`${(100*d/this.#Ii).toFixed(2)}%`,p.top=`${(100*c/this.#ki).toFixed(2)}%`):(p.left=`${u}${d.toFixed(2)}px)`,p.top=`${u}${c.toFixed(2)}px)`),p.fontSize=`${u}${(t.#Wi*l).toFixed(2)}px)`,p.fontFamily=o,s.fontSize=l,i.setAttribute("role","presentation"),i.textContent=e.str,i.dir=e.dir,this.#Pi&&(i.dataset.fontName=a.fontSubstitutionLoadedName||e.fontName),0!==r&&(s.angle=r*(180/Math.PI));let g=!1;if(e.str.length>1)g=!0;else if(" "!==e.str&&e.transform[0]!==e.transform[3]){const t=Math.abs(e.transform[0]),i=Math.abs(e.transform[3]);t!==i&&Math.max(t,i)/Math.min(t,i)>1.5&&(g=!0)}if(g&&(s.canvasWidth=a.vertical?e.height:e.width),this.#Vi.set(i,s),this.#Ti.div=i,this.#Ti.properties=s,this.#Yi(this.#Ti),s.hasText&&this.#pt.append(i),s.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#pt.append(t)}}#Yi(e){const{div:i,properties:s,ctx:n}=e,{style:r}=i;let a="";if(t.#Wi>1&&(a=`scale(${1/t.#Wi})`),0!==s.canvasWidth&&s.hasText){const{fontFamily:e}=r,{canvasWidth:o,fontSize:l}=s;t.#Zi(n,l*this.#Ni,e);const{width:h}=n.measureText(i.textContent);h>0&&(a=`scaleX(${o*this.#Ni/h}) ${a}`)}0!==s.angle&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(r.transform=a)}static cleanup(){if(!(this.#Gi.size>0)){this.#zi.clear();for(const{canvas:t}of this.#Ui.values())t.remove();this.#Ui.clear()}}static#Ki(t=null){let e=this.#Ui.get(t||="");if(!e){const i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#Ui.set(t,e),this.#$i.set(e,{size:0,family:""})}return e}static#Zi(t,e,i){const s=this.#$i.get(t);e===s.size&&i===s.family||(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static#qi(){if(null!==this.#Wi)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#Wi=t.getBoundingClientRect().height,t.remove()}static#Ji(t,e){const i=this.#zi.get(t);if(i)return i;const s=this.#Ki(e);s.canvas.width=s.canvas.height=Qi,this.#Zi(s,Qi,t);const n=s.measureText("");let r=n.fontBoundingBoxAscent,a=Math.abs(n.fontBoundingBoxDescent);if(r){const e=r/(r+a);return this.#zi.set(t,e),s.canvas.width=s.canvas.height=0,e}s.strokeStyle="red",s.clearRect(0,0,Qi,Qi),s.strokeText("g",0,0);let o=s.getImageData(0,0,Qi,Qi).data;a=0;for(let t=o.length-1-3;t>=0;t-=4)if(o[t]>0){a=Math.ceil(t/4/Qi);break}s.clearRect(0,0,Qi,Qi),s.strokeText("A",0,Qi),o=s.getImageData(0,0,Qi,Qi).data,r=0;for(let t=0,e=o.length;t<e;t+=4)if(o[t]>0){r=Qi-Math.floor(t/4/Qi);break}s.canvas.width=s.canvas.height=0;const l=r?r/(r+a):.8;return this.#zi.set(t,l),l}};class Zi{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};return function t(i){if(!i)return;let s=null;const n=i.name;if("#text"===n)s=i.value;else{if(!Zi.shouldBuildText(n))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(const e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}const ts=65536,es=y?class extends Ue{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire("undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:n&&"SCRIPT"===n.tagName.toUpperCase()&&n.src||new URL("index.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(t,e)}}:class extends Ue{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const i=this._document.createElement("canvas");return i.width=t,i.height=e,i}},is=y?class extends $e{async _fetch(t){return Ke(t)}}:We,ss=y?class extends Ge{}:class extends Ge{#ts;#es;#is;#ss;#ns;#rs;#w=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#ss=t,this.#ns=e}get#A(){return this.#es||=new Map}get#as(){return this.#rs||=new Map}get#os(){if(!this.#is){const t=this.#ns.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const i=this.#ns.createElementNS(zt,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#is=this.#ns.createElementNS(zt,"defs"),t.append(i),i.append(this.#is),this.#ns.body.append(t)}return this.#is}#ls(t){if(1===t.length){const e=t[0],i=new Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;const s=i.join(",");return[s,s,s]}const[e,i,s]=t,n=new Array(256),r=new Array(256),a=new Array(256);for(let t=0;t<256;t++)n[t]=e[t]/255,r[t]=i[t]/255,a[t]=s[t]/255;return[n.join(","),r.join(","),a.join(",")]}#hs(t){if(void 0===this.#ts){this.#ts="";const t=this.#ns.URL;t!==this.#ns.baseURI&&(qt(t)?wt('#createUrl: ignore "data:"-URL for performance reasons.'):this.#ts=t.split("#",1)[0])}return`url(${this.#ts}#${t})`}addFilter(t){if(!t)return"none";let e=this.#A.get(t);if(e)return e;const[i,s,n]=this.#ls(t),r=1===t.length?i:`${i}${s}${n}`;if(e=this.#A.get(r),e)return this.#A.set(t,e),e;const a=`g_${this.#ss}_transfer_map_${this.#w++}`,o=this.#hs(a);this.#A.set(t,o),this.#A.set(r,o);const l=this.#ds(a);return this.#cs(i,s,n,l),o}addHCMFilter(t,e){const i=`${t}-${e}`,s="base";let n=this.#as.get(s);if(n?.key===i)return n.url;if(n?(n.filter?.remove(),n.key=i,n.url="none",n.filter=null):(n={key:i,url:"none",filter:null},this.#as.set(s,n)),!t||!e)return n.url;const r=this.#us(t);t=Ot.makeHexColor(...r);const a=this.#us(e);if(e=Ot.makeHexColor(...a),this.#os.style.color="","#000000"===t&&"#ffffff"===e||t===e)return n.url;const o=new Array(256);for(let t=0;t<=255;t++){const e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const l=o.join(","),h=`g_${this.#ss}_hcm_filter`,d=n.filter=this.#ds(h);this.#cs(l,l,l,d),this.#ps(d);const c=(t,e)=>{const i=r[t]/255,s=a[t]/255,n=new Array(e+1);for(let t=0;t<=e;t++)n[t]=i+t/e*(s-i);return n.join(",")};return this.#cs(c(0,5),c(1,5),c(2,5),d),n.url=this.#hs(h),n.url}addAlphaFilter(t){let e=this.#A.get(t);if(e)return e;const[i]=this.#ls([t]),s=`alpha_${i}`;if(e=this.#A.get(s),e)return this.#A.set(t,e),e;const n=`g_${this.#ss}_alpha_map_${this.#w++}`,r=this.#hs(n);this.#A.set(t,r),this.#A.set(s,r);const a=this.#ds(n);return this.#gs(i,a),r}addLuminosityFilter(t){let e,i,s=this.#A.get(t||"luminosity");if(s)return s;if(t?([e]=this.#ls([t]),i=`luminosity_${e}`):i="luminosity",s=this.#A.get(i),s)return this.#A.set(t,s),s;const n=`g_${this.#ss}_luminosity_map_${this.#w++}`,r=this.#hs(n);this.#A.set(t,r),this.#A.set(i,r);const a=this.#ds(n);return this.#fs(a),t&&this.#gs(e,a),r}addHighlightHCMFilter(t,e,i,s,n){const r=`${e}-${i}-${s}-${n}`;let a=this.#as.get(t);if(a?.key===r)return a.url;if(a?(a.filter?.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},this.#as.set(t,a)),!e||!i)return a.url;const[o,l]=[e,i].map(this.#us.bind(this));let h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[c,u]=[s,n].map(this.#us.bind(this));d<h&&([h,d,c,u]=[d,h,u,c]),this.#os.style.color="";const p=(t,e,i)=>{const s=new Array(256),n=(d-h)/i,r=t/255,a=(e-t)/(255*i);let o=0;for(let t=0;t<=i;t++){const e=Math.round(h+t*n),i=r+t*a;for(let t=o;t<=e;t++)s[t]=i;o=e+1}for(let t=o;t<256;t++)s[t]=s[o-1];return s.join(",")},g=`g_${this.#ss}_hcm_${t}_filter`,f=a.filter=this.#ds(g);return this.#ps(f),this.#cs(p(c[0],u[0],5),p(c[1],u[1],5),p(c[2],u[2],5),f),a.url=this.#hs(g),a.url}destroy(t=!1){t&&this.#rs?.size||(this.#is?.parentNode.parentNode.remove(),this.#is=null,this.#es?.clear(),this.#es=null,this.#rs?.clear(),this.#rs=null,this.#w=0)}#fs(t){const e=this.#ns.createElementNS(zt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#ps(t){const e=this.#ns.createElementNS(zt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#ds(t){const e=this.#ns.createElementNS(zt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#os.append(e),e}#ms(t,e,i){const s=this.#ns.createElementNS(zt,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#cs(t,e,i,s){const n=this.#ns.createElementNS(zt,"feComponentTransfer");s.append(n),this.#ms(n,"feFuncR",t),this.#ms(n,"feFuncG",e),this.#ms(n,"feFuncB",i)}#gs(t,e){const i=this.#ns.createElementNS(zt,"feComponentTransfer");e.append(i),this.#ms(i,"feFuncA",t)}#us(t){return this.#os.style.color=t,se(getComputedStyle(this.#os).getPropertyValue("color"))}},ns=y?class extends qe{async _fetch(t){return Ke(t)}}:Xe;function rs(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new os,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;try{return new URL(t,window.location).href}catch{if(y&&"string"==typeof t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(y&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return Dt(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,r=t.httpHeaders||null,a=!0===t.withCredentials,o=t.password??null,l=t.range instanceof ls?t.range:null,h=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:ts;let d=t.worker instanceof us?t.worker:null;const c=t.verbosity,u="string"!=typeof t.docBaseUrl||qt(t.docBaseUrl)?null:t.docBaseUrl,p="string"==typeof t.cMapUrl?t.cMapUrl:null,g=!1!==t.cMapPacked,f=t.CMapReaderFactory||is,m="string"==typeof t.standardFontDataUrl?t.standardFontDataUrl:null,b=t.StandardFontDataFactory||ns,v=!0!==t.stopAtErrors,w=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,A=!1!==t.isEvalSupported,_="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!y,x="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!y&&(Nt.platform.isFirefox||!globalThis.chrome),S=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,C="boolean"==typeof t.disableFontFace?t.disableFontFace:y,E=!0===t.fontExtraProperties,P=!0===t.enableXfa,M=t.ownerDocument||globalThis.document,T=!0===t.disableRange,k=!0===t.disableStream,I=!0===t.disableAutoFetch,L=!0===t.pdfBug,D=t.CanvasFactory||es,R=t.FilterFactory||ss,N=!0===t.enableHWA,F=l?l.length:t.length??NaN,O="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!y&&!C,B="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:f===We&&b===Xe&&p&&m&&Jt(p,document.baseURI)&&Jt(m,document.baseURI);mt(c);const j={canvasFactory:new D({ownerDocument:M,enableHWA:N}),filterFactory:new R({docId:i,ownerDocument:M}),cMapReaderFactory:B?null:new f({baseUrl:p,isCompressed:g}),standardFontDataFactory:B?null:new b({baseUrl:m})};if(!d){const t={verbosity:c,port:Si.workerPort};d=t.port?us.fromPort(t):new us(t),e._worker=d}const V={docId:i,apiVersion:"4.10.38",data:n,password:o,disableAutoFetch:I,rangeChunkSize:h,length:F,docBaseUrl:u,enableXfa:P,evaluatorOptions:{maxImageSize:w,disableFontFace:C,ignoreErrors:v,isEvalSupported:A,isOffscreenCanvasSupported:_,isImageDecoderSupported:x,canvasMaxAreaInBytes:S,fontExtraProperties:E,useSystemFonts:O,cMapUrl:B?p:null,standardFontDataUrl:B?m:null}},H={disableFontFace:C,fontExtraProperties:E,ownerDocument:M,pdfBug:L,styleElement:null,loadingParams:{disableAutoFetch:I,enableXfa:P}};return d.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const t=d.messageHandler.sendWithPromise("GetDocRequest",V,n?[n.buffer]:null);let o;if(l)o=new Ti(l,{disableRange:T,disableStream:k});else if(!n){if(!s)throw new Error("getDocument - no `url` parameter provided.");let t;if(y)if(Jt(s)){if("undefined"==typeof fetch||"undefined"==typeof Response||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");t=Vi}else t=Xi;else t=Jt(s)?Vi:$i;o=new t({url:s,length:F,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:T,disableStream:k})}return t.then((t=>{if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const s=new ze(i,t,d.port),n=new ps(s,e,o,H,j);e._transport=n,s.send("Ready",null)}))})).catch(e._capability.reject),e}function as(t){return"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0}class os{static#ss=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+os.#ss++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await(this._transport?.destroy())}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}}let ls=class{constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(const i of this._rangeListeners)i(t,e)}onDataProgress(t,e){this._readyCapability.promise.then((()=>{for(const i of this._progressListeners)i(t,e)}))}onDataProgressiveRead(t){this._readyCapability.promise.then((()=>{for(const e of this._progressiveReadListeners)e(t)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(const t of this._progressiveDoneListeners)t()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){yt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class hs{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return xt(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class ds{#bs=null;#vs=!1;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new Qt:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new fs,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new Wt({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return xt(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:i="display",annotationMode:s=L.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:a=null,annotationCanvasMap:o=null,pageColors:l=null,printAnnotationStorage:h=null,isEditing:d=!1}){this._stats?.time("Overall");const c=this._transport.getRenderingIntent(i,s,h,d),{renderingIntent:u,cacheKey:p}=c;this.#vs=!1,this.#ws(),a||=this._transport.getOptionalContentConfig(u);let g=this._intentStates.get(p);g||(g=Object.create(null),this._intentStates.set(p,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);const f=!!(u&E);g.displayReadyCapability||(g.displayReadyCapability=Promise.withResolvers(),g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(c));const m=t=>{g.renderTasks.delete(b),(this._maybeCleanupAfterRender||f)&&(this.#vs=!0),this.#ys(!f),t?(b.capability.reject(t),this._abortOperatorList({intentState:g,reason:t instanceof Error?t:new Error(t)})):b.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},b=new bs({callback:m,params:{canvasContext:t,viewport:e,transform:n,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!f,pdfBug:this._pdfBug,pageColors:l});(g.renderTasks||=new Set).add(b);const v=b.task;return Promise.all([g.displayReadyCapability.promise,a]).then((([t,e])=>{if(this.destroyed)m();else{if(this._stats?.time("Rendering"),!(e.renderingIntent&u))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");b.initializeGraphics({transparency:t,optionalContentConfig:e}),b.operatorListChanged()}})).catch(m),v}getOperatorList({intent:t="display",annotationMode:e=L.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){const n=this._transport.getRenderingIntent(t,e,i,s,!0);let r,a=this._intentStates.get(n.cacheKey);return a||(a=Object.create(null),this._intentStates.set(n.cacheKey,a)),a.opListReadCapability||(r=Object.create(null),r.operatorListChanged=function(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(r))},a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(r),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then((t=>Zi.textContent(t)));const e=this.streamTextContent(t);return new Promise((function(t,i){const s=e.getReader(),n={items:[],styles:Object.create(null),lang:null};!function e(){s.read().then((function({value:i,done:s}){s?t(n):(n.lang??=i.lang,Object.assign(n.styles,i.styles),n.items.push(...i.items),e())}),i)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#vs=!1,this.#ws(),Promise.all(t)}cleanup(t=!1){this.#vs=!0;const e=this.#ys(!1);return t&&e&&(this._stats&&=new Qt),e}#ys(t=!1){if(this.#ws(),!this.#vs||this.destroyed)return!1;if(t)return this.#bs=setTimeout((()=>{this.#bs=null,this.#ys(!1)}),5e3),!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#vs=!1,!0}#ws(){this.#bs&&(clearTimeout(this.#bs),this.#bs=null)}_startRenderPage(t,e){const i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const t of e.renderTasks)t.operatorListChanged();t.lastChunk&&this.#ys(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){const{map:n,transfer:r}=i,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:s},r).getReader(),o=this._intentStates.get(e);o.streamReader=a;const l=()=>{a.read().then((({value:t,done:e})=>{e?o.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,o),l())}),(t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const t of o.renderTasks)t.operatorListChanged();this.#ys(!0)}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else{if(!o.opListReadCapability)throw t;o.opListReadCapability.reject(t)}}}))};l()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof Gt){let i=100;return e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout((()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})}),i))}}if(t.streamReader.cancel(new It(e.message)).catch((()=>{})),t.streamReader=null,!this._transport.destroyed){for(const[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class cs{#As=new Map;#_s=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#_s.then((()=>{for(const[t]of this.#As)t.call(this,i)}))}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){const{signal:n}=i;if(n.aborted)return void wt("LoopbackPort - cannot use an `aborted` signal.");const r=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#As.set(e,s)}removeEventListener(t,e){const i=this.#As.get(e);i?.(),this.#As.delete(e)}terminate(){for(const[,t]of this.#As)t?.();this.#As.clear()}}let us=class t{static#xs=0;static#Ss=!1;static#Cs;static{y&&(this.#Ss=!0,Si.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let i;try{if(i=new URL(t),!i.origin||"null"===i.origin)return!1}catch{return!1}const s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:e=null,port:i=null,verbosity:s=bt()}={}){if(this.name=e,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,i){if(t.#Cs?.has(i))throw new Error("Cannot use more than one PDFWorker per port.");return(t.#Cs||=new WeakMap).set(i,this),void this._initializeFromPort(i)}this._initialize()}get promise(){return this._readyCapability.promise}#Es(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new ze("main","worker",t),this._messageHandler.on("ready",(function(){})),this.#Es()}_initialize(){if(t.#Ss||t.#Ps)return void this._setupFakeWorker();let{workerSrc:e}=t;try{t._isSameOrigin(window.location.href,e)||(e=t._createCDNWrapper(new URL(e,window.location).href));const i=new Worker(e,{type:"module"}),s=new ze("main","worker",i),n=()=>{r.abort(),s.destroy(),i.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},r=new AbortController;i.addEventListener("error",(()=>{this._webWorker||n()}),{signal:r.signal}),s.on("test",(t=>{r.abort(),!this.destroyed&&t?(this._messageHandler=s,this._port=i,this._webWorker=i,this.#Es()):n()})),s.on("ready",(t=>{if(r.abort(),this.destroyed)n();else try{a()}catch{this._setupFakeWorker()}}));const a=()=>{const t=new Uint8Array;s.send("test",t,[t.buffer])};return void a()}catch{vt("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){t.#Ss||(wt("Setting up fake worker."),t.#Ss=!0),t._setupFakeWorkerGlobal.then((e=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const i=new cs;this._port=i;const s="fake"+t.#xs++,n=new ze(s+"_worker",s,i);e.setup(n,i),this._messageHandler=new ze(s,s+"_worker",i),this.#Es()})).catch((t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,t.#Cs?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(e){if(!e?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const i=this.#Cs?.get(e.port);if(i){if(i._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return i}return new t(e)}static get workerSrc(){if(Si.workerSrc)return Si.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#Ps(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return xt(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#Ps)return this.#Ps;return(await import(this.workerSrc)).WorkerMessageHandler})())}};class ps{#Ms=new Map;#Ts=new Map;#ks=new Map;#Is=new Map;#Ls=null;constructor(t,e,i,s,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new fs,this.fontLoader=new Me({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#Ds(t,e=null){const i=this.#Ms.get(t);if(i)return i;const s=this.messageHandler.sendWithPromise(t,e);return this.#Ms.set(t,s),s}get annotationStorage(){return xt(this,"annotationStorage",new Ee)}getRenderingIntent(t,e=L.ENABLE,i=null,s=!1,n=!1){let r=C,a=Ce;switch(t){case"any":r=S;break;case"display":break;case"print":r=E;break;default:wt(`getRenderingIntent - invalid intent: ${t}`)}const o=r&E&&i instanceof Pe?i:this.annotationStorage;switch(e){case L.DISABLE:r+=T;break;case L.ENABLE:break;case L.ENABLE_FORMS:r+=P;break;case L.ENABLE_STORAGE:r+=M,a=o.serializable;break;default:wt(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(r+=k),n&&(r+=I);const{ids:l,hash:h}=o.modifiedIds;return{renderingIntent:r,cacheKey:[r,a.hash,h].join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#Ls?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#Ts.values())t.push(e._destroy());this.#Ts.clear(),this.#ks.clear(),this.#Is.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#Ms.clear(),this.filterFactory.destroy(),Ji.cleanup(),this._networkStream?.cancelAllRequests(new It("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",((t,e)=>{At(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then((function({value:t,done:i}){i?e.close():(At(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}})),t.on("ReaderHeadersReady",(async t=>{await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:s,contentLength:n}=this._fullReader;return i&&s||(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),{isStreamingSupported:i,isRangeSupported:s,contentLength:n}})),t.on("GetRangeReader",((t,e)=>{At(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const i=this._networkStream.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then((function({value:t,done:i}){i?e.close():(At(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{i.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}):e.close()})),t.on("GetDoc",(({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new hs(t,this))})),t.on("DocException",(t=>{e._capability.reject(He(t))})),t.on("PasswordRequest",(t=>{this.#Ls=Promise.withResolvers();try{if(!e.onPassword)throw He(t);const i=t=>{t instanceof Error?this.#Ls.reject(t):this.#Ls.resolve({password:t})};e.onPassword(i,t.code)}catch(t){this.#Ls.reject(t)}return this.#Ls.promise})),t.on("DataLoaded",(t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),t.on("StartRenderPage",(t=>{if(this.destroyed)return;this.#Ts.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),t.on("commonobj",(([e,i,s])=>{if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(i){case"Font":const{disableFontFace:n,fontExtraProperties:r,pdfBug:a}=this._params;if("error"in s){const t=s.error;wt(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const o=a&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,l=new Te(s,{disableFontFace:n,fontExtraProperties:r,inspectFont:o});this.fontLoader.bind(l).catch((()=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!r&&l.data&&(l.data=null),this.commonObjs.resolve(e,l)}));break;case"CopyLocalImage":const{imageRef:h}=s;At(h,"The imageRef must be defined.");for(const t of this.#Ts.values())for(const[,i]of t.objs)if(i?.ref===h)return i.dataLen?(this.commonObjs.resolve(e,structuredClone(i)),i.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,s);break;default:throw new Error(`Got unknown common object type ${i}`)}return null})),t.on("obj",(([t,e,i,s])=>{if(this.destroyed)return;const n=this.#Ts.get(e);if(!n.objs.has(t))if(0!==n._intentStates.size)switch(i){case"Image":n.objs.resolve(t,s),s?.dataLen>1e7&&(n._maybeCleanupAfterRender=!0);break;case"Pattern":n.objs.resolve(t,s);break;default:throw new Error(`Got unknown object type ${i}`)}else s?.bitmap?.close()})),t.on("DocProgress",(t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})})),t.on("FetchBuiltInCMap",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(t)})),t.on("FetchStandardFontData",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(t)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&wt("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally((()=>{this.annotationStorage.resetModified()}))}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,i=this.#ks.get(e);if(i)return i;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((i=>{if(this.destroyed)throw new Error("Transport destroyed");i.refStr&&this.#Is.set(i.refStr,t);const s=new ds(e,i,this,this._params.pdfBug);return this.#Ts.set(e,s),s}));return this.#ks.set(e,s),s}getPageIndex(t){return as(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#Ds("GetFieldObjects")}hasJSActions(){return this.#Ds("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#Ds("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#Ds("GetOptionalContentConfig").then((e=>new Mi(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#Ms.get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new Ci(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#Ms.set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of this.#Ts.values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),this.#Ms.clear(),this.filterFactory.destroy(!0),Ji.cleanup()}}cachedPageNumber(t){if(!as(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#Is.get(e)??null}}const gs=Symbol("INITIAL_DATA");class fs{#Rs=Object.create(null);#Ns(t){return this.#Rs[t]||={...Promise.withResolvers(),data:gs}}get(t,e=null){if(e){const i=this.#Ns(t);return i.promise.then((()=>e(i.data))),null}const i=this.#Rs[t];if(!i||i.data===gs)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#Rs[t];return!!e&&e.data!==gs}delete(t){const e=this.#Rs[t];return!(!e||e.data===gs)&&(delete this.#Rs[t],!0)}resolve(t,e=null){const i=this.#Ns(t);i.data=e,i.resolve()}clear(){for(const t in this.#Rs){const{data:e}=this.#Rs[t];e?.bitmap?.close()}this.#Rs=Object.create(null)}*[Symbol.iterator](){for(const t in this.#Rs){const{data:e}=this.#Rs[t];e!==gs&&(yield[t,e])}}}class ms{#Fs=null;constructor(t){this.#Fs=t,this.onContinue=null}get promise(){return this.#Fs.capability.promise}cancel(t=0){this.#Fs.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#Fs.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#Fs;return t.form||t.canvas&&e?.size>0}}class bs{#Os=null;static#Bs=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:c=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=d,this.pageColors=c,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new ms(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(bs.#Bs.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");bs.#Bs.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:i,viewport:s,transform:n,background:r}=this.params;this.gfx=new xi(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:s,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#Os&&(window.cancelAnimationFrame(this.#Os),this.#Os=null),bs.#Bs.delete(this._canvas),this.callback(t||new Gt(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#Os=window.requestAnimationFrame((()=>{this.#Os=null,this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),bs.#Bs.delete(this._canvas),this.callback())))}}const vs="4.10.38",ws="f9bea397f";function ys(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function As(t){return Math.max(0,Math.min(255,255*t))}class _s{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=As(t),t,t]}static G_HTML([t]){const e=ys(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(As)}static RGB_HTML(t){return`#${t.map(ys).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[As(1-Math.min(1,t+s)),As(1-Math.min(1,i+s)),As(1-Math.min(1,e+s))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const s=1-t,n=1-e,r=1-i;return["CMYK",s,n,r,Math.min(s,n,r)]}}class xs{create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){yt("Abstract method `_createSVG` called.")}}let Ss=class extends xs{_createSVG(t){return document.createElementNS(zt,t)}},Cs=class{static setupStorage(t,e,i,s,n){const r=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==r.value&&(t.textContent=r.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(r.value===i.attributes.xfaOn?t.setAttribute("checked",!0):r.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",(t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})}))}else{if(null!==r.value&&t.setAttribute("value",r.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==r.value){t.setAttribute("value",r.value);for(const t of i.children)t.attributes.value===r.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",(t=>{const i=t.target.options,n=-1===i.selectedIndex?"":i[i.selectedIndex].value;s.setValue(e,{value:n})}))}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;"radio"===r.type&&(r.name=`${r.name}-${s}`);for(const[e,i]of Object.entries(r))if(null!=i)switch(e){case"class":i.length&&t.setAttribute(e,i.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",i);break;case"style":Object.assign(t.style,i);break;case"textContent":t.textContent=i;break;default:(!a||"href"!==e&&"newWindow"!==e)&&t.setAttribute(e,i)}a&&n.addLinkAttributes(t,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(t,r.dataId,e,i)}static render(t){const e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,n=t.intent||"display",r=document.createElement(s.name);s.attributes&&this.setAttributes({html:r,element:s,intent:n,linkService:i});const a="richText"!==n,o=t.div;if(o.append(r),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}a&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(0===s.children.length){if(s.value){const t=document.createTextNode(s.value);r.append(t),a&&Zi.shouldBuildText(s.name)&&l.push(t)}return{textDivs:l}}const h=[[s,-1,r]];for(;h.length>0;){const[t,s,r]=h.at(-1);if(s+1===t.children.length){h.pop();continue}const o=t.children[++h.at(-1)[1]];if(null===o)continue;const{name:d}=o;if("#text"===d){const t=document.createTextNode(o.value);l.push(t),r.append(t);continue}const c=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,d):document.createElement(d);if(r.append(c),o.attributes&&this.setAttributes({html:c,element:o,storage:e,intent:n,linkService:i}),o.children?.length>0)h.push([o,-1,c]);else if(o.value){const t=document.createTextNode(o.value);a&&Zi.shouldBuildText(d)&&l.push(t),c.append(t)}}for(const t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}};const Es=1e3,Ps=new WeakSet;function Ms(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class Ts{static create(t){switch(t.data.annotationType){case $:return new Is(t);case U:return new Ls(t);case at:switch(t.data.fieldType){case"Tx":return new Rs(t);case"Btn":return t.data.radioButton?new Os(t):t.data.checkBox?new Fs(t):new Bs(t);case"Ch":return new js(t);case"Sig":return new Ns(t)}return new Ds(t);case nt:return new Vs(t);case W:return new zs(t);case G:return new Us(t);case q:return new $s(t);case X:return new Ws(t);case Y:return new Gs(t);case it:return new Xs(t);case st:return new Ks(t);case K:return new qs(t);case Q:return new Ys(t);case J:return new Qs(t);case Z:return new Js(t);case tt:return new Zs(t);case et:return new tn(t);case rt:return new en(t);default:return new ks(t)}}}class ks{#js=null;#Vs=!1;#Hs=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:i}){return!!(t?.str||e?.str||i?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return ks._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#js||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#zs(e),this.#Hs?.popup.updateEdited(t)}resetEdited(){this.#js&&(this.#zs(this.#js.rect),this.#Hs?.popup.resetEdited(),this.#js=null)}#zs(t){const{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;i?.splice(0,4,...t);const{width:l,height:h}=Ms(t);e.left=100*(t[0]-a)/n+"%",e.top=100*(r-t[3]+o)/r+"%",0===s?(e.width=100*l/n+"%",e.height=100*h/r+"%"):this.setRotation(s)}_createContainer(t){const{data:e,parent:{page:i,viewport:s}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof Ds||(n.tabIndex=Es);const{style:r}=n;if(r.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Vs){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:a,height:o}=Ms(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;if(t>0||i>0){const e=`calc(${t}px * var(--scale-factor)) / calc(${i}px * var(--scale-factor))`;r.borderRadius=e}else if(this instanceof Os){const t=`calc(${a}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;r.borderRadius=t}switch(e.borderStyle.style){case ot:r.borderStyle="solid";break;case lt:r.borderStyle="dashed";break;case ht:wt("Unimplemented border style: beveled");break;case dt:wt("Unimplemented border style: inset");break;case ct:r.borderBottomStyle="solid"}const s=e.borderColor||null;s?(this.#Vs=!0,r.borderColor=Ot.makeHexColor(0|s[0],0|s[1],0|s[2])):r.borderWidth=0}const l=Ot.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:h,pageHeight:d,pageX:c,pageY:u}=s.rawDims;r.left=100*(l[0]-c)/h+"%",r.top=100*(l[1]-u)/d+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(r.width=100*a/h+"%",r.height=100*o/d+"%"):this.setRotation(p,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims,{width:n,height:r}=Ms(this.data.rect);let a,o;t%180==0?(a=100*n/i,o=100*r/s):(a=100*r/i,o=100*n/s),e.style.width=`${a}%`,e.style.height=`${o}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,i)=>{const s=i.detail[t],n=s[0],r=s.slice(1);i.target.style[e]=_s[`${n}_HTML`](r),this.annotationStorage.setValue(this.data.id,{[e]:_s[`${n}_rgb`](r)})};return xt(this,"_commonActions",{display:t=>{const{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const s of Object.keys(e.detail)){const n=t[s]||i[s];n?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[s,n]of Object.entries(e)){const r=i[s];if(r){r({detail:{[s]:n},target:t}),delete e[s]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,s,n]=this.data.rect.map((t=>Math.fround(t)));if(8===t.length){const[r,a,o,l]=t.subarray(2,6);if(s===r&&n===a&&e===o&&i===l)return}const{style:r}=this.container;let a;if(this.#Vs){const{borderColor:t,borderWidth:e}=r;r.borderWidth=0,a=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const o=s-e,l=n-i,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);const c=h.createElement("defs");d.append(c);const u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),c.append(u);for(let i=2,s=t.length;i<s;i+=8){const s=t[i],r=t[i+1],d=t[i+2],c=t[i+3],p=h.createElement("rect"),g=(d-e)/o,f=(n-r)/l,m=(s-d)/o,b=(r-c)/l;p.setAttribute("x",g),p.setAttribute("y",f),p.setAttribute("width",m),p.setAttribute("height",b),u.append(p),a?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${f}" width="${m}" height="${b}"/>`)}this.#Vs&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(){const{data:t}=this,e=this.#Hs=new Vs({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(e.render())}render(){yt("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const s=this._fieldObjects[t];if(s)for(const{page:t,id:n,exportValues:r}of s){if(-1===t)continue;if(n===e)continue;const s="string"==typeof r?r:null,a=document.querySelector(`[data-element-id="${n}"]`);!a||Ps.has(a)?i.push({id:n,exportValue:s,domElement:a}):wt(`_getElementsByName - element not allowed: ${n}`)}return i}for(const s of document.getElementsByName(t)){const{exportValue:t}=s,n=s.getAttribute("data-element-id");n!==e&&(Ps.has(s)&&i.push({id:n,exportValue:t,domElement:s}))}return i}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})}))}}class Is extends ks{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action),s=!0):t.attachment?(this.#Us(i,t.attachment,t.attachmentDest),s=!0):t.setOCGState?(this.#$s(i,t.setOCGState),s=!0):t.dest?(this._bindLink(i,t.dest),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&this.container.append(i),this.container}#Ws(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#Ws()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#Ws()}#Us(t,e,i=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,i),!1),this.#Ws()}#$s(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#Ws()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const s of Object.keys(e.actions)){const n=i.get(s);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}t.onclick||(t.onclick=()=>!1),this.#Ws()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#Ws(),!this._fieldObjects)return wt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(i||(t.onclick=()=>!1));t.onclick=()=>{i?.();const{fields:t,refs:s,include:n}=e,r=[];if(0!==t.length||0!==s.length){const e=new Set(s);for(const i of t){const t=this._fieldObjects[i]||[];for(const{id:i}of t)e.add(i)}for(const t of Object.values(this._fieldObjects))for(const i of t)e.has(i.id)===n&&r.push(i)}else for(const t of Object.values(this._fieldObjects))r.push(...t);const a=this.annotationStorage,o=[];for(const t of r){const{id:e}=t;switch(o.push(e),t.type){case"text":{const i=t.defaultValue||"";a.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{const i=t.defaultValue===t.exportValues;a.setValue(e,{value:i});break}case"combobox":case"listbox":{const i=t.defaultValue||"";a.setValue(e,{value:i});break}default:continue}const i=document.querySelector(`[data-element-id="${e}"]`);i&&(Ps.has(i)?i.dispatchEvent(new Event("resetform")):wt(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class Ls extends ks{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class Ds extends ks{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return Nt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,n){i.includes("mouse")?t.addEventListener(i,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(i,(t=>{if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t)}})}))}_setEventListeners(t,e,i,s){for(const[n,r]of i)("Action"===r||this.data.actions?.[r])&&("Focus"!==r&&"Blur"!==r||(e||={focused:!1}),this._setEventListener(t,e,n,r,s),"Focus"!==r||this.data.actions?.Blur?"Blur"!==r||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":Ot.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,n=t.style;let r;const a=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=t/(Math.round(t/(x*s))||1);r=Math.min(s,a(e/x))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(s,a(t/x))}n.fontSize=`calc(${r}px * var(--scale-factor))`,n.color=Ot.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Rs extends Ds{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,s){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=i),n.setValue(r.id,{[s]:i})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const s=t.getValue(e,{value:this.data.fieldValue});let n=s.value||"";const r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&n.length>r&&(n=n.slice(0,r));let a=s.formattedValue||this.data.textContent?.join("\n")||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));const o={userValue:n,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=a??n,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type="text",i.setAttribute("value",a??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),Ps.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=Es,this._setRequired(i,this.data.required),r&&(i.maxLength=r),i.addEventListener("input",(s=>{t.setValue(e,{value:s.target.value}),this.setPropertyOnSiblings(i,"value",s.target.value,"value"),o.formattedValue=null})),i.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null}));let l=t=>{const{formattedValue:e}=o;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",(t=>{if(o.focused)return;const{target:e}=t;o.userValue&&(e.value=o.userValue),o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)})),i.addEventListener("updatefromsandbox",(i=>{this.showElementAndHideCanvas(i.target);const s={value(i){o.userValue=i.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),i.target.value=o.userValue},formattedValue(i){const{formattedValue:s}=i.detail;o.formattedValue=s,null!=s&&i.target!==document.activeElement&&(i.target.value=s),t.setValue(e,{formattedValue:s})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{const{charLimit:s}=i.detail,{target:n}=i;if(0===s)return void n.removeAttribute("maxLength");n.setAttribute("maxLength",s);let r=o.userValue;!r||r.length<=s||(r=r.slice(0,s),n.value=o.userValue=r,t.setValue(e,{value:r}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,willCommit:!0,commitKey:1,selStart:n.selectionStart,selEnd:n.selectionEnd}}))}};this._dispatchEventFromSandbox(s,i)})),i.addEventListener("keydown",(t=>{o.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):i=2,-1===i)return;const{value:s}=t.target;o.lastCommittedValue!==s&&(o.lastCommittedValue=s,o.userValue=s,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}));const s=l;l=null,i.addEventListener("blur",(t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{value:i}=t.target;o.userValue=i,o.lastCommittedValue!==i&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),s(t)})),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",(t=>{o.lastCommittedValue=null;const{data:i,target:s}=t,{value:n,selectionStart:r,selectionEnd:a}=s;let l=r,h=a;switch(t.inputType){case"deleteWordBackward":{const t=n.substring(0,r).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{const t=n.substring(r).match(/^[^\w]*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":r===a&&(l-=1);break;case"deleteContentForward":r===a&&(h+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,change:i||"",willCommit:!1,selStart:l,selEnd:h}})})),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(l&&i.addEventListener("blur",l),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/r;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--scale-factor) - 1ch)`}}else i=document.createElement("div"),i.textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Ns extends Ds{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Fs extends Ds{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return Ps.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=Es,n.addEventListener("change",(s=>{const{name:n,checked:r}=s.target;for(const s of this._getElementsByName(n,i)){const i=r&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:r})})),n.addEventListener("resetform",(t=>{const i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue})),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",(e=>{const s={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}};this._dispatchEventFromSandbox(s,e)})),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Os extends Ds{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(const s of this._getElementsByName(e.fieldName,i))t.setValue(s.id,{value:!1});const n=document.createElement("input");if(Ps.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.tabIndex=Es,n.addEventListener("change",(e=>{const{name:s,checked:n}=e.target;for(const e of this._getElementsByName(s,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:n})})),n.addEventListener("resetform",(t=>{const i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue})),this.enableScripting&&this.hasJSActions){const s=e.buttonValue;n.addEventListener("updatefromsandbox",(e=>{const n={value:e=>{const n=s===e.detail.value;for(const s of this._getElementsByName(e.target.name)){const e=n&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}};this._dispatchEventFromSandbox(n,e)})),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Bs extends Is{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(t=>{this._dispatchEventFromSandbox({},t)}))),t}}class js extends Ds{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");Ps.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=Es;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue;for(const t of s.options)t.selected=t.value===e}));for(const t of this.data.options){const e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),n=!1),s.append(e)}let r=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),r=()=>{t.remove(),s.removeEventListener("input",r),r=null},s.addEventListener("input",r)}const a=t=>{const e=t?"value":"textContent",{options:i,multiple:n}=s;return n?Array.prototype.filter.call(i,(t=>t.selected)).map((t=>t[e])):-1===i.selectedIndex?null:i[i.selectedIndex][e]};let o=a(!1);const l=t=>{const e=t.target.options;return Array.prototype.map.call(e,(t=>({displayValue:t.textContent,exportValue:t.value})))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",(i=>{const n={value(i){r?.();const n=i.detail.value,l=new Set(Array.isArray(n)?n:[n]);for(const t of s.options)t.selected=l.has(t.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(t){s.multiple=!0},remove(i){const n=s.options,r=i.detail.remove;if(n[r].selected=!1,s.remove(r),n.length>0){-1===Array.prototype.findIndex.call(n,(t=>t.selected))&&(n[0].selected=!0)}t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(i){const{index:n,displayValue:r,exportValue:h}=i.detail.insert,d=s.children[n],c=document.createElement("option");c.textContent=r,c.value=h,d?d.before(c):s.append(c),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},items(i){const{items:n}=i.detail;for(;0!==s.length;)s.remove(0);for(const t of n){const{displayValue:e,exportValue:i}=t,n=document.createElement("option");n.textContent=e,n.value=i,s.append(n)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},indices(i){const s=new Set(i.detail.indices);for(const t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(n,i)})),s.addEventListener("input",(i=>{const s=a(!0),n=a(!1);t.setValue(e,{value:s}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:n,changeEx:s,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(t=>t.target.value))):s.addEventListener("input",(function(i){t.setValue(e,{value:a(!0)})})),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Vs extends ks{constructor(t){const{data:e,elements:i}=t;super(t,{isRenderable:ks._hasPopupData(e)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Hs({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(const i of this.elements)i.popup=t,i.container.ariaHasPopup="dialog",e.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",e.map((t=>`${Ht}${t}`)).join(",")),this.container}}class Hs{#Gs=this.#qs.bind(this);#Xs=this.#Ks.bind(this);#Ys=this.#Qs.bind(this);#Js=this.#Zs.bind(this);#tn=null;#pt=null;#en=null;#in=null;#sn=null;#nn=null;#rn=null;#an=!1;#on=null;#E=null;#ln=null;#hn=null;#dn=null;#js=null;#cn=!1;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:n,contentsObj:r,richText:a,parent:o,rect:l,parentRect:h,open:d}){this.#pt=t,this.#dn=s,this.#en=r,this.#hn=a,this.#nn=o,this.#tn=e,this.#ln=l,this.#rn=h,this.#sn=i,this.#in=ee.toDateObject(n),this.trigger=i.flatMap((t=>t.getElementsToTriggerPopup()));for(const t of this.trigger)t.addEventListener("click",this.#Js),t.addEventListener("mouseenter",this.#Ys),t.addEventListener("mouseleave",this.#Xs),t.classList.add("popupTriggerArea");for(const t of i)t.container?.addEventListener("keydown",this.#Gs);this.#pt.hidden=!0,d&&this.#Zs()}render(){if(this.#on)return;const t=this.#on=document.createElement("div");if(t.className="popup",this.#tn){const e=t.style.outlineColor=Ot.makeHexColor(...this.#tn);if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`;else{const e=.7;t.style.backgroundColor=Ot.makeHexColor(...this.#tn.map((t=>Math.floor(e*(255-t)+t))))}}const e=document.createElement("span");e.className="header";const i=document.createElement("h1");if(e.append(i),({dir:i.dir,str:i.textContent}=this.#dn),t.append(e),this.#in){const t=document.createElement("span");t.classList.add("popupDate"),t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#in.valueOf()})),e.append(t)}const s=this.#un;if(s)Cs.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(this.#en);t.append(e)}this.#pt.append(t)}get#un(){const t=this.#hn,e=this.#en;return!t?.str||e?.str&&e.str!==t.str?null:this.#hn.html||null}get#pn(){return this.#un?.attributes?.style?.fontSize||0}get#gn(){return this.#un?.attributes?.style?.color||null}#fn(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:this.#gn,fontSize:this.#pn?`calc(${this.#pn}px * var(--scale-factor))`:""}};for(const i of t.split("\n"))e.push({name:"span",value:i,attributes:s});return i}_formatContents({str:t,dir:e}){const i=document.createElement("p");i.classList.add("popupContent"),i.dir=e;const s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t){const n=s[t];i.append(document.createTextNode(n)),t<e-1&&i.append(document.createElement("br"))}return i}#qs(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#an)&&this.#Zs()}updateEdited({rect:t,popupContent:e}){this.#js||={contentsObj:this.#en,richText:this.#hn},t&&(this.#E=null),e&&(this.#hn=this.#fn(e),this.#en=null),this.#on?.remove(),this.#on=null}resetEdited(){this.#js&&(({contentsObj:this.#en,richText:this.#hn}=this.#js),this.#js=null,this.#on?.remove(),this.#on=null,this.#E=null)}#mn(){if(null!==this.#E)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=this.#nn;let r=!!this.#rn,a=r?this.#rn:this.#ln;for(const t of this.#sn)if(!a||null!==Ot.intersect(t.data.rect,a)){a=t.data.rect,r=!0;break}const o=Ot.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),l=r?a[2]-a[0]+5:0,h=o[0]+l,d=o[1];this.#E=[100*(h-s)/e,100*(d-n)/i];const{style:c}=this.#pt;c.left=`${this.#E[0]}%`,c.top=`${this.#E[1]}%`}#Zs(){this.#an=!this.#an,this.#an?(this.#Qs(),this.#pt.addEventListener("click",this.#Js),this.#pt.addEventListener("keydown",this.#Gs)):(this.#Ks(),this.#pt.removeEventListener("click",this.#Js),this.#pt.removeEventListener("keydown",this.#Gs))}#Qs(){this.#on||this.render(),this.isVisible?this.#an&&this.#pt.classList.add("focused"):(this.#mn(),this.#pt.hidden=!1,this.#pt.style.zIndex=parseInt(this.#pt.style.zIndex)+1e3)}#Ks(){this.#pt.classList.remove("focused"),!this.#an&&this.isVisible&&(this.#pt.hidden=!0,this.#pt.style.zIndex=parseInt(this.#pt.style.zIndex)-1e3)}forceHide(){this.#cn=this.isVisible,this.#cn&&(this.#pt.hidden=!0)}maybeShow(){this.#cn&&(this.#on||this.#Qs(),this.#cn=!1,this.#pt.hidden=!1)}get isVisible(){return!1===this.#pt.hidden}}class zs extends ks{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=D.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class Us extends ks{#bn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const t=this.data,{width:e,height:i}=Ms(t.rect),s=this.svgFactory.create(e,i,!0),n=this.#bn=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#bn}addHighlightArea(){this.container.classList.add("highlightArea")}}class $s extends ks{#vn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const t=this.data,{width:e,height:i}=Ms(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#vn=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",i-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#vn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ws extends ks{#wn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const t=this.data,{width:e,height:i}=Ms(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#wn=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",i/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",i/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#wn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Gs extends ks{#yn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:i,popupRef:s}}=this;if(!e)return this.container;const{width:n,height:r}=Ms(t),a=this.svgFactory.create(n,r,!0);let o=[];for(let i=0,s=e.length;i<s;i+=2){const s=e[i]-t[0],n=t[3]-e[i+1];o.push(`${s},${n}`)}o=o.join(" ");const l=this.#yn=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),a.append(l),this.container.append(a),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#yn}addHighlightArea(){this.container.classList.add("highlightArea")}}class qs extends Gs{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Xs extends ks{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class Ks extends ks{#An=null;#_n=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?D.HIGHLIGHT:D.INK}#xn(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:i,borderStyle:s,popupRef:n}}=this,{transform:r,width:a,height:o}=this.#xn(e,t),l=this.svgFactory.create(a,o,!0),h=this.#An=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",r);for(let t=0,e=i.length;t<e;t++){const e=this.svgFactory.createElement(this.svgElementName);this.#_n.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!n&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:i,rect:s}=t,n=this.#An;if(e>=0&&n.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#_n.length;t<e;t++)this.#_n[t].setAttribute("points",i[t].join(","));if(s){const{transform:t,width:e,height:i}=this.#xn(this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#_n}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ys extends ks{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=D.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Qs extends ks{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class Js extends ks{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class Zs extends ks{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class tn extends ks{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=D.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class en extends ks{#Sn=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let i;e.hasAppearance||0===e.fillAlpha?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),i.addEventListener("dblclick",this.#Cn.bind(this)),this.#Sn=i;const{isMac:s}=Nt.platform;return t.addEventListener("keydown",(t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#Cn()})),!e.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#Sn}addHighlightArea(){this.container.classList.add("highlightArea")}#Cn(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}let sn=class{#En=null;#Pn=null;#Mn=new Map;#Tn=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:r,structTreeLayer:a}){this.div=t,this.#En=e,this.#Pn=i,this.#Tn=a||null,this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return this.#Mn.size>0}async#kn(t,e){const i=t.firstChild||t,s=i.id=`${Ht}${e}`,n=await(this.#Tn?.getAriaAttributes(s));if(n)for(const[t,e]of n)i.setAttribute(t,e);this.div.append(t),this.#En?.moveElementInDOM(this.div,t,i,!1)}async render(t){const{annotations:e}=t,i=this.div;ae(i,this.viewport);const s=new Map,n={data:null,layer:i,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new Ss,annotationStorage:t.annotationStorage||new Ee,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const t of e){if(t.noHTML)continue;const e=t.annotationType===nt;if(e){const e=s.get(t.id);if(!e)continue;n.elements=e}else{const{width:e,height:i}=Ms(t.rect);if(e<=0||i<=0)continue}n.data=t;const i=Ts.create(n);if(!i.isRenderable)continue;if(!e&&t.popupRef){const e=s.get(t.popupRef);e?e.push(i):s.set(t.popupRef,[i])}const r=i.render();t.hidden&&(r.style.visibility="hidden"),await this.#kn(r,t.id),i._isEditable&&(this.#Mn.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}this.#In()}update({viewport:t}){const e=this.div;this.viewport=t,ae(e,{rotation:t.rotation}),this.#In(),e.hidden=!1}#In(){if(!this.#Pn)return;const t=this.div;for(const[e,i]of this.#Pn){const s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent";const{firstChild:n}=s;n?"CANVAS"===n.nodeName?n.replaceWith(i):n.classList.contains("annotationContent")?n.after(i):n.before(i):s.append(i)}this.#Pn.clear()}getEditableAnnotations(){return Array.from(this.#Mn.values())}getEditableAnnotation(t){return this.#Mn.get(t)}};const nn=/\r\n?|\n/g;class rn extends we{#tn;#Ln="";#Dn=`${this.id}-editor`;#Rn=null;#pn;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=rn.prototype,e=t=>t.isEmpty(),i=me.TRANSLATE_SMALL,s=me.TRANSLATE_BIG;return xt(this,"_keyboardManager",new ge([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=D.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#tn=t.color||rn._defaultColor||we._defaultLineColor,this.#pn=t.fontSize||rn._defaultFontSize}static initialize(t,e){we.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case R.FREETEXT_SIZE:rn._defaultFontSize=e;break;case R.FREETEXT_COLOR:rn._defaultColor=e}}updateParams(t,e){switch(t){case R.FREETEXT_SIZE:this.#Nn(e);break;case R.FREETEXT_COLOR:this.#Fn(e)}}static get defaultPropertiesToUpdate(){return[[R.FREETEXT_SIZE,rn._defaultFontSize],[R.FREETEXT_COLOR,rn._defaultColor||we._defaultLineColor]]}get propertiesToUpdate(){return[[R.FREETEXT_SIZE,this.#pn],[R.FREETEXT_COLOR,this.#tn]]}#Nn(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--scale-factor))`,this.translate(0,-(t-this.#pn)*this.parentScale),this.#pn=t,this.#On()},i=this.#pn;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:R.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#Fn(t){const e=t=>{this.#tn=this.editorDiv.style.color=t},i=this.#tn;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:R.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-rn._internalPadding*t,-(rn._internalPadding+this.#pn)*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(D.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#Rn=new AbortController;const t=this._uiManager.combinedSignal(this.#Rn);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#Dn),this._isDraggable=!0,this.#Rn?.abort(),this.#Rn=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#Bn(){const t=[];this.editorDiv.normalize();let e=null;for(const i of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&"BR"===i.nodeName||(t.push(rn.#jn(i)),e=i);return t.join("\n")}#On(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,s=e.style.display,n=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),i=e.getBoundingClientRect(),e.remove(),e.style.display=s,e.classList.toggle("hidden",n)}this.rotation%180==this.parentRotation%180?(this.width=i.width/t,this.height=i.height/e):(this.width=i.height/t,this.height=i.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#Ln,e=this.#Ln=this.#Bn().trimEnd();if(t===e)return;const i=t=>{this.#Ln=t,t?(this.#Vn(),this._uiManager.rebuild(this),this.#On()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#On()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){rn._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#Dn),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#pn}px * var(--scale-factor))`,i.color=this.#tn,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),de(this,this.div,["dblclick","keydown"]),this.width){const[i,s]=this.parentDimensions;if(this.annotationElementId){const{position:n}=this._initialData;let[r,a]=this.getInitialTranslation();[r,a]=this.pageTranslationToScreen(r,a);const[o,l]=this.pageDimensions,[h,d]=this.pageTranslation;let c,u;switch(this.rotation){case 0:c=t+(n[0]-h)/o,u=e+this.height-(n[1]-d)/l;break;case 90:c=t+(n[0]-h)/o,u=e-(n[1]-d)/l,[r,a]=[a,-r];break;case 180:c=t-this.width+(n[0]-h)/o,u=e-(n[1]-d)/l,[r,a]=[-r,-a];break;case 270:c=t+(n[0]-h-this.height*l)/o,u=e+(n[1]-d-this.width*o)/l,[r,a]=[-a,r]}this.setAt(c*i,u*s,r,a)}else this.setAt(t*i,e*s,this.width*i,this.height*s);this.#Vn(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#jn(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(nn,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const s=rn.#Hn(e.getData("text")||"").replaceAll(nn,"\n");if(!s)return;const n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();const r=n.getRangeAt(0);if(!s.includes("\n"))return r.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),void n.collapseToStart();const{startContainer:a,startOffset:o}=r,l=[],h=[];if(a.nodeType===Node.TEXT_NODE){const t=a.parentElement;if(h.push(a.nodeValue.slice(o).replaceAll(nn,"")),t!==this.editorDiv){let e=l;for(const i of this.editorDiv.childNodes)i!==t?e.push(rn.#jn(i)):e=h}l.push(a.nodeValue.slice(0,o).replaceAll(nn,""))}else if(a===this.editorDiv){let t=l,e=0;for(const i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(rn.#jn(i))}this.#Ln=`${l.join("\n")}${s}${h.join("\n")}`,this.#Vn();const d=new Range;let c=l.reduce(((t,e)=>t+e.length),0);for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(c<=e){d.setStart(t,c),d.setEnd(t,c);break}c-=e}n.removeAllRanges(),n.addRange(d)}#Vn(){if(this.editorDiv.replaceChildren(),this.#Ln)for(const t of this.#Ln.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#zn(){return this.#Ln.replaceAll(" "," ")}static#Hn(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,i){let s=null;if(t instanceof zs){const{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:n,rotation:r,id:a,popupRef:o},textContent:l,textPosition:h,parent:{page:{pageNumber:d}}}=t;if(!l||0===l.length)return null;s=t={annotationType:D.FREETEXT,color:Array.from(i),fontSize:e,value:l.join("\n"),position:h,pageIndex:d-1,rect:n.slice(0),rotation:r,id:a,deleted:!1,popupRef:o}}const n=await super.deserialize(t,e,i);return n.#pn=t.fontSize,n.#tn=Ot.makeHexColor(...t.color),n.#Ln=rn.#Hn(t.value),n.annotationElementId=t.id||null,n._initialData=s,n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=rn._internalPadding*this.parentScale,i=this.getRect(e,e),s=we._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#tn),n={annotationType:D.FREETEXT,color:s,fontSize:this.#pn,value:this.#zn(),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?n:this.annotationElementId&&!this.#Un(n)?null:(n.id=this.annotationElementId,n)}#Un(t){const{value:e,fontSize:i,color:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some(((t,e)=>t!==s[e]))||t.pageIndex!==n}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:i}=e;i.fontSize=`calc(${this.#pn}px * var(--scale-factor))`,i.color=this.#tn,e.replaceChildren();for(const t of this.#Ln.split("\n")){const i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}const s=rn._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:this.#Ln}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class an{static PRECISION=1e-4;toSVGPath(){yt("Abstract method `toSVGPath` must be implemented.")}get box(){yt("Abstract getter `box` must be implemented.")}serialize(t,e){yt("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*s,r[a+1]=i+t[a+1]*n;return r}static _rescaleAndSwap(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*s,r[a+1]=i+t[a]*n;return r}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n+=2)s[n]=e+t[n],s[n+1]=i+t[n+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,s,n){switch(n){case 90:return[1-e/i,t/s];case 180:return[1-t/i,1-e/s];case 270:return[e/i,1-t/s];default:return[t/i,e/s]}}static _normalizePagePoint(t,e,i){switch(i){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,i,s,n,r){return[(t+5*i)/6,(e+5*s)/6,(5*i+n)/6,(5*s+r)/6,(i+n)/2,(s+r)/2]}}class on{#$n;#Wn=[];#Gn;#qn;#Xn=[];#Kn=new Float32Array(18);#Yn;#Qn;#Jn;#Zn;#tr;#er;#ir=[];static#sr=8;static#nr=2;static#rr=on.#sr+on.#nr;constructor({x:t,y:e},i,s,n,r,a=0){this.#$n=i,this.#er=n*s,this.#qn=r,this.#Kn.set([NaN,NaN,NaN,NaN,t,e],6),this.#Gn=a,this.#Zn=on.#sr*s,this.#Jn=on.#rr*s,this.#tr=s,this.#ir.push(t,e)}isEmpty(){return isNaN(this.#Kn[8])}#ar(){const t=this.#Kn.subarray(4,6),e=this.#Kn.subarray(16,18),[i,s,n,r]=this.#$n;return[(this.#Yn+(t[0]-e[0])/2-i)/n,(this.#Qn+(t[1]-e[1])/2-s)/r,(this.#Yn+(e[0]-t[0])/2-i)/n,(this.#Qn+(e[1]-t[1])/2-s)/r]}add({x:t,y:e}){this.#Yn=t,this.#Qn=e;const[i,s,n,r]=this.#$n;let[a,o,l,h]=this.#Kn.subarray(8,12);const d=t-l,c=e-h,u=Math.hypot(d,c);if(u<this.#Jn)return!1;const p=u-this.#Zn,g=p/u,f=g*d,m=g*c;let b=a,v=o;a=l,o=h,l+=f,h+=m,this.#ir?.push(t,e);const w=f/p,y=-m/p*this.#er,A=w*this.#er;if(this.#Kn.set(this.#Kn.subarray(2,8),0),this.#Kn.set([l+y,h+A],4),this.#Kn.set(this.#Kn.subarray(14,18),12),this.#Kn.set([l-y,h-A],16),isNaN(this.#Kn[6]))return 0===this.#Xn.length&&(this.#Kn.set([a+y,o+A],2),this.#Xn.push(NaN,NaN,NaN,NaN,(a+y-i)/n,(o+A-s)/r),this.#Kn.set([a-y,o-A],14),this.#Wn.push(NaN,NaN,NaN,NaN,(a-y-i)/n,(o-A-s)/r)),this.#Kn.set([b,v,a,o,l,h],6),!this.isEmpty();this.#Kn.set([b,v,a,o,l,h],6);return Math.abs(Math.atan2(v-o,b-a)-Math.atan2(m,f))<Math.PI/2?([a,o,l,h]=this.#Kn.subarray(2,6),this.#Xn.push(NaN,NaN,NaN,NaN,((a+l)/2-i)/n,((o+h)/2-s)/r),[a,o,b,v]=this.#Kn.subarray(14,18),this.#Wn.push(NaN,NaN,NaN,NaN,((b+a)/2-i)/n,((v+o)/2-s)/r),!0):([b,v,a,o,l,h]=this.#Kn.subarray(0,6),this.#Xn.push(((b+5*a)/6-i)/n,((v+5*o)/6-s)/r,((5*a+l)/6-i)/n,((5*o+h)/6-s)/r,((a+l)/2-i)/n,((o+h)/2-s)/r),[l,h,a,o,b,v]=this.#Kn.subarray(12,18),this.#Wn.push(((b+5*a)/6-i)/n,((v+5*o)/6-s)/r,((5*a+l)/6-i)/n,((5*o+h)/6-s)/r,((a+l)/2-i)/n,((o+h)/2-s)/r),!0)}toSVGPath(){if(this.isEmpty())return"";const t=this.#Xn,e=this.#Wn;if(isNaN(this.#Kn[6])&&!this.isEmpty())return this.#or();const i=[];i.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#lr(i);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#hr(i),i.join(" ")}#or(){const[t,e,i,s]=this.#$n,[n,r,a,o]=this.#ar();return`M${(this.#Kn[2]-t)/i} ${(this.#Kn[3]-e)/s} L${(this.#Kn[4]-t)/i} ${(this.#Kn[5]-e)/s} L${n} ${r} L${a} ${o} L${(this.#Kn[16]-t)/i} ${(this.#Kn[17]-e)/s} L${(this.#Kn[14]-t)/i} ${(this.#Kn[15]-e)/s} Z`}#hr(t){const e=this.#Wn;t.push(`L${e[4]} ${e[5]} Z`)}#lr(t){const[e,i,s,n]=this.#$n,r=this.#Kn.subarray(4,6),a=this.#Kn.subarray(16,18),[o,l,h,d]=this.#ar();t.push(`L${(r[0]-e)/s} ${(r[1]-i)/n} L${o} ${l} L${h} ${d} L${(a[0]-e)/s} ${(a[1]-i)/n}`)}newFreeDrawOutline(t,e,i,s,n,r){return new ln(t,e,i,s,n,r)}getOutlines(){const t=this.#Xn,e=this.#Wn,i=this.#Kn,[s,n,r,a]=this.#$n,o=new Float32Array((this.#ir?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#ir[t]-s)/r,o[t+1]=(this.#ir[t+1]-n)/a;if(o[o.length-2]=(this.#Yn-s)/r,o[o.length-1]=(this.#Qn-n)/a,isNaN(i[6])&&!this.isEmpty())return this.#dr(o);const l=new Float32Array(this.#Xn.length+24+this.#Wn.length);let h=t.length;for(let e=0;e<h;e+=2)isNaN(t[e])?l[e]=l[e+1]=NaN:(l[e]=t[e],l[e+1]=t[e+1]);h=this.#cr(l,h);for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2)isNaN(e[t+i])?(l[h]=l[h+1]=NaN,h+=2):(l[h]=e[t+i],l[h+1]=e[t+i+1],h+=2);return this.#ur(l,h),this.newFreeDrawOutline(l,o,this.#$n,this.#tr,this.#Gn,this.#qn)}#dr(t){const e=this.#Kn,[i,s,n,r]=this.#$n,[a,o,l,h]=this.#ar(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/n,(e[3]-s)/r,NaN,NaN,NaN,NaN,(e[4]-i)/n,(e[5]-s)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/n,(e[17]-s)/r,NaN,NaN,NaN,NaN,(e[14]-i)/n,(e[15]-s)/r],0),this.newFreeDrawOutline(d,t,this.#$n,this.#tr,this.#Gn,this.#qn)}#ur(t,e){const i=this.#Wn;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#cr(t,e){const i=this.#Kn.subarray(4,6),s=this.#Kn.subarray(16,18),[n,r,a,o]=this.#$n,[l,h,d,c]=this.#ar();return t.set([NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,d,c,NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/o],e),e+24}}class ln extends an{#$n;#pr=new Float32Array(4);#Gn;#qn;#ir;#tr;#gr;constructor(t,e,i,s,n,r){super(),this.#gr=t,this.#ir=e,this.#$n=i,this.#tr=s,this.#Gn=n,this.#qn=r,this.lastPoint=[NaN,NaN],this.#fr(r);const[a,o,l,h]=this.#pr;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-a)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-a)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){const t=[`M${this.#gr[4]} ${this.#gr[5]}`];for(let e=6,i=this.#gr.length;e<i;e+=6)isNaN(this.#gr[e])?t.push(`L${this.#gr[e+4]} ${this.#gr[e+5]}`):t.push(`C${this.#gr[e]} ${this.#gr[e+1]} ${this.#gr[e+2]} ${this.#gr[e+3]} ${this.#gr[e+4]} ${this.#gr[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,i,s],n){const r=i-t,a=s-e;let o,l;switch(n){case 0:o=an._rescale(this.#gr,t,s,r,-a),l=an._rescale(this.#ir,t,s,r,-a);break;case 90:o=an._rescaleAndSwap(this.#gr,t,e,r,a),l=an._rescaleAndSwap(this.#ir,t,e,r,a);break;case 180:o=an._rescale(this.#gr,i,e,-r,a),l=an._rescale(this.#ir,i,e,-r,a);break;case 270:o=an._rescaleAndSwap(this.#gr,i,s,-r,-a),l=an._rescaleAndSwap(this.#ir,i,s,-r,-a)}return{outline:Array.from(o),points:[Array.from(l)]}}#fr(t){const e=this.#gr;let i=e[4],s=e[5],n=i,r=s,a=i,o=s,l=i,h=s;const d=t?Math.max:Math.min;for(let t=6,c=e.length;t<c;t+=6){if(isNaN(e[t]))n=Math.min(n,e[t+4]),r=Math.min(r,e[t+5]),a=Math.max(a,e[t+4]),o=Math.max(o,e[t+5]),h<e[t+5]?(l=e[t+4],h=e[t+5]):h===e[t+5]&&(l=d(l,e[t+4]));else{const c=Ot.bezierBoundingBox(i,s,...e.slice(t,t+6));n=Math.min(n,c[0]),r=Math.min(r,c[1]),a=Math.max(a,c[2]),o=Math.max(o,c[3]),h<c[3]?(l=c[2],h=c[3]):h===c[3]&&(l=d(l,c[2]))}i=e[t+4],s=e[t+5]}const c=this.#pr;c[0]=n-this.#Gn,c[1]=r-this.#Gn,c[2]=a-n+2*this.#Gn,c[3]=o-r+2*this.#Gn,this.lastPoint=[l,h]}get box(){return this.#pr}newOutliner(t,e,i,s,n,r=0){return new on(t,e,i,s,n,r)}getNewOutline(t,e){const[i,s,n,r]=this.#pr,[a,o,l,h]=this.#$n,d=n*l,c=r*h,u=i*l+a,p=s*h+o,g=this.newOutliner({x:this.#ir[0]*d+u,y:this.#ir[1]*c+p},this.#$n,this.#tr,t,this.#qn,e??this.#Gn);for(let t=2;t<this.#ir.length;t+=2)g.add({x:this.#ir[t]*d+u,y:this.#ir[t+1]*c+p});return g.getOutlines()}}class hn{#$n;#mr;#br=[];#vr=[];constructor(t,e=0,i=0,s=!0){let n=1/0,r=-1/0,a=1/0,o=-1/0;const l=10**-4;for(const{x:i,y:s,width:h,height:d}of t){const t=Math.floor((i-e)/l)*l,c=Math.ceil((i+h+e)/l)*l,u=Math.floor((s-e)/l)*l,p=Math.ceil((s+d+e)/l)*l,g=[t,u,p,!0],f=[c,u,p,!1];this.#br.push(g,f),n=Math.min(n,t),r=Math.max(r,c),a=Math.min(a,u),o=Math.max(o,p)}const h=r-n+2*i,d=o-a+2*i,c=n-i,u=a-i,p=this.#br.at(s?-1:-2),g=[p[0],p[2]];for(const t of this.#br){const[e,i,s]=t;t[0]=(e-c)/h,t[1]=(i-u)/d,t[2]=(s-u)/d}this.#$n=new Float32Array([c,u,h,d]),this.#mr=g}getOutlines(){this.#br.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of this.#br)e[3]?(t.push(...this.#wr(e)),this.#yr(e)):(this.#Ar(e),t.push(...this.#wr(e)));return this.#_r(t)}#_r(t){const e=[],i=new Set;for(const i of t){const[t,s,n]=i;e.push([t,s,i],[t,n,i])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(let t=0,s=e.length;t<s;t+=2){const s=e[t][2],n=e[t+1][2];s.push(n),n.push(s),i.add(s),i.add(n)}const s=[];let n;for(;i.size>0;){const t=i.values().next().value;let[e,r,a,o,l]=t;i.delete(t);let h=e,d=r;for(n=[e,a],s.push(n);;){let t;if(i.has(o))t=o;else{if(!i.has(l))break;t=l}i.delete(t),[e,r,a,o,l]=t,h!==e&&(n.push(h,d,e,d===r?r:a),h=e),d=d===r?a:r}n.push(h,d)}return new dn(s,this.#$n,this.#mr)}#xr(t){const e=this.#vr;let i=0,s=e.length-1;for(;i<=s;){const n=i+s>>1,r=e[n][0];if(r===t)return n;r<t?i=n+1:s=n-1}return s+1}#yr([,t,e]){const i=this.#xr(t);this.#vr.splice(i,0,[t,e])}#Ar([,t,e]){const i=this.#xr(t);for(let s=i;s<this.#vr.length;s++){const[i,n]=this.#vr[s];if(i!==t)break;if(i===t&&n===e)return void this.#vr.splice(s,1)}for(let s=i-1;s>=0;s--){const[i,n]=this.#vr[s];if(i!==t)break;if(i===t&&n===e)return void this.#vr.splice(s,1)}}#wr(t){const[e,i,s]=t,n=[[e,i,s]],r=this.#xr(s);for(let t=0;t<r;t++){const[i,s]=this.#vr[t];for(let t=0,r=n.length;t<r;t++){const[,a,o]=n[t];if(!(s<=a||o<=i))if(a>=i)if(o>s)n[t][1]=s;else{if(1===r)return[];n.splice(t,1),t--,r--}else n[t][2]=i,o>s&&n.push([e,s,o])}}return n}}class dn extends an{#$n;#Sr;constructor(t,e,i){super(),this.#Sr=t,this.#$n=e,this.lastPoint=i}toSVGPath(){const t=[];for(const e of this.#Sr){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n<e.length;n+=2){const r=e[n],a=e[n+1];r===i?(t.push(`V${a}`),s=a):a===s&&(t.push(`H${r}`),i=r)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],n){const r=[],a=i-t,o=s-e;for(const e of this.#Sr){const i=new Array(e.length);for(let n=0;n<e.length;n+=2)i[n]=t+e[n]*a,i[n+1]=s-e[n+1]*o;r.push(i)}return r}get box(){return this.#$n}get classNamesForOutlining(){return["highlightOutline"]}}class cn extends on{newFreeDrawOutline(t,e,i,s,n,r){return new un(t,e,i,s,n,r)}}class un extends ln{newOutliner(t,e,i,s,n,r=0){return new cn(t,e,i,s,n,r)}}let pn=class t{#Cr=null;#Er=null;#Pr;#Mr=null;#Tr=!1;#kr=!1;#r=null;#Ir;#Lr=null;#f=null;#Dr;static#Rr=null;static get _keyboardManager(){return xt(this,"_keyboardManager",new ge([[["Escape","mac+Escape"],t.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],t.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],t.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],t.prototype._moveToPrevious],[["Home","mac+Home"],t.prototype._moveToBeginning],[["End","mac+End"],t.prototype._moveToEnd]]))}constructor({editor:e=null,uiManager:i=null}){e?(this.#kr=!1,this.#Dr=R.HIGHLIGHT_COLOR,this.#r=e):(this.#kr=!0,this.#Dr=R.HIGHLIGHT_DEFAULT_COLOR),this.#f=e?._uiManager||i,this.#Ir=this.#f._eventBus,this.#Pr=e?.color||this.#f?.highlightColors.values().next().value||"#FFFF98",t.#Rr||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){const t=this.#Cr=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=this.#f._signal;t.addEventListener("click",this.#Nr.bind(this),{signal:e}),t.addEventListener("keydown",this.#qs.bind(this),{signal:e});const i=this.#Er=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#Pr,t.append(i),t}renderMainDropdown(){const t=this.#Mr=this.#Fr();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#Fr(){const e=document.createElement("div"),i=this.#f._signal;e.addEventListener("contextmenu",Zt,{signal:i}),e.className="dropdown",e.role="listbox",e.setAttribute("aria-multiselectable",!1),e.setAttribute("aria-orientation","vertical"),e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[s,n]of this.#f.highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",n),r.title=s,r.setAttribute("data-l10n-id",t.#Rr[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=n,r.setAttribute("aria-selected",n===this.#Pr),r.addEventListener("click",this.#Or.bind(this,n),{signal:i}),e.append(r)}return e.addEventListener("keydown",this.#qs.bind(this),{signal:i}),e}#Or(t,e){e.stopPropagation(),this.#Ir.dispatch("switchannotationeditorparams",{source:this,type:this.#Dr,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#Cr)return void this.#Nr(t);const e=t.target.getAttribute("data-color");e&&this.#Or(e,t)}_moveToNext(t){this.#Br?t.target!==this.#Cr?t.target.nextSibling?.focus():this.#Mr.firstChild?.focus():this.#Nr(t)}_moveToPrevious(t){t.target!==this.#Mr?.firstChild&&t.target!==this.#Cr?(this.#Br||this.#Nr(t),t.target.previousSibling?.focus()):this.#Br&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#Br?this.#Mr.firstChild?.focus():this.#Nr(t)}_moveToEnd(t){this.#Br?this.#Mr.lastChild?.focus():this.#Nr(t)}#qs(e){t._keyboardManager.exec(this,e)}#Nr(t){if(this.#Br)return void this.hideDropdown();if(this.#Tr=0===t.detail,this.#Lr||(this.#Lr=new AbortController,window.addEventListener("pointerdown",this.#h.bind(this),{signal:this.#f.combinedSignal(this.#Lr)})),this.#Mr)return void this.#Mr.classList.remove("hidden");const e=this.#Mr=this.#Fr();this.#Cr.append(e)}#h(t){this.#Mr?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#Mr?.classList.add("hidden"),this.#Lr?.abort(),this.#Lr=null}get#Br(){return this.#Mr&&!this.#Mr.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#kr||(this.#Br?(this.hideDropdown(),this.#Cr.focus({preventScroll:!0,focusVisible:this.#Tr})):this.#r?.unselect())}updateColor(t){if(this.#Er&&(this.#Er.style.backgroundColor=t),!this.#Mr)return;const e=this.#f.highlightColors.values();for(const i of this.#Mr.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#Cr?.remove(),this.#Cr=null,this.#Er=null,this.#Mr?.remove(),this.#Mr=null}};class gn extends we{#jr=null;#Vr=0;#Hr;#zr=null;#n=null;#Ur=null;#$r=null;#Wr=0;#Gr=null;#qr=null;#w=null;#Xr=!1;#mr=null;#Kr;#Yr=null;#Qr="";#er;#Jr="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=D.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=gn.prototype;return xt(this,"_keyboardManager",new ge([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||gn._defaultColor,this.#er=t.thickness||gn._defaultThickness,this.#Kr=t.opacity||gn._defaultOpacity,this.#Hr=t.boxes||null,this.#Jr=t.methodOfCreation||"",this.#Qr=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#Xr=!0,this.#Zr(t),this.#ta()):this.#Hr&&(this.#jr=t.anchorNode,this.#Vr=t.anchorOffset,this.#$r=t.focusNode,this.#Wr=t.focusOffset,this.#ea(),this.#ta(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#Xr?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#er,methodOfCreation:this.#Jr}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#ea(){const t=new hn(this.#Hr,.001);this.#qr=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#qr.box;const e=new hn(this.#Hr,.0025,.001,"ltr"===this._uiManager.direction);this.#Ur=e.getOutlines();const{lastPoint:i}=this.#Ur;this.#mr=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#Zr({highlightOutlines:t,highlightId:e,clipPathId:i}){this.#qr=t;if(this.#Ur=t.getNewOutline(this.#er/2+1.5,.0025),e>=0)this.#w=e,this.#zr=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#Yr=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#Ur.box,path:{d:this.#Ur.toSVGPath()}},!0);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#w,{bbox:gn.#ia(this.#qr.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#Yr,{bbox:gn.#ia(this.#Ur.box,e),path:{d:this.#Ur.toSVGPath()}})}const[s,n,r,a]=t.box;switch(this.rotation){case 0:this.x=s,this.y=n,this.width=r,this.height=a;break;case 90:{const[t,e]=this.parentDimensions;this.x=n,this.y=1-s,this.width=r*e/t,this.height=a*t/e;break}case 180:this.x=1-s,this.y=1-n,this.width=r,this.height=a;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-n,this.y=s,this.width=r*e/t,this.height=a*t/e;break}}const{lastPoint:o}=this.#Ur;this.#mr=[(o[0]-s)/r,(o[1]-n)/a]}static initialize(t,e){we.initialize(t,e),gn._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case R.HIGHLIGHT_DEFAULT_COLOR:gn._defaultColor=e;break;case R.HIGHLIGHT_THICKNESS:gn._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#mr}updateParams(t,e){switch(t){case R.HIGHLIGHT_COLOR:this.#Fn(e);break;case R.HIGHLIGHT_THICKNESS:this.#sa(e)}}static get defaultPropertiesToUpdate(){return[[R.HIGHLIGHT_DEFAULT_COLOR,gn._defaultColor],[R.HIGHLIGHT_THICKNESS,gn._defaultThickness]]}get propertiesToUpdate(){return[[R.HIGHLIGHT_COLOR,this.color||gn._defaultColor],[R.HIGHLIGHT_THICKNESS,this.#er||gn._defaultThickness],[R.HIGHLIGHT_FREE,this.#Xr]]}#Fn(t){const e=(t,e)=>{this.color=t,this.#Kr=e,this.parent?.drawLayer.updateProperties(this.#w,{root:{fill:t,"fill-opacity":e}}),this.#n?.updateColor(t)},i=this.color,s=this.#Kr;this.addCommands({cmd:e.bind(this,t,gn._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:R.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#sa(t){const e=this.#er,i=t=>{this.#er=t,this.#na(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:R.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#n=new pn({editor:this}),t.addColorPicker(this.#n)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#ra())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#ra())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#aa(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#ta(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#aa():t&&(this.#ta(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#na(t){if(!this.#Xr)return;this.#Zr({highlightOutlines:this.#qr.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#aa(){null!==this.#w&&this.parent&&(this.parent.drawLayer.remove(this.#w),this.#w=null,this.parent.drawLayer.remove(this.#Yr),this.#Yr=null)}#ta(t=this.parent){null===this.#w&&(({id:this.#w,clipPathId:this.#zr}=t.drawLayer.draw({bbox:this.#qr.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#Kr},rootClass:{highlight:!0,free:this.#Xr},path:{d:this.#qr.toSVGPath()}},!1,!0)),this.#Yr=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#Xr},bbox:this.#Ur.box,path:{d:this.#Ur.toSVGPath()}},this.#Xr),this.#Gr&&(this.#Gr.style.clipPath=this.#zr))}static#ia([t,e,i,s],n){switch(n){case 90:return[1-e-s,t,s,i];case 180:return[1-t-i,1-e-s,i,s];case 270:return[e,1-t-i,s,i]}return[t,e,i,s]}rotate(t){const{drawLayer:e}=this.parent;let i;this.#Xr?(t=(t-this.rotation+360)%360,i=gn.#ia(this.#qr.box,t)):i=gn.#ia([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#w,{bbox:i,root:{"data-main-rotation":t}}),e.updateProperties(this.#Yr,{bbox:gn.#ia(this.#Ur.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#Qr&&(t.setAttribute("aria-label",this.#Qr),t.setAttribute("role","mark")),this.#Xr?t.classList.add("free"):this.div.addEventListener("keydown",this.#oa.bind(this),{signal:this._uiManager._signal});const e=this.#Gr=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#zr;const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),de(this,this.#Gr,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Yr,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Yr,{rootClass:{hovered:!1}})}#oa(t){gn._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#la(!0);break;case 1:case 3:this.#la(!1)}}#la(t){if(!this.#jr)return;const e=window.getSelection();t?e.setPosition(this.#jr,this.#Vr):e.setPosition(this.#$r,this.#Wr)}select(){super.select(),this.#Yr&&this.parent?.drawLayer.updateProperties(this.#Yr,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#Yr&&(this.parent?.drawLayer.updateProperties(this.#Yr,{rootClass:{selected:!1}}),this.#Xr||this.#la(!1))}get _mustFixPosition(){return!this.#Xr}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#w,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#Yr,{rootClass:{hidden:!t}}))}#ra(){return this.#Xr?this.rotation:0}#ha(){if(this.#Xr)return null;const[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=this.#Hr,r=new Float32Array(8*n.length);let a=0;for(const{x:o,y:l,width:h,height:d}of n){const n=o*t+i,c=(1-l)*e+s;r[a]=r[a+4]=n,r[a+1]=r[a+3]=c,r[a+2]=r[a+6]=n+h*t,r[a+5]=r[a+7]=c-d*e,a+=8}return r}#da(t){return this.#qr.serialize(t,this.#ra())}static startHighlighting(t,e,{target:i,x:s,y:n}){const{x:r,y:a,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,d=t.combinedSignal(h),c=e=>{h.abort(),this.#ca(t,e)};window.addEventListener("blur",c,{signal:d}),window.addEventListener("pointerup",c,{signal:d}),window.addEventListener("pointerdown",te,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",Zt,{signal:d}),i.addEventListener("pointermove",this.#ua.bind(this,t),{signal:d}),this._freeHighlight=new cn({x:s,y:n},[r,a,o,l],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static#ua(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#ca(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,i){let s=null;if(t instanceof Ys){const{data:{quadPoints:e,rect:i,rotation:n,id:r,color:a,opacity:o,popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:D.HIGHLIGHT,color:Array.from(a),opacity:o,quadPoints:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:l}}else if(t instanceof Ks){const{data:{inkLists:e,rect:i,rotation:n,id:r,color:a,borderStyle:{rawWidth:o},popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:D.HIGHLIGHT,color:Array.from(a),thickness:o,inkLists:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:l}}const{color:n,quadPoints:r,inkLists:a,opacity:o}=t,l=await super.deserialize(t,e,i);l.color=Ot.makeHexColor(...n),l.#Kr=o||1,a&&(l.#er=t.thickness),l.annotationElementId=t.id||null,l._initialData=s;const[h,d]=l.pageDimensions,[c,u]=l.pageTranslation;if(r){const t=l.#Hr=[];for(let e=0;e<r.length;e+=8)t.push({x:(r[e]-c)/h,y:1-(r[e+1]-u)/d,width:(r[e+2]-r[e])/h,height:(r[e+1]-r[e+5])/d});l.#ea(),l.#ta(),l.rotate(l.rotation)}else if(a){l.#Xr=!0;const t=a[0],i={x:t[0]-c,y:d-(t[1]-u)},s=new cn(i,[0,0,h,d],1,l.#er/2,!0,.001);for(let e=0,n=t.length;e<n;e+=2)i.x=t[e]-c,i.y=d-(t[e+1]-u),s.add(i);const{id:n,clipPathId:r}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:l.color,"fill-opacity":l._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:s.toSVGPath()}},!0,!0);l.#Zr({highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:r}),l.#ta()}return l}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),i=we._colorManager.convert(this.color),s={annotationType:D.HIGHLIGHT,color:i,opacity:this.#Kr,thickness:this.#er,quadPoints:this.#ha(),outlines:this.#da(e),pageIndex:this.pageIndex,rect:e,rotation:this.#ra(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#Un(s)?null:(s.id=this.annotationElementId,s)}#Un(t){const{color:e}=this._initialData;return t.color.some(((t,i)=>t!==e[i]))}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class fn{#pa=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,i]of Object.entries(t))this.updateProperty(e,i)}updateSVGProperty(t,e){this.#pa[t]=e}toSVGProperties(){const t=this.#pa;return this.#pa=Object.create(null),{root:t}}reset(){this.#pa=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){yt("Not implemented")}}class mn extends we{#ga=null;#fa;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#ma=null;static#ba=null;static#va=null;static#wa=NaN;static#ya=null;static#Aa=null;static#_a=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#fa=t.mustBeCommitted||!1,t.drawOutlines&&(this.#xa(t),this.#ta())}#xa({drawOutlines:t,drawId:e,drawingOptions:i}){this.#ga=t,this._drawingOptions||=i,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#Sa(t,this.parent),this.#Ca(t.box)}#Sa(t,e){const{id:i}=e.drawLayer.draw(mn._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){const i=new Set(Object.keys(t));for(const[s,n]of Object.entries(e))i.has(s)?Object.assign(t[s],n):t[s]=n;return t}static getDefaultDrawingOptions(t){yt("Not implemented")}static get typesMap(){yt("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){const i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(mn.#ma.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){const s=this._drawingOptions,n=s[e],r=t=>{s.updateProperty(e,t);const i=this.#ga.updateProperty(e,t);i&&this.#Ca(i),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties())};this.addCommands({cmd:r.bind(this,i),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,mn._mergeSVGProperties(this.#ga.getPathResizingSVGProperties(this.#Ea()),{bbox:this.#Pa()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,mn._mergeSVGProperties(this.#ga.getPathResizedSVGProperties(this.#Ea()),{bbox:this.#Pa()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#Pa(t,e)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,mn._mergeSVGProperties(this.#ga.getPathTranslatedSVGProperties(this.#Ea(),this.parentDimensions),{bbox:this.#Pa()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#fa&&(this.#fa=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#aa(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#ta(),this.#Ca(this.#ga.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#aa()):t&&(this._uiManager.addShouldRescale(this),this.#ta(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#aa(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#ta(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#Sa(this.#ga,t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}#Ma([t,e,i,s]){const{parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[e,1-t,i*(r/n),s*(n/r)];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,i*(r/n),s*(n/r)];default:return[t,e,i,s]}}#Ea(){const{x:t,y:e,width:i,height:s,parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[1-e,t,i*(n/r),s*(r/n)];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,i*(n/r),s*(r/n)];default:return[t,e,i,s]}}#Ca(t){if([this.x,this.y,this.width,this.height]=this.#Ma(t),this.div){this.fixAndSetPosition();const[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()}#Pa(){const{x:t,y:e,width:i,height:s,rotation:n,parentRotation:r,parentDimensions:[a,o]}=this;switch((4*n+r)/90){case 1:return[1-e-s,t,s,i];case 2:return[1-t-i,1-e-s,i,s];case 3:return[e,1-t-i,s,i];case 4:return[t,e-i*(a/o),s*(o/a),i*(a/o)];case 5:return[1-e,t,i*(a/o),s*(o/a)];case 6:return[1-t-s*(o/a),1-e,s*(o/a),i*(a/o)];case 7:return[e-i*(a/o),1-t-s*(o/a),i*(a/o),s*(o/a)];case 8:return[t-i,e-s,i,s];case 9:return[1-e,t-i,s,i];case 10:return[1-t,1-e,i,s];case 11:return[e-s,1-t,s,i];case 12:return[t-s*(o/a),e,s*(o/a),i*(a/o)];case 13:return[1-e-i*(a/o),t-s*(o/a),i*(a/o),s*(o/a)];case 14:return[1-t,1-e-i*(a/o),s*(o/a),i*(a/o)];case 15:return[e,1-t,i*(a/o),s*(o/a)];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,mn._mergeSVGProperties({bbox:this.#Pa()},this.#ga.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#Ca(this.#ga.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const t=super.render();t.classList.add("draw");const e=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal";const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,e,i,s,n){yt("Not implemented")}static startDrawing(t,e,i,s){const{target:n,offsetX:r,offsetY:a,pointerId:o,pointerType:l}=s;if(mn.#ya&&mn.#ya!==l)return;const{viewport:{rotation:h}}=t,{width:d,height:c}=n.getBoundingClientRect(),u=mn.#ba=new AbortController,p=t.combinedSignal(u);mn.#wa||=o,mn.#ya??=l,window.addEventListener("pointerup",(t=>{mn.#wa===t.pointerId?this._endDraw(t):mn.#Aa?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointercancel",(t=>{mn.#wa===t.pointerId?this._currentParent.endDrawingSession():mn.#Aa?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointerdown",(t=>{mn.#ya===t.pointerType&&((mn.#Aa||=new Set).add(t.pointerId),mn.#ma.isCancellable()&&(mn.#ma.removeLastElement(),mn.#ma.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",Zt,{signal:p}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),n.addEventListener("touchmove",(t=>{t.timeStamp===mn.#_a&&te(t)}),{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),mn.#ma?t.drawLayer.updateProperties(this._currentDrawId,mn.#ma.startNew(r,a,d,c,h)):(e.updateUIForDefaultProperties(this),mn.#ma=this.createDrawerInstance(r,a,d,c,h),mn.#va=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(mn.#va.toSVGProperties(),mn.#ma.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(mn.#_a=-1,!mn.#ma)return;const{offsetX:e,offsetY:i,pointerId:s}=t;mn.#wa===s&&(mn.#Aa?.size>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,mn.#ma.add(e,i)),mn.#_a=t.timeStamp,te(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,mn.#ma=null,mn.#va=null,mn.#ya=null,mn.#_a=NaN),mn.#ba&&(mn.#ba.abort(),mn.#ba=null,mn.#wa=NaN,mn.#Aa=null)}static _endDraw(t){const e=this._currentParent;if(e)if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,mn.#ma.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const t=mn.#ma,i=this._currentDrawId,s=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:R.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(R.DRAW_STEP),!mn.#ma.isEmpty()){const{pageDimensions:[i,s],scale:n}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:mn.#ma.getOutlines(i*n,s*n,n,this._INNER_MARGIN),drawingOptions:mn.#va,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,n,r){yt("Not implemented")}static async deserialize(t,e,i){const{rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:a}}=e.viewport,o=this.deserializeDraw(r,a,s,n,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#xa({drawOutlines:o}),l.#ta(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){const[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return this.#ga.serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class bn{#Kn=new Float64Array(6);#bn;#Ta;#Ri;#er;#ir;#ka="";#Ia=0;#Sr=new vn;#La;#Da;constructor(t,e,i,s,n,r){this.#La=i,this.#Da=s,this.#Ri=n,this.#er=r,[t,e]=this.#Ra(t,e);const a=this.#bn=[NaN,NaN,NaN,NaN,t,e];this.#ir=[t,e],this.#Ta=[{line:a,points:this.#ir}],this.#Kn.set(a,0)}updateProperty(t,e){"stroke-width"===t&&(this.#er=e)}#Ra(t,e){return an._normalizePoint(t,e,this.#La,this.#Da,this.#Ri)}isEmpty(){return!this.#Ta||0===this.#Ta.length}isCancellable(){return this.#ir.length<=10}add(t,e){[t,e]=this.#Ra(t,e);const[i,s,n,r]=this.#Kn.subarray(2,6),a=t-n,o=e-r;return Math.hypot(this.#La*a,this.#Da*o)<=2?null:(this.#ir.push(t,e),isNaN(i)?(this.#Kn.set([n,r,t,e],2),this.#bn.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#Kn[0])&&this.#bn.splice(6,6),this.#Kn.set([i,s,n,r,t,e],0),this.#bn.push(...an.createBezierPoints(i,s,n,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const i=this.add(t,e);return i||(2===this.#ir.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,n){this.#La=i,this.#Da=s,this.#Ri=n,[t,e]=this.#Ra(t,e);const r=this.#bn=[NaN,NaN,NaN,NaN,t,e];this.#ir=[t,e];const a=this.#Ta.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#Ta.push({line:r,points:this.#ir}),this.#Kn.set(r,0),this.#Ia=0,this.toSVGPath(),null}getLastElement(){return this.#Ta.at(-1)}setLastElement(t){return this.#Ta?(this.#Ta.push(t),this.#bn=t.line,this.#ir=t.points,this.#Ia=0,{path:{d:this.toSVGPath()}}):this.#Sr.setLastElement(t)}removeLastElement(){if(!this.#Ta)return this.#Sr.removeLastElement();this.#Ta.pop(),this.#ka="";for(let t=0,e=this.#Ta.length;t<e;t++){const{line:e,points:i}=this.#Ta[t];this.#bn=e,this.#ir=i,this.#Ia=0,this.toSVGPath()}return{path:{d:this.#ka}}}toSVGPath(){const t=an.svgRound(this.#bn[4]),e=an.svgRound(this.#bn[5]);if(2===this.#ir.length)return this.#ka=`${this.#ka} M ${t} ${e} Z`,this.#ka;if(this.#ir.length<=6){const i=this.#ka.lastIndexOf("M");this.#ka=`${this.#ka.slice(0,i)} M ${t} ${e}`,this.#Ia=6}if(4===this.#ir.length){const t=an.svgRound(this.#bn[10]),e=an.svgRound(this.#bn[11]);return this.#ka=`${this.#ka} L ${t} ${e}`,this.#Ia=12,this.#ka}const i=[];0===this.#Ia&&(i.push(`M ${t} ${e}`),this.#Ia=6);for(let t=this.#Ia,e=this.#bn.length;t<e;t+=6){const[e,s,n,r,a,o]=this.#bn.slice(t,t+6).map(an.svgRound);i.push(`C${e} ${s} ${n} ${r} ${a} ${o}`)}return this.#ka+=i.join(" "),this.#Ia=this.#bn.length,this.#ka}getOutlines(t,e,i,s){const n=this.#Ta.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#Sr.build(this.#Ta,t,e,i,this.#Ri,this.#er,s),this.#Kn=null,this.#bn=null,this.#Ta=null,this.#ka=null,this.#Sr}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class vn extends an{#pr;#Na=0;#Gn;#Ta;#La;#Da;#Fa;#Ri;#er;build(t,e,i,s,n,r,a){this.#La=e,this.#Da=i,this.#Fa=s,this.#Ri=n,this.#er=r,this.#Gn=a??0,this.#Ta=t,this.#Oa()}setLastElement(t){return this.#Ta.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#Ta.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#Ta)if(t.push(`M${an.svgRound(e[4])} ${an.svgRound(e[5])}`),6!==e.length)if(12!==e.length)for(let i=6,s=e.length;i<s;i+=6){const[s,n,r,a,o,l]=e.subarray(i,i+6).map(an.svgRound);t.push(`C${s} ${n} ${r} ${a} ${o} ${l}`)}else t.push(`L${an.svgRound(e[10])} ${an.svgRound(e[11])}`);else t.push("Z");return t.join("")}serialize([t,e,i,s],n){const r=[],a=[],[o,l,h,d]=this.#Ba();let c,u,p,g,f,m,b,v,w;switch(this.#Ri){case 0:w=an._rescale,c=t,u=e+s,p=i,g=-s,f=t+o*i,m=e+(1-l-d)*s,b=t+(o+h)*i,v=e+(1-l)*s;break;case 90:w=an._rescaleAndSwap,c=t,u=e,p=i,g=s,f=t+l*i,m=e+o*s,b=t+(l+d)*i,v=e+(o+h)*s;break;case 180:w=an._rescale,c=t+i,u=e,p=-i,g=s,f=t+(1-o-h)*i,m=e+l*s,b=t+(1-o)*i,v=e+(l+d)*s;break;case 270:w=an._rescaleAndSwap,c=t+i,u=e+s,p=-i,g=-s,f=t+(1-l-d)*i,m=e+(1-o-h)*s,b=t+(1-l)*i,v=e+(1-o)*s}for(const{line:t,points:e}of this.#Ta)r.push(w(t,c,u,p,g,n?new Array(t.length):null)),a.push(w(e,c,u,p,g,n?new Array(e.length):null));return{lines:r,points:a,rect:[f,m,b,v]}}static deserialize(t,e,i,s,n,{paths:{lines:r,points:a},rotation:o,thickness:l}){const h=[];let d,c,u,p,g;switch(o){case 0:g=an._rescale,d=-t/i,c=e/s+1,u=1/i,p=-1/s;break;case 90:g=an._rescaleAndSwap,d=-e/s,c=-t/i,u=1/s,p=1/i;break;case 180:g=an._rescale,d=t/i+1,c=-e/s,u=-1/i,p=1/s;break;case 270:g=an._rescaleAndSwap,d=e/s+1,c=t/i+1,u=-1/s,p=-1/i}if(!r){r=[];for(const t of a){const e=t.length;if(2===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}const i=new Float32Array(3*(e-2));r.push(i);let[s,n,a,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,n],0);for(let r=4;r<e;r+=2){const e=t[r],l=t[r+1];i.set(an.createBezierPoints(s,n,a,o,e,l),3*(r-2)),[s,n,a,o]=[a,o,e,l]}}}for(let t=0,e=r.length;t<e;t++)h.push({line:g(r[t].map((t=>t??NaN)),d,c,u,p),points:g(a[t].map((t=>t??NaN)),d,c,u,p)});const f=new vn;return f.build(h,i,s,1,o,l,n),f}#ja(t=this.#er){const e=this.#Gn+t/2*this.#Fa;return this.#Ri%180==0?[e/this.#La,e/this.#Da]:[e/this.#Da,e/this.#La]}#Ba(){const[t,e,i,s]=this.#pr,[n,r]=this.#ja(0);return[t+n,e+r,i-2*n,s-2*r]}#Oa(){const t=this.#pr=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:e}of this.#Ta){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6){const[s,n]=e.subarray(i,i+2);t[0]=Math.min(t[0],s),t[1]=Math.min(t[1],n),t[2]=Math.max(t[2],s),t[3]=Math.max(t[3],n)}continue}let i=e[4],s=e[5];for(let n=6,r=e.length;n<r;n+=6){const[r,a,o,l,h,d]=e.subarray(n,n+6);Ot.bezierBoundingBox(i,s,r,a,o,l,h,d,t),i=h,s=d}}const[e,i]=this.#ja();t[0]=Math.min(1,Math.max(0,t[0]-e)),t[1]=Math.min(1,Math.max(0,t[1]-i)),t[2]=Math.min(1,Math.max(0,t[2]+e)),t[3]=Math.min(1,Math.max(0,t[3]+i)),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#pr}updateProperty(t,e){return"stroke-width"===t?this.#sa(e):null}#sa(t){const[e,i]=this.#ja();this.#er=t;const[s,n]=this.#ja(),[r,a]=[s-e,n-i],o=this.#pr;return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o}updateParentDimensions([t,e],i){const[s,n]=this.#ja();this.#La=t,this.#Da=e,this.#Fa=i;const[r,a]=this.#ja(),o=r-s,l=a-n,h=this.#pr;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#Na=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#pr.map(an.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#pr;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${an.svgRound(t)} ${an.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#pr;let i=0,s=0,n=0,r=0,a=0,o=0;switch(this.#Na){case 90:s=e/t,n=-t/e,a=t;break;case 180:i=-1,r=-1,a=t,o=e;break;case 270:s=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${n} ${r} ${an.svgRound(a)} ${an.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){const[n,r]=this.#ja(),[a,o,l,h]=this.#pr;if(Math.abs(l-n)<=an.PRECISION||Math.abs(h-r)<=an.PRECISION){const n=t+i/2-(a+l/2),r=e+s/2-(o+h/2);return{path:{"transform-origin":`${an.svgRound(t)} ${an.svgRound(e)}`,transform:`${this.rotationTransform} translate(${n} ${r})`}}}const d=(i-2*n)/(l-2*n),c=(s-2*r)/(h-2*r),u=l/i,p=h/s;return{path:{"transform-origin":`${an.svgRound(a)} ${an.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${p}) translate(${an.svgRound(n)} ${an.svgRound(r)}) scale(${d} ${c}) translate(${an.svgRound(-n)} ${an.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,i,s]){const[n,r]=this.#ja(),a=this.#pr,[o,l,h,d]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=s,Math.abs(h-n)<=an.PRECISION||Math.abs(d-r)<=an.PRECISION){const n=t+i/2-(o+h/2),r=e+s/2-(l+d/2);for(const{line:t,points:e}of this.#Ta)an._translate(t,n,r,t),an._translate(e,n,r,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${an.svgRound(t)} ${an.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const c=(i-2*n)/(h-2*n),u=(s-2*r)/(d-2*r),p=-c*(o+n)+t+n,g=-u*(l+r)+e+r;if(1!==c||1!==u||0!==p||0!==g)for(const{line:t,points:e}of this.#Ta)an._rescale(t,p,g,c,u,t),an._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${an.svgRound(t)} ${an.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[s,n]=i,r=this.#pr,a=t-r[0],o=e-r[1];if(this.#La===s&&this.#Da===n)for(const{line:t,points:e}of this.#Ta)an._translate(t,a,o,t),an._translate(e,a,o,e);else{const t=this.#La/s,e=this.#Da/n;this.#La=s,this.#Da=n;for(const{line:i,points:s}of this.#Ta)an._rescale(i,a,o,t,e,i),an._rescale(s,a,o,t,e,s);r[2]*=t,r[3]*=e}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${an.svgRound(t)} ${an.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#pr;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${an.svgRound(t[0])} ${an.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class wn extends fn{#Va;constructor(t){super(),this.#Va=t,super.updateProperties({fill:"none",stroke:we._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??=this["stroke-width"],e*=this.#Va.realScale),super.updateSVGProperty(t,e)}clone(){const t=new wn(this.#Va);return t.updateAll(this),t}}class yn extends mn{static _type="ink";static _editorType=D.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(t,e){we.initialize(t,e),this._defaultDrawingOptions=new wn(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return xt(this,"typesMap",new Map([[R.INK_THICKNESS,"stroke-width"],[R.INK_COLOR,"stroke"],[R.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,n){return new bn(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,r){return vn.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){let s=null;if(t instanceof Ks){const{data:{inkLists:e,rect:i,rotation:n,id:r,color:a,opacity:o,borderStyle:{rawWidth:l},popupRef:h},parent:{page:{pageNumber:d}}}=t;s=t={annotationType:D.INK,color:Array.from(a),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:d-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:h}}const n=await super.deserialize(t,e,i);return n.annotationElementId=t.id||null,n._initialData=s,n}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:i}){this._drawingOptions=yn.getDefaultDrawingOptions({stroke:Ot.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:i,rect:s}=this.serializeDraw(t),{_drawingOptions:{stroke:n,"stroke-opacity":r,"stroke-width":a}}=this,o={annotationType:D.INK,color:we._colorManager.convert(n),opacity:r,thickness:a,paths:{lines:e,points:i},pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?o:this.annotationElementId&&!this.#Un(o)?null:(o.id=this.annotationElementId,o)}#Un(t){const{color:e,thickness:i,opacity:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some(((t,i)=>t!==e[i]))||t.thickness!==i||t.opacity!==s||t.pageIndex!==n}renderAnnotationElement(t){const{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e}),null}}class An extends we{#Ha=null;#za=null;#Ua=null;#$a=null;#Wa=null;#Ga="";#qa=null;#Xa=null;#Ka=!1;#Ya=!1;static _type="stamp";static _editorType=D.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#$a=t.bitmapUrl,this.#Wa=t.bitmapFile}static initialize(t,e){we.initialize(t,e)}static get supportedTypes(){return xt(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((t=>`image/${t}`)))}static get supportedTypesStr(){return xt(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(D.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#Qa(t,e=!1){t?(this.#Ha=t.bitmap,e||(this.#za=t.id,this.#Ka=t.isSvg),t.file&&(this.#Ga=t.file.name),this.#Ja()):this.remove()}#Za(){if(this.#Ua=null,this._uiManager.enableWaiting(!1),this.#qa){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Ha)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Ha){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:s,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:s,width:n,height:r,channels:s.length/(n*r)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");const o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#to(){if(this.#za)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#za).then((t=>this.#Qa(t,!0))).finally((()=>this.#Za()));if(this.#$a){const t=this.#$a;return this.#$a=null,this._uiManager.enableWaiting(!0),void(this.#Ua=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#Qa(t))).finally((()=>this.#Za())))}if(this.#Wa){const t=this.#Wa;return this.#Wa=null,this._uiManager.enableWaiting(!0),void(this.#Ua=this._uiManager.imageManager.getFromFile(t).then((t=>this.#Qa(t))).finally((()=>this.#Za())))}const t=document.createElement("input");t.type="file",t.accept=An.supportedTypesStr;const e=this._uiManager._signal;this.#Ua=new Promise((i=>{t.addEventListener("change",(async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#Qa(e)}else this.remove();i()}),{signal:e}),t.addEventListener("cancel",(()=>{this.remove(),i()}),{signal:e})})).finally((()=>this.#Za())),t.click()}remove(){this.#za&&(this.#Ha=null,this._uiManager.imageManager.deleteId(this.#za),this.#qa?.remove(),this.#qa=null,this.#Xa&&(clearTimeout(this.#Xa),this.#Xa=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#za&&null===this.#qa&&this.#to(),this.isAttachedToDOM||this.parent.add(this))):this.#za&&this.#to()}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#Ua||this.#Ha||this.#$a||this.#Wa||this.#za)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#Ha?this.#Ja():this.#to(),this.width&&!this.annotationElementId){const[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==this.#Xa&&clearTimeout(this.#Xa);this.#Xa=setTimeout((()=>{this.#Xa=null,this.#eo()}),200)}#Ja(){const{div:t}=this;let{width:e,height:i}=this.#Ha;const[s,n]=this.pageDimensions,r=.75;if(this.width)e=this.width*s,i=this.height*n;else if(e>r*s||i>r*n){const t=Math.min(r*s/e,r*n/i);e*=t,i*=t}const[a,o]=this.parentDimensions;this.setDims(e*a/s,i*o/n),this._uiManager.enableWaiting(!1);const l=this.#qa=document.createElement("canvas");l.setAttribute("role","img"),this.addContainer(l),this.width=e/s,this.height=i/n,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#eo(),this.#Ya||(this.parent.addUndoableEditor(this),this.#Ya=!0),this._reportTelemetry({action:"inserted_image"}),this.#Ga&&l.setAttribute("aria-label",this.#Ga)}copyCanvas(t,e,i=!1){t||(t=224);const{width:s,height:n}=this.#Ha,r=new oe;let a=this.#Ha,o=s,l=n,h=null;if(e){if(s>e||n>e){const t=Math.min(e/s,e/n);o=Math.floor(s*t),l=Math.floor(n*t)}h=document.createElement("canvas");const t=h.width=Math.ceil(o*r.sx),i=h.height=Math.ceil(l*r.sy);this.#Ka||(a=this.#io(t,i));const d=h.getContext("2d");d.filter=this._uiManager.hcmFilter;let c="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(c="#8f8f9d",u="#42414d");const p=15,g=p*r.sx,f=p*r.sy,m=new OffscreenCanvas(2*g,2*f),b=m.getContext("2d");b.fillStyle=c,b.fillRect(0,0,2*g,2*f),b.fillStyle=u,b.fillRect(0,0,g,f),b.fillRect(g,f,g,f),d.fillStyle=d.createPattern(m,"repeat"),d.fillRect(0,0,t,i),d.drawImage(a,0,0,a.width,a.height,0,0,t,i)}let d=null;if(i){let e,i;if(r.symmetric&&a.width<t&&a.height<t)e=a.width,i=a.height;else if(a=this.#Ha,s>t||n>t){const r=Math.min(t/s,t/n);e=Math.floor(s*r),i=Math.floor(n*r),this.#Ka||(a=this.#io(e,i))}const o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(a,0,0,a.width,a.height,0,0,e,i),d={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:d}}#io(t,e){const{width:i,height:s}=this.#Ha;let n=i,r=s,a=this.#Ha;for(;n>2*t||r>2*e;){const i=n,s=r;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));const o=new OffscreenCanvas(n,r);o.getContext("2d").drawImage(a,0,0,i,s,0,0,n,r),a=o.transferToImageBitmap()}return a}#eo(){const[t,e]=this.parentDimensions,{width:i,height:s}=this,n=new oe,r=Math.ceil(i*t*n.sx),a=Math.ceil(s*e*n.sy),o=this.#qa;if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;const l=this.#Ka?this.#Ha:this.#io(r,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,r,a)}getImageForAltText(){return this.#qa}#so(t){if(t){if(this.#Ka){const t=this._uiManager.imageManager.getSvgUrl(this.#za);if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=this.#Ha);return t.getContext("2d").drawImage(this.#Ha,0,0),t.toDataURL()}if(this.#Ka){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*Ut.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*Ut.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(this.#Ha,0,0,this.#Ha.width,this.#Ha.height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(this.#Ha)}static async deserialize(t,e,i){let s=null;if(t instanceof tn){const{data:{rect:n,rotation:r,id:a,structParent:o,popupRef:l},container:h,parent:{page:{pageNumber:d}}}=t,c=h.querySelector("canvas"),u=i.imageManager.getFromCanvas(h.id,c);c.remove();const p=(await e._structTree.getAriaAttributes(`${Ht}${a}`))?.get("aria-label")||"";s=t={annotationType:D.STAMP,bitmapId:u.id,bitmap:u.bitmap,pageIndex:d-1,rect:n.slice(0),rotation:r,id:a,deleted:!1,accessibilityData:{decorative:!1,altText:p},isSvg:!1,structParent:o,popupRef:l}}const n=await super.deserialize(t,e,i),{rect:r,bitmap:a,bitmapUrl:o,bitmapId:l,isSvg:h,accessibilityData:d}=t;l&&i.imageManager.isValidId(l)?(n.#za=l,a&&(n.#Ha=a)):n.#$a=o,n.#Ka=h;const[c,u]=n.pageDimensions;return n.width=(r[2]-r[0])/c,n.height=(r[3]-r[1])/u,n.annotationElementId=t.id||null,d&&(n.altTextData=d),n._initialData=s,n.#Ya=!!s,n}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:D.STAMP,bitmapId:this.#za,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#Ka,structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=this.#so(!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(i.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const t=this.#Un(i);if(t.isSame)return null;t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,null===e)return i;e.stamps||=new Map;const r=this.#Ka?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#za)){if(this.#Ka){const t=e.stamps.get(this.#za);r>t.area&&(t.area=r,t.serialized.bitmap.close(),t.serialized.bitmap=this.#so(!1))}}else e.stamps.set(this.#za,{area:r,serialized:i}),i.bitmap=this.#so(!1);return i}#Un(t){const{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&s&&n,isSameAltText:n}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}let _n=class t{#En;#no=!1;#ro=null;#ao=null;#oo=null;#lo=new Map;#ho=!1;#do=!1;#co=!1;#uo=null;#po=null;#go=null;#fo=null;#f;static _initialized=!1;static#H=new Map([rn,yn,An,gn].map((t=>[t._editorType,t])));constructor({uiManager:e,pageIndex:i,div:s,structTreeLayer:n,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:d}){const c=[...t.#H.values()];if(!t._initialized){t._initialized=!0;for(const t of c)t.initialize(d,e)}e.registerEditorTypes(c),this.#f=e,this.pageIndex=i,this.div=s,this.#En=r,this.#ro=a,this.viewport=h,this.#go=l,this.drawLayer=o,this._structTree=n,this.#f.addLayer(this)}get isEmpty(){return 0===this.#lo.size}get isInvisible(){return this.isEmpty&&this.#f.getMode()===D.NONE}updateToolbar(t){this.#f.updateToolbar(t)}updateMode(e=this.#f.getMode()){switch(this.#mo(),e){case D.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case D.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case D.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:i}=this.div;for(const s of t.#H.values())i.toggle(`${s._type}Editing`,e===s._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#go?.div}setEditingState(t){this.#f.setEditingState(t)}addCommands(t){this.#f.addCommands(t)}cleanUndoStack(t){this.#f.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#ro?.div.classList.toggle("disabled",!t)}async enable(){this.#co=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const e of this.#lo.values())e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#f.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(!this.#ro)return void(this.#co=!1);const e=this.#ro.getEditableAnnotations();for(const i of e){if(i.hide(),this.#f.isDeletedAnnotationElement(i.data.id))continue;if(t.has(i.data.id))continue;const e=await this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}this.#co=!1}disable(){this.#do=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,i=new Map;for(const t of this.#lo.values())t.disableEditing(),t.annotationElementId&&(null===t.serialize()?(i.set(t.annotationElementId,t),this.getEditableAnnotation(t.annotationElementId)?.show(),t.remove()):e.set(t.annotationElementId,t));if(this.#ro){const t=this.#ro.getEditableAnnotations();for(const s of t){const{id:t}=s.data;if(this.#f.isDeletedAnnotationElement(t))continue;let n=i.get(t);n?(n.resetAnnotationElement(s),n.show(!1),s.show()):(n=e.get(t),n&&(this.#f.addChangedExistingAnnotation(n),n.renderAnnotationElement(s)&&n.show(!1)),s.show())}}this.#mo(),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const e of t.#H.values())s.remove(`${e._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#do=!1}getEditableAnnotation(t){return this.#ro?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#f.getActive()!==t&&this.#f.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#go?.div&&!this.#fo){this.#fo=new AbortController;const t=this.#f.combinedSignal(this.#fo);this.#go.div.addEventListener("pointerdown",this.#bo.bind(this),{signal:t}),this.#go.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#go?.div&&this.#fo&&(this.#fo.abort(),this.#fo=null,this.#go.div.classList.remove("highlighting"))}#bo(t){this.#f.unselectAll();const{target:e}=t;if(e===this.#go.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#go.div.contains(e)){const{isMac:e}=Nt.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#f.showAllEditors("highlight",!0,!0),this.#go.div.classList.add("free"),this.toggleDrawing(),gn.startHighlighting(this,"ltr"===this.#f.direction,{target:this.#go.div,x:t.x,y:t.y}),this.#go.div.addEventListener("pointerup",(()=>{this.#go.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#f._signal}),t.preventDefault()}}enableClick(){if(this.#ao)return;this.#ao=new AbortController;const t=this.#f.combinedSignal(this.#ao);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#ao?.abort(),this.#ao=null}attach(t){this.#lo.set(t.id,t);const{annotationElementId:e}=t;e&&this.#f.isDeletedAnnotationElement(e)&&this.#f.removeDeletedAnnotationElement(t)}detach(t){this.#lo.delete(t.id),this.#En?.removePointerInTextLayer(t.contentDiv),!this.#do&&t.annotationElementId&&this.#f.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#f.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#f.addDeletedAnnotationElement(t.annotationElementId),we.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),this.#f.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#co),this.#f.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#oo&&(t._focusEventsAllowed=!1,this.#oo=setTimeout((()=>{this.#oo=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this.#f._signal}),e.focus())}),0)),t._structTreeParentId=this.#En?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return this.#f.getId()}get#vo(){return t.#H.get(this.#f.getMode())}combinedSignal(t){return this.#f.combinedSignal(t)}#wo(t){const e=this.#vo;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#vo?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#f.updateToolbar(t),this.#f.updateMode(t);const{offsetX:i,offsetY:s}=this.#yo(),n=this.getNextId(),r=this.#wo({parent:this,id:n,x:i,y:s,uiManager:this.#f,isCentered:!0,...e});r&&this.add(r)}async deserialize(e){return await(t.#H.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#f))||null}createAndAddNewEditor(t,e,i={}){const s=this.getNextId(),n=this.#wo({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#f,isCentered:e,...i});return n&&this.add(n),n}#yo(){const{x:t,y:e,width:i,height:s}=this.div.getBoundingClientRect(),n=Math.max(0,t),r=Math.max(0,e),a=(n+Math.min(window.innerWidth,t+i))/2-t,o=(r+Math.min(window.innerHeight,e+s))/2-e,[l,h]=this.viewport.rotation%180==0?[a,o]:[o,a];return{offsetX:l,offsetY:h}}addNewEditor(){this.createAndAddNewEditor(this.#yo(),!0)}setSelected(t){this.#f.setSelected(t)}toggleSelected(t){this.#f.toggleSelected(t)}unselect(t){this.#f.unselect(t)}pointerup(t){const{isMac:e}=Nt.platform;0!==t.button||t.ctrlKey&&e||t.target===this.div&&this.#ho&&(this.#ho=!1,this.#vo?.isDrawer&&this.#vo.supportMultipleDrawings||(this.#no?this.#f.getMode()!==D.STAMP?this.createAndAddNewEditor(t,!1):this.#f.unselectAll():this.#no=!0))}pointerdown(t){if(this.#f.getMode()===D.HIGHLIGHT&&this.enableTextSelection(),this.#ho)return void(this.#ho=!1);const{isMac:e}=Nt.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#ho=!0,this.#vo?.isDrawer)return void this.startDrawingSession(t);const i=this.#f.getActive();this.#no=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus(),this.#uo)return void this.#vo.startDrawing(this,this.#f,!1,t);this.#f.setCurrentDrawingSession(this),this.#uo=new AbortController;const e=this.#f.combinedSignal(this.#uo);this.div.addEventListener("blur",(({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#po=null,this.commitOrRemove())}),{signal:e}),this.#vo.startDrawing(this,this.#f,!1,t)}pause(t){if(t){const{activeElement:t}=document;this.div.contains(t)&&(this.#po=t)}else this.#po&&setTimeout((()=>{this.#po?.focus(),this.#po=null}),0)}endDrawingSession(t=!1){return this.#uo?(this.#f.setCurrentDrawingSession(null),this.#uo.abort(),this.#uo=null,this.#po=null,this.#vo.endDrawing(t)):null}findNewParent(t,e,i){const s=this.#f.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#uo&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#uo&&this.#vo.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#f.getActive()?.parent===this&&(this.#f.commitOrRemove(),this.#f.setActiveEditor(null)),this.#oo&&(clearTimeout(this.#oo),this.#oo=null);for(const t of this.#lo.values())this.#En?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#lo.clear(),this.#f.removeLayer(this)}#mo(){for(const t of this.#lo.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,ae(this.div,t);for(const t of this.#f.getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:t}){this.#f.commitOrRemove(),this.#mo();const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,ae(this.div,{rotation:i}),e!==i)for(const t of this.#lo.values())t.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#f.viewParameters.realScale}},xn=class t{#nn=null;#w=0;#Ao=new Map;#_o=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#nn){if(this.#nn!==t){if(this.#Ao.size>0)for(const e of this.#Ao.values())e.remove(),t.append(e);this.#nn=t}}else this.#nn=t}static get _svgFactory(){return xt(this,"_svgFactory",new Ss)}static#xo(t,[e,i,s,n]){const{style:r}=t;r.top=100*i+"%",r.left=100*e+"%",r.width=100*s+"%",r.height=100*n+"%"}#So(){const e=t._svgFactory.create(1,1,!0);return this.#nn.append(e),e.setAttribute("aria-hidden",!0),e}#Co(e,i){const s=t._svgFactory.createElement("clipPath");e.append(s);const n=`clip_${i}`;s.setAttribute("id",n),s.setAttribute("clipPathUnits","objectBoundingBox");const r=t._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${i}`),r.classList.add("clip"),n}#Eo(t,e){for(const[i,s]of Object.entries(e))null===s?t.removeAttribute(i):t.setAttribute(i,s)}draw(e,i=!1,s=!1){const n=this.#w++,r=this.#So(),a=t._svgFactory.createElement("defs");r.append(a);const o=t._svgFactory.createElement("path");a.append(o);const l=`path_p${this.pageIndex}_${n}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),i&&this.#_o.set(n,o);const h=s?this.#Co(a,l):null,d=t._svgFactory.createElement("use");return r.append(d),d.setAttribute("href",`#${l}`),this.updateProperties(r,e),this.#Ao.set(n,r),{id:n,clipPathId:`url(#${h})`}}drawOutline(e,i){const s=this.#w++,n=this.#So(),r=t._svgFactory.createElement("defs");n.append(r);const a=t._svgFactory.createElement("path");r.append(a);const o=`path_p${this.pageIndex}_${s}`;let l;if(a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),i){const e=t._svgFactory.createElement("mask");r.append(e),l=`mask_p${this.pageIndex}_${s}`,e.setAttribute("id",l),e.setAttribute("maskUnits","objectBoundingBox");const i=t._svgFactory.createElement("rect");e.append(i),i.setAttribute("width","1"),i.setAttribute("height","1"),i.setAttribute("fill","white");const n=t._svgFactory.createElement("use");e.append(n),n.setAttribute("href",`#${o}`),n.setAttribute("stroke","none"),n.setAttribute("fill","black"),n.setAttribute("fill-rule","nonzero"),n.classList.add("mask")}const h=t._svgFactory.createElement("use");n.append(h),h.setAttribute("href",`#${o}`),l&&h.setAttribute("mask",`url(#${l})`);const d=h.cloneNode();return n.append(d),h.classList.add("mainOutline"),d.classList.add("secondaryOutline"),this.updateProperties(n,e),this.#Ao.set(s,n),s}finalizeDraw(t,e){this.#_o.delete(t),this.updateProperties(t,e)}updateProperties(e,i){if(!i)return;const{root:s,bbox:n,rootClass:r,path:a}=i,o="number"==typeof e?this.#Ao.get(e):e;if(o){if(s&&this.#Eo(o,s),n&&t.#xo(o,n),r){const{classList:t}=o;for(const[e,i]of Object.entries(r))t.toggle(e,i)}if(a){const t=o.firstChild.firstChild;this.#Eo(t,a)}}}updateParent(t,e){if(e===this)return;const i=this.#Ao.get(t);i&&(e.#nn.append(i),this.#Ao.delete(t),e.#Ao.set(t,i))}remove(t){this.#_o.delete(t),null!==this.#nn&&(this.#Ao.get(t).remove(),this.#Ao.delete(t))}destroy(){this.#nn=null;for(const t of this.#Ao.values())t.remove();this.#Ao.clear(),this.#_o.clear()}};globalThis.pdfjsTestingUtils={HighlightOutliner:hn};var Sn=w.AnnotationEditorParamsType,Cn=w.AnnotationEditorType,En=w.AnnotationMode,Pn=w.GlobalWorkerOptions,Mn=w.PDFDateString,Tn=w.PixelsPerInch,kn=w.RenderingCancelledException,In=w.getDocument,Ln=w.getPdfFilenameFromUrl,Dn=w.getXfaPageViewport,Rn={d:(t,e)=>{for(var i in e)Rn.o(e,i)&&!Rn.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},Nn=globalThis.pdfjsViewer={};Rn.d(Nn,{AnnotationLayerBuilder:()=>xa,DownloadManager:()=>Ca,EventBus:()=>Ma,FindState:()=>gr,GenericL10n:()=>$o,LinkTarget:()=>Tr,PDFFindController:()=>Mr,PDFHistory:()=>Go,PDFLinkService:()=>kr,PDFPageView:()=>gl,PDFScriptingManager:()=>bl,PDFSinglePageViewer:()=>Cl,PDFViewer:()=>Sl,ProgressBar:()=>ir,RenderingStates:()=>Fn,ScrollMode:()=>$n,SimpleLinkService:()=>Ir,SpreadMode:()=>Wn,StructTreeLayerBuilder:()=>ol,TextLayerBuilder:()=>dl,XfaLayerBuilder:()=>cl,parseQueryString:()=>qn});const Fn={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},On=0,Bn=1,jn=2,Vn=3,Hn=0,zn=1,Un=2,$n={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},Wn={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};function Gn(t,e,i=!1){let s=t.offsetParent;if(!s)return void console.error("offsetParent is not set -- cannot scroll");let n=t.offsetTop+t.clientTop,r=t.offsetLeft+t.clientLeft;for(;s.clientHeight===s.scrollHeight&&s.clientWidth===s.scrollWidth||i&&(s.classList.contains("markedContent")||"hidden"===getComputedStyle(s).overflow);)if(n+=s.offsetTop,r+=s.offsetLeft,s=s.offsetParent,!s)return;e&&(void 0!==e.top&&(n+=e.top),void 0!==e.left&&(r+=e.left,s.scrollLeft=r)),s.scrollTop=n}function qn(t){const e=new Map;for(const[i,s]of new URLSearchParams(t))e.set(i.toLowerCase(),s);return e}const Xn=/[\x00-\x1F]/g;function Kn(t,e=!1){return Xn.test(t)?e?t.replaceAll(Xn,(t=>"\0"===t?"":" ")):t.replaceAll("\0",""):t}function Yn(t,e,i=0){let s=i,n=t.length-1;if(n<0||!e(t[n]))return t.length;if(e(t[s]))return s;for(;s<n;){const i=s+n>>1;e(t[i])?n=i:s=i+1}return s}function Qn(t){if(Math.floor(t)===t)return[t,1];const e=1/t;if(e>8)return[1,8];if(Math.floor(e)===e)return[1,e];const i=t>1?e:t;let s,n=0,r=1,a=1,o=1;for(;;){const t=n+a,e=r+o;if(e>8)break;i<=t/e?(a=t,o=e):(n=t,r=e)}return s=i-n/r<a/o-i?i===t?[n,r]:[r,n]:i===t?[a,o]:[o,a],s}function Jn(t,e){return t-t%e}function Zn(t){return Number.isInteger(t)&&t%90==0}function tr(t){return t.width<=t.height}new Promise((function(t){window.requestAnimationFrame(t)}));const er=document.documentElement.style;let ir=class{#Po=null;#Mo=null;#To=0;#ko=null;#wi=!0;constructor(t){this.#Po=t.classList,this.#ko=t.style}get percent(){return this.#To}set percent(t){var e,i,s;this.#To=(e=t,i=0,s=100,Math.min(Math.max(e,i),s)),isNaN(t)?this.#Po.add("indeterminate"):(this.#Po.remove("indeterminate"),this.#ko.setProperty("--progressBar-percent",`${this.#To}%`))}setWidth(t){if(!t)return;const e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&this.#ko.setProperty("--progressBar-end-offset",`${e}px`)}setDisableAutoFetch(t=5e3){100===this.#To||isNaN(this.#To)||(this.#Mo&&clearTimeout(this.#Mo),this.show(),this.#Mo=setTimeout((()=>{this.#Mo=null,this.hide()}),t))}hide(){this.#wi&&(this.#wi=!1,this.#Po.add("hidden"))}show(){this.#wi||(this.#wi=!0,this.#Po.remove("hidden"))}};const sr=function(){const t=document.createElement("div");return t.style.width="round(down, calc(1.6666666666666665 * 792px), 1px)","calc(1320px)"===t.style.width?Math.fround:t=>t}(),nr=0,rr=1,ar=2,or=3,lr=4,hr=5,dr=6,cr=7;function ur(t){return function(t){return t<11904}(t)?function(t){return!(65408&t)}(t)?function(t){return 32===t||9===t||13===t||10===t}(t)?nr:function(t){return t>=97&&t<=122||t>=65&&t<=90}(t)||function(t){return t>=48&&t<=57}(t)||95===t?rr:ar:function(t){return 3584==(65408&t)}(t)?cr:160===t?nr:rr:function(t){return t>=13312&&t<=40959||t>=63744&&t<=64255}(t)?or:function(t){return t>=12448&&t<=12543}(t)?lr:function(t){return t>=12352&&t<=12447}(t)?hr:function(t){return t>=65376&&t<=65439}(t)?dr:rr}let pr;const gr={FOUND:0,NOT_FOUND:1,WRAPPED:2,PENDING:3},fr={"‐":"-","‘":"'","’":"'","‚":"'","‛":"'","“":'"',"”":'"',"„":'"',"‟":'"',"¼":"1/4","½":"1/2","¾":"3/4"},mr=new Set([12441,12442,2381,2509,2637,2765,2893,3021,3149,3277,3387,3388,3405,3530,3642,3770,3972,4153,4154,5908,5940,6098,6752,6980,7082,7083,7154,7155,11647,43014,43052,43204,43347,43456,43766,44013,3158,3953,3954,3962,3963,3964,3965,3968,3956]);let br;const vr=/\p{M}+/gu,wr=/([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu,yr=/([^\p{M}])\p{M}*$/u,Ar=/^\p{M}*([^\p{M}])/u,_r=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,xr=new Map,Sr=new Map;let Cr=null,Er=null;function Pr(t){const e=[];let i,s;for(;null!==(i=_r.exec(t));){let{index:t}=i;for(const s of i[0]){let i=xr.get(s);i||(i=s.normalize("NFD").length,xr.set(s,i)),e.push([i,t++])}}if(0===e.length&&Cr)s=Cr;else if(e.length>0&&Er)s=Er;else{const t=`([${Object.keys(fr).join("")}])|([${pr||=" ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩",pr}])|(${"(?:゙|゚)"}\\n)|(\\p{M}+(?:-\\n)?)|(${"\\p{Ll}-\\n\\p{Lu}"})|(\\S-\\n)|(${"(?:\\p{Ideographic}|[぀-ヿ])"}\\n)|(\\n)`;s=0===e.length?Cr=new RegExp(t+"|(\\u0000)","gum"):Er=new RegExp(t+"|([\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f])","gum")}const n=[];for(;null!==(i=vr.exec(t));)n.push([i[0].length,i.index]);let r=t.normalize("NFD");const a=[0,0];let o=0,l=0,h=0,d=0,c=0,u=!1;r=r.replace(s,((t,i,s,r,p,g,f,m,b,v,w)=>{if(w-=d,i){const t=fr[i],e=t.length;for(let t=1;t<e;t++)a.push(w-h+t,h-t);return h-=e-1,t}if(s){let t=Sr.get(s);t||(t=s.normalize("NFKC"),Sr.set(s,t));const e=t.length;for(let t=1;t<e;t++)a.push(w-h+t,h-t);return h-=e-1,t}if(r)return u=!0,w+c===n[o]?.[1]?++o:(a.push(w-1-h+1,h-1),h-=1,d+=1),a.push(w-h+1,h),d+=1,c+=1,r.charAt(0);if(p){const t=p.endsWith("\n"),e=t?p.length-2:p.length;u=!0;let i=e;w+c===n[o]?.[1]&&(i-=n[o][0],++o);for(let t=1;t<=i;t++)a.push(w-1-h+t,h-t);return h-=i,d+=i,t?(w+=e-1,a.push(w-h+1,1+h),h+=1,d+=1,c+=1,p.slice(0,e)):p}if(g)return d+=1,c+=1,g.replace("\n","");if(f){const t=f.length-2;return a.push(w-h+t,1+h),h+=1,d+=1,c+=1,f.slice(0,-2)}if(m){const t=m.length-1;return a.push(w-h+t,h),d+=1,c+=1,m.slice(0,-1)}if(b)return a.push(w-h+1,h-1),h-=1,d+=1,c+=1," ";if(w+c===e[l]?.[1]){const t=e[l][0]-1;++l;for(let e=1;e<=t;e++)a.push(w-(h-e),h-e);h-=t,d+=t}return v})),a.push(r.length,h);const p=new Uint32Array(a.length>>1),g=new Int32Array(a.length>>1);for(let t=0,e=a.length;t<e;t+=2)p[t>>1]=a[t],g[t>>1]=a[t+1];return[r,[p,g],u]}class Mr{#Io=null;#Lo=!0;#Do=0;constructor({linkService:t,eventBus:e,updateMatchesCountOnProgress:i=!0}){this._linkService=t,this._eventBus=e,this.#Lo=i,this.onIsPageVisible=null,this.#Ro(),e._on("find",this.#No.bind(this)),e._on("findbarclose",this.#Fo.bind(this))}get highlightMatches(){return this._highlightMatches}get pageMatches(){return this._pageMatches}get pageMatchesLength(){return this._pageMatchesLength}get selected(){return this._selected}get state(){return this.#Io}setDocument(t){this._pdfDocument&&this.#Ro(),t&&(this._pdfDocument=t,this._firstPageCapability.resolve())}#No(t){if(!t)return;const e=this._pdfDocument,{type:i}=t;(null===this.#Io||this.#Oo(t))&&(this._dirtyMatch=!0),this.#Io=t,"highlightallchange"!==i&&this.#Bo(gr.PENDING),this._firstPageCapability.promise.then((()=>{if(!this._pdfDocument||e&&this._pdfDocument!==e)return;this.#Bn();const t=!this._highlightMatches,s=!!this._findTimeout;this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),i?this._dirtyMatch?this.#jo():"again"===i?(this.#jo(),t&&this.#Io.highlightAll&&this.#Vo()):"highlightallchange"===i?(s?this.#jo():this._highlightMatches=!0,this.#Vo()):this.#jo():this._findTimeout=setTimeout((()=>{this.#jo(),this._findTimeout=null}),250)}))}scrollMatchIntoView({element:t=null,selectedLeft:e=0,pageIndex:i=-1,matchIndex:s=-1}){if(!this._scrollMatches||!t)return;if(-1===s||s!==this._selected.matchIdx)return;if(-1===i||i!==this._selected.pageIdx)return;this._scrollMatches=!1;Gn(t,{top:-50,left:e+-400},!0)}#Ro(){this._highlightMatches=!1,this._scrollMatches=!1,this._pdfDocument=null,this._pageMatches=[],this._pageMatchesLength=[],this.#Do=0,this.#Io=null,this._selected={pageIdx:-1,matchIdx:-1},this._offset={pageIdx:null,matchIdx:null,wrapped:!1},this._extractTextPromises=[],this._pageContents=[],this._pageDiffs=[],this._hasDiacritics=[],this._matchesCountTotal=0,this._pagesToSearch=null,this._pendingFindMatches=new Set,this._resumePageIdx=null,this._dirtyMatch=!1,clearTimeout(this._findTimeout),this._findTimeout=null,this._firstPageCapability=Promise.withResolvers()}get#Ho(){const{query:t}=this.#Io;return"string"==typeof t?(t!==this._rawQuery&&(this._rawQuery=t,[this._normalizedQuery]=Pr(t)),this._normalizedQuery):(t||[]).filter((t=>!!t)).map((t=>Pr(t)[0]))}#Oo(t){const e=t.query,i=this.#Io.query,s=typeof e;if(s!==typeof i)return!0;if("string"===s){if(e!==i)return!0}else if(JSON.stringify(e)!==JSON.stringify(i))return!0;switch(t.type){case"again":const t=this._selected.pageIdx+1,e=this._linkService;return t>=1&&t<=e.pagesCount&&t!==e.page&&!(this.onIsPageVisible?.(t)??1);case"highlightallchange":return!1}return!0}#zo(t,e,i){let s=t.slice(0,e).match(yr);if(s){const i=t.charCodeAt(e),n=s[1].charCodeAt(0);if(ur(i)===ur(n))return!1}if(s=t.slice(e+i).match(Ar),s){const n=t.charCodeAt(e+i-1),r=s[1].charCodeAt(0);if(ur(n)===ur(r))return!1}return!0}#Uo(t,e){const{matchDiacritics:i}=this.#Io;let s=!1;const n="[ ]*";return(t=t.replaceAll(wr,((t,n,r,a,o,l)=>n?`[ ]*\\${n}[ ]*`:r?`[ ]*${r}[ ]*`:a?"[ ]+":i?o||l:o?mr.has(o.charCodeAt(0))?o:"":e?(s=!0,`${l}\\p{M}*`):l))).endsWith(n)&&(t=t.slice(0,t.length-4)),i&&e&&(br||=String.fromCharCode(...mr),s=!0,t=`${t}(?=[${br}]|[^\\p{M}]|$)`),[s,t]}#$o(t){const e=this.#Ho;if(0===e.length)return;const i=this._pageContents[t],s=this.match(e,i,t),n=this._pageMatches[t]=[],r=this._pageMatchesLength[t]=[],a=this._pageDiffs[t];s?.forEach((({index:t,length:e})=>{const[i,s]=function(t,e,i){if(!t)return[e,i];const[s,n]=t,r=e,a=e+i-1;let o=Yn(s,(t=>t>=r));s[o]>r&&--o;let l=Yn(s,(t=>t>=a),o);s[l]>a&&--l;const h=r+n[o];return[h,a+n[l]+1-h]}(a,t,e);s&&(n.push(i),r.push(s))})),this.#Io.highlightAll&&this.#Wo(t),this._resumePageIdx===t&&(this._resumePageIdx=null,this.#Go());const o=n.length;this._matchesCountTotal+=o,this.#Lo?o>0&&this.#qo():++this.#Do===this._linkService.pagesCount&&this.#qo()}match(t,e,i){const s=this._hasDiacritics[i];let n=!1;if("string"==typeof t?[n,t]=this.#Uo(t,s):t=t.sort().reverse().map((t=>{const[e,i]=this.#Uo(t,s);return n||=e,`(${i})`})).join("|"),!t)return;const{caseSensitive:r,entireWord:a}=this.#Io;t=new RegExp(t,`g${n?"u":""}${r?"":"i"}`);const o=[];let l;for(;null!==(l=t.exec(e));)a&&!this.#zo(e,l.index,l[0].length)||o.push({index:l.index,length:l[0].length});return o}#Bn(){if(this._extractTextPromises.length>0)return;let t=Promise.resolve();const e={disableNormalization:!0};for(let i=0,s=this._linkService.pagesCount;i<s;i++){const{promise:s,resolve:n}=Promise.withResolvers();this._extractTextPromises[i]=s,t=t.then((()=>this._pdfDocument.getPage(i+1).then((t=>t.getTextContent(e))).then((t=>{const e=[];for(const i of t.items)e.push(i.str),i.hasEOL&&e.push("\n");[this._pageContents[i],this._pageDiffs[i],this._hasDiacritics[i]]=Pr(e.join("")),n()}),(t=>{console.error(`Unable to get text content for page ${i+1}`,t),this._pageContents[i]="",this._pageDiffs[i]=null,this._hasDiacritics[i]=!1,n()}))))}}#Wo(t){this._scrollMatches&&this._selected.pageIdx===t&&(this._linkService.page=t+1),this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:t})}#Vo(){this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:-1})}#jo(){const t=this.#Io.findPrevious,e=this._linkService.page-1,i=this._linkService.pagesCount;if(this._highlightMatches=!0,this._dirtyMatch){this._dirtyMatch=!1,this._selected.pageIdx=this._selected.matchIdx=-1,this._offset.pageIdx=e,this._offset.matchIdx=null,this._offset.wrapped=!1,this._resumePageIdx=null,this._pageMatches.length=0,this._pageMatchesLength.length=0,this.#Do=0,this._matchesCountTotal=0,this.#Vo();for(let t=0;t<i;t++)this._pendingFindMatches.has(t)||(this._pendingFindMatches.add(t),this._extractTextPromises[t].then((()=>{this._pendingFindMatches.delete(t),this.#$o(t)})))}if(0===this.#Ho.length)return void this.#Bo(gr.FOUND);if(this._resumePageIdx)return;const s=this._offset;if(this._pagesToSearch=i,null!==s.matchIdx){const e=this._pageMatches[s.pageIdx].length;if(!t&&s.matchIdx+1<e||t&&s.matchIdx>0)return s.matchIdx=t?s.matchIdx-1:s.matchIdx+1,void this.#Xo(!0);this.#Ko(t)}this.#Go()}#Yo(t){const e=this._offset,i=t.length,s=this.#Io.findPrevious;return i?(e.matchIdx=s?i-1:0,this.#Xo(!0),!0):(this.#Ko(s),!!(e.wrapped&&(e.matchIdx=null,this._pagesToSearch<0))&&(this.#Xo(!1),!0))}#Go(){null!==this._resumePageIdx&&console.error("There can only be one pending page.");let t=null;do{const e=this._offset.pageIdx;if(t=this._pageMatches[e],!t){this._resumePageIdx=e;break}}while(!this.#Yo(t))}#Ko(t){const e=this._offset,i=this._linkService.pagesCount;e.pageIdx=t?e.pageIdx-1:e.pageIdx+1,e.matchIdx=null,this._pagesToSearch--,(e.pageIdx>=i||e.pageIdx<0)&&(e.pageIdx=t?i-1:0,e.wrapped=!0)}#Xo(t=!1){let e=gr.NOT_FOUND;const i=this._offset.wrapped;if(this._offset.wrapped=!1,t){const t=this._selected.pageIdx;this._selected.pageIdx=this._offset.pageIdx,this._selected.matchIdx=this._offset.matchIdx,e=i?gr.WRAPPED:gr.FOUND,-1!==t&&t!==this._selected.pageIdx&&this.#Wo(t)}this.#Bo(e,this.#Io.findPrevious),-1!==this._selected.pageIdx&&(this._scrollMatches=!0,this.#Wo(this._selected.pageIdx))}#Fo(t){const e=this._pdfDocument;this._firstPageCapability.promise.then((()=>{!this._pdfDocument||e&&this._pdfDocument!==e||(this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),this._resumePageIdx&&(this._resumePageIdx=null,this._dirtyMatch=!0),this.#Bo(gr.FOUND),this._highlightMatches=!1,this.#Vo())}))}#Qo(){const{pageIdx:t,matchIdx:e}=this._selected;let i=0,s=this._matchesCountTotal;if(-1!==e){for(let e=0;e<t;e++)i+=this._pageMatches[e]?.length||0;i+=e+1}return(i<1||i>s)&&(i=s=0),{current:i,total:s}}#qo(){this._eventBus.dispatch("updatefindmatchescount",{source:this,matchesCount:this.#Qo()})}#Bo(t,e=!1){(this.#Lo||this.#Do===this._linkService.pagesCount&&t!==gr.PENDING)&&this._eventBus.dispatch("updatefindcontrolstate",{source:this,state:t,previous:e,entireWord:this.#Io?.entireWord??null,matchesCount:this.#Qo(),rawQuery:this.#Io?.query??null})}}const Tr={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};class kr{externalLinkEnabled=!0;constructor({eventBus:t,externalLinkTarget:e=null,externalLinkRel:i=null,ignoreDestinationZoom:s=!1}={}){this.eventBus=t,this.externalLinkTarget=e,this.externalLinkRel=i,this._ignoreDestinationZoom=s,this.baseUrl=null,this.pdfDocument=null,this.pdfViewer=null,this.pdfHistory=null}setDocument(t,e=null){this.baseUrl=e,this.pdfDocument=t}setViewer(t){this.pdfViewer=t}setHistory(t){this.pdfHistory=t}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return this.pdfDocument?this.pdfViewer.currentPageNumber:1}set page(t){this.pdfDocument&&(this.pdfViewer.currentPageNumber=t)}get rotation(){return this.pdfDocument?this.pdfViewer.pagesRotation:0}set rotation(t){this.pdfDocument&&(this.pdfViewer.pagesRotation=t)}get isInPresentationMode(){return!!this.pdfDocument&&this.pdfViewer.isInPresentationMode}async goToDestination(t){if(!this.pdfDocument)return;let e,i,s;if("string"==typeof t?(e=t,i=await this.pdfDocument.getDestination(t)):(e=null,i=await t),!Array.isArray(i))return void console.error(`goToDestination: "${i}" is not a valid destination array, for dest="${t}".`);const[n]=i;if(n&&"object"==typeof n){if(s=this.pdfDocument.cachedPageNumber(n),!s)try{s=await this.pdfDocument.getPageIndex(n)+1}catch{return void console.error(`goToDestination: "${n}" is not a valid page reference, for dest="${t}".`)}}else Number.isInteger(n)&&(s=n+1);!s||s<1||s>this.pagesCount?console.error(`goToDestination: "${s}" is not a valid page number, for dest="${t}".`):(this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.push({namedDest:e,explicitDest:i,pageNumber:s})),this.pdfViewer.scrollPageIntoView({pageNumber:s,destArray:i,ignoreDestinationZoom:this._ignoreDestinationZoom}))}goToPage(t){if(!this.pdfDocument)return;const e="string"==typeof t&&this.pdfViewer.pageLabelToPageNumber(t)||0|t;Number.isInteger(e)&&e>0&&e<=this.pagesCount?(this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.pushPage(e)),this.pdfViewer.scrollPageIntoView({pageNumber:e})):console.error(`PDFLinkService.goToPage: "${t}" is not a valid page.`)}addLinkAttributes(t,e,i=!1){if(!e||"string"!=typeof e)throw new Error('A valid "url" parameter must provided.');const s=i?Tr.BLANK:this.externalLinkTarget,n=this.externalLinkRel;this.externalLinkEnabled?t.href=t.title=e:(t.href="",t.title=`Disabled: ${e}`,t.onclick=()=>!1);let r="";switch(s){case Tr.NONE:break;case Tr.SELF:r="_self";break;case Tr.BLANK:r="_blank";break;case Tr.PARENT:r="_parent";break;case Tr.TOP:r="_top"}t.target=r,t.rel="string"==typeof n?n:"noopener noreferrer nofollow"}getDestinationHash(t){if("string"==typeof t){if(t.length>0)return this.getAnchorUrl("#"+escape(t))}else if(Array.isArray(t)){const e=JSON.stringify(t);if(e.length>0)return this.getAnchorUrl("#"+escape(e))}return this.getAnchorUrl("")}getAnchorUrl(t){return this.baseUrl?this.baseUrl+t:t}setHash(t){if(!this.pdfDocument)return;let e,i;if(t.includes("=")){const s=qn(t);if(s.has("search")){const t=s.get("search").replaceAll('"',""),e="true"===s.get("phrase");this.eventBus.dispatch("findfromurlhash",{source:this,query:e?t:t.match(/\S+/g)})}if(s.has("page")&&(e=0|s.get("page")||1),s.has("zoom")){const t=s.get("zoom").split(","),e=t[0],n=parseFloat(e);e.includes("Fit")?"Fit"===e||"FitB"===e?i=[null,{name:e}]:"FitH"===e||"FitBH"===e||"FitV"===e||"FitBV"===e?i=[null,{name:e},t.length>1?0|t[1]:null]:"FitR"===e?5!==t.length?console.error('PDFLinkService.setHash: Not enough parameters for "FitR".'):i=[null,{name:e},0|t[1],0|t[2],0|t[3],0|t[4]]:console.error(`PDFLinkService.setHash: "${e}" is not a valid zoom value.`):i=[null,{name:"XYZ"},t.length>1?0|t[1]:null,t.length>2?0|t[2]:null,n?n/100:e]}return i?this.pdfViewer.scrollPageIntoView({pageNumber:e||this.page,destArray:i,allowNegativeOffset:!0}):e&&(this.page=e),s.has("pagemode")&&this.eventBus.dispatch("pagemode",{source:this,mode:s.get("pagemode")}),void(s.has("nameddest")&&this.goToDestination(s.get("nameddest")))}i=unescape(t);try{i=JSON.parse(i),Array.isArray(i)||(i=i.toString())}catch{}"string"==typeof i||kr.#Jo(i)?this.goToDestination(i):console.error(`PDFLinkService.setHash: "${unescape(t)}" is not a valid destination.`)}executeNamedAction(t){if(this.pdfDocument){switch(t){case"GoBack":this.pdfHistory?.back();break;case"GoForward":this.pdfHistory?.forward();break;case"NextPage":this.pdfViewer.nextPage();break;case"PrevPage":this.pdfViewer.previousPage();break;case"LastPage":this.page=this.pagesCount;break;case"FirstPage":this.page=1}this.eventBus.dispatch("namedaction",{source:this,action:t})}}async executeSetOCGState(t){if(!this.pdfDocument)return;const e=this.pdfDocument,i=await this.pdfViewer.optionalContentConfigPromise;e===this.pdfDocument&&(i.setOCGState(t),this.pdfViewer.optionalContentConfigPromise=Promise.resolve(i))}static#Jo(t){if(!Array.isArray(t)||t.length<2)return!1;const[e,i,...s]=t;if(!("object"==typeof e&&Number.isInteger(e?.num)&&Number.isInteger(e?.gen)||Number.isInteger(e)))return!1;if("object"!=typeof i||"string"!=typeof i?.name)return!1;const n=s.length;let r=!0;switch(i.name){case"XYZ":if(n<2||n>3)return!1;break;case"Fit":case"FitB":return 0===n;case"FitH":case"FitBH":case"FitV":case"FitBV":if(n>1)return!1;break;case"FitR":if(4!==n)return!1;r=!1;break;default:return!1}for(const t of s)if(!("number"==typeof t||r&&null===t))return!1;return!0}}class Ir extends kr{setDocument(t,e=null){}}const{AbortException:Lr,AnnotationEditorLayer:Dr,AnnotationEditorParamsType:Rr,AnnotationEditorType:Nr,AnnotationEditorUIManager:Fr,AnnotationLayer:Or,AnnotationMode:Br,build:jr,ColorPicker:Vr,createValidAbsoluteUrl:Hr,DOMSVGFactory:zr,DrawLayer:Ur,FeatureTest:$r,fetchData:Wr,getDocument:Gr,getFilenameFromUrl:qr,getPdfFilenameFromUrl:Xr,getXfaPageViewport:Kr,GlobalWorkerOptions:Yr,ImageKind:Qr,InvalidPDFException:Jr,isDataScheme:Zr,isPdfFile:ta,MissingPDFException:ea,noContextMenu:ia,normalizeUnicode:sa,OPS:na,OutputScale:ra,PasswordResponses:aa,PDFDataRangeTransport:oa,PDFDateString:la,PDFWorker:ha,PermissionFlag:da,PixelsPerInch:ca,RenderingCancelledException:ua,setLayerDimensions:pa,shadow:ga,stopEvent:fa,TextLayer:ma,TouchManager:ba,UnexpectedResponseException:va,Util:wa,VerbosityLevel:ya,version:Aa,XfaLayer:_a}=globalThis.pdfjsLib;class xa{#Zo=null;#tl=null;constructor({pdfPage:t,linkService:e,downloadManager:i,annotationStorage:s=null,imageResourcesPath:n="",renderForms:r=!0,enableScripting:a=!1,hasJSActionsPromise:o=null,fieldObjectsPromise:l=null,annotationCanvasMap:h=null,accessibilityManager:d=null,annotationEditorUIManager:c=null,onAppend:u=null}){this.pdfPage=t,this.linkService=e,this.downloadManager=i,this.imageResourcesPath=n,this.renderForms=r,this.annotationStorage=s,this.enableScripting=a,this._hasJSActionsPromise=o||Promise.resolve(!1),this._fieldObjectsPromise=l||Promise.resolve(null),this._annotationCanvasMap=h,this._accessibilityManager=d,this._annotationEditorUIManager=c,this.#Zo=u,this.annotationLayer=null,this.div=null,this._cancelled=!1,this._eventBus=e.eventBus}async render(t,e,i="display"){if(this.div){if(this._cancelled||!this.annotationLayer)return;return void this.annotationLayer.update({viewport:t.clone({dontFlip:!0})})}const[s,n,r]=await Promise.all([this.pdfPage.getAnnotations({intent:i}),this._hasJSActionsPromise,this._fieldObjectsPromise]);if(this._cancelled)return;const a=this.div=document.createElement("div");a.className="annotationLayer",this.#Zo?.(a),0!==s.length?(this.annotationLayer=new Or({div:a,accessibilityManager:this._accessibilityManager,annotationCanvasMap:this._annotationCanvasMap,annotationEditorUIManager:this._annotationEditorUIManager,page:this.pdfPage,viewport:t.clone({dontFlip:!0}),structTreeLayer:e?.structTreeLayer||null}),await this.annotationLayer.render({annotations:s,imageResourcesPath:this.imageResourcesPath,renderForms:this.renderForms,linkService:this.linkService,downloadManager:this.downloadManager,annotationStorage:this.annotationStorage,enableScripting:this.enableScripting,hasJSActions:n,fieldObjects:r}),this.linkService.isInPresentationMode&&this.#el(Vn),this.#tl||(this.#tl=new AbortController,this._eventBus?._on("presentationmodechanged",(t=>{this.#el(t.state)}),{signal:this.#tl.signal}))):this.hide()}cancel(){this._cancelled=!0,this.#tl?.abort(),this.#tl=null}hide(){this.div&&(this.div.hidden=!0)}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}#el(t){if(!this.div)return;let e=!1;switch(t){case Vn:e=!0;break;case Bn:break;default:return}for(const t of this.div.childNodes)t.hasAttribute("data-internal-link")||(t.inert=e)}}function Sa(t,e){const i=document.createElement("a");if(!i.click)throw new Error('DownloadManager: "a.click()" is not supported.');i.href=t,i.target="_parent","download"in i&&(i.download=e),(document.body||document.documentElement).append(i),i.click(),i.remove()}class Ca{#il=new WeakMap;downloadData(t,e,i){Sa(URL.createObjectURL(new Blob([t],{type:i})),e)}openOrDownloadData(t,e,i=null){const s=ta(e)?"application/pdf":"";return this.downloadData(t,e,s),!1}download(t,e,i){let s;if(t)s=URL.createObjectURL(new Blob([t],{type:"application/pdf"}));else{if(!Hr(e,"http://example.com"))return void console.error(`download - not a valid URL: ${e}`);s=e+"#pdfjs.action=download"}Sa(s,i)}}const Ea="event",Pa="timeout";class Ma{#As=Object.create(null);on(t,e,i=null){this._on(t,e,{external:!0,once:i?.once,signal:i?.signal})}off(t,e,i=null){this._off(t,e)}dispatch(t,e){const i=this.#As[t];if(!i||0===i.length)return;let s;for(const{listener:n,external:r,once:a}of i.slice(0))a&&this._off(t,n),r?(s||=[]).push(n):n(e);if(s){for(const t of s)t(e);s=null}}_on(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){const{signal:n}=i;if(n.aborted)return void console.error("Cannot use an `aborted` signal.");const r=()=>this._off(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}(this.#As[t]||=[]).push({listener:e,external:!0===i?.external,once:!0===i?.once,rmAbort:s})}_off(t,e,i=null){const s=this.#As[t];if(s)for(let t=0,i=s.length;t<i;t++){const i=s[t];if(i.listener===e)return i.rmAbort?.(),void s.splice(t,1)}}}class Ta{constructor(t){this.value=t}valueOf(){return this.value}}class ka extends Ta{constructor(t="???"){super(t)}toString(t){return`{${this.value}}`}}class Ia extends Ta{constructor(t,e={}){super(t),this.opts=e}toString(t){try{return t.memoizeIntlObject(Intl.NumberFormat,this.opts).format(this.value)}catch(e){return t.reportError(e),this.value.toString(10)}}}class La extends Ta{constructor(t,e={}){super(t),this.opts=e}toString(t){try{return t.memoizeIntlObject(Intl.DateTimeFormat,this.opts).format(this.value)}catch(e){return t.reportError(e),new Date(this.value).toISOString()}}}function Da(t,e,i){if(i===e)return!0;if(i instanceof Ia&&e instanceof Ia&&i.value===e.value)return!0;if(e instanceof Ia&&"string"==typeof i){if(i===t.memoizeIntlObject(Intl.PluralRules,e.opts).select(e.value))return!0}return!1}function Ra(t,e,i){return e[i]?Ba(t,e[i].value):(t.reportError(new RangeError("No default")),new ka)}function Na(t,e){const i=[],s=Object.create(null);for(const n of e)"narg"===n.type?s[n.name]=Fa(t,n.value):i.push(Fa(t,n));return{positional:i,named:s}}function Fa(t,e){switch(e.type){case"str":return e.value;case"num":return new Ia(e.value,{minimumFractionDigits:e.precision});case"var":return function(t,{name:e}){let i;if(t.params){if(!Object.prototype.hasOwnProperty.call(t.params,e))return new ka(`$${e}`);i=t.params[e]}else{if(!t.args||!Object.prototype.hasOwnProperty.call(t.args,e))return t.reportError(new ReferenceError(`Unknown variable: $${e}`)),new ka(`$${e}`);i=t.args[e]}if(i instanceof Ta)return i;switch(typeof i){case"string":return i;case"number":return new Ia(i);case"object":if(i instanceof Date)return new La(i.getTime());default:return t.reportError(new TypeError(`Variable type not supported: $${e}, ${typeof i}`)),new ka(`$${e}`)}}(t,e);case"mesg":return function(t,{name:e,attr:i}){const s=t.bundle._messages.get(e);if(!s)return t.reportError(new ReferenceError(`Unknown message: ${e}`)),new ka(e);if(i){const n=s.attributes[i];return n?Ba(t,n):(t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new ka(`${e}.${i}`))}if(s.value)return Ba(t,s.value);return t.reportError(new ReferenceError(`No value: ${e}`)),new ka(e)}(t,e);case"term":return function(t,{name:e,attr:i,args:s}){const n=`-${e}`,r=t.bundle._terms.get(n);if(!r)return t.reportError(new ReferenceError(`Unknown term: ${n}`)),new ka(n);if(i){const e=r.attributes[i];if(e){t.params=Na(t,s).named;const i=Ba(t,e);return t.params=null,i}return t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new ka(`${n}.${i}`)}t.params=Na(t,s).named;const a=Ba(t,r.value);return t.params=null,a}(t,e);case"func":return function(t,{name:e,args:i}){let s=t.bundle._functions[e];if(!s)return t.reportError(new ReferenceError(`Unknown function: ${e}()`)),new ka(`${e}()`);if("function"!=typeof s)return t.reportError(new TypeError(`Function ${e}() is not callable`)),new ka(`${e}()`);try{let e=Na(t,i);return s(e.positional,e.named)}catch(i){return t.reportError(i),new ka(`${e}()`)}}(t,e);case"select":return function(t,{selector:e,variants:i,star:s}){let n=Fa(t,e);if(n instanceof ka)return Ra(t,i,s);for(const e of i){if(Da(t,n,Fa(t,e.key)))return Ba(t,e.value)}return Ra(t,i,s)}(t,e);default:return new ka}}function Oa(t,e){if(t.dirty.has(e))return t.reportError(new RangeError("Cyclic reference")),new ka;t.dirty.add(e);const i=[],s=t.bundle._useIsolating&&e.length>1;for(const n of e)if("string"!=typeof n){if(t.placeables++,t.placeables>100)throw t.dirty.delete(e),new RangeError(`Too many placeables expanded: ${t.placeables}, max allowed is 100`);s&&i.push("⁨"),i.push(Fa(t,n).toString(t)),s&&i.push("⁩")}else i.push(t.bundle._transform(n));return t.dirty.delete(e),i.join("")}function Ba(t,e){return"string"==typeof e?t.bundle._transform(e):Oa(t,e)}class ja{constructor(t,e,i){this.dirty=new WeakSet,this.params=null,this.placeables=0,this.bundle=t,this.errors=e,this.args=i}reportError(t){if(!(this.errors&&t instanceof Error))throw t;this.errors.push(t)}memoizeIntlObject(t,e){let i=this.bundle._intls.get(t);i||(i={},this.bundle._intls.set(t,i));let s=JSON.stringify(e);return i[s]||(i[s]=new t(this.bundle.locales,e)),i[s]}}function Va(t,e){const i=Object.create(null);for(const[s,n]of Object.entries(t))e.includes(s)&&(i[s]=n.valueOf());return i}const Ha=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function za(t,e){let i=t[0];if(i instanceof ka)return new ka(`NUMBER(${i.valueOf()})`);if(i instanceof Ia)return new Ia(i.valueOf(),{...i.opts,...Va(e,Ha)});if(i instanceof La)return new Ia(i.valueOf(),{...Va(e,Ha)});throw new TypeError("Invalid argument to NUMBER")}const Ua=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function $a(t,e){let i=t[0];if(i instanceof ka)return new ka(`DATETIME(${i.valueOf()})`);if(i instanceof La)return new La(i.valueOf(),{...i.opts,...Va(e,Ua)});if(i instanceof Ia)return new La(i.valueOf(),{...Va(e,Ua)});throw new TypeError("Invalid argument to DATETIME")}const Wa=new Map;class Ga{constructor(t,{functions:e,useIsolating:i=!0,transform:s=t=>t}={}){this._terms=new Map,this._messages=new Map,this.locales=Array.isArray(t)?t:[t],this._functions={NUMBER:za,DATETIME:$a,...e},this._useIsolating=i,this._transform=s,this._intls=function(t){const e=Array.isArray(t)?t.join(" "):t;let i=Wa.get(e);return void 0===i&&(i=new Map,Wa.set(e,i)),i}(t)}hasMessage(t){return this._messages.has(t)}getMessage(t){return this._messages.get(t)}addResource(t,{allowOverrides:e=!1}={}){const i=[];for(let s=0;s<t.body.length;s++){let n=t.body[s];if(n.id.startsWith("-")){if(!1===e&&this._terms.has(n.id)){i.push(new Error(`Attempt to override an existing term: "${n.id}"`));continue}this._terms.set(n.id,n)}else{if(!1===e&&this._messages.has(n.id)){i.push(new Error(`Attempt to override an existing message: "${n.id}"`));continue}this._messages.set(n.id,n)}}return i}formatPattern(t,e=null,i=null){if("string"==typeof t)return this._transform(t);let s=new ja(this,i,e);try{return Oa(s,t).toString(s)}catch(t){if(s.errors&&t instanceof Error)return s.errors.push(t),(new ka).toString(s);throw t}}}const qa=/^(-?[a-zA-Z][\w-]*) *= */gm,Xa=/\.([a-zA-Z][\w-]*) *= */y,Ka=/\*?\[/y,Ya=/(-?[0-9]+(?:\.([0-9]+))?)/y,Qa=/([a-zA-Z][\w-]*)/y,Ja=/([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y,Za=/^[A-Z][A-Z0-9_-]*$/,to=/([^{}\n\r]+)/y,eo=/([^\\"\n\r]*)/y,io=/\\([\\"])/y,so=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y,no=/^\n+/,ro=/ +$/,ao=/ *\r?\n/g,oo=/( *)$/,lo=/{\s*/y,ho=/\s*}/y,co=/\[\s*/y,uo=/\s*] */y,po=/\s*\(\s*/y,go=/\s*->\s*/y,fo=/\s*:\s*/y,mo=/\s*,?\s*/y,bo=/\s+/y;class vo{constructor(t){this.body=[],qa.lastIndex=0;let e=0;for(;;){let i=qa.exec(t);if(null===i)break;e=qa.lastIndex;try{this.body.push(o(i[1]))}catch(t){if(t instanceof SyntaxError)continue;throw t}}function i(i){return i.lastIndex=e,i.test(t)}function s(i,s){if(t[e]===i)return e++,!0;if(s)throw new s(`Expected ${i}`);return!1}function n(t,s){if(i(t))return e=t.lastIndex,!0;if(s)throw new s(`Expected ${t.toString()}`);return!1}function r(i){i.lastIndex=e;let s=i.exec(t);if(null===s)throw new SyntaxError(`Expected ${i.toString()}`);return e=i.lastIndex,s}function a(t){return r(t)[1]}function o(t){let e=l(),s=function(){let t=Object.create(null);for(;i(Xa);){let e=a(Xa),i=l();if(null===i)throw new SyntaxError("Expected attribute value");t[e]=i}return t}();if(null===e&&0===Object.keys(s).length)throw new SyntaxError("Expected message value or attributes");return{id:t,value:e,attributes:s}}function l(){let s;if(i(to)&&(s=a(to)),"{"===t[e]||"}"===t[e])return h(s?[s]:[],1/0);let n=b();return n?s?h([s,n],n.length):(n.value=v(n.value,no),h([n],n.length)):s?v(s,ro):null}function h(s=[],n){for(;;){if(i(to)){s.push(a(to));continue}if("{"===t[e]){s.push(d());continue}if("}"===t[e])throw new SyntaxError("Unbalanced closing brace");let r=b();if(!r)break;s.push(r),n=Math.min(n,r.length)}let r=s.length-1,o=s[r];"string"==typeof o&&(s[r]=v(o,ro));let l=[];for(let t of s)t instanceof wo&&(t=t.value.slice(0,t.value.length-n)),t&&l.push(t);return l}function d(){n(lo,SyntaxError);let t=c();if(n(ho))return t;if(n(go)){let e=function(){let t,e=[],n=0;for(;i(Ka);){s("*")&&(t=n);let i=p(),r=l();if(null===r)throw new SyntaxError("Expected variant value");e[n++]={key:i,value:r}}if(0===n)return null;if(void 0===t)throw new SyntaxError("Expected default variant");return{variants:e,star:t}}();return n(ho,SyntaxError),{type:"select",selector:t,...e}}throw new SyntaxError("Unclosed placeable")}function c(){if("{"===t[e])return d();if(i(Ja)){let[,i,s,a=null]=r(Ja);if("$"===i)return{type:"var",name:s};if(n(po)){let r=function(){let i=[];for(;;){switch(t[e]){case")":return e++,i;case void 0:throw new SyntaxError("Unclosed argument list")}i.push(u()),n(mo)}}();if("-"===i)return{type:"term",name:s,attr:a,args:r};if(Za.test(s))return{type:"func",name:s,args:r};throw new SyntaxError("Function names must be all upper-case")}return"-"===i?{type:"term",name:s,attr:a,args:[]}:{type:"mesg",name:s,attr:a}}return g()}function u(){let t=c();return"mesg"!==t.type?t:n(fo)?{type:"narg",name:t.name,value:g()}:t}function p(){let t;return n(co,SyntaxError),t=i(Ya)?f():{type:"str",value:a(Qa)},n(uo,SyntaxError),t}function g(){if(i(Ya))return f();if('"'===t[e])return function(){s('"',SyntaxError);let i="";for(;;){if(i+=a(eo),"\\"!==t[e]){if(s('"'))return{type:"str",value:i};throw new SyntaxError("Unclosed string literal")}i+=m()}}();throw new SyntaxError("Invalid expression")}function f(){let[,t,e=""]=r(Ya),i=e.length;return{type:"num",value:parseFloat(t),precision:i}}function m(){if(i(io))return a(io);if(i(so)){let[,t,e]=r(so),i=parseInt(t||e,16);return i<=55295||57344<=i?String.fromCodePoint(i):"�"}throw new SyntaxError("Unknown escape sequence")}function b(){let i=e;switch(n(bo),t[e]){case".":case"[":case"*":case"}":case void 0:return!1;case"{":return w(t.slice(i,e))}return" "===t[e-1]&&w(t.slice(i,e))}function v(t,e){return t.replace(e,"")}function w(t){let e=t.replace(ao,"\n"),i=oo.exec(t)[1].length;return new wo(e,i)}}}class wo{constructor(t,e){this.value=t,this.length=e}}const yo=/<|&#?\w+;/,Ao={"http://www.w3.org/1999/xhtml":["em","strong","small","s","cite","q","dfn","abbr","data","time","code","var","samp","kbd","sub","sup","i","b","u","mark","bdi","bdo","span","br","wbr"]},_o={"http://www.w3.org/1999/xhtml":{global:["title","aria-label","aria-valuetext"],a:["download"],area:["download","alt"],input:["alt","placeholder"],menuitem:["label"],menu:["label"],optgroup:["label"],option:["label"],track:["label"],img:["alt"],textarea:["placeholder"],th:["abbr"]},"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul":{global:["accesskey","aria-label","aria-valuetext","label","title","tooltiptext"],description:["value"],key:["key","keycode"],label:["value"],textbox:["placeholder","value"]}};function xo(t,e){const{value:i}=e;if("string"==typeof i)if("title"===t.localName&&"http://www.w3.org/1999/xhtml"===t.namespaceURI)t.textContent=i;else if(yo.test(i)){const e=t.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml","template");e.innerHTML=i,function(t,e){for(const i of t.childNodes)if(i.nodeType!==i.TEXT_NODE)if(i.hasAttribute("data-l10n-name")){const s=Eo(e,i);t.replaceChild(s,i)}else if(To(i)){const e=Po(i);t.replaceChild(e,i)}else console.warn(`An element of forbidden type "${i.localName}" was found in the translation. Only safe text-level elements and elements with data-l10n-name are allowed.`),t.replaceChild(Mo(i),i);e.textContent="",e.appendChild(t)}(e.content,t)}else t.textContent=i;Co(e,t)}function So(t,e){if(!t)return!1;for(let i of t)if(i.name===e)return!0;return!1}function Co(t,e){const i=e.hasAttribute("data-l10n-attrs")?e.getAttribute("data-l10n-attrs").split(",").map((t=>t.trim())):null;for(const s of Array.from(e.attributes))ko(s.name,e,i)&&!So(t.attributes,s.name)&&e.removeAttribute(s.name);if(t.attributes)for(const s of Array.from(t.attributes))ko(s.name,e,i)&&e.getAttribute(s.name)!==s.value&&e.setAttribute(s.name,s.value)}function Eo(t,e){const i=e.getAttribute("data-l10n-name"),s=t.querySelector(`[data-l10n-name="${i}"]`);if(!s)return console.warn(`An element named "${i}" wasn't found in the source.`),Mo(e);if(s.localName!==e.localName)return console.warn(`An element named "${i}" was found in the translation but its type ${e.localName} didn't match the element found in the source (${s.localName}).`),Mo(e);t.removeChild(s);return Io(e,s.cloneNode(!1))}function Po(t){const e=t.ownerDocument.createElement(t.localName);return Io(t,e)}function Mo(t){return t.ownerDocument.createTextNode(t.textContent)}function To(t){const e=Ao[t.namespaceURI];return e&&e.includes(t.localName)}function ko(t,e,i=null){if(i&&i.includes(t))return!0;const s=_o[e.namespaceURI];if(!s)return!1;const n=t.toLowerCase(),r=e.localName;if(s.global.includes(n))return!0;if(!s[r])return!1;if(s[r].includes(n))return!0;if("http://www.w3.org/1999/xhtml"===e.namespaceURI&&"input"===r&&"value"===n){const t=e.type.toLowerCase();if("submit"===t||"button"===t||"reset"===t)return!0}return!1}function Io(t,e){return e.textContent=t.textContent,Co(t,e),e}class Lo extends Array{static from(t){return t instanceof this?t:new this(t)}}class Do extends Lo{constructor(t){if(super(),Symbol.asyncIterator in Object(t))this.iterator=t[Symbol.asyncIterator]();else{if(!(Symbol.iterator in Object(t)))throw new TypeError("Argument must implement the iteration protocol.");this.iterator=t[Symbol.iterator]()}}[Symbol.asyncIterator](){const t=this;let e=0;return{next:async()=>(t.length<=e&&t.push(t.iterator.next()),t[e++])}}async touchNext(t=1){let e=0;for(;e++<t;){const t=this[this.length-1];if(t&&(await t).done)break;this.push(this.iterator.next())}return this[this.length-1]}}class Ro{constructor(t=[],e){this.resourceIds=t,this.generateBundles=e,this.onChange(!0)}addResourceIds(t,e=!1){return this.resourceIds.push(...t),this.onChange(e),this.resourceIds.length}removeResourceIds(t){return this.resourceIds=this.resourceIds.filter((e=>!t.includes(e))),this.onChange(),this.resourceIds.length}async formatWithFallback(t,e){const i=[];let s=!1;for await(const n of this.bundles){s=!0;const r=Oo(e,n,t,i);if(0===r.size)break;if("undefined"!=typeof console){const t=n.locales[0],e=Array.from(r).join(", ");console.warn(`[fluent] Missing translations in ${t}: ${e}`)}}return s||"undefined"==typeof console||console.warn(`[fluent] Request for keys failed because no resource bundles got generated.\n keys: ${JSON.stringify(t)}.\n resourceIds: ${JSON.stringify(this.resourceIds)}.`),i}formatMessages(t){return this.formatWithFallback(t,Fo)}formatValues(t){return this.formatWithFallback(t,No)}async formatValue(t,e){const[i]=await this.formatValues([{id:t,args:e}]);return i}handleEvent(){this.onChange()}onChange(t=!1){this.bundles=Do.from(this.generateBundles(this.resourceIds)),t&&this.bundles.touchNext(2)}}function No(t,e,i,s){return i.value?t.formatPattern(i.value,s,e):null}function Fo(t,e,i,s){const n={value:null,attributes:null};i.value&&(n.value=t.formatPattern(i.value,s,e));let r=Object.keys(i.attributes);if(r.length>0){n.attributes=new Array(r.length);for(let[a,o]of r.entries()){let r=t.formatPattern(i.attributes[o],s,e);n.attributes[a]={name:o,value:r}}}return n}function Oo(t,e,i,s){const n=[],r=new Set;return i.forEach((({id:i,args:a},o)=>{if(void 0!==s[o])return;let l=e.getMessage(i);if(l){if(n.length=0,s[o]=t(e,n,l,a),n.length>0&&"undefined"!=typeof console){const t=e.locales[0],s=n.join(", ");console.warn(`[fluent][resolver] errors in ${t}/${i}: ${s}.`)}}else r.add(i)})),r}const Bo="data-l10n-id",jo="data-l10n-args",Vo=`[${Bo}]`;class Ho extends Ro{constructor(t,e){super(t,e),this.roots=new Set,this.pendingrAF=null,this.pendingElements=new Set,this.windowElement=null,this.mutationObserver=null,this.observerConfig={attributes:!0,characterData:!1,childList:!0,subtree:!0,attributeFilter:[Bo,jo]}}onChange(t=!1){super.onChange(t),this.roots&&this.translateRoots()}setAttributes(t,e,i){return t.setAttribute(Bo,e),i?t.setAttribute(jo,JSON.stringify(i)):t.removeAttribute(jo),t}getAttributes(t){return{id:t.getAttribute(Bo),args:JSON.parse(t.getAttribute(jo)||null)}}connectRoot(t){for(const e of this.roots)if(e===t||e.contains(t)||t.contains(e))throw new Error("Cannot add a root that overlaps with existing root.");if(this.windowElement){if(this.windowElement!==t.ownerDocument.defaultView)throw new Error("Cannot connect a root:\n DOMLocalization already has a root from a different window.")}else this.windowElement=t.ownerDocument.defaultView,this.mutationObserver=new this.windowElement.MutationObserver((t=>this.translateMutations(t)));this.roots.add(t),this.mutationObserver.observe(t,this.observerConfig)}disconnectRoot(t){return this.roots.delete(t),this.pauseObserving(),0===this.roots.size?(this.mutationObserver=null,this.windowElement&&this.pendingrAF&&this.windowElement.cancelAnimationFrame(this.pendingrAF),this.windowElement=null,this.pendingrAF=null,this.pendingElements.clear(),!0):(this.resumeObserving(),!1)}translateRoots(){const t=Array.from(this.roots);return Promise.all(t.map((t=>this.translateFragment(t))))}pauseObserving(){this.mutationObserver&&(this.translateMutations(this.mutationObserver.takeRecords()),this.mutationObserver.disconnect())}resumeObserving(){if(this.mutationObserver)for(const t of this.roots)this.mutationObserver.observe(t,this.observerConfig)}translateMutations(t){for(const e of t)switch(e.type){case"attributes":e.target.hasAttribute("data-l10n-id")&&this.pendingElements.add(e.target);break;case"childList":for(const t of e.addedNodes)if(t.nodeType===t.ELEMENT_NODE)if(t.childElementCount)for(const e of this.getTranslatables(t))this.pendingElements.add(e);else t.hasAttribute(Bo)&&this.pendingElements.add(t)}this.pendingElements.size>0&&null===this.pendingrAF&&(this.pendingrAF=this.windowElement.requestAnimationFrame((()=>{this.translateElements(Array.from(this.pendingElements)),this.pendingElements.clear(),this.pendingrAF=null})))}translateFragment(t){return this.translateElements(this.getTranslatables(t))}async translateElements(t){if(!t.length)return;const e=t.map(this.getKeysForElement),i=await this.formatMessages(e);return this.applyTranslations(t,i)}applyTranslations(t,e){this.pauseObserving();for(let i=0;i<t.length;i++)void 0!==e[i]&&xo(t[i],e[i]);this.resumeObserving()}getTranslatables(t){const e=Array.from(t.querySelectorAll(Vo));return"function"==typeof t.hasAttribute&&t.hasAttribute(Bo)&&e.push(t),e}getKeysForElement(t){return{id:t.getAttribute(Bo),args:JSON.parse(t.getAttribute(jo)||null)}}}class zo{#sl;#sn;#Mi;#nl;constructor({lang:t,isRTL:e},i=null){this.#Mi=zo.#rl(t),this.#nl=i,this.#sl=e??zo.#al(this.#Mi)?"rtl":"ltr"}_setL10n(t){this.#nl=t}getLanguage(){return this.#Mi}getDirection(){return this.#sl}async get(t,e=null,i){if(Array.isArray(t)){t=t.map((t=>({id:t})));return(await this.#nl.formatMessages(t)).map((t=>t.value))}const s=await this.#nl.formatMessages([{id:t,args:e}]);return s[0]?.value||i}async translate(t){(this.#sn||=new Set).add(t);try{this.#nl.connectRoot(t),await this.#nl.translateRoots()}catch{}}async translateOnce(t){try{await this.#nl.translateElements([t])}catch(t){console.error("translateOnce:",t)}}async destroy(){if(this.#sn){for(const t of this.#sn)this.#nl.disconnectRoot(t);this.#sn.clear(),this.#sn=null}this.#nl.pauseObserving()}pause(){this.#nl.pauseObserving()}resume(){this.#nl.resumeObserving()}static#rl(t){return{en:"en-us",es:"es-es",fy:"fy-nl",ga:"ga-ie",gu:"gu-in",hi:"hi-in",hy:"hy-am",nb:"nb-no",ne:"ne-np",nn:"nn-no",pa:"pa-in",pt:"pt-pt",sv:"sv-se",zh:"zh-cn"}[t=t?.toLowerCase()||"en-us"]||t}static#al(t){const e=t.split("-",1)[0];return["ar","he","fa","ps","ur"].includes(e)}}function Uo(t,e){const i=new vo(e),s=new Ga(t),n=s.addResource(i);return n.length&&console.error("L10n errors",n),s}class $o extends zo{constructor(t){super({lang:t});const e=t?$o.#ol.bind($o,"en-us",this.getLanguage()):$o.#ll.bind($o,this.getLanguage());this._setL10n(new Ho([],e))}static async*#ol(t,e){const{baseURL:i,paths:s}=await this.#hl(),n=[e];if(t!==e){const i=e.split("-",1)[0];i!==e&&n.push(i),n.push(t)}for(const t of n){const e=await this.#dl(t,i,s);e?yield e:"en-us"===t&&(yield this.#cl(t))}}static async#dl(t,e,i){const s=i[t];if(!s)return null;const n=new URL(s,e);return Uo(t,await Wr(n,"text"))}static async#hl(){try{const{href:t}=document.querySelector('link[type="application/l10n"]'),e=await Wr(t,"json");return{baseURL:t.replace(/[^/]*$/,"")||"./",paths:e}}catch{}return{baseURL:"./",paths:Object.create(null)}}static async*#ll(t){yield this.#cl(t)}static async#cl(t){return Uo(t,'pdfjs-previous-button =\n .title = Previous Page\npdfjs-previous-button-label = Previous\npdfjs-next-button =\n .title = Next Page\npdfjs-next-button-label = Next\npdfjs-page-input =\n .title = Page\npdfjs-of-pages = of { $pagesCount }\npdfjs-page-of-pages = ({ $pageNumber } of { $pagesCount })\npdfjs-zoom-out-button =\n .title = Zoom Out\npdfjs-zoom-out-button-label = Zoom Out\npdfjs-zoom-in-button =\n .title = Zoom In\npdfjs-zoom-in-button-label = Zoom In\npdfjs-zoom-select =\n .title = Zoom\npdfjs-presentation-mode-button =\n .title = Switch to Presentation Mode\npdfjs-presentation-mode-button-label = Presentation Mode\npdfjs-open-file-button =\n .title = Open File\npdfjs-open-file-button-label = Open\npdfjs-print-button =\n .title = Print\npdfjs-print-button-label = Print\npdfjs-save-button =\n .title = Save\npdfjs-save-button-label = Save\npdfjs-download-button =\n .title = Download\npdfjs-download-button-label = Download\npdfjs-bookmark-button =\n .title = Current Page (View URL from Current Page)\npdfjs-bookmark-button-label = Current Page\npdfjs-tools-button =\n .title = Tools\npdfjs-tools-button-label = Tools\npdfjs-first-page-button =\n .title = Go to First Page\npdfjs-first-page-button-label = Go to First Page\npdfjs-last-page-button =\n .title = Go to Last Page\npdfjs-last-page-button-label = Go to Last Page\npdfjs-page-rotate-cw-button =\n .title = Rotate Clockwise\npdfjs-page-rotate-cw-button-label = Rotate Clockwise\npdfjs-page-rotate-ccw-button =\n .title = Rotate Counterclockwise\npdfjs-page-rotate-ccw-button-label = Rotate Counterclockwise\npdfjs-cursor-text-select-tool-button =\n .title = Enable Text Selection Tool\npdfjs-cursor-text-select-tool-button-label = Text Selection Tool\npdfjs-cursor-hand-tool-button =\n .title = Enable Hand Tool\npdfjs-cursor-hand-tool-button-label = Hand Tool\npdfjs-scroll-page-button =\n .title = Use Page Scrolling\npdfjs-scroll-page-button-label = Page Scrolling\npdfjs-scroll-vertical-button =\n .title = Use Vertical Scrolling\npdfjs-scroll-vertical-button-label = Vertical Scrolling\npdfjs-scroll-horizontal-button =\n .title = Use Horizontal Scrolling\npdfjs-scroll-horizontal-button-label = Horizontal Scrolling\npdfjs-scroll-wrapped-button =\n .title = Use Wrapped Scrolling\npdfjs-scroll-wrapped-button-label = Wrapped Scrolling\npdfjs-spread-none-button =\n .title = Do not join page spreads\npdfjs-spread-none-button-label = No Spreads\npdfjs-spread-odd-button =\n .title = Join page spreads starting with odd-numbered pages\npdfjs-spread-odd-button-label = Odd Spreads\npdfjs-spread-even-button =\n .title = Join page spreads starting with even-numbered pages\npdfjs-spread-even-button-label = Even Spreads\npdfjs-document-properties-button =\n .title = Document Properties…\npdfjs-document-properties-button-label = Document Properties…\npdfjs-document-properties-file-name = File name:\npdfjs-document-properties-file-size = File size:\npdfjs-document-properties-size-kb = { NUMBER($kb, maximumSignificantDigits: 3) } KB ({ $b } bytes)\npdfjs-document-properties-size-mb = { NUMBER($mb, maximumSignificantDigits: 3) } MB ({ $b } bytes)\npdfjs-document-properties-title = Title:\npdfjs-document-properties-author = Author:\npdfjs-document-properties-subject = Subject:\npdfjs-document-properties-keywords = Keywords:\npdfjs-document-properties-creation-date = Creation Date:\npdfjs-document-properties-modification-date = Modification Date:\npdfjs-document-properties-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\npdfjs-document-properties-creator = Creator:\npdfjs-document-properties-producer = PDF Producer:\npdfjs-document-properties-version = PDF Version:\npdfjs-document-properties-page-count = Page Count:\npdfjs-document-properties-page-size = Page Size:\npdfjs-document-properties-page-size-unit-inches = in\npdfjs-document-properties-page-size-unit-millimeters = mm\npdfjs-document-properties-page-size-orientation-portrait = portrait\npdfjs-document-properties-page-size-orientation-landscape = landscape\npdfjs-document-properties-page-size-name-a-three = A3\npdfjs-document-properties-page-size-name-a-four = A4\npdfjs-document-properties-page-size-name-letter = Letter\npdfjs-document-properties-page-size-name-legal = Legal\npdfjs-document-properties-page-size-dimension-string = { $width } × { $height } { $unit } ({ $orientation })\npdfjs-document-properties-page-size-dimension-name-string = { $width } × { $height } { $unit } ({ $name }, { $orientation })\npdfjs-document-properties-linearized = Fast Web View:\npdfjs-document-properties-linearized-yes = Yes\npdfjs-document-properties-linearized-no = No\npdfjs-document-properties-close-button = Close\npdfjs-print-progress-message = Preparing document for printing…\npdfjs-print-progress-percent = { $progress }%\npdfjs-print-progress-close-button = Cancel\npdfjs-printing-not-supported = Warning: Printing is not fully supported by this browser.\npdfjs-printing-not-ready = Warning: The PDF is not fully loaded for printing.\npdfjs-toggle-sidebar-button =\n .title = Toggle Sidebar\npdfjs-toggle-sidebar-notification-button =\n .title = Toggle Sidebar (document contains outline/attachments/layers)\npdfjs-toggle-sidebar-button-label = Toggle Sidebar\npdfjs-document-outline-button =\n .title = Show Document Outline (double-click to expand/collapse all items)\npdfjs-document-outline-button-label = Document Outline\npdfjs-attachments-button =\n .title = Show Attachments\npdfjs-attachments-button-label = Attachments\npdfjs-layers-button =\n .title = Show Layers (double-click to reset all layers to the default state)\npdfjs-layers-button-label = Layers\npdfjs-thumbs-button =\n .title = Show Thumbnails\npdfjs-thumbs-button-label = Thumbnails\npdfjs-current-outline-item-button =\n .title = Find Current Outline Item\npdfjs-current-outline-item-button-label = Current Outline Item\npdfjs-findbar-button =\n .title = Find in Document\npdfjs-findbar-button-label = Find\npdfjs-additional-layers = Additional Layers\npdfjs-thumb-page-title =\n .title = Page { $page }\npdfjs-thumb-page-canvas =\n .aria-label = Thumbnail of Page { $page }\npdfjs-find-input =\n .title = Find\n .placeholder = Find in document…\npdfjs-find-previous-button =\n .title = Find the previous occurrence of the phrase\npdfjs-find-previous-button-label = Previous\npdfjs-find-next-button =\n .title = Find the next occurrence of the phrase\npdfjs-find-next-button-label = Next\npdfjs-find-highlight-checkbox = Highlight All\npdfjs-find-match-case-checkbox-label = Match Case\npdfjs-find-match-diacritics-checkbox-label = Match Diacritics\npdfjs-find-entire-word-checkbox-label = Whole Words\npdfjs-find-reached-top = Reached top of document, continued from bottom\npdfjs-find-reached-bottom = Reached end of document, continued from top\npdfjs-find-match-count =\n { $total ->\n [one] { $current } of { $total } match\n *[other] { $current } of { $total } matches\n }\npdfjs-find-match-count-limit =\n { $limit ->\n [one] More than { $limit } match\n *[other] More than { $limit } matches\n }\npdfjs-find-not-found = Phrase not found\npdfjs-page-scale-width = Page Width\npdfjs-page-scale-fit = Page Fit\npdfjs-page-scale-auto = Automatic Zoom\npdfjs-page-scale-actual = Actual Size\npdfjs-page-scale-percent = { $scale }%\npdfjs-page-landmark =\n .aria-label = Page { $page }\npdfjs-loading-error = An error occurred while loading the PDF.\npdfjs-invalid-file-error = Invalid or corrupted PDF file.\npdfjs-missing-file-error = Missing PDF file.\npdfjs-unexpected-response-error = Unexpected server response.\npdfjs-rendering-error = An error occurred while rendering the page.\npdfjs-annotation-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\npdfjs-text-annotation-type =\n .alt = [{ $type } Annotation]\npdfjs-password-label = Enter the password to open this PDF file.\npdfjs-password-invalid = Invalid password. Please try again.\npdfjs-password-ok-button = OK\npdfjs-password-cancel-button = Cancel\npdfjs-web-fonts-disabled = Web fonts are disabled: unable to use embedded PDF fonts.\npdfjs-editor-free-text-button =\n .title = Text\npdfjs-editor-free-text-button-label = Text\npdfjs-editor-ink-button =\n .title = Draw\npdfjs-editor-ink-button-label = Draw\npdfjs-editor-stamp-button =\n .title = Add or edit images\npdfjs-editor-stamp-button-label = Add or edit images\npdfjs-editor-highlight-button =\n .title = Highlight\npdfjs-editor-highlight-button-label = Highlight\npdfjs-highlight-floating-button1 =\n .title = Highlight\n .aria-label = Highlight\npdfjs-highlight-floating-button-label = Highlight\npdfjs-editor-remove-ink-button =\n .title = Remove drawing\npdfjs-editor-remove-freetext-button =\n .title = Remove text\npdfjs-editor-remove-stamp-button =\n .title = Remove image\npdfjs-editor-remove-highlight-button =\n .title = Remove highlight\npdfjs-editor-free-text-color-input = Color\npdfjs-editor-free-text-size-input = Size\npdfjs-editor-ink-color-input = Color\npdfjs-editor-ink-thickness-input = Thickness\npdfjs-editor-ink-opacity-input = Opacity\npdfjs-editor-stamp-add-image-button =\n .title = Add image\npdfjs-editor-stamp-add-image-button-label = Add image\npdfjs-editor-free-highlight-thickness-input = Thickness\npdfjs-editor-free-highlight-thickness-title =\n .title = Change thickness when highlighting items other than text\npdfjs-free-text2 =\n .aria-label = Text Editor\n .default-content = Start typing…\npdfjs-ink =\n .aria-label = Draw Editor\npdfjs-ink-canvas =\n .aria-label = User-created image\npdfjs-editor-alt-text-button =\n .aria-label = Alt text\npdfjs-editor-alt-text-button-label = Alt text\npdfjs-editor-alt-text-edit-button =\n .aria-label = Edit alt text\npdfjs-editor-alt-text-dialog-label = Choose an option\npdfjs-editor-alt-text-dialog-description = Alt text (alternative text) helps when people can’t see the image or when it doesn’t load.\npdfjs-editor-alt-text-add-description-label = Add a description\npdfjs-editor-alt-text-add-description-description = Aim for 1-2 sentences that describe the subject, setting, or actions.\npdfjs-editor-alt-text-mark-decorative-label = Mark as decorative\npdfjs-editor-alt-text-mark-decorative-description = This is used for ornamental images, like borders or watermarks.\npdfjs-editor-alt-text-cancel-button = Cancel\npdfjs-editor-alt-text-save-button = Save\npdfjs-editor-alt-text-decorative-tooltip = Marked as decorative\npdfjs-editor-alt-text-textarea =\n .placeholder = For example, “A young man sits down at a table to eat a meal”\npdfjs-editor-resizer-top-left =\n .aria-label = Top left corner — resize\npdfjs-editor-resizer-top-middle =\n .aria-label = Top middle — resize\npdfjs-editor-resizer-top-right =\n .aria-label = Top right corner — resize\npdfjs-editor-resizer-middle-right =\n .aria-label = Middle right — resize\npdfjs-editor-resizer-bottom-right =\n .aria-label = Bottom right corner — resize\npdfjs-editor-resizer-bottom-middle =\n .aria-label = Bottom middle — resize\npdfjs-editor-resizer-bottom-left =\n .aria-label = Bottom left corner — resize\npdfjs-editor-resizer-middle-left =\n .aria-label = Middle left — resize\npdfjs-editor-highlight-colorpicker-label = Highlight color\npdfjs-editor-colorpicker-button =\n .title = Change color\npdfjs-editor-colorpicker-dropdown =\n .aria-label = Color choices\npdfjs-editor-colorpicker-yellow =\n .title = Yellow\npdfjs-editor-colorpicker-green =\n .title = Green\npdfjs-editor-colorpicker-blue =\n .title = Blue\npdfjs-editor-colorpicker-pink =\n .title = Pink\npdfjs-editor-colorpicker-red =\n .title = Red\npdfjs-editor-highlight-show-all-button-label = Show all\npdfjs-editor-highlight-show-all-button =\n .title = Show all\npdfjs-editor-new-alt-text-dialog-edit-label = Edit alt text (image description)\npdfjs-editor-new-alt-text-dialog-add-label = Add alt text (image description)\npdfjs-editor-new-alt-text-textarea =\n .placeholder = Write your description here…\npdfjs-editor-new-alt-text-description = Short description for people who can’t see the image or when the image doesn’t load.\npdfjs-editor-new-alt-text-disclaimer1 = This alt text was created automatically and may be inaccurate.\npdfjs-editor-new-alt-text-disclaimer-learn-more-url = Learn more\npdfjs-editor-new-alt-text-create-automatically-button-label = Create alt text automatically\npdfjs-editor-new-alt-text-not-now-button = Not now\npdfjs-editor-new-alt-text-error-title = Couldn’t create alt text automatically\npdfjs-editor-new-alt-text-error-description = Please write your own alt text or try again later.\npdfjs-editor-new-alt-text-error-close-button = Close\npdfjs-editor-new-alt-text-ai-model-downloading-progress = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\n .aria-valuetext = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\npdfjs-editor-new-alt-text-added-button =\n .aria-label = Alt text added\npdfjs-editor-new-alt-text-added-button-label = Alt text added\npdfjs-editor-new-alt-text-missing-button =\n .aria-label = Missing alt text\npdfjs-editor-new-alt-text-missing-button-label = Missing alt text\npdfjs-editor-new-alt-text-to-review-button =\n .aria-label = Review alt text\npdfjs-editor-new-alt-text-to-review-button-label = Review alt text\npdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer = Created automatically: { $generatedAltText }\npdfjs-image-alt-text-settings-button =\n .title = Image alt text settings\npdfjs-image-alt-text-settings-button-label = Image alt text settings\npdfjs-editor-alt-text-settings-dialog-label = Image alt text settings\npdfjs-editor-alt-text-settings-automatic-title = Automatic alt text\npdfjs-editor-alt-text-settings-create-model-button-label = Create alt text automatically\npdfjs-editor-alt-text-settings-create-model-description = Suggests descriptions to help people who can’t see the image or when the image doesn’t load.\npdfjs-editor-alt-text-settings-download-model-label = Alt text AI model ({ $totalSize } MB)\npdfjs-editor-alt-text-settings-ai-model-description = Runs locally on your device so your data stays private. Required for automatic alt text.\npdfjs-editor-alt-text-settings-delete-model-button = Delete\npdfjs-editor-alt-text-settings-download-model-button = Download\npdfjs-editor-alt-text-settings-downloading-model-button = Downloading…\npdfjs-editor-alt-text-settings-editor-title = Alt text editor\npdfjs-editor-alt-text-settings-show-dialog-button-label = Show alt text editor right away when adding an image\npdfjs-editor-alt-text-settings-show-dialog-description = Helps you make sure all your images have alt text.\npdfjs-editor-alt-text-settings-close-button = Close\npdfjs-editor-undo-bar-message-highlight = Highlight removed\npdfjs-editor-undo-bar-message-freetext = Text removed\npdfjs-editor-undo-bar-message-ink = Drawing removed\npdfjs-editor-undo-bar-message-stamp = Image removed\npdfjs-editor-undo-bar-message-multiple =\n { $count ->\n [one] { $count } annotation removed\n *[other] { $count } annotations removed\n }\npdfjs-editor-undo-bar-undo-button =\n .title = Undo\npdfjs-editor-undo-bar-undo-button-label = Undo\npdfjs-editor-undo-bar-close-button =\n .title = Close\npdfjs-editor-undo-bar-close-button-label = Close')}}function Wo(){return document.location.hash}class Go{#tl=null;constructor({linkService:t,eventBus:e}){this.linkService=t,this.eventBus=e,this._initialized=!1,this._fingerprint="",this.reset(),this.eventBus._on("pagesinit",(()=>{this._isPagesLoaded=!1,this.eventBus._on("pagesloaded",(t=>{this._isPagesLoaded=!!t.pagesCount}),{once:!0})}))}initialize({fingerprint:t,resetHistory:e=!1,updateUrl:i=!1}){if(!t||"string"!=typeof t)return void console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');this._initialized&&this.reset();const s=""!==this._fingerprint&&this._fingerprint!==t;this._fingerprint=t,this._updateUrl=!0===i,this._initialized=!0,this.#ul();const n=window.history.state;if(this._popStateInProgress=!1,this._blockHashChange=0,this._currentHash=Wo(),this._numPositionUpdates=0,this._uid=this._maxUid=0,this._destination=null,this._position=null,!this.#pl(n,!0)||e){const{hash:t,page:i,rotation:n}=this.#gl(!0);return!t||s||e?void this.#fl(null,!0):void this.#fl({hash:t,page:i,rotation:n},!0)}const r=n.destination;this.#ml(r,n.uid,!0),void 0!==r.rotation&&(this._initialRotation=r.rotation),r.dest?(this._initialBookmark=JSON.stringify(r.dest),this._destination.page=null):r.hash?this._initialBookmark=r.hash:r.page&&(this._initialBookmark=`page=${r.page}`)}reset(){this._initialized&&(this.#bl(),this._initialized=!1,this.#vl()),this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._initialBookmark=null,this._initialRotation=null}push({namedDest:t=null,explicitDest:e,pageNumber:i}){if(!this._initialized)return;if(t&&"string"!=typeof t)return void console.error(`PDFHistory.push: "${t}" is not a valid namedDest parameter.`);if(!Array.isArray(e))return void console.error(`PDFHistory.push: "${e}" is not a valid explicitDest parameter.`);if(!this.#wl(i)&&(null!==i||this._destination))return void console.error(`PDFHistory.push: "${i}" is not a valid pageNumber parameter.`);const s=t||JSON.stringify(e);if(!s)return;let n=!1;if(this._destination&&(function(t,e){if("string"!=typeof t||"string"!=typeof e)return!1;if(t===e)return!0;if(qn(t).get("nameddest")===e)return!0;return!1}(this._destination.hash,s)||function(t,e){function i(t,e){if(typeof t!=typeof e)return!1;if(Array.isArray(t)||Array.isArray(e))return!1;if(null!==t&&"object"==typeof t&&null!==e){if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const s in t)if(!i(t[s],e[s]))return!1;return!0}return t===e||Number.isNaN(t)&&Number.isNaN(e)}if(!Array.isArray(t)||!Array.isArray(e))return!1;if(t.length!==e.length)return!1;for(let s=0,n=t.length;s<n;s++)if(!i(t[s],e[s]))return!1;return!0}(this._destination.dest,e))){if(this._destination.page)return;n=!0}this._popStateInProgress&&!n||(this.#fl({dest:e,hash:s,page:i,rotation:this.linkService.rotation},n),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then((()=>{this._popStateInProgress=!1}))))}pushPage(t){this._initialized&&(this.#wl(t)?this._destination?.page!==t&&(this._popStateInProgress||(this.#fl({dest:null,hash:`page=${t}`,page:t,rotation:this.linkService.rotation}),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then((()=>{this._popStateInProgress=!1}))))):console.error(`PDFHistory.pushPage: "${t}" is not a valid page number.`))}pushCurrentPosition(){this._initialized&&!this._popStateInProgress&&this.#yl()}back(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#pl(t)&&t.uid>0&&window.history.back()}forward(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#pl(t)&&t.uid<this._maxUid&&window.history.forward()}get popStateInProgress(){return this._initialized&&(this._popStateInProgress||this._blockHashChange>0)}get initialBookmark(){return this._initialized?this._initialBookmark:null}get initialRotation(){return this._initialized?this._initialRotation:null}#fl(t,e=!1){const i=e||!this._destination,s={fingerprint:this._fingerprint,uid:i?this._uid:this._uid+1,destination:t};let n;if(this.#ml(t,s.uid),this._updateUrl&&t?.hash){const e=document.location.href.split("#",1)[0];e.startsWith("file://")||(n=`${e}#${t.hash}`)}i?window.history.replaceState(s,"",n):window.history.pushState(s,"",n)}#yl(t=!1){if(!this._position)return;let e=this._position;if(t&&(e=Object.assign(Object.create(null),this._position),e.temporary=!0),!this._destination)return void this.#fl(e);if(this._destination.temporary)return void this.#fl(e,!0);if(this._destination.hash===e.hash)return;if(!this._destination.page&&this._numPositionUpdates<=50)return;let i=!1;if(this._destination.page>=e.first&&this._destination.page<=e.page){if(void 0!==this._destination.dest||!this._destination.first)return;i=!0}this.#fl(e,i)}#wl(t){return Number.isInteger(t)&&t>0&&t<=this.linkService.pagesCount}#pl(t,e=!1){if(!t)return!1;if(t.fingerprint!==this._fingerprint){if(!e)return!1;{if("string"!=typeof t.fingerprint||t.fingerprint.length!==this._fingerprint.length)return!1;const[e]=performance.getEntriesByType("navigation");if("reload"!==e?.type)return!1}}return!(!Number.isInteger(t.uid)||t.uid<0)&&(null!==t.destination&&"object"==typeof t.destination)}#ml(t,e,i=!1){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),i&&t?.temporary&&delete t.temporary,this._destination=t,this._uid=e,this._maxUid=Math.max(this._maxUid,e),this._numPositionUpdates=0}#gl(t=!1){const e=unescape(Wo()).substring(1),i=qn(e),s=i.get("nameddest")||"";let n=0|i.get("page");return(!this.#wl(n)||t&&s.length>0)&&(n=null),{hash:e,page:n,rotation:this.linkService.rotation}}#Al({location:t}){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._position={hash:t.pdfOpenParams.substring(1),page:this.linkService.page,first:t.pageNumber,rotation:t.rotation},this._popStateInProgress||(this._isPagesLoaded&&this._destination&&!this._destination.page&&this._numPositionUpdates++,this._updateViewareaTimeout=setTimeout((()=>{this._popStateInProgress||this.#yl(!0),this._updateViewareaTimeout=null}),1e3))}#_l({state:t}){const e=Wo(),i=this._currentHash!==e;if(this._currentHash=e,!t){this._uid++;const{hash:t,page:e,rotation:i}=this.#gl();return void this.#fl({hash:t,page:e,rotation:i},!0)}if(!this.#pl(t))return;this._popStateInProgress=!0,i&&(this._blockHashChange++,async function({target:t,name:e,delay:i=0}){if("object"!=typeof t||!(Number.isInteger(i)&&i>=0))throw new Error("waitOnEventOrTimeout - invalid parameters.");const{promise:s,resolve:n}=Promise.withResolvers(),r=new AbortController;function a(t){r.abort(),clearTimeout(o),n(t)}t[t instanceof Ma?"_on":"addEventListener"](e,a.bind(null,Ea),{signal:r.signal});const o=setTimeout(a.bind(null,Pa),i);return s}({target:window,name:"hashchange",delay:1e3}).then((()=>{this._blockHashChange--})));const s=t.destination;this.#ml(s,t.uid,!0),Zn(s.rotation)&&(this.linkService.rotation=s.rotation),s.dest?this.linkService.goToDestination(s.dest):s.hash?this.linkService.setHash(s.hash):s.page&&(this.linkService.page=s.page),Promise.resolve().then((()=>{this._popStateInProgress=!1}))}#bl(){this._destination&&!this._destination.temporary||this.#yl()}#ul(){if(this.#tl)return;this.#tl=new AbortController;const{signal:t}=this.#tl;this.eventBus._on("updateviewarea",this.#Al.bind(this),{signal:t}),window.addEventListener("popstate",this.#_l.bind(this),{signal:t}),window.addEventListener("pagehide",this.#bl.bind(this),{signal:t})}#vl(){this.#tl?.abort(),this.#tl=null}}class qo{#ro=null;#xl=null;#Zo=null;#Tn=null;#go=null;#f;constructor(t){this.pdfPage=t.pdfPage,this.accessibilityManager=t.accessibilityManager,this.l10n=t.l10n,this.l10n||=new $o,this.annotationEditorLayer=null,this.div=null,this._cancelled=!1,this.#f=t.uiManager,this.#ro=t.annotationLayer||null,this.#go=t.textLayer||null,this.#xl=t.drawLayer||null,this.#Zo=t.onAppend||null,this.#Tn=t.structTreeLayer||null}async render(t,e="display"){if("display"!==e)return;if(this._cancelled)return;const i=t.clone({dontFlip:!0});if(this.div)return this.annotationEditorLayer.update({viewport:i}),void this.show();const s=this.div=document.createElement("div");s.className="annotationEditorLayer",s.hidden=!0,s.dir=this.#f.direction,this.#Zo?.(s),this.annotationEditorLayer=new Dr({uiManager:this.#f,div:s,structTreeLayer:this.#Tn,accessibilityManager:this.accessibilityManager,pageIndex:this.pdfPage.pageNumber-1,l10n:this.l10n,viewport:i,annotationLayer:this.#ro,textLayer:this.#go,drawLayer:this.#xl});const n={viewport:i,div:s,annotations:null,intent:e};this.annotationEditorLayer.render(n),this.show()}cancel(){this._cancelled=!0,this.div&&this.annotationEditorLayer.destroy()}hide(){this.div&&(this.annotationEditorLayer.pause(!0),this.div.hidden=!0)}show(){this.div&&!this.annotationEditorLayer.isInvisible&&(this.div.hidden=!1,this.annotationEditorLayer.pause(!1))}}{var Xo=new Map;const t=navigator.userAgent||"",e=navigator.platform||"",i=navigator.maxTouchPoints||1,s=/Android/.test(t);(/\b(iPad|iPhone|iPod)(?=;)/.test(t)||"MacIntel"===e&&i>1||s)&&Xo.set("maxCanvasPixels",5242880),s&&Xo.set("useSystemFonts",!1)}const Ko=1,Yo=2,Qo=4,Jo=8,Zo=16,tl=128,el={BOOLEAN:1,NUMBER:2,OBJECT:4,STRING:8,UNDEFINED:16},il={allowedGlobalEvents:{value:null,kind:Ko},canvasMaxAreaInBytes:{value:-1,kind:Ko+Qo},isInAutomation:{value:!1,kind:Ko},localeProperties:{value:{lang:navigator.language||"en-US"},kind:Ko},nimbusDataStr:{value:"",kind:Ko},supportsCaretBrowsingMode:{value:!1,kind:Ko},supportsDocumentFonts:{value:!0,kind:Ko},supportsIntegratedFind:{value:!1,kind:Ko},supportsMouseWheelZoomCtrlKey:{value:!0,kind:Ko},supportsMouseWheelZoomMetaKey:{value:!0,kind:Ko},supportsPinchToZoom:{value:!0,kind:Ko},toolbarDensity:{value:0,kind:Ko+Zo},altTextLearnMoreUrl:{value:"",kind:Yo+tl},annotationEditorMode:{value:0,kind:Yo+tl},annotationMode:{value:2,kind:Yo+tl},cursorToolOnLoad:{value:0,kind:Yo+tl},debuggerSrc:{value:"./debugger.mjs",kind:Yo},defaultZoomDelay:{value:400,kind:Yo+tl},defaultZoomValue:{value:"",kind:Yo+tl},disableHistory:{value:!1,kind:Yo},disablePageLabels:{value:!1,kind:Yo+tl},enableAltText:{value:!1,kind:Yo+tl},enableAltTextModelDownload:{value:!0,kind:Yo+tl+Zo},enableGuessAltText:{value:!0,kind:Yo+tl+Zo},enableHighlightFloatingButton:{value:!1,kind:Yo+tl},enableNewAltTextWhenAddingImage:{value:!0,kind:Yo+tl},enablePermissions:{value:!1,kind:Yo+tl},enablePrintAutoRotate:{value:!0,kind:Yo+tl},enableScripting:{value:!0,kind:Yo+tl},enableUpdatedAddImage:{value:!1,kind:Yo+tl},externalLinkRel:{value:"noopener noreferrer nofollow",kind:Yo},externalLinkTarget:{value:0,kind:Yo+tl},highlightEditorColors:{value:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",kind:Yo+tl},historyUpdateUrl:{value:!1,kind:Yo+tl},ignoreDestinationZoom:{value:!1,kind:Yo+tl},imageResourcesPath:{value:"./images/",kind:Yo},maxCanvasPixels:{value:2**25,kind:Yo},forcePageColors:{value:!1,kind:Yo+tl},pageColorsBackground:{value:"Canvas",kind:Yo+tl},pageColorsForeground:{value:"CanvasText",kind:Yo+tl},pdfBugEnabled:{value:!1,kind:Yo+tl},printResolution:{value:150,kind:Yo},sidebarViewOnLoad:{value:-1,kind:Yo+tl},scrollModeOnLoad:{value:-1,kind:Yo+tl},spreadModeOnLoad:{value:-1,kind:Yo+tl},textLayerMode:{value:1,kind:Yo+tl},viewOnLoad:{value:0,kind:Yo+tl},cMapPacked:{value:!0,kind:Qo},cMapUrl:{value:"../web/cmaps/",kind:Qo},disableAutoFetch:{value:!1,kind:Qo+tl},disableFontFace:{value:!1,kind:Qo+tl},disableRange:{value:!1,kind:Qo+tl},disableStream:{value:!1,kind:Qo+tl},docBaseUrl:{value:"",kind:Qo},enableHWA:{value:!0,kind:Qo+Yo+tl},enableXfa:{value:!0,kind:Qo+tl},fontExtraProperties:{value:!1,kind:Qo},isEvalSupported:{value:!0,kind:Qo},isOffscreenCanvasSupported:{value:!0,kind:Qo},maxImageSize:{value:-1,kind:Qo},pdfBug:{value:!1,kind:Qo},standardFontDataUrl:{value:"../web/standard_fonts/",kind:Qo},useSystemFonts:{value:void 0,kind:Qo,type:el.BOOLEAN+el.UNDEFINED},verbosity:{value:1,kind:Qo},workerPort:{value:null,kind:Jo},workerSrc:{value:"../build/pdf.worker.mjs",kind:Jo}};il.defaultUrl={value:"compressed.tracemonkey-pldi-09.pdf",kind:Yo},il.sandboxBundleSrc={value:"../build/pdf.sandbox.mjs",kind:Yo},il.viewerCssTheme={value:0,kind:Yo+tl},il.enableFakeMLManager={value:!0,kind:Yo},il.disablePreferences={value:!1,kind:Yo};class sl{static eventBus;static#Sl=new Map;static{for(const t in il)this.#Sl.set(t,il[t].value);for(const[t,e]of Xo)this.#Sl.set(t,e);this._hasInvokedSet=!1,this._checkDisablePreferences=()=>!!this.get("disablePreferences")||(this._hasInvokedSet&&console.warn('The Preferences may override manually set AppOptions; please use the "disablePreferences"-option to prevent that.'),!1)}static get(t){return this.#Sl.get(t)}static getAll(t=null,e=!1){const i=Object.create(null);for(const s in il){const n=il[s];(!t||t&n.kind)&&(i[s]=e?n.value:this.#Sl.get(s))}return i}static set(t,e){this.setAll({[t]:e})}static setAll(t,e=!1){let i;this._hasInvokedSet||=!0;for(const s in t){const n=il[s],r=t[s];if(!n||!(typeof r==typeof n.value||el[(typeof r).toUpperCase()]&n.type))continue;const{kind:a}=n;(!e||a&Ko||a&tl)&&(this.eventBus&&a&Zo&&(i||=new Map).set(s,r),this.#Sl.set(s,r))}if(i)for(const[t,e]of i)this.eventBus.dispatch(t.toLowerCase(),{source:this,value:e})}}class nl{#xl=null;constructor(t){this.pageIndex=t.pageIndex}async render(t="display"){"display"!==t||this.#xl||this._cancelled||(this.#xl=new Ur({pageIndex:this.pageIndex}))}cancel(){this._cancelled=!0,this.#xl&&(this.#xl.destroy(),this.#xl=null)}setParent(t){this.#xl?.setParent(t)}getDrawLayer(){return this.#xl}}const rl={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"columnheader",TBody:null,TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},al=/^H(\d+)$/;class ol{#Cl;#El=null;#Pl;#Ml=new Map;#Tl;#kl=null;constructor(t,e){this.#Cl=t.getStructTree(),this.#Tl=e}async render(){if(this.#Pl)return this.#Pl;const{promise:t,resolve:e,reject:i}=Promise.withResolvers();this.#Pl=t;try{this.#El=this.#Il(await this.#Cl)}catch(t){i(t)}return this.#Cl=null,this.#El?.classList.add("structTree"),e(this.#El),t}async getAriaAttributes(t){try{return await this.render(),this.#Ml.get(t)}catch{}return null}hide(){this.#El&&!this.#El.hidden&&(this.#El.hidden=!0)}show(){this.#El?.hidden&&(this.#El.hidden=!1)}#Ll(t,e){const{alt:i,id:s,lang:n}=t;if(void 0!==i){let s=!1;const n=Kn(i);for(const e of t.children)if("annotation"===e.type){let t=this.#Ml.get(e.id);t||(t=new Map,this.#Ml.set(e.id,t)),t.set("aria-label",n),s=!0}s||e.setAttribute("aria-label",n)}void 0!==s&&e.setAttribute("aria-owns",s),void 0!==n&&e.setAttribute("lang",Kn(n,!0))}#Dl(t,e){const{alt:i,bbox:s,children:n}=t,r=n?.[0];if(!this.#Tl||!i||!s||"content"!==r?.type)return!1;const{id:a}=r;if(!a)return!1;e.setAttribute("aria-owns",a);const o=document.createElement("span");(this.#kl||=new Map).set(a,o),o.setAttribute("role","img"),o.setAttribute("aria-label",Kn(i));const{pageHeight:l,pageX:h,pageY:d}=this.#Tl,c="calc(var(--scale-factor)*",{style:u}=o;return u.width=`${c}${s[2]-s[0]}px)`,u.height=`${c}${s[3]-s[1]}px)`,u.left=`${c}${s[0]-h}px)`,u.top=`${c}${l-s[3]+d}px)`,!0}addElementsToTextLayer(){if(this.#kl){for(const[t,e]of this.#kl)document.getElementById(t)?.append(e);this.#kl.clear(),this.#kl=null}}#Il(t){if(!t)return null;const e=document.createElement("span");if("role"in t){const{role:i}=t,s=i.match(al);if(s?(e.setAttribute("role","heading"),e.setAttribute("aria-level",s[1])):rl[i]&&e.setAttribute("role",rl[i]),"Figure"===i&&this.#Dl(t,e))return e}if(this.#Ll(t,e),t.children)if(1===t.children.length&&"id"in t.children[0])this.#Ll(t.children[0],e);else for(const i of t.children)e.append(this.#Il(i));return e}}class ll{#Rl=!1;#Nl=null;#Fl=new Map;#Ol=new Map;setTextMapping(t){this.#Nl=t}static#Bl(t,e){const i=t.getBoundingClientRect(),s=e.getBoundingClientRect();if(0===i.width&&0===i.height)return 1;if(0===s.width&&0===s.height)return-1;const n=i.y,r=i.y+i.height,a=i.y+i.height/2,o=s.y,l=s.y+s.height,h=s.y+s.height/2;if(a<=o&&h>=r)return-1;if(h<=n&&a>=l)return 1;return i.x+i.width/2-(s.x+s.width/2)}enable(){if(this.#Rl)throw new Error("TextAccessibilityManager is already enabled.");if(!this.#Nl)throw new Error("Text divs and strings have not been set.");if(this.#Rl=!0,this.#Nl=this.#Nl.slice(),this.#Nl.sort(ll.#Bl),this.#Fl.size>0){const t=this.#Nl;for(const[e,i]of this.#Fl){document.getElementById(e)?this.#jl(e,t[i]):this.#Fl.delete(e)}}for(const[t,e]of this.#Ol)this.addPointerInTextLayer(t,e);this.#Ol.clear()}disable(){this.#Rl&&(this.#Ol.clear(),this.#Nl=null,this.#Rl=!1)}removePointerInTextLayer(t){if(!this.#Rl)return void this.#Ol.delete(t);const e=this.#Nl;if(!e||0===e.length)return;const{id:i}=t,s=this.#Fl.get(i);if(void 0===s)return;const n=e[s];this.#Fl.delete(i);let r=n.getAttribute("aria-owns");r?.includes(i)&&(r=r.split(" ").filter((t=>t!==i)).join(" "),r?n.setAttribute("aria-owns",r):(n.removeAttribute("aria-owns"),n.setAttribute("role","presentation")))}#jl(t,e){const i=e.getAttribute("aria-owns");i?.includes(t)||e.setAttribute("aria-owns",i?`${i} ${t}`:t),e.removeAttribute("role")}addPointerInTextLayer(t,e){const{id:i}=t;if(!i)return null;if(!this.#Rl)return this.#Ol.set(t,e),null;e&&this.removePointerInTextLayer(t);const s=this.#Nl;if(!s||0===s.length)return null;const n=Yn(s,(e=>ll.#Bl(t,e)<0)),r=Math.max(0,n-1),a=s[r];this.#jl(i,a),this.#Fl.set(i,r);const o=a.parentNode;return o?.classList.contains("markedContent")?o.id:null}moveElementInDOM(t,e,i,s){const n=this.addPointerInTextLayer(i,s);if(!t.hasChildNodes())return t.append(e),n;const r=Array.from(t.childNodes).filter((t=>t!==e));if(0===r.length)return n;const a=i||e,o=Yn(r,(t=>ll.#Bl(a,t)<0));return 0===o?r[0].before(e):r[o-1].after(e),n}}class hl{#tl=null;constructor({findController:t,eventBus:e,pageIndex:i}){this.findController=t,this.matches=[],this.eventBus=e,this.pageIdx=i,this.textDivs=null,this.textContentItemsStr=null,this.enabled=!1}setTextMapping(t,e){this.textDivs=t,this.textContentItemsStr=e}enable(){if(!this.textDivs||!this.textContentItemsStr)throw new Error("Text divs and strings have not been set.");if(this.enabled)throw new Error("TextHighlighter is already enabled.");this.enabled=!0,this.#tl||(this.#tl=new AbortController,this.eventBus._on("updatetextlayermatches",(t=>{t.pageIndex!==this.pageIdx&&-1!==t.pageIndex||this._updateMatches()}),{signal:this.#tl.signal})),this._updateMatches()}disable(){this.enabled&&(this.enabled=!1,this.#tl?.abort(),this.#tl=null,this._updateMatches(!0))}_convertMatches(t,e){if(!t)return[];const{textContentItemsStr:i}=this;let s=0,n=0;const r=i.length-1,a=[];for(let o=0,l=t.length;o<l;o++){let l=t[o];for(;s!==r&&l>=n+i[s].length;)n+=i[s].length,s++;s===i.length&&console.error("Could not find a matching mapping");const h={begin:{divIdx:s,offset:l-n}};for(l+=e[o];s!==r&&l>n+i[s].length;)n+=i[s].length,s++;h.end={divIdx:s,offset:l-n},a.push(h)}return a}_renderMatches(t){if(0===t.length)return;const{findController:e,pageIdx:i}=this,{textContentItemsStr:s,textDivs:n}=this,r=i===e.selected.pageIdx,a=e.selected.matchIdx;let o=null;const l={offset:void 0};function h(t,e){const i=t.divIdx;return n[i].textContent="",d(i,0,t.offset,e)}function d(t,e,i,r){let a=n[t];if(a.nodeType===Node.TEXT_NODE){const e=document.createElement("span");a.before(e),e.append(a),n[t]=e,a=e}const o=s[t].substring(e,i),l=document.createTextNode(o);if(r){const t=document.createElement("span");if(t.className=`${r} appended`,t.append(l),a.append(t),r.includes("selected")){const{left:e}=t.getClientRects()[0];return e-a.getBoundingClientRect().left}return 0}return a.append(l),0}let c=a,u=c+1;if(e.state.highlightAll)c=0,u=t.length;else if(!r)return;let p=-1,g=-1;for(let s=c;s<u;s++){const c=t[s],u=c.begin;if(u.divIdx===p&&u.offset===g)continue;p=u.divIdx,g=u.offset;const f=c.end,m=r&&s===a,b=m?" selected":"";let v=0;if(o&&u.divIdx===o.divIdx?d(o.divIdx,o.offset,u.offset):(null!==o&&d(o.divIdx,o.offset,l.offset),h(u)),u.divIdx===f.divIdx)v=d(u.divIdx,u.offset,f.offset,"highlight"+b);else{v=d(u.divIdx,u.offset,l.offset,"highlight begin"+b);for(let t=u.divIdx+1,e=f.divIdx;t<e;t++)n[t].className="highlight middle"+b;h(f,"highlight end"+b)}o=f,m&&e.scrollMatchIntoView({element:n[u.divIdx],selectedLeft:v,pageIndex:i,matchIndex:a})}o&&d(o.divIdx,o.offset,l.offset)}_updateMatches(t=!1){if(!this.enabled&&!t)return;const{findController:e,matches:i,pageIdx:s}=this,{textContentItemsStr:n,textDivs:r}=this;let a=-1;for(const t of i){for(let e=Math.max(a,t.begin.divIdx),i=t.end.divIdx;e<=i;e++){const t=r[e];t.textContent=n[e],t.className=""}a=t.end.divIdx+1}if(!e?.highlightMatches||t)return;const o=e.pageMatches[s]||null,l=e.pageMatchesLength[s]||null;this.matches=this._convertMatches(o,l),this._renderMatches(this.matches)}}class dl{#Vl=!1;#Zo=null;#Hl=!1;#go=null;static#zl=new Map;static#Ul=null;constructor({pdfPage:t,highlighter:e=null,accessibilityManager:i=null,enablePermissions:s=!1,onAppend:n=null}){this.pdfPage=t,this.highlighter=e,this.accessibilityManager=i,this.#Vl=!0===s,this.#Zo=n,this.div=document.createElement("div"),this.div.tabIndex=0,this.div.className="textLayer"}async render(t,e=null){if(this.#Hl&&this.#go)return this.#go.update({viewport:t,onBefore:this.hide.bind(this)}),void this.show();this.cancel(),this.#go=new ma({textContentSource:this.pdfPage.streamTextContent(e||{includeMarkedContent:!0,disableNormalization:!0}),container:this.div,viewport:t});const{textDivs:i,textContentItemsStr:s}=this.#go;this.highlighter?.setTextMapping(i,s),this.accessibilityManager?.setTextMapping(i),await this.#go.render(),this.#Hl=!0;const n=document.createElement("div");n.className="endOfContent",this.div.append(n),this.#$l(n),this.#Zo?.(this.div),this.highlighter?.enable(),this.accessibilityManager?.enable()}hide(){!this.div.hidden&&this.#Hl&&(this.highlighter?.disable(),this.div.hidden=!0)}show(){this.div.hidden&&this.#Hl&&(this.div.hidden=!1,this.highlighter?.enable())}cancel(){this.#go?.cancel(),this.#go=null,this.highlighter?.disable(),this.accessibilityManager?.disable(),dl.#Wl(this.div)}#$l(t){const{div:e}=this;e.addEventListener("mousedown",(()=>{e.classList.add("selecting")})),e.addEventListener("copy",(t=>{if(!this.#Vl){const e=document.getSelection();t.clipboardData.setData("text/plain",Kn(sa(e.toString())))}fa(t)})),dl.#zl.set(e,t),dl.#Gl()}static#Wl(t){this.#zl.delete(t),0===this.#zl.size&&(this.#Ul?.abort(),this.#Ul=null)}static#Gl(){if(this.#Ul)return;this.#Ul=new AbortController;const{signal:t}=this.#Ul,e=(t,e)=>{e.append(t),t.style.width="",t.style.height="",e.classList.remove("selecting")};let i=!1;var s,n;document.addEventListener("pointerdown",(()=>{i=!0}),{signal:t}),document.addEventListener("pointerup",(()=>{i=!1,this.#zl.forEach(e)}),{signal:t}),window.addEventListener("blur",(()=>{i=!1,this.#zl.forEach(e)}),{signal:t}),document.addEventListener("keyup",(()=>{i||this.#zl.forEach(e)}),{signal:t}),document.addEventListener("selectionchange",(()=>{const t=document.getSelection();if(0===t.rangeCount)return void this.#zl.forEach(e);const i=new Set;for(let e=0;e<t.rangeCount;e++){const s=t.getRangeAt(e);for(const t of this.#zl.keys())!i.has(t)&&s.intersectsNode(t)&&i.add(t)}for(const[t,s]of this.#zl)i.has(t)?t.classList.add("selecting"):e(s,t);if(s??="none"===getComputedStyle(this.#zl.values().next().value).getPropertyValue("-moz-user-select"),s)return;const r=t.getRangeAt(0),a=n&&(0===r.compareBoundaryPoints(Range.END_TO_END,n)||0===r.compareBoundaryPoints(Range.START_TO_END,n));let o=a?r.startContainer:r.endContainer;o.nodeType===Node.TEXT_NODE&&(o=o.parentNode);const l=o.parentElement?.closest(".textLayer"),h=this.#zl.get(l);h&&(h.style.width=l.style.width,h.style.height=l.style.height,o.parentElement.insertBefore(h,a?o:o.nextSibling)),n=r.cloneRange()}),{signal:t})}}class cl{constructor({pdfPage:t,annotationStorage:e=null,linkService:i,xfaHtml:s=null}){this.pdfPage=t,this.annotationStorage=e,this.linkService=i,this.xfaHtml=s,this.div=null,this._cancelled=!1}async render(t,e="display"){if("print"===e){const i={viewport:t.clone({dontFlip:!0}),div:this.div,xfaHtml:this.xfaHtml,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:e};return this.div=document.createElement("div"),i.div=this.div,_a.render(i)}const i=await this.pdfPage.getXfa();if(this._cancelled||!i)return{textDivs:[]};const s={viewport:t.clone({dontFlip:!0}),div:this.div,xfaHtml:i,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:e};return this.div?_a.update(s):(this.div=document.createElement("div"),s.div=this.div,_a.render(s))}cancel(){this._cancelled=!0}hide(){this.div&&(this.div.hidden=!0)}}const ul={annotationEditorUIManager:null,annotationStorage:null,downloadManager:null,enableScripting:!1,fieldObjectsPromise:null,findController:null,hasJSActionsPromise:null,get linkService(){return new Ir}},pl=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);class gl{#ql=Br.ENABLE_FORMS;#Xl=null;#li=!1;#Kl=!1;#_e=!1;#Yl=null;#Ql=null;#Jl=null;#Zl=null;#th=1;#eh=1;#ih=null;#sh=Fn.INITIAL;#nh=zn;#rh={directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0};#ah=[null,null,null,null];constructor(t){const e=t.container,i=t.defaultViewport;this.id=t.id,this.renderingId="page"+this.id,this.#Yl=t.layerProperties||ul,this.pdfPage=null,this.pageLabel=null,this.rotation=0,this.scale=t.scale||1,this.viewport=i,this.pdfPageRotate=i.rotation,this._optionalContentConfigPromise=t.optionalContentConfigPromise||null,this.#nh=t.textLayerMode??zn,this.#ql=t.annotationMode??Br.ENABLE_FORMS,this.imageResourcesPath=t.imageResourcesPath||"",this.maxCanvasPixels=t.maxCanvasPixels??sl.get("maxCanvasPixels"),this.pageColors=t.pageColors||null,this.#li=t.enableHWA||!1,this.eventBus=t.eventBus,this.renderingQueue=t.renderingQueue,this.l10n=t.l10n,this.l10n||=new $o,this.renderTask=null,this.resume=null,this._isStandalone=!this.renderingQueue?.hasViewer(),this._container=e,this._annotationCanvasMap=null,this.annotationLayer=null,this.annotationEditorLayer=null,this.textLayer=null,this.xfaLayer=null,this.structTreeLayer=null,this.drawLayer=null;const s=document.createElement("div");if(s.className="page",s.setAttribute("data-page-number",this.id),s.setAttribute("role","region"),s.setAttribute("data-l10n-id","pdfjs-page-landmark"),s.setAttribute("data-l10n-args",JSON.stringify({page:this.id})),this.div=s,this.#oh(),e?.append(s),this._isStandalone){e?.style.setProperty("--scale-factor",this.scale*ca.PDF_TO_CSS_UNITS),this.pageColors?.background&&e?.style.setProperty("--page-bg-color",this.pageColors.background);const{optionalContentConfigPromise:i}=t;i&&i.then((t=>{i===this._optionalContentConfigPromise&&(this.#rh.initialOptionalContent=t.hasInitialVisibility)})),t.l10n||this.l10n.translate(this.div)}}#lh(t,e){const i=pl.get(e),s=this.#ah[i];if(this.#ah[i]=t,s)s.replaceWith(t);else{for(let e=i-1;e>=0;e--){const i=this.#ah[e];if(i)return void i.after(t)}this.div.prepend(t)}}get renderingState(){return this.#sh}set renderingState(t){if(t!==this.#sh)switch(this.#sh=t,this.#Ql&&(clearTimeout(this.#Ql),this.#Ql=null),t){case Fn.PAUSED:this.div.classList.remove("loading");break;case Fn.RUNNING:this.div.classList.add("loadingIcon"),this.#Ql=setTimeout((()=>{this.div.classList.add("loading"),this.#Ql=null}),0);break;case Fn.INITIAL:case Fn.FINISHED:this.div.classList.remove("loadingIcon","loading")}}#oh(){const{viewport:t}=this;if(this.pdfPage){if(this.#Zl===t.rotation)return;this.#Zl=t.rotation}pa(this.div,t,!0,!1)}setPdfPage(t){!this._isStandalone||"CanvasText"!==this.pageColors?.foreground&&"Canvas"!==this.pageColors?.background||(this._container?.style.setProperty("--hcm-highlight-filter",t.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight")),this._container?.style.setProperty("--hcm-highlight-selected-filter",t.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","Highlight"))),this.pdfPage=t,this.pdfPageRotate=t.rotate;const e=(this.rotation+this.pdfPageRotate)%360;this.viewport=t.getViewport({scale:this.scale*ca.PDF_TO_CSS_UNITS,rotation:e}),this.#oh(),this.reset()}destroy(){this.reset(),this.pdfPage?.cleanup()}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}get _textHighlighter(){return ga(this,"_textHighlighter",new hl({pageIndex:this.id-1,eventBus:this.eventBus,findController:this.#Yl.findController}))}#hh(t,e){this.eventBus.dispatch(t,{source:this,pageNumber:this.id,error:e})}async#dh(){let t=null;try{await this.annotationLayer.render(this.viewport,{structTreeLayer:this.structTreeLayer},"display")}catch(e){console.error("#renderAnnotationLayer:",e),t=e}finally{this.#hh("annotationlayerrendered",t)}}async#ch(){let t=null;try{await this.annotationEditorLayer.render(this.viewport,"display")}catch(e){console.error("#renderAnnotationEditorLayer:",e),t=e}finally{this.#hh("annotationeditorlayerrendered",t)}}async#uh(){try{await this.drawLayer.render("display")}catch(t){console.error("#renderDrawLayer:",t)}}async#ph(){let t=null;try{const t=await this.xfaLayer.render(this.viewport,"display");t?.textDivs&&this._textHighlighter&&this.#gh(t.textDivs)}catch(e){console.error("#renderXfaLayer:",e),t=e}finally{this.xfaLayer?.div&&(this.l10n.pause(),this.#lh(this.xfaLayer.div,"xfaLayer"),this.l10n.resume()),this.#hh("xfalayerrendered",t)}}async#fh(){if(!this.textLayer)return;let t=null;try{await this.textLayer.render(this.viewport)}catch(e){if(e instanceof Lr)return;console.error("#renderTextLayer:",e),t=e}this.#hh("textlayerrendered",t),this.#mh()}async#mh(){if(!this.textLayer)return;const t=await(this.structTreeLayer?.render());t&&(this.l10n.pause(),this.structTreeLayer?.addElementsToTextLayer(),this.canvas&&t.parentNode!==this.canvas&&this.canvas.append(t),this.l10n.resume()),this.structTreeLayer?.show()}async#gh(t){const e=await this.pdfPage.getTextContent(),i=[];for(const t of e.items)i.push(t.str);this._textHighlighter.setTextMapping(t,i),this._textHighlighter.enable()}#bh(){const{canvas:t}=this;t&&(t.remove(),t.width=t.height=0,this.canvas=null,this.#Jl=null)}reset({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:s=!1,keepCanvasWrapper:n=!1}={}){this.cancelRendering({keepAnnotationLayer:t,keepAnnotationEditorLayer:e,keepXfaLayer:i,keepTextLayer:s}),this.renderingState=Fn.INITIAL;const r=this.div,a=r.childNodes,o=t&&this.annotationLayer?.div||null,l=e&&this.annotationEditorLayer?.div||null,h=i&&this.xfaLayer?.div||null,d=s&&this.textLayer?.div||null,c=n&&this.#Xl||null;for(let t=a.length-1;t>=0;t--){const e=a[t];switch(e){case o:case l:case h:case d:case c:continue}e.remove();const i=this.#ah.indexOf(e);i>=0&&(this.#ah[i]=null)}r.removeAttribute("data-loaded"),o&&this.annotationLayer.hide(),l&&this.annotationEditorLayer.hide(),h&&this.xfaLayer.hide(),d&&this.textLayer.hide(),this.structTreeLayer?.hide(),!n&&this.#Xl&&(this.#Xl=null,this.#bh())}toggleEditingMode(t){this.hasEditableAnnotations()&&(this.#_e=t,this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0}))}update({scale:t=0,rotation:e=null,optionalContentConfigPromise:i=null,drawingDelay:s=-1}){this.scale=t||this.scale,"number"==typeof e&&(this.rotation=e),i instanceof Promise&&(this._optionalContentConfigPromise=i,i.then((t=>{i===this._optionalContentConfigPromise&&(this.#rh.initialOptionalContent=t.hasInitialVisibility)}))),this.#rh.directDrawing=!0;const n=(this.rotation+this.pdfPageRotate)%360;if(this.viewport=this.viewport.clone({scale:this.scale*ca.PDF_TO_CSS_UNITS,rotation:n}),this.#oh(),this._isStandalone&&this._container?.style.setProperty("--scale-factor",this.viewport.scale),this.canvas){let t=!1;if(this.#Kl)if(0===this.maxCanvasPixels)t=!0;else if(this.maxCanvasPixels>0){const{width:e,height:i}=this.viewport,{sx:s,sy:n}=this.outputScale;t=(Math.floor(e)*s|0)*(Math.floor(i)*n|0)>this.maxCanvasPixels}const e=s>=0&&s<1e3;if(e||t){if(e&&!t&&this.renderingState!==Fn.FINISHED&&(this.cancelRendering({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:s}),this.renderingState=Fn.FINISHED,this.#rh.directDrawing=!1),this.cssTransform({redrawAnnotationLayer:!0,redrawAnnotationEditorLayer:!0,redrawXfaLayer:!0,redrawTextLayer:!e,hideTextLayer:e}),e)return;return void this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!0,timestamp:performance.now(),error:this.#ih})}}this.cssTransform({}),this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0})}cancelRendering({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:s=!1,cancelExtraDelay:n=0}={}){this.renderTask&&(this.renderTask.cancel(n),this.renderTask=null),this.resume=null,!this.textLayer||s&&this.textLayer.div||(this.textLayer.cancel(),this.textLayer=null),!this.annotationLayer||t&&this.annotationLayer.div||(this.annotationLayer.cancel(),this.annotationLayer=null,this._annotationCanvasMap=null),this.structTreeLayer&&!this.textLayer&&(this.structTreeLayer=null),!this.annotationEditorLayer||e&&this.annotationEditorLayer.div||(this.drawLayer&&(this.drawLayer.cancel(),this.drawLayer=null),this.annotationEditorLayer.cancel(),this.annotationEditorLayer=null),!this.xfaLayer||i&&this.xfaLayer.div||(this.xfaLayer.cancel(),this.xfaLayer=null,this._textHighlighter?.disable())}cssTransform({redrawAnnotationLayer:t=!1,redrawAnnotationEditorLayer:e=!1,redrawXfaLayer:i=!1,redrawTextLayer:s=!1,hideTextLayer:n=!1}){const{canvas:r}=this;if(!r)return;const a=this.#Jl;if(this.viewport!==a){const t=(360+this.viewport.rotation-a.rotation)%360;if(90===t||270===t){const{width:e,height:i}=this.viewport,s=i/e,n=e/i;r.style.transform=`rotate(${t}deg) scale(${s},${n})`}else r.style.transform=0===t?"":`rotate(${t}deg)`}t&&this.annotationLayer&&this.#dh(),e&&this.annotationEditorLayer&&(this.drawLayer&&this.#uh(),this.#ch()),i&&this.xfaLayer&&this.#ph(),this.textLayer&&(n?(this.textLayer.hide(),this.structTreeLayer?.hide()):s&&this.#fh())}get width(){return this.viewport.width}get height(){return this.viewport.height}getPagePoint(t,e){return this.viewport.convertToPdfPoint(t,e)}async#vh(t,e=null){if(t===this.renderTask&&(this.renderTask=null),e instanceof ua)this.#ih=null;else if(this.#ih=e,this.renderingState=Fn.FINISHED,this.#rh.regularAnnotations=!t.separateAnnots,this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!1,timestamp:performance.now(),error:this.#ih}),e)throw e}async draw(){this.renderingState!==Fn.INITIAL&&(console.error("Must be in new state before drawing"),this.reset());const{div:t,l10n:e,pageColors:i,pdfPage:s,viewport:n}=this;if(!s)throw this.renderingState=Fn.FINISHED,new Error("pdfPage is not loaded");this.renderingState=Fn.RUNNING;let r=this.#Xl;if(r||(r=this.#Xl=document.createElement("div"),r.classList.add("canvasWrapper"),this.#lh(r,"canvasWrapper")),this.textLayer||this.#nh===Hn||s.isPureXfa||(this._accessibilityManager||=new ll,this.textLayer=new dl({pdfPage:s,highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,enablePermissions:this.#nh===Un,onAppend:t=>{this.l10n.pause(),this.#lh(t,"textLayer"),this.l10n.resume()}})),!this.annotationLayer&&this.#ql!==Br.DISABLE){const{annotationStorage:t,annotationEditorUIManager:e,downloadManager:i,enableScripting:n,fieldObjectsPromise:r,hasJSActionsPromise:a,linkService:o}=this.#Yl;this._annotationCanvasMap||=new Map,this.annotationLayer=new xa({pdfPage:s,annotationStorage:t,imageResourcesPath:this.imageResourcesPath,renderForms:this.#ql===Br.ENABLE_FORMS,linkService:o,downloadManager:i,enableScripting:n,hasJSActionsPromise:a,fieldObjectsPromise:r,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager,annotationEditorUIManager:e,onAppend:t=>{this.#lh(t,"annotationLayer")}})}const{width:a,height:o}=n,l=document.createElement("canvas");l.setAttribute("role","presentation");const h=!(!i?.background||!i?.foreground),d=this.canvas,c=!d&&!h;this.canvas=l,this.#Jl=n;let u=t=>{if(c)return r.prepend(l),void(u=null);t&&(d?(d.replaceWith(l),d.width=d.height=0):r.prepend(l),u=null)};const p=l.getContext("2d",{alpha:!1,willReadFrequently:!this.#li}),g=this.outputScale=new ra;if(0===this.maxCanvasPixels){const t=1/this.scale;g.sx*=t,g.sy*=t,this.#Kl=!0}else if(this.maxCanvasPixels>0){const t=a*o,e=Math.sqrt(this.maxCanvasPixels/t);g.sx>e||g.sy>e?(g.sx=e,g.sy=e,this.#Kl=!0):this.#Kl=!1}const f=Qn(g.sx),m=Qn(g.sy),b=l.width=Jn(sr(a*g.sx),f[0]),v=l.height=Jn(sr(o*g.sy),m[0]),w=Jn(sr(a),f[1]),y=Jn(sr(o),m[1]);g.sx=b/w,g.sy=v/y,this.#th!==f[1]&&(t.style.setProperty("--scale-round-x",`${f[1]}px`),this.#th=f[1]),this.#eh!==m[1]&&(t.style.setProperty("--scale-round-y",`${m[1]}px`),this.#eh=m[1]);const A={canvasContext:p,transform:g.scaled?[g.sx,0,0,g.sy,0,0]:null,viewport:n,annotationMode:this.#ql,optionalContentConfigPromise:this._optionalContentConfigPromise,annotationCanvasMap:this._annotationCanvasMap,pageColors:i,isEditing:this.#_e},_=this.renderTask=s.render(A);_.onContinue=t=>{if(u?.(!1),this.renderingQueue&&!this.renderingQueue.isHighestPriority(this))return this.renderingState=Fn.PAUSED,void(this.resume=()=>{this.renderingState=Fn.RUNNING,t()});t()};const x=_.promise.then((async()=>{u?.(!0),await this.#vh(_),this.structTreeLayer||=new ol(s,n.rawDims),this.#fh(),this.annotationLayer&&await this.#dh();const{annotationEditorUIManager:t}=this.#Yl;t&&(this.drawLayer||=new nl({pageIndex:this.id}),await this.#uh(),this.drawLayer.setParent(r),this.annotationEditorLayer||=new qo({uiManager:t,pdfPage:s,l10n:e,structTreeLayer:this.structTreeLayer,accessibilityManager:this._accessibilityManager,annotationLayer:this.annotationLayer?.annotationLayer,textLayer:this.textLayer,drawLayer:this.drawLayer.getDrawLayer(),onAppend:t=>{this.#lh(t,"annotationEditorLayer")}}),this.#ch())}),(t=>(t instanceof ua?(d?.remove(),this.#bh()):u?.(!0),this.#vh(_,t))));if(s.isPureXfa){if(!this.xfaLayer){const{annotationStorage:t,linkService:e}=this.#Yl;this.xfaLayer=new cl({pdfPage:s,annotationStorage:t,linkService:e})}this.#ph()}return t.setAttribute("data-loaded",!0),this.eventBus.dispatch("pagerender",{source:this,pageNumber:this.id}),x}setPageLabel(t){this.pageLabel="string"==typeof t?t:null,this.div.setAttribute("data-l10n-args",JSON.stringify({page:this.pageLabel??this.id})),null!==this.pageLabel?this.div.setAttribute("data-page-label",this.pageLabel):this.div.removeAttribute("data-page-label")}get thumbnailCanvas(){const{directDrawing:t,initialOptionalContent:e,regularAnnotations:i}=this.#rh;return t&&e&&i?this.canvas:null}}class fl{constructor(t){this._ready=new Promise(((e,i)=>{import(t).then((t=>{e(t.QuickJSSandbox())})).catch(i)}))}async createSandbox(t){(await this._ready).create(t)}async dispatchEventInSandbox(t){const e=await this._ready;setTimeout((()=>e.dispatchEvent(t)),0)}async destroySandbox(){(await this._ready).nukeSandbox()}}class ml{#wh=null;#yh=null;#Ah=null;#tl=null;#Ir=null;#_h=null;#xh=null;#Sh=null;#Ch=!1;#Eh=null;#Ph=null;constructor({eventBus:t,externalServices:e=null,docProperties:i=null}){this.#Ir=t,this.#_h=e,this.#Ah=i}setViewer(t){this.#Sh=t}async setDocument(t){if(this.#xh&&await this.#Mh(),this.#xh=t,!t)return;const[e,i,s]=await Promise.all([t.getFieldObjects(),t.getCalculationOrderIds(),t.getJSActions()]);if(!e&&!s)return void await this.#Mh();if(t!==this.#xh)return;try{this.#Eh=this.#Th()}catch(t){return console.error("setDocument:",t),void await this.#Mh()}const n=this.#Ir;this.#tl=new AbortController;const{signal:r}=this.#tl;n._on("updatefromsandbox",(t=>{t?.source===window&&this.#kh(t.detail)}),{signal:r}),n._on("dispatcheventinsandbox",(t=>{this.#Eh?.dispatchEventInSandbox(t.detail)}),{signal:r}),n._on("pagechanging",(({pageNumber:t,previous:e})=>{t!==e&&(this.#Ih(e),this.#Lh(t))}),{signal:r}),n._on("pagerendered",(({pageNumber:t})=>{this._pageOpenPending.has(t)&&t===this.#Sh.currentPageNumber&&this.#Lh(t)}),{signal:r}),n._on("pagesdestroy",(async()=>{await this.#Ih(this.#Sh.currentPageNumber),await(this.#Eh?.dispatchEventInSandbox({id:"doc",name:"WillClose"})),this.#wh?.resolve()}),{signal:r});try{const r=await this.#Ah(t);if(t!==this.#xh)return;await this.#Eh.createSandbox({objects:e,calculationOrder:i,appInfo:{platform:navigator.platform,language:navigator.language},docInfo:{...r,actions:s}}),n.dispatch("sandboxcreated",{source:this})}catch(t){return console.error("setDocument:",t),void await this.#Mh()}await(this.#Eh?.dispatchEventInSandbox({id:"doc",name:"Open"})),await this.#Lh(this.#Sh.currentPageNumber,!0),Promise.resolve().then((()=>{t===this.#xh&&(this.#Ch=!0)}))}async dispatchWillSave(){return this.#Eh?.dispatchEventInSandbox({id:"doc",name:"WillSave"})}async dispatchDidSave(){return this.#Eh?.dispatchEventInSandbox({id:"doc",name:"DidSave"})}async dispatchWillPrint(){if(this.#Eh){await(this.#Ph?.promise),this.#Ph=Promise.withResolvers();try{await this.#Eh.dispatchEventInSandbox({id:"doc",name:"WillPrint"})}catch(t){throw this.#Ph.resolve(),this.#Ph=null,t}await this.#Ph.promise}}async dispatchDidPrint(){return this.#Eh?.dispatchEventInSandbox({id:"doc",name:"DidPrint"})}get destroyPromise(){return this.#yh?.promise||null}get ready(){return this.#Ch}get _pageOpenPending(){return ga(this,"_pageOpenPending",new Set)}get _visitedPages(){return ga(this,"_visitedPages",new Map)}async#kh(t){const e=this.#Sh,i=e.isInPresentationMode||e.isChangingPresentationMode,{id:s,siblings:n,command:r,value:a}=t;if(!s){switch(r){case"clear":console.clear();break;case"error":console.error(a);break;case"layout":if(!i){const t=function(t){let e=$n.VERTICAL,i=Wn.NONE;switch(t){case"SinglePage":e=$n.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=$n.PAGE;case"TwoColumnLeft":i=Wn.ODD;break;case"TwoPageRight":e=$n.PAGE;case"TwoColumnRight":i=Wn.EVEN}return{scrollMode:e,spreadMode:i}}(a);e.spreadMode=t.spreadMode}break;case"page-num":e.currentPageNumber=a+1;break;case"print":await e.pagesPromise,this.#Ir.dispatch("print",{source:this});break;case"println":console.log(a);break;case"zoom":i||(e.currentScaleValue=a);break;case"SaveAs":this.#Ir.dispatch("download",{source:this});break;case"FirstPage":e.currentPageNumber=1;break;case"LastPage":e.currentPageNumber=e.pagesCount;break;case"NextPage":e.nextPage();break;case"PrevPage":e.previousPage();break;case"ZoomViewIn":i||e.increaseScale();break;case"ZoomViewOut":i||e.decreaseScale();break;case"WillPrintFinished":this.#Ph?.resolve(),this.#Ph=null}return}if(i&&t.focus)return;delete t.id,delete t.siblings;const o=n?[s,...n]:[s];for(const e of o){const i=document.querySelector(`[data-element-id="${e}"]`);i?i.dispatchEvent(new CustomEvent("updatefromsandbox",{detail:t})):this.#xh?.annotationStorage.setValue(e,t)}}async#Lh(t,e=!1){const i=this.#xh,s=this._visitedPages;if(e&&(this.#wh=Promise.withResolvers()),!this.#wh)return;const n=this.#Sh.getPageView(t-1);if(n?.renderingState!==Fn.FINISHED)return void this._pageOpenPending.add(t);this._pageOpenPending.delete(t);const r=(async()=>{const e=await(s.has(t)?null:n.pdfPage?.getJSActions());i===this.#xh&&await(this.#Eh?.dispatchEventInSandbox({id:"page",name:"PageOpen",pageNumber:t,actions:e}))})();s.set(t,r)}async#Ih(t){const e=this.#xh,i=this._visitedPages;if(!this.#wh)return;if(this._pageOpenPending.has(t))return;const s=i.get(t);s&&(i.set(t,null),await s,e===this.#xh&&await(this.#Eh?.dispatchEventInSandbox({id:"page",name:"PageClose",pageNumber:t})))}#Th(){if(this.#yh=Promise.withResolvers(),this.#Eh)throw new Error("#initScripting: Scripting already exists.");return this.#_h.createScripting()}async#Mh(){if(!this.#Eh)return this.#xh=null,void this.#yh?.resolve();this.#wh&&(await Promise.race([this.#wh.promise,new Promise((t=>{setTimeout(t,1e3)}))]).catch((()=>{})),this.#wh=null),this.#xh=null;try{await this.#Eh.destroySandbox()}catch{}this.#Ph?.reject(new Error("Scripting destroyed.")),this.#Ph=null,this.#tl?.abort(),this.#tl=null,this._pageOpenPending.clear(),this._visitedPages.clear(),this.#Eh=null,this.#Ch=!1,this.#yh?.resolve()}}class bl extends ml{constructor(t){t.externalServices||window.addEventListener("updatefromsandbox",(e=>{t.eventBus.dispatch("updatefromsandbox",{source:window,detail:e.detail})})),t.externalServices||={createScripting:()=>new fl(t.sandboxBundleSrc)},t.docProperties||=t=>async function(t){const e="".split("#",1)[0];let{info:i,metadata:s,contentDispositionFilename:n,contentLength:r}=await t.getMetadata();if(!r){const{length:e}=await t.getDownloadInfo();r=e}return{...i,baseURL:e,filesize:r,filename:n||Xr(""),metadata:s?.getRaw(),authors:s?.get("dc:creator"),numPages:t.numPages,URL:""}}(t),super(t)}}let vl=class{constructor(){this.pdfViewer=null,this.pdfThumbnailViewer=null,this.onIdle=null,this.highestPriorityPage=null,this.idleTimeout=null,this.printing=!1,this.isThumbnailViewEnabled=!1,Object.defineProperty(this,"hasViewer",{value:()=>!!this.pdfViewer})}setViewer(t){this.pdfViewer=t}setThumbnailViewer(t){this.pdfThumbnailViewer=t}isHighestPriority(t){return this.highestPriorityPage===t.renderingId}renderHighestPriority(t){this.idleTimeout&&(clearTimeout(this.idleTimeout),this.idleTimeout=null),this.pdfViewer.forceRendering(t)||this.isThumbnailViewEnabled&&this.pdfThumbnailViewer?.forceRendering()||this.printing||this.onIdle&&(this.idleTimeout=setTimeout(this.onIdle.bind(this),3e4))}getHighestPriority(t,e,i,s=!1){const n=t.views,r=n.length;if(0===r)return null;for(let t=0;t<r;t++){const e=n[t].view;if(!this.isViewFinished(e))return e}const a=t.first.id,o=t.last.id;if(o-a+1>r){const s=t.ids;for(let t=1,n=o-a;t<n;t++){const n=i?a+t:o-t;if(s.has(n))continue;const r=e[n-1];if(!this.isViewFinished(r))return r}}let l=i?o:a-2,h=e[l];return h&&!this.isViewFinished(h)||s&&(l+=i?1:-1,h=e[l],h&&!this.isViewFinished(h))?h:null}isViewFinished(t){return t.renderingState===Fn.FINISHED}renderView(t){switch(t.renderingState){case Fn.FINISHED:return!1;case Fn.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case Fn.RUNNING:this.highestPriorityPage=t.renderingId;break;case Fn.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally((()=>{this.renderHighestPriority()})).catch((t=>{t instanceof ua||console.error("renderView:",t)}))}return!0}};const wl=1e4,yl=5e3,Al=250;function _l(t){return Object.values(Nr).includes(t)&&t!==Nr.DISABLE}class xl{#Dh=new Set;#Rh=0;constructor(t){this.#Rh=t}push(t){const e=this.#Dh;e.has(t)&&e.delete(t),e.add(t),e.size>this.#Rh&&this.#Nh()}resize(t,e=null){this.#Rh=t;const i=this.#Dh;if(e){const t=i.size;let s=1;for(const n of i)if(e.has(n.id)&&(i.delete(n),i.add(n)),++s>t)break}for(;i.size>this.#Rh;)this.#Nh()}has(t){return this.#Dh.has(t)}[Symbol.iterator](){return this.#Dh.keys()}#Nh(){const t=this.#Dh.keys().next().value;t?.destroy(),this.#Dh.delete(t)}}class Sl{#Fh=null;#L=null;#Oh=null;#Bh=Nr.NONE;#jh=null;#ql=Br.ENABLE_FORMS;#Vh=null;#Hh=null;#li=!1;#U=!1;#Vl=!1;#$=!1;#W=!1;#tl=null;#nt=null;#zh=null;#Uh=null;#$h=!1;#Wh=null;#Gh=!1;#qh=0;#Xh=new ResizeObserver(this.#Kh.bind(this));#Yh=null;#Qh=null;#Jh=!0;#nh=zn;constructor(t){const e="4.10.38";if(Aa!==e)throw new Error(`The API version "${Aa}" does not match the Viewer version "${e}".`);if(this.container=t.container,this.viewer=t.viewer||t.container.firstElementChild,"DIV"!==this.container?.tagName||"DIV"!==this.viewer?.tagName)throw new Error("Invalid `container` and/or `viewer` option.");if(this.container.offsetParent&&"absolute"!==getComputedStyle(this.container).position)throw new Error("The `container` must be absolutely positioned.");this.#Xh.observe(this.container),this.eventBus=t.eventBus,this.linkService=t.linkService||new Ir,this.downloadManager=t.downloadManager||null,this.findController=t.findController||null,this.#L=t.altTextManager||null,this.#Hh=t.editorUndoBar||null,this.findController&&(this.findController.onIsPageVisible=t=>this._getVisiblePages().ids.has(t)),this._scriptingManager=t.scriptingManager||null,this.#nh=t.textLayerMode??zn,this.#ql=t.annotationMode??Br.ENABLE_FORMS,this.#Bh=t.annotationEditorMode??Nr.NONE,this.#Oh=t.annotationEditorHighlightColors||null,this.#U=!0===t.enableHighlightFloatingButton,this.#$=!0===t.enableUpdatedAddImage,this.#W=!0===t.enableNewAltTextWhenAddingImage,this.imageResourcesPath=t.imageResourcesPath||"",this.enablePrintAutoRotate=t.enablePrintAutoRotate||!1,this.removePageBorders=t.removePageBorders||!1,this.maxCanvasPixels=t.maxCanvasPixels,this.l10n=t.l10n,this.l10n||=new $o,this.#Vl=t.enablePermissions||!1,this.pageColors=t.pageColors||null,this.#nt=t.mlManager||null,this.#li=t.enableHWA||!1,this.#Jh=!1!==t.supportsPinchToZoom,this.defaultRenderingQueue=!t.renderingQueue,this.defaultRenderingQueue?(this.renderingQueue=new vl,this.renderingQueue.setViewer(this)):this.renderingQueue=t.renderingQueue;const{abortSignal:i}=t;i?.addEventListener("abort",(()=>{this.#Xh.disconnect(),this.#Xh=null}),{once:!0}),this.scroll=function(t,e,i){const s=function(i){r||(r=window.requestAnimationFrame((function(){r=null;const i=t.scrollLeft,s=n.lastX;i!==s&&(n.right=i>s),n.lastX=i;const a=t.scrollTop,o=n.lastY;a!==o&&(n.down=a>o),n.lastY=a,e(n)})))},n={right:!0,down:!0,lastX:t.scrollLeft,lastY:t.scrollTop,_eventHandler:s};let r=null;return t.addEventListener("scroll",s,{useCapture:!0,signal:i}),i?.addEventListener("abort",(()=>window.cancelAnimationFrame(r)),{once:!0}),n}(this.container,this._scrollUpdate.bind(this),i),this.presentationModeState=On,this._resetView(),this.removePageBorders&&this.viewer.classList.add("removePageBorders"),this.#Zh(),this.eventBus._on("thumbnailrendered",(({pageNumber:t,pdfPage:e})=>{const i=this._pages[t-1];this.#Fh.has(i)||e?.cleanup()})),t.l10n||this.l10n.translate(this.container)}get pagesCount(){return this._pages.length}getPageView(t){return this._pages[t]}getCachedPageViews(){return new Set(this.#Fh)}get pageViewsReady(){return this._pages.every((t=>t?.pdfPage))}get renderForms(){return this.#ql===Br.ENABLE_FORMS}get enableScripting(){return!!this._scriptingManager}get currentPageNumber(){return this._currentPageNumber}set currentPageNumber(t){if(!Number.isInteger(t))throw new Error("Invalid page number.");this.pdfDocument&&(this._setCurrentPageNumber(t,!0)||console.error(`currentPageNumber: "${t}" is not a valid page.`))}_setCurrentPageNumber(t,e=!1){if(this._currentPageNumber===t)return e&&this.#td(),!0;if(!(0<t&&t<=this.pagesCount))return!1;const i=this._currentPageNumber;return this._currentPageNumber=t,this.eventBus.dispatch("pagechanging",{source:this,pageNumber:t,pageLabel:this._pageLabels?.[t-1]??null,previous:i}),e&&this.#td(),!0}get currentPageLabel(){return this._pageLabels?.[this._currentPageNumber-1]??null}set currentPageLabel(t){if(!this.pdfDocument)return;let e=0|t;if(this._pageLabels){const i=this._pageLabels.indexOf(t);i>=0&&(e=i+1)}this._setCurrentPageNumber(e,!0)||console.error(`currentPageLabel: "${t}" is not a valid page.`)}get currentScale(){return 0!==this._currentScale?this._currentScale:1}set currentScale(t){if(isNaN(t))throw new Error("Invalid numeric scale.");this.pdfDocument&&this.#ed(t,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(t){this.pdfDocument&&this.#ed(t,{noScroll:!1})}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!Zn(t))throw new Error("Invalid pages rotation angle.");if(!this.pdfDocument)return;if((t%=360)<0&&(t+=360),this._pagesRotation===t)return;this._pagesRotation=t;const e=this._currentPageNumber;this.refresh(!0,{rotation:t}),this._currentScaleValue&&this.#ed(this._currentScaleValue,{noScroll:!0}),this.eventBus.dispatch("rotationchanging",{source:this,pagesRotation:t,pageNumber:e}),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 _layerProperties(){const t=this;return ga(this,"_layerProperties",{get annotationEditorUIManager(){return t.#jh},get annotationStorage(){return t.pdfDocument?.annotationStorage},get downloadManager(){return t.downloadManager},get enableScripting(){return!!t._scriptingManager},get fieldObjectsPromise(){return t.pdfDocument?.getFieldObjects()},get findController(){return t.findController},get hasJSActionsPromise(){return t.pdfDocument?.hasJSActions()},get linkService(){return t.linkService}})}#id(t){const e={annotationEditorMode:this.#Bh,annotationMode:this.#ql,textLayerMode:this.#nh};return t?(t.includes(da.COPY)||this.#nh!==zn||(e.textLayerMode=Un),t.includes(da.MODIFY_CONTENTS)||(e.annotationEditorMode=Nr.DISABLE),t.includes(da.MODIFY_ANNOTATIONS)||t.includes(da.FILL_INTERACTIVE_FORMS)||this.#ql!==Br.ENABLE_FORMS||(e.annotationMode=Br.ENABLE),e):e}async#sd(t){if("hidden"===document.visibilityState||!this.container.offsetParent||0===this._getVisiblePages().views.length)return;const e=Promise.withResolvers(),i=new AbortController;document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&e.resolve()}),{signal:"function"==typeof AbortSignal.any?AbortSignal.any([t,i.signal]):t}),await Promise.race([this._onePageRenderedCapability.promise,e.promise]),i.abort()}async getAllText(){const t=[],e=[];for(let i=1,s=this.pdfDocument.numPages;i<=s;++i){if(this.#Gh)return null;e.length=0;const s=await this.pdfDocument.getPage(i),{items:n}=await s.getTextContent();for(const t of n)t.str&&e.push(t.str),t.hasEOL&&e.push("\n");t.push(Kn(e.join("")))}return t.join("\n")}#nd(t,e){const i=document.getSelection(),{focusNode:s,anchorNode:n}=i;if(n&&s&&i.containsNode(this.#Wh)){if(this.#$h||t===Un)return void fa(e);this.#$h=!0;const{classList:i}=this.viewer;i.add("copyAll");const s=new AbortController;window.addEventListener("keydown",(t=>this.#Gh="Escape"===t.key),{signal:s.signal}),this.getAllText().then((async t=>{null!==t&&await navigator.clipboard.writeText(t)})).catch((t=>{console.warn(`Something goes wrong when extracting the text: ${t.message}`)})).finally((()=>{this.#$h=!1,this.#Gh=!1,s.abort(),i.remove("copyAll")})),fa(e)}}setDocument(t){if(this.pdfDocument&&(this.eventBus.dispatch("pagesdestroy",{source:this}),this._cancelRendering(),this._resetView(),this.findController?.setDocument(null),this._scriptingManager?.setDocument(null),this.#jh?.destroy(),this.#jh=null),this.pdfDocument=t,!t)return;const e=t.numPages,i=t.getPage(1),s=t.getOptionalContentConfig({intent:"display"}),n=this.#Vl?t.getPermissions():Promise.resolve(),{eventBus:r,pageColors:a,viewer:o}=this;this.#tl=new AbortController;const{signal:l}=this.#tl;if(e>wl){console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");const t=this._scrollMode=$n.PAGE;r.dispatch("scrollmodechanged",{source:this,mode:t})}this._pagesCapability.promise.then((()=>{r.dispatch("pagesloaded",{source:this,pagesCount:e})}),(()=>{}));r._on("pagerender",(t=>{const e=this._pages[t.pageNumber-1];e&&this.#Fh.push(e)}),{signal:l});const h=t=>{t.cssTransform||(this._onePageRenderedCapability.resolve({timestamp:t.timestamp}),r._off("pagerendered",h))};r._on("pagerendered",h,{signal:l}),Promise.all([i,n]).then((([i,n])=>{if(t!==this.pdfDocument)return;this._firstPageCapability.resolve(i),this._optionalContentConfigPromise=s;const{annotationEditorMode:h,annotationMode:d,textLayerMode:c}=this.#id(n);if(c!==Hn){const t=this.#Wh=document.createElement("div");t.id="hiddenCopyElement",o.before(t)}if("function"==typeof AbortSignal.any&&h!==Nr.DISABLE){const e=h;t.isPureXfa?console.warn("Warning: XFA-editing is not implemented."):_l(e)?(this.#jh=new Fr(this.container,o,this.#L,r,t,a,this.#Oh,this.#U,this.#$,this.#W,this.#nt,this.#Hh,this.#Jh),r.dispatch("annotationeditoruimanager",{source:this,uiManager:this.#jh}),e!==Nr.NONE&&(e===Nr.STAMP&&this.#nt?.loadModel("altText"),this.#jh.updateMode(e))):console.error(`Invalid AnnotationEditor mode: ${e}`)}const u=this._scrollMode===$n.PAGE?null:o,p=this.currentScale,g=i.getViewport({scale:p*ca.PDF_TO_CSS_UNITS});o.style.setProperty("--scale-factor",g.scale),a?.background&&o.style.setProperty("--page-bg-color",a.background),"CanvasText"!==a?.foreground&&"Canvas"!==a?.background||(o.style.setProperty("--hcm-highlight-filter",t.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight")),o.style.setProperty("--hcm-highlight-selected-filter",t.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","ButtonText")));for(let t=1;t<=e;++t){const e=new gl({container:u,eventBus:r,id:t,scale:p,defaultViewport:g.clone(),optionalContentConfigPromise:s,renderingQueue:this.renderingQueue,textLayerMode:c,annotationMode:d,imageResourcesPath:this.imageResourcesPath,maxCanvasPixels:this.maxCanvasPixels,pageColors:a,l10n:this.l10n,layerProperties:this._layerProperties,enableHWA:this.#li});this._pages.push(e)}this._pages[0]?.setPdfPage(i),this._scrollMode===$n.PAGE?this.#rd():this._spreadMode!==Wn.NONE&&this._updateSpreadMode(),this.#sd(l).then((async()=>{if(t!==this.pdfDocument)return;if(this.findController?.setDocument(t),this._scriptingManager?.setDocument(t),this.#Wh&&document.addEventListener("copy",this.#nd.bind(this,c),{signal:l}),this.#jh&&r.dispatch("annotationeditormodechanged",{source:this,mode:this.#Bh}),t.loadingParams.disableAutoFetch||e>yl)return void this._pagesCapability.resolve();let i=e-1;if(i<=0)this._pagesCapability.resolve();else for(let s=2;s<=e;++s){const e=t.getPage(s).then((t=>{const e=this._pages[s-1];e.pdfPage||e.setPdfPage(t),0==--i&&this._pagesCapability.resolve()}),(t=>{console.error(`Unable to get page ${s} to initialize viewer`,t),0==--i&&this._pagesCapability.resolve()}));s%Al==0&&await e}})),r.dispatch("pagesinit",{source:this}),t.getMetadata().then((({info:e})=>{t===this.pdfDocument&&e.Language&&(o.lang=e.Language)})),this.defaultRenderingQueue&&this.update()})).catch((t=>{console.error("Unable to initialize viewer",t),this._pagesCapability.reject(t)}))}setPageLabels(t){if(this.pdfDocument){t?Array.isArray(t)&&this.pdfDocument.numPages===t.length?this._pageLabels=t:(this._pageLabels=null,console.error("setPageLabels: Invalid page labels.")):this._pageLabels=null;for(let t=0,e=this._pages.length;t<e;t++)this._pages[t].setPageLabel(this._pageLabels?.[t]??null)}}_resetView(){this._pages=[],this._currentPageNumber=1,this._currentScale=0,this._currentScaleValue=null,this._pageLabels=null,this.#Fh=new xl(10),this._location=null,this._pagesRotation=0,this._optionalContentConfigPromise=null,this._firstPageCapability=Promise.withResolvers(),this._onePageRenderedCapability=Promise.withResolvers(),this._pagesCapability=Promise.withResolvers(),this._scrollMode=$n.VERTICAL,this._previousScrollMode=$n.UNKNOWN,this._spreadMode=Wn.NONE,this.#Yh={previousPageNumber:1,scrollDown:!0,pages:[]},this.#tl?.abort(),this.#tl=null,this.viewer.textContent="",this._updateScrollMode(),this.viewer.removeAttribute("lang"),this.#Wh?.remove(),this.#Wh=null,this.#ad()}#rd(){if(this._scrollMode!==$n.PAGE)throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");const t=this._currentPageNumber,e=this.#Yh,i=this.viewer;if(i.textContent="",e.pages.length=0,this._spreadMode!==Wn.NONE||this.isInPresentationMode){const s=new Set,n=this._spreadMode-1;-1===n?s.add(t-1):t%2!==n?(s.add(t-1),s.add(t)):(s.add(t-2),s.add(t-1));const r=document.createElement("div");if(r.className="spread",this.isInPresentationMode){const t=document.createElement("div");t.className="dummyPage",r.append(t)}for(const t of s){const i=this._pages[t];i&&(r.append(i.div),e.pages.push(i))}i.append(r)}else{const s=this._pages[t-1];i.append(s.div),e.pages.push(s)}e.scrollDown=t>=e.previousPageNumber,e.previousPageNumber=t}_scrollUpdate(){0!==this.pagesCount&&this.update()}#od(t,e=null){const{div:i,id:s}=t;if(this._currentPageNumber!==s&&this._setCurrentPageNumber(s),this._scrollMode===$n.PAGE&&(this.#rd(),this.update()),!e&&!this.isInPresentationMode){const t=i.offsetLeft+i.clientLeft,s=t+i.clientWidth,{scrollLeft:n,clientWidth:r}=this.container;(this._scrollMode===$n.HORIZONTAL||t<n||s>n+r)&&(e={left:0,top:0})}Gn(i,e),!this._currentScaleValue&&this._location&&(this._location=null)}#ld(t){return t===this._currentScale||Math.abs(t-this._currentScale)<1e-15}#hd(t,e,{noScroll:i=!1,preset:s=!1,drawingDelay:n=-1,origin:r=null}){if(this._currentScaleValue=e.toString(),this.#ld(t))return void(s&&this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:e}));this.viewer.style.setProperty("--scale-factor",t*ca.PDF_TO_CSS_UNITS);const a=n>=0&&n<1e3;this.refresh(!0,{scale:t,drawingDelay:a?n:-1}),a&&(this.#Qh=setTimeout((()=>{this.#Qh=null,this.refresh()}),n));const o=this._currentScale;if(this._currentScale=t,!i){let e,i=this._currentPageNumber;if(!this._location||this.isInPresentationMode||this.isChangingPresentationMode||(i=this._location.pageNumber,e=[null,{name:"XYZ"},this._location.left,this._location.top,null]),this.scrollPageIntoView({pageNumber:i,destArray:e,allowNegativeOffset:!0}),Array.isArray(r)){const e=t/o-1,[i,s]=this.containerTopLeft;this.container.scrollLeft+=(r[0]-s)*e,this.container.scrollTop+=(r[1]-i)*e}}this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:s?e:void 0}),this.defaultRenderingQueue&&this.update()}get#dd(){return this._spreadMode!==Wn.NONE&&this._scrollMode!==$n.HORIZONTAL?2:1}#ed(t,e){let i=parseFloat(t);if(i>0)e.preset=!1,this.#hd(i,t,e);else{const s=this._pages[this._currentPageNumber-1];if(!s)return;let n=40,r=5;this.isInPresentationMode?(n=r=4,this._spreadMode!==Wn.NONE&&(n*=2)):this.removePageBorders?n=r=0:this._scrollMode===$n.HORIZONTAL&&([n,r]=[r,n]);const a=(this.container.clientWidth-n)/s.width*s.scale/this.#dd,o=(this.container.clientHeight-r)/s.height*s.scale;switch(t){case"page-actual":i=1;break;case"page-width":i=a;break;case"page-height":i=o;break;case"page-fit":i=Math.min(a,o);break;case"auto":const e=tr(s)?a:Math.min(o,a);i=Math.min(1.25,e);break;default:return void console.error(`#setScale: "${t}" is an unknown zoom value.`)}e.preset=!0,this.#hd(i,t,e)}}#td(){const t=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&this.#ed(this._currentScaleValue,{noScroll:!0}),this.#od(t)}pageLabelToPageNumber(t){if(!this._pageLabels)return null;const e=this._pageLabels.indexOf(t);return e<0?null:e+1}scrollPageIntoView({pageNumber:t,destArray:e=null,allowNegativeOffset:i=!1,ignoreDestinationZoom:s=!1}){if(!this.pdfDocument)return;const n=Number.isInteger(t)&&this._pages[t-1];if(!n)return void console.error(`scrollPageIntoView: "${t}" is not a valid pageNumber parameter.`);if(this.isInPresentationMode||!e)return void this._setCurrentPageNumber(t,!0);let r,a,o=0,l=0,h=0,d=0;const c=n.rotation%180!=0,u=(c?n.height:n.width)/n.scale/ca.PDF_TO_CSS_UNITS,p=(c?n.width:n.height)/n.scale/ca.PDF_TO_CSS_UNITS;let g=0;switch(e[1].name){case"XYZ":o=e[2],l=e[3],g=e[4],o=null!==o?o:0,l=null!==l?l:p;break;case"Fit":case"FitB":g="page-fit";break;case"FitH":case"FitBH":l=e[2],g="page-width",null===l&&this._location?(o=this._location.left,l=this._location.top):("number"!=typeof l||l<0)&&(l=p);break;case"FitV":case"FitBV":o=e[2],h=u,d=p,g="page-height";break;case"FitR":o=e[2],l=e[3],h=e[4]-o,d=e[5]-l;let t=40,i=5;this.removePageBorders&&(t=i=0),r=(this.container.clientWidth-t)/h/ca.PDF_TO_CSS_UNITS,a=(this.container.clientHeight-i)/d/ca.PDF_TO_CSS_UNITS,g=Math.min(Math.abs(r),Math.abs(a));break;default:return void console.error(`scrollPageIntoView: "${e[1].name}" is not a valid destination type.`)}if(s||(g&&g!==this._currentScale?this.currentScaleValue=g:0===this._currentScale&&(this.currentScaleValue="auto")),"page-fit"===g&&!e[4])return void this.#od(n);const f=[n.viewport.convertToViewportPoint(o,l),n.viewport.convertToViewportPoint(o+h,l+d)];let m=Math.min(f[0][0],f[1][0]),b=Math.min(f[0][1],f[1][1]);i||(m=Math.max(m,0),b=Math.max(b,0)),this.#od(n,{left:m,top:b})}_updateLocation(t){const e=this._currentScale,i=this._currentScaleValue,s=parseFloat(i)===e?Math.round(1e4*e)/100:i,n=t.id,r=this._pages[n-1],a=this.container,o=r.getPagePoint(a.scrollLeft-t.x,a.scrollTop-t.y),l=Math.round(o[0]),h=Math.round(o[1]);let d=`#page=${n}`;this.isInPresentationMode||(d+=`&zoom=${s},${l},${h}`),this._location={pageNumber:n,scale:s,top:h,left:l,rotation:this._pagesRotation,pdfOpenParams:d}}update(){const t=this._getVisiblePages(),e=t.views,i=e.length;if(0===i)return;const s=Math.max(10,2*i+1);this.#Fh.resize(s,t.ids),this.renderingQueue.renderHighestPriority(t);const n=this._spreadMode===Wn.NONE&&(this._scrollMode===$n.PAGE||this._scrollMode===$n.VERTICAL),r=this._currentPageNumber;let a=!1;for(const t of e){if(t.percent<100)break;if(t.id===r&&n){a=!0;break}}this._setCurrentPageNumber(a?r:e[0].id),this._updateLocation(t.first),this.eventBus.dispatch("updateviewarea",{source:this,location:this._location})}#cd(){const t=this._getVisiblePages(),e=[],{ids:i,views:s}=t;for(const t of s){const{view:s}=t;s.hasEditableAnnotations()?e.push(t):i.delete(s.id)}return 0===e.length?null:(this.renderingQueue.renderHighestPriority({first:e[0],last:e.at(-1),views:e,ids:i}),i)}containsElement(t){return this.container.contains(t)}focus(){this.container.focus()}get _isContainerRtl(){return"rtl"===getComputedStyle(this.container).direction}get isInPresentationMode(){return this.presentationModeState===Vn}get isChangingPresentationMode(){return this.presentationModeState===jn}get isHorizontalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollWidth>this.container.clientWidth}get isVerticalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollHeight>this.container.clientHeight}_getVisiblePages(){const t=this._scrollMode===$n.PAGE?this.#Yh.pages:this._pages,e=this._scrollMode===$n.HORIZONTAL,i=e&&this._isContainerRtl;return function({scrollEl:t,views:e,sortByVisibility:i=!1,horizontal:s=!1,rtl:n=!1}){const r=t.scrollTop,a=r+t.clientHeight,o=t.scrollLeft,l=o+t.clientWidth,h=[],d=new Set,c=e.length;let u=Yn(e,s?function(t){const e=t.div,i=e.offsetLeft+e.clientLeft,s=i+e.clientWidth;return n?i<l:s>o}:function(t){const e=t.div;return e.offsetTop+e.clientTop+e.clientHeight>r});u>0&&u<c&&!s&&(u=function(t,e,i){if(t<2)return t;let s=e[t].div,n=s.offsetTop+s.clientTop;n>=i&&(s=e[t-1].div,n=s.offsetTop+s.clientTop);for(let i=t-2;i>=0&&(s=e[i].div,!(s.offsetTop+s.clientTop+s.clientHeight<=n));--i)t=i;return t}(u,e,r));let p=s?l:-1;for(let t=u;t<c;t++){const i=e[t],n=i.div,c=n.offsetLeft+n.clientLeft,u=n.offsetTop+n.clientTop,g=n.clientWidth,f=n.clientHeight,m=c+g,b=u+f;if(-1===p)b>=a&&(p=b);else if((s?c:u)>p)break;if(b<=r||u>=a||m<=o||c>=l)continue;const v=Math.max(0,r-u)+Math.max(0,b-a),w=(g-(Math.max(0,o-c)+Math.max(0,m-l)))/g,y=(f-v)/f*w*100|0;h.push({id:i.id,x:c,y:u,view:i,percent:y,widthPercent:100*w|0}),d.add(i.id)}const g=h[0],f=h.at(-1);return i&&h.sort((function(t,e){const i=t.percent-e.percent;return Math.abs(i)>.001?-i:t.id-e.id})),{first:g,last:f,views:h,ids:d}}({scrollEl:this.container,views:t,sortByVisibility:!0,horizontal:e,rtl:i})}cleanup(){for(const t of this._pages)t.renderingState!==Fn.FINISHED&&t.reset()}_cancelRendering(){for(const t of this._pages)t.cancelRendering()}async#ud(t){if(t.pdfPage)return t.pdfPage;try{const e=await this.pdfDocument.getPage(t.id);return t.pdfPage||t.setPdfPage(e),e}catch(t){return console.error("Unable to get page for page view",t),null}}#pd(t){if(1===t.first?.id)return!0;if(t.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case $n.PAGE:return this.#Yh.scrollDown;case $n.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(t){const e=t||this._getVisiblePages(),i=this.#pd(e),s=this._spreadMode!==Wn.NONE&&this._scrollMode!==$n.HORIZONTAL,n=this.renderingQueue.getHighestPriority(e,this._pages,i,s);return!!n&&(this.#ud(n).then((()=>{this.renderingQueue.renderView(n)})),!0)}get hasEqualPageSizes(){const t=this._pages[0];for(let e=1,i=this._pages.length;e<i;++e){const i=this._pages[e];if(i.width!==t.width||i.height!==t.height)return!1}return!0}getPagesOverview(){let t;return this._pages.map((e=>{const i=e.pdfPage.getViewport({scale:1}),s=tr(i);if(void 0===t)t=s;else if(this.enablePrintAutoRotate&&s!==t)return{width:i.height,height:i.width,rotation:(i.rotation-90)%360};return{width:i.width,height:i.height,rotation:i.rotation}}))}get optionalContentConfigPromise(){return this.pdfDocument?this._optionalContentConfigPromise?this._optionalContentConfigPromise:(console.error("optionalContentConfigPromise: Not initialized yet."),this.pdfDocument.getOptionalContentConfig({intent:"display"})):Promise.resolve(null)}set optionalContentConfigPromise(t){if(!(t instanceof Promise))throw new Error(`Invalid optionalContentConfigPromise: ${t}`);this.pdfDocument&&this._optionalContentConfigPromise&&(this._optionalContentConfigPromise=t,this.refresh(!1,{optionalContentConfigPromise:t}),this.eventBus.dispatch("optionalcontentconfigchanged",{source:this,promise:t}))}get scrollMode(){return this._scrollMode}set scrollMode(t){if(this._scrollMode!==t){if(!function(t){return Number.isInteger(t)&&Object.values($n).includes(t)&&t!==$n.UNKNOWN}(t))throw new Error(`Invalid scroll mode: ${t}`);this.pagesCount>wl||(this._previousScrollMode=this._scrollMode,this._scrollMode=t,this.eventBus.dispatch("scrollmodechanged",{source:this,mode:t}),this._updateScrollMode(this._currentPageNumber))}}_updateScrollMode(t=null){const e=this._scrollMode,i=this.viewer;i.classList.toggle("scrollHorizontal",e===$n.HORIZONTAL),i.classList.toggle("scrollWrapped",e===$n.WRAPPED),this.pdfDocument&&t&&(e===$n.PAGE?this.#rd():this._previousScrollMode===$n.PAGE&&this._updateSpreadMode(),this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#ed(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}get spreadMode(){return this._spreadMode}set spreadMode(t){if(this._spreadMode!==t){if(!function(t){return Number.isInteger(t)&&Object.values(Wn).includes(t)&&t!==Wn.UNKNOWN}(t))throw new Error(`Invalid spread mode: ${t}`);this._spreadMode=t,this.eventBus.dispatch("spreadmodechanged",{source:this,mode:t}),this._updateSpreadMode(this._currentPageNumber)}}_updateSpreadMode(t=null){if(!this.pdfDocument)return;const e=this.viewer,i=this._pages;if(this._scrollMode===$n.PAGE)this.#rd();else if(e.textContent="",this._spreadMode===Wn.NONE)for(const t of this._pages)e.append(t.div);else{const t=this._spreadMode-1;let s=null;for(let n=0,r=i.length;n<r;++n)null===s?(s=document.createElement("div"),s.className="spread",e.append(s)):n%2===t&&(s=s.cloneNode(!1),e.append(s)),s.append(i[n].div)}t&&(this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#ed(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}_getPageAdvance(t,e=!1){switch(this._scrollMode){case $n.WRAPPED:{const{views:i}=this._getVisiblePages(),s=new Map;for(const{id:t,y:e,percent:n,widthPercent:r}of i){if(0===n||r<100)continue;let i=s.get(e);i||s.set(e,i||=[]),i.push(t)}for(const i of s.values()){const s=i.indexOf(t);if(-1===s)continue;const n=i.length;if(1===n)break;if(e)for(let e=s-1,n=0;e>=n;e--){const s=i[e],n=i[e+1]-1;if(s<n)return t-n}else for(let e=s+1,r=n;e<r;e++){const s=i[e],n=i[e-1]+1;if(s>n)return n-t}if(e){const e=i[0];if(e<t)return t-e+1}else{const e=i[n-1];if(e>t)return e-t+1}break}break}case $n.HORIZONTAL:break;case $n.PAGE:case $n.VERTICAL:{if(this._spreadMode===Wn.NONE)break;const i=this._spreadMode-1;if(e&&t%2!==i)break;if(!e&&t%2===i)break;const{views:s}=this._getVisiblePages(),n=e?t-1:t+1;for(const{id:t,percent:e,widthPercent:i}of s)if(t===n){if(e>0&&100===i)return 2;break}break}}return 1}nextPage(){const t=this._currentPageNumber,e=this.pagesCount;if(t>=e)return!1;const i=this._getPageAdvance(t,!1)||1;return this.currentPageNumber=Math.min(t+i,e),!0}previousPage(){const t=this._currentPageNumber;if(t<=1)return!1;const e=this._getPageAdvance(t,!0)||1;return this.currentPageNumber=Math.max(t-e,1),!0}updateScale({drawingDelay:t,scaleFactor:e=null,steps:i=null,origin:s}){if(null===i&&null===e)throw new Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided.");if(!this.pdfDocument)return;let n=this._currentScale;if(e>0&&1!==e)n=Math.round(n*e*100)/100;else if(i){const t=i>0?1.1:1/1.1,e=i>0?Math.ceil:Math.floor;i=Math.abs(i);do{n=e(10*(n*t).toFixed(2))/10}while(--i>0)}n=Math.max(.1,Math.min(10,n)),this.#ed(n,{noScroll:!1,drawingDelay:t,origin:s})}increaseScale(t={}){this.updateScale({...t,steps:t.steps??1})}decreaseScale(t={}){this.updateScale({...t,steps:-(t.steps??1)})}#Zh(t=this.container.clientHeight){t!==this.#qh&&(this.#qh=t,er.setProperty("--viewer-container-height",`${t}px`))}#Kh(t){for(const e of t)if(e.target===this.container){this.#Zh(Math.floor(e.borderBoxSize[0].blockSize)),this.#Vh=null;break}}get containerTopLeft(){return this.#Vh||=[this.container.offsetTop,this.container.offsetLeft]}#ad(){this.#zh?.abort(),this.#zh=null,null!==this.#Uh&&(clearTimeout(this.#Uh),this.#Uh=null)}get annotationEditorMode(){return this.#jh?this.#Bh:Nr.DISABLE}set annotationEditorMode({mode:t,editId:e=null,isFromKeyboard:i=!1}){if(!this.#jh)throw new Error("The AnnotationEditor is not enabled.");if(this.#Bh===t)return;if(!_l(t))throw new Error(`Invalid AnnotationEditor mode: ${t}`);if(!this.pdfDocument)return;t===Nr.STAMP&&this.#nt?.loadModel("altText");const{eventBus:s}=this,n=()=>{this.#ad(),this.#Bh=t,this.#jh.updateMode(t,e,i),s.dispatch("annotationeditormodechanged",{source:this,mode:t})};if(t===Nr.NONE||this.#Bh===Nr.NONE){const e=t!==Nr.NONE;e||this.pdfDocument.annotationStorage.resetModifiedIds();for(const t of this._pages)t.toggleEditingMode(e);const i=this.#cd();if(e&&i){this.#ad(),this.#zh=new AbortController;const t=AbortSignal.any([this.#tl.signal,this.#zh.signal]);return void s._on("pagerendered",(({pageNumber:t})=>{i.delete(t),0===i.size&&(this.#Uh=setTimeout(n,0))}),{signal:t})}}n()}refresh(t=!1,e=Object.create(null)){if(this.pdfDocument){for(const t of this._pages)t.update(e);null!==this.#Qh&&(clearTimeout(this.#Qh),this.#Qh=null),t||this.update()}}}class Cl extends Sl{_resetView(){super._resetView(),this._scrollMode=$n.PAGE,this._spreadMode=Wn.NONE}set scrollMode(t){}_updateScrollMode(){}set spreadMode(t){}_updateSpreadMode(){}}var El,Pl,Ml,Tl,kl,Il=Nn.DownloadManager,Ll=Nn.EventBus,Dl=Nn.GenericL10n,Rl=Nn.PDFLinkService,Nl=Nn.PDFSinglePageViewer,Fl=Nn.PDFViewer,Ol=Nn.SimpleLinkService,Bl=Nn.XfaLayerBuilder;function jl(t,e,i,s){return new(i||(i=Promise))((function(n,r){function a(t){try{l(s.next(t))}catch(t){r(t)}}function o(t){try{l(s.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}l((s=s.apply(t,e||[])).next())}))}function Vl(t,e,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(t):s?s.value:e.get(t)}function Hl(t,e,i,s,n){if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n?n.value=i:e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError;const zl={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},Ul={UNKNOWN:0,NORMAL:1,CHANGING:2,FULLSCREEN:3},$l={UNKNOWN:-1,NONE:0,THUMBS:1,OUTLINE:2,ATTACHMENTS:3,LAYERS:4},Wl={DISABLE:0,ENABLE:1,ENABLE_PERMISSIONS:2},Gl={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},ql={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};class Xl{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}}function Kl(t,e,i=!1){let s=t.offsetParent;if(!s)return void console.error("offsetParent is not set -- cannot scroll");let n=t.offsetTop+t.clientTop,r=t.offsetLeft+t.clientLeft;for(;s.clientHeight===s.scrollHeight&&s.clientWidth===s.scrollWidth||i&&(s.classList.contains("markedContent")||"hidden"===getComputedStyle(s).overflow);)if(n+=s.offsetTop,r+=s.offsetLeft,s=s.offsetParent,!s)return;e&&(void 0!==e.top&&(n+=e.top),void 0!==e.left&&(r+=e.left,s.scrollLeft=r)),s.scrollTop=n}function Yl(t,e,i=void 0){const s=function(i){r||(r=window.requestAnimationFrame((function(){r=null;const i=t.scrollLeft,s=n.lastX;i!==s&&(n.right=i>s),n.lastX=i;const a=t.scrollTop,o=n.lastY;a!==o&&(n.down=a>o),n.lastY=a,e(n)})))},n={right:!0,down:!0,lastX:t.scrollLeft,lastY:t.scrollTop,_eventHandler:s};let r=null;return t.addEventListener("scroll",s,{useCapture:!0,signal:i}),null==i||i.addEventListener("abort",(()=>window.cancelAnimationFrame(r)),{once:!0}),n}const Ql=/[\x00-\x1F]/g;function Jl(t,e,i=0){let s=i,n=t.length-1;if(n<0||!e(t[n]))return t.length;if(e(t[s]))return s;for(;s<n;){const i=s+n>>1;e(t[i])?n=i:s=i+1}return s}function Zl({view:t,userUnit:e,rotate:i}){const[s,n,r,a]=t,o=i%180!=0,l=(r-s)/72*e,h=(a-n)/72*e;return{width:o?h:l,height:o?l:h}}function th(t,e,i){if(t<2)return t;let s=e[t].div,n=s.offsetTop+s.clientTop;n>=i&&(s=e[t-1].div,n=s.offsetTop+s.clientTop);for(let i=t-2;i>=0&&(s=e[i].div,!(s.offsetTop+s.clientTop+s.clientHeight<=n));--i)t=i;return t}function eh({scrollEl:t,views:e,sortByVisibility:i=!1,horizontal:s=!1,rtl:n=!1}){const r=t.scrollTop,a=r+t.clientHeight,o=t.scrollLeft,l=o+t.clientWidth;const h=[],d=new Set,c=e.length;let u=Jl(e,s?function(t){const e=t.div,i=e.offsetLeft+e.clientLeft,s=i+e.clientWidth;return n?i<l:s>o}:function(t){const e=t.div;return e.offsetTop+e.clientTop+e.clientHeight>r});u>0&&u<c&&!s&&(u=th(u,e,r));let p=s?l:-1;for(let t=u;t<c;t++){const i=e[t],n=i.div,c=n.offsetLeft+n.clientLeft,u=n.offsetTop+n.clientTop,g=n.clientWidth,f=n.clientHeight,m=c+g,b=u+f;if(-1===p)b>=a&&(p=b);else if((s?c:u)>p)break;if(b<=r||u>=a||m<=o||c>=l)continue;const v=Math.max(0,r-u)+Math.max(0,b-a),w=(g-(Math.max(0,o-c)+Math.max(0,m-l)))/g,y=(f-v)/f*w*100|0;h.push({id:i.id,x:c,y:u,view:i,percent:y,widthPercent:100*w|0}),d.add(i.id)}const g=h[0],f=h.at(-1);return i&&h.sort((function(t,e){const i=t.percent-e.percent;return Math.abs(i)>.001?-i:t.id-e.id})),{first:g,last:f,views:h,ids:d}}function ih(t){let e=Math.hypot(t.deltaX,t.deltaY);const i=Math.atan2(t.deltaY,t.deltaX);return-.25*Math.PI<i&&i<.75*Math.PI&&(e=-e),e}function sh(t){const e=t.deltaMode;let i=ih(t);return e===WheelEvent.DOM_DELTA_PIXEL?i/=900:e===WheelEvent.DOM_DELTA_LINE&&(i/=30),i}function nh(t){return Number.isInteger(t)&&t%90==0}function rh(t){return Number.isInteger(t)&&Object.values(Gl).includes(t)&&t!==Gl.UNKNOWN}function ah(t){return Number.isInteger(t)&&Object.values(ql).includes(t)&&t!==ql.UNKNOWN}function oh(t){return t.width<=t.height}const lh=new Promise((function(t){window.requestAnimationFrame(t)})),hh=document.documentElement.style;El=new WeakMap,Pl=new WeakMap,Ml=new WeakMap,Tl=new WeakMap,kl=new WeakMap;const dh=function(){const t=document.createElement("div");return t.style.width="round(down, calc(1.6666666666666665 * 792px), 1px)","calc(1320px)"===t.style.width?Math.fround:t=>t}();class ch{constructor(){this.pdfViewer=null,this.pdfThumbnailViewer=null,this.onIdle=null,this.highestPriorityPage=null,this.idleTimeout=null,this.printing=!1,this.isThumbnailViewEnabled=!1,Object.defineProperty(this,"hasViewer",{value:()=>!!this.pdfViewer})}setViewer(t){this.pdfViewer=t}setThumbnailViewer(t){this.pdfThumbnailViewer=t}isHighestPriority(t){return this.highestPriorityPage===t.renderingId}renderHighestPriority(t){var e;this.idleTimeout&&(clearTimeout(this.idleTimeout),this.idleTimeout=null),this.pdfViewer.forceRendering(t)||this.isThumbnailViewEnabled&&(null===(e=this.pdfThumbnailViewer)||void 0===e?void 0:e.forceRendering())||this.printing||this.onIdle&&(this.idleTimeout=setTimeout(this.onIdle.bind(this),3e4))}getHighestPriority(t,e,i,s=!1){const n=t.views,r=n.length;if(0===r)return null;for(let t=0;t<r;t++){const e=n[t].view;if(!this.isViewFinished(e))return e}const a=t.first.id,o=t.last.id;if(o-a+1>r){const s=t.ids;for(let t=1,n=o-a;t<n;t++){const n=i?a+t:o-t;if(s.has(n))continue;const r=e[n-1];if(!this.isViewFinished(r))return r}}let l=i?o:a-2,h=e[l];return h&&!this.isViewFinished(h)||s&&(l+=i?1:-1,h=e[l],h&&!this.isViewFinished(h))?h:null}isViewFinished(t){return t.renderingState===zl.FINISHED}renderView(t){switch(t.renderingState){case zl.FINISHED:return!1;case zl.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case zl.RUNNING:this.highestPriorityPage=t.renderingId;break;case zl.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally((()=>{this.renderHighestPriority()})).catch((t=>{t instanceof kn||console.error("renderView:",t)}))}return!0}}var uh,ph,gh,fh,mh,bh,vh,wh;class yh{static getCanvas(t,e){const i=Hl(this,uh,Vl(this,uh,"f",ph)||document.createElement("canvas"),0,ph);i.width=t,i.height=e;const s=i.getContext("2d",{alpha:!1});return s.save(),s.fillStyle="rgb(255, 255, 255)",s.fillRect(0,0,t,e),s.restore(),[i,i.getContext("2d")]}static destroyCanvas(){const t=Vl(this,uh,"f",ph);t&&(t.width=0,t.height=0),Hl(this,uh,null,0,ph)}}uh=yh,ph={value:null};class Ah{constructor({container:t,eventBus:e,id:i,defaultViewport:s,optionalContentConfigPromise:n,linkService:r,renderingQueue:a,pageColors:o,enableHWA:l,store:h,thumbnailWidth:d}){gh.add(this),this.id=i,this.renderingId="thumbnail"+i,this.pageLabel=null,this.pdfPage=null,this.rotation=0,this.viewport=s,this.pdfPageRotate=s.rotation,this._optionalContentConfigPromise=n||null,this.pageColors=o||null,this.enableHWA=l||!1,this.eventBus=e,this.linkService=r,this.renderingQueue=a,this.renderTask=null,this.renderingState=zl.INITIAL,this.resume=null,this.store=h,this.thumbnailWidth=d,this.loaded=!1;const c=document.createElement("div");c.className="thumbnail pdfSlickThumbHolder",c.setAttribute("data-page-number",this.id.toString()),this.div=c,Vl(this,gh,"m",fh).call(this),t.append(c)}setPdfPage(t){this.pdfPage=t,this.pdfPageRotate=t.rotate;const e=(this.rotation+this.pdfPageRotate)%360;this.viewport=t.getViewport({scale:1,rotation:e}),this.reset()}reset(){this.cancelRendering(),this.renderingState=zl.INITIAL,this.div.removeAttribute("data-loaded"),this.loaded=!1,Vl(this,gh,"m",fh).call(this)}update({rotation:t=null}){"number"==typeof t&&(this.rotation=t);const e=(this.rotation+this.pdfPageRotate)%360;this.viewport=this.viewport.clone({scale:1,rotation:e}),this.reset()}cancelRendering(){this.renderTask&&(this.renderTask.cancel(),this.renderTask=null),this.resume=null}draw(){return jl(this,void 0,void 0,(function*(){if(this.renderingState!==zl.INITIAL)return void console.error("Must be in new state before drawing");const{pdfPage:t}=this;if(!t)throw this.renderingState=zl.FINISHED,new Error("pdfPage is not loaded");this.renderingState=zl.RUNNING;const{ctx:e,canvas:i,transform:s}=Vl(this,gh,"m",mh).call(this,2),n={canvasContext:e,transform:s,viewport:this.viewport.clone({scale:2*this.scale}),optionalContentConfigPromise:this._optionalContentConfigPromise,pageColors:this.pageColors},r=this.renderTask=t.render(n);r.onContinue=t=>{if(!this.renderingQueue.isHighestPriority(this))return this.renderingState=zl.PAUSED,void(this.resume=()=>{this.renderingState=zl.RUNNING,t()});t()};const a=r.promise.then((()=>Vl(this,gh,"m",vh).call(this,r,i)),(t=>Vl(this,gh,"m",vh).call(this,r,i,t)));return a.finally((()=>{i.width=0,i.height=0,this.eventBus.dispatch("thumbnailrendered",{source:this,pageNumber:this.id,pdfPage:this.pdfPage})})),a}))}setImage(t){if(this.renderingState!==zl.INITIAL)return;const{thumbnailCanvas:e,pdfPage:i,scale:s}=t;e&&(this.pdfPage||this.setPdfPage(i),s<this.scale||(this.renderingState=zl.FINISHED,Vl(this,gh,"m",bh).call(this,e)))}setPageLabel(t){this.pageLabel="string"==typeof t?t:null}}var _h,xh,Sh,Ch,Eh,Ph,Mh;gh=new WeakSet,fh=function(){const{width:t,height:e}=this.viewport,i=t/e;this.canvasWidth=this.thumbnailWidth,this.canvasHeight=this.canvasWidth/i|0,this.scale=this.canvasWidth/t;const{style:s}=this.div;s.setProperty("--thumbnail-width",`${this.canvasWidth}px`),s.setProperty("--thumbnail-height",`${this.canvasHeight}px`)},mh=function(t=1,e=this.enableHWA){const i=document.createElement("canvas"),s=i.getContext("2d",{alpha:!1,willReadFrequently:!e}),n=new Xl;i.width=t*this.canvasWidth*n.sx|0,i.height=t*this.canvasHeight*n.sy|0;return{ctx:s,canvas:i,transform:n.scaled?[n.sx,0,0,n.sy,0,0]:null}},bh=function(t){if(this.renderingState!==zl.FINISHED)throw new Error("#convertCanvasToImage: Rendering has not finished.");const e=Vl(this,gh,"m",wh).call(this,t);this.src=e.toDataURL(),this.div.setAttribute("data-loaded","true"),this.loaded=!0,this.store.getState()._setThumbnailView(this.id,this),e.width=0,e.height=0},vh=function(t,e){return jl(this,arguments,void 0,(function*(t,e,i=null){if(t===this.renderTask&&(this.renderTask=null),!(i instanceof kn)&&(this.renderingState=zl.FINISHED,Vl(this,gh,"m",bh).call(this,e),i))throw i}))},wh=function(t){const{ctx:e,canvas:i}=Vl(this,gh,"m",mh).call(this,1,!0);if(t.width<=2*i.width)return e.drawImage(t,0,0,t.width,t.height,0,0,i.width,i.height),i;let s=i.width<<3,n=i.height<<3;const[r,a]=yh.getCanvas(s,n);for(;s>t.width||n>t.height;)s>>=1,n>>=1;for(a.drawImage(t,0,0,t.width,t.height,0,0,s,n);s>2*i.width;)a.drawImage(r,0,0,s,n,0,0,s>>1,n>>1),s>>=1,n>>=1;return e.drawImage(r,0,0,s,n,0,0,i.width,i.height),i};const Th="selected";class kh{constructor({container:t,eventBus:e,linkService:i,renderingQueue:s,pageColors:n,abortSignal:r,enableHWA:a,store:o,thumbnailWidth:l}){_h.add(this),this.container=t,this.eventBus=e,this.linkService=i,this.renderingQueue=s,this.pageColors=n||null,this.enableHWA=a||!1,this.store=o,this.thumbnailWidth=l,this.scroll=Yl(this.container,Vl(this,_h,"m",xh).bind(this),r),Vl(this,_h,"m",Ch).call(this)}getThumbnail(t){return this._thumbnails[t]}scrollThumbnailIntoView(t){if(!this.pdfDocument)return;const e=this._thumbnails[t-1];if(!e)return void console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');if(t!==this._currentPageNumber){this._thumbnails[this._currentPageNumber-1].div.classList.remove(Th),e.div.classList.add(Th)}const{first:i,last:s,views:n}=Vl(this,_h,"m",Sh).call(this);if(n.length>0){let r=!1;if(t<=i.id||t>=s.id)r=!0;else for(const{id:e,percent:i}of n)if(e===t){r=i<100;break}r&&Kl(e.div,{top:-19})}this._currentPageNumber=t}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!nh(t))throw new Error("Invalid thumbnails rotation angle.");if(!this.pdfDocument)return;if(this._pagesRotation===t)return;this._pagesRotation=t;const e={rotation:t};for(const t of this._thumbnails)t.update(e)}cleanup(){for(const t of this._thumbnails)t.renderingState!==zl.FINISHED&&t.reset();yh.destroyCanvas()}setDocument(t){if(this.pdfDocument&&(Vl(this,_h,"m",Eh).call(this),Vl(this,_h,"m",Ch).call(this)),this.pdfDocument=t,!t)return;const e=t.getPage(1),i=t.getOptionalContentConfig({intent:"display"});e.then((e=>{var s;const n=t.numPages,r=e.getViewport({scale:1});for(let t=1;t<=n;++t){const e=new Ah({container:this.container,eventBus:this.eventBus,id:t,defaultViewport:r.clone(),optionalContentConfigPromise:i,linkService:this.linkService,renderingQueue:this.renderingQueue,pageColors:this.pageColors,enableHWA:this.enableHWA,store:this.store,thumbnailWidth:this.thumbnailWidth});this._thumbnails.push(e)}null===(s=this._thumbnails[0])||void 0===s||s.setPdfPage(e);this._thumbnails[this._currentPageNumber-1].div.classList.add(Th),this.store.getState()._setThumbnailsViews(this._thumbnails)})).catch((t=>{console.error("Unable to initialize thumbnail viewer",t)}))}setPageLabels(t){var e,i;if(this.pdfDocument){t?Array.isArray(t)&&this.pdfDocument.numPages===t.length?this._pageLabels=t:(this._pageLabels=null,console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.")):this._pageLabels=null;for(let t=0,s=this._thumbnails.length;t<s;t++)this._thumbnails[t].setPageLabel(null!==(i=null===(e=this._pageLabels)||void 0===e?void 0:e[t])&&void 0!==i?i:null)}}forceRendering(){const t=Vl(this,_h,"m",Sh).call(this),e=Vl(this,_h,"m",Mh).call(this,t),i=this.renderingQueue.getHighestPriority(t,this._thumbnails,e);return!!i&&(Vl(this,_h,"m",Ph).call(this,i).then((()=>{this.renderingQueue.renderView(i)})),!0)}}_h=new WeakSet,xh=function(){this.renderingQueue.renderHighestPriority()},Sh=function(){return eh({scrollEl:this.container,views:this._thumbnails})},Ch=function(){this._thumbnails=[],this._currentPageNumber=1,this._pageLabels=null,this._pagesRotation=0,this.container.textContent=""},Eh=function(){for(const t of this._thumbnails)t.cancelRendering()},Ph=function(t){return jl(this,void 0,void 0,(function*(){if(t.pdfPage)return t.pdfPage;try{const e=yield this.pdfDocument.getPage(t.id);return t.pdfPage||t.setPdfPage(e),e}catch(t){return console.error("Unable to get page for thumb view",t),null}}))},Mh=function(t){var e,i;return 1===(null===(e=t.first)||void 0===e?void 0:e.id)||(null===(i=t.last)||void 0===i?void 0:i.id)!==this._thumbnails.length&&this.scroll.down};let Ih=null;class Lh{constructor({pdfDocument:t,pagesOverview:e,printContainer:i,printResolution:s,printAnnotationStoragePromise:n=null}){this.pdfDocument=t,this.pagesOverview=e,this.printContainer=i,this._printResolution=s||150,this._optionalContentConfigPromise=t.getOptionalContentConfig({intent:"print"}),this._printAnnotationStoragePromise=n||Promise.resolve(),this.currentPage=-1,this.scratchCanvas=document.createElement("canvas")}layout(){this.throwIfInactive();const t=document.querySelector("body");t.setAttribute("data-pdfjsprinting","true");const{width:e,height:i}=this.pagesOverview[0];this.pagesOverview.every((t=>t.width===e&&t.height===i))||console.warn("Not all pages have the same size. The printed result may be incorrect!"),this.pageStyleSheet=document.createElement("style"),this.pageStyleSheet.textContent=`@page { size: ${e}pt ${i}pt;}`,t.append(this.pageStyleSheet)}destroy(){if(Ih!==this)return;this.printContainer.textContent="";document.querySelector("body").removeAttribute("data-pdfjsprinting"),this.pageStyleSheet&&(this.pageStyleSheet.remove(),this.pageStyleSheet=null),this.scratchCanvas.width=this.scratchCanvas.height=0,this.scratchCanvas=null,Ih=null}renderPages(t){if(this.pdfDocument.isPureXfa)return function(t,e){const i=e.allXfaHtml,s=new Ol,n=Math.round(100*Tn.PDF_TO_CSS_UNITS)/100;for(const r of null==i?void 0:i.children){const i=document.createElement("div");i.className="xfaPrintedPage",t.append(i);const a=new Bl({pdfPage:null,annotationStorage:e.annotationStorage,linkService:s,xfaHtml:r}),o=Dn(r,{scale:n});a.render(o,"print"),i.append(a.div)}}(this.printContainer,this.pdfDocument),Promise.resolve();const e=this.pagesOverview.length,i=(s,n)=>{if(this.throwIfInactive(),++this.currentPage>=e)return t({index:e,total:e}),void s();const r=this.currentPage;t({index:r,total:e}),function(t,e,i,s,n,r,a){const o=t.scratchCanvas,l=n/Tn.PDF;o.width=Math.floor(s.width*l),o.height=Math.floor(s.height*l);const h=o.getContext("2d");return h.save(),h.fillStyle="rgb(255, 255, 255)",h.fillRect(0,0,o.width,o.height),h.restore(),Promise.all([e.getPage(i),a]).then((function([t,e]){const i={canvasContext:h,transform:[l,0,0,l,0,0],viewport:t.getViewport({scale:1,rotation:s.rotation}),intent:"print",annotationMode:En.ENABLE_STORAGE,optionalContentConfigPromise:r,printAnnotationStorage:e};return t.render(i).promise.catch((t=>{throw t instanceof kn||console.error(t),t}))}))}(this,this.pdfDocument,r+1,this.pagesOverview[r],this._printResolution,this._optionalContentConfigPromise,this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then((function(){i(s,n)}),n)};return new Promise(i)}useRenderedPage(){this.throwIfInactive();const t=document.createElement("img");this.scratchCanvas.toBlob((e=>{t.src=URL.createObjectURL(e)}));const e=document.createElement("div");e.className="printedPage",e.append(t),this.printContainer.append(e);const{promise:i,resolve:s,reject:n}=Promise.withResolvers();return t.onload=s,t.onerror=n,i.catch((()=>{})).then((()=>{URL.revokeObjectURL(t.src)})),i}performPrint(){return this.throwIfInactive(),new Promise((t=>{setTimeout((()=>{this.active?(window.print(),setTimeout(t,20)):t()}),0)}))}get active(){return this===Ih}throwIfInactive(){if(!this.active)throw new Error("This print request was cancelled or completed.")}}const Dh={instance:{supportsPrinting:!0,createPrintService(t){if(Ih)throw new Error("The print service is created and active.");return Ih=new Lh(t)}}};var Rh,Nh,Fh,Oh,Bh,jh,Vh,Hh,zh,Uh,$h,Wh,Gh,qh,Xh,Kh,Yh,Qh,Jh;const Zh="pdfPresentationMode",td="pdfPresentationModeControls",ed=Math.PI/6;class id{constructor({container:t,pdfViewer:e,eventBus:i}){Rh.add(this),Nh.set(this,Ul.UNKNOWN),Fh.set(this,null),Oh.set(this,null),Bh.set(this,null),this.container=t,this.pdfViewer=e,this.eventBus=i,this.contextMenuOpen=!1,this.mouseScrollTimeStamp=0,this.mouseScrollDelta=0,this.touchSwipeState=null}request(){return jl(this,void 0,void 0,(function*(){const{container:t,pdfViewer:e}=this;if(this.active||!e.pagesCount||!t.requestFullscreen)return!1;Vl(this,Rh,"m",Qh).call(this),Vl(this,Rh,"m",Vh).call(this,Ul.CHANGING);const i=t.requestFullscreen();Hl(this,Fh,{pageNumber:e.currentPageNumber,scaleValue:e.currentScaleValue,scrollMode:e.scrollMode,spreadMode:null,annotationEditorMode:null}),e.spreadMode===ql.NONE||e.pageViewsReady&&e.hasEqualPageSizes||(console.warn("Ignoring Spread modes when entering PresentationMode, since the document may contain varying page sizes."),Vl(this,Fh,"f").spreadMode=e.spreadMode),e.annotationEditorMode!==Cn.DISABLE&&(Vl(this,Fh,"f").annotationEditorMode=e.annotationEditorMode);try{return yield i,e.focus(),!0}catch(t){Vl(this,Rh,"m",Jh).call(this),Vl(this,Rh,"m",Vh).call(this,Ul.NORMAL)}return!1}))}get active(){return Vl(this,Nh,"f")===Ul.CHANGING||Vl(this,Nh,"f")===Ul.FULLSCREEN}}Nh=new WeakMap,Fh=new WeakMap,Oh=new WeakMap,Bh=new WeakMap,Rh=new WeakSet,jh=function(t){if(!this.active)return;t.preventDefault();const e=sh(t),i=Date.now(),s=this.mouseScrollTimeStamp;if(!(i>s&&i-s<50)&&((this.mouseScrollDelta>0&&e<0||this.mouseScrollDelta<0&&e>0)&&Vl(this,Rh,"m",qh).call(this),this.mouseScrollDelta+=e,Math.abs(this.mouseScrollDelta)>=.1)){const t=this.mouseScrollDelta;Vl(this,Rh,"m",qh).call(this);(t>0?this.pdfViewer.previousPage():this.pdfViewer.nextPage())&&(this.mouseScrollTimeStamp=i)}},Vh=function(t){Hl(this,Nh,t),this.eventBus.dispatch("presentationmodechanged",{source:this,state:t})},Hh=function(){var t;Vl(this,Rh,"m",Vh).call(this,Ul.FULLSCREEN),this.container.classList.add(Zh),setTimeout((()=>{this.pdfViewer.scrollMode=Gl.PAGE,null!==Vl(this,Fh,"f").spreadMode&&(this.pdfViewer.spreadMode=ql.NONE),this.pdfViewer.currentPageNumber=Vl(this,Fh,"f").pageNumber,this.pdfViewer.currentScaleValue="page-fit",null!==Vl(this,Fh,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:Cn.NONE})}),0),Vl(this,Rh,"m",Kh).call(this),Vl(this,Rh,"m",Wh).call(this),this.contextMenuOpen=!1,null===(t=document.getSelection())||void 0===t||t.empty()},zh=function(){const t=this.pdfViewer.currentPageNumber;this.container.classList.remove(Zh),setTimeout((()=>{Vl(this,Rh,"m",Jh).call(this),Vl(this,Rh,"m",Vh).call(this,Ul.NORMAL),this.pdfViewer.scrollMode=Vl(this,Fh,"f").scrollMode,null!==Vl(this,Fh,"f").spreadMode&&(this.pdfViewer.spreadMode=Vl(this,Fh,"f").spreadMode),this.pdfViewer.currentScaleValue=Vl(this,Fh,"f").scaleValue,this.pdfViewer.currentPageNumber=t,null!==Vl(this,Fh,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:Vl(this,Fh,"f").annotationEditorMode}),Hl(this,Fh,null)}),0),Vl(this,Rh,"m",Yh).call(this),Vl(this,Rh,"m",Gh).call(this),Vl(this,Rh,"m",qh).call(this),this.contextMenuOpen=!1},Uh=function(t){var e;if(this.contextMenuOpen)return this.contextMenuOpen=!1,void t.preventDefault();0===t.button&&(t.target.href&&(null===(e=t.target.parentNode)||void 0===e?void 0:e.hasAttribute("data-internal-link"))||(t.preventDefault(),t.shiftKey?this.pdfViewer.previousPage():this.pdfViewer.nextPage()))},$h=function(){this.contextMenuOpen=!0},Wh=function(){this.controlsTimeout?clearTimeout(this.controlsTimeout):this.container.classList.add(td),this.controlsTimeout=setTimeout((()=>{this.container.classList.remove(td),delete this.controlsTimeout}),3e3)},Gh=function(){this.controlsTimeout&&(clearTimeout(this.controlsTimeout),this.container.classList.remove(td),delete this.controlsTimeout)},qh=function(){this.mouseScrollTimeStamp=0,this.mouseScrollDelta=0},Xh=function(t){if(this.active)if(t.touches.length>1)this.touchSwipeState=null;else switch(t.type){case"touchstart":this.touchSwipeState={startX:t.touches[0].pageX,startY:t.touches[0].pageY,endX:t.touches[0].pageX,endY:t.touches[0].pageY};break;case"touchmove":if(null===this.touchSwipeState)return;this.touchSwipeState.endX=t.touches[0].pageX,this.touchSwipeState.endY=t.touches[0].pageY,t.preventDefault();break;case"touchend":if(null===this.touchSwipeState)return;let e=0;const i=this.touchSwipeState.endX-this.touchSwipeState.startX,s=this.touchSwipeState.endY-this.touchSwipeState.startY,n=Math.abs(Math.atan2(s,i));Math.abs(i)>50&&(n<=ed||n>=Math.PI-ed)?e=i:Math.abs(s)>50&&Math.abs(n-Math.PI/2)<=ed&&(e=s),e>0?this.pdfViewer.previousPage():e<0&&this.pdfViewer.nextPage()}},Kh=function(){if(Vl(this,Bh,"f"))return;Hl(this,Bh,new AbortController);const{signal:t}=Vl(this,Bh,"f"),e=Vl(this,Rh,"m",Xh).bind(this);window.addEventListener("mousemove",Vl(this,Rh,"m",Wh).bind(this),{signal:t}),window.addEventListener("mousedown",Vl(this,Rh,"m",Uh).bind(this),{signal:t}),window.addEventListener("wheel",Vl(this,Rh,"m",jh).bind(this),{passive:!1,signal:t}),window.addEventListener("keydown",Vl(this,Rh,"m",qh).bind(this),{signal:t}),window.addEventListener("contextmenu",Vl(this,Rh,"m",$h).bind(this),{signal:t}),window.addEventListener("touchstart",e,{signal:t}),window.addEventListener("touchmove",e,{signal:t}),window.addEventListener("touchend",e,{signal:t})},Yh=function(){var t;null===(t=Vl(this,Bh,"f"))||void 0===t||t.abort(),Hl(this,Bh,null)},Qh=function(){Vl(this,Oh,"f")||(Hl(this,Oh,new AbortController),window.addEventListener("fullscreenchange",(()=>{document.fullscreenElement?Vl(this,Rh,"m",Hh).call(this):Vl(this,Rh,"m",zh).call(this)}),{signal:Vl(this,Oh,"f").signal}))},Jh=function(){var t;null===(t=Vl(this,Oh,"f"))||void 0===t||t.abort(),Hl(this,Oh,null)};const sd={isDocumentLoaded:!1,pagesReady:!1,url:null,numPages:0,pageNumber:0,scale:0,scaleValue:"auto",pagesRotation:0,spreadMode:ql.UNKNOWN,scrollMode:Gl.UNKNOWN,documentOutline:null,attachments:new Map,thumbnails:new Map,thumbnailViews:new Map,annotationEditorMode:Cn.NONE,pdfSlick:null},nd=()=>{return(t=(t,e)=>Object.assign(Object.assign({},sd),{_setThumbnailView:(i,s)=>{const n=new Map(e().thumbnails),r=new Map(e().thumbnailViews),{canvasWidth:a,canvasHeight:o,scale:l,rotation:h,loaded:d,pageLabel:c,src:u=null}=s;r.set(i,s),n.set(i,{pageNumber:i,width:a,height:o,scale:l,rotation:h,loaded:d,pageLabel:c,src:u}),t({thumbnailViews:r,thumbnails:n})},_setThumbnailsViews:e=>{const i=new Map(e.map((t=>[t.id,t]))),s=new Map(e.map((t=>{const{canvasWidth:e,canvasHeight:i,scale:s,rotation:n,loaded:r,pageLabel:a,src:o=null}=t;return[t.id,{pageNumber:t.id,width:e,height:i,scale:s,rotation:n,loaded:r,pageLabel:a,src:o}]})));t({thumbnailViews:i,thumbnails:s})}}))?f(t):f;var t};var rd,ad,od,ld,hd,dd,cd,ud,pd,gd,fd,md,bd,vd,wd,yd,Ad,_d,xd,Sd,Cd,Ed,Pd,Md,Td,kd,Id;class Ld{constructor({eventBus:t,slick:e,printDialog:i}){rd.add(this),ad.set(this,null),od.set(this,null),ld.set(this,null),this.eventBus=t,this.slick=e,this.printDialog=null!=i?i:null,this.bindEvents()}get supportsPrinting(){return Dh.instance.supportsPrinting}get printing(){return!!Vl(this,ad,"f")}print(){return jl(this,void 0,void 0,(function*(){var t,e;if(this.supportsPrinting)if(this.printing)console.warn("Ignored pdf print because of a pending print job.");else{yield null===(t=this.printDialog)||void 0===t?void 0:t.open({close:()=>this.abort()});try{this.eventBus.dispatch("beforeprint",{source:this})}finally{if(this.printing){const t=Vl(this,ad,"f");yield t.renderPages((t=>{var e;return null===(e=this.printDialog)||void 0===e?void 0:e.progress(t)})).then((()=>t.performPrint())).catch((()=>{})).then((()=>{t===Vl(this,ad,"f")&&this.abort()}))}else console.error("Expected print service to be initialized."),null===(e=this.printDialog)||void 0===e||e.close()}}}))}abort(){var t;Vl(this,ad,"f")&&(Vl(this,ad,"f").destroy(),null===(t=this.printDialog)||void 0===t||t.close(),this.eventBus.dispatch("afterprint",{source:this}))}bindEvents(){Hl(this,od,new AbortController);const{signal:t}=Vl(this,od,"f"),e={signal:t};this.eventBus._on("beforeprint",Vl(this,rd,"m",hd).bind(this),e),this.eventBus._on("afterprint",Vl(this,rd,"m",dd).bind(this),e),window.addEventListener("beforeprint",(()=>this.eventBus.dispatch("beforeprint",{source:window})),e),window.addEventListener("afterprint",(()=>this.eventBus.dispatch("afterprint",{source:window})),e),window.addEventListener("keydown",(t=>{80!==t.keyCode||!t.ctrlKey&&!t.metaKey||t.altKey||t.shiftKey&&!window.chrome&&!window.opera||(this.print(),t.preventDefault(),t.stopImmediatePropagation())}),{signal:t,capture:!0})}unbindEvents(){var t;null===(t=Vl(this,od,"f"))||void 0===t||t.abort(),Hl(this,od,null)}}ad=new WeakMap,od=new WeakMap,ld=new WeakMap,rd=new WeakSet,hd=function(){Vl(this,ad,"f")||this.supportsPrinting&&(this.slick.viewer.pageViewsReady?(Hl(this,ld,function(){const t=document.createElement("div");t.classList.add("pdfSlickPrintContainer"),document.body.append(t);const e=document.createElement("style");return e.textContent="\n@page {\n margin: 0;\n}\n\n.pdfSlickPrintContainer {\n display: none;\n}\n\n@media print {\n body {\n background: rgb(0 0 0 / 0) none;\n }\n\n body[data-pdfjsprinting] > *:not(.pdfSlickPrintContainer) {\n display: none;\n }\n\n body[data-pdfjsprinting] .pdfSlickPrintContainer {\n display: block;\n }\n\n .pdfSlickPrintContainer {\n height: 100%;\n }\n\n /* wrapper around (scaled) print canvas elements */\n .pdfSlickPrintContainer > .printedPage {\n page-break-after: always;\n page-break-inside: avoid;\n\n /* The wrapper always cover the whole page. */\n height: 100%;\n width: 100%;\n\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n .pdfSlickPrintContainer > .xfaPrintedPage .xfaPage {\n position: absolute;\n }\n\n .pdfSlickPrintContainer > .xfaPrintedPage {\n page-break-after: always;\n page-break-inside: avoid;\n width: 100%;\n height: 100%;\n position: relative;\n }\n\n .pdfSlickPrintContainer > .printedPage :is(canvas, img) {\n /* The intrinsic canvas / image size will make sure that we fit the page. */\n max-width: 100%;\n max-height: 100%;\n\n direction: ltr;\n display: block;\n }\n}",document.body.append(e),{get element(){return t},remove:()=>{t.remove(),e.remove()}}}()),Hl(this,ad,Dh.instance.createPrintService({pdfDocument:this.slick.document,pagesOverview:this.slick.viewer.getPagesOverview(),printContainer:Vl(this,ld,"f").element,printResolution:this.slick.printResolution,optionalContentConfigPromise:null,printAnnotationStoragePromise:null})),this.slick.forceRendering(),Vl(this,ad,"f").layout()):this.slick.l10n.get("printing_not_ready",null).then((t=>{window.alert(t)})))},dd=function(){var t,e,i;Vl(this,ad,"f")&&(Vl(this,ad,"f").destroy(),Hl(this,ad,null),null===(t=this.printDialog)||void 0===t||t.close(),null===(e=Vl(this,ld,"f"))||void 0===e||e.remove(),Hl(this,ld,null),null===(i=this.slick.document)||void 0===i||i.annotationStorage.resetModified()),this.slick.forceRendering()};class Dd{static create(){let t=document.querySelector("#printServiceDialog");if(!t){const e=(t,e,i)=>{const s=document.createElement(t);return Object.entries(e).forEach((([t,e])=>s.setAttribute(t,e))),s.append(...i),s};t=e("dialog",{id:"printServiceDialog",class:"pdfSlick-dialog",style:"min-width: 200px;"},[e("div",{class:"row"},[e("span",{"data-l10n-id":"pdfjs-print-progress-message"},["Preparing document for printing…"])]),e("div",{class:"row"},[e("progress",{value:"0",max:"100"},[]),e("span",{"data-l10n-id":"pdfjs-print-progress-percent","data-l10n-args":'{ "progress": 0 }',class:"relative-progress"},["0%"])]),e("div",{class:"buttonRow"},[e("button",{id:"printCancel",class:"dialogButton",type:"button"},[e("span",{"data-l10n-id":"pdfjs-print-progress-close-button"},["Cancel"])])])]),document.body.append(t)}return new Dd(t)}constructor(t){this.dialog=t}open(t){return jl(this,void 0,void 0,(function*(){const e=this.dialog.querySelector("#printCancel"),i=()=>{var s;this.dialog.removeEventListener("close",i),this.dialog.removeEventListener("cancel",i),null==e||e.removeEventListener("click",i),null===(s=null==t?void 0:t.close)||void 0===s||s.call(t),this.close()};this.dialog.addEventListener("close",i),this.dialog.addEventListener("cancel",i),null==e||e.addEventListener("click",i),this.dialog.showModal()}))}close(){this.dialog.close()}progress({index:t,total:e}){const i=Math.round(100*t/e),s=this.dialog.querySelector("progress"),n=this.dialog.querySelector(".relative-progress");s.value=i,n.setAttribute("data-l10n-args",JSON.stringify({progress:i}))}}Pn.workerSrc=new URL("pdfjs-dist/build/pdf.worker.min.mjs","undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:n&&"SCRIPT"===n.tagName.toUpperCase()&&n.src||new URL("index.js",document.baseURI).href).toString();const Rd={"8.5x11":"Letter","8.5x14":"Legal"},Nd={"297x420":"A3","210x297":"A4"};function Fd(t,e,i){return i[`${e?t.width:t.height}x${e?t.height:t.width}`]}class Od{constructor({container:t,viewer:e,thumbs:i,store:s=nd(),options:n,onError:r,printDialog:a}){var o,l,h,d,c,u,p,g,f,m,b,v,w,y,A;cd.add(this),ud.set(this,void 0),pd.set(this,void 0),gd.set(this,void 0),fd.set(this,void 0),md.set(this,void 0),this.downloadManager=null,this.findController=null,this.pdfPresentationMode=null,this.document=null,bd.set(this,void 0),vd.set(this,void 0),wd.set(this,void 0),yd.set(this,void 0),Hl(this,pd,t),Hl(this,gd,e),Hl(this,fd,i),Hl(this,wd,r),this.l10n=null!==(o=null==n?void 0:n.l10n)&&void 0!==o?o:new Dl(navigator.language),this.downloadManager=new Il,this.textLayerMode=null!==(l=null==n?void 0:n.textLayerMode)&&void 0!==l?l:Wl.ENABLE,Hl(this,bd,null!==(h=null==n?void 0:n.annotationMode)&&void 0!==h?h:En.ENABLE_FORMS),Hl(this,vd,null!==(d=null==n?void 0:n.annotationEditorMode)&&void 0!==d?d:Cn.NONE),this.annotationEditorHighlightColors=null!==(c=null==n?void 0:n.annotationEditorHighlightColors)&&void 0!==c?c:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",this.removePageBorders=null!==(u=null==n?void 0:n.removePageBorders)&&void 0!==u&&u,this.singlePageViewer=null!==(p=null==n?void 0:n.singlePageViewer)&&void 0!==p&&p,this.enablePrintAutoRotate=null!==(g=null==n?void 0:n.enablePrintAutoRotate)&&void 0!==g&&g,this.useOnlyCssZoom=null!==(f=null==n?void 0:n.useOnlyCssZoom)&&void 0!==f&&f,this.pageColors=null!==(m=null==n?void 0:n.pageColors)&&void 0!==m?m:null,this.maxCanvasPixels=null!==(b=null==n?void 0:n.maxCanvasPixels)&&void 0!==b?b:16777216,this.printResolution=null!==(v=null==n?void 0:n.printResolution)&&void 0!==v?v:96,this.thumbnailWidth=null!==(w=null==n?void 0:n.thumbnailWidth)&&void 0!==w?w:125,this.getDocumentParams=null!==(y=null==n?void 0:n.getDocumentParams)&&void 0!==y?y:{},!this.pageColors||CSS.supports("color",this.pageColors.background)&&CSS.supports("color",this.pageColors.foreground)||((this.pageColors.background||this.pageColors.foreground)&&console.warn("PDFViewer: Ignoring `pageColors`-option, since the browser doesn't support the values used."),this.pageColors=null),this.store=s;const _=new ch;_.onIdle=this._cleanup.bind(this),_.isThumbnailViewEnabled=!0,Hl(this,ud,_);const x=new Ll,S=new Rl({eventBus:x,externalLinkTarget:2,externalLinkRel:"noopener noreferrer nofollow",ignoreDestinationZoom:!1}),C=Object.assign(Object.assign({container:t},e&&{viewer:e}),{eventBus:x,linkService:S,renderingQueue:_,textLayerMode:this.textLayerMode,annotationEditorHighlightColors:this.annotationEditorHighlightColors,l10n:this.l10n,annotationMode:Vl(this,bd,"f"),annotationEditorMode:Vl(this,vd,"f"),removePageBorders:this.removePageBorders,imageResourcesPath:"/images/"}),E=this.singlePageViewer?new Nl(C):new Fl(C);_.setViewer(E),i&&(this.thumbnailViewer=new kh({container:i,eventBus:x,linkService:S,renderingQueue:_,pageColors:this.pageColors,enableHWA:void 0,store:s,thumbnailWidth:this.thumbnailWidth}),_.setThumbnailViewer(this.thumbnailViewer)),document.fullscreenEnabled&&(this.pdfPresentationMode=new id({container:t,pdfViewer:E,eventBus:x})),this.eventBus=x,this.linkService=S,this.viewer=E,this.linkService.setViewer(E),Hl(this,md,new Ld({eventBus:x,slick:this,printDialog:null!=a?a:Dd.create()}));const P=null!==(A=null==n?void 0:n.scaleValue)&&void 0!==A?A:"auto";this.store.setState({scaleValue:P})}loadDocument(t,e){return jl(this,void 0,void 0,(function*(){var i,s,n,r,a;if(this.url&&"string"==typeof this.url)try{URL.revokeObjectURL(this.url)}catch(t){}try{null===(i=this.document)||void 0===i||i.destroy(),null===(s=this.viewer)||void 0===s||s.cleanup(),t instanceof URL?this.url=t.toString():t instanceof ArrayBuffer?this.url=URL.createObjectURL(new Blob([t],{type:"application/pdf"})):this.url=t;const o=null!==(n=null==e?void 0:e.filename)&&void 0!==n?n:Ln(null===(r=this.url)||void 0===r?void 0:r.toString());this.filename=o;const l=In(Object.assign(Object.assign({},this.getDocumentParams),{url:this.url,isEvalSupported:!1}));(null==e?void 0:e.onProgress)&&(l.onProgress=e.onProgress);const h=yield l.promise;this.document=h,this.viewer.setDocument(this.document),this.linkService.setDocument(this.document),this.thumbnailViewer&&(null===(a=this.thumbnailViewer)||void 0===a||a.setDocument(h)),Vl(this,cd,"m",Sd).call(this),yield Vl(this,cd,"m",Ad).call(this),this.store.setState({filename:o,numPages:h.numPages,pageNumber:1,isDocumentLoaded:!0,url:t.toString()});const d=yield h.getAttachments(),c=new Map(Object.keys(null!=d?d:{}).sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase()))).map((t=>[t,d[t]])));this.store.setState({attachments:c}),yield Vl(this,cd,"m",_d).call(this),this.forceRendering()}catch(t){Vl(this,wd,"f")&&Vl(this,wd,"f").call(this,t)}}))}forceRendering(t=!0){Vl(this,ud,"f").printing=!!Vl(this,md,"f").printing,Vl(this,ud,"f").isThumbnailViewEnabled=t,Vl(this,ud,"f").renderHighestPriority()}gotoPage(t){this.linkService.goToPage(t)}openOrDownloadData(t,e){var i;null===(i=this.downloadManager)||void 0===i||i.openOrDownloadData(t,e)}download(){return jl(this,void 0,void 0,(function*(){var t,e;const i=this.url,{filename:s}=this;try{const e=yield this.document.getData(),n=new Blob([e],{type:"application/pdf"});yield null===(t=this.downloadManager)||void 0===t?void 0:t.download(n,i,s)}catch(t){yield null===(e=this.downloadManager)||void 0===e?void 0:e.download(null,i,s)}}))}save(){return jl(this,void 0,void 0,(function*(){var t;const e=this.url,{filename:i}=this;try{const s=yield this.document.saveDocument(),n=new Blob([s],{type:"application/pdf"});yield null===(t=this.downloadManager)||void 0===t?void 0:t.download(n,e,i)}catch(t){console.error(`Error when saving the document: ${t.message}`),yield this.download()}}))}downloadOrSave(){var t;const{annotationStorage:e}=null!==(t=this.document)&&void 0!==t?t:{};e&&e.size>0?this.save():this.download()}get supportsPrinting(){return Vl(this,md,"f").supportsPrinting}requestPresentationMode(){var t;null===(t=this.pdfPresentationMode)||void 0===t||t.request()}triggerPrinting(){Vl(this,md,"f").print()}unbindEvents(){var t;null===(t=Vl(this,yd,"f"))||void 0===t||t.abort(),Hl(this,yd,null),Vl(this,md,"f").unbindEvents()}_cleanup(){var t;if(this.document)try{this.viewer.cleanup(),null===(t=this.thumbnailViewer)||void 0===t||t.cleanup(),this.document.cleanup()}catch(t){console.error("Unable to perform cleanup",t)}}setAnnotationEditorMode(t){this.viewer.annotationEditorMode={mode:t},this.dispatch("switchannotationeditormode",{source:this,mode:t}),this.store.setState({annotationEditorMode:t})}setAnnotationEditorParams(t){const e=Array.isArray(t)?t:[t];for(const t of e)this.dispatch("switchannotationeditorparams",{source:this,type:t.type,value:t.value})}setHighlightDefaultColor(t){this.setAnnotationEditorMode(Cn.HIGHLIGHT),this.setAnnotationEditorParams([{type:Sn.HIGHLIGHT_DEFAULT_COLOR,value:t}]),this.store.setState({highlightDefaultColor:t})}setSpreadMode(t){ah(t)&&(this.viewer.spreadMode=t,this.dispatch("switchspreadmode",{mode:t}))}setScrollMode(t){rh(t)&&(this.viewer.scrollMode=t,this.dispatch("switchscrollmode",{mode:t}))}setRotation(t){nh(t)&&(this.viewer.pagesRotation=t)}getPagesOverview(){var t,e;try{return null!==(e=null===(t=this.viewer)||void 0===t?void 0:t.getPagesOverview())&&void 0!==e?e:[]}catch(t){return[]}}increaseScale(){this.viewer.increaseScale()}decreaseScale(){this.viewer.decreaseScale()}set currentScaleValue(t){this.viewer.currentScaleValue=t}set currentScale(t){this.viewer.currentScale=t}getPageView(t){return this.viewer.getPageView(t)}on(t,e,i){this.eventBus.on(t,e,i)}off(t,e,i){this.eventBus.off(t,e,i)}dispatch(t,e){this.eventBus.dispatch(t,e)}}ud=new WeakMap,pd=new WeakMap,gd=new WeakMap,fd=new WeakMap,md=new WeakMap,bd=new WeakMap,vd=new WeakMap,wd=new WeakMap,yd=new WeakMap,cd=new WeakSet,Ad=function(){return jl(this,void 0,void 0,(function*(){var t;const e=this.document,i=null!==(t=yield e.getPageLabels())&&void 0!==t?t:[],s=i.length;let n=0,r=0;for(let t=0;t<s;t++){const e=i[t];if(e===(t+1).toString())n++;else{if(""!==e)break;r++}}if(n>=s||r>=s)return;const{viewer:a,thumbnailViewer:o}=this;a.setPageLabels(i),null==o||o.setPageLabels(i)}))},_d=function(){return jl(this,void 0,void 0,(function*(){const{info:t,contentLength:e}=yield this.document.getMetadata(),i=yield this.document.getPage(this.store.getState().pageNumber).then((t=>Vl(this,cd,"m",xd).call(this,Zl(t),0)));this.store.setState({filesize:e,title:t.Title,author:t.Author,subject:t.Subject,keywords:t.Keywords,creator:t.Creator,producer:t.Producer,version:t.PDFFormatVersion,creationDate:Mn.toDateObject(t.CreationDate),modificationDate:Mn.toDateObject(t.ModDate),isLinearized:t.IsLinearized,pageSize:i})}))},xd=function(t,e){return jl(this,void 0,void 0,(function*(){if(!t)return;e%180!=0&&(t={width:t.height,height:t.width});const i=oh(t);let s={width:Math.round(100*t.width)/100,height:Math.round(100*t.height)/100},n={width:Math.round(25.4*t.width*10)/10,height:Math.round(25.4*t.height*10)/10},r=Fd(s,i,Rd)||Fd(n,i,Nd);if(!(r||Number.isInteger(n.width)&&Number.isInteger(n.height))){const e={width:25.4*t.width,height:25.4*t.height},a={width:Math.round(n.width),height:Math.round(n.height)};Math.abs(e.width-a.width)<.1&&Math.abs(e.height-a.height)<.1&&(r=Fd(a,i,Nd),r&&(s={width:Math.round(a.width/25.4*100)/100,height:Math.round(a.height/25.4*100)/100},n=a))}const[{width:a,height:o},l,h,d]=yield Promise.all([s,this.l10n.get("document_properties_page_size_unit_inches",null),r&&this.l10n.get(`document_properties_page_size_name_${r.toLowerCase()}`,null),this.l10n.get("document_properties_page_size_orientation_"+(i?"portrait":"landscape"),null)]);return{width:a.toLocaleString(),height:o.toLocaleString(),unit:l,name:h,orientation:d}}))},Sd=function(){Hl(this,yd,new AbortController);const{signal:t}=Vl(this,yd,"f"),e={signal:t};this.eventBus._on("pagesinit",Vl(this,cd,"m",Cd).bind(this),e),this.eventBus._on("scalechanging",Vl(this,cd,"m",Td).bind(this),e),this.eventBus._on("pagechanging",Vl(this,cd,"m",kd).bind(this),e),this.eventBus._on("pagerendered",Vl(this,cd,"m",Id).bind(this),e),this.eventBus._on("rotationchanging",Vl(this,cd,"m",Ed).bind(this),e),this.eventBus._on("switchspreadmode",Vl(this,cd,"m",Pd).bind(this),e),this.eventBus._on("switchscrollmode",Vl(this,cd,"m",Md).bind(this),e)},Cd=function(t){return jl(this,arguments,void 0,(function*({source:t}){var e;const i=yield null===(e=this.document)||void 0===e?void 0:e.getOutline(),s=this.store.getState().scaleValue;t.currentScale=1,t.currentScaleValue="auto",this.store.setState({documentOutline:i,pageNumber:1,scaleValue:s,pagesReady:!0})}))},Ed=function({pagesRotation:t,pageNumber:e}){this.store.setState({pagesRotation:t}),this.thumbnailViewer&&(this.thumbnailViewer.pagesRotation=t),this.forceRendering(),this.viewer.currentPageNumber=e},Pd=function({mode:t}){this.store.setState({spreadMode:t})},Md=function({mode:t}){this.store.setState({scrollMode:t})},Td=function({scale:t,presetValue:e}){this.store.setState({scale:t,scaleValue:e}),this.viewer.update()},kd=function({pageNumber:t}){var e;null===(e=this.thumbnailViewer)||void 0===e||e.scrollThumbnailIntoView(t),this.store.setState({pageNumber:t})},Id=function({pageNumber:t,error:e}){var i;if(Vl(this,fd,"f")){const e=this.viewer.getPageView(t-1),s=null===(i=this.thumbnailViewer)||void 0===i?void 0:i.getThumbnail(t-1);e&&s&&s.setImage(e)}};var Bd=function(){},jd="undefined"!=typeof window,Vd=jd?e.useLayoutEffect:e.useEffect;function Hd(t,i,s){void 0===s&&(s=[]);var n=function(t,i){var s=e.useRef(!1),n=e.useRef(),r=e.useRef(t),a=e.useCallback((function(){return s.current}),[]),o=e.useCallback((function(){s.current=!1,n.current&&clearTimeout(n.current),n.current=setTimeout((function(){s.current=!0,r.current()}),i)}),[i]),l=e.useCallback((function(){s.current=null,n.current&&clearTimeout(n.current)}),[]);return e.useEffect((function(){r.current=t}),[t]),e.useEffect((function(){return o(),l}),[i]),[a,l,o]}(t,i),r=n[0],a=n[1],o=n[2];return e.useEffect(o,s),[r,a]}var zd={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};var Ud=jd&&void 0!==window.ResizeObserver?function(){var t=e.useState(null),i=t[0],s=t[1],n=e.useState(zd),r=n[0],a=n[1],o=e.useMemo((function(){return new window.ResizeObserver((function(t){if(t[0]){var e=t[0].contentRect,i=e.x,s=e.y,n=e.width,r=e.height,o=e.top,l=e.left,h=e.bottom,d=e.right;a({x:i,y:s,width:n,height:r,top:o,left:l,bottom:h,right:d})}}))}),[]);return Vd((function(){if(i)return o.observe(i),function(){o.disconnect()}}),[i]),[s,r]}:function(){return[Bd,zd]};function $d({usePDFSlickStore:t,viewerRef:e,className:s}){const n=t((t=>t.pdfSlick)),r=t((t=>t.scaleValue)),[a,{width:o}]=Ud();return Hd((()=>{o&&(!n||"auto"!==r&&"page-fit"!==r&&"page-width"!==r||(n.viewer.currentScaleValue=r),null==n||n.viewer.update())}),0,[o]),i.jsx("div",{ref:t=>{e(t),a(t)},id:"viewerContainer",className:`pdfSlickContainer ${null!=s?s:""}`,style:{position:"absolute",inset:0,overflow:"auto"},children:i.jsx("div",{id:"viewer",className:"pdfSlickViewer pdfViewer"})})}function Wd({children:t,thumbsRef:e,usePDFSlickStore:n,className:r}){const a=n((t=>t.thumbnailViews)),o=n((t=>t.pdfSlick)),[l,{width:h}]=Ud();return Hd((()=>{h&&(null==o||o.forceRendering())}),0,[h]),i.jsx("div",{ref:t=>{e(t),l(t)},className:r,style:{position:"absolute",overflow:"auto",inset:0},children:Array.from(a).map((([e,i])=>{var n;return s.createPortal(t({pageNumber:e,width:i.canvasWidth,height:i.canvasHeight,scale:i.scale,src:null!==(n=null==i?void 0:i.src)&&void 0!==n?n:null,rotation:i.rotation,pageLabel:i.pageLabel,loaded:i.loaded}),i.div)}))})}function Gd(t){return function(i,s){return function(t,i=b,s){const n=m(t.subscribe,t.getState,t.getInitialState,i,s);return e.useDebugValue(n),n}(t,i,s)}}t.AutoPrintRegExp=/\bprint\s*\(/,t.CursorTool={SELECT:0,HAND:1,ZOOM:2},t.DEFAULT_SCALE=1,t.DEFAULT_SCALE_DELTA=1.1,t.DEFAULT_SCALE_VALUE="auto",t.MAX_AUTO_SCALE=1.25,t.MAX_SCALE=10,t.MIN_SCALE=.1,t.OutputScale=Xl,t.PDFSlick=Od,t.PDFSlickThumbnails=Wd,t.PDFSlickViewer=$d,t.PresentationModeState=Ul,t.ProgressBar=class{constructor(t){El.set(this,void 0),Pl.set(this,null),Ml.set(this,0),Tl.set(this,void 0),kl.set(this,!0),Hl(this,El,t.classList),Hl(this,Tl,t.style)}get percent(){return Vl(this,Ml,"f")}set percent(t){var e,i,s;Hl(this,Ml,(e=t,i=0,s=100,Math.min(Math.max(e,i),s))),isNaN(t)?Vl(this,El,"f").add("indeterminate"):(Vl(this,El,"f").remove("indeterminate"),Vl(this,Tl,"f").setProperty("--progressBar-percent",`${Vl(this,Ml,"f")}%`))}setWidth(t){if(!t)return;const e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&Vl(this,Tl,"f").setProperty("--progressBar-end-offset",`${e}px`)}setDisableAutoFetch(t=5e3){100===Vl(this,Ml,"f")||isNaN(Vl(this,Ml,"f"))||(Vl(this,Pl,"f")&&clearTimeout(Vl(this,Pl,"f")),this.show(),Hl(this,Pl,setTimeout((()=>{Hl(this,Pl,null),this.hide()}),t)))}hide(){Vl(this,kl,"f")&&(Hl(this,kl,!1),Vl(this,El,"f").add("hidden"))}show(){Vl(this,kl,"f")||(Hl(this,kl,!0),Vl(this,El,"f").remove("hidden"))}},t.RendererType={CANVAS:"canvas",SVG:"svg"},t.RenderingStates=zl,t.SCROLLBAR_PADDING=40,t.ScrollMode=Gl,t.SidebarView=$l,t.SpreadMode=ql,t.TextLayerMode=Wl,t.UNKNOWN_SCALE=0,t.VERTICAL_PADDING=5,t.animationStarted=lh,t.apiPageLayoutToViewerModes=function(t){let e=Gl.VERTICAL,i=ql.NONE;switch(t){case"SinglePage":e=Gl.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=Gl.PAGE;case"TwoColumnLeft":i=ql.ODD;break;case"TwoPageRight":e=Gl.PAGE;case"TwoColumnRight":i=ql.EVEN}return{scrollMode:e,spreadMode:i}},t.apiPageModeToSidebarView=function(t){switch(t){case"UseNone":return $l.NONE;case"UseThumbs":return $l.THUMBS;case"UseOutlines":return $l.OUTLINE;case"UseAttachments":return $l.ATTACHMENTS;case"UseOC":return $l.LAYERS}return $l.NONE},t.approximateFraction=function(t){if(Math.floor(t)===t)return[t,1];const e=1/t;if(e>8)return[1,8];if(Math.floor(e)===e)return[1,e];const i=t>1?e:t;let s,n=0,r=1,a=1,o=1;for(;;){const t=n+a,e=r+o;if(e>8)break;i<=t/e?(a=t,o=e):(n=t,r=e)}return s=i-n/r<a/o-i?i===t?[n,r]:[r,n]:i===t?[a,o]:[o,a],s},t.backtrackBeforeAllVisibleElements=th,t.binarySearchFirstItem=Jl,t.calcRound=dh,t.create=nd,t.createStore=Gd,t.docStyle=hh,t.floorToDivide=function(t,e){return t-t%e},t.getActiveOrFocusedElement=function(){let t=document,e=t.activeElement||t.querySelector(":focus");for(;null==e?void 0:e.shadowRoot;)t=e.shadowRoot,e=t.activeElement||t.querySelector(":focus");return e},t.getPageSizeInches=Zl,t.getVisibleElements=eh,t.initialState=sd,t.isPortraitOrientation=oh,t.isValidRotation=nh,t.isValidScrollMode=rh,t.isValidSpreadMode=ah,t.normalizeWheelEventDelta=sh,t.normalizeWheelEventDirection=ih,t.parseQueryString=function(t){const e=new Map;for(const[i,s]of new URLSearchParams(t))e.set(i.toLowerCase(),s);return e},t.removeNullCharacters=function(t,e=!1){return Ql.test(t)?e?t.replaceAll(Ql,(t=>"\0"===t?"":" ")):t.replaceAll("\0",""):t},t.scrollIntoView=Kl,t.toggleCheckedBtn=function(t,e,i=null){t.classList.toggle("toggled",e),t.setAttribute("aria-checked",String(e)),null==i||i.classList.toggle("hidden",!e)},t.toggleExpandedBtn=function(t,e,i=null){t.classList.toggle("toggled",e),t.setAttribute("aria-expanded",String(e)),null==i||i.classList.toggle("hidden",!e)},t.usePDFSlick=(t,i)=>{const[s,n]=e.useState(!1),[r,a]=e.useState(null),[o,l]=e.useState(null),[h,d]=e.useState(null),c=e.useMemo((()=>nd()),[]),u=e.useMemo((()=>Gd(c)),[]),p=e.useCallback((t=>{null!==t&&a(t)}),[]),g=e.useCallback((t=>{null!==t&&l(t)}),[]);return e.useEffect((()=>{if(t&&r){const e=new Od({container:r,thumbs:o,store:c,options:i,onError:t=>d(t)});e.loadDocument(t,i).then((()=>{n(!0)})),c.setState({pdfSlick:e})}return()=>{}}),[t,r]),{isDocumentLoaded:s,viewerRef:p,thumbsRef:g,usePDFSlickStore:u,store:c,PDFSlickViewer:$d,PDFSlickThumbnails:Wd,error:h}},t.watchScroll=Yl}));
31
+ */var y={d:(t,e)=>{for(var i in e)y.o(e,i)&&!y.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},A=globalThis.pdfjsLib={};y.d(A,{AbortException:()=>Dt,AnnotationEditorLayer:()=>Sn,AnnotationEditorParamsType:()=>F,AnnotationEditorType:()=>N,AnnotationEditorUIManager:()=>ve,AnnotationLayer:()=>rn,AnnotationMode:()=>R,ColorPicker:()=>fn,DOMSVGFactory:()=>Es,DrawLayer:()=>Cn,FeatureTest:()=>Ot,GlobalWorkerOptions:()=>Ei,ImageKind:()=>$,InvalidPDFException:()=>Tt,MissingPDFException:()=>kt,OPS:()=>ft,OutputScale:()=>he,PDFDataRangeTransport:()=>ds,PDFDateString:()=>se,PDFWorker:()=>gs,PasswordResponses:()=>mt,PermissionFlag:()=>O,PixelsPerInch:()=>Wt,RenderingCancelledException:()=>Xt,TextLayer:()=>ts,TouchManager:()=>ye,UnexpectedResponseException:()=>It,Util:()=>jt,VerbosityLevel:()=>gt,XfaLayer:()=>Ps,build:()=>As,createValidAbsoluteUrl:()=>St,fetchData:()=>Gt,getDocument:()=>os,getFilenameFromUrl:()=>Qt,getPdfFilenameFromUrl:()=>Jt,getXfaPageViewport:()=>ne,isDataScheme:()=>Kt,isPdfFile:()=>Yt,noContextMenu:()=>ee,normalizeUnicode:()=>zt,setLayerDimensions:()=>le,shadow:()=>Ct,stopEvent:()=>ie,version:()=>ys});const _=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),x=[1,0,0,1,0,0],S=[.001,0,0,.001,0,0],C=1.35,E=1,P=2,M=4,T=16,k=32,I=64,L=128,D=256,R={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},N={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},F={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},O={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},B=0,j=1,V=2,H=3,z=3,U=4,$={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},W=1,G=2,q=3,X=4,K=5,Y=6,Q=7,J=8,Z=9,tt=10,et=11,it=12,st=13,nt=14,rt=15,at=16,ot=17,lt=20,ht=1,dt=2,ct=3,ut=4,pt=5,gt={ERRORS:0,WARNINGS:1,INFOS:5},ft={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},mt={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let bt=gt.WARNINGS;function vt(t){Number.isInteger(t)&&(bt=t)}function wt(){return bt}function yt(t){bt>=gt.INFOS&&console.log(`Info: ${t}`)}function At(t){bt>=gt.WARNINGS&&console.log(`Warning: ${t}`)}function _t(t){throw new Error(t)}function xt(t,e){t||_t(e)}function St(t,e=null,i=null){if(!t)return null;try{if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch{}}const s=e?new URL(t,e):new URL(t);if(function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s))return s}catch{}return null}function Ct(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}const Et=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class Pt extends Et{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Mt extends Et{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}let Tt=class extends Et{constructor(t){super(t,"InvalidPDFException")}},kt=class extends Et{constructor(t){super(t,"MissingPDFException")}},It=class extends Et{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}};class Lt extends Et{constructor(t){super(t,"FormatError")}}let Dt=class extends Et{constructor(t){super(t,"AbortException")}};function Rt(t){"object"==typeof t&&void 0!==t?.length||_t("Invalid argument for bytesToString");const e=t.length,i=8192;if(e<i)return String.fromCharCode.apply(null,t);const s=[];for(let n=0;n<e;n+=i){const r=Math.min(n+i,e),a=t.subarray(n,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function Nt(t){"string"!=typeof t&&_t("Invalid argument for stringToBytes");const e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}function Ft(t){const e=Object.create(null);for(const[i,s]of t)e[i]=s;return e}class Ot{static get isLittleEndian(){return Ct(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return Ct(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return Ct(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return Ct(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){return"undefined"!=typeof navigator&&"string"==typeof navigator?.platform?Ct(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof navigator?.userAgent&&navigator.userAgent.includes("Firefox")}):Ct(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return Ct(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const Bt=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));let jt=class{static makeHexColor(t,e,i){return`#${Bt[t]}${Bt[e]}${Bt[i]}`}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){const i=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/i,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/i]}static getAxialAlignedBoundingBox(t,e){const i=this.applyTransform(t,e),s=this.applyTransform(t.slice(2,4),e),n=this.applyTransform([t[0],t[3]],e),r=this.applyTransform([t[2],t[1]],e);return[Math.min(i[0],s[0],n[0],r[0]),Math.min(i[1],s[1],n[1],r[1]),Math.max(i[0],s[0],n[0],r[0]),Math.max(i[1],s[1],n[1],r[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],i=t[0]*e[0]+t[1]*e[2],s=t[0]*e[1]+t[1]*e[3],n=t[2]*e[0]+t[3]*e[2],r=t[2]*e[1]+t[3]*e[3],a=(i+r)/2,o=Math.sqrt((i+r)**2-4*(i*r-n*s))/2,l=a+o||1,h=a-o||1;return[Math.sqrt(l),Math.sqrt(h)]}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[i,n,s,r]}static#t(t,e,i,s,n,r,a,o,l,h){if(l<=0||l>=1)return;const d=1-l,c=l*l,u=c*l,p=d*(d*(d*t+3*l*e)+3*c*i)+u*s,g=d*(d*(d*n+3*l*r)+3*c*a)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static#e(t,e,i,s,n,r,a,o,l,h,d,c){if(Math.abs(l)<1e-12)return void(Math.abs(h)>=1e-12&&this.#t(t,e,i,s,n,r,a,o,-d/h,c));const u=h**2-4*d*l;if(u<0)return;const p=Math.sqrt(u),g=2*l;this.#t(t,e,i,s,n,r,a,o,(-h+p)/g,c),this.#t(t,e,i,s,n,r,a,o,(-h-p)/g,c)}static bezierBoundingBox(t,e,i,s,n,r,a,o,l){return l?(l[0]=Math.min(l[0],t,a),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,a),l[3]=Math.max(l[3],e,o)):l=[Math.min(t,a),Math.min(e,o),Math.max(t,a),Math.max(e,o)],this.#e(t,i,n,a,e,s,r,o,3*(3*(i-n)-t+a),6*(t-2*i+n),3*(i-t),l),this.#e(t,i,n,a,e,s,r,o,3*(3*(s-r)-e+o),6*(e-2*s+r),3*(s-e),l),l}};let Vt=null,Ht=null;function zt(t){return Vt||(Vt=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,Ht=new Map([["ſt","ſt"]])),t.replaceAll(Vt,((t,e,i)=>e?e.normalize("NFKC"):Ht.get(i)))}const Ut="pdfjs_internal_id_";"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise((i=>{i(t(...e))}))});const $t="http://www.w3.org/2000/svg";let Wt=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function Gt(t,e="text"){if(te(t,document.baseURI)){const i=await fetch(t);if(!i.ok)throw new Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise(((i,s)=>{const n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType=e,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE)if(200!==n.status&&0!==n.status)s(new Error(n.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void i(n.response)}i(n.responseText)}},n.send(null)}))}class qt{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=n,this.offsetY=r,i*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let h,d,c,u,p,g,f,m;switch((s%=360)<0&&(s+=360),s){case 180:h=-1,d=0,c=0,u=1;break;case 90:h=0,d=1,c=1,u=0;break;case 270:h=0,d=-1,c=-1,u=0;break;case 0:h=1,d=0,c=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(c=-c,u=-u),0===h?(p=Math.abs(l-t[1])*i+n,g=Math.abs(o-t[0])*i+r,f=(t[3]-t[1])*i,m=(t[2]-t[0])*i):(p=Math.abs(o-t[0])*i+n,g=Math.abs(l-t[1])*i+r,f=(t[2]-t[0])*i,m=(t[3]-t[1])*i),this.transform=[h*i,d*i,c*i,u*i,p-h*i*o-c*i*l,g-d*i*o-u*i*l],this.width=f,this.height=m}get rawDims(){const{userUnit:t,viewBox:e}=this,i=e.map((e=>e*t));return Ct(this,"rawDims",{pageWidth:i[2]-i[0],pageHeight:i[3]-i[1],pageX:i[0],pageY:i[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new qt({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){return jt.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=jt.applyTransform([t[0],t[1]],this.transform),i=jt.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){return jt.applyInverseTransform([t,e],this.transform)}}let Xt=class extends Et{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};function Kt(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function Yt(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function Qt(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function Jt(t,e="document.pdf"){if("string"!=typeof t)return e;if(Kt(t))return At('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const i=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t);let n=i.exec(s[1])||i.exec(s[2])||i.exec(s[3]);if(n&&(n=n[0],n.includes("%")))try{n=i.exec(decodeURIComponent(n))[0]}catch{}return n||e}class Zt{started=Object.create(null);times=[];time(t){t in this.started&&At(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||At(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:t}of this.times)e=Math.max(t.length,e);for(const{name:i,start:s,end:n}of this.times)t.push(`${i.padEnd(e)} ${n-s}ms\n`);return t.join("")}}function te(t,e){try{const{protocol:i}=e?new URL(t,e):new URL(t);return"http:"===i||"https:"===i}catch{return!1}}function ee(t){t.preventDefault()}function ie(t){t.preventDefault(),t.stopPropagation()}let se=class{static#i;static toDateObject(t){if(!t||"string"!=typeof t)return null;this.#i||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#i.exec(t);if(!e)return null;const i=parseInt(e[1],10);let s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const l=e[7]||"Z";let h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,"-"===l?(r+=h,a+=d):"+"===l&&(r-=h,a-=d),new Date(Date.UTC(i,s,n,r,a,o))}};function ne(t,{scale:e=1,rotation:i=0}){const{width:s,height:n}=t.attributes.style,r=[0,0,parseInt(s),parseInt(n)];return new qt({viewBox:r,userUnit:1,scale:e,rotation:i})}function re(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map((t=>parseInt(t))):t.startsWith("rgba(")?t.slice(5,-1).split(",").map((t=>parseInt(t))).slice(0,3):(At(`Not a valid color format: "${t}"`),[0,0,0])}function ae(t){const{a:e,b:i,c:s,d:n,e:r,f:a}=t.getTransform();return[e,i,s,n,r,a]}function oe(t){const{a:e,b:i,c:s,d:n,e:r,f:a}=t.getTransform().invertSelf();return[e,i,s,n,r,a]}function le(t,e,i=!1,s=!0){if(e instanceof qt){const{pageWidth:s,pageHeight:n}=e.rawDims,{style:r}=t,a=Ot.isCSSRoundSupported,o=`var(--scale-factor) * ${s}px`,l=`var(--scale-factor) * ${n}px`,h=a?`round(down, ${o}, var(--scale-round-x, 1px))`:`calc(${o})`,d=a?`round(down, ${l}, var(--scale-round-y, 1px))`:`calc(${l})`;i&&e.rotation%180!=0?(r.width=d,r.height=h):(r.width=h,r.height=d)}s&&t.setAttribute("data-main-rotation",e.rotation)}let he=class{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}};class de{#s=null;#n=null;#r;#a=null;#o=null;static#l=null;constructor(t){this.#r=t,de.#l||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"})}render(){const t=this.#s=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#r._uiManager._signal;t.addEventListener("contextmenu",ee,{signal:e}),t.addEventListener("pointerdown",de.#h,{signal:e});const i=this.#a=document.createElement("div");i.className="buttons",t.append(i);const s=this.#r.toolbarPosition;if(s){const{style:e}=t,i="ltr"===this.#r._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=100*i+"%",e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return this.#d(),t}get div(){return this.#s}static#h(t){t.stopPropagation()}#c(t){this.#r._focusEventsAllowed=!1,ie(t)}#u(t){this.#r._focusEventsAllowed=!0,ie(t)}#p(t){const e=this.#r._uiManager._signal;t.addEventListener("focusin",this.#c.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",ee,{signal:e})}hide(){this.#s.classList.add("hidden"),this.#n?.hideDropdown()}show(){this.#s.classList.remove("hidden"),this.#o?.shown()}#d(){const{editorType:t,_uiManager:e}=this.#r,i=document.createElement("button");i.className="delete",i.tabIndex=0,i.setAttribute("data-l10n-id",de.#l[t]),this.#p(i),i.addEventListener("click",(t=>{e.delete()}),{signal:e._signal}),this.#a.append(i)}get#g(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#p(e),this.#a.prepend(e,this.#g),this.#o=t}addColorPicker(t){this.#n=t;const e=t.renderButton();this.#p(e),this.#a.prepend(e,this.#g)}remove(){this.#s.remove(),this.#n?.destroy(),this.#n=null}}class ce{#a=null;#s=null;#f;constructor(t){this.#f=t}#m(){const t=this.#s=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",ee,{signal:this.#f._signal});const e=this.#a=document.createElement("div");return e.className="buttons",t.append(e),this.#b(),t}#v(t,e){let i=0,s=0;for(const n of t){const t=n.y+n.height;if(t<i)continue;const r=n.x+(e?n.width:0);t>i?(s=r,i=t):e?r>s&&(s=r):r<s&&(s=r)}return[e?1-s:s,i]}show(t,e,i){const[s,n]=this.#v(e,i),{style:r}=this.#s||=this.#m();t.append(this.#s),r.insetInlineEnd=100*s+"%",r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#s.remove()}#b(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const i=this.#f._signal;t.addEventListener("contextmenu",ee,{signal:i}),t.addEventListener("click",(()=>{this.#f.highlightSelection("floating_button")}),{signal:i}),this.#a.append(t)}}function ue(t,e,i){for(const s of i)e.addEventListener(s,t[s].bind(t))}class pe{#w=0;get id(){return"pdfjs_internal_editor_"+this.#w++}}class ge{#y=function(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),Rt(t)}();#w=0;#A=null;static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>';return Ct(this,"_isSVGFittingCanvas",e.decode().then((()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]))))}async#_(t,e){this.#A||=new Map;let i=this.#A.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#y}_${this.#w++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await Gt(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=ge._isSVGFittingCanvas,s=new FileReader,n=new Image,r=new Promise(((t,r)=>{n.onload=()=>{i.bitmap=n,i.isSvg=!0,t()},s.onload=async()=>{const t=i.svgUrl=s.result;n.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},n.onerror=s.onerror=r}));s.readAsDataURL(t),await r}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){At(t),i=null}return this.#A.set(t,i),i&&this.#A.set(i.id,i),i}async getFromFile(t){const{lastModified:e,name:i,size:s,type:n}=t;return this.#_(`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return this.#_(t,t)}async getFromBlob(t,e){const i=await e;return this.#_(t,i)}async getFromId(t){this.#A||=new Map;const e=this.#A.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#A||=new Map;let i=this.#A.get(t);if(i?.bitmap)return i.refCounter+=1,i;const s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#y}_${this.#w++}`,refCounter:1,isSvg:!1},this.#A.set(t,i),this.#A.set(i.id,i),i}getSvgUrl(t){const e=this.#A.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#A||=new Map;const e=this.#A.get(t);if(!e)return;if(e.refCounter-=1,0!==e.refCounter)return;const{bitmap:i}=e;if(!e.url&&!e.file){const t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=t.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#y}_`)}}class fe{#x=[];#S=!1;#C;#E=-1;constructor(t=128){this.#C=t}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(s&&t(),this.#S)return;const o={cmd:t,undo:e,post:i,type:n};if(-1===this.#E)return this.#x.length>0&&(this.#x.length=0),this.#E=0,void this.#x.push(o);if(r&&this.#x[this.#E].type===n)return a&&(o.undo=this.#x[this.#E].undo),void(this.#x[this.#E]=o);const l=this.#E+1;l===this.#C?this.#x.splice(0,1):(this.#E=l,l<this.#x.length&&this.#x.splice(l)),this.#x.push(o)}undo(){if(-1===this.#E)return;this.#S=!0;const{undo:t,post:e}=this.#x[this.#E];t(),e?.(),this.#S=!1,this.#E-=1}redo(){if(this.#E<this.#x.length-1){this.#E+=1,this.#S=!0;const{cmd:t,post:e}=this.#x[this.#E];t(),e?.(),this.#S=!1}}hasSomethingToUndo(){return-1!==this.#E}hasSomethingToRedo(){return this.#E<this.#x.length-1}cleanType(t){if(-1!==this.#E){for(let e=this.#E;e>=0;e--)if(this.#x[e].type!==t)return this.#x.splice(e+1,this.#E-e),void(this.#E=e);this.#x.length=0,this.#E=-1}}destroy(){this.#x=null}}class me{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=Ot.platform;for(const[i,s,n={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1)))}}#P(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const i=this.callbacks.get(this.#P(e));if(!i)return;const{callback:s,options:{bubbles:n=!1,args:r=[],checker:a=null}}=i;a&&!a(t,e)||(s.bind(t,...r,e)(),n||ie(e))}}class be{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",document.body.append(e);for(const i of t.keys()){e.style.color=i;const s=window.getComputedStyle(e).color;t.set(i,re(s))}e.remove()}(t),Ct(this,"_colors",t)}convert(t){const e=re(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[t,i]of this._colors)if(i.every(((t,i)=>t===e[i])))return be._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?jt.makeHexColor(...e):t}}let ve=class t{#M=new AbortController;#T=null;#k=new Map;#I=new Map;#L=null;#D=null;#R=null;#N=new fe;#F=null;#O=null;#B=0;#j=new Set;#V=null;#H=null;#z=new Set;_editorUndoBar=null;#U=!1;#$=!1;#W=!1;#G=null;#q=null;#X=null;#K=null;#Y=!1;#Q=null;#J=new pe;#Z=!1;#tt=!1;#et=null;#it=null;#st=null;#nt=null;#rt=N.NONE;#at=new Set;#ot=null;#lt=null;#ht=null;#dt={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#ct=[0,0];#ut=null;#pt=null;#gt=null;#ft=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const e=t.prototype,i=t=>t.#pt.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),s=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},n=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return Ct(this,"_keyboardManager",new me([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],e.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:s}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#pt.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#pt.contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-n,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-r,0],checker:i}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[n,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[r,0],checker:i}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-n],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-r],checker:i}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,n],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,r],checker:i}]]))}constructor(t,e,i,s,n,r,a,o,l,h,d,c,u){const p=this._signal=this.#M.signal;this.#pt=t,this.#gt=e,this.#L=i,this._eventBus=s,s._on("editingaction",this.onEditingAction.bind(this),{signal:p}),s._on("pagechanging",this.onPageChanging.bind(this),{signal:p}),s._on("scalechanging",this.onScaleChanging.bind(this),{signal:p}),s._on("rotationchanging",this.onRotationChanging.bind(this),{signal:p}),s._on("setpreference",this.onSetPreference.bind(this),{signal:p}),s._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:p}),this.#mt(),this.#bt(),this.#vt(),this.#D=n.annotationStorage,this.#G=n.filterFactory,this.#lt=r,this.#K=a||null,this.#U=o,this.#$=l,this.#W=h,this.#nt=d||null,this.viewParameters={realScale:Wt.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=c||null,this._supportsPinchToZoom=!1!==u}destroy(){this.#ft?.resolve(),this.#ft=null,this.#M?.abort(),this.#M=null,this._signal=null;for(const t of this.#I.values())t.destroy();this.#I.clear(),this.#k.clear(),this.#z.clear(),this.#T=null,this.#at.clear(),this.#N.destroy(),this.#L?.destroy(),this.#Q?.hide(),this.#Q=null,this.#q&&(clearTimeout(this.#q),this.#q=null),this.#ut&&(clearTimeout(this.#ut),this.#ut=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#nt}get useNewAltTextFlow(){return this.#$}get useNewAltTextWhenAddingImage(){return this.#W}get hcmFilter(){return Ct(this,"hcmFilter",this.#lt?this.#G.addHCMFilter(this.#lt.foreground,this.#lt.background):"none")}get direction(){return Ct(this,"direction",getComputedStyle(this.#pt).direction)}get highlightColors(){return Ct(this,"highlightColors",this.#K?new Map(this.#K.split(",").map((t=>t.split("=").map((t=>t.trim()))))):null)}get highlightColorNames(){return Ct(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#O=t}setMainHighlightColorPicker(t){this.#st=t}editAltText(t,e=!1){this.#L?.editAltText(this,t,e)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){if("enableNewAltTextWhenAddingImage"===t)this.#W=e}onPageChanging({pageNumber:t}){this.#B=t-1}focusMainContainer(){this.#pt.focus()}findParent(t,e){for(const i of this.#I.values()){const{x:s,y:n,width:r,height:a}=i.div.getBoundingClientRect();if(t>=s&&t<=s+r&&e>=n&&e<=n+a)return i}return null}disableUserSelect(t=!1){this.#gt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#z.add(t)}removeShouldRescale(t){this.#z.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Wt.PDF_TO_CSS_UNITS;for(const t of this.#z)t.onScaleChanging();this.#O?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#wt({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#yt(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const e of this.#I.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r}=e,a=e.toString(),o=this.#wt(e).closest(".textLayer"),l=this.getSelectionBoxes(o);if(!l)return;e.empty();const h=this.#yt(o),d=this.#rt===N.NONE,c=()=>{h?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:l,anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r,text:a}),d&&this.showAllEditors("highlight",!0,!0)};d?this.switchToMode(N.HIGHLIGHT,c):c()}#At(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#wt(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#Q||=new ce(this),this.#Q.show(e,i,"ltr"===this.direction))}addToAnnotationStorage(t){t.isEmpty()||!this.#D||this.#D.has(t.id)||this.#D.setValue(t.id,t)}#_t(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#ot&&(this.#Q?.hide(),this.#ot=null,this.#xt({hasSelectedText:!1})));const{anchorNode:e}=t;if(e===this.#ot)return;const i=this.#wt(t).closest(".textLayer");if(i){if(this.#Q?.hide(),this.#ot=e,this.#xt({hasSelectedText:!0}),(this.#rt===N.HIGHLIGHT||this.#rt===N.NONE)&&(this.#rt===N.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#Y=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#rt===N.HIGHLIGHT?this.#yt(i):null;t?.toggleDrawing();const e=new AbortController,s=this.combinedSignal(e),n=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#St("main_toolbar"))};window.addEventListener("pointerup",n,{signal:s}),window.addEventListener("blur",n,{signal:s})}}else this.#ot&&(this.#Q?.hide(),this.#ot=null,this.#xt({hasSelectedText:!1}))}#St(t=""){this.#rt===N.HIGHLIGHT?this.highlightSelection(t):this.#U&&this.#At()}#mt(){document.addEventListener("selectionchange",this.#_t.bind(this),{signal:this._signal})}#Ct(){if(this.#X)return;this.#X=new AbortController;const t=this.combinedSignal(this.#X);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#Et(){this.#X?.abort(),this.#X=null}blur(){if(this.isShiftKeyDown=!1,this.#Y&&(this.#Y=!1,this.#St("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#at)if(e.div.contains(t)){this.#it=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#it)return;const[t,e]=this.#it;this.#it=null,e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}#vt(){if(this.#et)return;this.#et=new AbortController;const t=this.combinedSignal(this.#et);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#Pt(){this.#et?.abort(),this.#et=null}#Mt(){if(this.#F)return;this.#F=new AbortController;const t=this.combinedSignal(this.#F);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#Tt(){this.#F?.abort(),this.#F=null}#bt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#vt(),this.#Mt()}removeEditListeners(){this.#Pt(),this.#Tt()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of this.#H)if(i.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const i of this.#H)if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#T?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const t of this.#at){const i=t.serialize(!0);i&&e.push(i)}0!==e.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const t of e.items)for(const e of this.#H)if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){return void At(`paste: "${t.message}".`)}if(!Array.isArray(i))return;this.unselectAll();const s=this.currentLayer;try{const t=[];for(const e of i){const i=await s.deserialize(e);if(!i)return;t.push(i)}const e=()=>{for(const e of t)this.#kt(e);this.#It(t)},n=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:n,mustExec:!0})}catch(t){At(`paste: "${t.message}".`)}}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0),this.#rt===N.NONE||this.isEditorHandlingKeyboard||t._keyboardManager.exec(this,e)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#Y&&(this.#Y=!1,this.#St("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#xt(t){Object.entries(t).some((([t,e])=>this.#dt[t]!==e))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#dt,t)}),this.#rt===N.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#Lt([[F.HIGHLIGHT_FREE,!0]]))}#Lt(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#Ct(),this.#Mt(),this.#xt({isEditing:this.#rt!==N.NONE,isEmpty:this.#Dt(),hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:this.#N.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Et(),this.#Tt(),this.#xt({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#H){this.#H=t;for(const t of this.#H)this.#Lt(t.defaultPropertiesToUpdate)}}getId(){return this.#J.id}get currentLayer(){return this.#I.get(this.#B)}getLayer(t){return this.#I.get(t)}get currentPageIndex(){return this.#B}addLayer(t){this.#I.set(t.pageIndex,t),this.#Z?t.enable():t.disable()}removeLayer(t){this.#I.delete(t.pageIndex)}async updateMode(t,e=null,i=!1){if(this.#rt!==t&&(!this.#ft||(await this.#ft.promise,this.#ft))){if(this.#ft=Promise.withResolvers(),this.#rt=t,t===N.NONE)return this.setEditingState(!1),this.#Rt(),this._editorUndoBar?.hide(),void this.#ft.resolve();this.setEditingState(!0),await this.#Nt(),this.unselectAll();for(const e of this.#I.values())e.updateMode(t);if(!e)return i&&this.addNewEditorFromKeyboard(),void this.#ft.resolve();for(const t of this.#k.values())t.annotationElementId===e?(this.setSelected(t),t.enterInEditMode()):t.unselect();this.#ft.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#rt&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#H){switch(t){case F.CREATE:return void this.currentLayer.addNewEditor();case F.HIGHLIGHT_DEFAULT_COLOR:this.#st?.updateColor(e);break;case F.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#ht||=new Map).set(t,e),this.showAllEditors("highlight",e)}for(const i of this.#at)i.updateParams(t,e);for(const i of this.#H)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(const i of this.#k.values())i.editorType===t&&i.show(e);(this.#ht?.get(F.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#Lt([[F.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#tt!==t){this.#tt=t;for(const e of this.#I.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#Nt(){if(!this.#Z){this.#Z=!0;const t=[];for(const e of this.#I.values())t.push(e.enable());await Promise.all(t);for(const t of this.#k.values())t.enable()}}#Rt(){if(this.unselectAll(),this.#Z){this.#Z=!1;for(const t of this.#I.values())t.disable();for(const t of this.#k.values())t.disable()}}getEditors(t){const e=[];for(const i of this.#k.values())i.pageIndex===t&&e.push(i);return e}getEditor(t){return this.#k.get(t)}addEditor(t){this.#k.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#q&&clearTimeout(this.#q),this.#q=setTimeout((()=>{this.focusMainContainer(),this.#q=null}),0)),this.#k.delete(t.id),this.unselect(t),t.annotationElementId&&this.#j.has(t.annotationElementId)||this.#D?.remove(t.id)}addDeletedAnnotationElement(t){this.#j.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#j.has(t)}removeDeletedAnnotationElement(t){this.#j.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#kt(t){const e=this.#I.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#T!==t&&(this.#T=t,t&&this.#Lt(t.propertiesToUpdate))}get#Ft(){let t=null;for(t of this.#at);return t}updateUI(t){this.#Ft===t&&this.#Lt(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#Lt(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#at.has(t))return this.#at.delete(t),t.unselect(),void this.#xt({hasSelectedEditor:this.hasSelection});this.#at.add(t),t.select(),this.#Lt(t.propertiesToUpdate),this.#xt({hasSelectedEditor:!0})}setSelected(t){this.#O?.commitOrRemove();for(const e of this.#at)e!==t&&e.unselect();this.#at.clear(),this.#at.add(t),t.select(),this.#Lt(t.propertiesToUpdate),this.#xt({hasSelectedEditor:!0})}isSelected(t){return this.#at.has(t)}get firstSelectedEditor(){return this.#at.values().next().value}unselect(t){t.unselect(),this.#at.delete(t),this.#xt({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#at.size}get isEnterHandled(){return 1===this.#at.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#N.undo(),this.#xt({hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Dt()}),this._editorUndoBar?.hide()}redo(){this.#N.redo(),this.#xt({hasSomethingToUndo:!0,hasSomethingToRedo:this.#N.hasSomethingToRedo(),isEmpty:this.#Dt()})}addCommands(t){this.#N.add(t),this.#xt({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Dt()})}cleanUndoStack(t){this.#N.cleanType(t)}#Dt(){if(0===this.#k.size)return!0;if(1===this.#k.size)for(const t of this.#k.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...this.#at],i=()=>{for(const t of e)this.#kt(t)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(i,1===e.length?e[0].editorType:e.length);for(const t of e)t.remove()},undo:i,mustExec:!0})}commitOrRemove(){this.#T?.commitOrRemove()}hasSomethingToControl(){return this.#T||this.hasSelection}#It(t){for(const t of this.#at)t.unselect();this.#at.clear();for(const e of t)e.isEmpty()||(this.#at.add(e),e.select());this.#xt({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#at)t.commit();this.#It(this.#k.values())}unselectAll(){if((!this.#T||(this.#T.commitOrRemove(),this.#rt===N.NONE))&&!this.#O?.commitOrRemove()&&this.hasSelection){for(const t of this.#at)t.unselect();this.#at.clear(),this.#xt({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#ct[0]+=t,this.#ct[1]+=e;const[s,n]=this.#ct,r=[...this.#at];this.#ut&&clearTimeout(this.#ut),this.#ut=setTimeout((()=>{this.#ut=null,this.#ct[0]=this.#ct[1]=0,this.addCommands({cmd:()=>{for(const t of r)this.#k.has(t.id)&&t.translateInPage(s,n)},undo:()=>{for(const t of r)this.#k.has(t.id)&&t.translateInPage(-s,-n)},mustExec:!1})}),1e3);for(const i of r)i.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#V=new Map;for(const t of this.#at)this.#V.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#V)return!1;this.disableUserSelect(!1);const t=this.#V;this.#V=null;let e=!1;for(const[{x:i,y:s,pageIndex:n},r]of t)r.newX=i,r.newY=s,r.newPageIndex=n,e||=i!==r.savedX||s!==r.savedY||n!==r.savedPageIndex;if(!e)return!1;const i=(t,e,i,s)=>{if(this.#k.has(t.id)){const n=this.#I.get(s);n?t._setParentAndPosition(n,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(const[e,{newX:s,newY:n,newPageIndex:r}]of t)i(e,s,n,r)},undo:()=>{for(const[e,{savedX:s,savedY:n,savedPageIndex:r}]of t)i(e,s,n,r)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#V)for(const i of this.#V.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#at.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#T===t}getActive(){return this.#T}getMode(){return this.#rt}get imageManager(){return Ct(this,"imageManager",new ge)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let i=0,s=e.rangeCount;i<s;i++)if(!t.contains(e.getRangeAt(i).commonAncestorContainer))return null;const{x:i,y:s,width:n,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(t,e,a,o)=>({x:(e-s)/r,y:1-(t+a-i)/n,width:o/r,height:a/n});break;case"180":a=(t,e,a,o)=>({x:1-(t+a-i)/n,y:1-(e+o-s)/r,width:a/n,height:o/r});break;case"270":a=(t,e,a,o)=>({x:1-(e+o-s)/r,y:(t-i)/n,width:o/r,height:a/n});break;default:a=(t,e,a,o)=>({x:(t-i)/n,y:(e-s)/r,width:a/n,height:o/r})}const o=[];for(let t=0,i=e.rangeCount;t<i;t++){const i=e.getRangeAt(t);if(!i.collapsed)for(const{x:t,y:e,width:s,height:n}of i.getClientRects())0!==s&&0!==n&&o.push(a(t,e,s,n))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#R||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#R?.delete(t)}renderAnnotationElement(t){const e=this.#R?.get(t.data.id);if(!e)return;const i=this.#D.getRawValue(e);i&&(this.#rt!==N.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}};class we{#o=null;#Ot=!1;#Bt=null;#jt=null;#Vt=null;#Ht=null;#zt=!1;#Ut=null;#r=null;#$t=null;#Wt=null;#Gt=!1;static#qt=null;static _l10n=null;constructor(t){this.#r=t,this.#Gt=t._uiManager.useNewAltTextFlow,we.#qt||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){we._l10n??=t}async render(){const t=this.#Bt=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#jt=document.createElement("span");t.append(e),this.#Gt?(t.classList.add("new"),t.setAttribute("data-l10n-id",we.#qt.missing),e.setAttribute("data-l10n-id",we.#qt["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const i=this.#r._uiManager._signal;t.addEventListener("contextmenu",ee,{signal:i}),t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:i});const s=t=>{t.preventDefault(),this.#r._uiManager.editAltText(this.#r),this.#Gt&&this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#Xt}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",(e=>{e.target===t&&"Enter"===e.key&&(this.#zt=!0,s(e))}),{signal:i}),await this.#Kt(),t}get#Xt(){return(this.#o?"added":null===this.#o&&this.guessedText&&"review")||"missing"}finish(){this.#Bt&&(this.#Bt.focus({focusVisible:this.#zt}),this.#zt=!1)}isEmpty(){return this.#Gt?null===this.#o:!this.#o&&!this.#Ot}hasData(){return this.#Gt?null!==this.#o||!!this.#$t:this.isEmpty()}get guessedText(){return this.#$t}async setGuessedText(t){null===this.#o&&(this.#$t=t,this.#Wt=await we._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#Kt())}toggleAltTextBadge(t=!1){if(!this.#Gt||this.#o)return this.#Ut?.remove(),void(this.#Ut=null);if(!this.#Ut){const t=this.#Ut=document.createElement("div");t.className="noAltTextBadge",this.#r.div.append(t)}this.#Ut.classList.toggle("hidden",!t)}serialize(t){let e=this.#o;return t||this.#$t!==e||(e=this.#Wt),{altText:e,decorative:this.#Ot,guessedText:this.#$t,textWithDisclaimer:this.#Wt}}get data(){return{altText:this.#o,decorative:this.#Ot}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:n=!1}){i&&(this.#$t=i,this.#Wt=s),this.#o===t&&this.#Ot===e||(n||(this.#o=t,this.#Ot=e),this.#Kt())}toggle(t=!1){this.#Bt&&(!t&&this.#Ht&&(clearTimeout(this.#Ht),this.#Ht=null),this.#Bt.disabled=!t)}shown(){this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#Xt}})}destroy(){this.#Bt?.remove(),this.#Bt=null,this.#jt=null,this.#Vt=null,this.#Ut?.remove(),this.#Ut=null}async#Kt(){const t=this.#Bt;if(!t)return;if(this.#Gt){if(t.classList.toggle("done",!!this.#o),t.setAttribute("data-l10n-id",we.#qt[this.#Xt]),this.#jt?.setAttribute("data-l10n-id",we.#qt[`${this.#Xt}-label`]),!this.#o)return void this.#Vt?.remove()}else{if(!this.#o&&!this.#Ot)return t.classList.remove("done"),void this.#Vt?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#Vt;if(!e){this.#Vt=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#r.id}`;const i=100,s=this.#r._uiManager._signal;s.addEventListener("abort",(()=>{clearTimeout(this.#Ht),this.#Ht=null}),{once:!0}),t.addEventListener("mouseenter",(()=>{this.#Ht=setTimeout((()=>{this.#Ht=null,this.#Vt.classList.add("show"),this.#r._reportTelemetry({action:"alt_text_tooltip"})}),i)}),{signal:s}),t.addEventListener("mouseleave",(()=>{this.#Ht&&(clearTimeout(this.#Ht),this.#Ht=null),this.#Vt?.classList.remove("show")}),{signal:s})}this.#Ot?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#o),e.parentNode||t.append(e);const i=this.#r.getImageForAltText();i?.setAttribute("aria-describedby",e.id)}}let ye=class t{#pt;#Yt=!1;#Qt=null;#Jt;#Zt;#te;#ee;#ie;#se=null;#ne;#re=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:r=null,signal:a}){this.#pt=t,this.#Qt=i,this.#Jt=e,this.#Zt=s,this.#te=n,this.#ee=r,this.#ne=new AbortController,this.#ie=AbortSignal.any([a,this.#ne.signal]),t.addEventListener("touchstart",this.#ae.bind(this),{passive:!1,signal:this.#ie})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return Ct(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#ae(t){if(this.#Jt?.()||t.touches.length<2)return;if(!this.#re){this.#re=new AbortController;const t=AbortSignal.any([this.#ie,this.#re.signal]),e=this.#pt,i={signal:t,passive:!1};e.addEventListener("touchmove",this.#oe.bind(this),i),e.addEventListener("touchend",this.#le.bind(this),i),e.addEventListener("touchcancel",this.#le.bind(this),i),this.#Zt?.()}if(ie(t),2!==t.touches.length||this.#Qt?.())return void(this.#se=null);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#se={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#oe(e){if(!this.#se||2!==e.touches.length)return;let[i,s]=e.touches;i.identifier>s.identifier&&([i,s]=[s,i]);const{screenX:n,screenY:r}=i,{screenX:a,screenY:o}=s,l=this.#se,{touch0X:h,touch0Y:d,touch1X:c,touch1Y:u}=l,p=c-h,g=u-d,f=a-n,m=o-r,b=Math.hypot(f,m)||1,v=Math.hypot(p,g)||1;if(!this.#Yt&&Math.abs(v-b)<=t.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=n,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,e.preventDefault(),!this.#Yt)return void(this.#Yt=!0);const w=[(n+a)/2,(r+o)/2];this.#te?.(w,v,b)}#le(t){this.#re.abort(),this.#re=null,this.#ee?.(),this.#se&&(t.preventDefault(),this.#se=null,this.#Yt=!1)}destroy(){this.#ne?.abort(),this.#ne=null}};class Ae{#he=null;#de=null;#o=null;#ce=!1;#ue=null;#pe="";#ge=!1;#fe=null;#me=null;#be=null;#ve=null;#we="";#ye=!1;#Ae=null;#_e=!1;#xe=!1;#Se=!1;#Ce=null;#Ee=0;#Pe=0;#Me=null;#Te=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#ke=!1;#Ie=Ae._zIndex++;static _borderLineWidth=-1;static _colorManager=new be;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=Ae.prototype._resizeWithKeyboard,e=ve.TRANSLATE_SMALL,i=ve.TRANSLATE_BIG;return Ct(this,"_resizerKeyboardManager",new me([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],Ae.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[n,r];const[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return Ct(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new _e({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(Ae._l10n??=t,Ae._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),-1!==Ae._borderLineWidth)return;const i=getComputedStyle(document.documentElement);Ae._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){_t("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#ke}set _isDraggable(t){this.#ke=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#Ie}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#Le(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#ye?this.#ye=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const e=t.relatedTarget;e?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){const[n,r]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/r,this.fixAndSetPosition()}#De([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#De(this.parentDimensions,t,e)}translateInPage(t,e){this.#Ae||=[this.x,this.y,this.width,this.height],this.#De(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#Ae||=[this.x,this.y,this.width,this.height];const{div:i,parentDimensions:[s,n]}=this;if(this.x+=t/s,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:a}=this;const[o,l]=this.getBaseTranslation();r+=o,a+=l;const{style:h}=i;h.left=`${(100*r).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#Ae&&(this.#Ae[0]!==this.x||this.#Ae[1]!==this.y)}get _hasBeenResized(){return!!this.#Ae&&(this.#Ae[2]!==this.width||this.#Ae[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=Ae,s=i/t,n=i/e;switch(this.rotation){case 90:return[-s,n];case 180:return[s,n];case 270:return[s,-n];default:return[-s,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[i,s]}=this;let{x:n,y:r,width:a,height:o}=this;if(a*=i,o*=s,n*=i,r*=s,this._mustFixPosition)switch(t){case 0:n=Math.max(0,Math.min(i-a,n)),r=Math.max(0,Math.min(s-o,r));break;case 90:n=Math.max(0,Math.min(i-o,n)),r=Math.min(s,Math.max(a,r));break;case 180:n=Math.min(i,Math.max(a,n)),r=Math.min(s,Math.max(o,r));break;case 270:n=Math.min(i,Math.max(o,n)),r=Math.max(0,Math.min(s-a,r))}this.x=n/=i,this.y=r/=s;const[l,h]=this.getBaseTranslation();n+=l,r+=h,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#Re(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return Ae.#Re(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return Ae.#Re(t,e,360-this.parentRotation)}#Ne(t){switch(t){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(t,e){const[i,s]=this.parentDimensions,{style:n}=this.div;n.width=`${(100*t/i).toFixed(2)}%`,this.#ge||(n.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:i}=t,s=i.endsWith("%"),n=!this.#ge&&e.endsWith("%");if(s&&n)return;const[r,a]=this.parentDimensions;s||(t.width=`${(100*parseFloat(i)/r).toFixed(2)}%`),this.#ge||n||(t.height=`${(100*parseFloat(e)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#Fe(){if(this.#fe)return;this.#fe=document.createElement("div"),this.#fe.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const i of t){const t=document.createElement("div");this.#fe.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#Oe.bind(this,i),{signal:e}),t.addEventListener("contextmenu",ee,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#fe)}#Oe(t,e){e.preventDefault();const{isMac:i}=Ot.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#o?.toggle(!1);const s=this._isDraggable;this._isDraggable=!1,this.#me=[e.screenX,e.screenY];const n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#Be.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",ie,{passive:!1,signal:r}),window.addEventListener("contextmenu",ee,{signal:r}),this.#be={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const l=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#o?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#je()};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}#Ve(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e;const[n,r]=this.parentDimensions;this.setDims(n*i,r*s),this.fixAndSetPosition(),this._onResized()}_onResized(){}#je(){if(!this.#be)return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#be;this.#be=null;const n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===i&&o===s||this.addCommands({cmd:this.#Ve.bind(this,n,r,a,o),undo:this.#Ve.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#Be(t,e){const[i,s]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,l=Ae.MIN_SIZE/i,h=Ae.MIN_SIZE/s,d=this.#Ne(this.rotation),c=(t,e)=>[d[0]*t+d[2]*e,d[1]*t+d[3]*e],u=this.#Ne(360-this.rotation);let p,g,f=!1,m=!1;switch(t){case"topLeft":f=!0,p=(t,e)=>[0,0],g=(t,e)=>[t,e];break;case"topMiddle":p=(t,e)=>[t/2,0],g=(t,e)=>[t/2,e];break;case"topRight":f=!0,p=(t,e)=>[t,0],g=(t,e)=>[0,e];break;case"middleRight":m=!0,p=(t,e)=>[t,e/2],g=(t,e)=>[0,e/2];break;case"bottomRight":f=!0,p=(t,e)=>[t,e],g=(t,e)=>[0,0];break;case"bottomMiddle":p=(t,e)=>[t/2,e],g=(t,e)=>[t/2,0];break;case"bottomLeft":f=!0,p=(t,e)=>[0,e],g=(t,e)=>[t,0];break;case"middleLeft":m=!0,p=(t,e)=>[0,e/2],g=(t,e)=>[t,e/2]}const b=p(a,o),v=g(a,o);let w=c(...v);const y=Ae._round(n+w[0]),A=Ae._round(r+w[1]);let _,x,S=1,C=1;if(e.fromKeyboard)({deltaX:_,deltaY:x}=e);else{const{screenX:t,screenY:i}=e,[s,n]=this.#me;[_,x]=this.screenToPageTranslation(t-s,i-n),this.#me[0]=t,this.#me[1]=i}var E,P;if([_,x]=(E=_/i,P=x/s,[u[0]*E+u[2]*P,u[1]*E+u[3]*P]),f){const t=Math.hypot(a,o);S=C=Math.max(Math.min(Math.hypot(v[0]-b[0]-_,v[1]-b[1]-x)/t,1/a,1/o),l/a,h/o)}else m?S=Math.max(l,Math.min(1,Math.abs(v[0]-b[0]-_)))/a:C=Math.max(h,Math.min(1,Math.abs(v[1]-b[1]-x)))/o;const M=Ae._round(a*S),T=Ae._round(o*C);w=c(...g(M,T));const k=y-w[0],I=A-w[1];this.#Ae||=[this.x,this.y,this.width,this.height],this.width=M,this.height=T,this.x=k,this.y=I,this.setDims(i*M,s*T),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#o?.finish()}async addEditToolbar(){return this._editToolbar||this.#xe||(this._editToolbar=new de(this),this.div.append(this._editToolbar.render()),this.#o&&await this._editToolbar.addAltText(this.#o)),this._editToolbar}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#o?.destroy())}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#o||(we.initialize(Ae._l10n),this.#o=new we(this),this.#he&&(this.#o.data=this.#he,this.#he=null),await this.addEditToolbar())}get altTextData(){return this.#o?.data}set altTextData(t){this.#o&&(this.#o.data=t)}get guessedAltText(){return this.#o?.guessedText}async setGuessedAltText(t){await(this.#o?.setGuessedText(t))}serializeAltText(t){return this.#o?.serialize(t)}hasAltText(){return!!this.#o&&!this.#o.isEmpty()}hasAltTextData(){return this.#o?.hasData()??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#ce?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#He();const[t,e]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);const[i,s]=this.getInitialTranslation();return this.translate(i,s),ue(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#Te||=new ye({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#ze.bind(this),onPinching:this.#Ue.bind(this),onPinchEnd:this.#$e.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#ze(){this.#be={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#o?.toggle(!1),this.parent.togglePointerEvents(!1)}#Ue(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;const n=this.#Ne(this.rotation),r=(t,e)=>[n[0]*t+n[2]*e,n[1]*t+n[3]*e],[a,o]=this.parentDimensions,l=this.x,h=this.y,d=this.width,c=this.height,u=Ae.MIN_SIZE/a,p=Ae.MIN_SIZE/o;s=Math.max(Math.min(s,1/d,1/c),u/d,p/c);const g=Ae._round(d*s),f=Ae._round(c*s);if(g===d&&f===c)return;this.#Ae||=[l,h,d,c];const m=r(d/2,c/2),b=Ae._round(l+m[0]),v=Ae._round(h+m[1]),w=r(g/2,f/2);this.x=b-w[0],this.y=v-w[1],this.width=g,this.height=f,this.setDims(a*g,o*f),this.fixAndSetPosition(),this._onResizing()}#$e(){this.#o?.toggle(!0),this.parent.togglePointerEvents(!0),this.#je()}pointerdown(t){const{isMac:e}=Ot.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#ye=!0,this._isDraggable?this.#We(t):this.#Ge(t))}get isSelected(){return this._uiManager.isSelected(this)}#Ge(t){const{isMac:e}=Ot.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#We(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const s=new AbortController,n=this._uiManager.combinedSignal(s),r={capture:!0,passive:!1,signal:n},a=t=>{s.abort(),this.#ue=null,this.#ye=!1,this._uiManager.endDragSession()||this.#Ge(t),i&&this._onStopDragging()};e&&(this.#Ee=t.clientX,this.#Pe=t.clientY,this.#ue=t.pointerId,this.#pe=t.pointerType,window.addEventListener("pointermove",(t=>{i||(i=!0,this._onStartDragging());const{clientX:e,clientY:s,pointerId:n}=t;if(n!==this.#ue)return void ie(t);const[r,a]=this.screenToPageTranslation(e-this.#Ee,s-this.#Pe);this.#Ee=e,this.#Pe=s,this._uiManager.dragSelectedEditors(r,a)}),r),window.addEventListener("touchmove",ie,r),window.addEventListener("pointerdown",(t=>{t.pointerType===this.#pe&&(this.#Te||t.isPrimary)&&a(t),ie(t)}),r));const o=t=>{this.#ue&&this.#ue!==t.pointerId?ie(t):a(t)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#Ce&&clearTimeout(this.#Ce),this.#Ce=setTimeout((()=>{this.#Ce=null,this.parent?.moveEditorInDOM(this)}),0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){const s=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/s,h=e/s,d=this.x*n,c=this.y*r,u=this.width*n,p=this.height*r;switch(i){case 0:return[d+l+a,r-c-h-p+o,d+l+u+a,r-c-h+o];case 90:return[d+h+a,r-c+l+o,d+h+p+a,r-c+l+u+o];case 180:return[d-l-u+a,r-c+h+o,d-l+a,r-c+h+p+o];case 270:return[d-h-p+a,r-c-l-u+o,d-h+a,r-c-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,s,n,r]=t,a=n-i,o=r-s;switch(this.rotation){case 0:return[i,e-r,a,o];case 90:return[i,e-s,o,a];case 180:return[n,e-s,a,o];case 270:return[n,e-r,o,a];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){this.#xe=!0}disableEditMode(){this.#xe=!1}isInEditMode(){return this.#xe}shouldGetKeyboardEvents(){return this.#Se}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&s>0&&t<n&&i>0}#He(){if(this.#ve||!this.div)return;this.#ve=new AbortController;const t=this._uiManager.combinedSignal(this.#ve);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#He()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){_t("An editor must be serializable")}static async deserialize(t,e,i){const s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i});s.rotation=t.rotation,s.#he=t.accessibilityData;const[n,r]=s.pageDimensions,[a,o,l,h]=s.getRectInCurrentCoords(t.rect,r);return s.x=a/n,s.y=o/r,s.width=l/n,s.height=h/r,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#ve?.abort(),this.#ve=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#Ce&&(clearTimeout(this.#Ce),this.#Ce=null),this.#Le(),this.removeEditToolbar(),this.#Me){for(const t of this.#Me.values())clearTimeout(t);this.#Me=null}this.parent=null,this.#Te?.destroy(),this.#Te=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#Fe(),this.#fe.classList.remove("hidden"),ue(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#be={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#fe.children;if(!this.#de){this.#de=Array.from(e);const t=this.#qe.bind(this),i=this.#Xe.bind(this),s=this._uiManager._signal;for(const e of this.#de){const n=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#Ke.bind(this,n),{signal:s}),e.setAttribute("data-l10n-id",Ae._l10nResizer[n])}}const i=this.#de[0];let s=0;for(const t of e){if(t===i)break;s++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#de.length/4);if(n!==s){if(n<s)for(let t=0;t<s-n;t++)this.#fe.append(this.#fe.firstChild);else if(n>s)for(let t=0;t<n-s;t++)this.#fe.firstChild.before(this.#fe.lastChild);let t=0;for(const i of e){const e=this.#de[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",Ae._l10nResizer[e])}}this.#Ye(0),this.#Se=!0,this.#fe.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#qe(t){Ae._resizerKeyboardManager.exec(this,t)}#Xe(t){this.#Se&&t.relatedTarget?.parentNode!==this.#fe&&this.#Le()}#Ke(t){this.#we=this.#Se?t:""}#Ye(t){if(this.#de)for(const e of this.#de)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#Se&&this.#Be(this.#we,{deltaX:t,deltaY:e,fromKeyboard:!0})}#Le(){this.#Se=!1,this.#Ye(-1),this.#je()}_stopResizingWithKeyboard(){this.#Le(),this.div.focus()}select(){this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#o?.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()}))}unselect(){this.#fe?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#o?.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#_e}set isEditing(t){this.#_e=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#ge=!0;const i=t/e,{style:s}=this.div;s.aspectRatio=i,s.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#Me||=new Map;const{action:e}=t;let i=this.#Me.get(e);return i&&clearTimeout(i),i=setTimeout((()=>{this._reportTelemetry(t),this.#Me.delete(e),0===this.#Me.size&&(this.#Me=null)}),Ae._telemetryTimeout),void this.#Me.set(e,i)}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#ce=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#ce=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===e?.nodeName&&e.classList.contains("annotationContent")&&e.remove()}}class _e extends Ae{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const xe=3285377520,Se=4294901760,Ce=65535;class Ee{constructor(t){this.h1=t?4294967295&t:xe,this.h2=t?4294967295&t:xe}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,n=t.length;s<n;s++){const n=t.charCodeAt(s);n<=255?e[i++]=n:(e[i++]=n>>>8,e[i++]=255&n)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),i=e.byteLength}const s=i>>2,n=i-4*s,r=new Uint32Array(e.buffer,0,s);let a=0,o=0,l=this.h1,h=this.h2;const d=3432918353,c=461845907,u=11601,p=13715;for(let t=0;t<s;t++)1&t?(a=r[t],a=a*d&Se|a*u&Ce,a=a<<15|a>>>17,a=a*c&Se|a*p&Ce,l^=a,l=l<<13|l>>>19,l=5*l+3864292196):(o=r[t],o=o*d&Se|o*u&Ce,o=o<<15|o>>>17,o=o*c&Se|o*p&Ce,h^=o,h=h<<13|h>>>19,h=5*h+3864292196);switch(a=0,n){case 3:a^=e[4*s+2]<<16;case 2:a^=e[4*s+1]<<8;case 1:a^=e[4*s],a=a*d&Se|a*u&Ce,a=a<<15|a>>>17,a=a*c&Se|a*p&Ce,1&s?l^=a:h^=a}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&Se|36045*t&Ce,e=4283543511*e&Se|(2950163797*(e<<16|t>>>16)&Se)>>>16,t^=e>>>1,t=444984403*t&Se|60499*t&Ce,e=3301882366*e&Se|(3120437893*(e<<16|t>>>16)&Se)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Pe=Object.freeze({map:null,hash:"",transfer:void 0});class Me{#Qe=!1;#Je=null;#Ze=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=this.#Ze.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#Ze.get(t)}remove(t){if(this.#Ze.delete(t),0===this.#Ze.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of this.#Ze.values())if(t instanceof Ae)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=this.#Ze.get(t);let s=!1;if(void 0!==i)for(const[t,n]of Object.entries(e))i[t]!==n&&(s=!0,i[t]=n);else s=!0,this.#Ze.set(t,e);s&&this.#ti(),e instanceof Ae&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#Ze.has(t)}getAll(){return this.#Ze.size>0?Ft(this.#Ze):null}setAll(t){for(const[e,i]of Object.entries(t))this.setValue(e,i)}get size(){return this.#Ze.size}#ti(){this.#Qe||(this.#Qe=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#Qe&&(this.#Qe=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new Te(this)}get serializable(){if(0===this.#Ze.size)return Pe;const t=new Map,e=new Ee,i=[],s=Object.create(null);let n=!1;for(const[i,r]of this.#Ze){const a=r instanceof Ae?r.serialize(!1,s):r;a&&(t.set(i,a),e.update(`${i}:${JSON.stringify(a)}`),n||=!!a.bitmap)}if(n)for(const e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:Pe}get editorStats(){let t=null;const e=new Map;for(const i of this.#Ze.values()){if(!(i instanceof Ae))continue;const s=i.telemetryFinalData;if(!s)continue;const{type:n}=s;e.has(n)||e.set(n,Object.getPrototypeOf(i).constructor),t||=Object.create(null);const r=t[n]||=new Map;for(const[t,e]of Object.entries(s)){if("type"===t)continue;let i=r.get(t);i||(i=new Map,r.set(t,i));const s=i.get(e)??0;i.set(e,s+1)}}for(const[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#Je=null}get modifiedIds(){if(this.#Je)return this.#Je;const t=[];for(const e of this.#Ze.values())e instanceof Ae&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return this.#Je={ids:new Set(t),hash:t.join(",")}}}class Te extends Me{#ei;constructor(t){super();const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);this.#ei={map:n,hash:i,transfer:s}}get print(){_t("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ei}get modifiedIds(){return Ct(this,"modifiedIds",{ids:new Set,hash:""})}}class ke{#ii=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#ii.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(t&&!this.#ii.has(t.loadedName))if(xt(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:s,style:n}=t,r=new FontFace(i,s,n);this.addNativeFontFace(r);try{await r.load(),this.#ii.add(i),e?.(t)}catch{At(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}}else _t("Not implemented: loadSystemFont without the Font Loading API.")}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void await this.loadSystemFont(t);if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw At(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise((e=>{const i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)}))}}get isFontLoadingAPISupported(){return Ct(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let t=!1;return(_||"undefined"!=typeof navigator&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),Ct(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){const{loadingRequests:e}=this,i={done:!1,complete:function(){for(xt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;){const t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(i),i}get _loadTestFont(){return Ct(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function i(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function s(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let n,r;const a=this._document.createElement("canvas");a.width=1,a.height=1;const o=a.getContext("2d");let l=0;const h=`lt${Date.now()}${this.loadTestFontId++}`;let d=this._loadTestFont;d=s(d,976,h.length,h);const c=1482184792;let u=i(d,16);for(n=0,r=h.length-3;n<r;n+=4)u=u-c+i(h,n)|0;var p;n<h.length&&(u=u-c+i(h+"XXX",n)|0),d=s(d,16,4,(p=u,String.fromCharCode(p>>24&255,p>>16&255,p>>8&255,255&p)));const g=`@font-face {font-family:"${h}";src:${`url(data:font/opentype;base64,${btoa(d)});`}}`;this.insertRule(g);const f=this._document.createElement("div");f.style.visibility="hidden",f.style.width=f.style.height="10px",f.style.position="absolute",f.style.top=f.style.left="0px";for(const e of[t.loadedName,h]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,f.append(t)}this._document.body.append(f),function t(e,i){if(++l>30)return At("Load test font never loaded."),void i();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?i():setTimeout(t.bind(null,e,i))}(h,(()=>{f.remove(),e.complete()}))}}class Ie{constructor(t,{disableFontFace:e=!1,fontExtraProperties:i=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const e in t)this[e]=t[e];this.disableFontFace=!0===e,this.fontExtraProperties=!0===i,this._inspectFont=s}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${e=this.data,Uint8Array.prototype.toBase64?e.toBase64():btoa(Rt(e))});`;var e;let i;if(this.cssFontInfo){let e=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(e+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),i=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${e}src:${t}}`}else i=`@font-face {font-family:"${this.loadedName}";src:${t}}`;return this._inspectFont?.(this,t),i}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];const i=this.loadedName+"_path_"+e;let s;try{s=t.get(i)}catch(t){At(`getPathGenerator - ignoring character: "${t}".`)}const n=new Path2D(s||"");return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=n}}const Le=1,De=2,Re=1,Ne=2,Fe=3,Oe=4,Be=5,je=6,Ve=7,He=8;function ze(){}function Ue(t){if(t instanceof Dt||t instanceof Tt||t instanceof kt||t instanceof Pt||t instanceof It||t instanceof Mt)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||_t('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new Dt(t.message);case"InvalidPDFException":return new Tt(t.message);case"MissingPDFException":return new kt(t.message);case"PasswordException":return new Pt(t.message,t.code);case"UnexpectedResponseException":return new It(t.message,t.status);case"UnknownErrorException":return new Mt(t.message,t.details)}return new Mt(t.message,t.toString())}class $e{#si=new AbortController;constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),i.addEventListener("message",this.#ni.bind(this),{signal:this.#si.signal})}#ni({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#ri(t);if(t.callback){const e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],t.callback===Le)i.resolve(t.data);else{if(t.callback!==De)throw new Error("Unexpected callback case");i.reject(Ue(t.reason))}return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const i=this.sourceName,s=t.sourceName,n=this.comObj;Promise.try(e,t.data).then((function(e){n.postMessage({sourceName:i,targetName:s,callback:Le,callbackId:t.callbackId,data:e})}),(function(e){n.postMessage({sourceName:i,targetName:s,callback:De,callbackId:t.callbackId,reason:Ue(e)})}))}else t.streamId?this.#ai(t):e(t.data)}on(t,e){const i=this.actionHandler;if(i[t])throw new Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){const s=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[s]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(t){n.reject(t)}return n.promise}sendWithStream(t,e,i,s){const n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{const l=Promise.withResolvers();return this.streamControllers[n]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:i.desiredSize},s),l.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[n].pullCall=e,o.postMessage({sourceName:r,targetName:a,stream:je,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{xt(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[n].cancelCall=e,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:Re,streamId:n,reason:Ue(t)}),e.promise}},i)}#ai(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(t,r=1,a){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=r,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:i,targetName:s,stream:Oe,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Fe,streamId:e}),delete r.streamSinks[e])},error(t){xt(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Be,streamId:e,reason:Ue(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(a,t.data,o).then((function(){n.postMessage({sourceName:i,targetName:s,stream:He,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:He,streamId:e,reason:Ue(t)})}))}#ri(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case He:t.success?r.startCall.resolve():r.startCall.reject(Ue(t.reason));break;case Ve:t.success?r.pullCall.resolve():r.pullCall.reject(Ue(t.reason));break;case je:if(!a){n.postMessage({sourceName:i,targetName:s,stream:Ve,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||ze).then((function(){n.postMessage({sourceName:i,targetName:s,stream:Ve,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Ve,streamId:e,reason:Ue(t)})}));break;case Oe:if(xt(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case Fe:if(xt(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#oi(r,e);break;case Be:xt(r,"error should have stream controller"),r.controller.error(Ue(t.reason)),this.#oi(r,e);break;case Ne:t.success?r.cancelCall.resolve():r.cancelCall.reject(Ue(t.reason)),this.#oi(r,e);break;case Re:if(!a)break;const o=Ue(t.reason);Promise.try(a.onCancel||ze,o).then((function(){n.postMessage({sourceName:i,targetName:s,stream:Ne,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Ne,streamId:e,reason:Ue(t)})})),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#oi(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#si?.abort(),this.#si=null}}class We{#li=!1;constructor({enableHWA:t=!1}){this.#li=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#li})}}reset(t,e,i){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){_t("Abstract method `_createCanvas` called.")}}class Ge{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then((t=>({cMapData:t,isCompressed:this.isCompressed}))).catch((t=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)}))}async _fetch(t){_t("Abstract method `_fetch` called.")}}class qe extends Ge{async _fetch(t){const e=await Gt(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):Nt(e)}}class Xe{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,s,n){return"none"}destroy(t=!1){}}class Ke{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch((t=>{throw new Error(`Unable to load font data at: ${e}`)}))}async _fetch(t){_t("Abstract method `_fetch` called.")}}class Ye extends Ke{async _fetch(t){const e=await Gt(t,"arraybuffer");return new Uint8Array(e)}}async function Qe(t){const e=process.getBuiltinModule("fs"),i=await e.promises.readFile(t);return new Uint8Array(i)}_&&At("Please use the `legacy` build in Node.js environments.");const Je="Fill",Ze="Stroke",ti="Shading";function ei(t,e){if(!e)return;const i=e[2]-e[0],s=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],i,s),t.clip(n)}class ii{getPattern(){_t("Abstract method `getPattern` called.")}}class si extends ii{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;"axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const t of this._colorStops)e.addColorStop(t[0],t[1]);return e}getPattern(t,e,i,s){let n;if(s===Ze||s===Je){const r=e.current.getClippedPathBoundingBox(s,ae(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,l=e.cachedCanvases.getCanvas("pattern",a,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-r[0],-r[1]),i=jt.transform(i,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),ei(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),n=t.createPattern(l.canvas,"no-repeat");const d=new DOMMatrix(i);n.setTransform(d)}else ei(t,this._bbox),n=this._createGradient(t);return n}}function ni(t,e,i,s,n,r,a,o){const l=e.coords,h=e.colors,d=t.data,c=4*t.width;let u;l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=r,r=a,a=u),l[s+1]>l[n+1]&&(u=s,s=n,n=u,u=a,a=o,o=u),l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=r,r=a,a=u);const p=(l[i]+e.offsetX)*e.scaleX,g=(l[i+1]+e.offsetY)*e.scaleY,f=(l[s]+e.offsetX)*e.scaleX,m=(l[s+1]+e.offsetY)*e.scaleY,b=(l[n]+e.offsetX)*e.scaleX,v=(l[n+1]+e.offsetY)*e.scaleY;if(g>=v)return;const w=h[r],y=h[r+1],A=h[r+2],_=h[a],x=h[a+1],S=h[a+2],C=h[o],E=h[o+1],P=h[o+2],M=Math.round(g),T=Math.round(v);let k,I,L,D,R,N,F,O;for(let t=M;t<=T;t++){if(t<m){const e=t<g?0:(g-t)/(g-m);k=p-(p-f)*e,I=w-(w-_)*e,L=y-(y-x)*e,D=A-(A-S)*e}else{let e;e=t>v?1:m===v?0:(m-t)/(m-v),k=f-(f-b)*e,I=_-(_-C)*e,L=x-(x-E)*e,D=S-(S-P)*e}let e;e=t<g?0:t>v?1:(g-t)/(g-v),R=p-(p-b)*e,N=w-(w-C)*e,F=y-(y-E)*e,O=A-(A-P)*e;const i=Math.round(Math.min(k,R)),s=Math.round(Math.max(k,R));let n=c*t+4*i;for(let t=i;t<=s;t++)e=(k-t)/(k-R),e<0?e=0:e>1&&(e=1),d[n++]=I-(I-N)*e|0,d[n++]=L-(L-F)*e|0,d[n++]=D-(D-O)*e|0,d[n++]=255}}function ri(t,e,i){const s=e.coords,n=e.colors;let r,a;switch(e.type){case"lattice":const o=e.verticesPerRow,l=Math.floor(s.length/o)-1,h=o-1;for(r=0;r<l;r++){let e=r*o;for(let r=0;r<h;r++,e++)ni(t,i,s[e],s[e+1],s[e+o],n[e],n[e+1],n[e+o]),ni(t,i,s[e+o+1],s[e+1],s[e+o],n[e+o+1],n[e+1],n[e+o])}break;case"triangles":for(r=0,a=s.length;r<a;r+=3)ni(t,i,s[r],s[r+1],s[r+2],n[r],n[r+1],n[r+2]);break;default:throw new Error("illegal figure")}}class ai extends ii{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,i){const s=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-s,a=Math.ceil(this._bounds[3])-n,o=Math.min(Math.ceil(Math.abs(r*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(a*t[1]*1.1)),3e3),h=r/o,d=a/l,c={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-n,scaleX:1/h,scaleY:1/d},u=o+4,p=l+4,g=i.getCanvas("mesh",u,p),f=g.context,m=f.createImageData(o,l);if(e){const t=m.data;for(let i=0,s=t.length;i<s;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}for(const t of this._figures)ri(m,t,c);f.putImageData(m,2,2);return{canvas:g.canvas,offsetX:s-2*h,offsetY:n-2*d,scaleX:h,scaleY:d}}getPattern(t,e,i,s){let n;if(ei(t,this._bbox),s===ti)n=jt.singularValueDecompose2dScale(ae(t));else if(n=jt.singularValueDecompose2dScale(e.baseTransform),this.matrix){const t=jt.singularValueDecompose2dScale(this.matrix);n=[n[0]*t[0],n[1]*t[1]]}const r=this._createMeshCanvas(n,s===ti?null:this._background,e.cachedCanvases);return s!==ti&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class oi extends ii{getPattern(){return"hotpink"}}const li=1,hi=2;class di{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s,n){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=i,this.canvasGraphicsFactory=s,this.baseTransform=n}createPatternCanvas(t){const{bbox:e,operatorList:i,paintType:s,tilingType:n,color:r,canvasGraphicsFactory:a}=this;let{xstep:o,ystep:l}=this;o=Math.abs(o),l=Math.abs(l),yt("TilingType: "+n);const h=e[0],d=e[1],c=e[2],u=e[3],p=c-h,g=u-d,f=jt.singularValueDecompose2dScale(this.matrix),m=jt.singularValueDecompose2dScale(this.baseTransform),b=f[0]*m[0],v=f[1]*m[1];let w=p,y=g,A=!1,_=!1;const x=Math.ceil(o*b),S=Math.ceil(l*v);x>=Math.ceil(p*b)?w=o:A=!0,S>=Math.ceil(g*v)?y=l:_=!0;const C=this.getSizeAndScale(w,this.ctx.canvas.width,b),E=this.getSizeAndScale(y,this.ctx.canvas.height,v),P=t.cachedCanvases.getCanvas("pattern",C.size,E.size),M=P.context,T=a.createCanvasGraphics(M);if(T.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(T,s,r),M.translate(-C.scale*h,-E.scale*d),T.transform(C.scale,0,0,E.scale,0,0),M.save(),this.clipBbox(T,h,d,c,u),T.baseTransform=ae(T.ctx),T.executeOperatorList(i),T.endDrawing(),M.restore(),A||_){const e=P.canvas;A&&(w=o),_&&(y=l);const i=this.getSizeAndScale(w,this.ctx.canvas.width,b),s=this.getSizeAndScale(y,this.ctx.canvas.height,v),n=i.size,r=s.size,a=t.cachedCanvases.getCanvas("pattern-workaround",n,r),c=a.context,u=A?Math.floor(p/o):0,f=_?Math.floor(g/l):0;for(let t=0;t<=u;t++)for(let i=0;i<=f;i++)c.drawImage(e,n*t,r*i,n,r,0,0,n,r);return{canvas:a.canvas,scaleX:i.scale,scaleY:s.scale,offsetX:h,offsetY:d}}return{canvas:P.canvas,scaleX:C.scale,scaleY:E.scale,offsetX:h,offsetY:d}}getSizeAndScale(t,e,i){const s=Math.max(di.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*i);return n>=s?n=s:i=n/t,{scale:i,size:n}}clipBbox(t,e,i,s,n){const r=s-e,a=n-i;t.ctx.rect(e,i,r,a),t.current.updateRectMinMax(ae(t.ctx),[e,i,s,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const s=t.ctx,n=t.current;switch(e){case li:const t=this.ctx;s.fillStyle=t.fillStyle,s.strokeStyle=t.strokeStyle,n.fillColor=t.fillStyle,n.strokeColor=t.strokeStyle;break;case hi:const r=jt.makeHexColor(i[0],i[1],i[2]);s.fillStyle=r,s.strokeStyle=r,n.fillColor=r,n.strokeColor=r;break;default:throw new Lt(`Unsupported paint type: ${e}`)}}getPattern(t,e,i,s){let n=i;s!==ti&&(n=jt.transform(n,e.baseTransform),this.matrix&&(n=jt.transform(n,this.matrix)));const r=this.createPatternCanvas(e);let a=new DOMMatrix(n);a=a.translate(r.offsetX,r.offsetY),a=a.scale(1/r.scaleX,1/r.scaleY);const o=t.createPattern(r.canvas,"repeat");return o.setTransform(a),o}}function ci({src:t,srcPos:e=0,dest:i,width:s,height:n,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=Ot.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],d=s>>3,c=7&s,u=t.length;i=new Uint32Array(i.buffer);let p=0;for(let s=0;s<n;s++){for(const s=e+d;e<s;e++){const s=e<u?t[e]:255;i[p++]=128&s?h:l,i[p++]=64&s?h:l,i[p++]=32&s?h:l,i[p++]=16&s?h:l,i[p++]=8&s?h:l,i[p++]=4&s?h:l,i[p++]=2&s?h:l,i[p++]=1&s?h:l}if(0===c)continue;const s=e<u?t[e++]:255;for(let t=0;t<c;t++)i[p++]=s&1<<7-t?h:l}return{srcPos:e,destPos:p}}const ui=16;class pi{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let s;return void 0!==this.cache[t]?(s=this.cache[t],this.canvasFactory.reset(s,e,i)):(s=this.canvasFactory.create(e,i),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function gi(t,e,i,s,n,r,a,o,l,h){const[d,c,u,p,g,f]=ae(t);if(0===c&&0===u){const m=a*d+g,b=Math.round(m),v=o*p+f,w=Math.round(v),y=(a+l)*d+g,A=Math.abs(Math.round(y)-b)||1,_=(o+h)*p+f,x=Math.abs(Math.round(_)-w)||1;return t.setTransform(Math.sign(d),0,0,Math.sign(p),b,w),t.drawImage(e,i,s,n,r,0,0,A,x),t.setTransform(d,c,u,p,g,f),[A,x]}if(0===d&&0===p){const m=o*u+g,b=Math.round(m),v=a*c+f,w=Math.round(v),y=(o+h)*u+g,A=Math.abs(Math.round(y)-b)||1,_=(a+l)*c+f,x=Math.abs(Math.round(_)-w)||1;return t.setTransform(0,Math.sign(c),Math.sign(u),0,b,w),t.drawImage(e,i,s,n,r,0,0,x,A),t.setTransform(d,c,u,p,g,f),[x,A]}t.drawImage(e,i,s,n,r,a,o,l,h);return[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class fi{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=x,this.textMatrixScale=1,this.fontMatrix=S,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=B,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,i){[e,i]=jt.applyTransform([e,i],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,i),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,i)}updateRectMinMax(t,e){const i=jt.applyTransform(e,t),s=jt.applyTransform(e.slice(2),t),n=jt.applyTransform([e[0],e[3]],t),r=jt.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,i[0],s[0],n[0],r[0]),this.minY=Math.min(this.minY,i[1],s[1],n[1],r[1]),this.maxX=Math.max(this.maxX,i[0],s[0],n[0],r[0]),this.maxY=Math.max(this.maxY,i[1],s[1],n[1],r[1])}updateScalingPathMinMax(t,e){jt.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,i,s,n,r,a,o,l,h){const d=jt.bezierBoundingBox(e,i,s,n,r,a,o,l,h);h||this.updateRectMinMax(t,d)}getPathBoundingBox(t=Je,e=null){const i=[this.minX,this.minY,this.maxX,this.maxY];if(t===Ze){e||_t("Stroke bounding box must include transform.");const t=jt.singularValueDecompose2dScale(e),s=t[0]*this.lineWidth/2,n=t[1]*this.lineWidth/2;i[0]-=s,i[1]-=n,i[2]+=s,i[3]+=n}return i}updateClipFromPath(){const t=jt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=Je,e=null){return jt.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function mi(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,s=e.width,n=i%ui,r=(i-n)/ui,a=0===n?r:r+1,o=t.createImageData(s,ui);let l,h=0;const d=e.data,c=o.data;let u,p,g,f;if(e.kind===$.GRAYSCALE_1BPP){const e=d.byteLength,i=new Uint32Array(c.buffer,0,c.byteLength>>2),f=i.length,m=s+7>>3,b=4294967295,v=Ot.isLittleEndian?4278190080:255;for(u=0;u<a;u++){for(g=u<r?ui:n,l=0,p=0;p<g;p++){const t=e-h;let n=0;const r=t>m?s:8*t-7,a=-8&r;let o=0,c=0;for(;n<a;n+=8)c=d[h++],i[l++]=128&c?b:v,i[l++]=64&c?b:v,i[l++]=32&c?b:v,i[l++]=16&c?b:v,i[l++]=8&c?b:v,i[l++]=4&c?b:v,i[l++]=2&c?b:v,i[l++]=1&c?b:v;for(;n<r;n++)0===o&&(c=d[h++],o=128),i[l++]=c&o?b:v,o>>=1}for(;l<f;)i[l++]=0;t.putImageData(o,0,u*ui)}}else if(e.kind===$.RGBA_32BPP){for(p=0,f=s*ui*4,u=0;u<r;u++)c.set(d.subarray(h,h+f)),h+=f,t.putImageData(o,0,p),p+=ui;u<a&&(f=s*n*4,c.set(d.subarray(h,h+f)),t.putImageData(o,0,p))}else{if(e.kind!==$.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=ui,f=s*g,u=0;u<a;u++){for(u>=r&&(g=n,f=s*g),l=0,p=f;p--;)c[l++]=d[h++],c[l++]=d[h++],c[l++]=d[h++],c[l++]=255;t.putImageData(o,0,u*ui)}}}function bi(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,s=e.width,n=i%ui,r=(i-n)/ui,a=0===n?r:r+1,o=t.createImageData(s,ui);let l=0;const h=e.data,d=o.data;for(let e=0;e<a;e++){const i=e<r?ui:n;({srcPos:l}=ci({src:h,srcPos:l,dest:d,width:s,height:i,nonBlackColor:0})),t.putImageData(o,0,e*ui)}}function vi(t,e){const i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of i)void 0!==t[s]&&(e[s]=t[s]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function wi(t){if(t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0),!_){const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}}function yi(t,e){if(e)return!0;const i=jt.singularValueDecompose2dScale(t);i[0]=Math.fround(i[0]),i[1]=Math.fround(i[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*Wt.PDF_TO_CSS_UNITS);return i[0]<=s&&i[1]<=s}const Ai=["butt","round","square"],_i=["miter","round","bevel"],xi={},Si={};class Ci{constructor(t,e,i,s,n,{optionalContentConfig:r,markedContentStack:a=null},o,l){this.ctx=t,this.current=new fi(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=n,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=r,this.cachedCanvases=new pi(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,i){const t=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...ae(this.compositeCtx))}this.ctx.save(),wi(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=ae(this.ctx)}executeOperatorList(t,e,i,s){const n=t.argsArray,r=t.fnArray;let a=e||0;const o=n.length;if(o===a)return a;const l=o-a>10&&"function"==typeof i,h=l?Date.now()+15:0;let d=0;const c=this.commonObjs,u=this.objs;let p;for(;;){if(void 0!==s&&a===s.nextBreakPoint)return s.breakIt(a,i),a;if(p=r[a],p!==ft.dependency)this[p].apply(this,n[a]);else for(const t of n[a]){const e=t.startsWith("g_")?c:u;if(!e.has(t))return e.get(t,i),a}if(a++,a===o)return a;if(l&&++d>10){if(Date.now()>h)return i(),a;d=0}}}#hi(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#hi(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#di()}#di(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const i=t.width??t.displayWidth,s=t.height??t.displayHeight;let n,r,a=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=i,h=s,d="prescale1";for(;a>2&&l>1||o>2&&h>1;){let e=l,i=h;a>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),a/=l/e),o>2&&h>1&&(i=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/i),n=this.cachedCanvases.getCanvas(d,e,i),r=n.context,r.clearRect(0,0,e,i),r.drawImage(t,0,0,l,h,0,0,e,i),t=n.canvas,l=e,h=i,d="prescale1"===d?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t){const e=this.ctx,{width:i,height:s}=t,n=this.current.fillColor,r=this.current.patternFill,a=ae(e);let o,l,h,d;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;l=JSON.stringify(r?a:[a.slice(0,4),n]),o=this._cachedBitmapsMap.get(e),o||(o=new Map,this._cachedBitmapsMap.set(e,o));const i=o.get(l);if(i&&!r){return{canvas:i,offsetX:Math.round(Math.min(a[0],a[2])+a[4]),offsetY:Math.round(Math.min(a[1],a[3])+a[5])}}h=i}h||(d=this.cachedCanvases.getCanvas("maskCanvas",i,s),bi(d.context,t));let c=jt.transform(a,[1/i,0,0,-1/s,0,0]);c=jt.transform(c,[1,0,0,1,0,-s]);const[u,p,g,f]=jt.getAxialAlignedBoundingBox([0,0,i,s],c),m=Math.round(g-u)||1,b=Math.round(f-p)||1,v=this.cachedCanvases.getCanvas("fillCanvas",m,b),w=v.context,y=u,A=p;w.translate(-y,-A),w.transform(...c),h||(h=this._scaleImage(d.canvas,oe(w)),h=h.img,o&&r&&o.set(l,h)),w.imageSmoothingEnabled=yi(ae(w),t.interpolate),gi(w,h,0,0,h.width,h.height,0,0,i,s),w.globalCompositeOperation="source-in";const _=jt.transform(oe(w),[1,0,0,1,-y,-A]);return w.fillStyle=r?n.getPattern(e,this,_,Je):n,w.fillRect(0,0,i,s),o&&!r&&(this.cachedCanvases.delete("fillCanvas"),o.set(l,v.canvas)),{canvas:v.canvas,offsetX:Math.round(y),offsetY:Math.round(A)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Ai[t]}setLineJoin(t){this.ctx.lineJoin=_i[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const i=this.ctx;void 0!==i.setLineDash&&(i.setLineDash(t),i.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,i]of t)switch(e){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i[0],i[1]);break;case"CA":this.current.strokeAlpha=i;break;case"ca":this.current.fillAlpha=i,this.ctx.globalAlpha=i;break;case"BM":this.ctx.globalCompositeOperation=i;break;case"SMask":this.current.activeSMask=i?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(i,t,e);this.suspendedCtx=this.ctx,this.ctx=s.context;const n=this.ctx;n.setTransform(...ae(this.suspendedCtx)),vi(this.suspendedCtx,n),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,i){e.translate(t,i),this.__originalTranslate(t,i)},t.scale=function(t,i){e.scale(t,i),this.__originalScale(t,i)},t.transform=function(t,i,s,n,r,a){e.transform(t,i,s,n,r,a),this.__originalTransform(t,i,s,n,r,a)},t.setTransform=function(t,i,s,n,r,a){e.setTransform(t,i,s,n,r,a),this.__originalSetTransform(t,i,s,n,r,a)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,i){e.moveTo(t,i),this.__originalMoveTo(t,i)},t.lineTo=function(t,i){e.lineTo(t,i),this.__originalLineTo(t,i)},t.bezierCurveTo=function(t,i,s,n,r,a){e.bezierCurveTo(t,i,s,n,r,a),this.__originalBezierCurveTo(t,i,s,n,r,a)},t.rect=function(t,i,s,n){e.rect(t,i,s,n),this.__originalRect(t,i,s,n)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(n,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),vi(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,i,s){const n=s[0],r=s[1],a=s[2]-n,o=s[3]-r;0!==a&&0!==o&&(this.genericComposeSMask(e.context,i,a,o,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,s,n,r,a,o,l,h,d){let c=t.canvas,u=o-h,p=l-d;if(r){const e=jt.makeHexColor(...r);if(u<0||p<0||u+i>c.width||p+s>c.height){const t=this.cachedCanvases.getCanvas("maskExtension",i,s),n=t.context;n.drawImage(c,-u,-p),n.globalCompositeOperation="destination-atop",n.fillStyle=e,n.fillRect(0,0,i,s),n.globalCompositeOperation="source-over",c=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const n=new Path2D;n.rect(u,p,i,s),t.clip(n),t.globalCompositeOperation="destination-atop",t.fillStyle=e,t.fillRect(u,p,i,s),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===n&&a?e.filter=this.filterFactory.addAlphaFilter(a):"Luminosity"===n&&(e.filter=this.filterFactory.addLuminosityFilter(a));const g=new Path2D;g.rect(o,l,i,s),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(c,u,p,i,s,o,l,i,s),e.restore()}save(){this.inSMaskMode?(vi(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),vi(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,i,s,n,r){this.ctx.transform(t,e,i,s,n,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i){const s=this.ctx,n=this.current;let r,a,o=n.x,l=n.y;const h=ae(s),d=0===h[0]&&0===h[3]||0===h[1]&&0===h[2],c=d?i.slice(0):null;for(let i=0,u=0,p=t.length;i<p;i++)switch(0|t[i]){case ft.rectangle:o=e[u++],l=e[u++];const t=e[u++],i=e[u++],p=o+t,g=l+i;s.moveTo(o,l),0===t||0===i?s.lineTo(p,g):(s.lineTo(p,l),s.lineTo(p,g),s.lineTo(o,g)),d||n.updateRectMinMax(h,[o,l,p,g]),s.closePath();break;case ft.moveTo:o=e[u++],l=e[u++],s.moveTo(o,l),d||n.updatePathMinMax(h,o,l);break;case ft.lineTo:o=e[u++],l=e[u++],s.lineTo(o,l),d||n.updatePathMinMax(h,o,l);break;case ft.curveTo:r=o,a=l,o=e[u+4],l=e[u+5],s.bezierCurveTo(e[u],e[u+1],e[u+2],e[u+3],o,l),n.updateCurvePathMinMax(h,r,a,e[u],e[u+1],e[u+2],e[u+3],o,l,c),u+=6;break;case ft.curveTo2:r=o,a=l,s.bezierCurveTo(o,l,e[u],e[u+1],e[u+2],e[u+3]),n.updateCurvePathMinMax(h,r,a,o,l,e[u],e[u+1],e[u+2],e[u+3],c),o=e[u+2],l=e[u+3],u+=4;break;case ft.curveTo3:r=o,a=l,o=e[u+2],l=e[u+3],s.bezierCurveTo(e[u],e[u+1],o,l,o,l),n.updateCurvePathMinMax(h,r,a,e[u],e[u+1],o,l,o,l,c),u+=4;break;case ft.closePath:s.closePath()}d&&n.updateScalingPathMinMax(h,c),n.setCurrentPoint(o,l)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,i=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof i&&i?.getPattern?(e.save(),e.strokeStyle=i.getPattern(e,this,oe(e),Ze),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){const e=this.ctx,i=this.current.fillColor;let s=!1;this.current.patternFill&&(e.save(),e.fillStyle=i.getPattern(e,this,oe(e),Je),s=!0);const n=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==n&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),s&&e.restore(),t&&this.consumePath(n)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=xi}eoClip(){this.pendingClip=Si}beginText(){this.current.textMatrix=x,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(void 0===t)return void e.beginPath();const i=new Path2D,s=e.getTransform().invertSelf();for(const{transform:e,x:n,y:r,fontSize:a,path:o}of t)i.addPath(o,new DOMMatrix(e).preMultiplySelf(s).translate(n,r).scale(a,-a));e.clip(i),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){const i=this.commonObjs.get(t),s=this.current;if(!i)throw new Error(`Can't find font for ${t}`);if(s.fontMatrix=i.fontMatrix||S,0!==s.fontMatrix[0]&&0!==s.fontMatrix[3]||At("Invalid font matrix for font "+t),e<0?(e=-e,s.fontDirection=-1):s.fontDirection=1,this.current.font=i,this.current.fontSize=e,i.isType3Font)return;const n=i.loadedName||"sans-serif",r=i.systemFontInfo?.css||`"${n}", ${i.fallbackName}`;let a="normal";i.black?a="900":i.bold&&(a="bold");const o=i.italic?"italic":"normal";let l=e;e<16?l=16:e>100&&(l=100),this.current.fontSizeScale=e/l,this.ctx.font=`${o} ${a} ${l}px ${r}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,i,s,n,r){this.current.textMatrix=[t,e,i,s,n,r],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#ci(t,e,i){const s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,n){const r=this.ctx,a=this.current,o=a.font,l=a.textRenderingMode,h=a.fontSize/a.fontSizeScale,d=l&z,c=!!(l&U),u=a.patternFill&&!o.missingFile,p=a.patternStroke&&!o.missingFile;let g;if((o.disableFontFace||c||u||p)&&(g=o.getPathGenerator(this.commonObjs,t)),o.disableFontFace||u||p){if(r.save(),r.translate(e,i),r.scale(h,-h),d===B||d===V)if(s){const t=r.getTransform();r.setTransform(...s),r.fill(this.#ci(g,t,s))}else r.fill(g);if(d===j||d===V)if(n){const t=r.getTransform();r.setTransform(...n),r.stroke(this.#ci(g,t,n))}else r.lineWidth/=h,r.stroke(g);r.restore()}else d!==B&&d!==V||r.fillText(t,e,i),d!==j&&d!==V||r.strokeText(t,e,i);if(c){(this.pendingTextPaths||=[]).push({transform:ae(r),x:e,y:i,fontSize:h,path:g})}}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let i=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){i=!0;break}return Ct(this,"isFontSubpixelAAEnabled",i)}showText(t){const e=this.current,i=e.font;if(i.isType3Font)return this.showType3Text(t);const s=e.fontSize;if(0===s)return;const n=this.ctx,r=e.fontSizeScale,a=e.charSpacing,o=e.wordSpacing,l=e.fontDirection,h=e.textHScale*l,d=t.length,c=i.vertical,u=c?1:-1,p=i.defaultVMetrics,g=s*e.fontMatrix[0],f=e.textRenderingMode===B&&!i.disableFontFace&&!e.patternFill;let m,b;if(n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),l>0?n.scale(h,-1):n.scale(h,1),e.patternFill){n.save();const t=e.fillColor.getPattern(n,this,oe(n),Je);m=ae(n),n.restore(),n.fillStyle=t}if(e.patternStroke){n.save();const t=e.strokeColor.getPattern(n,this,oe(n),Ze);b=ae(n),n.restore(),n.strokeStyle=t}let v=e.lineWidth;const w=e.textMatrixScale;if(0===w||0===v){const t=e.textRenderingMode&z;t!==j&&t!==V||(v=this.getSinglePixelWidth())}else v/=w;if(1!==r&&(n.scale(r,r),v/=r),n.lineWidth=v,i.isInvalidPDFjsFont){const i=[];let s=0;for(const e of t)i.push(e.unicode),s+=e.width;return n.fillText(i.join(""),0,0),e.x+=s*g*h,n.restore(),void this.compose()}let y,A=0;for(y=0;y<d;++y){const e=t[y];if("number"==typeof e){A+=u*e*s/1e3;continue}let h=!1;const d=(e.isSpace?o:0)+a,v=e.fontChar,w=e.accent;let _,x,S=e.width;if(c){const t=e.vmetric||p,i=-(e.vmetric?t[1]:.5*S)*g,s=t[2]*g;S=t?-t[0]:S,_=i/r,x=(A+s)/r}else _=A/r,x=0;if(i.remeasure&&S>0){const t=1e3*n.measureText(v).width/s*r;if(S<t&&this.isFontSubpixelAAEnabled){const e=S/t;h=!0,n.save(),n.scale(e,1),_/=e}else S!==t&&(_+=(S-t)/2e3*s/r)}if(this.contentVisible&&(e.isInFont||i.missingFile))if(f&&!w)n.fillText(v,_,x);else if(this.paintChar(v,_,x,m,b),w){const t=_+s*w.offset.x/r,e=x-s*w.offset.y/r;this.paintChar(w.fontChar,t,e,m,b)}A+=c?S*g-d*l:S*g+d*l,h&&n.restore()}c?e.y-=A:e.x+=A*h,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,i=this.current,s=i.font,n=i.fontSize,r=i.fontDirection,a=s.vertical?1:-1,o=i.charSpacing,l=i.wordSpacing,h=i.textHScale*r,d=i.fontMatrix||S,c=t.length;let u,p,g,f;if(!(i.textRenderingMode===H)&&0!==n){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...i.textMatrix),e.translate(i.x,i.y),e.scale(h,r),u=0;u<c;++u){if(p=t[u],"number"==typeof p){f=a*p*n/1e3,this.ctx.translate(f,0),i.x+=f*h;continue}const r=(p.isSpace?l:0)+o,c=s.charProcOperatorList[p.operatorListId];if(!c){At(`Type3 character "${p.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=p,this.save(),e.scale(n,n),e.transform(...d),this.executeOperatorList(c),this.restore());g=jt.applyTransform([p.width,0],d)[0]*n+r,e.translate(g,0),i.x+=g*h}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,i,s,n,r){this.ctx.rect(i,s,n-i,r-s),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){const i=t[1],s=this.baseTransform||ae(this.ctx),n={createCanvasGraphics:t=>new Ci(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new di(t,i,this.ctx,n,s)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,i){this.ctx.strokeStyle=this.current.strokeColor=jt.makeHexColor(t,e,i),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,i){this.ctx.fillStyle=this.current.fillColor=jt.makeHexColor(t,e,i),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let i;return this.cachedPatterns.has(t)?i=this.cachedPatterns.get(t):(i=function(t){switch(t[0]){case"RadialAxial":return new si(t);case"Mesh":return new ai(t);case"Dummy":return new oi}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,i)),e&&(i.matrix=e),i}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const i=this._getPattern(t);e.fillStyle=i.getPattern(e,this,oe(e),ti);const s=oe(e);if(s){const{width:t,height:i}=e.canvas,[n,r,a,o]=jt.getAxialAlignedBoundingBox([0,0,t,i],s);this.ctx.fillRect(n,r,a-n,o-r)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){_t("Should not call beginInlineImage")}beginImageData(){_t("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=ae(this.ctx),e)){const t=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],t,i),this.current.updateRectMinMax(ae(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||yt("TODO: Support non-isolated groups."),t.knockout&&At("Knockout groups not supported.");const i=ae(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let s=jt.getAxialAlignedBoundingBox(t.bbox,ae(e));const n=[0,0,e.canvas.width,e.canvas.height];s=jt.intersect(s,n)||[0,0,0,0];const r=Math.floor(s[0]),a=Math.floor(s[1]),o=Math.max(Math.ceil(s[2])-r,1),l=Math.max(Math.ceil(s[3])-a,1);this.current.startNewPathAndClipBox([0,0,o,l]);let h="groupAt"+this.groupLevel;t.smask&&(h+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(h,o,l),c=d.context;c.translate(-r,-a),c.transform(...i),t.smask?this.smaskStack.push({canvas:d.canvas,context:c,offsetX:r,offsetY:a,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(r,a),e.save()),vi(e,c),this.ctx=c,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const t=ae(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const i=jt.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(t,e,i,s,n){if(this.#hi(),wi(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const s=e[2]-e[0],r=e[3]-e[1];if(n&&this.annotationCanvasMap){(i=i.slice())[4]-=e[0],i[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=s,e[3]=r;const[n,a]=jt.singularValueDecompose2dScale(ae(this.ctx)),{viewportScale:o}=this,l=Math.ceil(s*this.outputScaleX*o),h=Math.ceil(r*this.outputScaleY*o);this.annotationCanvas=this.canvasFactory.create(l,h);const{canvas:d,context:c}=this.annotationCanvas;this.annotationCanvasMap.set(t,d),this.annotationCanvas.savedCtx=this.ctx,this.ctx=c,this.ctx.save(),this.ctx.setTransform(n,0,0,-a,0,r*a),wi(this.ctx)}else wi(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],s,r),this.ctx.clip(),this.ctx.beginPath()}this.current=new fi(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#di(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;(t=this.getObject(t.data,t)).count=e;const i=this.ctx,s=this.processingType3;if(s&&(void 0===s.compiled&&(s.compiled=function(t){const{width:e,height:i}=t;if(e>1e3||i>1e3)return null;const s=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=e+1;let r,a,o,l=new Uint8Array(n*(i+1));const h=e+7&-8;let d=new Uint8Array(h*i),c=0;for(const e of t.data){let t=128;for(;t>0;)d[c++]=e&t?0:255,t>>=1}let u=0;for(c=0,0!==d[c]&&(l[0]=1,++u),a=1;a<e;a++)d[c]!==d[c+1]&&(l[a]=d[c]?2:1,++u),c++;for(0!==d[c]&&(l[a]=2,++u),r=1;r<i;r++){c=r*h,o=r*n,d[c-h]!==d[c]&&(l[o]=d[c]?1:8,++u);let t=(d[c]?4:0)+(d[c-h]?8:0);for(a=1;a<e;a++)t=(t>>2)+(d[c+1]?4:0)+(d[c-h+1]?8:0),s[t]&&(l[o+a]=s[t],++u),c++;if(d[c-h]!==d[c]&&(l[o+a]=d[c]?2:4,++u),u>1e3)return null}for(c=h*(i-1),o=r*n,0!==d[c]&&(l[o]=8,++u),a=1;a<e;a++)d[c]!==d[c+1]&&(l[o+a]=d[c]?4:8,++u),c++;if(0!==d[c]&&(l[o+a]=4,++u),u>1e3)return null;const p=new Int32Array([0,n,-1,0,-n,0,0,0,1]),g=new Path2D;for(r=0;u&&r<=i;r++){let t=r*n;const i=t+e;for(;t<i&&!l[t];)t++;if(t===i)continue;g.moveTo(t%n,r);const s=t;let a=l[t];do{const e=p[a];do{t+=e}while(!l[t]);const i=l[t];5!==i&&10!==i?(a=i,l[t]=0):(a=i&51*a>>4,l[t]&=a>>2|a<<2),g.lineTo(t%n,t/n|0),l[t]||--u}while(s!==t);--r}return d=null,l=null,function(t){t.save(),t.scale(1/e,-1/i),t.translate(0,-i),t.fill(g),t.beginPath(),t.restore()}}(t)),s.compiled))return void s.compiled(i);const n=this._createMaskCanvas(t),r=n.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(r,n.offsetX,n.offsetY),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i=0,s=0,n,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);const a=this.ctx;a.save();const o=ae(a);a.transform(e,i,s,n,0,0);const l=this._createMaskCanvas(t);a.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(let t=0,h=r.length;t<h;t+=2){const h=jt.transform(o,[e,i,s,n,r[t],r[t+1]]),[d,c]=jt.applyTransform([0,0],h);a.drawImage(l.canvas,d,c)}a.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,i=this.current.fillColor,s=this.current.patternFill;for(const n of t){const{data:t,width:r,height:a,transform:o}=n,l=this.cachedCanvases.getCanvas("maskCanvas",r,a),h=l.context;h.save();bi(h,this.getObject(t,n)),h.globalCompositeOperation="source-in",h.fillStyle=s?i.getPattern(h,this,oe(e),Je):i,h.fillRect(0,0,r,a),h.restore(),e.save(),e.transform(...o),e.scale(1,-1),gi(e,l.canvas,0,0,r,a,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):At("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s){if(!this.contentVisible)return;const n=this.getObject(t);if(!n)return void At("Dependent image isn't ready yet");const r=n.width,a=n.height,o=[];for(let t=0,n=s.length;t<n;t+=2)o.push({transform:[e,0,0,i,s[t],s[t+1]],x:0,y:0,w:r,h:a});this.paintInlineImageXObjectGroup(n,o)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;const{bitmap:e,width:i,height:s}=t,n=this.cachedCanvases.getCanvas("inlineImage",i,s),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,i=t.height,s=this.ctx;if(this.save(),!_){const{filter:t}=s;"none"!==t&&""!==t&&(s.filter="none")}let n;if(s.scale(1/e,-1/i),t.bitmap)n=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)n=t;else{const s=this.cachedCanvases.getCanvas("inlineImage",e,i).context;mi(s,t),n=this.applyTransferMapsToCanvas(s)}const r=this._scaleImage(n,oe(s));s.imageSmoothingEnabled=yi(ae(s),t.interpolate),gi(s,r.img,0,0,r.paintWidth,r.paintHeight,0,-i,e,i),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const i=this.ctx;let s;if(t.bitmap)s=t.bitmap;else{const e=t.width,i=t.height,n=this.cachedCanvases.getCanvas("inlineImage",e,i).context;mi(n,t),s=this.applyTransferMapsToCanvas(n)}for(const t of e)i.save(),i.transform(...t.transform),i.scale(1,-1),gi(i,s,t.x,t.y,t.w,t.h,0,-1,1,1),i.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const i=this.ctx;this.pendingClip&&(e||(this.pendingClip===Si?i.clip("evenodd"):i.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),i.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=ae(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:i,c:s,d:n}=this.ctx.getTransform();let r,a;if(0===i&&0===s){const i=Math.abs(e),s=Math.abs(n);if(i===s)if(0===t)r=a=1/i;else{const e=i*t;r=a=e<1?1/e:1}else if(0===t)r=1/i,a=1/s;else{const e=i*t,n=s*t;r=e<1?1/e:1,a=n<1?1/n:1}}else{const o=Math.abs(e*n-i*s),l=Math.hypot(e,i),h=Math.hypot(s,n);if(0===t)r=h/o,a=l/o;else{const e=t*o;r=h>e?h/e:1,a=l>e?l/e:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:i}=this.current,[s,n]=this.getScaleForStroking();if(e.lineWidth=i||1,1===s&&1===n)return void e.stroke();const r=e.getLineDash();if(t&&e.save(),e.scale(s,n),r.length>0){const t=Math.max(s,n);e.setLineDash(r.map((e=>e/t))),e.lineDashOffset/=t}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const t in ft)void 0!==Ci.prototype[t]&&(Ci.prototype[ft[t]]=Ci.prototype[t]);let Ei=class{static#ui=null;static#pi="";static get workerPort(){return this.#ui}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#ui=t}static get workerSrc(){return this.#pi}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#pi=t}};class Pi{#gi;#fi;constructor({parsedData:t,rawData:e}){this.#gi=t,this.#fi=e}getRaw(){return this.#fi}get(t){return this.#gi.get(t)??null}getAll(){return Ft(this.#gi)}has(t){return this.#gi.has(t)}}const Mi=Symbol("INTERNAL");class Ti{#mi=!1;#bi=!1;#vi=!1;#wi=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){this.#mi=!!(t&P),this.#bi=!!(t&M),this.name=e,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(this.#vi)return this.#wi;if(!this.#wi)return!1;const{print:t,view:e}=this.usage;return this.#mi?"OFF"!==e?.viewState:!this.#bi||"OFF"!==t?.printState}_setVisible(t,e,i=!1){t!==Mi&&_t("Internal method `_setVisible` called."),this.#vi=i,this.#wi=e}}class ki{#yi=null;#Ai=new Map;#_i=null;#xi=null;constructor(t,e=P){if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#xi=t.order;for(const i of t.groups)this.#Ai.set(i.id,new Ti(e,i));if("OFF"===t.baseState)for(const t of this.#Ai.values())t._setVisible(Mi,!1);for(const e of t.on)this.#Ai.get(e)._setVisible(Mi,!0);for(const e of t.off)this.#Ai.get(e)._setVisible(Mi,!1);this.#_i=this.getHash()}}#Si(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let s=1;s<e;s++){const e=t[s];let n;if(Array.isArray(e))n=this.#Si(e);else{if(!this.#Ai.has(e))return At(`Optional content group not found: ${e}`),!0;n=this.#Ai.get(e).visible}switch(i){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return"And"===i}isVisible(t){if(0===this.#Ai.size)return!0;if(!t)return yt("Optional content group not defined."),!0;if("OCG"===t.type)return this.#Ai.has(t.id)?this.#Ai.get(t.id).visible:(At(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#Si(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return At(`Optional content group not found: ${e}`),!0;if(this.#Ai.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return At(`Optional content group not found: ${e}`),!0;if(!this.#Ai.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return At(`Optional content group not found: ${e}`),!0;if(!this.#Ai.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return At(`Optional content group not found: ${e}`),!0;if(this.#Ai.get(e).visible)return!1}return!0}return At(`Unknown optional content policy ${t.policy}.`),!0}return At(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){const s=this.#Ai.get(t);if(s){if(i&&e&&s.rbGroups.length)for(const e of s.rbGroups)for(const i of e)i!==t&&this.#Ai.get(i)?._setVisible(Mi,!1,!0);s._setVisible(Mi,!!e,!0),this.#yi=null}else At(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let i;for(const s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}const t=this.#Ai.get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}this.#yi=null}get hasInitialVisibility(){return null===this.#_i||this.getHash()===this.#_i}getOrder(){return this.#Ai.size?this.#xi?this.#xi.slice():[...this.#Ai.keys()]:null}getGroups(){return this.#Ai.size>0?Ft(this.#Ai):null}getGroup(t){return this.#Ai.get(t)||null}getHash(){if(null!==this.#yi)return this.#yi;const t=new Ee;for(const[e,i]of this.#Ai)t.update(`${e}:${i.visible}`);return this.#yi=t.hexdigest()}}class Ii{constructor(t,{disableRange:e=!1,disableStream:i=!1}){xt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:n,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,n?.length>0){const t=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener(((t,e)=>{this._onReceiveData({begin:t,chunk:e})})),t.addProgressListener(((t,e)=>{this._onProgress({loaded:t,total:e})})),t.addProgressiveReadListener((t=>{this._onReceiveData({chunk:t})})),t.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(void 0===t)this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i);else{xt(this._rangeReaders.some((function(e){return e._begin===t&&(e._enqueue(i),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){void 0===t.total?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){xt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Li(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Di(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class Li{constructor(t,e,i=!1,s=null){this._stream=t,this._done=i||!1,this._filename=Yt(s)?s:null,this._queuedChunks=e||[],this._loaded=0;for(const t of this._queuedChunks)this._loaded+=t.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._queuedChunks.push(t);this._loaded+=t.byteLength}}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0){return{value:this._queuedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Di{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Ri(t,e){const i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(const t in e){const s=e[t];void 0!==s&&i.append(t,s)}return i}function Ni(t){try{return new URL(t).origin}catch{}return null}function Fi({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){const n={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(r))return n;if(n.suggestedLength=r,r<=2*i)return n;if(s||!e)return n;if("bytes"!==t.get("Accept-Ranges"))return n;return"identity"!==(t.get("Content-Encoding")||"identity")||(n.allowRangeRequests=!0),n}function Oi(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){i=i[1];let t=a(i);return t=unescape(t),t=o(t),t=l(t),r(t)}if(i=function(t){const e=[];let i;const n=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=n.exec(t));){let[,t,s,n]=i;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[s,n]}const r=[];for(let t=0;t<e.length&&t in e;++t){let[i,s]=e[t];s=a(s),i&&(s=unescape(s),0===t&&(s=o(s))),r.push(s)}return r.join("")}(t),i)return r(l(i));if(i=s("filename","i").exec(t),i){i=i[1];let t=a(i);return t=l(t),r(t)}function s(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function n(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const s=new TextDecoder(t,{fatal:!0}),n=Nt(i);i=s.decode(n),e=!1}catch{}}return i}function r(t){return e&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),e&&(t=n("iso-8859-1",t))),t}function a(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){const e=t.indexOf("'");return-1===e?t:n(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(t,e,i,s){if("q"===i||"Q"===i)return n(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))})));try{s=atob(s)}catch{}return n(e,s)}))}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(Yt(t))return t}return null}function Bi(t,e){return 404===t||0===t&&e.startsWith("file:")?new kt('Missing PDF "'+e+'".'):new It(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t)}function ji(t){return 200===t||206===t}function Vi(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function Hi(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(At(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class zi{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=Ri(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return xt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Ui(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new $i(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Ui{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const i=new Headers(t.headers),s=e.url;fetch(s,Vi(i,this._withCredentials,this._abortController)).then((e=>{if(t._responseOrigin=Ni(e.url),!ji(e.status))throw Bi(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();const i=e.headers,{allowRangeRequests:n,suggestedLength:r}=Fi({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=r||this._contentLength,this._filename=Oi(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Dt("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:Hi(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class $i{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;const n=new Headers(t.headers);n.append("Range",`bytes=${e}-${i-1}`);const r=s.url;fetch(r,Vi(n,this._withCredentials,this._abortController)).then((e=>{const i=Ni(e.url);if(i!==t._responseOrigin)throw new Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!ji(e.status))throw Bi(e.status,r);this._readCapability.resolve(),this._reader=e.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:Hi(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Wi{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Ri(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,i=this.currXhrId++,s=this.pendingRequests[i]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[t,i]of this.headers)e.setRequestHeader(t,i);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.expectedStatus=206):s.expectedStatus=200,e.responseType="arraybuffer",xt(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){const i=this.pendingRequests[t];i&&i.onProgress?.(e)}onStateChange(t,e){const i=this.pendingRequests[t];if(!i)return;const s=i.xhr;if(s.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==s.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===s.status&&this.isHttp)return void i.onError(s.status);const n=s.status||200;if(!(200===n&&206===i.expectedStatus)&&n!==i.expectedStatus)return void i.onError(s.status);const r=function(t){const e=t.response;return"string"!=typeof e?e:Nt(e).buffer}(s);if(206===n){const t=s.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?i.onDone({begin:parseInt(e[1],10),chunk:r}):(At('Missing or invalid "Content-Range" header.'),i.onError(0))}else r?i.onDone({begin:0,chunk:r}):i.onError(s.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class Gi{constructor(t){this._source=t,this._manager=new Wi(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return xt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new qi(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new Xi(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class qi{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=Ni(e.responseURL);const i=e.getAllResponseHeaders(),s=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((t=>{const[e,...i]=t.split(": ");return[e,i.join(": ")]})):[]),{allowRangeRequests:n,suggestedLength:r}=Fi({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=Oi(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t)if(this._requests.length>0){this._requests.shift().resolve({value:t.chunk,done:!1})}else this._cachedChunks.push(t.chunk);if(this._done=!0,!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Bi(t,this._url),this._headersCapability.reject(this._storedError);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0){return{value:this._cachedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Xi{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const t=Ni(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunk=e;this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??=Bi(t,this._url);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const Ki=/^[a-z][a-z0-9\-+.]+:/i;class Yi{constructor(t){this.source=t,this.url=function(t){if(Ki.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),xt("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return xt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Qi(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Ji(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Qi{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=process.getBuiltinModule("fs");i.promises.lstat(this._url).then((t=>{this._contentLength=t.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()}),(t=>{"ENOENT"===t.code&&(t=new kt(`Missing PDF "${this._url}".`)),this._storedError=t,this._headersCapability.reject(t)}))}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Dt("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Ji{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const s=t.source;this._isStreamingSupported=!s.disableStream;const n=process.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:e,end:i-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),this._storedError&&this._readableStream.destroy(this._storedError)}}const Zi=30;let ts=class t{#Ci=Promise.withResolvers();#pt=null;#Ei=!1;#Pi=!!globalThis.FontInspector?.enabled;#Mi=null;#Ti=null;#ki=0;#Ii=0;#Li=null;#Di=null;#Ri=0;#Ni=0;#Fi=Object.create(null);#Oi=[];#Bi=null;#ji=[];#Vi=new WeakMap;#Hi=null;static#zi=new Map;static#Ui=new Map;static#$i=new WeakMap;static#Wi=null;static#Gi=new Set;constructor({textContentSource:e,container:i,viewport:s}){if(e instanceof ReadableStream)this.#Bi=e;else{if("object"!=typeof e)throw new Error('No "textContentSource" parameter specified.');this.#Bi=new ReadableStream({start(t){t.enqueue(e),t.close()}})}this.#pt=this.#Di=i,this.#Ni=s.scale*(globalThis.devicePixelRatio||1),this.#Ri=s.rotation,this.#Ti={div:null,properties:null,ctx:null};const{pageWidth:n,pageHeight:r,pageX:a,pageY:o}=s.rawDims;this.#Hi=[1,0,0,-1,-a,o+r],this.#Ii=n,this.#ki=r,t.#qi(),le(i,s),this.#Ci.promise.finally((()=>{t.#Gi.delete(this),this.#Ti=null,this.#Fi=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=Ot.platform;return Ct(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const e=()=>{this.#Li.read().then((({value:t,done:i})=>{i?this.#Ci.resolve():(this.#Mi??=t.lang,Object.assign(this.#Fi,t.styles),this.#Xi(t.items),e())}),this.#Ci.reject)};return this.#Li=this.#Bi.getReader(),t.#Gi.add(this),e(),this.#Ci.promise}update({viewport:e,onBefore:i=null}){const s=e.scale*(globalThis.devicePixelRatio||1),n=e.rotation;if(n!==this.#Ri&&(i?.(),this.#Ri=n,le(this.#Di,{rotation:n})),s!==this.#Ni){i?.(),this.#Ni=s;const e={div:null,properties:null,ctx:t.#Ki(this.#Mi)};for(const t of this.#ji)e.properties=this.#Vi.get(t),e.div=t,this.#Yi(e)}}cancel(){const t=new Dt("TextLayer task cancelled.");this.#Li?.cancel(t).catch((()=>{})),this.#Li=null,this.#Ci.reject(t)}get textDivs(){return this.#ji}get textContentItemsStr(){return this.#Oi}#Xi(e){if(this.#Ei)return;this.#Ti.ctx??=t.#Ki(this.#Mi);const i=this.#ji,s=this.#Oi;for(const t of e){if(i.length>1e5)return At("Ignoring additional textDivs for performance reasons."),void(this.#Ei=!0);if(void 0!==t.str)s.push(t.str),this.#Qi(t);else if("beginMarkedContentProps"===t.type||"beginMarkedContent"===t.type){const e=this.#pt;this.#pt=document.createElement("span"),this.#pt.classList.add("markedContent"),null!==t.id&&this.#pt.setAttribute("id",`${t.id}`),e.append(this.#pt)}else"endMarkedContent"===t.type&&(this.#pt=this.#pt.parentNode)}}#Qi(e){const i=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,fontSize:0};this.#ji.push(i);const n=jt.transform(this.#Hi,e.transform);let r=Math.atan2(n[1],n[0]);const a=this.#Fi[e.fontName];a.vertical&&(r+=Math.PI/2);let o=this.#Pi&&a.fontSubstitution||a.fontFamily;o=t.fontFamilyMap.get(o)||o;const l=Math.hypot(n[2],n[3]),h=l*t.#Ji(o,this.#Mi);let d,c;0===r?(d=n[4],c=n[5]-h):(d=n[4]+h*Math.sin(r),c=n[5]-h*Math.cos(r));const u="calc(var(--scale-factor)*",p=i.style;this.#pt===this.#Di?(p.left=`${(100*d/this.#Ii).toFixed(2)}%`,p.top=`${(100*c/this.#ki).toFixed(2)}%`):(p.left=`${u}${d.toFixed(2)}px)`,p.top=`${u}${c.toFixed(2)}px)`),p.fontSize=`${u}${(t.#Wi*l).toFixed(2)}px)`,p.fontFamily=o,s.fontSize=l,i.setAttribute("role","presentation"),i.textContent=e.str,i.dir=e.dir,this.#Pi&&(i.dataset.fontName=a.fontSubstitutionLoadedName||e.fontName),0!==r&&(s.angle=r*(180/Math.PI));let g=!1;if(e.str.length>1)g=!0;else if(" "!==e.str&&e.transform[0]!==e.transform[3]){const t=Math.abs(e.transform[0]),i=Math.abs(e.transform[3]);t!==i&&Math.max(t,i)/Math.min(t,i)>1.5&&(g=!0)}if(g&&(s.canvasWidth=a.vertical?e.height:e.width),this.#Vi.set(i,s),this.#Ti.div=i,this.#Ti.properties=s,this.#Yi(this.#Ti),s.hasText&&this.#pt.append(i),s.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#pt.append(t)}}#Yi(e){const{div:i,properties:s,ctx:n}=e,{style:r}=i;let a="";if(t.#Wi>1&&(a=`scale(${1/t.#Wi})`),0!==s.canvasWidth&&s.hasText){const{fontFamily:e}=r,{canvasWidth:o,fontSize:l}=s;t.#Zi(n,l*this.#Ni,e);const{width:h}=n.measureText(i.textContent);h>0&&(a=`scaleX(${o*this.#Ni/h}) ${a}`)}0!==s.angle&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(r.transform=a)}static cleanup(){if(!(this.#Gi.size>0)){this.#zi.clear();for(const{canvas:t}of this.#Ui.values())t.remove();this.#Ui.clear()}}static#Ki(t=null){let e=this.#Ui.get(t||="");if(!e){const i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#Ui.set(t,e),this.#$i.set(e,{size:0,family:""})}return e}static#Zi(t,e,i){const s=this.#$i.get(t);e===s.size&&i===s.family||(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static#qi(){if(null!==this.#Wi)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#Wi=t.getBoundingClientRect().height,t.remove()}static#Ji(t,e){const i=this.#zi.get(t);if(i)return i;const s=this.#Ki(e);s.canvas.width=s.canvas.height=Zi,this.#Zi(s,Zi,t);const n=s.measureText("");let r=n.fontBoundingBoxAscent,a=Math.abs(n.fontBoundingBoxDescent);if(r){const e=r/(r+a);return this.#zi.set(t,e),s.canvas.width=s.canvas.height=0,e}s.strokeStyle="red",s.clearRect(0,0,Zi,Zi),s.strokeText("g",0,0);let o=s.getImageData(0,0,Zi,Zi).data;a=0;for(let t=o.length-1-3;t>=0;t-=4)if(o[t]>0){a=Math.ceil(t/4/Zi);break}s.clearRect(0,0,Zi,Zi),s.strokeText("A",0,Zi),o=s.getImageData(0,0,Zi,Zi).data,r=0;for(let t=0,e=o.length;t<e;t+=4)if(o[t]>0){r=Zi-Math.floor(t/4/Zi);break}s.canvas.width=s.canvas.height=0;const l=r?r/(r+a):.8;return this.#zi.set(t,l),l}};class es{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};return function t(i){if(!i)return;let s=null;const n=i.name;if("#text"===n)s=i.value;else{if(!es.shouldBuildText(n))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(const e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}const is=65536,ss=_?class extends We{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire("undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:n&&"SCRIPT"===n.tagName.toUpperCase()&&n.src||new URL("index.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(t,e)}}:class extends We{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const i=this._document.createElement("canvas");return i.width=t,i.height=e,i}},ns=_?class extends Ge{async _fetch(t){return Qe(t)}}:qe,rs=_?class extends Xe{}:class extends Xe{#ts;#es;#is;#ss;#ns;#rs;#w=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#ss=t,this.#ns=e}get#A(){return this.#es||=new Map}get#as(){return this.#rs||=new Map}get#os(){if(!this.#is){const t=this.#ns.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const i=this.#ns.createElementNS($t,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#is=this.#ns.createElementNS($t,"defs"),t.append(i),i.append(this.#is),this.#ns.body.append(t)}return this.#is}#ls(t){if(1===t.length){const e=t[0],i=new Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;const s=i.join(",");return[s,s,s]}const[e,i,s]=t,n=new Array(256),r=new Array(256),a=new Array(256);for(let t=0;t<256;t++)n[t]=e[t]/255,r[t]=i[t]/255,a[t]=s[t]/255;return[n.join(","),r.join(","),a.join(",")]}#hs(t){if(void 0===this.#ts){this.#ts="";const t=this.#ns.URL;t!==this.#ns.baseURI&&(Kt(t)?At('#createUrl: ignore "data:"-URL for performance reasons.'):this.#ts=t.split("#",1)[0])}return`url(${this.#ts}#${t})`}addFilter(t){if(!t)return"none";let e=this.#A.get(t);if(e)return e;const[i,s,n]=this.#ls(t),r=1===t.length?i:`${i}${s}${n}`;if(e=this.#A.get(r),e)return this.#A.set(t,e),e;const a=`g_${this.#ss}_transfer_map_${this.#w++}`,o=this.#hs(a);this.#A.set(t,o),this.#A.set(r,o);const l=this.#ds(a);return this.#cs(i,s,n,l),o}addHCMFilter(t,e){const i=`${t}-${e}`,s="base";let n=this.#as.get(s);if(n?.key===i)return n.url;if(n?(n.filter?.remove(),n.key=i,n.url="none",n.filter=null):(n={key:i,url:"none",filter:null},this.#as.set(s,n)),!t||!e)return n.url;const r=this.#us(t);t=jt.makeHexColor(...r);const a=this.#us(e);if(e=jt.makeHexColor(...a),this.#os.style.color="","#000000"===t&&"#ffffff"===e||t===e)return n.url;const o=new Array(256);for(let t=0;t<=255;t++){const e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const l=o.join(","),h=`g_${this.#ss}_hcm_filter`,d=n.filter=this.#ds(h);this.#cs(l,l,l,d),this.#ps(d);const c=(t,e)=>{const i=r[t]/255,s=a[t]/255,n=new Array(e+1);for(let t=0;t<=e;t++)n[t]=i+t/e*(s-i);return n.join(",")};return this.#cs(c(0,5),c(1,5),c(2,5),d),n.url=this.#hs(h),n.url}addAlphaFilter(t){let e=this.#A.get(t);if(e)return e;const[i]=this.#ls([t]),s=`alpha_${i}`;if(e=this.#A.get(s),e)return this.#A.set(t,e),e;const n=`g_${this.#ss}_alpha_map_${this.#w++}`,r=this.#hs(n);this.#A.set(t,r),this.#A.set(s,r);const a=this.#ds(n);return this.#gs(i,a),r}addLuminosityFilter(t){let e,i,s=this.#A.get(t||"luminosity");if(s)return s;if(t?([e]=this.#ls([t]),i=`luminosity_${e}`):i="luminosity",s=this.#A.get(i),s)return this.#A.set(t,s),s;const n=`g_${this.#ss}_luminosity_map_${this.#w++}`,r=this.#hs(n);this.#A.set(t,r),this.#A.set(i,r);const a=this.#ds(n);return this.#fs(a),t&&this.#gs(e,a),r}addHighlightHCMFilter(t,e,i,s,n){const r=`${e}-${i}-${s}-${n}`;let a=this.#as.get(t);if(a?.key===r)return a.url;if(a?(a.filter?.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},this.#as.set(t,a)),!e||!i)return a.url;const[o,l]=[e,i].map(this.#us.bind(this));let h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[c,u]=[s,n].map(this.#us.bind(this));d<h&&([h,d,c,u]=[d,h,u,c]),this.#os.style.color="";const p=(t,e,i)=>{const s=new Array(256),n=(d-h)/i,r=t/255,a=(e-t)/(255*i);let o=0;for(let t=0;t<=i;t++){const e=Math.round(h+t*n),i=r+t*a;for(let t=o;t<=e;t++)s[t]=i;o=e+1}for(let t=o;t<256;t++)s[t]=s[o-1];return s.join(",")},g=`g_${this.#ss}_hcm_${t}_filter`,f=a.filter=this.#ds(g);return this.#ps(f),this.#cs(p(c[0],u[0],5),p(c[1],u[1],5),p(c[2],u[2],5),f),a.url=this.#hs(g),a.url}destroy(t=!1){t&&this.#rs?.size||(this.#is?.parentNode.parentNode.remove(),this.#is=null,this.#es?.clear(),this.#es=null,this.#rs?.clear(),this.#rs=null,this.#w=0)}#fs(t){const e=this.#ns.createElementNS($t,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#ps(t){const e=this.#ns.createElementNS($t,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#ds(t){const e=this.#ns.createElementNS($t,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#os.append(e),e}#ms(t,e,i){const s=this.#ns.createElementNS($t,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#cs(t,e,i,s){const n=this.#ns.createElementNS($t,"feComponentTransfer");s.append(n),this.#ms(n,"feFuncR",t),this.#ms(n,"feFuncG",e),this.#ms(n,"feFuncB",i)}#gs(t,e){const i=this.#ns.createElementNS($t,"feComponentTransfer");e.append(i),this.#ms(i,"feFuncA",t)}#us(t){return this.#os.style.color=t,re(getComputedStyle(this.#os).getPropertyValue("color"))}},as=_?class extends Ke{async _fetch(t){return Qe(t)}}:Ye;function os(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new hs,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;try{return new URL(t,window.location).href}catch{if(_&&"string"==typeof t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(_&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return Nt(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,r=t.httpHeaders||null,a=!0===t.withCredentials,o=t.password??null,l=t.range instanceof ds?t.range:null,h=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:is;let d=t.worker instanceof gs?t.worker:null;const c=t.verbosity,u="string"!=typeof t.docBaseUrl||Kt(t.docBaseUrl)?null:t.docBaseUrl,p="string"==typeof t.cMapUrl?t.cMapUrl:null,g=!1!==t.cMapPacked,f=t.CMapReaderFactory||ns,m="string"==typeof t.standardFontDataUrl?t.standardFontDataUrl:null,b=t.StandardFontDataFactory||as,v=!0!==t.stopAtErrors,w=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,y=!1!==t.isEvalSupported,A="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!_,x="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!_&&(Ot.platform.isFirefox||!globalThis.chrome),S=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,C="boolean"==typeof t.disableFontFace?t.disableFontFace:_,E=!0===t.fontExtraProperties,P=!0===t.enableXfa,M=t.ownerDocument||globalThis.document,T=!0===t.disableRange,k=!0===t.disableStream,I=!0===t.disableAutoFetch,L=!0===t.pdfBug,D=t.CanvasFactory||ss,R=t.FilterFactory||rs,N=!0===t.enableHWA,F=l?l.length:t.length??NaN,O="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!_&&!C,B="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:f===qe&&b===Ye&&p&&m&&te(p,document.baseURI)&&te(m,document.baseURI);vt(c);const j={canvasFactory:new D({ownerDocument:M,enableHWA:N}),filterFactory:new R({docId:i,ownerDocument:M}),cMapReaderFactory:B?null:new f({baseUrl:p,isCompressed:g}),standardFontDataFactory:B?null:new b({baseUrl:m})};if(!d){const t={verbosity:c,port:Ei.workerPort};d=t.port?gs.fromPort(t):new gs(t),e._worker=d}const V={docId:i,apiVersion:"4.10.38",data:n,password:o,disableAutoFetch:I,rangeChunkSize:h,length:F,docBaseUrl:u,enableXfa:P,evaluatorOptions:{maxImageSize:w,disableFontFace:C,ignoreErrors:v,isEvalSupported:y,isOffscreenCanvasSupported:A,isImageDecoderSupported:x,canvasMaxAreaInBytes:S,fontExtraProperties:E,useSystemFonts:O,cMapUrl:B?p:null,standardFontDataUrl:B?m:null}},H={disableFontFace:C,fontExtraProperties:E,ownerDocument:M,pdfBug:L,styleElement:null,loadingParams:{disableAutoFetch:I,enableXfa:P}};return d.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const t=d.messageHandler.sendWithPromise("GetDocRequest",V,n?[n.buffer]:null);let o;if(l)o=new Ii(l,{disableRange:T,disableStream:k});else if(!n){if(!s)throw new Error("getDocument - no `url` parameter provided.");let t;if(_)if(te(s)){if("undefined"==typeof fetch||"undefined"==typeof Response||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");t=zi}else t=Yi;else t=te(s)?zi:Gi;o=new t({url:s,length:F,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:T,disableStream:k})}return t.then((t=>{if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const s=new $e(i,t,d.port),n=new fs(s,e,o,H,j);e._transport=n,s.send("Ready",null)}))})).catch(e._capability.reject),e}function ls(t){return"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0}class hs{static#ss=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+hs.#ss++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await(this._transport?.destroy())}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}}let ds=class{constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(const i of this._rangeListeners)i(t,e)}onDataProgress(t,e){this._readyCapability.promise.then((()=>{for(const i of this._progressListeners)i(t,e)}))}onDataProgressiveRead(t){this._readyCapability.promise.then((()=>{for(const e of this._progressiveReadListeners)e(t)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(const t of this._progressiveDoneListeners)t()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){_t("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class cs{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Ct(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class us{#bs=null;#vs=!1;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new Zt:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new bs,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new qt({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Ct(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:i="display",annotationMode:s=R.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:a=null,annotationCanvasMap:o=null,pageColors:l=null,printAnnotationStorage:h=null,isEditing:d=!1}){this._stats?.time("Overall");const c=this._transport.getRenderingIntent(i,s,h,d),{renderingIntent:u,cacheKey:p}=c;this.#vs=!1,this.#ws(),a||=this._transport.getOptionalContentConfig(u);let g=this._intentStates.get(p);g||(g=Object.create(null),this._intentStates.set(p,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);const f=!!(u&M);g.displayReadyCapability||(g.displayReadyCapability=Promise.withResolvers(),g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(c));const m=t=>{g.renderTasks.delete(b),(this._maybeCleanupAfterRender||f)&&(this.#vs=!0),this.#ys(!f),t?(b.capability.reject(t),this._abortOperatorList({intentState:g,reason:t instanceof Error?t:new Error(t)})):b.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},b=new ws({callback:m,params:{canvasContext:t,viewport:e,transform:n,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!f,pdfBug:this._pdfBug,pageColors:l});(g.renderTasks||=new Set).add(b);const v=b.task;return Promise.all([g.displayReadyCapability.promise,a]).then((([t,e])=>{if(this.destroyed)m();else{if(this._stats?.time("Rendering"),!(e.renderingIntent&u))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");b.initializeGraphics({transparency:t,optionalContentConfig:e}),b.operatorListChanged()}})).catch(m),v}getOperatorList({intent:t="display",annotationMode:e=R.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){const n=this._transport.getRenderingIntent(t,e,i,s,!0);let r,a=this._intentStates.get(n.cacheKey);return a||(a=Object.create(null),this._intentStates.set(n.cacheKey,a)),a.opListReadCapability||(r=Object.create(null),r.operatorListChanged=function(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(r))},a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(r),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then((t=>es.textContent(t)));const e=this.streamTextContent(t);return new Promise((function(t,i){const s=e.getReader(),n={items:[],styles:Object.create(null),lang:null};!function e(){s.read().then((function({value:i,done:s}){s?t(n):(n.lang??=i.lang,Object.assign(n.styles,i.styles),n.items.push(...i.items),e())}),i)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#vs=!1,this.#ws(),Promise.all(t)}cleanup(t=!1){this.#vs=!0;const e=this.#ys(!1);return t&&e&&(this._stats&&=new Zt),e}#ys(t=!1){if(this.#ws(),!this.#vs||this.destroyed)return!1;if(t)return this.#bs=setTimeout((()=>{this.#bs=null,this.#ys(!1)}),5e3),!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#vs=!1,!0}#ws(){this.#bs&&(clearTimeout(this.#bs),this.#bs=null)}_startRenderPage(t,e){const i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const t of e.renderTasks)t.operatorListChanged();t.lastChunk&&this.#ys(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){const{map:n,transfer:r}=i,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:s},r).getReader(),o=this._intentStates.get(e);o.streamReader=a;const l=()=>{a.read().then((({value:t,done:e})=>{e?o.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,o),l())}),(t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const t of o.renderTasks)t.operatorListChanged();this.#ys(!0)}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else{if(!o.opListReadCapability)throw t;o.opListReadCapability.reject(t)}}}))};l()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof Xt){let i=100;return e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout((()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})}),i))}}if(t.streamReader.cancel(new Dt(e.message)).catch((()=>{})),t.streamReader=null,!this._transport.destroyed){for(const[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class ps{#As=new Map;#_s=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#_s.then((()=>{for(const[t]of this.#As)t.call(this,i)}))}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){const{signal:n}=i;if(n.aborted)return void At("LoopbackPort - cannot use an `aborted` signal.");const r=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#As.set(e,s)}removeEventListener(t,e){const i=this.#As.get(e);i?.(),this.#As.delete(e)}terminate(){for(const[,t]of this.#As)t?.();this.#As.clear()}}let gs=class t{static#xs=0;static#Ss=!1;static#Cs;static{_&&(this.#Ss=!0,Ei.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let i;try{if(i=new URL(t),!i.origin||"null"===i.origin)return!1}catch{return!1}const s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:e=null,port:i=null,verbosity:s=wt()}={}){if(this.name=e,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,i){if(t.#Cs?.has(i))throw new Error("Cannot use more than one PDFWorker per port.");return(t.#Cs||=new WeakMap).set(i,this),void this._initializeFromPort(i)}this._initialize()}get promise(){return this._readyCapability.promise}#Es(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new $e("main","worker",t),this._messageHandler.on("ready",(function(){})),this.#Es()}_initialize(){if(t.#Ss||t.#Ps)return void this._setupFakeWorker();let{workerSrc:e}=t;try{t._isSameOrigin(window.location.href,e)||(e=t._createCDNWrapper(new URL(e,window.location).href));const i=new Worker(e,{type:"module"}),s=new $e("main","worker",i),n=()=>{r.abort(),s.destroy(),i.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},r=new AbortController;i.addEventListener("error",(()=>{this._webWorker||n()}),{signal:r.signal}),s.on("test",(t=>{r.abort(),!this.destroyed&&t?(this._messageHandler=s,this._port=i,this._webWorker=i,this.#Es()):n()})),s.on("ready",(t=>{if(r.abort(),this.destroyed)n();else try{a()}catch{this._setupFakeWorker()}}));const a=()=>{const t=new Uint8Array;s.send("test",t,[t.buffer])};return void a()}catch{yt("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){t.#Ss||(At("Setting up fake worker."),t.#Ss=!0),t._setupFakeWorkerGlobal.then((e=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const i=new ps;this._port=i;const s="fake"+t.#xs++,n=new $e(s+"_worker",s,i);e.setup(n,i),this._messageHandler=new $e(s,s+"_worker",i),this.#Es()})).catch((t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,t.#Cs?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(e){if(!e?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const i=this.#Cs?.get(e.port);if(i){if(i._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return i}return new t(e)}static get workerSrc(){if(Ei.workerSrc)return Ei.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#Ps(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return Ct(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#Ps)return this.#Ps;return(await import(this.workerSrc)).WorkerMessageHandler})())}};class fs{#Ms=new Map;#Ts=new Map;#ks=new Map;#Is=new Map;#Ls=null;constructor(t,e,i,s,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new bs,this.fontLoader=new ke({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#Ds(t,e=null){const i=this.#Ms.get(t);if(i)return i;const s=this.messageHandler.sendWithPromise(t,e);return this.#Ms.set(t,s),s}get annotationStorage(){return Ct(this,"annotationStorage",new Me)}getRenderingIntent(t,e=R.ENABLE,i=null,s=!1,n=!1){let r=P,a=Pe;switch(t){case"any":r=E;break;case"display":break;case"print":r=M;break;default:At(`getRenderingIntent - invalid intent: ${t}`)}const o=r&M&&i instanceof Te?i:this.annotationStorage;switch(e){case R.DISABLE:r+=I;break;case R.ENABLE:break;case R.ENABLE_FORMS:r+=T;break;case R.ENABLE_STORAGE:r+=k,a=o.serializable;break;default:At(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(r+=L),n&&(r+=D);const{ids:l,hash:h}=o.modifiedIds;return{renderingIntent:r,cacheKey:[r,a.hash,h].join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#Ls?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#Ts.values())t.push(e._destroy());this.#Ts.clear(),this.#ks.clear(),this.#Is.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#Ms.clear(),this.filterFactory.destroy(),ts.cleanup(),this._networkStream?.cancelAllRequests(new Dt("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",((t,e)=>{xt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then((function({value:t,done:i}){i?e.close():(xt(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}})),t.on("ReaderHeadersReady",(async t=>{await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:s,contentLength:n}=this._fullReader;return i&&s||(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),{isStreamingSupported:i,isRangeSupported:s,contentLength:n}})),t.on("GetRangeReader",((t,e)=>{xt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const i=this._networkStream.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then((function({value:t,done:i}){i?e.close():(xt(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{i.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}):e.close()})),t.on("GetDoc",(({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new cs(t,this))})),t.on("DocException",(t=>{e._capability.reject(Ue(t))})),t.on("PasswordRequest",(t=>{this.#Ls=Promise.withResolvers();try{if(!e.onPassword)throw Ue(t);const i=t=>{t instanceof Error?this.#Ls.reject(t):this.#Ls.resolve({password:t})};e.onPassword(i,t.code)}catch(t){this.#Ls.reject(t)}return this.#Ls.promise})),t.on("DataLoaded",(t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),t.on("StartRenderPage",(t=>{if(this.destroyed)return;this.#Ts.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),t.on("commonobj",(([e,i,s])=>{if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(i){case"Font":const{disableFontFace:n,fontExtraProperties:r,pdfBug:a}=this._params;if("error"in s){const t=s.error;At(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const o=a&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,l=new Ie(s,{disableFontFace:n,fontExtraProperties:r,inspectFont:o});this.fontLoader.bind(l).catch((()=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!r&&l.data&&(l.data=null),this.commonObjs.resolve(e,l)}));break;case"CopyLocalImage":const{imageRef:h}=s;xt(h,"The imageRef must be defined.");for(const t of this.#Ts.values())for(const[,i]of t.objs)if(i?.ref===h)return i.dataLen?(this.commonObjs.resolve(e,structuredClone(i)),i.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,s);break;default:throw new Error(`Got unknown common object type ${i}`)}return null})),t.on("obj",(([t,e,i,s])=>{if(this.destroyed)return;const n=this.#Ts.get(e);if(!n.objs.has(t))if(0!==n._intentStates.size)switch(i){case"Image":n.objs.resolve(t,s),s?.dataLen>1e7&&(n._maybeCleanupAfterRender=!0);break;case"Pattern":n.objs.resolve(t,s);break;default:throw new Error(`Got unknown object type ${i}`)}else s?.bitmap?.close()})),t.on("DocProgress",(t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})})),t.on("FetchBuiltInCMap",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(t)})),t.on("FetchStandardFontData",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(t)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&At("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally((()=>{this.annotationStorage.resetModified()}))}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,i=this.#ks.get(e);if(i)return i;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((i=>{if(this.destroyed)throw new Error("Transport destroyed");i.refStr&&this.#Is.set(i.refStr,t);const s=new us(e,i,this,this._params.pdfBug);return this.#Ts.set(e,s),s}));return this.#ks.set(e,s),s}getPageIndex(t){return ls(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#Ds("GetFieldObjects")}hasJSActions(){return this.#Ds("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#Ds("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#Ds("GetOptionalContentConfig").then((e=>new ki(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#Ms.get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new Pi(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#Ms.set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of this.#Ts.values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),this.#Ms.clear(),this.filterFactory.destroy(!0),ts.cleanup()}}cachedPageNumber(t){if(!ls(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#Is.get(e)??null}}const ms=Symbol("INITIAL_DATA");class bs{#Rs=Object.create(null);#Ns(t){return this.#Rs[t]||={...Promise.withResolvers(),data:ms}}get(t,e=null){if(e){const i=this.#Ns(t);return i.promise.then((()=>e(i.data))),null}const i=this.#Rs[t];if(!i||i.data===ms)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#Rs[t];return!!e&&e.data!==ms}delete(t){const e=this.#Rs[t];return!(!e||e.data===ms)&&(delete this.#Rs[t],!0)}resolve(t,e=null){const i=this.#Ns(t);i.data=e,i.resolve()}clear(){for(const t in this.#Rs){const{data:e}=this.#Rs[t];e?.bitmap?.close()}this.#Rs=Object.create(null)}*[Symbol.iterator](){for(const t in this.#Rs){const{data:e}=this.#Rs[t];e!==ms&&(yield[t,e])}}}class vs{#Fs=null;constructor(t){this.#Fs=t,this.onContinue=null}get promise(){return this.#Fs.capability.promise}cancel(t=0){this.#Fs.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#Fs.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#Fs;return t.form||t.canvas&&e?.size>0}}class ws{#Os=null;static#Bs=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:c=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=d,this.pageColors=c,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new vs(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(ws.#Bs.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");ws.#Bs.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:i,viewport:s,transform:n,background:r}=this.params;this.gfx=new Ci(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:s,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#Os&&(window.cancelAnimationFrame(this.#Os),this.#Os=null),ws.#Bs.delete(this._canvas),this.callback(t||new Xt(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#Os=window.requestAnimationFrame((()=>{this.#Os=null,this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),ws.#Bs.delete(this._canvas),this.callback())))}}const ys="4.10.38",As="f9bea397f";function _s(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function xs(t){return Math.max(0,Math.min(255,255*t))}class Ss{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=xs(t),t,t]}static G_HTML([t]){const e=_s(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(xs)}static RGB_HTML(t){return`#${t.map(_s).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[xs(1-Math.min(1,t+s)),xs(1-Math.min(1,i+s)),xs(1-Math.min(1,e+s))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const s=1-t,n=1-e,r=1-i;return["CMYK",s,n,r,Math.min(s,n,r)]}}class Cs{create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){_t("Abstract method `_createSVG` called.")}}let Es=class extends Cs{_createSVG(t){return document.createElementNS($t,t)}},Ps=class{static setupStorage(t,e,i,s,n){const r=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==r.value&&(t.textContent=r.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(r.value===i.attributes.xfaOn?t.setAttribute("checked",!0):r.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",(t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})}))}else{if(null!==r.value&&t.setAttribute("value",r.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==r.value){t.setAttribute("value",r.value);for(const t of i.children)t.attributes.value===r.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",(t=>{const i=t.target.options,n=-1===i.selectedIndex?"":i[i.selectedIndex].value;s.setValue(e,{value:n})}))}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;"radio"===r.type&&(r.name=`${r.name}-${s}`);for(const[e,i]of Object.entries(r))if(null!=i)switch(e){case"class":i.length&&t.setAttribute(e,i.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",i);break;case"style":Object.assign(t.style,i);break;case"textContent":t.textContent=i;break;default:(!a||"href"!==e&&"newWindow"!==e)&&t.setAttribute(e,i)}a&&n.addLinkAttributes(t,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(t,r.dataId,e,i)}static render(t){const e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,n=t.intent||"display",r=document.createElement(s.name);s.attributes&&this.setAttributes({html:r,element:s,intent:n,linkService:i});const a="richText"!==n,o=t.div;if(o.append(r),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}a&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(0===s.children.length){if(s.value){const t=document.createTextNode(s.value);r.append(t),a&&es.shouldBuildText(s.name)&&l.push(t)}return{textDivs:l}}const h=[[s,-1,r]];for(;h.length>0;){const[t,s,r]=h.at(-1);if(s+1===t.children.length){h.pop();continue}const o=t.children[++h.at(-1)[1]];if(null===o)continue;const{name:d}=o;if("#text"===d){const t=document.createTextNode(o.value);l.push(t),r.append(t);continue}const c=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,d):document.createElement(d);if(r.append(c),o.attributes&&this.setAttributes({html:c,element:o,storage:e,intent:n,linkService:i}),o.children?.length>0)h.push([o,-1,c]);else if(o.value){const t=document.createTextNode(o.value);a&&es.shouldBuildText(d)&&l.push(t),c.append(t)}}for(const t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}};const Ms=1e3,Ts=new WeakSet;function ks(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class Is{static create(t){switch(t.data.annotationType){case G:return new Ds(t);case W:return new Rs(t);case lt:switch(t.data.fieldType){case"Tx":return new Fs(t);case"Btn":return t.data.radioButton?new js(t):t.data.checkBox?new Bs(t):new Vs(t);case"Ch":return new Hs(t);case"Sig":return new Os(t)}return new Ns(t);case at:return new zs(t);case q:return new $s(t);case X:return new Ws(t);case K:return new Gs(t);case Y:return new qs(t);case J:return new Xs(t);case nt:return new Ys(t);case rt:return new Qs(t);case Q:return new Ks(t);case Z:return new Js(t);case tt:return new Zs(t);case et:return new tn(t);case it:return new en(t);case st:return new sn(t);case ot:return new nn(t);default:return new Ls(t)}}}class Ls{#js=null;#Vs=!1;#Hs=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:i}){return!!(t?.str||e?.str||i?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Ls._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#js||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#zs(e),this.#Hs?.popup.updateEdited(t)}resetEdited(){this.#js&&(this.#zs(this.#js.rect),this.#Hs?.popup.resetEdited(),this.#js=null)}#zs(t){const{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;i?.splice(0,4,...t);const{width:l,height:h}=ks(t);e.left=100*(t[0]-a)/n+"%",e.top=100*(r-t[3]+o)/r+"%",0===s?(e.width=100*l/n+"%",e.height=100*h/r+"%"):this.setRotation(s)}_createContainer(t){const{data:e,parent:{page:i,viewport:s}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof Ns||(n.tabIndex=Ms);const{style:r}=n;if(r.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof zs){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:a,height:o}=ks(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;if(t>0||i>0){const e=`calc(${t}px * var(--scale-factor)) / calc(${i}px * var(--scale-factor))`;r.borderRadius=e}else if(this instanceof js){const t=`calc(${a}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;r.borderRadius=t}switch(e.borderStyle.style){case ht:r.borderStyle="solid";break;case dt:r.borderStyle="dashed";break;case ct:At("Unimplemented border style: beveled");break;case ut:At("Unimplemented border style: inset");break;case pt:r.borderBottomStyle="solid"}const s=e.borderColor||null;s?(this.#Vs=!0,r.borderColor=jt.makeHexColor(0|s[0],0|s[1],0|s[2])):r.borderWidth=0}const l=jt.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:h,pageHeight:d,pageX:c,pageY:u}=s.rawDims;r.left=100*(l[0]-c)/h+"%",r.top=100*(l[1]-u)/d+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(r.width=100*a/h+"%",r.height=100*o/d+"%"):this.setRotation(p,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims,{width:n,height:r}=ks(this.data.rect);let a,o;t%180==0?(a=100*n/i,o=100*r/s):(a=100*r/i,o=100*n/s),e.style.width=`${a}%`,e.style.height=`${o}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,i)=>{const s=i.detail[t],n=s[0],r=s.slice(1);i.target.style[e]=Ss[`${n}_HTML`](r),this.annotationStorage.setValue(this.data.id,{[e]:Ss[`${n}_rgb`](r)})};return Ct(this,"_commonActions",{display:t=>{const{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const s of Object.keys(e.detail)){const n=t[s]||i[s];n?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[s,n]of Object.entries(e)){const r=i[s];if(r){r({detail:{[s]:n},target:t}),delete e[s]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,s,n]=this.data.rect.map((t=>Math.fround(t)));if(8===t.length){const[r,a,o,l]=t.subarray(2,6);if(s===r&&n===a&&e===o&&i===l)return}const{style:r}=this.container;let a;if(this.#Vs){const{borderColor:t,borderWidth:e}=r;r.borderWidth=0,a=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const o=s-e,l=n-i,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);const c=h.createElement("defs");d.append(c);const u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),c.append(u);for(let i=2,s=t.length;i<s;i+=8){const s=t[i],r=t[i+1],d=t[i+2],c=t[i+3],p=h.createElement("rect"),g=(d-e)/o,f=(n-r)/l,m=(s-d)/o,b=(r-c)/l;p.setAttribute("x",g),p.setAttribute("y",f),p.setAttribute("width",m),p.setAttribute("height",b),u.append(p),a?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${f}" width="${m}" height="${b}"/>`)}this.#Vs&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(){const{data:t}=this,e=this.#Hs=new zs({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(e.render())}render(){_t("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const s=this._fieldObjects[t];if(s)for(const{page:t,id:n,exportValues:r}of s){if(-1===t)continue;if(n===e)continue;const s="string"==typeof r?r:null,a=document.querySelector(`[data-element-id="${n}"]`);!a||Ts.has(a)?i.push({id:n,exportValue:s,domElement:a}):At(`_getElementsByName - element not allowed: ${n}`)}return i}for(const s of document.getElementsByName(t)){const{exportValue:t}=s,n=s.getAttribute("data-element-id");n!==e&&(Ts.has(s)&&i.push({id:n,exportValue:t,domElement:s}))}return i}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})}))}}class Ds extends Ls{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action),s=!0):t.attachment?(this.#Us(i,t.attachment,t.attachmentDest),s=!0):t.setOCGState?(this.#$s(i,t.setOCGState),s=!0):t.dest?(this._bindLink(i,t.dest),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&this.container.append(i),this.container}#Ws(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#Ws()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#Ws()}#Us(t,e,i=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,i),!1),this.#Ws()}#$s(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#Ws()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const s of Object.keys(e.actions)){const n=i.get(s);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}t.onclick||(t.onclick=()=>!1),this.#Ws()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#Ws(),!this._fieldObjects)return At('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(i||(t.onclick=()=>!1));t.onclick=()=>{i?.();const{fields:t,refs:s,include:n}=e,r=[];if(0!==t.length||0!==s.length){const e=new Set(s);for(const i of t){const t=this._fieldObjects[i]||[];for(const{id:i}of t)e.add(i)}for(const t of Object.values(this._fieldObjects))for(const i of t)e.has(i.id)===n&&r.push(i)}else for(const t of Object.values(this._fieldObjects))r.push(...t);const a=this.annotationStorage,o=[];for(const t of r){const{id:e}=t;switch(o.push(e),t.type){case"text":{const i=t.defaultValue||"";a.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{const i=t.defaultValue===t.exportValues;a.setValue(e,{value:i});break}case"combobox":case"listbox":{const i=t.defaultValue||"";a.setValue(e,{value:i});break}default:continue}const i=document.querySelector(`[data-element-id="${e}"]`);i&&(Ts.has(i)?i.dispatchEvent(new Event("resetform")):At(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class Rs extends Ls{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class Ns extends Ls{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return Ot.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,n){i.includes("mouse")?t.addEventListener(i,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(i,(t=>{if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t)}})}))}_setEventListeners(t,e,i,s){for(const[n,r]of i)("Action"===r||this.data.actions?.[r])&&("Focus"!==r&&"Blur"!==r||(e||={focused:!1}),this._setEventListener(t,e,n,r,s),"Focus"!==r||this.data.actions?.Blur?"Blur"!==r||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":jt.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,n=t.style;let r;const a=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=t/(Math.round(t/(C*s))||1);r=Math.min(s,a(e/C))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(s,a(t/C))}n.fontSize=`calc(${r}px * var(--scale-factor))`,n.color=jt.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Fs extends Ns{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,s){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=i),n.setValue(r.id,{[s]:i})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const s=t.getValue(e,{value:this.data.fieldValue});let n=s.value||"";const r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&n.length>r&&(n=n.slice(0,r));let a=s.formattedValue||this.data.textContent?.join("\n")||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));const o={userValue:n,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=a??n,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type="text",i.setAttribute("value",a??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),Ts.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=Ms,this._setRequired(i,this.data.required),r&&(i.maxLength=r),i.addEventListener("input",(s=>{t.setValue(e,{value:s.target.value}),this.setPropertyOnSiblings(i,"value",s.target.value,"value"),o.formattedValue=null})),i.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null}));let l=t=>{const{formattedValue:e}=o;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",(t=>{if(o.focused)return;const{target:e}=t;o.userValue&&(e.value=o.userValue),o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)})),i.addEventListener("updatefromsandbox",(i=>{this.showElementAndHideCanvas(i.target);const s={value(i){o.userValue=i.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),i.target.value=o.userValue},formattedValue(i){const{formattedValue:s}=i.detail;o.formattedValue=s,null!=s&&i.target!==document.activeElement&&(i.target.value=s),t.setValue(e,{formattedValue:s})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{const{charLimit:s}=i.detail,{target:n}=i;if(0===s)return void n.removeAttribute("maxLength");n.setAttribute("maxLength",s);let r=o.userValue;!r||r.length<=s||(r=r.slice(0,s),n.value=o.userValue=r,t.setValue(e,{value:r}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,willCommit:!0,commitKey:1,selStart:n.selectionStart,selEnd:n.selectionEnd}}))}};this._dispatchEventFromSandbox(s,i)})),i.addEventListener("keydown",(t=>{o.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):i=2,-1===i)return;const{value:s}=t.target;o.lastCommittedValue!==s&&(o.lastCommittedValue=s,o.userValue=s,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}));const s=l;l=null,i.addEventListener("blur",(t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{value:i}=t.target;o.userValue=i,o.lastCommittedValue!==i&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),s(t)})),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",(t=>{o.lastCommittedValue=null;const{data:i,target:s}=t,{value:n,selectionStart:r,selectionEnd:a}=s;let l=r,h=a;switch(t.inputType){case"deleteWordBackward":{const t=n.substring(0,r).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{const t=n.substring(r).match(/^[^\w]*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":r===a&&(l-=1);break;case"deleteContentForward":r===a&&(h+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,change:i||"",willCommit:!1,selStart:l,selEnd:h}})})),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(l&&i.addEventListener("blur",l),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/r;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--scale-factor) - 1ch)`}}else i=document.createElement("div"),i.textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Os extends Ns{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Bs extends Ns{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return Ts.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=Ms,n.addEventListener("change",(s=>{const{name:n,checked:r}=s.target;for(const s of this._getElementsByName(n,i)){const i=r&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:r})})),n.addEventListener("resetform",(t=>{const i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue})),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",(e=>{const s={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}};this._dispatchEventFromSandbox(s,e)})),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class js extends Ns{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(const s of this._getElementsByName(e.fieldName,i))t.setValue(s.id,{value:!1});const n=document.createElement("input");if(Ts.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.tabIndex=Ms,n.addEventListener("change",(e=>{const{name:s,checked:n}=e.target;for(const e of this._getElementsByName(s,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:n})})),n.addEventListener("resetform",(t=>{const i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue})),this.enableScripting&&this.hasJSActions){const s=e.buttonValue;n.addEventListener("updatefromsandbox",(e=>{const n={value:e=>{const n=s===e.detail.value;for(const s of this._getElementsByName(e.target.name)){const e=n&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}};this._dispatchEventFromSandbox(n,e)})),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Vs extends Ds{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(t=>{this._dispatchEventFromSandbox({},t)}))),t}}class Hs extends Ns{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");Ts.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=Ms;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue;for(const t of s.options)t.selected=t.value===e}));for(const t of this.data.options){const e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),n=!1),s.append(e)}let r=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),r=()=>{t.remove(),s.removeEventListener("input",r),r=null},s.addEventListener("input",r)}const a=t=>{const e=t?"value":"textContent",{options:i,multiple:n}=s;return n?Array.prototype.filter.call(i,(t=>t.selected)).map((t=>t[e])):-1===i.selectedIndex?null:i[i.selectedIndex][e]};let o=a(!1);const l=t=>{const e=t.target.options;return Array.prototype.map.call(e,(t=>({displayValue:t.textContent,exportValue:t.value})))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",(i=>{const n={value(i){r?.();const n=i.detail.value,l=new Set(Array.isArray(n)?n:[n]);for(const t of s.options)t.selected=l.has(t.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(t){s.multiple=!0},remove(i){const n=s.options,r=i.detail.remove;if(n[r].selected=!1,s.remove(r),n.length>0){-1===Array.prototype.findIndex.call(n,(t=>t.selected))&&(n[0].selected=!0)}t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(i){const{index:n,displayValue:r,exportValue:h}=i.detail.insert,d=s.children[n],c=document.createElement("option");c.textContent=r,c.value=h,d?d.before(c):s.append(c),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},items(i){const{items:n}=i.detail;for(;0!==s.length;)s.remove(0);for(const t of n){const{displayValue:e,exportValue:i}=t,n=document.createElement("option");n.textContent=e,n.value=i,s.append(n)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},indices(i){const s=new Set(i.detail.indices);for(const t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(n,i)})),s.addEventListener("input",(i=>{const s=a(!0),n=a(!1);t.setValue(e,{value:s}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:n,changeEx:s,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(t=>t.target.value))):s.addEventListener("input",(function(i){t.setValue(e,{value:a(!0)})})),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class zs extends Ls{constructor(t){const{data:e,elements:i}=t;super(t,{isRenderable:Ls._hasPopupData(e)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Us({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(const i of this.elements)i.popup=t,i.container.ariaHasPopup="dialog",e.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",e.map((t=>`${Ut}${t}`)).join(",")),this.container}}class Us{#Gs=this.#qs.bind(this);#Xs=this.#Ks.bind(this);#Ys=this.#Qs.bind(this);#Js=this.#Zs.bind(this);#tn=null;#pt=null;#en=null;#in=null;#sn=null;#nn=null;#rn=null;#an=!1;#on=null;#E=null;#ln=null;#hn=null;#dn=null;#js=null;#cn=!1;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:n,contentsObj:r,richText:a,parent:o,rect:l,parentRect:h,open:d}){this.#pt=t,this.#dn=s,this.#en=r,this.#hn=a,this.#nn=o,this.#tn=e,this.#ln=l,this.#rn=h,this.#sn=i,this.#in=se.toDateObject(n),this.trigger=i.flatMap((t=>t.getElementsToTriggerPopup()));for(const t of this.trigger)t.addEventListener("click",this.#Js),t.addEventListener("mouseenter",this.#Ys),t.addEventListener("mouseleave",this.#Xs),t.classList.add("popupTriggerArea");for(const t of i)t.container?.addEventListener("keydown",this.#Gs);this.#pt.hidden=!0,d&&this.#Zs()}render(){if(this.#on)return;const t=this.#on=document.createElement("div");if(t.className="popup",this.#tn){const e=t.style.outlineColor=jt.makeHexColor(...this.#tn);if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`;else{const e=.7;t.style.backgroundColor=jt.makeHexColor(...this.#tn.map((t=>Math.floor(e*(255-t)+t))))}}const e=document.createElement("span");e.className="header";const i=document.createElement("h1");if(e.append(i),({dir:i.dir,str:i.textContent}=this.#dn),t.append(e),this.#in){const t=document.createElement("span");t.classList.add("popupDate"),t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#in.valueOf()})),e.append(t)}const s=this.#un;if(s)Ps.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(this.#en);t.append(e)}this.#pt.append(t)}get#un(){const t=this.#hn,e=this.#en;return!t?.str||e?.str&&e.str!==t.str?null:this.#hn.html||null}get#pn(){return this.#un?.attributes?.style?.fontSize||0}get#gn(){return this.#un?.attributes?.style?.color||null}#fn(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:this.#gn,fontSize:this.#pn?`calc(${this.#pn}px * var(--scale-factor))`:""}};for(const i of t.split("\n"))e.push({name:"span",value:i,attributes:s});return i}_formatContents({str:t,dir:e}){const i=document.createElement("p");i.classList.add("popupContent"),i.dir=e;const s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t){const n=s[t];i.append(document.createTextNode(n)),t<e-1&&i.append(document.createElement("br"))}return i}#qs(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#an)&&this.#Zs()}updateEdited({rect:t,popupContent:e}){this.#js||={contentsObj:this.#en,richText:this.#hn},t&&(this.#E=null),e&&(this.#hn=this.#fn(e),this.#en=null),this.#on?.remove(),this.#on=null}resetEdited(){this.#js&&(({contentsObj:this.#en,richText:this.#hn}=this.#js),this.#js=null,this.#on?.remove(),this.#on=null,this.#E=null)}#mn(){if(null!==this.#E)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=this.#nn;let r=!!this.#rn,a=r?this.#rn:this.#ln;for(const t of this.#sn)if(!a||null!==jt.intersect(t.data.rect,a)){a=t.data.rect,r=!0;break}const o=jt.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),l=r?a[2]-a[0]+5:0,h=o[0]+l,d=o[1];this.#E=[100*(h-s)/e,100*(d-n)/i];const{style:c}=this.#pt;c.left=`${this.#E[0]}%`,c.top=`${this.#E[1]}%`}#Zs(){this.#an=!this.#an,this.#an?(this.#Qs(),this.#pt.addEventListener("click",this.#Js),this.#pt.addEventListener("keydown",this.#Gs)):(this.#Ks(),this.#pt.removeEventListener("click",this.#Js),this.#pt.removeEventListener("keydown",this.#Gs))}#Qs(){this.#on||this.render(),this.isVisible?this.#an&&this.#pt.classList.add("focused"):(this.#mn(),this.#pt.hidden=!1,this.#pt.style.zIndex=parseInt(this.#pt.style.zIndex)+1e3)}#Ks(){this.#pt.classList.remove("focused"),!this.#an&&this.isVisible&&(this.#pt.hidden=!0,this.#pt.style.zIndex=parseInt(this.#pt.style.zIndex)-1e3)}forceHide(){this.#cn=this.isVisible,this.#cn&&(this.#pt.hidden=!0)}maybeShow(){this.#cn&&(this.#on||this.#Qs(),this.#cn=!1,this.#pt.hidden=!1)}get isVisible(){return!1===this.#pt.hidden}}class $s extends Ls{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=N.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class Ws extends Ls{#bn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const t=this.data,{width:e,height:i}=ks(t.rect),s=this.svgFactory.create(e,i,!0),n=this.#bn=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#bn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Gs extends Ls{#vn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const t=this.data,{width:e,height:i}=ks(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#vn=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",i-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#vn}addHighlightArea(){this.container.classList.add("highlightArea")}}class qs extends Ls{#wn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const t=this.data,{width:e,height:i}=ks(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#wn=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",i/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",i/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#wn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Xs extends Ls{#yn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:i,popupRef:s}}=this;if(!e)return this.container;const{width:n,height:r}=ks(t),a=this.svgFactory.create(n,r,!0);let o=[];for(let i=0,s=e.length;i<s;i+=2){const s=e[i]-t[0],n=t[3]-e[i+1];o.push(`${s},${n}`)}o=o.join(" ");const l=this.#yn=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),a.append(l),this.container.append(a),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#yn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ks extends Xs{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Ys extends Ls{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class Qs extends Ls{#An=null;#_n=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?N.HIGHLIGHT:N.INK}#xn(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:i,borderStyle:s,popupRef:n}}=this,{transform:r,width:a,height:o}=this.#xn(e,t),l=this.svgFactory.create(a,o,!0),h=this.#An=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",r);for(let t=0,e=i.length;t<e;t++){const e=this.svgFactory.createElement(this.svgElementName);this.#_n.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!n&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:i,rect:s}=t,n=this.#An;if(e>=0&&n.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#_n.length;t<e;t++)this.#_n[t].setAttribute("points",i[t].join(","));if(s){const{transform:t,width:e,height:i}=this.#xn(this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#_n}addHighlightArea(){this.container.classList.add("highlightArea")}}class Js extends Ls{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=N.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Zs extends Ls{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class tn extends Ls{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class en extends Ls{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class sn extends Ls{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=N.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class nn extends Ls{#Sn=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let i;e.hasAppearance||0===e.fillAlpha?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),i.addEventListener("dblclick",this.#Cn.bind(this)),this.#Sn=i;const{isMac:s}=Ot.platform;return t.addEventListener("keydown",(t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#Cn()})),!e.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#Sn}addHighlightArea(){this.container.classList.add("highlightArea")}#Cn(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}let rn=class{#En=null;#Pn=null;#Mn=new Map;#Tn=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:r,structTreeLayer:a}){this.div=t,this.#En=e,this.#Pn=i,this.#Tn=a||null,this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return this.#Mn.size>0}async#kn(t,e){const i=t.firstChild||t,s=i.id=`${Ut}${e}`,n=await(this.#Tn?.getAriaAttributes(s));if(n)for(const[t,e]of n)i.setAttribute(t,e);this.div.append(t),this.#En?.moveElementInDOM(this.div,t,i,!1)}async render(t){const{annotations:e}=t,i=this.div;le(i,this.viewport);const s=new Map,n={data:null,layer:i,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new Es,annotationStorage:t.annotationStorage||new Me,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const t of e){if(t.noHTML)continue;const e=t.annotationType===at;if(e){const e=s.get(t.id);if(!e)continue;n.elements=e}else{const{width:e,height:i}=ks(t.rect);if(e<=0||i<=0)continue}n.data=t;const i=Is.create(n);if(!i.isRenderable)continue;if(!e&&t.popupRef){const e=s.get(t.popupRef);e?e.push(i):s.set(t.popupRef,[i])}const r=i.render();t.hidden&&(r.style.visibility="hidden"),await this.#kn(r,t.id),i._isEditable&&(this.#Mn.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}this.#In()}update({viewport:t}){const e=this.div;this.viewport=t,le(e,{rotation:t.rotation}),this.#In(),e.hidden=!1}#In(){if(!this.#Pn)return;const t=this.div;for(const[e,i]of this.#Pn){const s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent";const{firstChild:n}=s;n?"CANVAS"===n.nodeName?n.replaceWith(i):n.classList.contains("annotationContent")?n.after(i):n.before(i):s.append(i)}this.#Pn.clear()}getEditableAnnotations(){return Array.from(this.#Mn.values())}getEditableAnnotation(t){return this.#Mn.get(t)}};const an=/\r\n?|\n/g;class on extends Ae{#tn;#Ln="";#Dn=`${this.id}-editor`;#Rn=null;#pn;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=on.prototype,e=t=>t.isEmpty(),i=ve.TRANSLATE_SMALL,s=ve.TRANSLATE_BIG;return Ct(this,"_keyboardManager",new me([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=N.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#tn=t.color||on._defaultColor||Ae._defaultLineColor,this.#pn=t.fontSize||on._defaultFontSize}static initialize(t,e){Ae.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case F.FREETEXT_SIZE:on._defaultFontSize=e;break;case F.FREETEXT_COLOR:on._defaultColor=e}}updateParams(t,e){switch(t){case F.FREETEXT_SIZE:this.#Nn(e);break;case F.FREETEXT_COLOR:this.#Fn(e)}}static get defaultPropertiesToUpdate(){return[[F.FREETEXT_SIZE,on._defaultFontSize],[F.FREETEXT_COLOR,on._defaultColor||Ae._defaultLineColor]]}get propertiesToUpdate(){return[[F.FREETEXT_SIZE,this.#pn],[F.FREETEXT_COLOR,this.#tn]]}#Nn(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--scale-factor))`,this.translate(0,-(t-this.#pn)*this.parentScale),this.#pn=t,this.#On()},i=this.#pn;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:F.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#Fn(t){const e=t=>{this.#tn=this.editorDiv.style.color=t},i=this.#tn;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:F.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-on._internalPadding*t,-(on._internalPadding+this.#pn)*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(N.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#Rn=new AbortController;const t=this._uiManager.combinedSignal(this.#Rn);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#Dn),this._isDraggable=!0,this.#Rn?.abort(),this.#Rn=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#Bn(){const t=[];this.editorDiv.normalize();let e=null;for(const i of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&"BR"===i.nodeName||(t.push(on.#jn(i)),e=i);return t.join("\n")}#On(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,s=e.style.display,n=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),i=e.getBoundingClientRect(),e.remove(),e.style.display=s,e.classList.toggle("hidden",n)}this.rotation%180==this.parentRotation%180?(this.width=i.width/t,this.height=i.height/e):(this.width=i.height/t,this.height=i.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#Ln,e=this.#Ln=this.#Bn().trimEnd();if(t===e)return;const i=t=>{this.#Ln=t,t?(this.#Vn(),this._uiManager.rebuild(this),this.#On()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#On()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){on._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#Dn),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#pn}px * var(--scale-factor))`,i.color=this.#tn,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),ue(this,this.div,["dblclick","keydown"]),this.width){const[i,s]=this.parentDimensions;if(this.annotationElementId){const{position:n}=this._initialData;let[r,a]=this.getInitialTranslation();[r,a]=this.pageTranslationToScreen(r,a);const[o,l]=this.pageDimensions,[h,d]=this.pageTranslation;let c,u;switch(this.rotation){case 0:c=t+(n[0]-h)/o,u=e+this.height-(n[1]-d)/l;break;case 90:c=t+(n[0]-h)/o,u=e-(n[1]-d)/l,[r,a]=[a,-r];break;case 180:c=t-this.width+(n[0]-h)/o,u=e-(n[1]-d)/l,[r,a]=[-r,-a];break;case 270:c=t+(n[0]-h-this.height*l)/o,u=e+(n[1]-d-this.width*o)/l,[r,a]=[-a,r]}this.setAt(c*i,u*s,r,a)}else this.setAt(t*i,e*s,this.width*i,this.height*s);this.#Vn(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#jn(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(an,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const s=on.#Hn(e.getData("text")||"").replaceAll(an,"\n");if(!s)return;const n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();const r=n.getRangeAt(0);if(!s.includes("\n"))return r.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),void n.collapseToStart();const{startContainer:a,startOffset:o}=r,l=[],h=[];if(a.nodeType===Node.TEXT_NODE){const t=a.parentElement;if(h.push(a.nodeValue.slice(o).replaceAll(an,"")),t!==this.editorDiv){let e=l;for(const i of this.editorDiv.childNodes)i!==t?e.push(on.#jn(i)):e=h}l.push(a.nodeValue.slice(0,o).replaceAll(an,""))}else if(a===this.editorDiv){let t=l,e=0;for(const i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(on.#jn(i))}this.#Ln=`${l.join("\n")}${s}${h.join("\n")}`,this.#Vn();const d=new Range;let c=l.reduce(((t,e)=>t+e.length),0);for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(c<=e){d.setStart(t,c),d.setEnd(t,c);break}c-=e}n.removeAllRanges(),n.addRange(d)}#Vn(){if(this.editorDiv.replaceChildren(),this.#Ln)for(const t of this.#Ln.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#zn(){return this.#Ln.replaceAll(" "," ")}static#Hn(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,i){let s=null;if(t instanceof $s){const{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:n,rotation:r,id:a,popupRef:o},textContent:l,textPosition:h,parent:{page:{pageNumber:d}}}=t;if(!l||0===l.length)return null;s=t={annotationType:N.FREETEXT,color:Array.from(i),fontSize:e,value:l.join("\n"),position:h,pageIndex:d-1,rect:n.slice(0),rotation:r,id:a,deleted:!1,popupRef:o}}const n=await super.deserialize(t,e,i);return n.#pn=t.fontSize,n.#tn=jt.makeHexColor(...t.color),n.#Ln=on.#Hn(t.value),n.annotationElementId=t.id||null,n._initialData=s,n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=on._internalPadding*this.parentScale,i=this.getRect(e,e),s=Ae._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#tn),n={annotationType:N.FREETEXT,color:s,fontSize:this.#pn,value:this.#zn(),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?n:this.annotationElementId&&!this.#Un(n)?null:(n.id=this.annotationElementId,n)}#Un(t){const{value:e,fontSize:i,color:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some(((t,e)=>t!==s[e]))||t.pageIndex!==n}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:i}=e;i.fontSize=`calc(${this.#pn}px * var(--scale-factor))`,i.color=this.#tn,e.replaceChildren();for(const t of this.#Ln.split("\n")){const i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}const s=on._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:this.#Ln}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class ln{static PRECISION=1e-4;toSVGPath(){_t("Abstract method `toSVGPath` must be implemented.")}get box(){_t("Abstract getter `box` must be implemented.")}serialize(t,e){_t("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*s,r[a+1]=i+t[a+1]*n;return r}static _rescaleAndSwap(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*s,r[a+1]=i+t[a]*n;return r}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n+=2)s[n]=e+t[n],s[n+1]=i+t[n+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,s,n){switch(n){case 90:return[1-e/i,t/s];case 180:return[1-t/i,1-e/s];case 270:return[e/i,1-t/s];default:return[t/i,e/s]}}static _normalizePagePoint(t,e,i){switch(i){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,i,s,n,r){return[(t+5*i)/6,(e+5*s)/6,(5*i+n)/6,(5*s+r)/6,(i+n)/2,(s+r)/2]}}class hn{#$n;#Wn=[];#Gn;#qn;#Xn=[];#Kn=new Float32Array(18);#Yn;#Qn;#Jn;#Zn;#tr;#er;#ir=[];static#sr=8;static#nr=2;static#rr=hn.#sr+hn.#nr;constructor({x:t,y:e},i,s,n,r,a=0){this.#$n=i,this.#er=n*s,this.#qn=r,this.#Kn.set([NaN,NaN,NaN,NaN,t,e],6),this.#Gn=a,this.#Zn=hn.#sr*s,this.#Jn=hn.#rr*s,this.#tr=s,this.#ir.push(t,e)}isEmpty(){return isNaN(this.#Kn[8])}#ar(){const t=this.#Kn.subarray(4,6),e=this.#Kn.subarray(16,18),[i,s,n,r]=this.#$n;return[(this.#Yn+(t[0]-e[0])/2-i)/n,(this.#Qn+(t[1]-e[1])/2-s)/r,(this.#Yn+(e[0]-t[0])/2-i)/n,(this.#Qn+(e[1]-t[1])/2-s)/r]}add({x:t,y:e}){this.#Yn=t,this.#Qn=e;const[i,s,n,r]=this.#$n;let[a,o,l,h]=this.#Kn.subarray(8,12);const d=t-l,c=e-h,u=Math.hypot(d,c);if(u<this.#Jn)return!1;const p=u-this.#Zn,g=p/u,f=g*d,m=g*c;let b=a,v=o;a=l,o=h,l+=f,h+=m,this.#ir?.push(t,e);const w=f/p,y=-m/p*this.#er,A=w*this.#er;if(this.#Kn.set(this.#Kn.subarray(2,8),0),this.#Kn.set([l+y,h+A],4),this.#Kn.set(this.#Kn.subarray(14,18),12),this.#Kn.set([l-y,h-A],16),isNaN(this.#Kn[6]))return 0===this.#Xn.length&&(this.#Kn.set([a+y,o+A],2),this.#Xn.push(NaN,NaN,NaN,NaN,(a+y-i)/n,(o+A-s)/r),this.#Kn.set([a-y,o-A],14),this.#Wn.push(NaN,NaN,NaN,NaN,(a-y-i)/n,(o-A-s)/r)),this.#Kn.set([b,v,a,o,l,h],6),!this.isEmpty();this.#Kn.set([b,v,a,o,l,h],6);return Math.abs(Math.atan2(v-o,b-a)-Math.atan2(m,f))<Math.PI/2?([a,o,l,h]=this.#Kn.subarray(2,6),this.#Xn.push(NaN,NaN,NaN,NaN,((a+l)/2-i)/n,((o+h)/2-s)/r),[a,o,b,v]=this.#Kn.subarray(14,18),this.#Wn.push(NaN,NaN,NaN,NaN,((b+a)/2-i)/n,((v+o)/2-s)/r),!0):([b,v,a,o,l,h]=this.#Kn.subarray(0,6),this.#Xn.push(((b+5*a)/6-i)/n,((v+5*o)/6-s)/r,((5*a+l)/6-i)/n,((5*o+h)/6-s)/r,((a+l)/2-i)/n,((o+h)/2-s)/r),[l,h,a,o,b,v]=this.#Kn.subarray(12,18),this.#Wn.push(((b+5*a)/6-i)/n,((v+5*o)/6-s)/r,((5*a+l)/6-i)/n,((5*o+h)/6-s)/r,((a+l)/2-i)/n,((o+h)/2-s)/r),!0)}toSVGPath(){if(this.isEmpty())return"";const t=this.#Xn,e=this.#Wn;if(isNaN(this.#Kn[6])&&!this.isEmpty())return this.#or();const i=[];i.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#lr(i);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#hr(i),i.join(" ")}#or(){const[t,e,i,s]=this.#$n,[n,r,a,o]=this.#ar();return`M${(this.#Kn[2]-t)/i} ${(this.#Kn[3]-e)/s} L${(this.#Kn[4]-t)/i} ${(this.#Kn[5]-e)/s} L${n} ${r} L${a} ${o} L${(this.#Kn[16]-t)/i} ${(this.#Kn[17]-e)/s} L${(this.#Kn[14]-t)/i} ${(this.#Kn[15]-e)/s} Z`}#hr(t){const e=this.#Wn;t.push(`L${e[4]} ${e[5]} Z`)}#lr(t){const[e,i,s,n]=this.#$n,r=this.#Kn.subarray(4,6),a=this.#Kn.subarray(16,18),[o,l,h,d]=this.#ar();t.push(`L${(r[0]-e)/s} ${(r[1]-i)/n} L${o} ${l} L${h} ${d} L${(a[0]-e)/s} ${(a[1]-i)/n}`)}newFreeDrawOutline(t,e,i,s,n,r){return new dn(t,e,i,s,n,r)}getOutlines(){const t=this.#Xn,e=this.#Wn,i=this.#Kn,[s,n,r,a]=this.#$n,o=new Float32Array((this.#ir?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#ir[t]-s)/r,o[t+1]=(this.#ir[t+1]-n)/a;if(o[o.length-2]=(this.#Yn-s)/r,o[o.length-1]=(this.#Qn-n)/a,isNaN(i[6])&&!this.isEmpty())return this.#dr(o);const l=new Float32Array(this.#Xn.length+24+this.#Wn.length);let h=t.length;for(let e=0;e<h;e+=2)isNaN(t[e])?l[e]=l[e+1]=NaN:(l[e]=t[e],l[e+1]=t[e+1]);h=this.#cr(l,h);for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2)isNaN(e[t+i])?(l[h]=l[h+1]=NaN,h+=2):(l[h]=e[t+i],l[h+1]=e[t+i+1],h+=2);return this.#ur(l,h),this.newFreeDrawOutline(l,o,this.#$n,this.#tr,this.#Gn,this.#qn)}#dr(t){const e=this.#Kn,[i,s,n,r]=this.#$n,[a,o,l,h]=this.#ar(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/n,(e[3]-s)/r,NaN,NaN,NaN,NaN,(e[4]-i)/n,(e[5]-s)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/n,(e[17]-s)/r,NaN,NaN,NaN,NaN,(e[14]-i)/n,(e[15]-s)/r],0),this.newFreeDrawOutline(d,t,this.#$n,this.#tr,this.#Gn,this.#qn)}#ur(t,e){const i=this.#Wn;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#cr(t,e){const i=this.#Kn.subarray(4,6),s=this.#Kn.subarray(16,18),[n,r,a,o]=this.#$n,[l,h,d,c]=this.#ar();return t.set([NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,d,c,NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/o],e),e+24}}class dn extends ln{#$n;#pr=new Float32Array(4);#Gn;#qn;#ir;#tr;#gr;constructor(t,e,i,s,n,r){super(),this.#gr=t,this.#ir=e,this.#$n=i,this.#tr=s,this.#Gn=n,this.#qn=r,this.lastPoint=[NaN,NaN],this.#fr(r);const[a,o,l,h]=this.#pr;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-a)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-a)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){const t=[`M${this.#gr[4]} ${this.#gr[5]}`];for(let e=6,i=this.#gr.length;e<i;e+=6)isNaN(this.#gr[e])?t.push(`L${this.#gr[e+4]} ${this.#gr[e+5]}`):t.push(`C${this.#gr[e]} ${this.#gr[e+1]} ${this.#gr[e+2]} ${this.#gr[e+3]} ${this.#gr[e+4]} ${this.#gr[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,i,s],n){const r=i-t,a=s-e;let o,l;switch(n){case 0:o=ln._rescale(this.#gr,t,s,r,-a),l=ln._rescale(this.#ir,t,s,r,-a);break;case 90:o=ln._rescaleAndSwap(this.#gr,t,e,r,a),l=ln._rescaleAndSwap(this.#ir,t,e,r,a);break;case 180:o=ln._rescale(this.#gr,i,e,-r,a),l=ln._rescale(this.#ir,i,e,-r,a);break;case 270:o=ln._rescaleAndSwap(this.#gr,i,s,-r,-a),l=ln._rescaleAndSwap(this.#ir,i,s,-r,-a)}return{outline:Array.from(o),points:[Array.from(l)]}}#fr(t){const e=this.#gr;let i=e[4],s=e[5],n=i,r=s,a=i,o=s,l=i,h=s;const d=t?Math.max:Math.min;for(let t=6,c=e.length;t<c;t+=6){if(isNaN(e[t]))n=Math.min(n,e[t+4]),r=Math.min(r,e[t+5]),a=Math.max(a,e[t+4]),o=Math.max(o,e[t+5]),h<e[t+5]?(l=e[t+4],h=e[t+5]):h===e[t+5]&&(l=d(l,e[t+4]));else{const c=jt.bezierBoundingBox(i,s,...e.slice(t,t+6));n=Math.min(n,c[0]),r=Math.min(r,c[1]),a=Math.max(a,c[2]),o=Math.max(o,c[3]),h<c[3]?(l=c[2],h=c[3]):h===c[3]&&(l=d(l,c[2]))}i=e[t+4],s=e[t+5]}const c=this.#pr;c[0]=n-this.#Gn,c[1]=r-this.#Gn,c[2]=a-n+2*this.#Gn,c[3]=o-r+2*this.#Gn,this.lastPoint=[l,h]}get box(){return this.#pr}newOutliner(t,e,i,s,n,r=0){return new hn(t,e,i,s,n,r)}getNewOutline(t,e){const[i,s,n,r]=this.#pr,[a,o,l,h]=this.#$n,d=n*l,c=r*h,u=i*l+a,p=s*h+o,g=this.newOutliner({x:this.#ir[0]*d+u,y:this.#ir[1]*c+p},this.#$n,this.#tr,t,this.#qn,e??this.#Gn);for(let t=2;t<this.#ir.length;t+=2)g.add({x:this.#ir[t]*d+u,y:this.#ir[t+1]*c+p});return g.getOutlines()}}class cn{#$n;#mr;#br=[];#vr=[];constructor(t,e=0,i=0,s=!0){let n=1/0,r=-1/0,a=1/0,o=-1/0;const l=10**-4;for(const{x:i,y:s,width:h,height:d}of t){const t=Math.floor((i-e)/l)*l,c=Math.ceil((i+h+e)/l)*l,u=Math.floor((s-e)/l)*l,p=Math.ceil((s+d+e)/l)*l,g=[t,u,p,!0],f=[c,u,p,!1];this.#br.push(g,f),n=Math.min(n,t),r=Math.max(r,c),a=Math.min(a,u),o=Math.max(o,p)}const h=r-n+2*i,d=o-a+2*i,c=n-i,u=a-i,p=this.#br.at(s?-1:-2),g=[p[0],p[2]];for(const t of this.#br){const[e,i,s]=t;t[0]=(e-c)/h,t[1]=(i-u)/d,t[2]=(s-u)/d}this.#$n=new Float32Array([c,u,h,d]),this.#mr=g}getOutlines(){this.#br.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of this.#br)e[3]?(t.push(...this.#wr(e)),this.#yr(e)):(this.#Ar(e),t.push(...this.#wr(e)));return this.#_r(t)}#_r(t){const e=[],i=new Set;for(const i of t){const[t,s,n]=i;e.push([t,s,i],[t,n,i])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(let t=0,s=e.length;t<s;t+=2){const s=e[t][2],n=e[t+1][2];s.push(n),n.push(s),i.add(s),i.add(n)}const s=[];let n;for(;i.size>0;){const t=i.values().next().value;let[e,r,a,o,l]=t;i.delete(t);let h=e,d=r;for(n=[e,a],s.push(n);;){let t;if(i.has(o))t=o;else{if(!i.has(l))break;t=l}i.delete(t),[e,r,a,o,l]=t,h!==e&&(n.push(h,d,e,d===r?r:a),h=e),d=d===r?a:r}n.push(h,d)}return new un(s,this.#$n,this.#mr)}#xr(t){const e=this.#vr;let i=0,s=e.length-1;for(;i<=s;){const n=i+s>>1,r=e[n][0];if(r===t)return n;r<t?i=n+1:s=n-1}return s+1}#yr([,t,e]){const i=this.#xr(t);this.#vr.splice(i,0,[t,e])}#Ar([,t,e]){const i=this.#xr(t);for(let s=i;s<this.#vr.length;s++){const[i,n]=this.#vr[s];if(i!==t)break;if(i===t&&n===e)return void this.#vr.splice(s,1)}for(let s=i-1;s>=0;s--){const[i,n]=this.#vr[s];if(i!==t)break;if(i===t&&n===e)return void this.#vr.splice(s,1)}}#wr(t){const[e,i,s]=t,n=[[e,i,s]],r=this.#xr(s);for(let t=0;t<r;t++){const[i,s]=this.#vr[t];for(let t=0,r=n.length;t<r;t++){const[,a,o]=n[t];if(!(s<=a||o<=i))if(a>=i)if(o>s)n[t][1]=s;else{if(1===r)return[];n.splice(t,1),t--,r--}else n[t][2]=i,o>s&&n.push([e,s,o])}}return n}}class un extends ln{#$n;#Sr;constructor(t,e,i){super(),this.#Sr=t,this.#$n=e,this.lastPoint=i}toSVGPath(){const t=[];for(const e of this.#Sr){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n<e.length;n+=2){const r=e[n],a=e[n+1];r===i?(t.push(`V${a}`),s=a):a===s&&(t.push(`H${r}`),i=r)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],n){const r=[],a=i-t,o=s-e;for(const e of this.#Sr){const i=new Array(e.length);for(let n=0;n<e.length;n+=2)i[n]=t+e[n]*a,i[n+1]=s-e[n+1]*o;r.push(i)}return r}get box(){return this.#$n}get classNamesForOutlining(){return["highlightOutline"]}}class pn extends hn{newFreeDrawOutline(t,e,i,s,n,r){return new gn(t,e,i,s,n,r)}}class gn extends dn{newOutliner(t,e,i,s,n,r=0){return new pn(t,e,i,s,n,r)}}let fn=class t{#Cr=null;#Er=null;#Pr;#Mr=null;#Tr=!1;#kr=!1;#r=null;#Ir;#Lr=null;#f=null;#Dr;static#Rr=null;static get _keyboardManager(){return Ct(this,"_keyboardManager",new me([[["Escape","mac+Escape"],t.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],t.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],t.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],t.prototype._moveToPrevious],[["Home","mac+Home"],t.prototype._moveToBeginning],[["End","mac+End"],t.prototype._moveToEnd]]))}constructor({editor:e=null,uiManager:i=null}){e?(this.#kr=!1,this.#Dr=F.HIGHLIGHT_COLOR,this.#r=e):(this.#kr=!0,this.#Dr=F.HIGHLIGHT_DEFAULT_COLOR),this.#f=e?._uiManager||i,this.#Ir=this.#f._eventBus,this.#Pr=e?.color||this.#f?.highlightColors.values().next().value||"#FFFF98",t.#Rr||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){const t=this.#Cr=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=this.#f._signal;t.addEventListener("click",this.#Nr.bind(this),{signal:e}),t.addEventListener("keydown",this.#qs.bind(this),{signal:e});const i=this.#Er=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#Pr,t.append(i),t}renderMainDropdown(){const t=this.#Mr=this.#Fr();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#Fr(){const e=document.createElement("div"),i=this.#f._signal;e.addEventListener("contextmenu",ee,{signal:i}),e.className="dropdown",e.role="listbox",e.setAttribute("aria-multiselectable",!1),e.setAttribute("aria-orientation","vertical"),e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[s,n]of this.#f.highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",n),r.title=s,r.setAttribute("data-l10n-id",t.#Rr[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=n,r.setAttribute("aria-selected",n===this.#Pr),r.addEventListener("click",this.#Or.bind(this,n),{signal:i}),e.append(r)}return e.addEventListener("keydown",this.#qs.bind(this),{signal:i}),e}#Or(t,e){e.stopPropagation(),this.#Ir.dispatch("switchannotationeditorparams",{source:this,type:this.#Dr,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#Cr)return void this.#Nr(t);const e=t.target.getAttribute("data-color");e&&this.#Or(e,t)}_moveToNext(t){this.#Br?t.target!==this.#Cr?t.target.nextSibling?.focus():this.#Mr.firstChild?.focus():this.#Nr(t)}_moveToPrevious(t){t.target!==this.#Mr?.firstChild&&t.target!==this.#Cr?(this.#Br||this.#Nr(t),t.target.previousSibling?.focus()):this.#Br&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#Br?this.#Mr.firstChild?.focus():this.#Nr(t)}_moveToEnd(t){this.#Br?this.#Mr.lastChild?.focus():this.#Nr(t)}#qs(e){t._keyboardManager.exec(this,e)}#Nr(t){if(this.#Br)return void this.hideDropdown();if(this.#Tr=0===t.detail,this.#Lr||(this.#Lr=new AbortController,window.addEventListener("pointerdown",this.#h.bind(this),{signal:this.#f.combinedSignal(this.#Lr)})),this.#Mr)return void this.#Mr.classList.remove("hidden");const e=this.#Mr=this.#Fr();this.#Cr.append(e)}#h(t){this.#Mr?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#Mr?.classList.add("hidden"),this.#Lr?.abort(),this.#Lr=null}get#Br(){return this.#Mr&&!this.#Mr.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#kr||(this.#Br?(this.hideDropdown(),this.#Cr.focus({preventScroll:!0,focusVisible:this.#Tr})):this.#r?.unselect())}updateColor(t){if(this.#Er&&(this.#Er.style.backgroundColor=t),!this.#Mr)return;const e=this.#f.highlightColors.values();for(const i of this.#Mr.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#Cr?.remove(),this.#Cr=null,this.#Er=null,this.#Mr?.remove(),this.#Mr=null}};class mn extends Ae{#jr=null;#Vr=0;#Hr;#zr=null;#n=null;#Ur=null;#$r=null;#Wr=0;#Gr=null;#qr=null;#w=null;#Xr=!1;#mr=null;#Kr;#Yr=null;#Qr="";#er;#Jr="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=N.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=mn.prototype;return Ct(this,"_keyboardManager",new me([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||mn._defaultColor,this.#er=t.thickness||mn._defaultThickness,this.#Kr=t.opacity||mn._defaultOpacity,this.#Hr=t.boxes||null,this.#Jr=t.methodOfCreation||"",this.#Qr=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#Xr=!0,this.#Zr(t),this.#ta()):this.#Hr&&(this.#jr=t.anchorNode,this.#Vr=t.anchorOffset,this.#$r=t.focusNode,this.#Wr=t.focusOffset,this.#ea(),this.#ta(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#Xr?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#er,methodOfCreation:this.#Jr}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#ea(){const t=new cn(this.#Hr,.001);this.#qr=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#qr.box;const e=new cn(this.#Hr,.0025,.001,"ltr"===this._uiManager.direction);this.#Ur=e.getOutlines();const{lastPoint:i}=this.#Ur;this.#mr=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#Zr({highlightOutlines:t,highlightId:e,clipPathId:i}){this.#qr=t;if(this.#Ur=t.getNewOutline(this.#er/2+1.5,.0025),e>=0)this.#w=e,this.#zr=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#Yr=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#Ur.box,path:{d:this.#Ur.toSVGPath()}},!0);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#w,{bbox:mn.#ia(this.#qr.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#Yr,{bbox:mn.#ia(this.#Ur.box,e),path:{d:this.#Ur.toSVGPath()}})}const[s,n,r,a]=t.box;switch(this.rotation){case 0:this.x=s,this.y=n,this.width=r,this.height=a;break;case 90:{const[t,e]=this.parentDimensions;this.x=n,this.y=1-s,this.width=r*e/t,this.height=a*t/e;break}case 180:this.x=1-s,this.y=1-n,this.width=r,this.height=a;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-n,this.y=s,this.width=r*e/t,this.height=a*t/e;break}}const{lastPoint:o}=this.#Ur;this.#mr=[(o[0]-s)/r,(o[1]-n)/a]}static initialize(t,e){Ae.initialize(t,e),mn._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case F.HIGHLIGHT_DEFAULT_COLOR:mn._defaultColor=e;break;case F.HIGHLIGHT_THICKNESS:mn._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#mr}updateParams(t,e){switch(t){case F.HIGHLIGHT_COLOR:this.#Fn(e);break;case F.HIGHLIGHT_THICKNESS:this.#sa(e)}}static get defaultPropertiesToUpdate(){return[[F.HIGHLIGHT_DEFAULT_COLOR,mn._defaultColor],[F.HIGHLIGHT_THICKNESS,mn._defaultThickness]]}get propertiesToUpdate(){return[[F.HIGHLIGHT_COLOR,this.color||mn._defaultColor],[F.HIGHLIGHT_THICKNESS,this.#er||mn._defaultThickness],[F.HIGHLIGHT_FREE,this.#Xr]]}#Fn(t){const e=(t,e)=>{this.color=t,this.#Kr=e,this.parent?.drawLayer.updateProperties(this.#w,{root:{fill:t,"fill-opacity":e}}),this.#n?.updateColor(t)},i=this.color,s=this.#Kr;this.addCommands({cmd:e.bind(this,t,mn._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:F.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#sa(t){const e=this.#er,i=t=>{this.#er=t,this.#na(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:F.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#n=new fn({editor:this}),t.addColorPicker(this.#n)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#ra())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#ra())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#aa(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#ta(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#aa():t&&(this.#ta(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#na(t){if(!this.#Xr)return;this.#Zr({highlightOutlines:this.#qr.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#aa(){null!==this.#w&&this.parent&&(this.parent.drawLayer.remove(this.#w),this.#w=null,this.parent.drawLayer.remove(this.#Yr),this.#Yr=null)}#ta(t=this.parent){null===this.#w&&(({id:this.#w,clipPathId:this.#zr}=t.drawLayer.draw({bbox:this.#qr.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#Kr},rootClass:{highlight:!0,free:this.#Xr},path:{d:this.#qr.toSVGPath()}},!1,!0)),this.#Yr=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#Xr},bbox:this.#Ur.box,path:{d:this.#Ur.toSVGPath()}},this.#Xr),this.#Gr&&(this.#Gr.style.clipPath=this.#zr))}static#ia([t,e,i,s],n){switch(n){case 90:return[1-e-s,t,s,i];case 180:return[1-t-i,1-e-s,i,s];case 270:return[e,1-t-i,s,i]}return[t,e,i,s]}rotate(t){const{drawLayer:e}=this.parent;let i;this.#Xr?(t=(t-this.rotation+360)%360,i=mn.#ia(this.#qr.box,t)):i=mn.#ia([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#w,{bbox:i,root:{"data-main-rotation":t}}),e.updateProperties(this.#Yr,{bbox:mn.#ia(this.#Ur.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#Qr&&(t.setAttribute("aria-label",this.#Qr),t.setAttribute("role","mark")),this.#Xr?t.classList.add("free"):this.div.addEventListener("keydown",this.#oa.bind(this),{signal:this._uiManager._signal});const e=this.#Gr=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#zr;const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),ue(this,this.#Gr,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Yr,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Yr,{rootClass:{hovered:!1}})}#oa(t){mn._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#la(!0);break;case 1:case 3:this.#la(!1)}}#la(t){if(!this.#jr)return;const e=window.getSelection();t?e.setPosition(this.#jr,this.#Vr):e.setPosition(this.#$r,this.#Wr)}select(){super.select(),this.#Yr&&this.parent?.drawLayer.updateProperties(this.#Yr,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#Yr&&(this.parent?.drawLayer.updateProperties(this.#Yr,{rootClass:{selected:!1}}),this.#Xr||this.#la(!1))}get _mustFixPosition(){return!this.#Xr}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#w,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#Yr,{rootClass:{hidden:!t}}))}#ra(){return this.#Xr?this.rotation:0}#ha(){if(this.#Xr)return null;const[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=this.#Hr,r=new Float32Array(8*n.length);let a=0;for(const{x:o,y:l,width:h,height:d}of n){const n=o*t+i,c=(1-l)*e+s;r[a]=r[a+4]=n,r[a+1]=r[a+3]=c,r[a+2]=r[a+6]=n+h*t,r[a+5]=r[a+7]=c-d*e,a+=8}return r}#da(t){return this.#qr.serialize(t,this.#ra())}static startHighlighting(t,e,{target:i,x:s,y:n}){const{x:r,y:a,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,d=t.combinedSignal(h),c=e=>{h.abort(),this.#ca(t,e)};window.addEventListener("blur",c,{signal:d}),window.addEventListener("pointerup",c,{signal:d}),window.addEventListener("pointerdown",ie,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",ee,{signal:d}),i.addEventListener("pointermove",this.#ua.bind(this,t),{signal:d}),this._freeHighlight=new pn({x:s,y:n},[r,a,o,l],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static#ua(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#ca(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,i){let s=null;if(t instanceof Js){const{data:{quadPoints:e,rect:i,rotation:n,id:r,color:a,opacity:o,popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:N.HIGHLIGHT,color:Array.from(a),opacity:o,quadPoints:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:l}}else if(t instanceof Qs){const{data:{inkLists:e,rect:i,rotation:n,id:r,color:a,borderStyle:{rawWidth:o},popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:N.HIGHLIGHT,color:Array.from(a),thickness:o,inkLists:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:l}}const{color:n,quadPoints:r,inkLists:a,opacity:o}=t,l=await super.deserialize(t,e,i);l.color=jt.makeHexColor(...n),l.#Kr=o||1,a&&(l.#er=t.thickness),l.annotationElementId=t.id||null,l._initialData=s;const[h,d]=l.pageDimensions,[c,u]=l.pageTranslation;if(r){const t=l.#Hr=[];for(let e=0;e<r.length;e+=8)t.push({x:(r[e]-c)/h,y:1-(r[e+1]-u)/d,width:(r[e+2]-r[e])/h,height:(r[e+1]-r[e+5])/d});l.#ea(),l.#ta(),l.rotate(l.rotation)}else if(a){l.#Xr=!0;const t=a[0],i={x:t[0]-c,y:d-(t[1]-u)},s=new pn(i,[0,0,h,d],1,l.#er/2,!0,.001);for(let e=0,n=t.length;e<n;e+=2)i.x=t[e]-c,i.y=d-(t[e+1]-u),s.add(i);const{id:n,clipPathId:r}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:l.color,"fill-opacity":l._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:s.toSVGPath()}},!0,!0);l.#Zr({highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:r}),l.#ta()}return l}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),i=Ae._colorManager.convert(this.color),s={annotationType:N.HIGHLIGHT,color:i,opacity:this.#Kr,thickness:this.#er,quadPoints:this.#ha(),outlines:this.#da(e),pageIndex:this.pageIndex,rect:e,rotation:this.#ra(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#Un(s)?null:(s.id=this.annotationElementId,s)}#Un(t){const{color:e}=this._initialData;return t.color.some(((t,i)=>t!==e[i]))}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class bn{#pa=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,i]of Object.entries(t))this.updateProperty(e,i)}updateSVGProperty(t,e){this.#pa[t]=e}toSVGProperties(){const t=this.#pa;return this.#pa=Object.create(null),{root:t}}reset(){this.#pa=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){_t("Not implemented")}}class vn extends Ae{#ga=null;#fa;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#ma=null;static#ba=null;static#va=null;static#wa=NaN;static#ya=null;static#Aa=null;static#_a=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#fa=t.mustBeCommitted||!1,t.drawOutlines&&(this.#xa(t),this.#ta())}#xa({drawOutlines:t,drawId:e,drawingOptions:i}){this.#ga=t,this._drawingOptions||=i,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#Sa(t,this.parent),this.#Ca(t.box)}#Sa(t,e){const{id:i}=e.drawLayer.draw(vn._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){const i=new Set(Object.keys(t));for(const[s,n]of Object.entries(e))i.has(s)?Object.assign(t[s],n):t[s]=n;return t}static getDefaultDrawingOptions(t){_t("Not implemented")}static get typesMap(){_t("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){const i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(vn.#ma.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){const s=this._drawingOptions,n=s[e],r=t=>{s.updateProperty(e,t);const i=this.#ga.updateProperty(e,t);i&&this.#Ca(i),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties())};this.addCommands({cmd:r.bind(this,i),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,vn._mergeSVGProperties(this.#ga.getPathResizingSVGProperties(this.#Ea()),{bbox:this.#Pa()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,vn._mergeSVGProperties(this.#ga.getPathResizedSVGProperties(this.#Ea()),{bbox:this.#Pa()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#Pa(t,e)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,vn._mergeSVGProperties(this.#ga.getPathTranslatedSVGProperties(this.#Ea(),this.parentDimensions),{bbox:this.#Pa()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#fa&&(this.#fa=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#aa(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#ta(),this.#Ca(this.#ga.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#aa()):t&&(this._uiManager.addShouldRescale(this),this.#ta(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#aa(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#ta(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#Sa(this.#ga,t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}#Ma([t,e,i,s]){const{parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[e,1-t,i*(r/n),s*(n/r)];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,i*(r/n),s*(n/r)];default:return[t,e,i,s]}}#Ea(){const{x:t,y:e,width:i,height:s,parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[1-e,t,i*(n/r),s*(r/n)];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,i*(n/r),s*(r/n)];default:return[t,e,i,s]}}#Ca(t){if([this.x,this.y,this.width,this.height]=this.#Ma(t),this.div){this.fixAndSetPosition();const[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()}#Pa(){const{x:t,y:e,width:i,height:s,rotation:n,parentRotation:r,parentDimensions:[a,o]}=this;switch((4*n+r)/90){case 1:return[1-e-s,t,s,i];case 2:return[1-t-i,1-e-s,i,s];case 3:return[e,1-t-i,s,i];case 4:return[t,e-i*(a/o),s*(o/a),i*(a/o)];case 5:return[1-e,t,i*(a/o),s*(o/a)];case 6:return[1-t-s*(o/a),1-e,s*(o/a),i*(a/o)];case 7:return[e-i*(a/o),1-t-s*(o/a),i*(a/o),s*(o/a)];case 8:return[t-i,e-s,i,s];case 9:return[1-e,t-i,s,i];case 10:return[1-t,1-e,i,s];case 11:return[e-s,1-t,s,i];case 12:return[t-s*(o/a),e,s*(o/a),i*(a/o)];case 13:return[1-e-i*(a/o),t-s*(o/a),i*(a/o),s*(o/a)];case 14:return[1-t,1-e-i*(a/o),s*(o/a),i*(a/o)];case 15:return[e,1-t,i*(a/o),s*(o/a)];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,vn._mergeSVGProperties({bbox:this.#Pa()},this.#ga.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#Ca(this.#ga.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const t=super.render();t.classList.add("draw");const e=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal";const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,e,i,s,n){_t("Not implemented")}static startDrawing(t,e,i,s){const{target:n,offsetX:r,offsetY:a,pointerId:o,pointerType:l}=s;if(vn.#ya&&vn.#ya!==l)return;const{viewport:{rotation:h}}=t,{width:d,height:c}=n.getBoundingClientRect(),u=vn.#ba=new AbortController,p=t.combinedSignal(u);vn.#wa||=o,vn.#ya??=l,window.addEventListener("pointerup",(t=>{vn.#wa===t.pointerId?this._endDraw(t):vn.#Aa?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointercancel",(t=>{vn.#wa===t.pointerId?this._currentParent.endDrawingSession():vn.#Aa?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointerdown",(t=>{vn.#ya===t.pointerType&&((vn.#Aa||=new Set).add(t.pointerId),vn.#ma.isCancellable()&&(vn.#ma.removeLastElement(),vn.#ma.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",ee,{signal:p}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),n.addEventListener("touchmove",(t=>{t.timeStamp===vn.#_a&&ie(t)}),{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),vn.#ma?t.drawLayer.updateProperties(this._currentDrawId,vn.#ma.startNew(r,a,d,c,h)):(e.updateUIForDefaultProperties(this),vn.#ma=this.createDrawerInstance(r,a,d,c,h),vn.#va=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(vn.#va.toSVGProperties(),vn.#ma.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(vn.#_a=-1,!vn.#ma)return;const{offsetX:e,offsetY:i,pointerId:s}=t;vn.#wa===s&&(vn.#Aa?.size>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,vn.#ma.add(e,i)),vn.#_a=t.timeStamp,ie(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,vn.#ma=null,vn.#va=null,vn.#ya=null,vn.#_a=NaN),vn.#ba&&(vn.#ba.abort(),vn.#ba=null,vn.#wa=NaN,vn.#Aa=null)}static _endDraw(t){const e=this._currentParent;if(e)if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,vn.#ma.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const t=vn.#ma,i=this._currentDrawId,s=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:F.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(F.DRAW_STEP),!vn.#ma.isEmpty()){const{pageDimensions:[i,s],scale:n}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:vn.#ma.getOutlines(i*n,s*n,n,this._INNER_MARGIN),drawingOptions:vn.#va,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,n,r){_t("Not implemented")}static async deserialize(t,e,i){const{rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:a}}=e.viewport,o=this.deserializeDraw(r,a,s,n,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#xa({drawOutlines:o}),l.#ta(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){const[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return this.#ga.serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class wn{#Kn=new Float64Array(6);#bn;#Ta;#Ri;#er;#ir;#ka="";#Ia=0;#Sr=new yn;#La;#Da;constructor(t,e,i,s,n,r){this.#La=i,this.#Da=s,this.#Ri=n,this.#er=r,[t,e]=this.#Ra(t,e);const a=this.#bn=[NaN,NaN,NaN,NaN,t,e];this.#ir=[t,e],this.#Ta=[{line:a,points:this.#ir}],this.#Kn.set(a,0)}updateProperty(t,e){"stroke-width"===t&&(this.#er=e)}#Ra(t,e){return ln._normalizePoint(t,e,this.#La,this.#Da,this.#Ri)}isEmpty(){return!this.#Ta||0===this.#Ta.length}isCancellable(){return this.#ir.length<=10}add(t,e){[t,e]=this.#Ra(t,e);const[i,s,n,r]=this.#Kn.subarray(2,6),a=t-n,o=e-r;return Math.hypot(this.#La*a,this.#Da*o)<=2?null:(this.#ir.push(t,e),isNaN(i)?(this.#Kn.set([n,r,t,e],2),this.#bn.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#Kn[0])&&this.#bn.splice(6,6),this.#Kn.set([i,s,n,r,t,e],0),this.#bn.push(...ln.createBezierPoints(i,s,n,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const i=this.add(t,e);return i||(2===this.#ir.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,n){this.#La=i,this.#Da=s,this.#Ri=n,[t,e]=this.#Ra(t,e);const r=this.#bn=[NaN,NaN,NaN,NaN,t,e];this.#ir=[t,e];const a=this.#Ta.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#Ta.push({line:r,points:this.#ir}),this.#Kn.set(r,0),this.#Ia=0,this.toSVGPath(),null}getLastElement(){return this.#Ta.at(-1)}setLastElement(t){return this.#Ta?(this.#Ta.push(t),this.#bn=t.line,this.#ir=t.points,this.#Ia=0,{path:{d:this.toSVGPath()}}):this.#Sr.setLastElement(t)}removeLastElement(){if(!this.#Ta)return this.#Sr.removeLastElement();this.#Ta.pop(),this.#ka="";for(let t=0,e=this.#Ta.length;t<e;t++){const{line:e,points:i}=this.#Ta[t];this.#bn=e,this.#ir=i,this.#Ia=0,this.toSVGPath()}return{path:{d:this.#ka}}}toSVGPath(){const t=ln.svgRound(this.#bn[4]),e=ln.svgRound(this.#bn[5]);if(2===this.#ir.length)return this.#ka=`${this.#ka} M ${t} ${e} Z`,this.#ka;if(this.#ir.length<=6){const i=this.#ka.lastIndexOf("M");this.#ka=`${this.#ka.slice(0,i)} M ${t} ${e}`,this.#Ia=6}if(4===this.#ir.length){const t=ln.svgRound(this.#bn[10]),e=ln.svgRound(this.#bn[11]);return this.#ka=`${this.#ka} L ${t} ${e}`,this.#Ia=12,this.#ka}const i=[];0===this.#Ia&&(i.push(`M ${t} ${e}`),this.#Ia=6);for(let t=this.#Ia,e=this.#bn.length;t<e;t+=6){const[e,s,n,r,a,o]=this.#bn.slice(t,t+6).map(ln.svgRound);i.push(`C${e} ${s} ${n} ${r} ${a} ${o}`)}return this.#ka+=i.join(" "),this.#Ia=this.#bn.length,this.#ka}getOutlines(t,e,i,s){const n=this.#Ta.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#Sr.build(this.#Ta,t,e,i,this.#Ri,this.#er,s),this.#Kn=null,this.#bn=null,this.#Ta=null,this.#ka=null,this.#Sr}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class yn extends ln{#pr;#Na=0;#Gn;#Ta;#La;#Da;#Fa;#Ri;#er;build(t,e,i,s,n,r,a){this.#La=e,this.#Da=i,this.#Fa=s,this.#Ri=n,this.#er=r,this.#Gn=a??0,this.#Ta=t,this.#Oa()}setLastElement(t){return this.#Ta.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#Ta.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#Ta)if(t.push(`M${ln.svgRound(e[4])} ${ln.svgRound(e[5])}`),6!==e.length)if(12!==e.length)for(let i=6,s=e.length;i<s;i+=6){const[s,n,r,a,o,l]=e.subarray(i,i+6).map(ln.svgRound);t.push(`C${s} ${n} ${r} ${a} ${o} ${l}`)}else t.push(`L${ln.svgRound(e[10])} ${ln.svgRound(e[11])}`);else t.push("Z");return t.join("")}serialize([t,e,i,s],n){const r=[],a=[],[o,l,h,d]=this.#Ba();let c,u,p,g,f,m,b,v,w;switch(this.#Ri){case 0:w=ln._rescale,c=t,u=e+s,p=i,g=-s,f=t+o*i,m=e+(1-l-d)*s,b=t+(o+h)*i,v=e+(1-l)*s;break;case 90:w=ln._rescaleAndSwap,c=t,u=e,p=i,g=s,f=t+l*i,m=e+o*s,b=t+(l+d)*i,v=e+(o+h)*s;break;case 180:w=ln._rescale,c=t+i,u=e,p=-i,g=s,f=t+(1-o-h)*i,m=e+l*s,b=t+(1-o)*i,v=e+(l+d)*s;break;case 270:w=ln._rescaleAndSwap,c=t+i,u=e+s,p=-i,g=-s,f=t+(1-l-d)*i,m=e+(1-o-h)*s,b=t+(1-l)*i,v=e+(1-o)*s}for(const{line:t,points:e}of this.#Ta)r.push(w(t,c,u,p,g,n?new Array(t.length):null)),a.push(w(e,c,u,p,g,n?new Array(e.length):null));return{lines:r,points:a,rect:[f,m,b,v]}}static deserialize(t,e,i,s,n,{paths:{lines:r,points:a},rotation:o,thickness:l}){const h=[];let d,c,u,p,g;switch(o){case 0:g=ln._rescale,d=-t/i,c=e/s+1,u=1/i,p=-1/s;break;case 90:g=ln._rescaleAndSwap,d=-e/s,c=-t/i,u=1/s,p=1/i;break;case 180:g=ln._rescale,d=t/i+1,c=-e/s,u=-1/i,p=1/s;break;case 270:g=ln._rescaleAndSwap,d=e/s+1,c=t/i+1,u=-1/s,p=-1/i}if(!r){r=[];for(const t of a){const e=t.length;if(2===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}const i=new Float32Array(3*(e-2));r.push(i);let[s,n,a,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,n],0);for(let r=4;r<e;r+=2){const e=t[r],l=t[r+1];i.set(ln.createBezierPoints(s,n,a,o,e,l),3*(r-2)),[s,n,a,o]=[a,o,e,l]}}}for(let t=0,e=r.length;t<e;t++)h.push({line:g(r[t].map((t=>t??NaN)),d,c,u,p),points:g(a[t].map((t=>t??NaN)),d,c,u,p)});const f=new yn;return f.build(h,i,s,1,o,l,n),f}#ja(t=this.#er){const e=this.#Gn+t/2*this.#Fa;return this.#Ri%180==0?[e/this.#La,e/this.#Da]:[e/this.#Da,e/this.#La]}#Ba(){const[t,e,i,s]=this.#pr,[n,r]=this.#ja(0);return[t+n,e+r,i-2*n,s-2*r]}#Oa(){const t=this.#pr=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:e}of this.#Ta){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6){const[s,n]=e.subarray(i,i+2);t[0]=Math.min(t[0],s),t[1]=Math.min(t[1],n),t[2]=Math.max(t[2],s),t[3]=Math.max(t[3],n)}continue}let i=e[4],s=e[5];for(let n=6,r=e.length;n<r;n+=6){const[r,a,o,l,h,d]=e.subarray(n,n+6);jt.bezierBoundingBox(i,s,r,a,o,l,h,d,t),i=h,s=d}}const[e,i]=this.#ja();t[0]=Math.min(1,Math.max(0,t[0]-e)),t[1]=Math.min(1,Math.max(0,t[1]-i)),t[2]=Math.min(1,Math.max(0,t[2]+e)),t[3]=Math.min(1,Math.max(0,t[3]+i)),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#pr}updateProperty(t,e){return"stroke-width"===t?this.#sa(e):null}#sa(t){const[e,i]=this.#ja();this.#er=t;const[s,n]=this.#ja(),[r,a]=[s-e,n-i],o=this.#pr;return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o}updateParentDimensions([t,e],i){const[s,n]=this.#ja();this.#La=t,this.#Da=e,this.#Fa=i;const[r,a]=this.#ja(),o=r-s,l=a-n,h=this.#pr;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#Na=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#pr.map(ln.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#pr;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ln.svgRound(t)} ${ln.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#pr;let i=0,s=0,n=0,r=0,a=0,o=0;switch(this.#Na){case 90:s=e/t,n=-t/e,a=t;break;case 180:i=-1,r=-1,a=t,o=e;break;case 270:s=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${n} ${r} ${ln.svgRound(a)} ${ln.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){const[n,r]=this.#ja(),[a,o,l,h]=this.#pr;if(Math.abs(l-n)<=ln.PRECISION||Math.abs(h-r)<=ln.PRECISION){const n=t+i/2-(a+l/2),r=e+s/2-(o+h/2);return{path:{"transform-origin":`${ln.svgRound(t)} ${ln.svgRound(e)}`,transform:`${this.rotationTransform} translate(${n} ${r})`}}}const d=(i-2*n)/(l-2*n),c=(s-2*r)/(h-2*r),u=l/i,p=h/s;return{path:{"transform-origin":`${ln.svgRound(a)} ${ln.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${p}) translate(${ln.svgRound(n)} ${ln.svgRound(r)}) scale(${d} ${c}) translate(${ln.svgRound(-n)} ${ln.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,i,s]){const[n,r]=this.#ja(),a=this.#pr,[o,l,h,d]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=s,Math.abs(h-n)<=ln.PRECISION||Math.abs(d-r)<=ln.PRECISION){const n=t+i/2-(o+h/2),r=e+s/2-(l+d/2);for(const{line:t,points:e}of this.#Ta)ln._translate(t,n,r,t),ln._translate(e,n,r,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ln.svgRound(t)} ${ln.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const c=(i-2*n)/(h-2*n),u=(s-2*r)/(d-2*r),p=-c*(o+n)+t+n,g=-u*(l+r)+e+r;if(1!==c||1!==u||0!==p||0!==g)for(const{line:t,points:e}of this.#Ta)ln._rescale(t,p,g,c,u,t),ln._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ln.svgRound(t)} ${ln.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[s,n]=i,r=this.#pr,a=t-r[0],o=e-r[1];if(this.#La===s&&this.#Da===n)for(const{line:t,points:e}of this.#Ta)ln._translate(t,a,o,t),ln._translate(e,a,o,e);else{const t=this.#La/s,e=this.#Da/n;this.#La=s,this.#Da=n;for(const{line:i,points:s}of this.#Ta)ln._rescale(i,a,o,t,e,i),ln._rescale(s,a,o,t,e,s);r[2]*=t,r[3]*=e}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${ln.svgRound(t)} ${ln.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#pr;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${ln.svgRound(t[0])} ${ln.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class An extends bn{#Va;constructor(t){super(),this.#Va=t,super.updateProperties({fill:"none",stroke:Ae._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??=this["stroke-width"],e*=this.#Va.realScale),super.updateSVGProperty(t,e)}clone(){const t=new An(this.#Va);return t.updateAll(this),t}}class _n extends vn{static _type="ink";static _editorType=N.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(t,e){Ae.initialize(t,e),this._defaultDrawingOptions=new An(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Ct(this,"typesMap",new Map([[F.INK_THICKNESS,"stroke-width"],[F.INK_COLOR,"stroke"],[F.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,n){return new wn(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,r){return yn.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){let s=null;if(t instanceof Qs){const{data:{inkLists:e,rect:i,rotation:n,id:r,color:a,opacity:o,borderStyle:{rawWidth:l},popupRef:h},parent:{page:{pageNumber:d}}}=t;s=t={annotationType:N.INK,color:Array.from(a),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:d-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:h}}const n=await super.deserialize(t,e,i);return n.annotationElementId=t.id||null,n._initialData=s,n}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:i}){this._drawingOptions=_n.getDefaultDrawingOptions({stroke:jt.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:i,rect:s}=this.serializeDraw(t),{_drawingOptions:{stroke:n,"stroke-opacity":r,"stroke-width":a}}=this,o={annotationType:N.INK,color:Ae._colorManager.convert(n),opacity:r,thickness:a,paths:{lines:e,points:i},pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?o:this.annotationElementId&&!this.#Un(o)?null:(o.id=this.annotationElementId,o)}#Un(t){const{color:e,thickness:i,opacity:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some(((t,i)=>t!==e[i]))||t.thickness!==i||t.opacity!==s||t.pageIndex!==n}renderAnnotationElement(t){const{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e}),null}}class xn extends Ae{#Ha=null;#za=null;#Ua=null;#$a=null;#Wa=null;#Ga="";#qa=null;#Xa=null;#Ka=!1;#Ya=!1;static _type="stamp";static _editorType=N.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#$a=t.bitmapUrl,this.#Wa=t.bitmapFile}static initialize(t,e){Ae.initialize(t,e)}static get supportedTypes(){return Ct(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((t=>`image/${t}`)))}static get supportedTypesStr(){return Ct(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(N.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#Qa(t,e=!1){t?(this.#Ha=t.bitmap,e||(this.#za=t.id,this.#Ka=t.isSvg),t.file&&(this.#Ga=t.file.name),this.#Ja()):this.remove()}#Za(){if(this.#Ua=null,this._uiManager.enableWaiting(!1),this.#qa){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Ha)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Ha){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:s,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:s,width:n,height:r,channels:s.length/(n*r)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");const o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#to(){if(this.#za)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#za).then((t=>this.#Qa(t,!0))).finally((()=>this.#Za()));if(this.#$a){const t=this.#$a;return this.#$a=null,this._uiManager.enableWaiting(!0),void(this.#Ua=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#Qa(t))).finally((()=>this.#Za())))}if(this.#Wa){const t=this.#Wa;return this.#Wa=null,this._uiManager.enableWaiting(!0),void(this.#Ua=this._uiManager.imageManager.getFromFile(t).then((t=>this.#Qa(t))).finally((()=>this.#Za())))}const t=document.createElement("input");t.type="file",t.accept=xn.supportedTypesStr;const e=this._uiManager._signal;this.#Ua=new Promise((i=>{t.addEventListener("change",(async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#Qa(e)}else this.remove();i()}),{signal:e}),t.addEventListener("cancel",(()=>{this.remove(),i()}),{signal:e})})).finally((()=>this.#Za())),t.click()}remove(){this.#za&&(this.#Ha=null,this._uiManager.imageManager.deleteId(this.#za),this.#qa?.remove(),this.#qa=null,this.#Xa&&(clearTimeout(this.#Xa),this.#Xa=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#za&&null===this.#qa&&this.#to(),this.isAttachedToDOM||this.parent.add(this))):this.#za&&this.#to()}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#Ua||this.#Ha||this.#$a||this.#Wa||this.#za)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#Ha?this.#Ja():this.#to(),this.width&&!this.annotationElementId){const[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==this.#Xa&&clearTimeout(this.#Xa);this.#Xa=setTimeout((()=>{this.#Xa=null,this.#eo()}),200)}#Ja(){const{div:t}=this;let{width:e,height:i}=this.#Ha;const[s,n]=this.pageDimensions,r=.75;if(this.width)e=this.width*s,i=this.height*n;else if(e>r*s||i>r*n){const t=Math.min(r*s/e,r*n/i);e*=t,i*=t}const[a,o]=this.parentDimensions;this.setDims(e*a/s,i*o/n),this._uiManager.enableWaiting(!1);const l=this.#qa=document.createElement("canvas");l.setAttribute("role","img"),this.addContainer(l),this.width=e/s,this.height=i/n,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#eo(),this.#Ya||(this.parent.addUndoableEditor(this),this.#Ya=!0),this._reportTelemetry({action:"inserted_image"}),this.#Ga&&l.setAttribute("aria-label",this.#Ga)}copyCanvas(t,e,i=!1){t||(t=224);const{width:s,height:n}=this.#Ha,r=new he;let a=this.#Ha,o=s,l=n,h=null;if(e){if(s>e||n>e){const t=Math.min(e/s,e/n);o=Math.floor(s*t),l=Math.floor(n*t)}h=document.createElement("canvas");const t=h.width=Math.ceil(o*r.sx),i=h.height=Math.ceil(l*r.sy);this.#Ka||(a=this.#io(t,i));const d=h.getContext("2d");d.filter=this._uiManager.hcmFilter;let c="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(c="#8f8f9d",u="#42414d");const p=15,g=p*r.sx,f=p*r.sy,m=new OffscreenCanvas(2*g,2*f),b=m.getContext("2d");b.fillStyle=c,b.fillRect(0,0,2*g,2*f),b.fillStyle=u,b.fillRect(0,0,g,f),b.fillRect(g,f,g,f),d.fillStyle=d.createPattern(m,"repeat"),d.fillRect(0,0,t,i),d.drawImage(a,0,0,a.width,a.height,0,0,t,i)}let d=null;if(i){let e,i;if(r.symmetric&&a.width<t&&a.height<t)e=a.width,i=a.height;else if(a=this.#Ha,s>t||n>t){const r=Math.min(t/s,t/n);e=Math.floor(s*r),i=Math.floor(n*r),this.#Ka||(a=this.#io(e,i))}const o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(a,0,0,a.width,a.height,0,0,e,i),d={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:d}}#io(t,e){const{width:i,height:s}=this.#Ha;let n=i,r=s,a=this.#Ha;for(;n>2*t||r>2*e;){const i=n,s=r;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));const o=new OffscreenCanvas(n,r);o.getContext("2d").drawImage(a,0,0,i,s,0,0,n,r),a=o.transferToImageBitmap()}return a}#eo(){const[t,e]=this.parentDimensions,{width:i,height:s}=this,n=new he,r=Math.ceil(i*t*n.sx),a=Math.ceil(s*e*n.sy),o=this.#qa;if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;const l=this.#Ka?this.#Ha:this.#io(r,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,r,a)}getImageForAltText(){return this.#qa}#so(t){if(t){if(this.#Ka){const t=this._uiManager.imageManager.getSvgUrl(this.#za);if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=this.#Ha);return t.getContext("2d").drawImage(this.#Ha,0,0),t.toDataURL()}if(this.#Ka){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*Wt.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*Wt.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(this.#Ha,0,0,this.#Ha.width,this.#Ha.height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(this.#Ha)}static async deserialize(t,e,i){let s=null;if(t instanceof sn){const{data:{rect:n,rotation:r,id:a,structParent:o,popupRef:l},container:h,parent:{page:{pageNumber:d}}}=t,c=h.querySelector("canvas"),u=i.imageManager.getFromCanvas(h.id,c);c.remove();const p=(await e._structTree.getAriaAttributes(`${Ut}${a}`))?.get("aria-label")||"";s=t={annotationType:N.STAMP,bitmapId:u.id,bitmap:u.bitmap,pageIndex:d-1,rect:n.slice(0),rotation:r,id:a,deleted:!1,accessibilityData:{decorative:!1,altText:p},isSvg:!1,structParent:o,popupRef:l}}const n=await super.deserialize(t,e,i),{rect:r,bitmap:a,bitmapUrl:o,bitmapId:l,isSvg:h,accessibilityData:d}=t;l&&i.imageManager.isValidId(l)?(n.#za=l,a&&(n.#Ha=a)):n.#$a=o,n.#Ka=h;const[c,u]=n.pageDimensions;return n.width=(r[2]-r[0])/c,n.height=(r[3]-r[1])/u,n.annotationElementId=t.id||null,d&&(n.altTextData=d),n._initialData=s,n.#Ya=!!s,n}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:N.STAMP,bitmapId:this.#za,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#Ka,structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=this.#so(!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(i.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const t=this.#Un(i);if(t.isSame)return null;t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,null===e)return i;e.stamps||=new Map;const r=this.#Ka?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#za)){if(this.#Ka){const t=e.stamps.get(this.#za);r>t.area&&(t.area=r,t.serialized.bitmap.close(),t.serialized.bitmap=this.#so(!1))}}else e.stamps.set(this.#za,{area:r,serialized:i}),i.bitmap=this.#so(!1);return i}#Un(t){const{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&s&&n,isSameAltText:n}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}let Sn=class t{#En;#no=!1;#ro=null;#ao=null;#oo=null;#lo=new Map;#ho=!1;#do=!1;#co=!1;#uo=null;#po=null;#go=null;#fo=null;#f;static _initialized=!1;static#H=new Map([on,_n,xn,mn].map((t=>[t._editorType,t])));constructor({uiManager:e,pageIndex:i,div:s,structTreeLayer:n,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:d}){const c=[...t.#H.values()];if(!t._initialized){t._initialized=!0;for(const t of c)t.initialize(d,e)}e.registerEditorTypes(c),this.#f=e,this.pageIndex=i,this.div=s,this.#En=r,this.#ro=a,this.viewport=h,this.#go=l,this.drawLayer=o,this._structTree=n,this.#f.addLayer(this)}get isEmpty(){return 0===this.#lo.size}get isInvisible(){return this.isEmpty&&this.#f.getMode()===N.NONE}updateToolbar(t){this.#f.updateToolbar(t)}updateMode(e=this.#f.getMode()){switch(this.#mo(),e){case N.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case N.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case N.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:i}=this.div;for(const s of t.#H.values())i.toggle(`${s._type}Editing`,e===s._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#go?.div}setEditingState(t){this.#f.setEditingState(t)}addCommands(t){this.#f.addCommands(t)}cleanUndoStack(t){this.#f.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#ro?.div.classList.toggle("disabled",!t)}async enable(){this.#co=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const e of this.#lo.values())e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#f.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(!this.#ro)return void(this.#co=!1);const e=this.#ro.getEditableAnnotations();for(const i of e){if(i.hide(),this.#f.isDeletedAnnotationElement(i.data.id))continue;if(t.has(i.data.id))continue;const e=await this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}this.#co=!1}disable(){this.#do=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,i=new Map;for(const t of this.#lo.values())t.disableEditing(),t.annotationElementId&&(null===t.serialize()?(i.set(t.annotationElementId,t),this.getEditableAnnotation(t.annotationElementId)?.show(),t.remove()):e.set(t.annotationElementId,t));if(this.#ro){const t=this.#ro.getEditableAnnotations();for(const s of t){const{id:t}=s.data;if(this.#f.isDeletedAnnotationElement(t))continue;let n=i.get(t);n?(n.resetAnnotationElement(s),n.show(!1),s.show()):(n=e.get(t),n&&(this.#f.addChangedExistingAnnotation(n),n.renderAnnotationElement(s)&&n.show(!1)),s.show())}}this.#mo(),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const e of t.#H.values())s.remove(`${e._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#do=!1}getEditableAnnotation(t){return this.#ro?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#f.getActive()!==t&&this.#f.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#go?.div&&!this.#fo){this.#fo=new AbortController;const t=this.#f.combinedSignal(this.#fo);this.#go.div.addEventListener("pointerdown",this.#bo.bind(this),{signal:t}),this.#go.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#go?.div&&this.#fo&&(this.#fo.abort(),this.#fo=null,this.#go.div.classList.remove("highlighting"))}#bo(t){this.#f.unselectAll();const{target:e}=t;if(e===this.#go.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#go.div.contains(e)){const{isMac:e}=Ot.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#f.showAllEditors("highlight",!0,!0),this.#go.div.classList.add("free"),this.toggleDrawing(),mn.startHighlighting(this,"ltr"===this.#f.direction,{target:this.#go.div,x:t.x,y:t.y}),this.#go.div.addEventListener("pointerup",(()=>{this.#go.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#f._signal}),t.preventDefault()}}enableClick(){if(this.#ao)return;this.#ao=new AbortController;const t=this.#f.combinedSignal(this.#ao);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#ao?.abort(),this.#ao=null}attach(t){this.#lo.set(t.id,t);const{annotationElementId:e}=t;e&&this.#f.isDeletedAnnotationElement(e)&&this.#f.removeDeletedAnnotationElement(t)}detach(t){this.#lo.delete(t.id),this.#En?.removePointerInTextLayer(t.contentDiv),!this.#do&&t.annotationElementId&&this.#f.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#f.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#f.addDeletedAnnotationElement(t.annotationElementId),Ae.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),this.#f.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#co),this.#f.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#oo&&(t._focusEventsAllowed=!1,this.#oo=setTimeout((()=>{this.#oo=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this.#f._signal}),e.focus())}),0)),t._structTreeParentId=this.#En?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return this.#f.getId()}get#vo(){return t.#H.get(this.#f.getMode())}combinedSignal(t){return this.#f.combinedSignal(t)}#wo(t){const e=this.#vo;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#vo?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#f.updateToolbar(t),this.#f.updateMode(t);const{offsetX:i,offsetY:s}=this.#yo(),n=this.getNextId(),r=this.#wo({parent:this,id:n,x:i,y:s,uiManager:this.#f,isCentered:!0,...e});r&&this.add(r)}async deserialize(e){return await(t.#H.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#f))||null}createAndAddNewEditor(t,e,i={}){const s=this.getNextId(),n=this.#wo({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#f,isCentered:e,...i});return n&&this.add(n),n}#yo(){const{x:t,y:e,width:i,height:s}=this.div.getBoundingClientRect(),n=Math.max(0,t),r=Math.max(0,e),a=(n+Math.min(window.innerWidth,t+i))/2-t,o=(r+Math.min(window.innerHeight,e+s))/2-e,[l,h]=this.viewport.rotation%180==0?[a,o]:[o,a];return{offsetX:l,offsetY:h}}addNewEditor(){this.createAndAddNewEditor(this.#yo(),!0)}setSelected(t){this.#f.setSelected(t)}toggleSelected(t){this.#f.toggleSelected(t)}unselect(t){this.#f.unselect(t)}pointerup(t){const{isMac:e}=Ot.platform;0!==t.button||t.ctrlKey&&e||t.target===this.div&&this.#ho&&(this.#ho=!1,this.#vo?.isDrawer&&this.#vo.supportMultipleDrawings||(this.#no?this.#f.getMode()!==N.STAMP?this.createAndAddNewEditor(t,!1):this.#f.unselectAll():this.#no=!0))}pointerdown(t){if(this.#f.getMode()===N.HIGHLIGHT&&this.enableTextSelection(),this.#ho)return void(this.#ho=!1);const{isMac:e}=Ot.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#ho=!0,this.#vo?.isDrawer)return void this.startDrawingSession(t);const i=this.#f.getActive();this.#no=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus(),this.#uo)return void this.#vo.startDrawing(this,this.#f,!1,t);this.#f.setCurrentDrawingSession(this),this.#uo=new AbortController;const e=this.#f.combinedSignal(this.#uo);this.div.addEventListener("blur",(({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#po=null,this.commitOrRemove())}),{signal:e}),this.#vo.startDrawing(this,this.#f,!1,t)}pause(t){if(t){const{activeElement:t}=document;this.div.contains(t)&&(this.#po=t)}else this.#po&&setTimeout((()=>{this.#po?.focus(),this.#po=null}),0)}endDrawingSession(t=!1){return this.#uo?(this.#f.setCurrentDrawingSession(null),this.#uo.abort(),this.#uo=null,this.#po=null,this.#vo.endDrawing(t)):null}findNewParent(t,e,i){const s=this.#f.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#uo&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#uo&&this.#vo.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#f.getActive()?.parent===this&&(this.#f.commitOrRemove(),this.#f.setActiveEditor(null)),this.#oo&&(clearTimeout(this.#oo),this.#oo=null);for(const t of this.#lo.values())this.#En?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#lo.clear(),this.#f.removeLayer(this)}#mo(){for(const t of this.#lo.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,le(this.div,t);for(const t of this.#f.getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:t}){this.#f.commitOrRemove(),this.#mo();const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,le(this.div,{rotation:i}),e!==i)for(const t of this.#lo.values())t.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#f.viewParameters.realScale}},Cn=class t{#nn=null;#w=0;#Ao=new Map;#_o=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#nn){if(this.#nn!==t){if(this.#Ao.size>0)for(const e of this.#Ao.values())e.remove(),t.append(e);this.#nn=t}}else this.#nn=t}static get _svgFactory(){return Ct(this,"_svgFactory",new Es)}static#xo(t,[e,i,s,n]){const{style:r}=t;r.top=100*i+"%",r.left=100*e+"%",r.width=100*s+"%",r.height=100*n+"%"}#So(){const e=t._svgFactory.create(1,1,!0);return this.#nn.append(e),e.setAttribute("aria-hidden",!0),e}#Co(e,i){const s=t._svgFactory.createElement("clipPath");e.append(s);const n=`clip_${i}`;s.setAttribute("id",n),s.setAttribute("clipPathUnits","objectBoundingBox");const r=t._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${i}`),r.classList.add("clip"),n}#Eo(t,e){for(const[i,s]of Object.entries(e))null===s?t.removeAttribute(i):t.setAttribute(i,s)}draw(e,i=!1,s=!1){const n=this.#w++,r=this.#So(),a=t._svgFactory.createElement("defs");r.append(a);const o=t._svgFactory.createElement("path");a.append(o);const l=`path_p${this.pageIndex}_${n}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),i&&this.#_o.set(n,o);const h=s?this.#Co(a,l):null,d=t._svgFactory.createElement("use");return r.append(d),d.setAttribute("href",`#${l}`),this.updateProperties(r,e),this.#Ao.set(n,r),{id:n,clipPathId:`url(#${h})`}}drawOutline(e,i){const s=this.#w++,n=this.#So(),r=t._svgFactory.createElement("defs");n.append(r);const a=t._svgFactory.createElement("path");r.append(a);const o=`path_p${this.pageIndex}_${s}`;let l;if(a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),i){const e=t._svgFactory.createElement("mask");r.append(e),l=`mask_p${this.pageIndex}_${s}`,e.setAttribute("id",l),e.setAttribute("maskUnits","objectBoundingBox");const i=t._svgFactory.createElement("rect");e.append(i),i.setAttribute("width","1"),i.setAttribute("height","1"),i.setAttribute("fill","white");const n=t._svgFactory.createElement("use");e.append(n),n.setAttribute("href",`#${o}`),n.setAttribute("stroke","none"),n.setAttribute("fill","black"),n.setAttribute("fill-rule","nonzero"),n.classList.add("mask")}const h=t._svgFactory.createElement("use");n.append(h),h.setAttribute("href",`#${o}`),l&&h.setAttribute("mask",`url(#${l})`);const d=h.cloneNode();return n.append(d),h.classList.add("mainOutline"),d.classList.add("secondaryOutline"),this.updateProperties(n,e),this.#Ao.set(s,n),s}finalizeDraw(t,e){this.#_o.delete(t),this.updateProperties(t,e)}updateProperties(e,i){if(!i)return;const{root:s,bbox:n,rootClass:r,path:a}=i,o="number"==typeof e?this.#Ao.get(e):e;if(o){if(s&&this.#Eo(o,s),n&&t.#xo(o,n),r){const{classList:t}=o;for(const[e,i]of Object.entries(r))t.toggle(e,i)}if(a){const t=o.firstChild.firstChild;this.#Eo(t,a)}}}updateParent(t,e){if(e===this)return;const i=this.#Ao.get(t);i&&(e.#nn.append(i),this.#Ao.delete(t),e.#Ao.set(t,i))}remove(t){this.#_o.delete(t),null!==this.#nn&&(this.#Ao.get(t).remove(),this.#Ao.delete(t))}destroy(){this.#nn=null;for(const t of this.#Ao.values())t.remove();this.#Ao.clear(),this.#_o.clear()}};globalThis.pdfjsTestingUtils={HighlightOutliner:cn};var En=A.AnnotationEditorParamsType,Pn=A.AnnotationEditorType,Mn=A.AnnotationMode,Tn=A.GlobalWorkerOptions,kn=A.PDFDateString,In=A.PixelsPerInch,Ln=A.RenderingCancelledException,Dn=A.getDocument,Rn=A.getPdfFilenameFromUrl,Nn=A.getXfaPageViewport,Fn={d:(t,e)=>{for(var i in e)Fn.o(e,i)&&!Fn.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},On=globalThis.pdfjsViewer={};Fn.d(On,{AnnotationLayerBuilder:()=>Ca,DownloadManager:()=>Pa,EventBus:()=>ka,FindState:()=>mr,GenericL10n:()=>Go,LinkTarget:()=>Ir,PDFFindController:()=>kr,PDFHistory:()=>Xo,PDFLinkService:()=>Lr,PDFPageView:()=>ml,PDFScriptingManager:()=>wl,PDFSinglePageViewer:()=>Pl,PDFViewer:()=>El,ProgressBar:()=>nr,RenderingStates:()=>Bn,ScrollMode:()=>Gn,SimpleLinkService:()=>Dr,SpreadMode:()=>qn,StructTreeLayerBuilder:()=>hl,TextLayerBuilder:()=>ul,XfaLayerBuilder:()=>pl,parseQueryString:()=>Kn});const Bn={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},jn=0,Vn=1,Hn=2,zn=3,Un=0,$n=1,Wn=2,Gn={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},qn={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};function Xn(t,e,i=!1){let s=t.offsetParent;if(!s)return void console.error("offsetParent is not set -- cannot scroll");let n=t.offsetTop+t.clientTop,r=t.offsetLeft+t.clientLeft;for(;s.clientHeight===s.scrollHeight&&s.clientWidth===s.scrollWidth||i&&(s.classList.contains("markedContent")||"hidden"===getComputedStyle(s).overflow);)if(n+=s.offsetTop,r+=s.offsetLeft,s=s.offsetParent,!s)return;e&&(void 0!==e.top&&(n+=e.top),void 0!==e.left&&(r+=e.left,s.scrollLeft=r)),s.scrollTop=n}function Kn(t){const e=new Map;for(const[i,s]of new URLSearchParams(t))e.set(i.toLowerCase(),s);return e}const Yn=/[\x00-\x1F]/g;function Qn(t,e=!1){return Yn.test(t)?e?t.replaceAll(Yn,(t=>"\0"===t?"":" ")):t.replaceAll("\0",""):t}function Jn(t,e,i=0){let s=i,n=t.length-1;if(n<0||!e(t[n]))return t.length;if(e(t[s]))return s;for(;s<n;){const i=s+n>>1;e(t[i])?n=i:s=i+1}return s}function Zn(t){if(Math.floor(t)===t)return[t,1];const e=1/t;if(e>8)return[1,8];if(Math.floor(e)===e)return[1,e];const i=t>1?e:t;let s,n=0,r=1,a=1,o=1;for(;;){const t=n+a,e=r+o;if(e>8)break;i<=t/e?(a=t,o=e):(n=t,r=e)}return s=i-n/r<a/o-i?i===t?[n,r]:[r,n]:i===t?[a,o]:[o,a],s}function tr(t,e){return t-t%e}function er(t){return Number.isInteger(t)&&t%90==0}function ir(t){return t.width<=t.height}new Promise((function(t){window.requestAnimationFrame(t)}));const sr=document.documentElement.style;let nr=class{#Po=null;#Mo=null;#To=0;#ko=null;#wi=!0;constructor(t){this.#Po=t.classList,this.#ko=t.style}get percent(){return this.#To}set percent(t){var e,i,s;this.#To=(e=t,i=0,s=100,Math.min(Math.max(e,i),s)),isNaN(t)?this.#Po.add("indeterminate"):(this.#Po.remove("indeterminate"),this.#ko.setProperty("--progressBar-percent",`${this.#To}%`))}setWidth(t){if(!t)return;const e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&this.#ko.setProperty("--progressBar-end-offset",`${e}px`)}setDisableAutoFetch(t=5e3){100===this.#To||isNaN(this.#To)||(this.#Mo&&clearTimeout(this.#Mo),this.show(),this.#Mo=setTimeout((()=>{this.#Mo=null,this.hide()}),t))}hide(){this.#wi&&(this.#wi=!1,this.#Po.add("hidden"))}show(){this.#wi||(this.#wi=!0,this.#Po.remove("hidden"))}};const rr=function(){const t=document.createElement("div");return t.style.width="round(down, calc(1.6666666666666665 * 792px), 1px)","calc(1320px)"===t.style.width?Math.fround:t=>t}(),ar=0,or=1,lr=2,hr=3,dr=4,cr=5,ur=6,pr=7;function gr(t){return function(t){return t<11904}(t)?function(t){return!(65408&t)}(t)?function(t){return 32===t||9===t||13===t||10===t}(t)?ar:function(t){return t>=97&&t<=122||t>=65&&t<=90}(t)||function(t){return t>=48&&t<=57}(t)||95===t?or:lr:function(t){return 3584==(65408&t)}(t)?pr:160===t?ar:or:function(t){return t>=13312&&t<=40959||t>=63744&&t<=64255}(t)?hr:function(t){return t>=12448&&t<=12543}(t)?dr:function(t){return t>=12352&&t<=12447}(t)?cr:function(t){return t>=65376&&t<=65439}(t)?ur:or}let fr;const mr={FOUND:0,NOT_FOUND:1,WRAPPED:2,PENDING:3},br={"‐":"-","‘":"'","’":"'","‚":"'","‛":"'","“":'"',"”":'"',"„":'"',"‟":'"',"¼":"1/4","½":"1/2","¾":"3/4"},vr=new Set([12441,12442,2381,2509,2637,2765,2893,3021,3149,3277,3387,3388,3405,3530,3642,3770,3972,4153,4154,5908,5940,6098,6752,6980,7082,7083,7154,7155,11647,43014,43052,43204,43347,43456,43766,44013,3158,3953,3954,3962,3963,3964,3965,3968,3956]);let wr;const yr=/\p{M}+/gu,Ar=/([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu,_r=/([^\p{M}])\p{M}*$/u,xr=/^\p{M}*([^\p{M}])/u,Sr=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,Cr=new Map,Er=new Map;let Pr=null,Mr=null;function Tr(t){const e=[];let i,s;for(;null!==(i=Sr.exec(t));){let{index:t}=i;for(const s of i[0]){let i=Cr.get(s);i||(i=s.normalize("NFD").length,Cr.set(s,i)),e.push([i,t++])}}if(0===e.length&&Pr)s=Pr;else if(e.length>0&&Mr)s=Mr;else{const t=`([${Object.keys(br).join("")}])|([${fr||=" ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩",fr}])|(${"(?:゙|゚)"}\\n)|(\\p{M}+(?:-\\n)?)|(${"\\p{Ll}-\\n\\p{Lu}"})|(\\S-\\n)|(${"(?:\\p{Ideographic}|[぀-ヿ])"}\\n)|(\\n)`;s=0===e.length?Pr=new RegExp(t+"|(\\u0000)","gum"):Mr=new RegExp(t+"|([\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f])","gum")}const n=[];for(;null!==(i=yr.exec(t));)n.push([i[0].length,i.index]);let r=t.normalize("NFD");const a=[0,0];let o=0,l=0,h=0,d=0,c=0,u=!1;r=r.replace(s,((t,i,s,r,p,g,f,m,b,v,w)=>{if(w-=d,i){const t=br[i],e=t.length;for(let t=1;t<e;t++)a.push(w-h+t,h-t);return h-=e-1,t}if(s){let t=Er.get(s);t||(t=s.normalize("NFKC"),Er.set(s,t));const e=t.length;for(let t=1;t<e;t++)a.push(w-h+t,h-t);return h-=e-1,t}if(r)return u=!0,w+c===n[o]?.[1]?++o:(a.push(w-1-h+1,h-1),h-=1,d+=1),a.push(w-h+1,h),d+=1,c+=1,r.charAt(0);if(p){const t=p.endsWith("\n"),e=t?p.length-2:p.length;u=!0;let i=e;w+c===n[o]?.[1]&&(i-=n[o][0],++o);for(let t=1;t<=i;t++)a.push(w-1-h+t,h-t);return h-=i,d+=i,t?(w+=e-1,a.push(w-h+1,1+h),h+=1,d+=1,c+=1,p.slice(0,e)):p}if(g)return d+=1,c+=1,g.replace("\n","");if(f){const t=f.length-2;return a.push(w-h+t,1+h),h+=1,d+=1,c+=1,f.slice(0,-2)}if(m){const t=m.length-1;return a.push(w-h+t,h),d+=1,c+=1,m.slice(0,-1)}if(b)return a.push(w-h+1,h-1),h-=1,d+=1,c+=1," ";if(w+c===e[l]?.[1]){const t=e[l][0]-1;++l;for(let e=1;e<=t;e++)a.push(w-(h-e),h-e);h-=t,d+=t}return v})),a.push(r.length,h);const p=new Uint32Array(a.length>>1),g=new Int32Array(a.length>>1);for(let t=0,e=a.length;t<e;t+=2)p[t>>1]=a[t],g[t>>1]=a[t+1];return[r,[p,g],u]}class kr{#Io=null;#Lo=!0;#Do=0;constructor({linkService:t,eventBus:e,updateMatchesCountOnProgress:i=!0}){this._linkService=t,this._eventBus=e,this.#Lo=i,this.onIsPageVisible=null,this.#Ro(),e._on("find",this.#No.bind(this)),e._on("findbarclose",this.#Fo.bind(this))}get highlightMatches(){return this._highlightMatches}get pageMatches(){return this._pageMatches}get pageMatchesLength(){return this._pageMatchesLength}get selected(){return this._selected}get state(){return this.#Io}setDocument(t){this._pdfDocument&&this.#Ro(),t&&(this._pdfDocument=t,this._firstPageCapability.resolve())}#No(t){if(!t)return;const e=this._pdfDocument,{type:i}=t;(null===this.#Io||this.#Oo(t))&&(this._dirtyMatch=!0),this.#Io=t,"highlightallchange"!==i&&this.#Bo(mr.PENDING),this._firstPageCapability.promise.then((()=>{if(!this._pdfDocument||e&&this._pdfDocument!==e)return;this.#Bn();const t=!this._highlightMatches,s=!!this._findTimeout;this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),i?this._dirtyMatch?this.#jo():"again"===i?(this.#jo(),t&&this.#Io.highlightAll&&this.#Vo()):"highlightallchange"===i?(s?this.#jo():this._highlightMatches=!0,this.#Vo()):this.#jo():this._findTimeout=setTimeout((()=>{this.#jo(),this._findTimeout=null}),250)}))}scrollMatchIntoView({element:t=null,selectedLeft:e=0,pageIndex:i=-1,matchIndex:s=-1}){if(!this._scrollMatches||!t)return;if(-1===s||s!==this._selected.matchIdx)return;if(-1===i||i!==this._selected.pageIdx)return;this._scrollMatches=!1;Xn(t,{top:-50,left:e+-400},!0)}#Ro(){this._highlightMatches=!1,this._scrollMatches=!1,this._pdfDocument=null,this._pageMatches=[],this._pageMatchesLength=[],this.#Do=0,this.#Io=null,this._selected={pageIdx:-1,matchIdx:-1},this._offset={pageIdx:null,matchIdx:null,wrapped:!1},this._extractTextPromises=[],this._pageContents=[],this._pageDiffs=[],this._hasDiacritics=[],this._matchesCountTotal=0,this._pagesToSearch=null,this._pendingFindMatches=new Set,this._resumePageIdx=null,this._dirtyMatch=!1,clearTimeout(this._findTimeout),this._findTimeout=null,this._firstPageCapability=Promise.withResolvers()}get#Ho(){const{query:t}=this.#Io;return"string"==typeof t?(t!==this._rawQuery&&(this._rawQuery=t,[this._normalizedQuery]=Tr(t)),this._normalizedQuery):(t||[]).filter((t=>!!t)).map((t=>Tr(t)[0]))}#Oo(t){const e=t.query,i=this.#Io.query,s=typeof e;if(s!==typeof i)return!0;if("string"===s){if(e!==i)return!0}else if(JSON.stringify(e)!==JSON.stringify(i))return!0;switch(t.type){case"again":const t=this._selected.pageIdx+1,e=this._linkService;return t>=1&&t<=e.pagesCount&&t!==e.page&&!(this.onIsPageVisible?.(t)??1);case"highlightallchange":return!1}return!0}#zo(t,e,i){let s=t.slice(0,e).match(_r);if(s){const i=t.charCodeAt(e),n=s[1].charCodeAt(0);if(gr(i)===gr(n))return!1}if(s=t.slice(e+i).match(xr),s){const n=t.charCodeAt(e+i-1),r=s[1].charCodeAt(0);if(gr(n)===gr(r))return!1}return!0}#Uo(t,e){const{matchDiacritics:i}=this.#Io;let s=!1;const n="[ ]*";return(t=t.replaceAll(Ar,((t,n,r,a,o,l)=>n?`[ ]*\\${n}[ ]*`:r?`[ ]*${r}[ ]*`:a?"[ ]+":i?o||l:o?vr.has(o.charCodeAt(0))?o:"":e?(s=!0,`${l}\\p{M}*`):l))).endsWith(n)&&(t=t.slice(0,t.length-4)),i&&e&&(wr||=String.fromCharCode(...vr),s=!0,t=`${t}(?=[${wr}]|[^\\p{M}]|$)`),[s,t]}#$o(t){const e=this.#Ho;if(0===e.length)return;const i=this._pageContents[t],s=this.match(e,i,t),n=this._pageMatches[t]=[],r=this._pageMatchesLength[t]=[],a=this._pageDiffs[t];s?.forEach((({index:t,length:e})=>{const[i,s]=function(t,e,i){if(!t)return[e,i];const[s,n]=t,r=e,a=e+i-1;let o=Jn(s,(t=>t>=r));s[o]>r&&--o;let l=Jn(s,(t=>t>=a),o);s[l]>a&&--l;const h=r+n[o];return[h,a+n[l]+1-h]}(a,t,e);s&&(n.push(i),r.push(s))})),this.#Io.highlightAll&&this.#Wo(t),this._resumePageIdx===t&&(this._resumePageIdx=null,this.#Go());const o=n.length;this._matchesCountTotal+=o,this.#Lo?o>0&&this.#qo():++this.#Do===this._linkService.pagesCount&&this.#qo()}match(t,e,i){const s=this._hasDiacritics[i];let n=!1;if("string"==typeof t?[n,t]=this.#Uo(t,s):t=t.sort().reverse().map((t=>{const[e,i]=this.#Uo(t,s);return n||=e,`(${i})`})).join("|"),!t)return;const{caseSensitive:r,entireWord:a}=this.#Io;t=new RegExp(t,`g${n?"u":""}${r?"":"i"}`);const o=[];let l;for(;null!==(l=t.exec(e));)a&&!this.#zo(e,l.index,l[0].length)||o.push({index:l.index,length:l[0].length});return o}#Bn(){if(this._extractTextPromises.length>0)return;let t=Promise.resolve();const e={disableNormalization:!0};for(let i=0,s=this._linkService.pagesCount;i<s;i++){const{promise:s,resolve:n}=Promise.withResolvers();this._extractTextPromises[i]=s,t=t.then((()=>this._pdfDocument.getPage(i+1).then((t=>t.getTextContent(e))).then((t=>{const e=[];for(const i of t.items)e.push(i.str),i.hasEOL&&e.push("\n");[this._pageContents[i],this._pageDiffs[i],this._hasDiacritics[i]]=Tr(e.join("")),n()}),(t=>{console.error(`Unable to get text content for page ${i+1}`,t),this._pageContents[i]="",this._pageDiffs[i]=null,this._hasDiacritics[i]=!1,n()}))))}}#Wo(t){this._scrollMatches&&this._selected.pageIdx===t&&(this._linkService.page=t+1),this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:t})}#Vo(){this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:-1})}#jo(){const t=this.#Io.findPrevious,e=this._linkService.page-1,i=this._linkService.pagesCount;if(this._highlightMatches=!0,this._dirtyMatch){this._dirtyMatch=!1,this._selected.pageIdx=this._selected.matchIdx=-1,this._offset.pageIdx=e,this._offset.matchIdx=null,this._offset.wrapped=!1,this._resumePageIdx=null,this._pageMatches.length=0,this._pageMatchesLength.length=0,this.#Do=0,this._matchesCountTotal=0,this.#Vo();for(let t=0;t<i;t++)this._pendingFindMatches.has(t)||(this._pendingFindMatches.add(t),this._extractTextPromises[t].then((()=>{this._pendingFindMatches.delete(t),this.#$o(t)})))}if(0===this.#Ho.length)return void this.#Bo(mr.FOUND);if(this._resumePageIdx)return;const s=this._offset;if(this._pagesToSearch=i,null!==s.matchIdx){const e=this._pageMatches[s.pageIdx].length;if(!t&&s.matchIdx+1<e||t&&s.matchIdx>0)return s.matchIdx=t?s.matchIdx-1:s.matchIdx+1,void this.#Xo(!0);this.#Ko(t)}this.#Go()}#Yo(t){const e=this._offset,i=t.length,s=this.#Io.findPrevious;return i?(e.matchIdx=s?i-1:0,this.#Xo(!0),!0):(this.#Ko(s),!!(e.wrapped&&(e.matchIdx=null,this._pagesToSearch<0))&&(this.#Xo(!1),!0))}#Go(){null!==this._resumePageIdx&&console.error("There can only be one pending page.");let t=null;do{const e=this._offset.pageIdx;if(t=this._pageMatches[e],!t){this._resumePageIdx=e;break}}while(!this.#Yo(t))}#Ko(t){const e=this._offset,i=this._linkService.pagesCount;e.pageIdx=t?e.pageIdx-1:e.pageIdx+1,e.matchIdx=null,this._pagesToSearch--,(e.pageIdx>=i||e.pageIdx<0)&&(e.pageIdx=t?i-1:0,e.wrapped=!0)}#Xo(t=!1){let e=mr.NOT_FOUND;const i=this._offset.wrapped;if(this._offset.wrapped=!1,t){const t=this._selected.pageIdx;this._selected.pageIdx=this._offset.pageIdx,this._selected.matchIdx=this._offset.matchIdx,e=i?mr.WRAPPED:mr.FOUND,-1!==t&&t!==this._selected.pageIdx&&this.#Wo(t)}this.#Bo(e,this.#Io.findPrevious),-1!==this._selected.pageIdx&&(this._scrollMatches=!0,this.#Wo(this._selected.pageIdx))}#Fo(t){const e=this._pdfDocument;this._firstPageCapability.promise.then((()=>{!this._pdfDocument||e&&this._pdfDocument!==e||(this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),this._resumePageIdx&&(this._resumePageIdx=null,this._dirtyMatch=!0),this.#Bo(mr.FOUND),this._highlightMatches=!1,this.#Vo())}))}#Qo(){const{pageIdx:t,matchIdx:e}=this._selected;let i=0,s=this._matchesCountTotal;if(-1!==e){for(let e=0;e<t;e++)i+=this._pageMatches[e]?.length||0;i+=e+1}return(i<1||i>s)&&(i=s=0),{current:i,total:s}}#qo(){this._eventBus.dispatch("updatefindmatchescount",{source:this,matchesCount:this.#Qo()})}#Bo(t,e=!1){(this.#Lo||this.#Do===this._linkService.pagesCount&&t!==mr.PENDING)&&this._eventBus.dispatch("updatefindcontrolstate",{source:this,state:t,previous:e,entireWord:this.#Io?.entireWord??null,matchesCount:this.#Qo(),rawQuery:this.#Io?.query??null})}}const Ir={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};class Lr{externalLinkEnabled=!0;constructor({eventBus:t,externalLinkTarget:e=null,externalLinkRel:i=null,ignoreDestinationZoom:s=!1}={}){this.eventBus=t,this.externalLinkTarget=e,this.externalLinkRel=i,this._ignoreDestinationZoom=s,this.baseUrl=null,this.pdfDocument=null,this.pdfViewer=null,this.pdfHistory=null}setDocument(t,e=null){this.baseUrl=e,this.pdfDocument=t}setViewer(t){this.pdfViewer=t}setHistory(t){this.pdfHistory=t}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return this.pdfDocument?this.pdfViewer.currentPageNumber:1}set page(t){this.pdfDocument&&(this.pdfViewer.currentPageNumber=t)}get rotation(){return this.pdfDocument?this.pdfViewer.pagesRotation:0}set rotation(t){this.pdfDocument&&(this.pdfViewer.pagesRotation=t)}get isInPresentationMode(){return!!this.pdfDocument&&this.pdfViewer.isInPresentationMode}async goToDestination(t){if(!this.pdfDocument)return;let e,i,s;if("string"==typeof t?(e=t,i=await this.pdfDocument.getDestination(t)):(e=null,i=await t),!Array.isArray(i))return void console.error(`goToDestination: "${i}" is not a valid destination array, for dest="${t}".`);const[n]=i;if(n&&"object"==typeof n){if(s=this.pdfDocument.cachedPageNumber(n),!s)try{s=await this.pdfDocument.getPageIndex(n)+1}catch{return void console.error(`goToDestination: "${n}" is not a valid page reference, for dest="${t}".`)}}else Number.isInteger(n)&&(s=n+1);!s||s<1||s>this.pagesCount?console.error(`goToDestination: "${s}" is not a valid page number, for dest="${t}".`):(this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.push({namedDest:e,explicitDest:i,pageNumber:s})),this.pdfViewer.scrollPageIntoView({pageNumber:s,destArray:i,ignoreDestinationZoom:this._ignoreDestinationZoom}))}goToPage(t){if(!this.pdfDocument)return;const e="string"==typeof t&&this.pdfViewer.pageLabelToPageNumber(t)||0|t;Number.isInteger(e)&&e>0&&e<=this.pagesCount?(this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.pushPage(e)),this.pdfViewer.scrollPageIntoView({pageNumber:e})):console.error(`PDFLinkService.goToPage: "${t}" is not a valid page.`)}addLinkAttributes(t,e,i=!1){if(!e||"string"!=typeof e)throw new Error('A valid "url" parameter must provided.');const s=i?Ir.BLANK:this.externalLinkTarget,n=this.externalLinkRel;this.externalLinkEnabled?t.href=t.title=e:(t.href="",t.title=`Disabled: ${e}`,t.onclick=()=>!1);let r="";switch(s){case Ir.NONE:break;case Ir.SELF:r="_self";break;case Ir.BLANK:r="_blank";break;case Ir.PARENT:r="_parent";break;case Ir.TOP:r="_top"}t.target=r,t.rel="string"==typeof n?n:"noopener noreferrer nofollow"}getDestinationHash(t){if("string"==typeof t){if(t.length>0)return this.getAnchorUrl("#"+escape(t))}else if(Array.isArray(t)){const e=JSON.stringify(t);if(e.length>0)return this.getAnchorUrl("#"+escape(e))}return this.getAnchorUrl("")}getAnchorUrl(t){return this.baseUrl?this.baseUrl+t:t}setHash(t){if(!this.pdfDocument)return;let e,i;if(t.includes("=")){const s=Kn(t);if(s.has("search")){const t=s.get("search").replaceAll('"',""),e="true"===s.get("phrase");this.eventBus.dispatch("findfromurlhash",{source:this,query:e?t:t.match(/\S+/g)})}if(s.has("page")&&(e=0|s.get("page")||1),s.has("zoom")){const t=s.get("zoom").split(","),e=t[0],n=parseFloat(e);e.includes("Fit")?"Fit"===e||"FitB"===e?i=[null,{name:e}]:"FitH"===e||"FitBH"===e||"FitV"===e||"FitBV"===e?i=[null,{name:e},t.length>1?0|t[1]:null]:"FitR"===e?5!==t.length?console.error('PDFLinkService.setHash: Not enough parameters for "FitR".'):i=[null,{name:e},0|t[1],0|t[2],0|t[3],0|t[4]]:console.error(`PDFLinkService.setHash: "${e}" is not a valid zoom value.`):i=[null,{name:"XYZ"},t.length>1?0|t[1]:null,t.length>2?0|t[2]:null,n?n/100:e]}return i?this.pdfViewer.scrollPageIntoView({pageNumber:e||this.page,destArray:i,allowNegativeOffset:!0}):e&&(this.page=e),s.has("pagemode")&&this.eventBus.dispatch("pagemode",{source:this,mode:s.get("pagemode")}),void(s.has("nameddest")&&this.goToDestination(s.get("nameddest")))}i=unescape(t);try{i=JSON.parse(i),Array.isArray(i)||(i=i.toString())}catch{}"string"==typeof i||Lr.#Jo(i)?this.goToDestination(i):console.error(`PDFLinkService.setHash: "${unescape(t)}" is not a valid destination.`)}executeNamedAction(t){if(this.pdfDocument){switch(t){case"GoBack":this.pdfHistory?.back();break;case"GoForward":this.pdfHistory?.forward();break;case"NextPage":this.pdfViewer.nextPage();break;case"PrevPage":this.pdfViewer.previousPage();break;case"LastPage":this.page=this.pagesCount;break;case"FirstPage":this.page=1}this.eventBus.dispatch("namedaction",{source:this,action:t})}}async executeSetOCGState(t){if(!this.pdfDocument)return;const e=this.pdfDocument,i=await this.pdfViewer.optionalContentConfigPromise;e===this.pdfDocument&&(i.setOCGState(t),this.pdfViewer.optionalContentConfigPromise=Promise.resolve(i))}static#Jo(t){if(!Array.isArray(t)||t.length<2)return!1;const[e,i,...s]=t;if(!("object"==typeof e&&Number.isInteger(e?.num)&&Number.isInteger(e?.gen)||Number.isInteger(e)))return!1;if("object"!=typeof i||"string"!=typeof i?.name)return!1;const n=s.length;let r=!0;switch(i.name){case"XYZ":if(n<2||n>3)return!1;break;case"Fit":case"FitB":return 0===n;case"FitH":case"FitBH":case"FitV":case"FitBV":if(n>1)return!1;break;case"FitR":if(4!==n)return!1;r=!1;break;default:return!1}for(const t of s)if(!("number"==typeof t||r&&null===t))return!1;return!0}}class Dr extends Lr{setDocument(t,e=null){}}const{AbortException:Rr,AnnotationEditorLayer:Nr,AnnotationEditorParamsType:Fr,AnnotationEditorType:Or,AnnotationEditorUIManager:Br,AnnotationLayer:jr,AnnotationMode:Vr,build:Hr,ColorPicker:zr,createValidAbsoluteUrl:Ur,DOMSVGFactory:$r,DrawLayer:Wr,FeatureTest:Gr,fetchData:qr,getDocument:Xr,getFilenameFromUrl:Kr,getPdfFilenameFromUrl:Yr,getXfaPageViewport:Qr,GlobalWorkerOptions:Jr,ImageKind:Zr,InvalidPDFException:ta,isDataScheme:ea,isPdfFile:ia,MissingPDFException:sa,noContextMenu:na,normalizeUnicode:ra,OPS:aa,OutputScale:oa,PasswordResponses:la,PDFDataRangeTransport:ha,PDFDateString:da,PDFWorker:ca,PermissionFlag:ua,PixelsPerInch:pa,RenderingCancelledException:ga,setLayerDimensions:fa,shadow:ma,stopEvent:ba,TextLayer:va,TouchManager:wa,UnexpectedResponseException:ya,Util:Aa,VerbosityLevel:_a,version:xa,XfaLayer:Sa}=globalThis.pdfjsLib;class Ca{#Zo=null;#tl=null;constructor({pdfPage:t,linkService:e,downloadManager:i,annotationStorage:s=null,imageResourcesPath:n="",renderForms:r=!0,enableScripting:a=!1,hasJSActionsPromise:o=null,fieldObjectsPromise:l=null,annotationCanvasMap:h=null,accessibilityManager:d=null,annotationEditorUIManager:c=null,onAppend:u=null}){this.pdfPage=t,this.linkService=e,this.downloadManager=i,this.imageResourcesPath=n,this.renderForms=r,this.annotationStorage=s,this.enableScripting=a,this._hasJSActionsPromise=o||Promise.resolve(!1),this._fieldObjectsPromise=l||Promise.resolve(null),this._annotationCanvasMap=h,this._accessibilityManager=d,this._annotationEditorUIManager=c,this.#Zo=u,this.annotationLayer=null,this.div=null,this._cancelled=!1,this._eventBus=e.eventBus}async render(t,e,i="display"){if(this.div){if(this._cancelled||!this.annotationLayer)return;return void this.annotationLayer.update({viewport:t.clone({dontFlip:!0})})}const[s,n,r]=await Promise.all([this.pdfPage.getAnnotations({intent:i}),this._hasJSActionsPromise,this._fieldObjectsPromise]);if(this._cancelled)return;const a=this.div=document.createElement("div");a.className="annotationLayer",this.#Zo?.(a),0!==s.length?(this.annotationLayer=new jr({div:a,accessibilityManager:this._accessibilityManager,annotationCanvasMap:this._annotationCanvasMap,annotationEditorUIManager:this._annotationEditorUIManager,page:this.pdfPage,viewport:t.clone({dontFlip:!0}),structTreeLayer:e?.structTreeLayer||null}),await this.annotationLayer.render({annotations:s,imageResourcesPath:this.imageResourcesPath,renderForms:this.renderForms,linkService:this.linkService,downloadManager:this.downloadManager,annotationStorage:this.annotationStorage,enableScripting:this.enableScripting,hasJSActions:n,fieldObjects:r}),this.linkService.isInPresentationMode&&this.#el(zn),this.#tl||(this.#tl=new AbortController,this._eventBus?._on("presentationmodechanged",(t=>{this.#el(t.state)}),{signal:this.#tl.signal}))):this.hide()}cancel(){this._cancelled=!0,this.#tl?.abort(),this.#tl=null}hide(){this.div&&(this.div.hidden=!0)}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}#el(t){if(!this.div)return;let e=!1;switch(t){case zn:e=!0;break;case Vn:break;default:return}for(const t of this.div.childNodes)t.hasAttribute("data-internal-link")||(t.inert=e)}}function Ea(t,e){const i=document.createElement("a");if(!i.click)throw new Error('DownloadManager: "a.click()" is not supported.');i.href=t,i.target="_parent","download"in i&&(i.download=e),(document.body||document.documentElement).append(i),i.click(),i.remove()}class Pa{#il=new WeakMap;downloadData(t,e,i){Ea(URL.createObjectURL(new Blob([t],{type:i})),e)}openOrDownloadData(t,e,i=null){const s=ia(e)?"application/pdf":"";return this.downloadData(t,e,s),!1}download(t,e,i){let s;if(t)s=URL.createObjectURL(new Blob([t],{type:"application/pdf"}));else{if(!Ur(e,"http://example.com"))return void console.error(`download - not a valid URL: ${e}`);s=e+"#pdfjs.action=download"}Ea(s,i)}}const Ma="event",Ta="timeout";class ka{#As=Object.create(null);on(t,e,i=null){this._on(t,e,{external:!0,once:i?.once,signal:i?.signal})}off(t,e,i=null){this._off(t,e)}dispatch(t,e){const i=this.#As[t];if(!i||0===i.length)return;let s;for(const{listener:n,external:r,once:a}of i.slice(0))a&&this._off(t,n),r?(s||=[]).push(n):n(e);if(s){for(const t of s)t(e);s=null}}_on(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){const{signal:n}=i;if(n.aborted)return void console.error("Cannot use an `aborted` signal.");const r=()=>this._off(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}(this.#As[t]||=[]).push({listener:e,external:!0===i?.external,once:!0===i?.once,rmAbort:s})}_off(t,e,i=null){const s=this.#As[t];if(s)for(let t=0,i=s.length;t<i;t++){const i=s[t];if(i.listener===e)return i.rmAbort?.(),void s.splice(t,1)}}}class Ia{constructor(t){this.value=t}valueOf(){return this.value}}class La extends Ia{constructor(t="???"){super(t)}toString(t){return`{${this.value}}`}}class Da extends Ia{constructor(t,e={}){super(t),this.opts=e}toString(t){try{return t.memoizeIntlObject(Intl.NumberFormat,this.opts).format(this.value)}catch(e){return t.reportError(e),this.value.toString(10)}}}class Ra extends Ia{constructor(t,e={}){super(t),this.opts=e}toString(t){try{return t.memoizeIntlObject(Intl.DateTimeFormat,this.opts).format(this.value)}catch(e){return t.reportError(e),new Date(this.value).toISOString()}}}function Na(t,e,i){if(i===e)return!0;if(i instanceof Da&&e instanceof Da&&i.value===e.value)return!0;if(e instanceof Da&&"string"==typeof i){if(i===t.memoizeIntlObject(Intl.PluralRules,e.opts).select(e.value))return!0}return!1}function Fa(t,e,i){return e[i]?Va(t,e[i].value):(t.reportError(new RangeError("No default")),new La)}function Oa(t,e){const i=[],s=Object.create(null);for(const n of e)"narg"===n.type?s[n.name]=Ba(t,n.value):i.push(Ba(t,n));return{positional:i,named:s}}function Ba(t,e){switch(e.type){case"str":return e.value;case"num":return new Da(e.value,{minimumFractionDigits:e.precision});case"var":return function(t,{name:e}){let i;if(t.params){if(!Object.prototype.hasOwnProperty.call(t.params,e))return new La(`$${e}`);i=t.params[e]}else{if(!t.args||!Object.prototype.hasOwnProperty.call(t.args,e))return t.reportError(new ReferenceError(`Unknown variable: $${e}`)),new La(`$${e}`);i=t.args[e]}if(i instanceof Ia)return i;switch(typeof i){case"string":return i;case"number":return new Da(i);case"object":if(i instanceof Date)return new Ra(i.getTime());default:return t.reportError(new TypeError(`Variable type not supported: $${e}, ${typeof i}`)),new La(`$${e}`)}}(t,e);case"mesg":return function(t,{name:e,attr:i}){const s=t.bundle._messages.get(e);if(!s)return t.reportError(new ReferenceError(`Unknown message: ${e}`)),new La(e);if(i){const n=s.attributes[i];return n?Va(t,n):(t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new La(`${e}.${i}`))}if(s.value)return Va(t,s.value);return t.reportError(new ReferenceError(`No value: ${e}`)),new La(e)}(t,e);case"term":return function(t,{name:e,attr:i,args:s}){const n=`-${e}`,r=t.bundle._terms.get(n);if(!r)return t.reportError(new ReferenceError(`Unknown term: ${n}`)),new La(n);if(i){const e=r.attributes[i];if(e){t.params=Oa(t,s).named;const i=Va(t,e);return t.params=null,i}return t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new La(`${n}.${i}`)}t.params=Oa(t,s).named;const a=Va(t,r.value);return t.params=null,a}(t,e);case"func":return function(t,{name:e,args:i}){let s=t.bundle._functions[e];if(!s)return t.reportError(new ReferenceError(`Unknown function: ${e}()`)),new La(`${e}()`);if("function"!=typeof s)return t.reportError(new TypeError(`Function ${e}() is not callable`)),new La(`${e}()`);try{let e=Oa(t,i);return s(e.positional,e.named)}catch(i){return t.reportError(i),new La(`${e}()`)}}(t,e);case"select":return function(t,{selector:e,variants:i,star:s}){let n=Ba(t,e);if(n instanceof La)return Fa(t,i,s);for(const e of i){if(Na(t,n,Ba(t,e.key)))return Va(t,e.value)}return Fa(t,i,s)}(t,e);default:return new La}}function ja(t,e){if(t.dirty.has(e))return t.reportError(new RangeError("Cyclic reference")),new La;t.dirty.add(e);const i=[],s=t.bundle._useIsolating&&e.length>1;for(const n of e)if("string"!=typeof n){if(t.placeables++,t.placeables>100)throw t.dirty.delete(e),new RangeError(`Too many placeables expanded: ${t.placeables}, max allowed is 100`);s&&i.push("⁨"),i.push(Ba(t,n).toString(t)),s&&i.push("⁩")}else i.push(t.bundle._transform(n));return t.dirty.delete(e),i.join("")}function Va(t,e){return"string"==typeof e?t.bundle._transform(e):ja(t,e)}class Ha{constructor(t,e,i){this.dirty=new WeakSet,this.params=null,this.placeables=0,this.bundle=t,this.errors=e,this.args=i}reportError(t){if(!(this.errors&&t instanceof Error))throw t;this.errors.push(t)}memoizeIntlObject(t,e){let i=this.bundle._intls.get(t);i||(i={},this.bundle._intls.set(t,i));let s=JSON.stringify(e);return i[s]||(i[s]=new t(this.bundle.locales,e)),i[s]}}function za(t,e){const i=Object.create(null);for(const[s,n]of Object.entries(t))e.includes(s)&&(i[s]=n.valueOf());return i}const Ua=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function $a(t,e){let i=t[0];if(i instanceof La)return new La(`NUMBER(${i.valueOf()})`);if(i instanceof Da)return new Da(i.valueOf(),{...i.opts,...za(e,Ua)});if(i instanceof Ra)return new Da(i.valueOf(),{...za(e,Ua)});throw new TypeError("Invalid argument to NUMBER")}const Wa=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function Ga(t,e){let i=t[0];if(i instanceof La)return new La(`DATETIME(${i.valueOf()})`);if(i instanceof Ra)return new Ra(i.valueOf(),{...i.opts,...za(e,Wa)});if(i instanceof Da)return new Ra(i.valueOf(),{...za(e,Wa)});throw new TypeError("Invalid argument to DATETIME")}const qa=new Map;class Xa{constructor(t,{functions:e,useIsolating:i=!0,transform:s=t=>t}={}){this._terms=new Map,this._messages=new Map,this.locales=Array.isArray(t)?t:[t],this._functions={NUMBER:$a,DATETIME:Ga,...e},this._useIsolating=i,this._transform=s,this._intls=function(t){const e=Array.isArray(t)?t.join(" "):t;let i=qa.get(e);return void 0===i&&(i=new Map,qa.set(e,i)),i}(t)}hasMessage(t){return this._messages.has(t)}getMessage(t){return this._messages.get(t)}addResource(t,{allowOverrides:e=!1}={}){const i=[];for(let s=0;s<t.body.length;s++){let n=t.body[s];if(n.id.startsWith("-")){if(!1===e&&this._terms.has(n.id)){i.push(new Error(`Attempt to override an existing term: "${n.id}"`));continue}this._terms.set(n.id,n)}else{if(!1===e&&this._messages.has(n.id)){i.push(new Error(`Attempt to override an existing message: "${n.id}"`));continue}this._messages.set(n.id,n)}}return i}formatPattern(t,e=null,i=null){if("string"==typeof t)return this._transform(t);let s=new Ha(this,i,e);try{return ja(s,t).toString(s)}catch(t){if(s.errors&&t instanceof Error)return s.errors.push(t),(new La).toString(s);throw t}}}const Ka=/^(-?[a-zA-Z][\w-]*) *= */gm,Ya=/\.([a-zA-Z][\w-]*) *= */y,Qa=/\*?\[/y,Ja=/(-?[0-9]+(?:\.([0-9]+))?)/y,Za=/([a-zA-Z][\w-]*)/y,to=/([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y,eo=/^[A-Z][A-Z0-9_-]*$/,io=/([^{}\n\r]+)/y,so=/([^\\"\n\r]*)/y,no=/\\([\\"])/y,ro=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y,ao=/^\n+/,oo=/ +$/,lo=/ *\r?\n/g,ho=/( *)$/,co=/{\s*/y,uo=/\s*}/y,po=/\[\s*/y,go=/\s*] */y,fo=/\s*\(\s*/y,mo=/\s*->\s*/y,bo=/\s*:\s*/y,vo=/\s*,?\s*/y,wo=/\s+/y;class yo{constructor(t){this.body=[],Ka.lastIndex=0;let e=0;for(;;){let i=Ka.exec(t);if(null===i)break;e=Ka.lastIndex;try{this.body.push(o(i[1]))}catch(t){if(t instanceof SyntaxError)continue;throw t}}function i(i){return i.lastIndex=e,i.test(t)}function s(i,s){if(t[e]===i)return e++,!0;if(s)throw new s(`Expected ${i}`);return!1}function n(t,s){if(i(t))return e=t.lastIndex,!0;if(s)throw new s(`Expected ${t.toString()}`);return!1}function r(i){i.lastIndex=e;let s=i.exec(t);if(null===s)throw new SyntaxError(`Expected ${i.toString()}`);return e=i.lastIndex,s}function a(t){return r(t)[1]}function o(t){let e=l(),s=function(){let t=Object.create(null);for(;i(Ya);){let e=a(Ya),i=l();if(null===i)throw new SyntaxError("Expected attribute value");t[e]=i}return t}();if(null===e&&0===Object.keys(s).length)throw new SyntaxError("Expected message value or attributes");return{id:t,value:e,attributes:s}}function l(){let s;if(i(io)&&(s=a(io)),"{"===t[e]||"}"===t[e])return h(s?[s]:[],1/0);let n=b();return n?s?h([s,n],n.length):(n.value=v(n.value,ao),h([n],n.length)):s?v(s,oo):null}function h(s=[],n){for(;;){if(i(io)){s.push(a(io));continue}if("{"===t[e]){s.push(d());continue}if("}"===t[e])throw new SyntaxError("Unbalanced closing brace");let r=b();if(!r)break;s.push(r),n=Math.min(n,r.length)}let r=s.length-1,o=s[r];"string"==typeof o&&(s[r]=v(o,oo));let l=[];for(let t of s)t instanceof Ao&&(t=t.value.slice(0,t.value.length-n)),t&&l.push(t);return l}function d(){n(co,SyntaxError);let t=c();if(n(uo))return t;if(n(mo)){let e=function(){let t,e=[],n=0;for(;i(Qa);){s("*")&&(t=n);let i=p(),r=l();if(null===r)throw new SyntaxError("Expected variant value");e[n++]={key:i,value:r}}if(0===n)return null;if(void 0===t)throw new SyntaxError("Expected default variant");return{variants:e,star:t}}();return n(uo,SyntaxError),{type:"select",selector:t,...e}}throw new SyntaxError("Unclosed placeable")}function c(){if("{"===t[e])return d();if(i(to)){let[,i,s,a=null]=r(to);if("$"===i)return{type:"var",name:s};if(n(fo)){let r=function(){let i=[];for(;;){switch(t[e]){case")":return e++,i;case void 0:throw new SyntaxError("Unclosed argument list")}i.push(u()),n(vo)}}();if("-"===i)return{type:"term",name:s,attr:a,args:r};if(eo.test(s))return{type:"func",name:s,args:r};throw new SyntaxError("Function names must be all upper-case")}return"-"===i?{type:"term",name:s,attr:a,args:[]}:{type:"mesg",name:s,attr:a}}return g()}function u(){let t=c();return"mesg"!==t.type?t:n(bo)?{type:"narg",name:t.name,value:g()}:t}function p(){let t;return n(po,SyntaxError),t=i(Ja)?f():{type:"str",value:a(Za)},n(go,SyntaxError),t}function g(){if(i(Ja))return f();if('"'===t[e])return function(){s('"',SyntaxError);let i="";for(;;){if(i+=a(so),"\\"!==t[e]){if(s('"'))return{type:"str",value:i};throw new SyntaxError("Unclosed string literal")}i+=m()}}();throw new SyntaxError("Invalid expression")}function f(){let[,t,e=""]=r(Ja),i=e.length;return{type:"num",value:parseFloat(t),precision:i}}function m(){if(i(no))return a(no);if(i(ro)){let[,t,e]=r(ro),i=parseInt(t||e,16);return i<=55295||57344<=i?String.fromCodePoint(i):"�"}throw new SyntaxError("Unknown escape sequence")}function b(){let i=e;switch(n(wo),t[e]){case".":case"[":case"*":case"}":case void 0:return!1;case"{":return w(t.slice(i,e))}return" "===t[e-1]&&w(t.slice(i,e))}function v(t,e){return t.replace(e,"")}function w(t){let e=t.replace(lo,"\n"),i=ho.exec(t)[1].length;return new Ao(e,i)}}}class Ao{constructor(t,e){this.value=t,this.length=e}}const _o=/<|&#?\w+;/,xo={"http://www.w3.org/1999/xhtml":["em","strong","small","s","cite","q","dfn","abbr","data","time","code","var","samp","kbd","sub","sup","i","b","u","mark","bdi","bdo","span","br","wbr"]},So={"http://www.w3.org/1999/xhtml":{global:["title","aria-label","aria-valuetext"],a:["download"],area:["download","alt"],input:["alt","placeholder"],menuitem:["label"],menu:["label"],optgroup:["label"],option:["label"],track:["label"],img:["alt"],textarea:["placeholder"],th:["abbr"]},"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul":{global:["accesskey","aria-label","aria-valuetext","label","title","tooltiptext"],description:["value"],key:["key","keycode"],label:["value"],textbox:["placeholder","value"]}};function Co(t,e){const{value:i}=e;if("string"==typeof i)if("title"===t.localName&&"http://www.w3.org/1999/xhtml"===t.namespaceURI)t.textContent=i;else if(_o.test(i)){const e=t.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml","template");e.innerHTML=i,function(t,e){for(const i of t.childNodes)if(i.nodeType!==i.TEXT_NODE)if(i.hasAttribute("data-l10n-name")){const s=Mo(e,i);t.replaceChild(s,i)}else if(Io(i)){const e=To(i);t.replaceChild(e,i)}else console.warn(`An element of forbidden type "${i.localName}" was found in the translation. Only safe text-level elements and elements with data-l10n-name are allowed.`),t.replaceChild(ko(i),i);e.textContent="",e.appendChild(t)}(e.content,t)}else t.textContent=i;Po(e,t)}function Eo(t,e){if(!t)return!1;for(let i of t)if(i.name===e)return!0;return!1}function Po(t,e){const i=e.hasAttribute("data-l10n-attrs")?e.getAttribute("data-l10n-attrs").split(",").map((t=>t.trim())):null;for(const s of Array.from(e.attributes))Lo(s.name,e,i)&&!Eo(t.attributes,s.name)&&e.removeAttribute(s.name);if(t.attributes)for(const s of Array.from(t.attributes))Lo(s.name,e,i)&&e.getAttribute(s.name)!==s.value&&e.setAttribute(s.name,s.value)}function Mo(t,e){const i=e.getAttribute("data-l10n-name"),s=t.querySelector(`[data-l10n-name="${i}"]`);if(!s)return console.warn(`An element named "${i}" wasn't found in the source.`),ko(e);if(s.localName!==e.localName)return console.warn(`An element named "${i}" was found in the translation but its type ${e.localName} didn't match the element found in the source (${s.localName}).`),ko(e);t.removeChild(s);return Do(e,s.cloneNode(!1))}function To(t){const e=t.ownerDocument.createElement(t.localName);return Do(t,e)}function ko(t){return t.ownerDocument.createTextNode(t.textContent)}function Io(t){const e=xo[t.namespaceURI];return e&&e.includes(t.localName)}function Lo(t,e,i=null){if(i&&i.includes(t))return!0;const s=So[e.namespaceURI];if(!s)return!1;const n=t.toLowerCase(),r=e.localName;if(s.global.includes(n))return!0;if(!s[r])return!1;if(s[r].includes(n))return!0;if("http://www.w3.org/1999/xhtml"===e.namespaceURI&&"input"===r&&"value"===n){const t=e.type.toLowerCase();if("submit"===t||"button"===t||"reset"===t)return!0}return!1}function Do(t,e){return e.textContent=t.textContent,Po(t,e),e}class Ro extends Array{static from(t){return t instanceof this?t:new this(t)}}class No extends Ro{constructor(t){if(super(),Symbol.asyncIterator in Object(t))this.iterator=t[Symbol.asyncIterator]();else{if(!(Symbol.iterator in Object(t)))throw new TypeError("Argument must implement the iteration protocol.");this.iterator=t[Symbol.iterator]()}}[Symbol.asyncIterator](){const t=this;let e=0;return{next:async()=>(t.length<=e&&t.push(t.iterator.next()),t[e++])}}async touchNext(t=1){let e=0;for(;e++<t;){const t=this[this.length-1];if(t&&(await t).done)break;this.push(this.iterator.next())}return this[this.length-1]}}class Fo{constructor(t=[],e){this.resourceIds=t,this.generateBundles=e,this.onChange(!0)}addResourceIds(t,e=!1){return this.resourceIds.push(...t),this.onChange(e),this.resourceIds.length}removeResourceIds(t){return this.resourceIds=this.resourceIds.filter((e=>!t.includes(e))),this.onChange(),this.resourceIds.length}async formatWithFallback(t,e){const i=[];let s=!1;for await(const n of this.bundles){s=!0;const r=jo(e,n,t,i);if(0===r.size)break;if("undefined"!=typeof console){const t=n.locales[0],e=Array.from(r).join(", ");console.warn(`[fluent] Missing translations in ${t}: ${e}`)}}return s||"undefined"==typeof console||console.warn(`[fluent] Request for keys failed because no resource bundles got generated.\n keys: ${JSON.stringify(t)}.\n resourceIds: ${JSON.stringify(this.resourceIds)}.`),i}formatMessages(t){return this.formatWithFallback(t,Bo)}formatValues(t){return this.formatWithFallback(t,Oo)}async formatValue(t,e){const[i]=await this.formatValues([{id:t,args:e}]);return i}handleEvent(){this.onChange()}onChange(t=!1){this.bundles=No.from(this.generateBundles(this.resourceIds)),t&&this.bundles.touchNext(2)}}function Oo(t,e,i,s){return i.value?t.formatPattern(i.value,s,e):null}function Bo(t,e,i,s){const n={value:null,attributes:null};i.value&&(n.value=t.formatPattern(i.value,s,e));let r=Object.keys(i.attributes);if(r.length>0){n.attributes=new Array(r.length);for(let[a,o]of r.entries()){let r=t.formatPattern(i.attributes[o],s,e);n.attributes[a]={name:o,value:r}}}return n}function jo(t,e,i,s){const n=[],r=new Set;return i.forEach((({id:i,args:a},o)=>{if(void 0!==s[o])return;let l=e.getMessage(i);if(l){if(n.length=0,s[o]=t(e,n,l,a),n.length>0&&"undefined"!=typeof console){const t=e.locales[0],s=n.join(", ");console.warn(`[fluent][resolver] errors in ${t}/${i}: ${s}.`)}}else r.add(i)})),r}const Vo="data-l10n-id",Ho="data-l10n-args",zo=`[${Vo}]`;class Uo extends Fo{constructor(t,e){super(t,e),this.roots=new Set,this.pendingrAF=null,this.pendingElements=new Set,this.windowElement=null,this.mutationObserver=null,this.observerConfig={attributes:!0,characterData:!1,childList:!0,subtree:!0,attributeFilter:[Vo,Ho]}}onChange(t=!1){super.onChange(t),this.roots&&this.translateRoots()}setAttributes(t,e,i){return t.setAttribute(Vo,e),i?t.setAttribute(Ho,JSON.stringify(i)):t.removeAttribute(Ho),t}getAttributes(t){return{id:t.getAttribute(Vo),args:JSON.parse(t.getAttribute(Ho)||null)}}connectRoot(t){for(const e of this.roots)if(e===t||e.contains(t)||t.contains(e))throw new Error("Cannot add a root that overlaps with existing root.");if(this.windowElement){if(this.windowElement!==t.ownerDocument.defaultView)throw new Error("Cannot connect a root:\n DOMLocalization already has a root from a different window.")}else this.windowElement=t.ownerDocument.defaultView,this.mutationObserver=new this.windowElement.MutationObserver((t=>this.translateMutations(t)));this.roots.add(t),this.mutationObserver.observe(t,this.observerConfig)}disconnectRoot(t){return this.roots.delete(t),this.pauseObserving(),0===this.roots.size?(this.mutationObserver=null,this.windowElement&&this.pendingrAF&&this.windowElement.cancelAnimationFrame(this.pendingrAF),this.windowElement=null,this.pendingrAF=null,this.pendingElements.clear(),!0):(this.resumeObserving(),!1)}translateRoots(){const t=Array.from(this.roots);return Promise.all(t.map((t=>this.translateFragment(t))))}pauseObserving(){this.mutationObserver&&(this.translateMutations(this.mutationObserver.takeRecords()),this.mutationObserver.disconnect())}resumeObserving(){if(this.mutationObserver)for(const t of this.roots)this.mutationObserver.observe(t,this.observerConfig)}translateMutations(t){for(const e of t)switch(e.type){case"attributes":e.target.hasAttribute("data-l10n-id")&&this.pendingElements.add(e.target);break;case"childList":for(const t of e.addedNodes)if(t.nodeType===t.ELEMENT_NODE)if(t.childElementCount)for(const e of this.getTranslatables(t))this.pendingElements.add(e);else t.hasAttribute(Vo)&&this.pendingElements.add(t)}this.pendingElements.size>0&&null===this.pendingrAF&&(this.pendingrAF=this.windowElement.requestAnimationFrame((()=>{this.translateElements(Array.from(this.pendingElements)),this.pendingElements.clear(),this.pendingrAF=null})))}translateFragment(t){return this.translateElements(this.getTranslatables(t))}async translateElements(t){if(!t.length)return;const e=t.map(this.getKeysForElement),i=await this.formatMessages(e);return this.applyTranslations(t,i)}applyTranslations(t,e){this.pauseObserving();for(let i=0;i<t.length;i++)void 0!==e[i]&&Co(t[i],e[i]);this.resumeObserving()}getTranslatables(t){const e=Array.from(t.querySelectorAll(zo));return"function"==typeof t.hasAttribute&&t.hasAttribute(Vo)&&e.push(t),e}getKeysForElement(t){return{id:t.getAttribute(Vo),args:JSON.parse(t.getAttribute(Ho)||null)}}}class $o{#sl;#sn;#Mi;#nl;constructor({lang:t,isRTL:e},i=null){this.#Mi=$o.#rl(t),this.#nl=i,this.#sl=e??$o.#al(this.#Mi)?"rtl":"ltr"}_setL10n(t){this.#nl=t}getLanguage(){return this.#Mi}getDirection(){return this.#sl}async get(t,e=null,i){if(Array.isArray(t)){t=t.map((t=>({id:t})));return(await this.#nl.formatMessages(t)).map((t=>t.value))}const s=await this.#nl.formatMessages([{id:t,args:e}]);return s[0]?.value||i}async translate(t){(this.#sn||=new Set).add(t);try{this.#nl.connectRoot(t),await this.#nl.translateRoots()}catch{}}async translateOnce(t){try{await this.#nl.translateElements([t])}catch(t){console.error("translateOnce:",t)}}async destroy(){if(this.#sn){for(const t of this.#sn)this.#nl.disconnectRoot(t);this.#sn.clear(),this.#sn=null}this.#nl.pauseObserving()}pause(){this.#nl.pauseObserving()}resume(){this.#nl.resumeObserving()}static#rl(t){return{en:"en-us",es:"es-es",fy:"fy-nl",ga:"ga-ie",gu:"gu-in",hi:"hi-in",hy:"hy-am",nb:"nb-no",ne:"ne-np",nn:"nn-no",pa:"pa-in",pt:"pt-pt",sv:"sv-se",zh:"zh-cn"}[t=t?.toLowerCase()||"en-us"]||t}static#al(t){const e=t.split("-",1)[0];return["ar","he","fa","ps","ur"].includes(e)}}function Wo(t,e){const i=new yo(e),s=new Xa(t),n=s.addResource(i);return n.length&&console.error("L10n errors",n),s}class Go extends $o{constructor(t){super({lang:t});const e=t?Go.#ol.bind(Go,"en-us",this.getLanguage()):Go.#ll.bind(Go,this.getLanguage());this._setL10n(new Uo([],e))}static async*#ol(t,e){const{baseURL:i,paths:s}=await this.#hl(),n=[e];if(t!==e){const i=e.split("-",1)[0];i!==e&&n.push(i),n.push(t)}for(const t of n){const e=await this.#dl(t,i,s);e?yield e:"en-us"===t&&(yield this.#cl(t))}}static async#dl(t,e,i){const s=i[t];if(!s)return null;const n=new URL(s,e);return Wo(t,await qr(n,"text"))}static async#hl(){try{const{href:t}=document.querySelector('link[type="application/l10n"]'),e=await qr(t,"json");return{baseURL:t.replace(/[^/]*$/,"")||"./",paths:e}}catch{}return{baseURL:"./",paths:Object.create(null)}}static async*#ll(t){yield this.#cl(t)}static async#cl(t){return Wo(t,'pdfjs-previous-button =\n .title = Previous Page\npdfjs-previous-button-label = Previous\npdfjs-next-button =\n .title = Next Page\npdfjs-next-button-label = Next\npdfjs-page-input =\n .title = Page\npdfjs-of-pages = of { $pagesCount }\npdfjs-page-of-pages = ({ $pageNumber } of { $pagesCount })\npdfjs-zoom-out-button =\n .title = Zoom Out\npdfjs-zoom-out-button-label = Zoom Out\npdfjs-zoom-in-button =\n .title = Zoom In\npdfjs-zoom-in-button-label = Zoom In\npdfjs-zoom-select =\n .title = Zoom\npdfjs-presentation-mode-button =\n .title = Switch to Presentation Mode\npdfjs-presentation-mode-button-label = Presentation Mode\npdfjs-open-file-button =\n .title = Open File\npdfjs-open-file-button-label = Open\npdfjs-print-button =\n .title = Print\npdfjs-print-button-label = Print\npdfjs-save-button =\n .title = Save\npdfjs-save-button-label = Save\npdfjs-download-button =\n .title = Download\npdfjs-download-button-label = Download\npdfjs-bookmark-button =\n .title = Current Page (View URL from Current Page)\npdfjs-bookmark-button-label = Current Page\npdfjs-tools-button =\n .title = Tools\npdfjs-tools-button-label = Tools\npdfjs-first-page-button =\n .title = Go to First Page\npdfjs-first-page-button-label = Go to First Page\npdfjs-last-page-button =\n .title = Go to Last Page\npdfjs-last-page-button-label = Go to Last Page\npdfjs-page-rotate-cw-button =\n .title = Rotate Clockwise\npdfjs-page-rotate-cw-button-label = Rotate Clockwise\npdfjs-page-rotate-ccw-button =\n .title = Rotate Counterclockwise\npdfjs-page-rotate-ccw-button-label = Rotate Counterclockwise\npdfjs-cursor-text-select-tool-button =\n .title = Enable Text Selection Tool\npdfjs-cursor-text-select-tool-button-label = Text Selection Tool\npdfjs-cursor-hand-tool-button =\n .title = Enable Hand Tool\npdfjs-cursor-hand-tool-button-label = Hand Tool\npdfjs-scroll-page-button =\n .title = Use Page Scrolling\npdfjs-scroll-page-button-label = Page Scrolling\npdfjs-scroll-vertical-button =\n .title = Use Vertical Scrolling\npdfjs-scroll-vertical-button-label = Vertical Scrolling\npdfjs-scroll-horizontal-button =\n .title = Use Horizontal Scrolling\npdfjs-scroll-horizontal-button-label = Horizontal Scrolling\npdfjs-scroll-wrapped-button =\n .title = Use Wrapped Scrolling\npdfjs-scroll-wrapped-button-label = Wrapped Scrolling\npdfjs-spread-none-button =\n .title = Do not join page spreads\npdfjs-spread-none-button-label = No Spreads\npdfjs-spread-odd-button =\n .title = Join page spreads starting with odd-numbered pages\npdfjs-spread-odd-button-label = Odd Spreads\npdfjs-spread-even-button =\n .title = Join page spreads starting with even-numbered pages\npdfjs-spread-even-button-label = Even Spreads\npdfjs-document-properties-button =\n .title = Document Properties…\npdfjs-document-properties-button-label = Document Properties…\npdfjs-document-properties-file-name = File name:\npdfjs-document-properties-file-size = File size:\npdfjs-document-properties-size-kb = { NUMBER($kb, maximumSignificantDigits: 3) } KB ({ $b } bytes)\npdfjs-document-properties-size-mb = { NUMBER($mb, maximumSignificantDigits: 3) } MB ({ $b } bytes)\npdfjs-document-properties-title = Title:\npdfjs-document-properties-author = Author:\npdfjs-document-properties-subject = Subject:\npdfjs-document-properties-keywords = Keywords:\npdfjs-document-properties-creation-date = Creation Date:\npdfjs-document-properties-modification-date = Modification Date:\npdfjs-document-properties-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\npdfjs-document-properties-creator = Creator:\npdfjs-document-properties-producer = PDF Producer:\npdfjs-document-properties-version = PDF Version:\npdfjs-document-properties-page-count = Page Count:\npdfjs-document-properties-page-size = Page Size:\npdfjs-document-properties-page-size-unit-inches = in\npdfjs-document-properties-page-size-unit-millimeters = mm\npdfjs-document-properties-page-size-orientation-portrait = portrait\npdfjs-document-properties-page-size-orientation-landscape = landscape\npdfjs-document-properties-page-size-name-a-three = A3\npdfjs-document-properties-page-size-name-a-four = A4\npdfjs-document-properties-page-size-name-letter = Letter\npdfjs-document-properties-page-size-name-legal = Legal\npdfjs-document-properties-page-size-dimension-string = { $width } × { $height } { $unit } ({ $orientation })\npdfjs-document-properties-page-size-dimension-name-string = { $width } × { $height } { $unit } ({ $name }, { $orientation })\npdfjs-document-properties-linearized = Fast Web View:\npdfjs-document-properties-linearized-yes = Yes\npdfjs-document-properties-linearized-no = No\npdfjs-document-properties-close-button = Close\npdfjs-print-progress-message = Preparing document for printing…\npdfjs-print-progress-percent = { $progress }%\npdfjs-print-progress-close-button = Cancel\npdfjs-printing-not-supported = Warning: Printing is not fully supported by this browser.\npdfjs-printing-not-ready = Warning: The PDF is not fully loaded for printing.\npdfjs-toggle-sidebar-button =\n .title = Toggle Sidebar\npdfjs-toggle-sidebar-notification-button =\n .title = Toggle Sidebar (document contains outline/attachments/layers)\npdfjs-toggle-sidebar-button-label = Toggle Sidebar\npdfjs-document-outline-button =\n .title = Show Document Outline (double-click to expand/collapse all items)\npdfjs-document-outline-button-label = Document Outline\npdfjs-attachments-button =\n .title = Show Attachments\npdfjs-attachments-button-label = Attachments\npdfjs-layers-button =\n .title = Show Layers (double-click to reset all layers to the default state)\npdfjs-layers-button-label = Layers\npdfjs-thumbs-button =\n .title = Show Thumbnails\npdfjs-thumbs-button-label = Thumbnails\npdfjs-current-outline-item-button =\n .title = Find Current Outline Item\npdfjs-current-outline-item-button-label = Current Outline Item\npdfjs-findbar-button =\n .title = Find in Document\npdfjs-findbar-button-label = Find\npdfjs-additional-layers = Additional Layers\npdfjs-thumb-page-title =\n .title = Page { $page }\npdfjs-thumb-page-canvas =\n .aria-label = Thumbnail of Page { $page }\npdfjs-find-input =\n .title = Find\n .placeholder = Find in document…\npdfjs-find-previous-button =\n .title = Find the previous occurrence of the phrase\npdfjs-find-previous-button-label = Previous\npdfjs-find-next-button =\n .title = Find the next occurrence of the phrase\npdfjs-find-next-button-label = Next\npdfjs-find-highlight-checkbox = Highlight All\npdfjs-find-match-case-checkbox-label = Match Case\npdfjs-find-match-diacritics-checkbox-label = Match Diacritics\npdfjs-find-entire-word-checkbox-label = Whole Words\npdfjs-find-reached-top = Reached top of document, continued from bottom\npdfjs-find-reached-bottom = Reached end of document, continued from top\npdfjs-find-match-count =\n { $total ->\n [one] { $current } of { $total } match\n *[other] { $current } of { $total } matches\n }\npdfjs-find-match-count-limit =\n { $limit ->\n [one] More than { $limit } match\n *[other] More than { $limit } matches\n }\npdfjs-find-not-found = Phrase not found\npdfjs-page-scale-width = Page Width\npdfjs-page-scale-fit = Page Fit\npdfjs-page-scale-auto = Automatic Zoom\npdfjs-page-scale-actual = Actual Size\npdfjs-page-scale-percent = { $scale }%\npdfjs-page-landmark =\n .aria-label = Page { $page }\npdfjs-loading-error = An error occurred while loading the PDF.\npdfjs-invalid-file-error = Invalid or corrupted PDF file.\npdfjs-missing-file-error = Missing PDF file.\npdfjs-unexpected-response-error = Unexpected server response.\npdfjs-rendering-error = An error occurred while rendering the page.\npdfjs-annotation-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\npdfjs-text-annotation-type =\n .alt = [{ $type } Annotation]\npdfjs-password-label = Enter the password to open this PDF file.\npdfjs-password-invalid = Invalid password. Please try again.\npdfjs-password-ok-button = OK\npdfjs-password-cancel-button = Cancel\npdfjs-web-fonts-disabled = Web fonts are disabled: unable to use embedded PDF fonts.\npdfjs-editor-free-text-button =\n .title = Text\npdfjs-editor-free-text-button-label = Text\npdfjs-editor-ink-button =\n .title = Draw\npdfjs-editor-ink-button-label = Draw\npdfjs-editor-stamp-button =\n .title = Add or edit images\npdfjs-editor-stamp-button-label = Add or edit images\npdfjs-editor-highlight-button =\n .title = Highlight\npdfjs-editor-highlight-button-label = Highlight\npdfjs-highlight-floating-button1 =\n .title = Highlight\n .aria-label = Highlight\npdfjs-highlight-floating-button-label = Highlight\npdfjs-editor-remove-ink-button =\n .title = Remove drawing\npdfjs-editor-remove-freetext-button =\n .title = Remove text\npdfjs-editor-remove-stamp-button =\n .title = Remove image\npdfjs-editor-remove-highlight-button =\n .title = Remove highlight\npdfjs-editor-free-text-color-input = Color\npdfjs-editor-free-text-size-input = Size\npdfjs-editor-ink-color-input = Color\npdfjs-editor-ink-thickness-input = Thickness\npdfjs-editor-ink-opacity-input = Opacity\npdfjs-editor-stamp-add-image-button =\n .title = Add image\npdfjs-editor-stamp-add-image-button-label = Add image\npdfjs-editor-free-highlight-thickness-input = Thickness\npdfjs-editor-free-highlight-thickness-title =\n .title = Change thickness when highlighting items other than text\npdfjs-free-text2 =\n .aria-label = Text Editor\n .default-content = Start typing…\npdfjs-ink =\n .aria-label = Draw Editor\npdfjs-ink-canvas =\n .aria-label = User-created image\npdfjs-editor-alt-text-button =\n .aria-label = Alt text\npdfjs-editor-alt-text-button-label = Alt text\npdfjs-editor-alt-text-edit-button =\n .aria-label = Edit alt text\npdfjs-editor-alt-text-dialog-label = Choose an option\npdfjs-editor-alt-text-dialog-description = Alt text (alternative text) helps when people can’t see the image or when it doesn’t load.\npdfjs-editor-alt-text-add-description-label = Add a description\npdfjs-editor-alt-text-add-description-description = Aim for 1-2 sentences that describe the subject, setting, or actions.\npdfjs-editor-alt-text-mark-decorative-label = Mark as decorative\npdfjs-editor-alt-text-mark-decorative-description = This is used for ornamental images, like borders or watermarks.\npdfjs-editor-alt-text-cancel-button = Cancel\npdfjs-editor-alt-text-save-button = Save\npdfjs-editor-alt-text-decorative-tooltip = Marked as decorative\npdfjs-editor-alt-text-textarea =\n .placeholder = For example, “A young man sits down at a table to eat a meal”\npdfjs-editor-resizer-top-left =\n .aria-label = Top left corner — resize\npdfjs-editor-resizer-top-middle =\n .aria-label = Top middle — resize\npdfjs-editor-resizer-top-right =\n .aria-label = Top right corner — resize\npdfjs-editor-resizer-middle-right =\n .aria-label = Middle right — resize\npdfjs-editor-resizer-bottom-right =\n .aria-label = Bottom right corner — resize\npdfjs-editor-resizer-bottom-middle =\n .aria-label = Bottom middle — resize\npdfjs-editor-resizer-bottom-left =\n .aria-label = Bottom left corner — resize\npdfjs-editor-resizer-middle-left =\n .aria-label = Middle left — resize\npdfjs-editor-highlight-colorpicker-label = Highlight color\npdfjs-editor-colorpicker-button =\n .title = Change color\npdfjs-editor-colorpicker-dropdown =\n .aria-label = Color choices\npdfjs-editor-colorpicker-yellow =\n .title = Yellow\npdfjs-editor-colorpicker-green =\n .title = Green\npdfjs-editor-colorpicker-blue =\n .title = Blue\npdfjs-editor-colorpicker-pink =\n .title = Pink\npdfjs-editor-colorpicker-red =\n .title = Red\npdfjs-editor-highlight-show-all-button-label = Show all\npdfjs-editor-highlight-show-all-button =\n .title = Show all\npdfjs-editor-new-alt-text-dialog-edit-label = Edit alt text (image description)\npdfjs-editor-new-alt-text-dialog-add-label = Add alt text (image description)\npdfjs-editor-new-alt-text-textarea =\n .placeholder = Write your description here…\npdfjs-editor-new-alt-text-description = Short description for people who can’t see the image or when the image doesn’t load.\npdfjs-editor-new-alt-text-disclaimer1 = This alt text was created automatically and may be inaccurate.\npdfjs-editor-new-alt-text-disclaimer-learn-more-url = Learn more\npdfjs-editor-new-alt-text-create-automatically-button-label = Create alt text automatically\npdfjs-editor-new-alt-text-not-now-button = Not now\npdfjs-editor-new-alt-text-error-title = Couldn’t create alt text automatically\npdfjs-editor-new-alt-text-error-description = Please write your own alt text or try again later.\npdfjs-editor-new-alt-text-error-close-button = Close\npdfjs-editor-new-alt-text-ai-model-downloading-progress = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\n .aria-valuetext = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\npdfjs-editor-new-alt-text-added-button =\n .aria-label = Alt text added\npdfjs-editor-new-alt-text-added-button-label = Alt text added\npdfjs-editor-new-alt-text-missing-button =\n .aria-label = Missing alt text\npdfjs-editor-new-alt-text-missing-button-label = Missing alt text\npdfjs-editor-new-alt-text-to-review-button =\n .aria-label = Review alt text\npdfjs-editor-new-alt-text-to-review-button-label = Review alt text\npdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer = Created automatically: { $generatedAltText }\npdfjs-image-alt-text-settings-button =\n .title = Image alt text settings\npdfjs-image-alt-text-settings-button-label = Image alt text settings\npdfjs-editor-alt-text-settings-dialog-label = Image alt text settings\npdfjs-editor-alt-text-settings-automatic-title = Automatic alt text\npdfjs-editor-alt-text-settings-create-model-button-label = Create alt text automatically\npdfjs-editor-alt-text-settings-create-model-description = Suggests descriptions to help people who can’t see the image or when the image doesn’t load.\npdfjs-editor-alt-text-settings-download-model-label = Alt text AI model ({ $totalSize } MB)\npdfjs-editor-alt-text-settings-ai-model-description = Runs locally on your device so your data stays private. Required for automatic alt text.\npdfjs-editor-alt-text-settings-delete-model-button = Delete\npdfjs-editor-alt-text-settings-download-model-button = Download\npdfjs-editor-alt-text-settings-downloading-model-button = Downloading…\npdfjs-editor-alt-text-settings-editor-title = Alt text editor\npdfjs-editor-alt-text-settings-show-dialog-button-label = Show alt text editor right away when adding an image\npdfjs-editor-alt-text-settings-show-dialog-description = Helps you make sure all your images have alt text.\npdfjs-editor-alt-text-settings-close-button = Close\npdfjs-editor-undo-bar-message-highlight = Highlight removed\npdfjs-editor-undo-bar-message-freetext = Text removed\npdfjs-editor-undo-bar-message-ink = Drawing removed\npdfjs-editor-undo-bar-message-stamp = Image removed\npdfjs-editor-undo-bar-message-multiple =\n { $count ->\n [one] { $count } annotation removed\n *[other] { $count } annotations removed\n }\npdfjs-editor-undo-bar-undo-button =\n .title = Undo\npdfjs-editor-undo-bar-undo-button-label = Undo\npdfjs-editor-undo-bar-close-button =\n .title = Close\npdfjs-editor-undo-bar-close-button-label = Close')}}function qo(){return document.location.hash}class Xo{#tl=null;constructor({linkService:t,eventBus:e}){this.linkService=t,this.eventBus=e,this._initialized=!1,this._fingerprint="",this.reset(),this.eventBus._on("pagesinit",(()=>{this._isPagesLoaded=!1,this.eventBus._on("pagesloaded",(t=>{this._isPagesLoaded=!!t.pagesCount}),{once:!0})}))}initialize({fingerprint:t,resetHistory:e=!1,updateUrl:i=!1}){if(!t||"string"!=typeof t)return void console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');this._initialized&&this.reset();const s=""!==this._fingerprint&&this._fingerprint!==t;this._fingerprint=t,this._updateUrl=!0===i,this._initialized=!0,this.#ul();const n=window.history.state;if(this._popStateInProgress=!1,this._blockHashChange=0,this._currentHash=qo(),this._numPositionUpdates=0,this._uid=this._maxUid=0,this._destination=null,this._position=null,!this.#pl(n,!0)||e){const{hash:t,page:i,rotation:n}=this.#gl(!0);return!t||s||e?void this.#fl(null,!0):void this.#fl({hash:t,page:i,rotation:n},!0)}const r=n.destination;this.#ml(r,n.uid,!0),void 0!==r.rotation&&(this._initialRotation=r.rotation),r.dest?(this._initialBookmark=JSON.stringify(r.dest),this._destination.page=null):r.hash?this._initialBookmark=r.hash:r.page&&(this._initialBookmark=`page=${r.page}`)}reset(){this._initialized&&(this.#bl(),this._initialized=!1,this.#vl()),this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._initialBookmark=null,this._initialRotation=null}push({namedDest:t=null,explicitDest:e,pageNumber:i}){if(!this._initialized)return;if(t&&"string"!=typeof t)return void console.error(`PDFHistory.push: "${t}" is not a valid namedDest parameter.`);if(!Array.isArray(e))return void console.error(`PDFHistory.push: "${e}" is not a valid explicitDest parameter.`);if(!this.#wl(i)&&(null!==i||this._destination))return void console.error(`PDFHistory.push: "${i}" is not a valid pageNumber parameter.`);const s=t||JSON.stringify(e);if(!s)return;let n=!1;if(this._destination&&(function(t,e){if("string"!=typeof t||"string"!=typeof e)return!1;if(t===e)return!0;if(Kn(t).get("nameddest")===e)return!0;return!1}(this._destination.hash,s)||function(t,e){function i(t,e){if(typeof t!=typeof e)return!1;if(Array.isArray(t)||Array.isArray(e))return!1;if(null!==t&&"object"==typeof t&&null!==e){if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const s in t)if(!i(t[s],e[s]))return!1;return!0}return t===e||Number.isNaN(t)&&Number.isNaN(e)}if(!Array.isArray(t)||!Array.isArray(e))return!1;if(t.length!==e.length)return!1;for(let s=0,n=t.length;s<n;s++)if(!i(t[s],e[s]))return!1;return!0}(this._destination.dest,e))){if(this._destination.page)return;n=!0}this._popStateInProgress&&!n||(this.#fl({dest:e,hash:s,page:i,rotation:this.linkService.rotation},n),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then((()=>{this._popStateInProgress=!1}))))}pushPage(t){this._initialized&&(this.#wl(t)?this._destination?.page!==t&&(this._popStateInProgress||(this.#fl({dest:null,hash:`page=${t}`,page:t,rotation:this.linkService.rotation}),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then((()=>{this._popStateInProgress=!1}))))):console.error(`PDFHistory.pushPage: "${t}" is not a valid page number.`))}pushCurrentPosition(){this._initialized&&!this._popStateInProgress&&this.#yl()}back(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#pl(t)&&t.uid>0&&window.history.back()}forward(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#pl(t)&&t.uid<this._maxUid&&window.history.forward()}get popStateInProgress(){return this._initialized&&(this._popStateInProgress||this._blockHashChange>0)}get initialBookmark(){return this._initialized?this._initialBookmark:null}get initialRotation(){return this._initialized?this._initialRotation:null}#fl(t,e=!1){const i=e||!this._destination,s={fingerprint:this._fingerprint,uid:i?this._uid:this._uid+1,destination:t};let n;if(this.#ml(t,s.uid),this._updateUrl&&t?.hash){const e=document.location.href.split("#",1)[0];e.startsWith("file://")||(n=`${e}#${t.hash}`)}i?window.history.replaceState(s,"",n):window.history.pushState(s,"",n)}#yl(t=!1){if(!this._position)return;let e=this._position;if(t&&(e=Object.assign(Object.create(null),this._position),e.temporary=!0),!this._destination)return void this.#fl(e);if(this._destination.temporary)return void this.#fl(e,!0);if(this._destination.hash===e.hash)return;if(!this._destination.page&&this._numPositionUpdates<=50)return;let i=!1;if(this._destination.page>=e.first&&this._destination.page<=e.page){if(void 0!==this._destination.dest||!this._destination.first)return;i=!0}this.#fl(e,i)}#wl(t){return Number.isInteger(t)&&t>0&&t<=this.linkService.pagesCount}#pl(t,e=!1){if(!t)return!1;if(t.fingerprint!==this._fingerprint){if(!e)return!1;{if("string"!=typeof t.fingerprint||t.fingerprint.length!==this._fingerprint.length)return!1;const[e]=performance.getEntriesByType("navigation");if("reload"!==e?.type)return!1}}return!(!Number.isInteger(t.uid)||t.uid<0)&&(null!==t.destination&&"object"==typeof t.destination)}#ml(t,e,i=!1){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),i&&t?.temporary&&delete t.temporary,this._destination=t,this._uid=e,this._maxUid=Math.max(this._maxUid,e),this._numPositionUpdates=0}#gl(t=!1){const e=unescape(qo()).substring(1),i=Kn(e),s=i.get("nameddest")||"";let n=0|i.get("page");return(!this.#wl(n)||t&&s.length>0)&&(n=null),{hash:e,page:n,rotation:this.linkService.rotation}}#Al({location:t}){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._position={hash:t.pdfOpenParams.substring(1),page:this.linkService.page,first:t.pageNumber,rotation:t.rotation},this._popStateInProgress||(this._isPagesLoaded&&this._destination&&!this._destination.page&&this._numPositionUpdates++,this._updateViewareaTimeout=setTimeout((()=>{this._popStateInProgress||this.#yl(!0),this._updateViewareaTimeout=null}),1e3))}#_l({state:t}){const e=qo(),i=this._currentHash!==e;if(this._currentHash=e,!t){this._uid++;const{hash:t,page:e,rotation:i}=this.#gl();return void this.#fl({hash:t,page:e,rotation:i},!0)}if(!this.#pl(t))return;this._popStateInProgress=!0,i&&(this._blockHashChange++,async function({target:t,name:e,delay:i=0}){if("object"!=typeof t||!(Number.isInteger(i)&&i>=0))throw new Error("waitOnEventOrTimeout - invalid parameters.");const{promise:s,resolve:n}=Promise.withResolvers(),r=new AbortController;function a(t){r.abort(),clearTimeout(o),n(t)}t[t instanceof ka?"_on":"addEventListener"](e,a.bind(null,Ma),{signal:r.signal});const o=setTimeout(a.bind(null,Ta),i);return s}({target:window,name:"hashchange",delay:1e3}).then((()=>{this._blockHashChange--})));const s=t.destination;this.#ml(s,t.uid,!0),er(s.rotation)&&(this.linkService.rotation=s.rotation),s.dest?this.linkService.goToDestination(s.dest):s.hash?this.linkService.setHash(s.hash):s.page&&(this.linkService.page=s.page),Promise.resolve().then((()=>{this._popStateInProgress=!1}))}#bl(){this._destination&&!this._destination.temporary||this.#yl()}#ul(){if(this.#tl)return;this.#tl=new AbortController;const{signal:t}=this.#tl;this.eventBus._on("updateviewarea",this.#Al.bind(this),{signal:t}),window.addEventListener("popstate",this.#_l.bind(this),{signal:t}),window.addEventListener("pagehide",this.#bl.bind(this),{signal:t})}#vl(){this.#tl?.abort(),this.#tl=null}}class Ko{#ro=null;#xl=null;#Zo=null;#Tn=null;#go=null;#f;constructor(t){this.pdfPage=t.pdfPage,this.accessibilityManager=t.accessibilityManager,this.l10n=t.l10n,this.l10n||=new Go,this.annotationEditorLayer=null,this.div=null,this._cancelled=!1,this.#f=t.uiManager,this.#ro=t.annotationLayer||null,this.#go=t.textLayer||null,this.#xl=t.drawLayer||null,this.#Zo=t.onAppend||null,this.#Tn=t.structTreeLayer||null}async render(t,e="display"){if("display"!==e)return;if(this._cancelled)return;const i=t.clone({dontFlip:!0});if(this.div)return this.annotationEditorLayer.update({viewport:i}),void this.show();const s=this.div=document.createElement("div");s.className="annotationEditorLayer",s.hidden=!0,s.dir=this.#f.direction,this.#Zo?.(s),this.annotationEditorLayer=new Nr({uiManager:this.#f,div:s,structTreeLayer:this.#Tn,accessibilityManager:this.accessibilityManager,pageIndex:this.pdfPage.pageNumber-1,l10n:this.l10n,viewport:i,annotationLayer:this.#ro,textLayer:this.#go,drawLayer:this.#xl});const n={viewport:i,div:s,annotations:null,intent:e};this.annotationEditorLayer.render(n),this.show()}cancel(){this._cancelled=!0,this.div&&this.annotationEditorLayer.destroy()}hide(){this.div&&(this.annotationEditorLayer.pause(!0),this.div.hidden=!0)}show(){this.div&&!this.annotationEditorLayer.isInvisible&&(this.div.hidden=!1,this.annotationEditorLayer.pause(!1))}}{var Yo=new Map;const t=navigator.userAgent||"",e=navigator.platform||"",i=navigator.maxTouchPoints||1,s=/Android/.test(t);(/\b(iPad|iPhone|iPod)(?=;)/.test(t)||"MacIntel"===e&&i>1||s)&&Yo.set("maxCanvasPixels",5242880),s&&Yo.set("useSystemFonts",!1)}const Qo=1,Jo=2,Zo=4,tl=8,el=16,il=128,sl={BOOLEAN:1,NUMBER:2,OBJECT:4,STRING:8,UNDEFINED:16},nl={allowedGlobalEvents:{value:null,kind:Qo},canvasMaxAreaInBytes:{value:-1,kind:Qo+Zo},isInAutomation:{value:!1,kind:Qo},localeProperties:{value:{lang:navigator.language||"en-US"},kind:Qo},nimbusDataStr:{value:"",kind:Qo},supportsCaretBrowsingMode:{value:!1,kind:Qo},supportsDocumentFonts:{value:!0,kind:Qo},supportsIntegratedFind:{value:!1,kind:Qo},supportsMouseWheelZoomCtrlKey:{value:!0,kind:Qo},supportsMouseWheelZoomMetaKey:{value:!0,kind:Qo},supportsPinchToZoom:{value:!0,kind:Qo},toolbarDensity:{value:0,kind:Qo+el},altTextLearnMoreUrl:{value:"",kind:Jo+il},annotationEditorMode:{value:0,kind:Jo+il},annotationMode:{value:2,kind:Jo+il},cursorToolOnLoad:{value:0,kind:Jo+il},debuggerSrc:{value:"./debugger.mjs",kind:Jo},defaultZoomDelay:{value:400,kind:Jo+il},defaultZoomValue:{value:"",kind:Jo+il},disableHistory:{value:!1,kind:Jo},disablePageLabels:{value:!1,kind:Jo+il},enableAltText:{value:!1,kind:Jo+il},enableAltTextModelDownload:{value:!0,kind:Jo+il+el},enableGuessAltText:{value:!0,kind:Jo+il+el},enableHighlightFloatingButton:{value:!1,kind:Jo+il},enableNewAltTextWhenAddingImage:{value:!0,kind:Jo+il},enablePermissions:{value:!1,kind:Jo+il},enablePrintAutoRotate:{value:!0,kind:Jo+il},enableScripting:{value:!0,kind:Jo+il},enableUpdatedAddImage:{value:!1,kind:Jo+il},externalLinkRel:{value:"noopener noreferrer nofollow",kind:Jo},externalLinkTarget:{value:0,kind:Jo+il},highlightEditorColors:{value:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",kind:Jo+il},historyUpdateUrl:{value:!1,kind:Jo+il},ignoreDestinationZoom:{value:!1,kind:Jo+il},imageResourcesPath:{value:"./images/",kind:Jo},maxCanvasPixels:{value:2**25,kind:Jo},forcePageColors:{value:!1,kind:Jo+il},pageColorsBackground:{value:"Canvas",kind:Jo+il},pageColorsForeground:{value:"CanvasText",kind:Jo+il},pdfBugEnabled:{value:!1,kind:Jo+il},printResolution:{value:150,kind:Jo},sidebarViewOnLoad:{value:-1,kind:Jo+il},scrollModeOnLoad:{value:-1,kind:Jo+il},spreadModeOnLoad:{value:-1,kind:Jo+il},textLayerMode:{value:1,kind:Jo+il},viewOnLoad:{value:0,kind:Jo+il},cMapPacked:{value:!0,kind:Zo},cMapUrl:{value:"../web/cmaps/",kind:Zo},disableAutoFetch:{value:!1,kind:Zo+il},disableFontFace:{value:!1,kind:Zo+il},disableRange:{value:!1,kind:Zo+il},disableStream:{value:!1,kind:Zo+il},docBaseUrl:{value:"",kind:Zo},enableHWA:{value:!0,kind:Zo+Jo+il},enableXfa:{value:!0,kind:Zo+il},fontExtraProperties:{value:!1,kind:Zo},isEvalSupported:{value:!0,kind:Zo},isOffscreenCanvasSupported:{value:!0,kind:Zo},maxImageSize:{value:-1,kind:Zo},pdfBug:{value:!1,kind:Zo},standardFontDataUrl:{value:"../web/standard_fonts/",kind:Zo},useSystemFonts:{value:void 0,kind:Zo,type:sl.BOOLEAN+sl.UNDEFINED},verbosity:{value:1,kind:Zo},workerPort:{value:null,kind:tl},workerSrc:{value:"../build/pdf.worker.mjs",kind:tl}};nl.defaultUrl={value:"compressed.tracemonkey-pldi-09.pdf",kind:Jo},nl.sandboxBundleSrc={value:"../build/pdf.sandbox.mjs",kind:Jo},nl.viewerCssTheme={value:0,kind:Jo+il},nl.enableFakeMLManager={value:!0,kind:Jo},nl.disablePreferences={value:!1,kind:Jo};class rl{static eventBus;static#Sl=new Map;static{for(const t in nl)this.#Sl.set(t,nl[t].value);for(const[t,e]of Yo)this.#Sl.set(t,e);this._hasInvokedSet=!1,this._checkDisablePreferences=()=>!!this.get("disablePreferences")||(this._hasInvokedSet&&console.warn('The Preferences may override manually set AppOptions; please use the "disablePreferences"-option to prevent that.'),!1)}static get(t){return this.#Sl.get(t)}static getAll(t=null,e=!1){const i=Object.create(null);for(const s in nl){const n=nl[s];(!t||t&n.kind)&&(i[s]=e?n.value:this.#Sl.get(s))}return i}static set(t,e){this.setAll({[t]:e})}static setAll(t,e=!1){let i;this._hasInvokedSet||=!0;for(const s in t){const n=nl[s],r=t[s];if(!n||!(typeof r==typeof n.value||sl[(typeof r).toUpperCase()]&n.type))continue;const{kind:a}=n;(!e||a&Qo||a&il)&&(this.eventBus&&a&el&&(i||=new Map).set(s,r),this.#Sl.set(s,r))}if(i)for(const[t,e]of i)this.eventBus.dispatch(t.toLowerCase(),{source:this,value:e})}}class al{#xl=null;constructor(t){this.pageIndex=t.pageIndex}async render(t="display"){"display"!==t||this.#xl||this._cancelled||(this.#xl=new Wr({pageIndex:this.pageIndex}))}cancel(){this._cancelled=!0,this.#xl&&(this.#xl.destroy(),this.#xl=null)}setParent(t){this.#xl?.setParent(t)}getDrawLayer(){return this.#xl}}const ol={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"columnheader",TBody:null,TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},ll=/^H(\d+)$/;class hl{#Cl;#El=null;#Pl;#Ml=new Map;#Tl;#kl=null;constructor(t,e){this.#Cl=t.getStructTree(),this.#Tl=e}async render(){if(this.#Pl)return this.#Pl;const{promise:t,resolve:e,reject:i}=Promise.withResolvers();this.#Pl=t;try{this.#El=this.#Il(await this.#Cl)}catch(t){i(t)}return this.#Cl=null,this.#El?.classList.add("structTree"),e(this.#El),t}async getAriaAttributes(t){try{return await this.render(),this.#Ml.get(t)}catch{}return null}hide(){this.#El&&!this.#El.hidden&&(this.#El.hidden=!0)}show(){this.#El?.hidden&&(this.#El.hidden=!1)}#Ll(t,e){const{alt:i,id:s,lang:n}=t;if(void 0!==i){let s=!1;const n=Qn(i);for(const e of t.children)if("annotation"===e.type){let t=this.#Ml.get(e.id);t||(t=new Map,this.#Ml.set(e.id,t)),t.set("aria-label",n),s=!0}s||e.setAttribute("aria-label",n)}void 0!==s&&e.setAttribute("aria-owns",s),void 0!==n&&e.setAttribute("lang",Qn(n,!0))}#Dl(t,e){const{alt:i,bbox:s,children:n}=t,r=n?.[0];if(!this.#Tl||!i||!s||"content"!==r?.type)return!1;const{id:a}=r;if(!a)return!1;e.setAttribute("aria-owns",a);const o=document.createElement("span");(this.#kl||=new Map).set(a,o),o.setAttribute("role","img"),o.setAttribute("aria-label",Qn(i));const{pageHeight:l,pageX:h,pageY:d}=this.#Tl,c="calc(var(--scale-factor)*",{style:u}=o;return u.width=`${c}${s[2]-s[0]}px)`,u.height=`${c}${s[3]-s[1]}px)`,u.left=`${c}${s[0]-h}px)`,u.top=`${c}${l-s[3]+d}px)`,!0}addElementsToTextLayer(){if(this.#kl){for(const[t,e]of this.#kl)document.getElementById(t)?.append(e);this.#kl.clear(),this.#kl=null}}#Il(t){if(!t)return null;const e=document.createElement("span");if("role"in t){const{role:i}=t,s=i.match(ll);if(s?(e.setAttribute("role","heading"),e.setAttribute("aria-level",s[1])):ol[i]&&e.setAttribute("role",ol[i]),"Figure"===i&&this.#Dl(t,e))return e}if(this.#Ll(t,e),t.children)if(1===t.children.length&&"id"in t.children[0])this.#Ll(t.children[0],e);else for(const i of t.children)e.append(this.#Il(i));return e}}class dl{#Rl=!1;#Nl=null;#Fl=new Map;#Ol=new Map;setTextMapping(t){this.#Nl=t}static#Bl(t,e){const i=t.getBoundingClientRect(),s=e.getBoundingClientRect();if(0===i.width&&0===i.height)return 1;if(0===s.width&&0===s.height)return-1;const n=i.y,r=i.y+i.height,a=i.y+i.height/2,o=s.y,l=s.y+s.height,h=s.y+s.height/2;if(a<=o&&h>=r)return-1;if(h<=n&&a>=l)return 1;return i.x+i.width/2-(s.x+s.width/2)}enable(){if(this.#Rl)throw new Error("TextAccessibilityManager is already enabled.");if(!this.#Nl)throw new Error("Text divs and strings have not been set.");if(this.#Rl=!0,this.#Nl=this.#Nl.slice(),this.#Nl.sort(dl.#Bl),this.#Fl.size>0){const t=this.#Nl;for(const[e,i]of this.#Fl){document.getElementById(e)?this.#jl(e,t[i]):this.#Fl.delete(e)}}for(const[t,e]of this.#Ol)this.addPointerInTextLayer(t,e);this.#Ol.clear()}disable(){this.#Rl&&(this.#Ol.clear(),this.#Nl=null,this.#Rl=!1)}removePointerInTextLayer(t){if(!this.#Rl)return void this.#Ol.delete(t);const e=this.#Nl;if(!e||0===e.length)return;const{id:i}=t,s=this.#Fl.get(i);if(void 0===s)return;const n=e[s];this.#Fl.delete(i);let r=n.getAttribute("aria-owns");r?.includes(i)&&(r=r.split(" ").filter((t=>t!==i)).join(" "),r?n.setAttribute("aria-owns",r):(n.removeAttribute("aria-owns"),n.setAttribute("role","presentation")))}#jl(t,e){const i=e.getAttribute("aria-owns");i?.includes(t)||e.setAttribute("aria-owns",i?`${i} ${t}`:t),e.removeAttribute("role")}addPointerInTextLayer(t,e){const{id:i}=t;if(!i)return null;if(!this.#Rl)return this.#Ol.set(t,e),null;e&&this.removePointerInTextLayer(t);const s=this.#Nl;if(!s||0===s.length)return null;const n=Jn(s,(e=>dl.#Bl(t,e)<0)),r=Math.max(0,n-1),a=s[r];this.#jl(i,a),this.#Fl.set(i,r);const o=a.parentNode;return o?.classList.contains("markedContent")?o.id:null}moveElementInDOM(t,e,i,s){const n=this.addPointerInTextLayer(i,s);if(!t.hasChildNodes())return t.append(e),n;const r=Array.from(t.childNodes).filter((t=>t!==e));if(0===r.length)return n;const a=i||e,o=Jn(r,(t=>dl.#Bl(a,t)<0));return 0===o?r[0].before(e):r[o-1].after(e),n}}class cl{#tl=null;constructor({findController:t,eventBus:e,pageIndex:i}){this.findController=t,this.matches=[],this.eventBus=e,this.pageIdx=i,this.textDivs=null,this.textContentItemsStr=null,this.enabled=!1}setTextMapping(t,e){this.textDivs=t,this.textContentItemsStr=e}enable(){if(!this.textDivs||!this.textContentItemsStr)throw new Error("Text divs and strings have not been set.");if(this.enabled)throw new Error("TextHighlighter is already enabled.");this.enabled=!0,this.#tl||(this.#tl=new AbortController,this.eventBus._on("updatetextlayermatches",(t=>{t.pageIndex!==this.pageIdx&&-1!==t.pageIndex||this._updateMatches()}),{signal:this.#tl.signal})),this._updateMatches()}disable(){this.enabled&&(this.enabled=!1,this.#tl?.abort(),this.#tl=null,this._updateMatches(!0))}_convertMatches(t,e){if(!t)return[];const{textContentItemsStr:i}=this;let s=0,n=0;const r=i.length-1,a=[];for(let o=0,l=t.length;o<l;o++){let l=t[o];for(;s!==r&&l>=n+i[s].length;)n+=i[s].length,s++;s===i.length&&console.error("Could not find a matching mapping");const h={begin:{divIdx:s,offset:l-n}};for(l+=e[o];s!==r&&l>n+i[s].length;)n+=i[s].length,s++;h.end={divIdx:s,offset:l-n},a.push(h)}return a}_renderMatches(t){if(0===t.length)return;const{findController:e,pageIdx:i}=this,{textContentItemsStr:s,textDivs:n}=this,r=i===e.selected.pageIdx,a=e.selected.matchIdx;let o=null;const l={offset:void 0};function h(t,e){const i=t.divIdx;return n[i].textContent="",d(i,0,t.offset,e)}function d(t,e,i,r){let a=n[t];if(a.nodeType===Node.TEXT_NODE){const e=document.createElement("span");a.before(e),e.append(a),n[t]=e,a=e}const o=s[t].substring(e,i),l=document.createTextNode(o);if(r){const t=document.createElement("span");if(t.className=`${r} appended`,t.append(l),a.append(t),r.includes("selected")){const{left:e}=t.getClientRects()[0];return e-a.getBoundingClientRect().left}return 0}return a.append(l),0}let c=a,u=c+1;if(e.state.highlightAll)c=0,u=t.length;else if(!r)return;let p=-1,g=-1;for(let s=c;s<u;s++){const c=t[s],u=c.begin;if(u.divIdx===p&&u.offset===g)continue;p=u.divIdx,g=u.offset;const f=c.end,m=r&&s===a,b=m?" selected":"";let v=0;if(o&&u.divIdx===o.divIdx?d(o.divIdx,o.offset,u.offset):(null!==o&&d(o.divIdx,o.offset,l.offset),h(u)),u.divIdx===f.divIdx)v=d(u.divIdx,u.offset,f.offset,"highlight"+b);else{v=d(u.divIdx,u.offset,l.offset,"highlight begin"+b);for(let t=u.divIdx+1,e=f.divIdx;t<e;t++)n[t].className="highlight middle"+b;h(f,"highlight end"+b)}o=f,m&&e.scrollMatchIntoView({element:n[u.divIdx],selectedLeft:v,pageIndex:i,matchIndex:a})}o&&d(o.divIdx,o.offset,l.offset)}_updateMatches(t=!1){if(!this.enabled&&!t)return;const{findController:e,matches:i,pageIdx:s}=this,{textContentItemsStr:n,textDivs:r}=this;let a=-1;for(const t of i){for(let e=Math.max(a,t.begin.divIdx),i=t.end.divIdx;e<=i;e++){const t=r[e];t.textContent=n[e],t.className=""}a=t.end.divIdx+1}if(!e?.highlightMatches||t)return;const o=e.pageMatches[s]||null,l=e.pageMatchesLength[s]||null;this.matches=this._convertMatches(o,l),this._renderMatches(this.matches)}}class ul{#Vl=!1;#Zo=null;#Hl=!1;#go=null;static#zl=new Map;static#Ul=null;constructor({pdfPage:t,highlighter:e=null,accessibilityManager:i=null,enablePermissions:s=!1,onAppend:n=null}){this.pdfPage=t,this.highlighter=e,this.accessibilityManager=i,this.#Vl=!0===s,this.#Zo=n,this.div=document.createElement("div"),this.div.tabIndex=0,this.div.className="textLayer"}async render(t,e=null){if(this.#Hl&&this.#go)return this.#go.update({viewport:t,onBefore:this.hide.bind(this)}),void this.show();this.cancel(),this.#go=new va({textContentSource:this.pdfPage.streamTextContent(e||{includeMarkedContent:!0,disableNormalization:!0}),container:this.div,viewport:t});const{textDivs:i,textContentItemsStr:s}=this.#go;this.highlighter?.setTextMapping(i,s),this.accessibilityManager?.setTextMapping(i),await this.#go.render(),this.#Hl=!0;const n=document.createElement("div");n.className="endOfContent",this.div.append(n),this.#$l(n),this.#Zo?.(this.div),this.highlighter?.enable(),this.accessibilityManager?.enable()}hide(){!this.div.hidden&&this.#Hl&&(this.highlighter?.disable(),this.div.hidden=!0)}show(){this.div.hidden&&this.#Hl&&(this.div.hidden=!1,this.highlighter?.enable())}cancel(){this.#go?.cancel(),this.#go=null,this.highlighter?.disable(),this.accessibilityManager?.disable(),ul.#Wl(this.div)}#$l(t){const{div:e}=this;e.addEventListener("mousedown",(()=>{e.classList.add("selecting")})),e.addEventListener("copy",(t=>{if(!this.#Vl){const e=document.getSelection();t.clipboardData.setData("text/plain",Qn(ra(e.toString())))}ba(t)})),ul.#zl.set(e,t),ul.#Gl()}static#Wl(t){this.#zl.delete(t),0===this.#zl.size&&(this.#Ul?.abort(),this.#Ul=null)}static#Gl(){if(this.#Ul)return;this.#Ul=new AbortController;const{signal:t}=this.#Ul,e=(t,e)=>{e.append(t),t.style.width="",t.style.height="",e.classList.remove("selecting")};let i=!1;var s,n;document.addEventListener("pointerdown",(()=>{i=!0}),{signal:t}),document.addEventListener("pointerup",(()=>{i=!1,this.#zl.forEach(e)}),{signal:t}),window.addEventListener("blur",(()=>{i=!1,this.#zl.forEach(e)}),{signal:t}),document.addEventListener("keyup",(()=>{i||this.#zl.forEach(e)}),{signal:t}),document.addEventListener("selectionchange",(()=>{const t=document.getSelection();if(0===t.rangeCount)return void this.#zl.forEach(e);const i=new Set;for(let e=0;e<t.rangeCount;e++){const s=t.getRangeAt(e);for(const t of this.#zl.keys())!i.has(t)&&s.intersectsNode(t)&&i.add(t)}for(const[t,s]of this.#zl)i.has(t)?t.classList.add("selecting"):e(s,t);if(s??="none"===getComputedStyle(this.#zl.values().next().value).getPropertyValue("-moz-user-select"),s)return;const r=t.getRangeAt(0),a=n&&(0===r.compareBoundaryPoints(Range.END_TO_END,n)||0===r.compareBoundaryPoints(Range.START_TO_END,n));let o=a?r.startContainer:r.endContainer;o.nodeType===Node.TEXT_NODE&&(o=o.parentNode);const l=o.parentElement?.closest(".textLayer"),h=this.#zl.get(l);h&&(h.style.width=l.style.width,h.style.height=l.style.height,o.parentElement.insertBefore(h,a?o:o.nextSibling)),n=r.cloneRange()}),{signal:t})}}class pl{constructor({pdfPage:t,annotationStorage:e=null,linkService:i,xfaHtml:s=null}){this.pdfPage=t,this.annotationStorage=e,this.linkService=i,this.xfaHtml=s,this.div=null,this._cancelled=!1}async render(t,e="display"){if("print"===e){const i={viewport:t.clone({dontFlip:!0}),div:this.div,xfaHtml:this.xfaHtml,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:e};return this.div=document.createElement("div"),i.div=this.div,Sa.render(i)}const i=await this.pdfPage.getXfa();if(this._cancelled||!i)return{textDivs:[]};const s={viewport:t.clone({dontFlip:!0}),div:this.div,xfaHtml:i,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:e};return this.div?Sa.update(s):(this.div=document.createElement("div"),s.div=this.div,Sa.render(s))}cancel(){this._cancelled=!0}hide(){this.div&&(this.div.hidden=!0)}}const gl={annotationEditorUIManager:null,annotationStorage:null,downloadManager:null,enableScripting:!1,fieldObjectsPromise:null,findController:null,hasJSActionsPromise:null,get linkService(){return new Dr}},fl=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);class ml{#ql=Vr.ENABLE_FORMS;#Xl=null;#li=!1;#Kl=!1;#_e=!1;#Yl=null;#Ql=null;#Jl=null;#Zl=null;#th=1;#eh=1;#ih=null;#sh=Bn.INITIAL;#nh=$n;#rh={directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0};#ah=[null,null,null,null];constructor(t){const e=t.container,i=t.defaultViewport;this.id=t.id,this.renderingId="page"+this.id,this.#Yl=t.layerProperties||gl,this.pdfPage=null,this.pageLabel=null,this.rotation=0,this.scale=t.scale||1,this.viewport=i,this.pdfPageRotate=i.rotation,this._optionalContentConfigPromise=t.optionalContentConfigPromise||null,this.#nh=t.textLayerMode??$n,this.#ql=t.annotationMode??Vr.ENABLE_FORMS,this.imageResourcesPath=t.imageResourcesPath||"",this.maxCanvasPixels=t.maxCanvasPixels??rl.get("maxCanvasPixels"),this.pageColors=t.pageColors||null,this.#li=t.enableHWA||!1,this.eventBus=t.eventBus,this.renderingQueue=t.renderingQueue,this.l10n=t.l10n,this.l10n||=new Go,this.renderTask=null,this.resume=null,this._isStandalone=!this.renderingQueue?.hasViewer(),this._container=e,this._annotationCanvasMap=null,this.annotationLayer=null,this.annotationEditorLayer=null,this.textLayer=null,this.xfaLayer=null,this.structTreeLayer=null,this.drawLayer=null;const s=document.createElement("div");if(s.className="page",s.setAttribute("data-page-number",this.id),s.setAttribute("role","region"),s.setAttribute("data-l10n-id","pdfjs-page-landmark"),s.setAttribute("data-l10n-args",JSON.stringify({page:this.id})),this.div=s,this.#oh(),e?.append(s),this._isStandalone){e?.style.setProperty("--scale-factor",this.scale*pa.PDF_TO_CSS_UNITS),this.pageColors?.background&&e?.style.setProperty("--page-bg-color",this.pageColors.background);const{optionalContentConfigPromise:i}=t;i&&i.then((t=>{i===this._optionalContentConfigPromise&&(this.#rh.initialOptionalContent=t.hasInitialVisibility)})),t.l10n||this.l10n.translate(this.div)}}#lh(t,e){const i=fl.get(e),s=this.#ah[i];if(this.#ah[i]=t,s)s.replaceWith(t);else{for(let e=i-1;e>=0;e--){const i=this.#ah[e];if(i)return void i.after(t)}this.div.prepend(t)}}get renderingState(){return this.#sh}set renderingState(t){if(t!==this.#sh)switch(this.#sh=t,this.#Ql&&(clearTimeout(this.#Ql),this.#Ql=null),t){case Bn.PAUSED:this.div.classList.remove("loading");break;case Bn.RUNNING:this.div.classList.add("loadingIcon"),this.#Ql=setTimeout((()=>{this.div.classList.add("loading"),this.#Ql=null}),0);break;case Bn.INITIAL:case Bn.FINISHED:this.div.classList.remove("loadingIcon","loading")}}#oh(){const{viewport:t}=this;if(this.pdfPage){if(this.#Zl===t.rotation)return;this.#Zl=t.rotation}fa(this.div,t,!0,!1)}setPdfPage(t){!this._isStandalone||"CanvasText"!==this.pageColors?.foreground&&"Canvas"!==this.pageColors?.background||(this._container?.style.setProperty("--hcm-highlight-filter",t.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight")),this._container?.style.setProperty("--hcm-highlight-selected-filter",t.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","Highlight"))),this.pdfPage=t,this.pdfPageRotate=t.rotate;const e=(this.rotation+this.pdfPageRotate)%360;this.viewport=t.getViewport({scale:this.scale*pa.PDF_TO_CSS_UNITS,rotation:e}),this.#oh(),this.reset()}destroy(){this.reset(),this.pdfPage?.cleanup()}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}get _textHighlighter(){return ma(this,"_textHighlighter",new cl({pageIndex:this.id-1,eventBus:this.eventBus,findController:this.#Yl.findController}))}#hh(t,e){this.eventBus.dispatch(t,{source:this,pageNumber:this.id,error:e})}async#dh(){let t=null;try{await this.annotationLayer.render(this.viewport,{structTreeLayer:this.structTreeLayer},"display")}catch(e){console.error("#renderAnnotationLayer:",e),t=e}finally{this.#hh("annotationlayerrendered",t)}}async#ch(){let t=null;try{await this.annotationEditorLayer.render(this.viewport,"display")}catch(e){console.error("#renderAnnotationEditorLayer:",e),t=e}finally{this.#hh("annotationeditorlayerrendered",t)}}async#uh(){try{await this.drawLayer.render("display")}catch(t){console.error("#renderDrawLayer:",t)}}async#ph(){let t=null;try{const t=await this.xfaLayer.render(this.viewport,"display");t?.textDivs&&this._textHighlighter&&this.#gh(t.textDivs)}catch(e){console.error("#renderXfaLayer:",e),t=e}finally{this.xfaLayer?.div&&(this.l10n.pause(),this.#lh(this.xfaLayer.div,"xfaLayer"),this.l10n.resume()),this.#hh("xfalayerrendered",t)}}async#fh(){if(!this.textLayer)return;let t=null;try{await this.textLayer.render(this.viewport)}catch(e){if(e instanceof Rr)return;console.error("#renderTextLayer:",e),t=e}this.#hh("textlayerrendered",t),this.#mh()}async#mh(){if(!this.textLayer)return;const t=await(this.structTreeLayer?.render());t&&(this.l10n.pause(),this.structTreeLayer?.addElementsToTextLayer(),this.canvas&&t.parentNode!==this.canvas&&this.canvas.append(t),this.l10n.resume()),this.structTreeLayer?.show()}async#gh(t){const e=await this.pdfPage.getTextContent(),i=[];for(const t of e.items)i.push(t.str);this._textHighlighter.setTextMapping(t,i),this._textHighlighter.enable()}#bh(){const{canvas:t}=this;t&&(t.remove(),t.width=t.height=0,this.canvas=null,this.#Jl=null)}reset({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:s=!1,keepCanvasWrapper:n=!1}={}){this.cancelRendering({keepAnnotationLayer:t,keepAnnotationEditorLayer:e,keepXfaLayer:i,keepTextLayer:s}),this.renderingState=Bn.INITIAL;const r=this.div,a=r.childNodes,o=t&&this.annotationLayer?.div||null,l=e&&this.annotationEditorLayer?.div||null,h=i&&this.xfaLayer?.div||null,d=s&&this.textLayer?.div||null,c=n&&this.#Xl||null;for(let t=a.length-1;t>=0;t--){const e=a[t];switch(e){case o:case l:case h:case d:case c:continue}e.remove();const i=this.#ah.indexOf(e);i>=0&&(this.#ah[i]=null)}r.removeAttribute("data-loaded"),o&&this.annotationLayer.hide(),l&&this.annotationEditorLayer.hide(),h&&this.xfaLayer.hide(),d&&this.textLayer.hide(),this.structTreeLayer?.hide(),!n&&this.#Xl&&(this.#Xl=null,this.#bh())}toggleEditingMode(t){this.hasEditableAnnotations()&&(this.#_e=t,this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0}))}update({scale:t=0,rotation:e=null,optionalContentConfigPromise:i=null,drawingDelay:s=-1}){this.scale=t||this.scale,"number"==typeof e&&(this.rotation=e),i instanceof Promise&&(this._optionalContentConfigPromise=i,i.then((t=>{i===this._optionalContentConfigPromise&&(this.#rh.initialOptionalContent=t.hasInitialVisibility)}))),this.#rh.directDrawing=!0;const n=(this.rotation+this.pdfPageRotate)%360;if(this.viewport=this.viewport.clone({scale:this.scale*pa.PDF_TO_CSS_UNITS,rotation:n}),this.#oh(),this._isStandalone&&this._container?.style.setProperty("--scale-factor",this.viewport.scale),this.canvas){let t=!1;if(this.#Kl)if(0===this.maxCanvasPixels)t=!0;else if(this.maxCanvasPixels>0){const{width:e,height:i}=this.viewport,{sx:s,sy:n}=this.outputScale;t=(Math.floor(e)*s|0)*(Math.floor(i)*n|0)>this.maxCanvasPixels}const e=s>=0&&s<1e3;if(e||t){if(e&&!t&&this.renderingState!==Bn.FINISHED&&(this.cancelRendering({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:s}),this.renderingState=Bn.FINISHED,this.#rh.directDrawing=!1),this.cssTransform({redrawAnnotationLayer:!0,redrawAnnotationEditorLayer:!0,redrawXfaLayer:!0,redrawTextLayer:!e,hideTextLayer:e}),e)return;return void this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!0,timestamp:performance.now(),error:this.#ih})}}this.cssTransform({}),this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0})}cancelRendering({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:s=!1,cancelExtraDelay:n=0}={}){this.renderTask&&(this.renderTask.cancel(n),this.renderTask=null),this.resume=null,!this.textLayer||s&&this.textLayer.div||(this.textLayer.cancel(),this.textLayer=null),!this.annotationLayer||t&&this.annotationLayer.div||(this.annotationLayer.cancel(),this.annotationLayer=null,this._annotationCanvasMap=null),this.structTreeLayer&&!this.textLayer&&(this.structTreeLayer=null),!this.annotationEditorLayer||e&&this.annotationEditorLayer.div||(this.drawLayer&&(this.drawLayer.cancel(),this.drawLayer=null),this.annotationEditorLayer.cancel(),this.annotationEditorLayer=null),!this.xfaLayer||i&&this.xfaLayer.div||(this.xfaLayer.cancel(),this.xfaLayer=null,this._textHighlighter?.disable())}cssTransform({redrawAnnotationLayer:t=!1,redrawAnnotationEditorLayer:e=!1,redrawXfaLayer:i=!1,redrawTextLayer:s=!1,hideTextLayer:n=!1}){const{canvas:r}=this;if(!r)return;const a=this.#Jl;if(this.viewport!==a){const t=(360+this.viewport.rotation-a.rotation)%360;if(90===t||270===t){const{width:e,height:i}=this.viewport,s=i/e,n=e/i;r.style.transform=`rotate(${t}deg) scale(${s},${n})`}else r.style.transform=0===t?"":`rotate(${t}deg)`}t&&this.annotationLayer&&this.#dh(),e&&this.annotationEditorLayer&&(this.drawLayer&&this.#uh(),this.#ch()),i&&this.xfaLayer&&this.#ph(),this.textLayer&&(n?(this.textLayer.hide(),this.structTreeLayer?.hide()):s&&this.#fh())}get width(){return this.viewport.width}get height(){return this.viewport.height}getPagePoint(t,e){return this.viewport.convertToPdfPoint(t,e)}async#vh(t,e=null){if(t===this.renderTask&&(this.renderTask=null),e instanceof ga)this.#ih=null;else if(this.#ih=e,this.renderingState=Bn.FINISHED,this.#rh.regularAnnotations=!t.separateAnnots,this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!1,timestamp:performance.now(),error:this.#ih}),e)throw e}async draw(){this.renderingState!==Bn.INITIAL&&(console.error("Must be in new state before drawing"),this.reset());const{div:t,l10n:e,pageColors:i,pdfPage:s,viewport:n}=this;if(!s)throw this.renderingState=Bn.FINISHED,new Error("pdfPage is not loaded");this.renderingState=Bn.RUNNING;let r=this.#Xl;if(r||(r=this.#Xl=document.createElement("div"),r.classList.add("canvasWrapper"),this.#lh(r,"canvasWrapper")),this.textLayer||this.#nh===Un||s.isPureXfa||(this._accessibilityManager||=new dl,this.textLayer=new ul({pdfPage:s,highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,enablePermissions:this.#nh===Wn,onAppend:t=>{this.l10n.pause(),this.#lh(t,"textLayer"),this.l10n.resume()}})),!this.annotationLayer&&this.#ql!==Vr.DISABLE){const{annotationStorage:t,annotationEditorUIManager:e,downloadManager:i,enableScripting:n,fieldObjectsPromise:r,hasJSActionsPromise:a,linkService:o}=this.#Yl;this._annotationCanvasMap||=new Map,this.annotationLayer=new Ca({pdfPage:s,annotationStorage:t,imageResourcesPath:this.imageResourcesPath,renderForms:this.#ql===Vr.ENABLE_FORMS,linkService:o,downloadManager:i,enableScripting:n,hasJSActionsPromise:a,fieldObjectsPromise:r,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager,annotationEditorUIManager:e,onAppend:t=>{this.#lh(t,"annotationLayer")}})}const{width:a,height:o}=n,l=document.createElement("canvas");l.setAttribute("role","presentation");const h=!(!i?.background||!i?.foreground),d=this.canvas,c=!d&&!h;this.canvas=l,this.#Jl=n;let u=t=>{if(c)return r.prepend(l),void(u=null);t&&(d?(d.replaceWith(l),d.width=d.height=0):r.prepend(l),u=null)};const p=l.getContext("2d",{alpha:!1,willReadFrequently:!this.#li}),g=this.outputScale=new oa;if(0===this.maxCanvasPixels){const t=1/this.scale;g.sx*=t,g.sy*=t,this.#Kl=!0}else if(this.maxCanvasPixels>0){const t=a*o,e=Math.sqrt(this.maxCanvasPixels/t);g.sx>e||g.sy>e?(g.sx=e,g.sy=e,this.#Kl=!0):this.#Kl=!1}const f=Zn(g.sx),m=Zn(g.sy),b=l.width=tr(rr(a*g.sx),f[0]),v=l.height=tr(rr(o*g.sy),m[0]),w=tr(rr(a),f[1]),y=tr(rr(o),m[1]);g.sx=b/w,g.sy=v/y,this.#th!==f[1]&&(t.style.setProperty("--scale-round-x",`${f[1]}px`),this.#th=f[1]),this.#eh!==m[1]&&(t.style.setProperty("--scale-round-y",`${m[1]}px`),this.#eh=m[1]);const A={canvasContext:p,transform:g.scaled?[g.sx,0,0,g.sy,0,0]:null,viewport:n,annotationMode:this.#ql,optionalContentConfigPromise:this._optionalContentConfigPromise,annotationCanvasMap:this._annotationCanvasMap,pageColors:i,isEditing:this.#_e},_=this.renderTask=s.render(A);_.onContinue=t=>{if(u?.(!1),this.renderingQueue&&!this.renderingQueue.isHighestPriority(this))return this.renderingState=Bn.PAUSED,void(this.resume=()=>{this.renderingState=Bn.RUNNING,t()});t()};const x=_.promise.then((async()=>{u?.(!0),await this.#vh(_),this.structTreeLayer||=new hl(s,n.rawDims),this.#fh(),this.annotationLayer&&await this.#dh();const{annotationEditorUIManager:t}=this.#Yl;t&&(this.drawLayer||=new al({pageIndex:this.id}),await this.#uh(),this.drawLayer.setParent(r),this.annotationEditorLayer||=new Ko({uiManager:t,pdfPage:s,l10n:e,structTreeLayer:this.structTreeLayer,accessibilityManager:this._accessibilityManager,annotationLayer:this.annotationLayer?.annotationLayer,textLayer:this.textLayer,drawLayer:this.drawLayer.getDrawLayer(),onAppend:t=>{this.#lh(t,"annotationEditorLayer")}}),this.#ch())}),(t=>(t instanceof ga?(d?.remove(),this.#bh()):u?.(!0),this.#vh(_,t))));if(s.isPureXfa){if(!this.xfaLayer){const{annotationStorage:t,linkService:e}=this.#Yl;this.xfaLayer=new pl({pdfPage:s,annotationStorage:t,linkService:e})}this.#ph()}return t.setAttribute("data-loaded",!0),this.eventBus.dispatch("pagerender",{source:this,pageNumber:this.id}),x}setPageLabel(t){this.pageLabel="string"==typeof t?t:null,this.div.setAttribute("data-l10n-args",JSON.stringify({page:this.pageLabel??this.id})),null!==this.pageLabel?this.div.setAttribute("data-page-label",this.pageLabel):this.div.removeAttribute("data-page-label")}get thumbnailCanvas(){const{directDrawing:t,initialOptionalContent:e,regularAnnotations:i}=this.#rh;return t&&e&&i?this.canvas:null}}class bl{constructor(t){this._ready=new Promise(((e,i)=>{import(t).then((t=>{e(t.QuickJSSandbox())})).catch(i)}))}async createSandbox(t){(await this._ready).create(t)}async dispatchEventInSandbox(t){const e=await this._ready;setTimeout((()=>e.dispatchEvent(t)),0)}async destroySandbox(){(await this._ready).nukeSandbox()}}class vl{#wh=null;#yh=null;#Ah=null;#tl=null;#Ir=null;#_h=null;#xh=null;#Sh=null;#Ch=!1;#Eh=null;#Ph=null;constructor({eventBus:t,externalServices:e=null,docProperties:i=null}){this.#Ir=t,this.#_h=e,this.#Ah=i}setViewer(t){this.#Sh=t}async setDocument(t){if(this.#xh&&await this.#Mh(),this.#xh=t,!t)return;const[e,i,s]=await Promise.all([t.getFieldObjects(),t.getCalculationOrderIds(),t.getJSActions()]);if(!e&&!s)return void await this.#Mh();if(t!==this.#xh)return;try{this.#Eh=this.#Th()}catch(t){return console.error("setDocument:",t),void await this.#Mh()}const n=this.#Ir;this.#tl=new AbortController;const{signal:r}=this.#tl;n._on("updatefromsandbox",(t=>{t?.source===window&&this.#kh(t.detail)}),{signal:r}),n._on("dispatcheventinsandbox",(t=>{this.#Eh?.dispatchEventInSandbox(t.detail)}),{signal:r}),n._on("pagechanging",(({pageNumber:t,previous:e})=>{t!==e&&(this.#Ih(e),this.#Lh(t))}),{signal:r}),n._on("pagerendered",(({pageNumber:t})=>{this._pageOpenPending.has(t)&&t===this.#Sh.currentPageNumber&&this.#Lh(t)}),{signal:r}),n._on("pagesdestroy",(async()=>{await this.#Ih(this.#Sh.currentPageNumber),await(this.#Eh?.dispatchEventInSandbox({id:"doc",name:"WillClose"})),this.#wh?.resolve()}),{signal:r});try{const r=await this.#Ah(t);if(t!==this.#xh)return;await this.#Eh.createSandbox({objects:e,calculationOrder:i,appInfo:{platform:navigator.platform,language:navigator.language},docInfo:{...r,actions:s}}),n.dispatch("sandboxcreated",{source:this})}catch(t){return console.error("setDocument:",t),void await this.#Mh()}await(this.#Eh?.dispatchEventInSandbox({id:"doc",name:"Open"})),await this.#Lh(this.#Sh.currentPageNumber,!0),Promise.resolve().then((()=>{t===this.#xh&&(this.#Ch=!0)}))}async dispatchWillSave(){return this.#Eh?.dispatchEventInSandbox({id:"doc",name:"WillSave"})}async dispatchDidSave(){return this.#Eh?.dispatchEventInSandbox({id:"doc",name:"DidSave"})}async dispatchWillPrint(){if(this.#Eh){await(this.#Ph?.promise),this.#Ph=Promise.withResolvers();try{await this.#Eh.dispatchEventInSandbox({id:"doc",name:"WillPrint"})}catch(t){throw this.#Ph.resolve(),this.#Ph=null,t}await this.#Ph.promise}}async dispatchDidPrint(){return this.#Eh?.dispatchEventInSandbox({id:"doc",name:"DidPrint"})}get destroyPromise(){return this.#yh?.promise||null}get ready(){return this.#Ch}get _pageOpenPending(){return ma(this,"_pageOpenPending",new Set)}get _visitedPages(){return ma(this,"_visitedPages",new Map)}async#kh(t){const e=this.#Sh,i=e.isInPresentationMode||e.isChangingPresentationMode,{id:s,siblings:n,command:r,value:a}=t;if(!s){switch(r){case"clear":console.clear();break;case"error":console.error(a);break;case"layout":if(!i){const t=function(t){let e=Gn.VERTICAL,i=qn.NONE;switch(t){case"SinglePage":e=Gn.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=Gn.PAGE;case"TwoColumnLeft":i=qn.ODD;break;case"TwoPageRight":e=Gn.PAGE;case"TwoColumnRight":i=qn.EVEN}return{scrollMode:e,spreadMode:i}}(a);e.spreadMode=t.spreadMode}break;case"page-num":e.currentPageNumber=a+1;break;case"print":await e.pagesPromise,this.#Ir.dispatch("print",{source:this});break;case"println":console.log(a);break;case"zoom":i||(e.currentScaleValue=a);break;case"SaveAs":this.#Ir.dispatch("download",{source:this});break;case"FirstPage":e.currentPageNumber=1;break;case"LastPage":e.currentPageNumber=e.pagesCount;break;case"NextPage":e.nextPage();break;case"PrevPage":e.previousPage();break;case"ZoomViewIn":i||e.increaseScale();break;case"ZoomViewOut":i||e.decreaseScale();break;case"WillPrintFinished":this.#Ph?.resolve(),this.#Ph=null}return}if(i&&t.focus)return;delete t.id,delete t.siblings;const o=n?[s,...n]:[s];for(const e of o){const i=document.querySelector(`[data-element-id="${e}"]`);i?i.dispatchEvent(new CustomEvent("updatefromsandbox",{detail:t})):this.#xh?.annotationStorage.setValue(e,t)}}async#Lh(t,e=!1){const i=this.#xh,s=this._visitedPages;if(e&&(this.#wh=Promise.withResolvers()),!this.#wh)return;const n=this.#Sh.getPageView(t-1);if(n?.renderingState!==Bn.FINISHED)return void this._pageOpenPending.add(t);this._pageOpenPending.delete(t);const r=(async()=>{const e=await(s.has(t)?null:n.pdfPage?.getJSActions());i===this.#xh&&await(this.#Eh?.dispatchEventInSandbox({id:"page",name:"PageOpen",pageNumber:t,actions:e}))})();s.set(t,r)}async#Ih(t){const e=this.#xh,i=this._visitedPages;if(!this.#wh)return;if(this._pageOpenPending.has(t))return;const s=i.get(t);s&&(i.set(t,null),await s,e===this.#xh&&await(this.#Eh?.dispatchEventInSandbox({id:"page",name:"PageClose",pageNumber:t})))}#Th(){if(this.#yh=Promise.withResolvers(),this.#Eh)throw new Error("#initScripting: Scripting already exists.");return this.#_h.createScripting()}async#Mh(){if(!this.#Eh)return this.#xh=null,void this.#yh?.resolve();this.#wh&&(await Promise.race([this.#wh.promise,new Promise((t=>{setTimeout(t,1e3)}))]).catch((()=>{})),this.#wh=null),this.#xh=null;try{await this.#Eh.destroySandbox()}catch{}this.#Ph?.reject(new Error("Scripting destroyed.")),this.#Ph=null,this.#tl?.abort(),this.#tl=null,this._pageOpenPending.clear(),this._visitedPages.clear(),this.#Eh=null,this.#Ch=!1,this.#yh?.resolve()}}class wl extends vl{constructor(t){t.externalServices||window.addEventListener("updatefromsandbox",(e=>{t.eventBus.dispatch("updatefromsandbox",{source:window,detail:e.detail})})),t.externalServices||={createScripting:()=>new bl(t.sandboxBundleSrc)},t.docProperties||=t=>async function(t){const e="".split("#",1)[0];let{info:i,metadata:s,contentDispositionFilename:n,contentLength:r}=await t.getMetadata();if(!r){const{length:e}=await t.getDownloadInfo();r=e}return{...i,baseURL:e,filesize:r,filename:n||Yr(""),metadata:s?.getRaw(),authors:s?.get("dc:creator"),numPages:t.numPages,URL:""}}(t),super(t)}}let yl=class{constructor(){this.pdfViewer=null,this.pdfThumbnailViewer=null,this.onIdle=null,this.highestPriorityPage=null,this.idleTimeout=null,this.printing=!1,this.isThumbnailViewEnabled=!1,Object.defineProperty(this,"hasViewer",{value:()=>!!this.pdfViewer})}setViewer(t){this.pdfViewer=t}setThumbnailViewer(t){this.pdfThumbnailViewer=t}isHighestPriority(t){return this.highestPriorityPage===t.renderingId}renderHighestPriority(t){this.idleTimeout&&(clearTimeout(this.idleTimeout),this.idleTimeout=null),this.pdfViewer.forceRendering(t)||this.isThumbnailViewEnabled&&this.pdfThumbnailViewer?.forceRendering()||this.printing||this.onIdle&&(this.idleTimeout=setTimeout(this.onIdle.bind(this),3e4))}getHighestPriority(t,e,i,s=!1){const n=t.views,r=n.length;if(0===r)return null;for(let t=0;t<r;t++){const e=n[t].view;if(!this.isViewFinished(e))return e}const a=t.first.id,o=t.last.id;if(o-a+1>r){const s=t.ids;for(let t=1,n=o-a;t<n;t++){const n=i?a+t:o-t;if(s.has(n))continue;const r=e[n-1];if(!this.isViewFinished(r))return r}}let l=i?o:a-2,h=e[l];return h&&!this.isViewFinished(h)||s&&(l+=i?1:-1,h=e[l],h&&!this.isViewFinished(h))?h:null}isViewFinished(t){return t.renderingState===Bn.FINISHED}renderView(t){switch(t.renderingState){case Bn.FINISHED:return!1;case Bn.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case Bn.RUNNING:this.highestPriorityPage=t.renderingId;break;case Bn.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally((()=>{this.renderHighestPriority()})).catch((t=>{t instanceof ga||console.error("renderView:",t)}))}return!0}};const Al=1e4,_l=5e3,xl=250;function Sl(t){return Object.values(Or).includes(t)&&t!==Or.DISABLE}class Cl{#Dh=new Set;#Rh=0;constructor(t){this.#Rh=t}push(t){const e=this.#Dh;e.has(t)&&e.delete(t),e.add(t),e.size>this.#Rh&&this.#Nh()}resize(t,e=null){this.#Rh=t;const i=this.#Dh;if(e){const t=i.size;let s=1;for(const n of i)if(e.has(n.id)&&(i.delete(n),i.add(n)),++s>t)break}for(;i.size>this.#Rh;)this.#Nh()}has(t){return this.#Dh.has(t)}[Symbol.iterator](){return this.#Dh.keys()}#Nh(){const t=this.#Dh.keys().next().value;t?.destroy(),this.#Dh.delete(t)}}class El{#Fh=null;#L=null;#Oh=null;#Bh=Or.NONE;#jh=null;#ql=Vr.ENABLE_FORMS;#Vh=null;#Hh=null;#li=!1;#U=!1;#Vl=!1;#$=!1;#W=!1;#tl=null;#nt=null;#zh=null;#Uh=null;#$h=!1;#Wh=null;#Gh=!1;#qh=0;#Xh=new ResizeObserver(this.#Kh.bind(this));#Yh=null;#Qh=null;#Jh=!0;#nh=$n;constructor(t){const e="4.10.38";if(xa!==e)throw new Error(`The API version "${xa}" does not match the Viewer version "${e}".`);if(this.container=t.container,this.viewer=t.viewer||t.container.firstElementChild,"DIV"!==this.container?.tagName||"DIV"!==this.viewer?.tagName)throw new Error("Invalid `container` and/or `viewer` option.");if(this.container.offsetParent&&"absolute"!==getComputedStyle(this.container).position)throw new Error("The `container` must be absolutely positioned.");this.#Xh.observe(this.container),this.eventBus=t.eventBus,this.linkService=t.linkService||new Dr,this.downloadManager=t.downloadManager||null,this.findController=t.findController||null,this.#L=t.altTextManager||null,this.#Hh=t.editorUndoBar||null,this.findController&&(this.findController.onIsPageVisible=t=>this._getVisiblePages().ids.has(t)),this._scriptingManager=t.scriptingManager||null,this.#nh=t.textLayerMode??$n,this.#ql=t.annotationMode??Vr.ENABLE_FORMS,this.#Bh=t.annotationEditorMode??Or.NONE,this.#Oh=t.annotationEditorHighlightColors||null,this.#U=!0===t.enableHighlightFloatingButton,this.#$=!0===t.enableUpdatedAddImage,this.#W=!0===t.enableNewAltTextWhenAddingImage,this.imageResourcesPath=t.imageResourcesPath||"",this.enablePrintAutoRotate=t.enablePrintAutoRotate||!1,this.removePageBorders=t.removePageBorders||!1,this.maxCanvasPixels=t.maxCanvasPixels,this.l10n=t.l10n,this.l10n||=new Go,this.#Vl=t.enablePermissions||!1,this.pageColors=t.pageColors||null,this.#nt=t.mlManager||null,this.#li=t.enableHWA||!1,this.#Jh=!1!==t.supportsPinchToZoom,this.defaultRenderingQueue=!t.renderingQueue,this.defaultRenderingQueue?(this.renderingQueue=new yl,this.renderingQueue.setViewer(this)):this.renderingQueue=t.renderingQueue;const{abortSignal:i}=t;i?.addEventListener("abort",(()=>{this.#Xh.disconnect(),this.#Xh=null}),{once:!0}),this.scroll=function(t,e,i){const s=function(i){r||(r=window.requestAnimationFrame((function(){r=null;const i=t.scrollLeft,s=n.lastX;i!==s&&(n.right=i>s),n.lastX=i;const a=t.scrollTop,o=n.lastY;a!==o&&(n.down=a>o),n.lastY=a,e(n)})))},n={right:!0,down:!0,lastX:t.scrollLeft,lastY:t.scrollTop,_eventHandler:s};let r=null;return t.addEventListener("scroll",s,{useCapture:!0,signal:i}),i?.addEventListener("abort",(()=>window.cancelAnimationFrame(r)),{once:!0}),n}(this.container,this._scrollUpdate.bind(this),i),this.presentationModeState=jn,this._resetView(),this.removePageBorders&&this.viewer.classList.add("removePageBorders"),this.#Zh(),this.eventBus._on("thumbnailrendered",(({pageNumber:t,pdfPage:e})=>{const i=this._pages[t-1];this.#Fh.has(i)||e?.cleanup()})),t.l10n||this.l10n.translate(this.container)}get pagesCount(){return this._pages.length}getPageView(t){return this._pages[t]}getCachedPageViews(){return new Set(this.#Fh)}get pageViewsReady(){return this._pages.every((t=>t?.pdfPage))}get renderForms(){return this.#ql===Vr.ENABLE_FORMS}get enableScripting(){return!!this._scriptingManager}get currentPageNumber(){return this._currentPageNumber}set currentPageNumber(t){if(!Number.isInteger(t))throw new Error("Invalid page number.");this.pdfDocument&&(this._setCurrentPageNumber(t,!0)||console.error(`currentPageNumber: "${t}" is not a valid page.`))}_setCurrentPageNumber(t,e=!1){if(this._currentPageNumber===t)return e&&this.#td(),!0;if(!(0<t&&t<=this.pagesCount))return!1;const i=this._currentPageNumber;return this._currentPageNumber=t,this.eventBus.dispatch("pagechanging",{source:this,pageNumber:t,pageLabel:this._pageLabels?.[t-1]??null,previous:i}),e&&this.#td(),!0}get currentPageLabel(){return this._pageLabels?.[this._currentPageNumber-1]??null}set currentPageLabel(t){if(!this.pdfDocument)return;let e=0|t;if(this._pageLabels){const i=this._pageLabels.indexOf(t);i>=0&&(e=i+1)}this._setCurrentPageNumber(e,!0)||console.error(`currentPageLabel: "${t}" is not a valid page.`)}get currentScale(){return 0!==this._currentScale?this._currentScale:1}set currentScale(t){if(isNaN(t))throw new Error("Invalid numeric scale.");this.pdfDocument&&this.#ed(t,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(t){this.pdfDocument&&this.#ed(t,{noScroll:!1})}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!er(t))throw new Error("Invalid pages rotation angle.");if(!this.pdfDocument)return;if((t%=360)<0&&(t+=360),this._pagesRotation===t)return;this._pagesRotation=t;const e=this._currentPageNumber;this.refresh(!0,{rotation:t}),this._currentScaleValue&&this.#ed(this._currentScaleValue,{noScroll:!0}),this.eventBus.dispatch("rotationchanging",{source:this,pagesRotation:t,pageNumber:e}),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 _layerProperties(){const t=this;return ma(this,"_layerProperties",{get annotationEditorUIManager(){return t.#jh},get annotationStorage(){return t.pdfDocument?.annotationStorage},get downloadManager(){return t.downloadManager},get enableScripting(){return!!t._scriptingManager},get fieldObjectsPromise(){return t.pdfDocument?.getFieldObjects()},get findController(){return t.findController},get hasJSActionsPromise(){return t.pdfDocument?.hasJSActions()},get linkService(){return t.linkService}})}#id(t){const e={annotationEditorMode:this.#Bh,annotationMode:this.#ql,textLayerMode:this.#nh};return t?(t.includes(ua.COPY)||this.#nh!==$n||(e.textLayerMode=Wn),t.includes(ua.MODIFY_CONTENTS)||(e.annotationEditorMode=Or.DISABLE),t.includes(ua.MODIFY_ANNOTATIONS)||t.includes(ua.FILL_INTERACTIVE_FORMS)||this.#ql!==Vr.ENABLE_FORMS||(e.annotationMode=Vr.ENABLE),e):e}async#sd(t){if("hidden"===document.visibilityState||!this.container.offsetParent||0===this._getVisiblePages().views.length)return;const e=Promise.withResolvers(),i=new AbortController;document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&e.resolve()}),{signal:"function"==typeof AbortSignal.any?AbortSignal.any([t,i.signal]):t}),await Promise.race([this._onePageRenderedCapability.promise,e.promise]),i.abort()}async getAllText(){const t=[],e=[];for(let i=1,s=this.pdfDocument.numPages;i<=s;++i){if(this.#Gh)return null;e.length=0;const s=await this.pdfDocument.getPage(i),{items:n}=await s.getTextContent();for(const t of n)t.str&&e.push(t.str),t.hasEOL&&e.push("\n");t.push(Qn(e.join("")))}return t.join("\n")}#nd(t,e){const i=document.getSelection(),{focusNode:s,anchorNode:n}=i;if(n&&s&&i.containsNode(this.#Wh)){if(this.#$h||t===Wn)return void ba(e);this.#$h=!0;const{classList:i}=this.viewer;i.add("copyAll");const s=new AbortController;window.addEventListener("keydown",(t=>this.#Gh="Escape"===t.key),{signal:s.signal}),this.getAllText().then((async t=>{null!==t&&await navigator.clipboard.writeText(t)})).catch((t=>{console.warn(`Something goes wrong when extracting the text: ${t.message}`)})).finally((()=>{this.#$h=!1,this.#Gh=!1,s.abort(),i.remove("copyAll")})),ba(e)}}setDocument(t){if(this.pdfDocument&&(this.eventBus.dispatch("pagesdestroy",{source:this}),this._cancelRendering(),this._resetView(),this.findController?.setDocument(null),this._scriptingManager?.setDocument(null),this.#jh?.destroy(),this.#jh=null),this.pdfDocument=t,!t)return;const e=t.numPages,i=t.getPage(1),s=t.getOptionalContentConfig({intent:"display"}),n=this.#Vl?t.getPermissions():Promise.resolve(),{eventBus:r,pageColors:a,viewer:o}=this;this.#tl=new AbortController;const{signal:l}=this.#tl;if(e>Al){console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");const t=this._scrollMode=Gn.PAGE;r.dispatch("scrollmodechanged",{source:this,mode:t})}this._pagesCapability.promise.then((()=>{r.dispatch("pagesloaded",{source:this,pagesCount:e})}),(()=>{}));r._on("pagerender",(t=>{const e=this._pages[t.pageNumber-1];e&&this.#Fh.push(e)}),{signal:l});const h=t=>{t.cssTransform||(this._onePageRenderedCapability.resolve({timestamp:t.timestamp}),r._off("pagerendered",h))};r._on("pagerendered",h,{signal:l}),Promise.all([i,n]).then((([i,n])=>{if(t!==this.pdfDocument)return;this._firstPageCapability.resolve(i),this._optionalContentConfigPromise=s;const{annotationEditorMode:h,annotationMode:d,textLayerMode:c}=this.#id(n);if(c!==Un){const t=this.#Wh=document.createElement("div");t.id="hiddenCopyElement",o.before(t)}if("function"==typeof AbortSignal.any&&h!==Or.DISABLE){const e=h;t.isPureXfa?console.warn("Warning: XFA-editing is not implemented."):Sl(e)?(this.#jh=new Br(this.container,o,this.#L,r,t,a,this.#Oh,this.#U,this.#$,this.#W,this.#nt,this.#Hh,this.#Jh),r.dispatch("annotationeditoruimanager",{source:this,uiManager:this.#jh}),e!==Or.NONE&&(e===Or.STAMP&&this.#nt?.loadModel("altText"),this.#jh.updateMode(e))):console.error(`Invalid AnnotationEditor mode: ${e}`)}const u=this._scrollMode===Gn.PAGE?null:o,p=this.currentScale,g=i.getViewport({scale:p*pa.PDF_TO_CSS_UNITS});o.style.setProperty("--scale-factor",g.scale),a?.background&&o.style.setProperty("--page-bg-color",a.background),"CanvasText"!==a?.foreground&&"Canvas"!==a?.background||(o.style.setProperty("--hcm-highlight-filter",t.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight")),o.style.setProperty("--hcm-highlight-selected-filter",t.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","ButtonText")));for(let t=1;t<=e;++t){const e=new ml({container:u,eventBus:r,id:t,scale:p,defaultViewport:g.clone(),optionalContentConfigPromise:s,renderingQueue:this.renderingQueue,textLayerMode:c,annotationMode:d,imageResourcesPath:this.imageResourcesPath,maxCanvasPixels:this.maxCanvasPixels,pageColors:a,l10n:this.l10n,layerProperties:this._layerProperties,enableHWA:this.#li});this._pages.push(e)}this._pages[0]?.setPdfPage(i),this._scrollMode===Gn.PAGE?this.#rd():this._spreadMode!==qn.NONE&&this._updateSpreadMode(),this.#sd(l).then((async()=>{if(t!==this.pdfDocument)return;if(this.findController?.setDocument(t),this._scriptingManager?.setDocument(t),this.#Wh&&document.addEventListener("copy",this.#nd.bind(this,c),{signal:l}),this.#jh&&r.dispatch("annotationeditormodechanged",{source:this,mode:this.#Bh}),t.loadingParams.disableAutoFetch||e>_l)return void this._pagesCapability.resolve();let i=e-1;if(i<=0)this._pagesCapability.resolve();else for(let s=2;s<=e;++s){const e=t.getPage(s).then((t=>{const e=this._pages[s-1];e.pdfPage||e.setPdfPage(t),0==--i&&this._pagesCapability.resolve()}),(t=>{console.error(`Unable to get page ${s} to initialize viewer`,t),0==--i&&this._pagesCapability.resolve()}));s%xl==0&&await e}})),r.dispatch("pagesinit",{source:this}),t.getMetadata().then((({info:e})=>{t===this.pdfDocument&&e.Language&&(o.lang=e.Language)})),this.defaultRenderingQueue&&this.update()})).catch((t=>{console.error("Unable to initialize viewer",t),this._pagesCapability.reject(t)}))}setPageLabels(t){if(this.pdfDocument){t?Array.isArray(t)&&this.pdfDocument.numPages===t.length?this._pageLabels=t:(this._pageLabels=null,console.error("setPageLabels: Invalid page labels.")):this._pageLabels=null;for(let t=0,e=this._pages.length;t<e;t++)this._pages[t].setPageLabel(this._pageLabels?.[t]??null)}}_resetView(){this._pages=[],this._currentPageNumber=1,this._currentScale=0,this._currentScaleValue=null,this._pageLabels=null,this.#Fh=new Cl(10),this._location=null,this._pagesRotation=0,this._optionalContentConfigPromise=null,this._firstPageCapability=Promise.withResolvers(),this._onePageRenderedCapability=Promise.withResolvers(),this._pagesCapability=Promise.withResolvers(),this._scrollMode=Gn.VERTICAL,this._previousScrollMode=Gn.UNKNOWN,this._spreadMode=qn.NONE,this.#Yh={previousPageNumber:1,scrollDown:!0,pages:[]},this.#tl?.abort(),this.#tl=null,this.viewer.textContent="",this._updateScrollMode(),this.viewer.removeAttribute("lang"),this.#Wh?.remove(),this.#Wh=null,this.#ad()}#rd(){if(this._scrollMode!==Gn.PAGE)throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");const t=this._currentPageNumber,e=this.#Yh,i=this.viewer;if(i.textContent="",e.pages.length=0,this._spreadMode!==qn.NONE||this.isInPresentationMode){const s=new Set,n=this._spreadMode-1;-1===n?s.add(t-1):t%2!==n?(s.add(t-1),s.add(t)):(s.add(t-2),s.add(t-1));const r=document.createElement("div");if(r.className="spread",this.isInPresentationMode){const t=document.createElement("div");t.className="dummyPage",r.append(t)}for(const t of s){const i=this._pages[t];i&&(r.append(i.div),e.pages.push(i))}i.append(r)}else{const s=this._pages[t-1];i.append(s.div),e.pages.push(s)}e.scrollDown=t>=e.previousPageNumber,e.previousPageNumber=t}_scrollUpdate(){0!==this.pagesCount&&this.update()}#od(t,e=null){const{div:i,id:s}=t;if(this._currentPageNumber!==s&&this._setCurrentPageNumber(s),this._scrollMode===Gn.PAGE&&(this.#rd(),this.update()),!e&&!this.isInPresentationMode){const t=i.offsetLeft+i.clientLeft,s=t+i.clientWidth,{scrollLeft:n,clientWidth:r}=this.container;(this._scrollMode===Gn.HORIZONTAL||t<n||s>n+r)&&(e={left:0,top:0})}Xn(i,e),!this._currentScaleValue&&this._location&&(this._location=null)}#ld(t){return t===this._currentScale||Math.abs(t-this._currentScale)<1e-15}#hd(t,e,{noScroll:i=!1,preset:s=!1,drawingDelay:n=-1,origin:r=null}){if(this._currentScaleValue=e.toString(),this.#ld(t))return void(s&&this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:e}));this.viewer.style.setProperty("--scale-factor",t*pa.PDF_TO_CSS_UNITS);const a=n>=0&&n<1e3;this.refresh(!0,{scale:t,drawingDelay:a?n:-1}),a&&(this.#Qh=setTimeout((()=>{this.#Qh=null,this.refresh()}),n));const o=this._currentScale;if(this._currentScale=t,!i){let e,i=this._currentPageNumber;if(!this._location||this.isInPresentationMode||this.isChangingPresentationMode||(i=this._location.pageNumber,e=[null,{name:"XYZ"},this._location.left,this._location.top,null]),this.scrollPageIntoView({pageNumber:i,destArray:e,allowNegativeOffset:!0}),Array.isArray(r)){const e=t/o-1,[i,s]=this.containerTopLeft;this.container.scrollLeft+=(r[0]-s)*e,this.container.scrollTop+=(r[1]-i)*e}}this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:s?e:void 0}),this.defaultRenderingQueue&&this.update()}get#dd(){return this._spreadMode!==qn.NONE&&this._scrollMode!==Gn.HORIZONTAL?2:1}#ed(t,e){let i=parseFloat(t);if(i>0)e.preset=!1,this.#hd(i,t,e);else{const s=this._pages[this._currentPageNumber-1];if(!s)return;let n=40,r=5;this.isInPresentationMode?(n=r=4,this._spreadMode!==qn.NONE&&(n*=2)):this.removePageBorders?n=r=0:this._scrollMode===Gn.HORIZONTAL&&([n,r]=[r,n]);const a=(this.container.clientWidth-n)/s.width*s.scale/this.#dd,o=(this.container.clientHeight-r)/s.height*s.scale;switch(t){case"page-actual":i=1;break;case"page-width":i=a;break;case"page-height":i=o;break;case"page-fit":i=Math.min(a,o);break;case"auto":const e=ir(s)?a:Math.min(o,a);i=Math.min(1.25,e);break;default:return void console.error(`#setScale: "${t}" is an unknown zoom value.`)}e.preset=!0,this.#hd(i,t,e)}}#td(){const t=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&this.#ed(this._currentScaleValue,{noScroll:!0}),this.#od(t)}pageLabelToPageNumber(t){if(!this._pageLabels)return null;const e=this._pageLabels.indexOf(t);return e<0?null:e+1}scrollPageIntoView({pageNumber:t,destArray:e=null,allowNegativeOffset:i=!1,ignoreDestinationZoom:s=!1}){if(!this.pdfDocument)return;const n=Number.isInteger(t)&&this._pages[t-1];if(!n)return void console.error(`scrollPageIntoView: "${t}" is not a valid pageNumber parameter.`);if(this.isInPresentationMode||!e)return void this._setCurrentPageNumber(t,!0);let r,a,o=0,l=0,h=0,d=0;const c=n.rotation%180!=0,u=(c?n.height:n.width)/n.scale/pa.PDF_TO_CSS_UNITS,p=(c?n.width:n.height)/n.scale/pa.PDF_TO_CSS_UNITS;let g=0;switch(e[1].name){case"XYZ":o=e[2],l=e[3],g=e[4],o=null!==o?o:0,l=null!==l?l:p;break;case"Fit":case"FitB":g="page-fit";break;case"FitH":case"FitBH":l=e[2],g="page-width",null===l&&this._location?(o=this._location.left,l=this._location.top):("number"!=typeof l||l<0)&&(l=p);break;case"FitV":case"FitBV":o=e[2],h=u,d=p,g="page-height";break;case"FitR":o=e[2],l=e[3],h=e[4]-o,d=e[5]-l;let t=40,i=5;this.removePageBorders&&(t=i=0),r=(this.container.clientWidth-t)/h/pa.PDF_TO_CSS_UNITS,a=(this.container.clientHeight-i)/d/pa.PDF_TO_CSS_UNITS,g=Math.min(Math.abs(r),Math.abs(a));break;default:return void console.error(`scrollPageIntoView: "${e[1].name}" is not a valid destination type.`)}if(s||(g&&g!==this._currentScale?this.currentScaleValue=g:0===this._currentScale&&(this.currentScaleValue="auto")),"page-fit"===g&&!e[4])return void this.#od(n);const f=[n.viewport.convertToViewportPoint(o,l),n.viewport.convertToViewportPoint(o+h,l+d)];let m=Math.min(f[0][0],f[1][0]),b=Math.min(f[0][1],f[1][1]);i||(m=Math.max(m,0),b=Math.max(b,0)),this.#od(n,{left:m,top:b})}_updateLocation(t){const e=this._currentScale,i=this._currentScaleValue,s=parseFloat(i)===e?Math.round(1e4*e)/100:i,n=t.id,r=this._pages[n-1],a=this.container,o=r.getPagePoint(a.scrollLeft-t.x,a.scrollTop-t.y),l=Math.round(o[0]),h=Math.round(o[1]);let d=`#page=${n}`;this.isInPresentationMode||(d+=`&zoom=${s},${l},${h}`),this._location={pageNumber:n,scale:s,top:h,left:l,rotation:this._pagesRotation,pdfOpenParams:d}}update(){const t=this._getVisiblePages(),e=t.views,i=e.length;if(0===i)return;const s=Math.max(10,2*i+1);this.#Fh.resize(s,t.ids),this.renderingQueue.renderHighestPriority(t);const n=this._spreadMode===qn.NONE&&(this._scrollMode===Gn.PAGE||this._scrollMode===Gn.VERTICAL),r=this._currentPageNumber;let a=!1;for(const t of e){if(t.percent<100)break;if(t.id===r&&n){a=!0;break}}this._setCurrentPageNumber(a?r:e[0].id),this._updateLocation(t.first),this.eventBus.dispatch("updateviewarea",{source:this,location:this._location})}#cd(){const t=this._getVisiblePages(),e=[],{ids:i,views:s}=t;for(const t of s){const{view:s}=t;s.hasEditableAnnotations()?e.push(t):i.delete(s.id)}return 0===e.length?null:(this.renderingQueue.renderHighestPriority({first:e[0],last:e.at(-1),views:e,ids:i}),i)}containsElement(t){return this.container.contains(t)}focus(){this.container.focus()}get _isContainerRtl(){return"rtl"===getComputedStyle(this.container).direction}get isInPresentationMode(){return this.presentationModeState===zn}get isChangingPresentationMode(){return this.presentationModeState===Hn}get isHorizontalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollWidth>this.container.clientWidth}get isVerticalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollHeight>this.container.clientHeight}_getVisiblePages(){const t=this._scrollMode===Gn.PAGE?this.#Yh.pages:this._pages,e=this._scrollMode===Gn.HORIZONTAL,i=e&&this._isContainerRtl;return function({scrollEl:t,views:e,sortByVisibility:i=!1,horizontal:s=!1,rtl:n=!1}){const r=t.scrollTop,a=r+t.clientHeight,o=t.scrollLeft,l=o+t.clientWidth,h=[],d=new Set,c=e.length;let u=Jn(e,s?function(t){const e=t.div,i=e.offsetLeft+e.clientLeft,s=i+e.clientWidth;return n?i<l:s>o}:function(t){const e=t.div;return e.offsetTop+e.clientTop+e.clientHeight>r});u>0&&u<c&&!s&&(u=function(t,e,i){if(t<2)return t;let s=e[t].div,n=s.offsetTop+s.clientTop;n>=i&&(s=e[t-1].div,n=s.offsetTop+s.clientTop);for(let i=t-2;i>=0&&(s=e[i].div,!(s.offsetTop+s.clientTop+s.clientHeight<=n));--i)t=i;return t}(u,e,r));let p=s?l:-1;for(let t=u;t<c;t++){const i=e[t],n=i.div,c=n.offsetLeft+n.clientLeft,u=n.offsetTop+n.clientTop,g=n.clientWidth,f=n.clientHeight,m=c+g,b=u+f;if(-1===p)b>=a&&(p=b);else if((s?c:u)>p)break;if(b<=r||u>=a||m<=o||c>=l)continue;const v=Math.max(0,r-u)+Math.max(0,b-a),w=(g-(Math.max(0,o-c)+Math.max(0,m-l)))/g,y=(f-v)/f*w*100|0;h.push({id:i.id,x:c,y:u,view:i,percent:y,widthPercent:100*w|0}),d.add(i.id)}const g=h[0],f=h.at(-1);return i&&h.sort((function(t,e){const i=t.percent-e.percent;return Math.abs(i)>.001?-i:t.id-e.id})),{first:g,last:f,views:h,ids:d}}({scrollEl:this.container,views:t,sortByVisibility:!0,horizontal:e,rtl:i})}cleanup(){for(const t of this._pages)t.renderingState!==Bn.FINISHED&&t.reset()}_cancelRendering(){for(const t of this._pages)t.cancelRendering()}async#ud(t){if(t.pdfPage)return t.pdfPage;try{const e=await this.pdfDocument.getPage(t.id);return t.pdfPage||t.setPdfPage(e),e}catch(t){return console.error("Unable to get page for page view",t),null}}#pd(t){if(1===t.first?.id)return!0;if(t.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case Gn.PAGE:return this.#Yh.scrollDown;case Gn.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(t){const e=t||this._getVisiblePages(),i=this.#pd(e),s=this._spreadMode!==qn.NONE&&this._scrollMode!==Gn.HORIZONTAL,n=this.renderingQueue.getHighestPriority(e,this._pages,i,s);return!!n&&(this.#ud(n).then((()=>{this.renderingQueue.renderView(n)})),!0)}get hasEqualPageSizes(){const t=this._pages[0];for(let e=1,i=this._pages.length;e<i;++e){const i=this._pages[e];if(i.width!==t.width||i.height!==t.height)return!1}return!0}getPagesOverview(){let t;return this._pages.map((e=>{const i=e.pdfPage.getViewport({scale:1}),s=ir(i);if(void 0===t)t=s;else if(this.enablePrintAutoRotate&&s!==t)return{width:i.height,height:i.width,rotation:(i.rotation-90)%360};return{width:i.width,height:i.height,rotation:i.rotation}}))}get optionalContentConfigPromise(){return this.pdfDocument?this._optionalContentConfigPromise?this._optionalContentConfigPromise:(console.error("optionalContentConfigPromise: Not initialized yet."),this.pdfDocument.getOptionalContentConfig({intent:"display"})):Promise.resolve(null)}set optionalContentConfigPromise(t){if(!(t instanceof Promise))throw new Error(`Invalid optionalContentConfigPromise: ${t}`);this.pdfDocument&&this._optionalContentConfigPromise&&(this._optionalContentConfigPromise=t,this.refresh(!1,{optionalContentConfigPromise:t}),this.eventBus.dispatch("optionalcontentconfigchanged",{source:this,promise:t}))}get scrollMode(){return this._scrollMode}set scrollMode(t){if(this._scrollMode!==t){if(!function(t){return Number.isInteger(t)&&Object.values(Gn).includes(t)&&t!==Gn.UNKNOWN}(t))throw new Error(`Invalid scroll mode: ${t}`);this.pagesCount>Al||(this._previousScrollMode=this._scrollMode,this._scrollMode=t,this.eventBus.dispatch("scrollmodechanged",{source:this,mode:t}),this._updateScrollMode(this._currentPageNumber))}}_updateScrollMode(t=null){const e=this._scrollMode,i=this.viewer;i.classList.toggle("scrollHorizontal",e===Gn.HORIZONTAL),i.classList.toggle("scrollWrapped",e===Gn.WRAPPED),this.pdfDocument&&t&&(e===Gn.PAGE?this.#rd():this._previousScrollMode===Gn.PAGE&&this._updateSpreadMode(),this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#ed(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}get spreadMode(){return this._spreadMode}set spreadMode(t){if(this._spreadMode!==t){if(!function(t){return Number.isInteger(t)&&Object.values(qn).includes(t)&&t!==qn.UNKNOWN}(t))throw new Error(`Invalid spread mode: ${t}`);this._spreadMode=t,this.eventBus.dispatch("spreadmodechanged",{source:this,mode:t}),this._updateSpreadMode(this._currentPageNumber)}}_updateSpreadMode(t=null){if(!this.pdfDocument)return;const e=this.viewer,i=this._pages;if(this._scrollMode===Gn.PAGE)this.#rd();else if(e.textContent="",this._spreadMode===qn.NONE)for(const t of this._pages)e.append(t.div);else{const t=this._spreadMode-1;let s=null;for(let n=0,r=i.length;n<r;++n)null===s?(s=document.createElement("div"),s.className="spread",e.append(s)):n%2===t&&(s=s.cloneNode(!1),e.append(s)),s.append(i[n].div)}t&&(this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#ed(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}_getPageAdvance(t,e=!1){switch(this._scrollMode){case Gn.WRAPPED:{const{views:i}=this._getVisiblePages(),s=new Map;for(const{id:t,y:e,percent:n,widthPercent:r}of i){if(0===n||r<100)continue;let i=s.get(e);i||s.set(e,i||=[]),i.push(t)}for(const i of s.values()){const s=i.indexOf(t);if(-1===s)continue;const n=i.length;if(1===n)break;if(e)for(let e=s-1,n=0;e>=n;e--){const s=i[e],n=i[e+1]-1;if(s<n)return t-n}else for(let e=s+1,r=n;e<r;e++){const s=i[e],n=i[e-1]+1;if(s>n)return n-t}if(e){const e=i[0];if(e<t)return t-e+1}else{const e=i[n-1];if(e>t)return e-t+1}break}break}case Gn.HORIZONTAL:break;case Gn.PAGE:case Gn.VERTICAL:{if(this._spreadMode===qn.NONE)break;const i=this._spreadMode-1;if(e&&t%2!==i)break;if(!e&&t%2===i)break;const{views:s}=this._getVisiblePages(),n=e?t-1:t+1;for(const{id:t,percent:e,widthPercent:i}of s)if(t===n){if(e>0&&100===i)return 2;break}break}}return 1}nextPage(){const t=this._currentPageNumber,e=this.pagesCount;if(t>=e)return!1;const i=this._getPageAdvance(t,!1)||1;return this.currentPageNumber=Math.min(t+i,e),!0}previousPage(){const t=this._currentPageNumber;if(t<=1)return!1;const e=this._getPageAdvance(t,!0)||1;return this.currentPageNumber=Math.max(t-e,1),!0}updateScale({drawingDelay:t,scaleFactor:e=null,steps:i=null,origin:s}){if(null===i&&null===e)throw new Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided.");if(!this.pdfDocument)return;let n=this._currentScale;if(e>0&&1!==e)n=Math.round(n*e*100)/100;else if(i){const t=i>0?1.1:1/1.1,e=i>0?Math.ceil:Math.floor;i=Math.abs(i);do{n=e(10*(n*t).toFixed(2))/10}while(--i>0)}n=Math.max(.1,Math.min(10,n)),this.#ed(n,{noScroll:!1,drawingDelay:t,origin:s})}increaseScale(t={}){this.updateScale({...t,steps:t.steps??1})}decreaseScale(t={}){this.updateScale({...t,steps:-(t.steps??1)})}#Zh(t=this.container.clientHeight){t!==this.#qh&&(this.#qh=t,sr.setProperty("--viewer-container-height",`${t}px`))}#Kh(t){for(const e of t)if(e.target===this.container){this.#Zh(Math.floor(e.borderBoxSize[0].blockSize)),this.#Vh=null;break}}get containerTopLeft(){return this.#Vh||=[this.container.offsetTop,this.container.offsetLeft]}#ad(){this.#zh?.abort(),this.#zh=null,null!==this.#Uh&&(clearTimeout(this.#Uh),this.#Uh=null)}get annotationEditorMode(){return this.#jh?this.#Bh:Or.DISABLE}set annotationEditorMode({mode:t,editId:e=null,isFromKeyboard:i=!1}){if(!this.#jh)throw new Error("The AnnotationEditor is not enabled.");if(this.#Bh===t)return;if(!Sl(t))throw new Error(`Invalid AnnotationEditor mode: ${t}`);if(!this.pdfDocument)return;t===Or.STAMP&&this.#nt?.loadModel("altText");const{eventBus:s}=this,n=()=>{this.#ad(),this.#Bh=t,this.#jh.updateMode(t,e,i),s.dispatch("annotationeditormodechanged",{source:this,mode:t})};if(t===Or.NONE||this.#Bh===Or.NONE){const e=t!==Or.NONE;e||this.pdfDocument.annotationStorage.resetModifiedIds();for(const t of this._pages)t.toggleEditingMode(e);const i=this.#cd();if(e&&i){this.#ad(),this.#zh=new AbortController;const t=AbortSignal.any([this.#tl.signal,this.#zh.signal]);return void s._on("pagerendered",(({pageNumber:t})=>{i.delete(t),0===i.size&&(this.#Uh=setTimeout(n,0))}),{signal:t})}}n()}refresh(t=!1,e=Object.create(null)){if(this.pdfDocument){for(const t of this._pages)t.update(e);null!==this.#Qh&&(clearTimeout(this.#Qh),this.#Qh=null),t||this.update()}}}class Pl extends El{_resetView(){super._resetView(),this._scrollMode=Gn.PAGE,this._spreadMode=qn.NONE}set scrollMode(t){}_updateScrollMode(){}set spreadMode(t){}_updateSpreadMode(){}}var Ml,Tl,kl,Il,Ll,Dl=On.DownloadManager,Rl=On.EventBus,Nl=On.GenericL10n,Fl=On.PDFFindController,Ol=On.PDFLinkService,Bl=On.PDFSinglePageViewer,jl=On.PDFViewer,Vl=On.SimpleLinkService,Hl=On.XfaLayerBuilder;function zl(t,e,i,s){return new(i||(i=Promise))((function(n,r){function a(t){try{l(s.next(t))}catch(t){r(t)}}function o(t){try{l(s.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}l((s=s.apply(t,e||[])).next())}))}function Ul(t,e,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(t):s?s.value:e.get(t)}function $l(t,e,i,s,n){if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n?n.value=i:e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError;const Wl={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},Gl={UNKNOWN:0,NORMAL:1,CHANGING:2,FULLSCREEN:3},ql={UNKNOWN:-1,NONE:0,THUMBS:1,OUTLINE:2,ATTACHMENTS:3,LAYERS:4},Xl={DISABLE:0,ENABLE:1,ENABLE_PERMISSIONS:2},Kl={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},Yl={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};class Ql{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}}function Jl(t,e,i=!1){let s=t.offsetParent;if(!s)return void console.error("offsetParent is not set -- cannot scroll");let n=t.offsetTop+t.clientTop,r=t.offsetLeft+t.clientLeft;for(;s.clientHeight===s.scrollHeight&&s.clientWidth===s.scrollWidth||i&&(s.classList.contains("markedContent")||"hidden"===getComputedStyle(s).overflow);)if(n+=s.offsetTop,r+=s.offsetLeft,s=s.offsetParent,!s)return;e&&(void 0!==e.top&&(n+=e.top),void 0!==e.left&&(r+=e.left,s.scrollLeft=r)),s.scrollTop=n}function Zl(t,e,i=void 0){const s=function(i){r||(r=window.requestAnimationFrame((function(){r=null;const i=t.scrollLeft,s=n.lastX;i!==s&&(n.right=i>s),n.lastX=i;const a=t.scrollTop,o=n.lastY;a!==o&&(n.down=a>o),n.lastY=a,e(n)})))},n={right:!0,down:!0,lastX:t.scrollLeft,lastY:t.scrollTop,_eventHandler:s};let r=null;return t.addEventListener("scroll",s,{useCapture:!0,signal:i}),null==i||i.addEventListener("abort",(()=>window.cancelAnimationFrame(r)),{once:!0}),n}const th=/[\x00-\x1F]/g;function eh(t,e,i=0){let s=i,n=t.length-1;if(n<0||!e(t[n]))return t.length;if(e(t[s]))return s;for(;s<n;){const i=s+n>>1;e(t[i])?n=i:s=i+1}return s}function ih({view:t,userUnit:e,rotate:i}){const[s,n,r,a]=t,o=i%180!=0,l=(r-s)/72*e,h=(a-n)/72*e;return{width:o?h:l,height:o?l:h}}function sh(t,e,i){if(t<2)return t;let s=e[t].div,n=s.offsetTop+s.clientTop;n>=i&&(s=e[t-1].div,n=s.offsetTop+s.clientTop);for(let i=t-2;i>=0&&(s=e[i].div,!(s.offsetTop+s.clientTop+s.clientHeight<=n));--i)t=i;return t}function nh({scrollEl:t,views:e,sortByVisibility:i=!1,horizontal:s=!1,rtl:n=!1}){const r=t.scrollTop,a=r+t.clientHeight,o=t.scrollLeft,l=o+t.clientWidth;const h=[],d=new Set,c=e.length;let u=eh(e,s?function(t){const e=t.div,i=e.offsetLeft+e.clientLeft,s=i+e.clientWidth;return n?i<l:s>o}:function(t){const e=t.div;return e.offsetTop+e.clientTop+e.clientHeight>r});u>0&&u<c&&!s&&(u=sh(u,e,r));let p=s?l:-1;for(let t=u;t<c;t++){const i=e[t],n=i.div,c=n.offsetLeft+n.clientLeft,u=n.offsetTop+n.clientTop,g=n.clientWidth,f=n.clientHeight,m=c+g,b=u+f;if(-1===p)b>=a&&(p=b);else if((s?c:u)>p)break;if(b<=r||u>=a||m<=o||c>=l)continue;const v=Math.max(0,r-u)+Math.max(0,b-a),w=(g-(Math.max(0,o-c)+Math.max(0,m-l)))/g,y=(f-v)/f*w*100|0;h.push({id:i.id,x:c,y:u,view:i,percent:y,widthPercent:100*w|0}),d.add(i.id)}const g=h[0],f=h.at(-1);return i&&h.sort((function(t,e){const i=t.percent-e.percent;return Math.abs(i)>.001?-i:t.id-e.id})),{first:g,last:f,views:h,ids:d}}function rh(t){let e=Math.hypot(t.deltaX,t.deltaY);const i=Math.atan2(t.deltaY,t.deltaX);return-.25*Math.PI<i&&i<.75*Math.PI&&(e=-e),e}function ah(t){const e=t.deltaMode;let i=rh(t);return e===WheelEvent.DOM_DELTA_PIXEL?i/=900:e===WheelEvent.DOM_DELTA_LINE&&(i/=30),i}function oh(t){return Number.isInteger(t)&&t%90==0}function lh(t){return Number.isInteger(t)&&Object.values(Kl).includes(t)&&t!==Kl.UNKNOWN}function hh(t){return Number.isInteger(t)&&Object.values(Yl).includes(t)&&t!==Yl.UNKNOWN}function dh(t){return t.width<=t.height}const ch=new Promise((function(t){window.requestAnimationFrame(t)})),uh=document.documentElement.style;Ml=new WeakMap,Tl=new WeakMap,kl=new WeakMap,Il=new WeakMap,Ll=new WeakMap;const ph=function(){const t=document.createElement("div");return t.style.width="round(down, calc(1.6666666666666665 * 792px), 1px)","calc(1320px)"===t.style.width?Math.fround:t=>t}();class gh{constructor(){this.pdfViewer=null,this.pdfThumbnailViewer=null,this.onIdle=null,this.highestPriorityPage=null,this.idleTimeout=null,this.printing=!1,this.isThumbnailViewEnabled=!1,Object.defineProperty(this,"hasViewer",{value:()=>!!this.pdfViewer})}setViewer(t){this.pdfViewer=t}setThumbnailViewer(t){this.pdfThumbnailViewer=t}isHighestPriority(t){return this.highestPriorityPage===t.renderingId}renderHighestPriority(t){var e;this.idleTimeout&&(clearTimeout(this.idleTimeout),this.idleTimeout=null),this.pdfViewer.forceRendering(t)||this.isThumbnailViewEnabled&&(null===(e=this.pdfThumbnailViewer)||void 0===e?void 0:e.forceRendering())||this.printing||this.onIdle&&(this.idleTimeout=setTimeout(this.onIdle.bind(this),3e4))}getHighestPriority(t,e,i,s=!1){const n=t.views,r=n.length;if(0===r)return null;for(let t=0;t<r;t++){const e=n[t].view;if(!this.isViewFinished(e))return e}const a=t.first.id,o=t.last.id;if(o-a+1>r){const s=t.ids;for(let t=1,n=o-a;t<n;t++){const n=i?a+t:o-t;if(s.has(n))continue;const r=e[n-1];if(!this.isViewFinished(r))return r}}let l=i?o:a-2,h=e[l];return h&&!this.isViewFinished(h)||s&&(l+=i?1:-1,h=e[l],h&&!this.isViewFinished(h))?h:null}isViewFinished(t){return t.renderingState===Wl.FINISHED}renderView(t){switch(t.renderingState){case Wl.FINISHED:return!1;case Wl.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case Wl.RUNNING:this.highestPriorityPage=t.renderingId;break;case Wl.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally((()=>{this.renderHighestPriority()})).catch((t=>{t instanceof Ln||console.error("renderView:",t)}))}return!0}}var fh,mh,bh,vh,wh,yh,Ah,_h;class xh{static getCanvas(t,e){const i=$l(this,fh,Ul(this,fh,"f",mh)||document.createElement("canvas"),0,mh);i.width=t,i.height=e;const s=i.getContext("2d",{alpha:!1});return s.save(),s.fillStyle="rgb(255, 255, 255)",s.fillRect(0,0,t,e),s.restore(),[i,i.getContext("2d")]}static destroyCanvas(){const t=Ul(this,fh,"f",mh);t&&(t.width=0,t.height=0),$l(this,fh,null,0,mh)}}fh=xh,mh={value:null};class Sh{constructor({container:t,eventBus:e,id:i,defaultViewport:s,optionalContentConfigPromise:n,linkService:r,renderingQueue:a,pageColors:o,enableHWA:l,store:h,thumbnailWidth:d}){bh.add(this),this.id=i,this.renderingId="thumbnail"+i,this.pageLabel=null,this.pdfPage=null,this.rotation=0,this.viewport=s,this.pdfPageRotate=s.rotation,this._optionalContentConfigPromise=n||null,this.pageColors=o||null,this.enableHWA=l||!1,this.eventBus=e,this.linkService=r,this.renderingQueue=a,this.renderTask=null,this.renderingState=Wl.INITIAL,this.resume=null,this.store=h,this.thumbnailWidth=d,this.loaded=!1;const c=document.createElement("div");c.className="thumbnail pdfSlickThumbHolder",c.setAttribute("data-page-number",this.id.toString()),this.div=c,Ul(this,bh,"m",vh).call(this),t.append(c)}setPdfPage(t){this.pdfPage=t,this.pdfPageRotate=t.rotate;const e=(this.rotation+this.pdfPageRotate)%360;this.viewport=t.getViewport({scale:1,rotation:e}),this.reset()}reset(){this.cancelRendering(),this.renderingState=Wl.INITIAL,this.div.removeAttribute("data-loaded"),this.loaded=!1,Ul(this,bh,"m",vh).call(this)}update({rotation:t=null}){"number"==typeof t&&(this.rotation=t);const e=(this.rotation+this.pdfPageRotate)%360;this.viewport=this.viewport.clone({scale:1,rotation:e}),this.reset()}cancelRendering(){this.renderTask&&(this.renderTask.cancel(),this.renderTask=null),this.resume=null}draw(){return zl(this,void 0,void 0,(function*(){if(this.renderingState!==Wl.INITIAL)return void console.error("Must be in new state before drawing");const{pdfPage:t}=this;if(!t)throw this.renderingState=Wl.FINISHED,new Error("pdfPage is not loaded");this.renderingState=Wl.RUNNING;const{ctx:e,canvas:i,transform:s}=Ul(this,bh,"m",wh).call(this,2),n={canvasContext:e,transform:s,viewport:this.viewport.clone({scale:2*this.scale}),optionalContentConfigPromise:this._optionalContentConfigPromise,pageColors:this.pageColors},r=this.renderTask=t.render(n);r.onContinue=t=>{if(!this.renderingQueue.isHighestPriority(this))return this.renderingState=Wl.PAUSED,void(this.resume=()=>{this.renderingState=Wl.RUNNING,t()});t()};const a=r.promise.then((()=>Ul(this,bh,"m",Ah).call(this,r,i)),(t=>Ul(this,bh,"m",Ah).call(this,r,i,t)));return a.finally((()=>{i.width=0,i.height=0,this.eventBus.dispatch("thumbnailrendered",{source:this,pageNumber:this.id,pdfPage:this.pdfPage})})),a}))}setImage(t){if(this.renderingState!==Wl.INITIAL)return;const{thumbnailCanvas:e,pdfPage:i,scale:s}=t;e&&(this.pdfPage||this.setPdfPage(i),s<this.scale||(this.renderingState=Wl.FINISHED,Ul(this,bh,"m",yh).call(this,e)))}setPageLabel(t){this.pageLabel="string"==typeof t?t:null}}var Ch,Eh,Ph,Mh,Th,kh,Ih;bh=new WeakSet,vh=function(){const{width:t,height:e}=this.viewport,i=t/e;this.canvasWidth=this.thumbnailWidth,this.canvasHeight=this.canvasWidth/i|0,this.scale=this.canvasWidth/t;const{style:s}=this.div;s.setProperty("--thumbnail-width",`${this.canvasWidth}px`),s.setProperty("--thumbnail-height",`${this.canvasHeight}px`)},wh=function(t=1,e=this.enableHWA){const i=document.createElement("canvas"),s=i.getContext("2d",{alpha:!1,willReadFrequently:!e}),n=new Ql;i.width=t*this.canvasWidth*n.sx|0,i.height=t*this.canvasHeight*n.sy|0;return{ctx:s,canvas:i,transform:n.scaled?[n.sx,0,0,n.sy,0,0]:null}},yh=function(t){if(this.renderingState!==Wl.FINISHED)throw new Error("#convertCanvasToImage: Rendering has not finished.");const e=Ul(this,bh,"m",_h).call(this,t);this.src=e.toDataURL(),this.div.setAttribute("data-loaded","true"),this.loaded=!0,this.store.getState()._setThumbnailView(this.id,this),e.width=0,e.height=0},Ah=function(t,e){return zl(this,arguments,void 0,(function*(t,e,i=null){if(t===this.renderTask&&(this.renderTask=null),!(i instanceof Ln)&&(this.renderingState=Wl.FINISHED,Ul(this,bh,"m",yh).call(this,e),i))throw i}))},_h=function(t){const{ctx:e,canvas:i}=Ul(this,bh,"m",wh).call(this,1,!0);if(t.width<=2*i.width)return e.drawImage(t,0,0,t.width,t.height,0,0,i.width,i.height),i;let s=i.width<<3,n=i.height<<3;const[r,a]=xh.getCanvas(s,n);for(;s>t.width||n>t.height;)s>>=1,n>>=1;for(a.drawImage(t,0,0,t.width,t.height,0,0,s,n);s>2*i.width;)a.drawImage(r,0,0,s,n,0,0,s>>1,n>>1),s>>=1,n>>=1;return e.drawImage(r,0,0,s,n,0,0,i.width,i.height),i};const Lh="selected";class Dh{constructor({container:t,eventBus:e,linkService:i,renderingQueue:s,pageColors:n,abortSignal:r,enableHWA:a,store:o,thumbnailWidth:l}){Ch.add(this),this.container=t,this.eventBus=e,this.linkService=i,this.renderingQueue=s,this.pageColors=n||null,this.enableHWA=a||!1,this.store=o,this.thumbnailWidth=l,this.scroll=Zl(this.container,Ul(this,Ch,"m",Eh).bind(this),r),Ul(this,Ch,"m",Mh).call(this)}getThumbnail(t){return this._thumbnails[t]}scrollThumbnailIntoView(t){if(!this.pdfDocument)return;const e=this._thumbnails[t-1];if(!e)return void console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');if(t!==this._currentPageNumber){this._thumbnails[this._currentPageNumber-1].div.classList.remove(Lh),e.div.classList.add(Lh)}const{first:i,last:s,views:n}=Ul(this,Ch,"m",Ph).call(this);if(n.length>0){let r=!1;if(t<=i.id||t>=s.id)r=!0;else for(const{id:e,percent:i}of n)if(e===t){r=i<100;break}r&&Jl(e.div,{top:-19})}this._currentPageNumber=t}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!oh(t))throw new Error("Invalid thumbnails rotation angle.");if(!this.pdfDocument)return;if(this._pagesRotation===t)return;this._pagesRotation=t;const e={rotation:t};for(const t of this._thumbnails)t.update(e)}cleanup(){for(const t of this._thumbnails)t.renderingState!==Wl.FINISHED&&t.reset();xh.destroyCanvas()}setDocument(t){if(this.pdfDocument&&(Ul(this,Ch,"m",Th).call(this),Ul(this,Ch,"m",Mh).call(this)),this.pdfDocument=t,!t)return;const e=t.getPage(1),i=t.getOptionalContentConfig({intent:"display"});e.then((e=>{var s;const n=t.numPages,r=e.getViewport({scale:1});for(let t=1;t<=n;++t){const e=new Sh({container:this.container,eventBus:this.eventBus,id:t,defaultViewport:r.clone(),optionalContentConfigPromise:i,linkService:this.linkService,renderingQueue:this.renderingQueue,pageColors:this.pageColors,enableHWA:this.enableHWA,store:this.store,thumbnailWidth:this.thumbnailWidth});this._thumbnails.push(e)}null===(s=this._thumbnails[0])||void 0===s||s.setPdfPage(e);this._thumbnails[this._currentPageNumber-1].div.classList.add(Lh),this.store.getState()._setThumbnailsViews(this._thumbnails)})).catch((t=>{console.error("Unable to initialize thumbnail viewer",t)}))}setPageLabels(t){var e,i;if(this.pdfDocument){t?Array.isArray(t)&&this.pdfDocument.numPages===t.length?this._pageLabels=t:(this._pageLabels=null,console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.")):this._pageLabels=null;for(let t=0,s=this._thumbnails.length;t<s;t++)this._thumbnails[t].setPageLabel(null!==(i=null===(e=this._pageLabels)||void 0===e?void 0:e[t])&&void 0!==i?i:null)}}forceRendering(){const t=Ul(this,Ch,"m",Ph).call(this),e=Ul(this,Ch,"m",Ih).call(this,t),i=this.renderingQueue.getHighestPriority(t,this._thumbnails,e);return!!i&&(Ul(this,Ch,"m",kh).call(this,i).then((()=>{this.renderingQueue.renderView(i)})),!0)}}Ch=new WeakSet,Eh=function(){this.renderingQueue.renderHighestPriority()},Ph=function(){return nh({scrollEl:this.container,views:this._thumbnails})},Mh=function(){this._thumbnails=[],this._currentPageNumber=1,this._pageLabels=null,this._pagesRotation=0,this.container.textContent=""},Th=function(){for(const t of this._thumbnails)t.cancelRendering()},kh=function(t){return zl(this,void 0,void 0,(function*(){if(t.pdfPage)return t.pdfPage;try{const e=yield this.pdfDocument.getPage(t.id);return t.pdfPage||t.setPdfPage(e),e}catch(t){return console.error("Unable to get page for thumb view",t),null}}))},Ih=function(t){var e,i;return 1===(null===(e=t.first)||void 0===e?void 0:e.id)||(null===(i=t.last)||void 0===i?void 0:i.id)!==this._thumbnails.length&&this.scroll.down};let Rh=null;class Nh{constructor({pdfDocument:t,pagesOverview:e,printContainer:i,printResolution:s,printAnnotationStoragePromise:n=null}){this.pdfDocument=t,this.pagesOverview=e,this.printContainer=i,this._printResolution=s||150,this._optionalContentConfigPromise=t.getOptionalContentConfig({intent:"print"}),this._printAnnotationStoragePromise=n||Promise.resolve(),this.currentPage=-1,this.scratchCanvas=document.createElement("canvas")}layout(){this.throwIfInactive();const t=document.querySelector("body");t.setAttribute("data-pdfjsprinting","true");const{width:e,height:i}=this.pagesOverview[0];this.pagesOverview.every((t=>t.width===e&&t.height===i))||console.warn("Not all pages have the same size. The printed result may be incorrect!"),this.pageStyleSheet=document.createElement("style"),this.pageStyleSheet.textContent=`@page { size: ${e}pt ${i}pt;}`,t.append(this.pageStyleSheet)}destroy(){if(Rh!==this)return;this.printContainer.textContent="";document.querySelector("body").removeAttribute("data-pdfjsprinting"),this.pageStyleSheet&&(this.pageStyleSheet.remove(),this.pageStyleSheet=null),this.scratchCanvas.width=this.scratchCanvas.height=0,this.scratchCanvas=null,Rh=null}renderPages(t){if(this.pdfDocument.isPureXfa)return function(t,e){const i=e.allXfaHtml,s=new Vl,n=Math.round(100*In.PDF_TO_CSS_UNITS)/100;for(const r of null==i?void 0:i.children){const i=document.createElement("div");i.className="xfaPrintedPage",t.append(i);const a=new Hl({pdfPage:null,annotationStorage:e.annotationStorage,linkService:s,xfaHtml:r}),o=Nn(r,{scale:n});a.render(o,"print"),i.append(a.div)}}(this.printContainer,this.pdfDocument),Promise.resolve();const e=this.pagesOverview.length,i=(s,n)=>{if(this.throwIfInactive(),++this.currentPage>=e)return t({index:e,total:e}),void s();const r=this.currentPage;t({index:r,total:e}),function(t,e,i,s,n,r,a){const o=t.scratchCanvas,l=n/In.PDF;o.width=Math.floor(s.width*l),o.height=Math.floor(s.height*l);const h=o.getContext("2d");return h.save(),h.fillStyle="rgb(255, 255, 255)",h.fillRect(0,0,o.width,o.height),h.restore(),Promise.all([e.getPage(i),a]).then((function([t,e]){const i={canvasContext:h,transform:[l,0,0,l,0,0],viewport:t.getViewport({scale:1,rotation:s.rotation}),intent:"print",annotationMode:Mn.ENABLE_STORAGE,optionalContentConfigPromise:r,printAnnotationStorage:e};return t.render(i).promise.catch((t=>{throw t instanceof Ln||console.error(t),t}))}))}(this,this.pdfDocument,r+1,this.pagesOverview[r],this._printResolution,this._optionalContentConfigPromise,this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then((function(){i(s,n)}),n)};return new Promise(i)}useRenderedPage(){this.throwIfInactive();const t=document.createElement("img");this.scratchCanvas.toBlob((e=>{t.src=URL.createObjectURL(e)}));const e=document.createElement("div");e.className="printedPage",e.append(t),this.printContainer.append(e);const{promise:i,resolve:s,reject:n}=Promise.withResolvers();return t.onload=s,t.onerror=n,i.catch((()=>{})).then((()=>{URL.revokeObjectURL(t.src)})),i}performPrint(){return this.throwIfInactive(),new Promise((t=>{setTimeout((()=>{this.active?(window.print(),setTimeout(t,20)):t()}),0)}))}get active(){return this===Rh}throwIfInactive(){if(!this.active)throw new Error("This print request was cancelled or completed.")}}const Fh={instance:{supportsPrinting:!0,createPrintService(t){if(Rh)throw new Error("The print service is created and active.");return Rh=new Nh(t)}}};var Oh,Bh,jh,Vh,Hh,zh,Uh,$h,Wh,Gh,qh,Xh,Kh,Yh,Qh,Jh,Zh,td,ed;const id="pdfPresentationMode",sd="pdfPresentationModeControls",nd=Math.PI/6;class rd{constructor({container:t,pdfViewer:e,eventBus:i}){Oh.add(this),Bh.set(this,Gl.UNKNOWN),jh.set(this,null),Vh.set(this,null),Hh.set(this,null),this.container=t,this.pdfViewer=e,this.eventBus=i,this.contextMenuOpen=!1,this.mouseScrollTimeStamp=0,this.mouseScrollDelta=0,this.touchSwipeState=null}request(){return zl(this,void 0,void 0,(function*(){const{container:t,pdfViewer:e}=this;if(this.active||!e.pagesCount||!t.requestFullscreen)return!1;Ul(this,Oh,"m",td).call(this),Ul(this,Oh,"m",Uh).call(this,Gl.CHANGING);const i=t.requestFullscreen();$l(this,jh,{pageNumber:e.currentPageNumber,scaleValue:e.currentScaleValue,scrollMode:e.scrollMode,spreadMode:null,annotationEditorMode:null}),e.spreadMode===Yl.NONE||e.pageViewsReady&&e.hasEqualPageSizes||(console.warn("Ignoring Spread modes when entering PresentationMode, since the document may contain varying page sizes."),Ul(this,jh,"f").spreadMode=e.spreadMode),e.annotationEditorMode!==Pn.DISABLE&&(Ul(this,jh,"f").annotationEditorMode=e.annotationEditorMode);try{return yield i,e.focus(),!0}catch(t){Ul(this,Oh,"m",ed).call(this),Ul(this,Oh,"m",Uh).call(this,Gl.NORMAL)}return!1}))}get active(){return Ul(this,Bh,"f")===Gl.CHANGING||Ul(this,Bh,"f")===Gl.FULLSCREEN}}Bh=new WeakMap,jh=new WeakMap,Vh=new WeakMap,Hh=new WeakMap,Oh=new WeakSet,zh=function(t){if(!this.active)return;t.preventDefault();const e=ah(t),i=Date.now(),s=this.mouseScrollTimeStamp;if(!(i>s&&i-s<50)&&((this.mouseScrollDelta>0&&e<0||this.mouseScrollDelta<0&&e>0)&&Ul(this,Oh,"m",Yh).call(this),this.mouseScrollDelta+=e,Math.abs(this.mouseScrollDelta)>=.1)){const t=this.mouseScrollDelta;Ul(this,Oh,"m",Yh).call(this);(t>0?this.pdfViewer.previousPage():this.pdfViewer.nextPage())&&(this.mouseScrollTimeStamp=i)}},Uh=function(t){$l(this,Bh,t),this.eventBus.dispatch("presentationmodechanged",{source:this,state:t})},$h=function(){var t;Ul(this,Oh,"m",Uh).call(this,Gl.FULLSCREEN),this.container.classList.add(id),setTimeout((()=>{this.pdfViewer.scrollMode=Kl.PAGE,null!==Ul(this,jh,"f").spreadMode&&(this.pdfViewer.spreadMode=Yl.NONE),this.pdfViewer.currentPageNumber=Ul(this,jh,"f").pageNumber,this.pdfViewer.currentScaleValue="page-fit",null!==Ul(this,jh,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:Pn.NONE})}),0),Ul(this,Oh,"m",Jh).call(this),Ul(this,Oh,"m",Xh).call(this),this.contextMenuOpen=!1,null===(t=document.getSelection())||void 0===t||t.empty()},Wh=function(){const t=this.pdfViewer.currentPageNumber;this.container.classList.remove(id),setTimeout((()=>{Ul(this,Oh,"m",ed).call(this),Ul(this,Oh,"m",Uh).call(this,Gl.NORMAL),this.pdfViewer.scrollMode=Ul(this,jh,"f").scrollMode,null!==Ul(this,jh,"f").spreadMode&&(this.pdfViewer.spreadMode=Ul(this,jh,"f").spreadMode),this.pdfViewer.currentScaleValue=Ul(this,jh,"f").scaleValue,this.pdfViewer.currentPageNumber=t,null!==Ul(this,jh,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:Ul(this,jh,"f").annotationEditorMode}),$l(this,jh,null)}),0),Ul(this,Oh,"m",Zh).call(this),Ul(this,Oh,"m",Kh).call(this),Ul(this,Oh,"m",Yh).call(this),this.contextMenuOpen=!1},Gh=function(t){var e;if(this.contextMenuOpen)return this.contextMenuOpen=!1,void t.preventDefault();0===t.button&&(t.target.href&&(null===(e=t.target.parentNode)||void 0===e?void 0:e.hasAttribute("data-internal-link"))||(t.preventDefault(),t.shiftKey?this.pdfViewer.previousPage():this.pdfViewer.nextPage()))},qh=function(){this.contextMenuOpen=!0},Xh=function(){this.controlsTimeout?clearTimeout(this.controlsTimeout):this.container.classList.add(sd),this.controlsTimeout=setTimeout((()=>{this.container.classList.remove(sd),delete this.controlsTimeout}),3e3)},Kh=function(){this.controlsTimeout&&(clearTimeout(this.controlsTimeout),this.container.classList.remove(sd),delete this.controlsTimeout)},Yh=function(){this.mouseScrollTimeStamp=0,this.mouseScrollDelta=0},Qh=function(t){if(this.active)if(t.touches.length>1)this.touchSwipeState=null;else switch(t.type){case"touchstart":this.touchSwipeState={startX:t.touches[0].pageX,startY:t.touches[0].pageY,endX:t.touches[0].pageX,endY:t.touches[0].pageY};break;case"touchmove":if(null===this.touchSwipeState)return;this.touchSwipeState.endX=t.touches[0].pageX,this.touchSwipeState.endY=t.touches[0].pageY,t.preventDefault();break;case"touchend":if(null===this.touchSwipeState)return;let e=0;const i=this.touchSwipeState.endX-this.touchSwipeState.startX,s=this.touchSwipeState.endY-this.touchSwipeState.startY,n=Math.abs(Math.atan2(s,i));Math.abs(i)>50&&(n<=nd||n>=Math.PI-nd)?e=i:Math.abs(s)>50&&Math.abs(n-Math.PI/2)<=nd&&(e=s),e>0?this.pdfViewer.previousPage():e<0&&this.pdfViewer.nextPage()}},Jh=function(){if(Ul(this,Hh,"f"))return;$l(this,Hh,new AbortController);const{signal:t}=Ul(this,Hh,"f"),e=Ul(this,Oh,"m",Qh).bind(this);window.addEventListener("mousemove",Ul(this,Oh,"m",Xh).bind(this),{signal:t}),window.addEventListener("mousedown",Ul(this,Oh,"m",Gh).bind(this),{signal:t}),window.addEventListener("wheel",Ul(this,Oh,"m",zh).bind(this),{passive:!1,signal:t}),window.addEventListener("keydown",Ul(this,Oh,"m",Yh).bind(this),{signal:t}),window.addEventListener("contextmenu",Ul(this,Oh,"m",qh).bind(this),{signal:t}),window.addEventListener("touchstart",e,{signal:t}),window.addEventListener("touchmove",e,{signal:t}),window.addEventListener("touchend",e,{signal:t})},Zh=function(){var t;null===(t=Ul(this,Hh,"f"))||void 0===t||t.abort(),$l(this,Hh,null)},td=function(){Ul(this,Vh,"f")||($l(this,Vh,new AbortController),window.addEventListener("fullscreenchange",(()=>{document.fullscreenElement?Ul(this,Oh,"m",$h).call(this):Ul(this,Oh,"m",Wh).call(this)}),{signal:Ul(this,Vh,"f").signal}))},ed=function(){var t;null===(t=Ul(this,Vh,"f"))||void 0===t||t.abort(),$l(this,Vh,null)};const ad={isDocumentLoaded:!1,pagesReady:!1,url:null,numPages:0,pageNumber:0,scale:0,scaleValue:"auto",pagesRotation:0,spreadMode:Yl.UNKNOWN,scrollMode:Kl.UNKNOWN,documentOutline:null,attachments:new Map,thumbnails:new Map,thumbnailViews:new Map,annotationEditorMode:Pn.NONE,pdfSlick:null},od=()=>{return(t=(t,e)=>Object.assign(Object.assign({},ad),{_setThumbnailView:(i,s)=>{const n=new Map(e().thumbnails),r=new Map(e().thumbnailViews),{canvasWidth:a,canvasHeight:o,scale:l,rotation:h,loaded:d,pageLabel:c,src:u=null}=s;r.set(i,s),n.set(i,{pageNumber:i,width:a,height:o,scale:l,rotation:h,loaded:d,pageLabel:c,src:u}),t({thumbnailViews:r,thumbnails:n})},_setThumbnailsViews:e=>{const i=new Map(e.map((t=>[t.id,t]))),s=new Map(e.map((t=>{const{canvasWidth:e,canvasHeight:i,scale:s,rotation:n,loaded:r,pageLabel:a,src:o=null}=t;return[t.id,{pageNumber:t.id,width:e,height:i,scale:s,rotation:n,loaded:r,pageLabel:a,src:o}]})));t({thumbnailViews:i,thumbnails:s})}}))?b(t):b;var t};var ld,hd,dd,cd,ud,pd,gd,fd,md,bd,vd,wd,yd,Ad,_d,xd,Sd,Cd,Ed,Pd,Md,Td,kd,Id,Ld,Dd,Rd;class Nd{constructor({eventBus:t,slick:e,printDialog:i}){ld.add(this),hd.set(this,null),dd.set(this,null),cd.set(this,null),this.eventBus=t,this.slick=e,this.printDialog=null!=i?i:null,this.bindEvents()}get supportsPrinting(){return Fh.instance.supportsPrinting}get printing(){return!!Ul(this,hd,"f")}print(){return zl(this,void 0,void 0,(function*(){var t,e;if(this.supportsPrinting)if(this.printing)console.warn("Ignored pdf print because of a pending print job.");else{yield null===(t=this.printDialog)||void 0===t?void 0:t.open({close:()=>this.abort()});try{this.eventBus.dispatch("beforeprint",{source:this})}finally{if(this.printing){const t=Ul(this,hd,"f");yield t.renderPages((t=>{var e;return null===(e=this.printDialog)||void 0===e?void 0:e.progress(t)})).then((()=>t.performPrint())).catch((()=>{})).then((()=>{t===Ul(this,hd,"f")&&this.abort()}))}else console.error("Expected print service to be initialized."),null===(e=this.printDialog)||void 0===e||e.close()}}}))}abort(){var t;Ul(this,hd,"f")&&(Ul(this,hd,"f").destroy(),null===(t=this.printDialog)||void 0===t||t.close(),this.eventBus.dispatch("afterprint",{source:this}))}bindEvents(){$l(this,dd,new AbortController);const{signal:t}=Ul(this,dd,"f"),e={signal:t};this.eventBus._on("beforeprint",Ul(this,ld,"m",ud).bind(this),e),this.eventBus._on("afterprint",Ul(this,ld,"m",pd).bind(this),e),window.addEventListener("beforeprint",(()=>this.eventBus.dispatch("beforeprint",{source:window})),e),window.addEventListener("afterprint",(()=>this.eventBus.dispatch("afterprint",{source:window})),e),window.addEventListener("keydown",(t=>{80!==t.keyCode||!t.ctrlKey&&!t.metaKey||t.altKey||t.shiftKey&&!window.chrome&&!window.opera||(this.print(),t.preventDefault(),t.stopImmediatePropagation())}),{signal:t,capture:!0})}unbindEvents(){var t;null===(t=Ul(this,dd,"f"))||void 0===t||t.abort(),$l(this,dd,null)}}hd=new WeakMap,dd=new WeakMap,cd=new WeakMap,ld=new WeakSet,ud=function(){Ul(this,hd,"f")||this.supportsPrinting&&(this.slick.viewer.pageViewsReady?($l(this,cd,function(){const t=document.createElement("div");t.classList.add("pdfSlickPrintContainer"),document.body.append(t);const e=document.createElement("style");return e.textContent="\n@page {\n margin: 0;\n}\n\n.pdfSlickPrintContainer {\n display: none;\n}\n\n@media print {\n body {\n background: rgb(0 0 0 / 0) none;\n }\n\n body[data-pdfjsprinting] > *:not(.pdfSlickPrintContainer) {\n display: none;\n }\n\n body[data-pdfjsprinting] .pdfSlickPrintContainer {\n display: block;\n }\n\n .pdfSlickPrintContainer {\n height: 100%;\n }\n\n /* wrapper around (scaled) print canvas elements */\n .pdfSlickPrintContainer > .printedPage {\n page-break-after: always;\n page-break-inside: avoid;\n\n /* The wrapper always cover the whole page. */\n height: 100%;\n width: 100%;\n\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n .pdfSlickPrintContainer > .xfaPrintedPage .xfaPage {\n position: absolute;\n }\n\n .pdfSlickPrintContainer > .xfaPrintedPage {\n page-break-after: always;\n page-break-inside: avoid;\n width: 100%;\n height: 100%;\n position: relative;\n }\n\n .pdfSlickPrintContainer > .printedPage :is(canvas, img) {\n /* The intrinsic canvas / image size will make sure that we fit the page. */\n max-width: 100%;\n max-height: 100%;\n\n direction: ltr;\n display: block;\n }\n}",document.body.append(e),{get element(){return t},remove:()=>{t.remove(),e.remove()}}}()),$l(this,hd,Fh.instance.createPrintService({pdfDocument:this.slick.document,pagesOverview:this.slick.viewer.getPagesOverview(),printContainer:Ul(this,cd,"f").element,printResolution:this.slick.printResolution,optionalContentConfigPromise:null,printAnnotationStoragePromise:null})),this.slick.forceRendering(),Ul(this,hd,"f").layout()):this.slick.l10n.get("printing_not_ready",null).then((t=>{window.alert(t)})))},pd=function(){var t,e,i;Ul(this,hd,"f")&&(Ul(this,hd,"f").destroy(),$l(this,hd,null),null===(t=this.printDialog)||void 0===t||t.close(),null===(e=Ul(this,cd,"f"))||void 0===e||e.remove(),$l(this,cd,null),null===(i=this.slick.document)||void 0===i||i.annotationStorage.resetModified()),this.slick.forceRendering()};class Fd{static create(){let t=document.querySelector("#printServiceDialog");if(!t){const e=(t,e,i)=>{const s=document.createElement(t);return Object.entries(e).forEach((([t,e])=>s.setAttribute(t,e))),s.append(...i),s};t=e("dialog",{id:"printServiceDialog",class:"pdfSlick-dialog",style:"min-width: 200px;"},[e("div",{class:"row"},[e("span",{"data-l10n-id":"pdfjs-print-progress-message"},["Preparing document for printing…"])]),e("div",{class:"row"},[e("progress",{value:"0",max:"100"},[]),e("span",{"data-l10n-id":"pdfjs-print-progress-percent","data-l10n-args":'{ "progress": 0 }',class:"relative-progress"},["0%"])]),e("div",{class:"buttonRow"},[e("button",{id:"printCancel",class:"dialogButton",type:"button"},[e("span",{"data-l10n-id":"pdfjs-print-progress-close-button"},["Cancel"])])])]),document.body.append(t)}return new Fd(t)}constructor(t){this.dialog=t}open(t){return zl(this,void 0,void 0,(function*(){const e=this.dialog.querySelector("#printCancel"),i=()=>{var s;this.dialog.removeEventListener("close",i),this.dialog.removeEventListener("cancel",i),null==e||e.removeEventListener("click",i),null===(s=null==t?void 0:t.close)||void 0===s||s.call(t),this.close()};this.dialog.addEventListener("close",i),this.dialog.addEventListener("cancel",i),null==e||e.addEventListener("click",i),this.dialog.showModal()}))}close(){this.dialog.close()}progress({index:t,total:e}){const i=Math.round(100*t/e),s=this.dialog.querySelector("progress"),n=this.dialog.querySelector(".relative-progress");s.value=i,n.setAttribute("data-l10n-args",JSON.stringify({progress:i}))}}Tn.workerSrc=new URL("pdfjs-dist/build/pdf.worker.min.mjs","undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:n&&"SCRIPT"===n.tagName.toUpperCase()&&n.src||new URL("index.js",document.baseURI).href).toString();const Od={"8.5x11":"Letter","8.5x14":"Legal"},Bd={"297x420":"A3","210x297":"A4"};function jd(t,e,i){return i[`${e?t.width:t.height}x${e?t.height:t.width}`]}class Vd{constructor({container:t,viewer:e,thumbs:i,store:s=od(),options:n,onError:r,printDialog:a}){var o,l,h,d,c,u,p,g,f,m,b,v,w,y,A;gd.add(this),fd.set(this,void 0),md.set(this,void 0),bd.set(this,void 0),vd.set(this,void 0),wd.set(this,void 0),this.downloadManager=null,this.findController=null,this.pdfPresentationMode=null,this.document=null,yd.set(this,void 0),Ad.set(this,void 0),_d.set(this,void 0),xd.set(this,void 0),$l(this,md,t),$l(this,bd,e),$l(this,vd,i),$l(this,_d,r),this.l10n=null!==(o=null==n?void 0:n.l10n)&&void 0!==o?o:new Nl(navigator.language),this.downloadManager=new Dl,this.textLayerMode=null!==(l=null==n?void 0:n.textLayerMode)&&void 0!==l?l:Xl.ENABLE,$l(this,yd,null!==(h=null==n?void 0:n.annotationMode)&&void 0!==h?h:Mn.ENABLE_FORMS),$l(this,Ad,null!==(d=null==n?void 0:n.annotationEditorMode)&&void 0!==d?d:Pn.NONE),this.annotationEditorHighlightColors=null!==(c=null==n?void 0:n.annotationEditorHighlightColors)&&void 0!==c?c:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",this.removePageBorders=null!==(u=null==n?void 0:n.removePageBorders)&&void 0!==u&&u,this.singlePageViewer=null!==(p=null==n?void 0:n.singlePageViewer)&&void 0!==p&&p,this.enablePrintAutoRotate=null!==(g=null==n?void 0:n.enablePrintAutoRotate)&&void 0!==g&&g,this.useOnlyCssZoom=null!==(f=null==n?void 0:n.useOnlyCssZoom)&&void 0!==f&&f,this.pageColors=null!==(m=null==n?void 0:n.pageColors)&&void 0!==m?m:null,this.maxCanvasPixels=null!==(b=null==n?void 0:n.maxCanvasPixels)&&void 0!==b?b:16777216,this.printResolution=null!==(v=null==n?void 0:n.printResolution)&&void 0!==v?v:96,this.thumbnailWidth=null!==(w=null==n?void 0:n.thumbnailWidth)&&void 0!==w?w:125,this.getDocumentParams=null!==(y=null==n?void 0:n.getDocumentParams)&&void 0!==y?y:{},!this.pageColors||CSS.supports("color",this.pageColors.background)&&CSS.supports("color",this.pageColors.foreground)||((this.pageColors.background||this.pageColors.foreground)&&console.warn("PDFViewer: Ignoring `pageColors`-option, since the browser doesn't support the values used."),this.pageColors=null),this.store=s;const _=new gh;_.onIdle=this._cleanup.bind(this),_.isThumbnailViewEnabled=!0,$l(this,fd,_);const x=new Rl,S=new Ol({eventBus:x,externalLinkTarget:2,externalLinkRel:"noopener noreferrer nofollow",ignoreDestinationZoom:!1}),C=new Fl({eventBus:x,linkService:S}),E=Object.assign(Object.assign({container:t},e&&{viewer:e}),{eventBus:x,linkService:S,findController:C,renderingQueue:_,textLayerMode:this.textLayerMode,annotationEditorHighlightColors:this.annotationEditorHighlightColors,l10n:this.l10n,annotationMode:Ul(this,yd,"f"),annotationEditorMode:Ul(this,Ad,"f"),removePageBorders:this.removePageBorders,imageResourcesPath:"/images/"}),P=this.singlePageViewer?new Bl(E):new jl(E);_.setViewer(P),i&&(this.thumbnailViewer=new Dh({container:i,eventBus:x,linkService:S,renderingQueue:_,pageColors:this.pageColors,enableHWA:void 0,store:s,thumbnailWidth:this.thumbnailWidth}),_.setThumbnailViewer(this.thumbnailViewer)),document.fullscreenEnabled&&(this.pdfPresentationMode=new rd({container:t,pdfViewer:P,eventBus:x})),this.eventBus=x,this.linkService=S,this.findController=C,this.viewer=P,this.linkService.setViewer(P),$l(this,wd,new Nd({eventBus:x,slick:this,printDialog:null!=a?a:Fd.create()}));const M=null!==(A=null==n?void 0:n.scaleValue)&&void 0!==A?A:"auto";this.store.setState({scaleValue:M})}loadDocument(t,e){return zl(this,void 0,void 0,(function*(){var i,s,n,r,a;if(this.url&&"string"==typeof this.url)try{URL.revokeObjectURL(this.url)}catch(t){}try{null===(i=this.document)||void 0===i||i.destroy(),null===(s=this.viewer)||void 0===s||s.cleanup(),t instanceof URL?this.url=t.toString():t instanceof ArrayBuffer?this.url=URL.createObjectURL(new Blob([t],{type:"application/pdf"})):this.url=t;const o=null!==(n=null==e?void 0:e.filename)&&void 0!==n?n:Rn(null===(r=this.url)||void 0===r?void 0:r.toString());this.filename=o;const l=Dn(Object.assign(Object.assign({},this.getDocumentParams),{url:this.url,isEvalSupported:!1}));(null==e?void 0:e.onProgress)&&(l.onProgress=e.onProgress);const h=yield l.promise;this.document=h,this.viewer.setDocument(this.document),this.linkService.setDocument(this.document),this.thumbnailViewer&&(null===(a=this.thumbnailViewer)||void 0===a||a.setDocument(h)),Ul(this,gd,"m",Pd).call(this),yield Ul(this,gd,"m",Sd).call(this),this.store.setState({filename:o,numPages:h.numPages,pageNumber:1,isDocumentLoaded:!0,url:t.toString()});const d=yield h.getAttachments(),c=new Map(Object.keys(null!=d?d:{}).sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase()))).map((t=>[t,d[t]])));this.store.setState({attachments:c}),yield Ul(this,gd,"m",Cd).call(this),this.forceRendering()}catch(t){Ul(this,_d,"f")&&Ul(this,_d,"f").call(this,t)}}))}forceRendering(t=!0){Ul(this,fd,"f").printing=!!Ul(this,wd,"f").printing,Ul(this,fd,"f").isThumbnailViewEnabled=t,Ul(this,fd,"f").renderHighestPriority()}gotoPage(t){this.linkService.goToPage(t)}openOrDownloadData(t,e){var i;null===(i=this.downloadManager)||void 0===i||i.openOrDownloadData(t,e)}download(){return zl(this,void 0,void 0,(function*(){var t,e;const i=this.url,{filename:s}=this;try{const e=yield this.document.getData(),n=new Blob([e],{type:"application/pdf"});yield null===(t=this.downloadManager)||void 0===t?void 0:t.download(n,i,s)}catch(t){yield null===(e=this.downloadManager)||void 0===e?void 0:e.download(null,i,s)}}))}save(){return zl(this,void 0,void 0,(function*(){var t;const e=this.url,{filename:i}=this;try{const s=yield this.document.saveDocument(),n=new Blob([s],{type:"application/pdf"});yield null===(t=this.downloadManager)||void 0===t?void 0:t.download(n,e,i)}catch(t){console.error(`Error when saving the document: ${t.message}`),yield this.download()}}))}downloadOrSave(){var t;const{annotationStorage:e}=null!==(t=this.document)&&void 0!==t?t:{};e&&e.size>0?this.save():this.download()}get supportsPrinting(){return Ul(this,wd,"f").supportsPrinting}requestPresentationMode(){var t;null===(t=this.pdfPresentationMode)||void 0===t||t.request()}triggerPrinting(){Ul(this,wd,"f").print()}unbindEvents(){var t;null===(t=Ul(this,xd,"f"))||void 0===t||t.abort(),$l(this,xd,null),Ul(this,wd,"f").unbindEvents()}_cleanup(){var t;if(this.document)try{this.viewer.cleanup(),null===(t=this.thumbnailViewer)||void 0===t||t.cleanup(),this.document.cleanup()}catch(t){console.error("Unable to perform cleanup",t)}}setAnnotationEditorMode(t){this.viewer.annotationEditorMode={mode:t},this.dispatch("switchannotationeditormode",{source:this,mode:t}),this.store.setState({annotationEditorMode:t})}setAnnotationEditorParams(t){const e=Array.isArray(t)?t:[t];for(const t of e)this.dispatch("switchannotationeditorparams",{source:this,type:t.type,value:t.value})}setHighlightDefaultColor(t){this.setAnnotationEditorMode(Pn.HIGHLIGHT),this.setAnnotationEditorParams([{type:En.HIGHLIGHT_DEFAULT_COLOR,value:t}]),this.store.setState({highlightDefaultColor:t})}setSpreadMode(t){hh(t)&&(this.viewer.spreadMode=t,this.dispatch("switchspreadmode",{mode:t}))}setScrollMode(t){lh(t)&&(this.viewer.scrollMode=t,this.dispatch("switchscrollmode",{mode:t}))}setRotation(t){oh(t)&&(this.viewer.pagesRotation=t)}getPagesOverview(){var t,e;try{return null!==(e=null===(t=this.viewer)||void 0===t?void 0:t.getPagesOverview())&&void 0!==e?e:[]}catch(t){return[]}}increaseScale(){this.viewer.increaseScale()}decreaseScale(){this.viewer.decreaseScale()}set currentScaleValue(t){this.viewer.currentScaleValue=t}set currentScale(t){this.viewer.currentScale=t}getPageView(t){return this.viewer.getPageView(t)}on(t,e,i){this.eventBus.on(t,e,i)}off(t,e,i){this.eventBus.off(t,e,i)}dispatch(t,e){this.eventBus.dispatch(t,e)}}fd=new WeakMap,md=new WeakMap,bd=new WeakMap,vd=new WeakMap,wd=new WeakMap,yd=new WeakMap,Ad=new WeakMap,_d=new WeakMap,xd=new WeakMap,gd=new WeakSet,Sd=function(){return zl(this,void 0,void 0,(function*(){var t;const e=this.document,i=null!==(t=yield e.getPageLabels())&&void 0!==t?t:[],s=i.length;let n=0,r=0;for(let t=0;t<s;t++){const e=i[t];if(e===(t+1).toString())n++;else{if(""!==e)break;r++}}if(n>=s||r>=s)return;const{viewer:a,thumbnailViewer:o}=this;a.setPageLabels(i),null==o||o.setPageLabels(i)}))},Cd=function(){return zl(this,void 0,void 0,(function*(){const{info:t,contentLength:e}=yield this.document.getMetadata(),i=yield this.document.getPage(this.store.getState().pageNumber).then((t=>Ul(this,gd,"m",Ed).call(this,ih(t),0)));this.store.setState({filesize:e,title:t.Title,author:t.Author,subject:t.Subject,keywords:t.Keywords,creator:t.Creator,producer:t.Producer,version:t.PDFFormatVersion,creationDate:kn.toDateObject(t.CreationDate),modificationDate:kn.toDateObject(t.ModDate),isLinearized:t.IsLinearized,pageSize:i})}))},Ed=function(t,e){return zl(this,void 0,void 0,(function*(){if(!t)return;e%180!=0&&(t={width:t.height,height:t.width});const i=dh(t);let s={width:Math.round(100*t.width)/100,height:Math.round(100*t.height)/100},n={width:Math.round(25.4*t.width*10)/10,height:Math.round(25.4*t.height*10)/10},r=jd(s,i,Od)||jd(n,i,Bd);if(!(r||Number.isInteger(n.width)&&Number.isInteger(n.height))){const e={width:25.4*t.width,height:25.4*t.height},a={width:Math.round(n.width),height:Math.round(n.height)};Math.abs(e.width-a.width)<.1&&Math.abs(e.height-a.height)<.1&&(r=jd(a,i,Bd),r&&(s={width:Math.round(a.width/25.4*100)/100,height:Math.round(a.height/25.4*100)/100},n=a))}const[{width:a,height:o},l,h,d]=yield Promise.all([s,this.l10n.get("document_properties_page_size_unit_inches",null),r&&this.l10n.get(`document_properties_page_size_name_${r.toLowerCase()}`,null),this.l10n.get("document_properties_page_size_orientation_"+(i?"portrait":"landscape"),null)]);return{width:a.toLocaleString(),height:o.toLocaleString(),unit:l,name:h,orientation:d}}))},Pd=function(){$l(this,xd,new AbortController);const{signal:t}=Ul(this,xd,"f"),e={signal:t};this.eventBus._on("pagesinit",Ul(this,gd,"m",Md).bind(this),e),this.eventBus._on("scalechanging",Ul(this,gd,"m",Ld).bind(this),e),this.eventBus._on("pagechanging",Ul(this,gd,"m",Dd).bind(this),e),this.eventBus._on("pagerendered",Ul(this,gd,"m",Rd).bind(this),e),this.eventBus._on("rotationchanging",Ul(this,gd,"m",Td).bind(this),e),this.eventBus._on("switchspreadmode",Ul(this,gd,"m",kd).bind(this),e),this.eventBus._on("switchscrollmode",Ul(this,gd,"m",Id).bind(this),e)},Md=function(t){return zl(this,arguments,void 0,(function*({source:t}){var e;const i=yield null===(e=this.document)||void 0===e?void 0:e.getOutline(),s=this.store.getState().scaleValue;t.currentScale=1,t.currentScaleValue="auto",this.store.setState({documentOutline:i,pageNumber:1,scaleValue:s,pagesReady:!0})}))},Td=function({pagesRotation:t,pageNumber:e}){this.store.setState({pagesRotation:t}),this.thumbnailViewer&&(this.thumbnailViewer.pagesRotation=t),this.forceRendering(),this.viewer.currentPageNumber=e},kd=function({mode:t}){this.store.setState({spreadMode:t})},Id=function({mode:t}){this.store.setState({scrollMode:t})},Ld=function({scale:t,presetValue:e}){this.store.setState({scale:t,scaleValue:e}),this.viewer.update()},Dd=function({pageNumber:t}){var e;null===(e=this.thumbnailViewer)||void 0===e||e.scrollThumbnailIntoView(t),this.store.setState({pageNumber:t})},Rd=function({pageNumber:t,error:e}){var i;if(Ul(this,vd,"f")){const e=this.viewer.getPageView(t-1),s=null===(i=this.thumbnailViewer)||void 0===i?void 0:i.getThumbnail(t-1);e&&s&&s.setImage(e)}};var Hd=function(){},zd="undefined"!=typeof window,Ud=zd?e.useLayoutEffect:e.useEffect;function $d(t,i,s){void 0===s&&(s=[]);var n=function(t,i){var s=e.useRef(!1),n=e.useRef(),r=e.useRef(t),a=e.useCallback((function(){return s.current}),[]),o=e.useCallback((function(){s.current=!1,n.current&&clearTimeout(n.current),n.current=setTimeout((function(){s.current=!0,r.current()}),i)}),[i]),l=e.useCallback((function(){s.current=null,n.current&&clearTimeout(n.current)}),[]);return e.useEffect((function(){r.current=t}),[t]),e.useEffect((function(){return o(),l}),[i]),[a,l,o]}(t,i),r=n[0],a=n[1],o=n[2];return e.useEffect(o,s),[r,a]}var Wd={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};var Gd=zd&&void 0!==window.ResizeObserver?function(){var t=e.useState(null),i=t[0],s=t[1],n=e.useState(Wd),r=n[0],a=n[1],o=e.useMemo((function(){return new window.ResizeObserver((function(t){if(t[0]){var e=t[0].contentRect,i=e.x,s=e.y,n=e.width,r=e.height,o=e.top,l=e.left,h=e.bottom,d=e.right;a({x:i,y:s,width:n,height:r,top:o,left:l,bottom:h,right:d})}}))}),[]);return Ud((function(){if(i)return o.observe(i),function(){o.disconnect()}}),[i]),[s,r]}:function(){return[Hd,Wd]};function qd({usePDFSlickStore:t,viewerRef:e,className:s}){const n=t((t=>t.pdfSlick)),r=t((t=>t.scaleValue)),[a,{width:o}]=Gd();return $d((()=>{o&&(!n||"auto"!==r&&"page-fit"!==r&&"page-width"!==r||(n.viewer.currentScaleValue=r),null==n||n.viewer.update())}),0,[o]),i.jsx("div",{ref:t=>{e(t),a(t)},id:"viewerContainer",className:`pdfSlickContainer ${null!=s?s:""}`,style:{position:"absolute",inset:0,overflow:"auto"},children:i.jsx("div",{id:"viewer",className:"pdfSlickViewer pdfViewer"})})}function Xd({children:t,thumbsRef:e,usePDFSlickStore:n,className:r}){const a=n((t=>t.thumbnailViews)),o=n((t=>t.pdfSlick)),[l,{width:h}]=Gd();return $d((()=>{h&&(null==o||o.forceRendering())}),0,[h]),i.jsx("div",{ref:t=>{e(t),l(t)},className:r,style:{position:"absolute",overflow:"auto",inset:0},children:Array.from(a).map((([e,i])=>{var n;return s.createPortal(t({pageNumber:e,width:i.canvasWidth,height:i.canvasHeight,scale:i.scale,src:null!==(n=null==i?void 0:i.src)&&void 0!==n?n:null,rotation:i.rotation,pageLabel:i.pageLabel,loaded:i.loaded}),i.div)}))})}function Kd(t){return function(i,s){return function(t,i=w,s){const n=v(t.subscribe,t.getState,t.getInitialState,i,s);return e.useDebugValue(n),n}(t,i,s)}}t.AutoPrintRegExp=/\bprint\s*\(/,t.CursorTool={SELECT:0,HAND:1,ZOOM:2},t.DEFAULT_SCALE=1,t.DEFAULT_SCALE_DELTA=1.1,t.DEFAULT_SCALE_VALUE="auto",t.MAX_AUTO_SCALE=1.25,t.MAX_SCALE=10,t.MIN_SCALE=.1,t.OutputScale=Ql,t.PDFSlick=Vd,t.PDFSlickThumbnails=Xd,t.PDFSlickViewer=qd,t.PresentationModeState=Gl,t.ProgressBar=class{constructor(t){Ml.set(this,void 0),Tl.set(this,null),kl.set(this,0),Il.set(this,void 0),Ll.set(this,!0),$l(this,Ml,t.classList),$l(this,Il,t.style)}get percent(){return Ul(this,kl,"f")}set percent(t){var e,i,s;$l(this,kl,(e=t,i=0,s=100,Math.min(Math.max(e,i),s))),isNaN(t)?Ul(this,Ml,"f").add("indeterminate"):(Ul(this,Ml,"f").remove("indeterminate"),Ul(this,Il,"f").setProperty("--progressBar-percent",`${Ul(this,kl,"f")}%`))}setWidth(t){if(!t)return;const e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&Ul(this,Il,"f").setProperty("--progressBar-end-offset",`${e}px`)}setDisableAutoFetch(t=5e3){100===Ul(this,kl,"f")||isNaN(Ul(this,kl,"f"))||(Ul(this,Tl,"f")&&clearTimeout(Ul(this,Tl,"f")),this.show(),$l(this,Tl,setTimeout((()=>{$l(this,Tl,null),this.hide()}),t)))}hide(){Ul(this,Ll,"f")&&($l(this,Ll,!1),Ul(this,Ml,"f").add("hidden"))}show(){Ul(this,Ll,"f")||($l(this,Ll,!0),Ul(this,Ml,"f").remove("hidden"))}},t.RendererType={CANVAS:"canvas",SVG:"svg"},t.RenderingStates=Wl,t.SCROLLBAR_PADDING=40,t.ScrollMode=Kl,t.SidebarView=ql,t.SpreadMode=Yl,t.TextLayerMode=Xl,t.UNKNOWN_SCALE=0,t.VERTICAL_PADDING=5,t.animationStarted=ch,t.apiPageLayoutToViewerModes=function(t){let e=Kl.VERTICAL,i=Yl.NONE;switch(t){case"SinglePage":e=Kl.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=Kl.PAGE;case"TwoColumnLeft":i=Yl.ODD;break;case"TwoPageRight":e=Kl.PAGE;case"TwoColumnRight":i=Yl.EVEN}return{scrollMode:e,spreadMode:i}},t.apiPageModeToSidebarView=function(t){switch(t){case"UseNone":return ql.NONE;case"UseThumbs":return ql.THUMBS;case"UseOutlines":return ql.OUTLINE;case"UseAttachments":return ql.ATTACHMENTS;case"UseOC":return ql.LAYERS}return ql.NONE},t.approximateFraction=function(t){if(Math.floor(t)===t)return[t,1];const e=1/t;if(e>8)return[1,8];if(Math.floor(e)===e)return[1,e];const i=t>1?e:t;let s,n=0,r=1,a=1,o=1;for(;;){const t=n+a,e=r+o;if(e>8)break;i<=t/e?(a=t,o=e):(n=t,r=e)}return s=i-n/r<a/o-i?i===t?[n,r]:[r,n]:i===t?[a,o]:[o,a],s},t.backtrackBeforeAllVisibleElements=sh,t.binarySearchFirstItem=eh,t.calcRound=ph,t.create=od,t.createStore=Kd,t.docStyle=uh,t.floorToDivide=function(t,e){return t-t%e},t.getActiveOrFocusedElement=function(){let t=document,e=t.activeElement||t.querySelector(":focus");for(;null==e?void 0:e.shadowRoot;)t=e.shadowRoot,e=t.activeElement||t.querySelector(":focus");return e},t.getPageSizeInches=ih,t.getVisibleElements=nh,t.initialState=ad,t.isPortraitOrientation=dh,t.isValidRotation=oh,t.isValidScrollMode=lh,t.isValidSpreadMode=hh,t.normalizeWheelEventDelta=ah,t.normalizeWheelEventDirection=rh,t.parseQueryString=function(t){const e=new Map;for(const[i,s]of new URLSearchParams(t))e.set(i.toLowerCase(),s);return e},t.removeNullCharacters=function(t,e=!1){return th.test(t)?e?t.replaceAll(th,(t=>"\0"===t?"":" ")):t.replaceAll("\0",""):t},t.scrollIntoView=Jl,t.toggleCheckedBtn=function(t,e,i=null){t.classList.toggle("toggled",e),t.setAttribute("aria-checked",String(e)),null==i||i.classList.toggle("hidden",!e)},t.toggleExpandedBtn=function(t,e,i=null){t.classList.toggle("toggled",e),t.setAttribute("aria-expanded",String(e)),null==i||i.classList.toggle("hidden",!e)},t.usePDFSlick=(t,i)=>{const[s,n]=e.useState(!1),[r,a]=e.useState(null),[o,l]=e.useState(null),[h,d]=e.useState(null),c=e.useMemo((()=>od()),[]),u=e.useMemo((()=>Kd(c)),[]),p=e.useCallback((t=>{null!==t&&a(t)}),[]),g=e.useCallback((t=>{null!==t&&l(t)}),[]);return e.useEffect((()=>{if(t&&r){const e=new Vd({container:r,thumbs:o,store:c,options:i,onError:t=>d(t)});e.loadDocument(t,i).then((()=>{n(!0)})),c.setState({pdfSlick:e})}return()=>{}}),[t,r]),{isDocumentLoaded:s,viewerRef:p,thumbsRef:g,usePDFSlickStore:u,store:c,PDFSlickViewer:qd,PDFSlickThumbnails:Xd,error:h}},t.watchScroll=Zl}));