@pdfslick/react 3.0.0 → 4.0.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 a(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var r,o,l,h,d={exports:{}},c={},u={exports:{}},p={};function g(){return o||(o=1,u.exports=function(){if(r)return p;r=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,a=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(),r=s({inst:{value:i,getSnapshot:e}}),h=r[0].inst,d=r[1];return a((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}
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,n){"use strict";var s="undefined"!=typeof document?document.currentScript:null;function a(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var r,o,l,h,d={exports:{}},c={},u={exports:{}},p={};function g(){return o||(o=1,u.exports=function(){if(r)return p;r=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},n=t.useState,s=t.useEffect,a=t.useLayoutEffect,o=t.useDebugValue;function l(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!i(t,n)}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(),r=n({inst:{value:i,getSnapshot:e}}),h=r[0].inst,d=r[1];return a(function(){h.value=i,h.getSnapshot=e,l(h)&&d({inst:h})},[t,i,e]),s(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
- */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,a=t.useRef,r=t.useEffect,o=t.useMemo,h=t.useDebugValue;return c.useSyncExternalStoreWithSelector=function(t,e,i,l,d){var c=a(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(!r){if(r=!0,n=t,t=l(t),void 0!==d&&u.hasValue){var e=u.value;if(d(e,t))return a=e}return a=t}if(e=a,s(n,t))return e;var i=l(t);return void 0!==d&&d(e,i)?(n=t,e):(n=t,a=i)}var n,a,r=!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 r((function(){u.hasValue=!0,u.value=p}),[p]),h(p),p},c}()),d.exports),m=a(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,a={setState:s,getState:n,getInitialState:()=>r,subscribe:t=>(i.add(t),()=>i.delete(t))},r=e=t(s,n,a);return a},{useSyncExternalStoreWithSelector:v}=m,w=t=>t;
10
+ */var m=(h||(h=1,d.exports=function(){if(l)return c;l=1;var t=e,i=g(),n="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},s=i.useSyncExternalStore,a=t.useRef,r=t.useEffect,o=t.useMemo,h=t.useDebugValue;return c.useSyncExternalStoreWithSelector=function(t,e,i,l,d){var c=a(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(!r){if(r=!0,s=t,t=l(t),void 0!==d&&u.hasValue){var e=u.value;if(d(e,t))return a=e}return a=t}if(e=a,n(s,t))return e;var i=l(t);return void 0!==d&&d(e,i)?(s=t,e):(s=t,a=i)}var s,a,r=!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=s(t,c[0],c[1]);return r(function(){u.hasValue=!0,u.value=p},[p]),h(p),p},c}()),d.exports),f=a(m);const b=t=>{let e;const i=new Set,n=(t,n)=>{const s="function"==typeof t?t(e):t;if(!Object.is(s,e)){const t=e;e=(null!=n?n:"object"!=typeof s||null===s)?s:Object.assign({},e,s),i.forEach(i=>i(e,t))}},s=()=>e,a={setState:n,getState:s,getInitialState:()=>r,subscribe:t=>(i.add(t),()=>i.delete(t))},r=e=t(n,s,a);return a},{useSyncExternalStoreWithSelector:v}=f,w=t=>t;
11
11
  /**
12
12
  * @licstart The following is the entire license notice for the
13
13
  * JavaScript code in this page
@@ -29,7 +29,7 @@
29
29
  * @licend The above is the entire license notice for the
30
30
  * JavaScript code in this page
31
31
  */
32
- const y=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),A=[.001,0,0,.001,0,0],_=1.35,x=1,S=2,C=4,E=16,P=32,T=64,M=128,I=256,k={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},L={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,SIGNATURE:101},D={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},R=0,N=1,F=2,O=3,B=3,j=4,V={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},H={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},U=1,z=2,$=3,W=4,G=5,q={ERRORS:0,WARNINGS:1,INFOS:5},X={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,rawFillPath:94},K=0,Y=1,Q=2,Z=3;let J=q.WARNINGS;function tt(t){Number.isInteger(t)&&(J=t)}function et(){return J}function it(t){J>=q.INFOS&&console.log(`Info: ${t}`)}function st(t){J>=q.WARNINGS&&console.log(`Warning: ${t}`)}function nt(t){throw new Error(t)}function at(t,e){t||nt(e)}function rt(t,e=null,i=null){if(!t)return null;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?URL.parse(t,e):URL.parse(t);return function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s)?s:null}function ot(t,e,i=!1){const s=URL.parse(t);return s?(s.hash=e,s.href):i&&rt(t,"http://example.com")?t.split("#",1)[0]+""+(e?`#${e}`:""):""}function lt(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}const ht=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class dt extends ht{constructor(t,e){super(t,"PasswordException"),this.code=e}}class ct extends ht{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}let ut=class extends ht{constructor(t){super(t,"InvalidPDFException")}},pt=class extends ht{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}};class gt extends ht{constructor(t){super(t,"FormatError")}}let ft=class extends ht{constructor(t){super(t,"AbortException")}};function mt(t){"object"==typeof t&&void 0!==t?.length||nt("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 a=Math.min(n+i,e),r=t.subarray(n,a);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function bt(t){"string"!=typeof t&&nt("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}class vt{static get isLittleEndian(){return lt(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return lt(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return lt(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return lt(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){if("undefined"!=typeof navigator&&"string"==typeof navigator?.platform&&"string"==typeof navigator?.userAgent){const{platform:t,userAgent:e}=navigator;return lt(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}return lt(this,"platform",{isAndroid:!1,isLinux:!1,isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return lt(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const wt=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));let yt=class{static makeHexColor(t,e,i){return`#${wt[t]}${wt[e]}${wt[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,i=0){const s=t[i],n=t[i+1];t[i]=s*e[0]+n*e[2]+e[4],t[i+1]=s*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){const s=e[0],n=e[1],a=e[2],r=e[3],o=e[4],l=e[5];for(let e=0;e<6;e+=2){const h=t[i+e],d=t[i+e+1];t[i+e]=h*s+d*a+o,t[i+e+1]=h*n+d*r+l}}static applyInverseTransform(t,e){const i=t[0],s=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-s*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-i*e[1]+s*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,i){const s=e[0],n=e[1],a=e[2],r=e[3],o=e[4],l=e[5],h=t[0],d=t[1],c=t[2],u=t[3];let p=s*h+o,g=p,f=s*c+o,m=f,b=r*d+l,v=b,w=r*u+l,y=w;if(0!==n||0!==a){const t=n*h,e=n*c,i=a*d,s=a*u;p+=i,m+=i,f+=s,g+=s,b+=t,y+=t,w+=e,v+=e}i[0]=Math.min(i[0],p,f,g,m),i[1]=Math.min(i[1],b,w,v,y),i[2]=Math.max(i[2],p,f,g,m),i[3]=Math.max(i[3],b,w,v,y)}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,e){const i=t[0],s=t[1],n=t[2],a=t[3],r=i**2+s**2,o=i*n+s*a,l=n**2+a**2,h=(r+l)/2,d=Math.sqrt(h**2-(r*l-o**2));e[0]=Math.sqrt(h+d||1),e[1]=Math.sqrt(h-d||1)}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])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>a?null:[i,n,s,a]}static pointBoundingBox(t,e,i){i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],t),i[3]=Math.max(i[3],e)}static rectBoundingBox(t,e,i,s,n){n[0]=Math.min(n[0],t,i),n[1]=Math.min(n[1],e,s),n[2]=Math.max(n[2],t,i),n[3]=Math.max(n[3],e,s)}static#t(t,e,i,s,n,a,r,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*a)+3*c*r)+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,a,r,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,a,r,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,a,r,o,(-h+p)/g,c),this.#t(t,e,i,s,n,a,r,o,(-h-p)/g,c)}static bezierBoundingBox(t,e,i,s,n,a,r,o,l){l[0]=Math.min(l[0],t,r),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,r),l[3]=Math.max(l[3],e,o),this.#e(t,i,n,r,e,s,a,o,3*(3*(i-n)-t+r),6*(t-2*i+n),3*(i-t),l),this.#e(t,i,n,r,e,s,a,o,3*(3*(s-a)-e+o),6*(e-2*s+a),3*(s-e),l)}};let At=null,_t=null;function xt(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),mt(t)}const St="pdfjs_internal_id_";function Ct(t,e,i){return Math.min(Math.max(t,e),i)}function Et(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(mt(t))}"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise((i=>{i(t(...e))}))}),"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(t){return t.reduce(((t,e)=>t+e),0)});const Pt="http://www.w3.org/2000/svg";let Tt=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function Mt(t,e="text"){if(Ft(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 It{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:n=0,offsetY:a=0,dontFlip:r=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=n,this.offsetY=a,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.")}r&&(c=-c,u=-u),0===h?(p=Math.abs(l-t[1])*i+n,g=Math.abs(o-t[0])*i+a,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+a,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 t=this.viewBox;return lt(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new It({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){const i=[t,e];return yt.applyTransform(i,this.transform),i}convertToViewportRectangle(t){const e=[t[0],t[1]];yt.applyTransform(e,this.transform);const i=[t[2],t[3]];return yt.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){const i=[t,e];return yt.applyInverseTransform(i,this.transform),i}}let kt=class extends ht{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};function Lt(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function Dt(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function Rt(t,e="document.pdf"){if("string"!=typeof t)return e;if(Lt(t))return st('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 Nt{started=Object.create(null);times=[];time(t){t in this.started&&st(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||st(`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 Ft(t,e){const i=e?URL.parse(t,e):URL.parse(t);return"http:"===i?.protocol||"https:"===i?.protocol}function Ot(t){t.preventDefault()}function Bt(t){t.preventDefault(),t.stopPropagation()}let jt=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 a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let r=parseInt(e[5],10);r=r>=0&&r<=59?r: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?(a+=h,r+=d):"+"===l&&(a-=h,r-=d),new Date(Date.UTC(i,s,n,a,r,o))}};function Vt(t,{scale:e=1,rotation:i=0}){const{width:s,height:n}=t.attributes.style,a=[0,0,parseInt(s),parseInt(n)];return new It({viewBox:a,userUnit:1,scale:e,rotation:i})}function Ht(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):(st(`Not a valid color format: "${t}"`),[0,0,0])}function Ut(t){const{a:e,b:i,c:s,d:n,e:a,f:r}=t.getTransform();return[e,i,s,n,a,r]}function zt(t){const{a:e,b:i,c:s,d:n,e:a,f:r}=t.getTransform().invertSelf();return[e,i,s,n,a,r]}function $t(t,e,i=!1,s=!0){if(e instanceof It){const{pageWidth:s,pageHeight:n}=e.rawDims,{style:a}=t,r=vt.isCSSRoundSupported,o=`var(--total-scale-factor) * ${s}px`,l=`var(--total-scale-factor) * ${n}px`,h=r?`round(down, ${o}, var(--scale-round-x))`:`calc(${o})`,d=r?`round(down, ${l}, var(--scale-round-y))`:`calc(${l})`;i&&e.rotation%180!=0?(a.width=d,a.height=h):(a.width=h,a.height=d)}s&&t.setAttribute("data-main-rotation",e.rotation)}let Wt=class t{constructor(){const{pixelRatio:e}=t;this.sx=e,this.sy=e}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,i,s){let n=1/0,a=1/0,r=1/0;i>0&&(n=Math.sqrt(i/(t*e))),-1!==s&&(a=s/t,r=s/e);const o=Math.min(n,a,r);return(this.sx>o||this.sy>o)&&(this.sx=o,this.sy=o,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}};const Gt=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class qt{#s=null;#n=null;#a;#r=null;#o=null;#l=null;static#h=null;constructor(t){this.#a=t,qt.#h||=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",signature:"pdfjs-editor-remove-signature-button"})}render(){const t=this.#s=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#a._uiManager._signal;t.addEventListener("contextmenu",Ot,{signal:e}),t.addEventListener("pointerdown",qt.#d,{signal:e});const i=this.#r=document.createElement("div");i.className="buttons",t.append(i);const s=this.#a.toolbarPosition;if(s){const{style:e}=t,i="ltr"===this.#a._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=100*i+"%",e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return this.#c(),t}get div(){return this.#s}static#d(t){t.stopPropagation()}#u(t){this.#a._focusEventsAllowed=!1,Bt(t)}#p(t){this.#a._focusEventsAllowed=!0,Bt(t)}#g(t){const e=this.#a._uiManager._signal;t.addEventListener("focusin",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#p.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Ot,{signal:e})}hide(){this.#s.classList.add("hidden"),this.#n?.hideDropdown()}show(){this.#s.classList.remove("hidden"),this.#o?.shown()}#c(){const{editorType:t,_uiManager:e}=this.#a,i=document.createElement("button");i.className="delete",i.tabIndex=0,i.setAttribute("data-l10n-id",qt.#h[t]),this.#g(i),i.addEventListener("click",(t=>{e.delete()}),{signal:e._signal}),this.#r.append(i)}get#f(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#g(e),this.#r.prepend(e,this.#f),this.#o=t}addColorPicker(t){this.#n=t;const e=t.renderButton();this.#g(e),this.#r.prepend(e,this.#f)}async addEditSignatureButton(t){const e=this.#l=await t.renderEditButton(this.#a);this.#g(e),this.#r.prepend(e,this.#f)}updateEditSignatureButton(t){this.#l&&(this.#l.title=t)}remove(){this.#s.remove(),this.#n?.destroy(),this.#n=null}}class Xt{#r=null;#s=null;#m;constructor(t){this.#m=t}#b(){const t=this.#s=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",Ot,{signal:this.#m._signal});const e=this.#r=document.createElement("div");return e.className="buttons",t.append(e),this.#v(),t}#w(t,e){let i=0,s=0;for(const n of t){const t=n.y+n.height;if(t<i)continue;const a=n.x+(e?n.width:0);t>i?(s=a,i=t):e?a>s&&(s=a):a<s&&(s=a)}return[e?1-s:s,i]}show(t,e,i){const[s,n]=this.#w(e,i),{style:a}=this.#s||=this.#b();t.append(this.#s),a.insetInlineEnd=100*s+"%",a.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#s.remove()}#v(){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.#m._signal;t.addEventListener("contextmenu",Ot,{signal:i}),t.addEventListener("click",(()=>{this.#m.highlightSelection("floating_button")}),{signal:i}),this.#r.append(t)}}function Kt(t,e,i){for(const s of i)e.addEventListener(s,t[s].bind(t))}class Yt{#y=0;get id(){return"pdfjs_internal_editor_"+this.#y++}}class Qt{#A=xt();#y=0;#_=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 lt(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#x(t,e){this.#_||=new Map;let i=this.#_.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.#A}_${this.#y++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await Mt(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=Qt._isSVGFittingCanvas,s=new FileReader,n=new Image,a=new Promise(((t,a)=>{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=a}));s.readAsDataURL(t),await a}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){st(t),i=null}return this.#_.set(t,i),i&&this.#_.set(i.id,i),i}async getFromFile(t){const{lastModified:e,name:i,size:s,type:n}=t;return this.#x(`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return this.#x(t,t)}async getFromBlob(t,e){const i=await e;return this.#x(t,i)}async getFromId(t){this.#_||=new Map;const e=this.#_.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.#_||=new Map;let i=this.#_.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.#A}_${this.#y++}`,refCounter:1,isSvg:!1},this.#_.set(t,i),this.#_.set(i.id,i),i}getSvgUrl(t){const e=this.#_.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#_||=new Map;const e=this.#_.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.#A}_`)}}class Zt{#S=[];#C=!1;#E;#P=-1;constructor(t=128){this.#E=t}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:a=!1,keepUndo:r=!1}){if(s&&t(),this.#C)return;const o={cmd:t,undo:e,post:i,type:n};if(-1===this.#P)return this.#S.length>0&&(this.#S.length=0),this.#P=0,void this.#S.push(o);if(a&&this.#S[this.#P].type===n)return r&&(o.undo=this.#S[this.#P].undo),void(this.#S[this.#P]=o);const l=this.#P+1;l===this.#E?this.#S.splice(0,1):(this.#P=l,l<this.#S.length&&this.#S.splice(l)),this.#S.push(o)}undo(){if(-1===this.#P)return;this.#C=!0;const{undo:t,post:e}=this.#S[this.#P];t(),e?.(),this.#C=!1,this.#P-=1}redo(){if(this.#P<this.#S.length-1){this.#P+=1,this.#C=!0;const{cmd:t,post:e}=this.#S[this.#P];t(),e?.(),this.#C=!1}}hasSomethingToUndo(){return-1!==this.#P}hasSomethingToRedo(){return this.#P<this.#S.length-1}cleanType(t){if(-1!==this.#P){for(let e=this.#P;e>=0;e--)if(this.#S[e].type!==t)return this.#S.splice(e+1,this.#P-e),void(this.#P=e);this.#S.length=0,this.#P=-1}}destroy(){this.#S=null}}class Jt{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=vt.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)))}}#T(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.#T(e));if(!i)return;const{callback:s,options:{bubbles:n=!1,args:a=[],checker:r=null}}=i;r&&!r(t,e)||(s.bind(t,...a,e)(),n||Bt(e))}}class te{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",e.style.colorScheme="only light",document.body.append(e);for(const i of t.keys()){e.style.color=i;const s=window.getComputedStyle(e).color;t.set(i,Ht(s))}e.remove()}(t),lt(this,"_colors",t)}convert(t){const e=Ht(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 te._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?yt.makeHexColor(...e):t}}let ee=class t{#M=new AbortController;#I=null;#k=new Map;#L=new Map;#D=null;#R=null;#N=null;#F=new Zt;#O=null;#B=null;#j=0;#V=new Set;#H=null;#U=null;#z=new Set;_editorUndoBar=null;#$=!1;#W=!1;#G=!1;#q=null;#X=null;#K=null;#Y=null;#Q=!1;#Z=null;#J=new Yt;#tt=!1;#et=!1;#it=null;#st=null;#nt=null;#at=null;#rt=null;#ot=L.NONE;#lt=new Set;#ht=null;#dt=null;#ct=null;#ut=null;#pt={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#gt=[0,0];#ft=null;#mt=null;#bt=null;#vt=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const e=t.prototype,i=t=>t.#mt.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,a=this.TRANSLATE_BIG;return lt(this,"_keyboardManager",new Jt([[["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.#mt.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#mt.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:[-a,0],checker:i}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[n,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[a,0],checker:i}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-n],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-a],checker:i}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,n],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,a],checker:i}]]))}constructor(t,e,i,s,n,a,r,o,l,h,d,c,u,p){const g=this._signal=this.#M.signal;this.#mt=t,this.#bt=e,this.#D=i,this.#dt=s,this._eventBus=n,n._on("editingaction",this.onEditingAction.bind(this),{signal:g}),n._on("pagechanging",this.onPageChanging.bind(this),{signal:g}),n._on("scalechanging",this.onScaleChanging.bind(this),{signal:g}),n._on("rotationchanging",this.onRotationChanging.bind(this),{signal:g}),n._on("setpreference",this.onSetPreference.bind(this),{signal:g}),n._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:g}),this.#wt(),this.#yt(),this.#At(),this.#R=a.annotationStorage,this.#q=a.filterFactory,this.#ct=r,this.#Y=o||null,this.#$=l,this.#W=h,this.#G=d,this.#rt=c||null,this.viewParameters={realScale:Tt.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=u||null,this._supportsPinchToZoom=!1!==p}destroy(){this.#vt?.resolve(),this.#vt=null,this.#M?.abort(),this.#M=null,this._signal=null;for(const t of this.#L.values())t.destroy();this.#L.clear(),this.#k.clear(),this.#z.clear(),this.#at?.clear(),this.#I=null,this.#lt.clear(),this.#F.destroy(),this.#D?.destroy(),this.#dt?.destroy(),this.#Z?.hide(),this.#Z=null,this.#nt?.destroy(),this.#nt=null,this.#X&&(clearTimeout(this.#X),this.#X=null),this.#ft&&(clearTimeout(this.#ft),this.#ft=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#rt}get useNewAltTextFlow(){return this.#W}get useNewAltTextWhenAddingImage(){return this.#G}get hcmFilter(){return lt(this,"hcmFilter",this.#ct?this.#q.addHCMFilter(this.#ct.foreground,this.#ct.background):"none")}get direction(){return lt(this,"direction",getComputedStyle(this.#mt).direction)}get highlightColors(){return lt(this,"highlightColors",this.#Y?new Map(this.#Y.split(",").map((t=>t.split("=").map((t=>t.trim()))))):null)}get highlightColorNames(){return lt(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.#B=t}setMainHighlightColorPicker(t){this.#nt=t}editAltText(t,e=!1){this.#D?.editAltText(this,t,e)}getSignature(t){this.#dt?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#dt}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.#G=e}onPageChanging({pageNumber:t}){this.#j=t-1}focusMainContainer(){this.#mt.focus()}findParent(t,e){for(const i of this.#L.values()){const{x:s,y:n,width:a,height:r}=i.div.getBoundingClientRect();if(t>=s&&t<=s+a&&e>=n&&e<=n+r)return i}return null}disableUserSelect(t=!1){this.#bt.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*Tt.PDF_TO_CSS_UNITS;for(const t of this.#z)t.onScaleChanging();this.#B?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#_t({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#xt(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const e of this.#L.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:a}=e,r=e.toString(),o=this.#_t(e).closest(".textLayer"),l=this.getSelectionBoxes(o);if(!l)return;e.empty();const h=this.#xt(o),d=this.#ot===L.NONE,c=()=>{h?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:l,anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:a,text:r}),d&&this.showAllEditors("highlight",!0,!0)};d?this.switchToMode(L.HIGHLIGHT,c):c()}#St(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#_t(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#Z||=new Xt(this),this.#Z.show(e,i,"ltr"===this.direction))}addToAnnotationStorage(t){t.isEmpty()||!this.#R||this.#R.has(t.id)||this.#R.setValue(t.id,t)}#Ct(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#ht&&(this.#Z?.hide(),this.#ht=null,this.#Et({hasSelectedText:!1})));const{anchorNode:e}=t;if(e===this.#ht)return;const i=this.#_t(t).closest(".textLayer");if(i){if(this.#Z?.hide(),this.#ht=e,this.#Et({hasSelectedText:!0}),(this.#ot===L.HIGHLIGHT||this.#ot===L.NONE)&&(this.#ot===L.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#Q=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#ot===L.HIGHLIGHT?this.#xt(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.#Pt("main_toolbar"))};window.addEventListener("pointerup",n,{signal:s}),window.addEventListener("blur",n,{signal:s})}}else this.#ht&&(this.#Z?.hide(),this.#ht=null,this.#Et({hasSelectedText:!1}))}#Pt(t=""){this.#ot===L.HIGHLIGHT?this.highlightSelection(t):this.#$&&this.#St()}#wt(){document.addEventListener("selectionchange",this.#Ct.bind(this),{signal:this._signal})}#Tt(){if(this.#K)return;this.#K=new AbortController;const t=this.combinedSignal(this.#K);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#Mt(){this.#K?.abort(),this.#K=null}blur(){if(this.isShiftKeyDown=!1,this.#Q&&(this.#Q=!1,this.#Pt("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#lt)if(e.div.contains(t)){this.#st=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#st)return;const[t,e]=this.#st;this.#st=null,e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}#At(){if(this.#it)return;this.#it=new AbortController;const t=this.combinedSignal(this.#it);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#It(){this.#it?.abort(),this.#it=null}#kt(){if(this.#O)return;this.#O=new AbortController;const t=this.combinedSignal(this.#O);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})}#Lt(){this.#O?.abort(),this.#O=null}#yt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#At(),this.#kt()}removeEditListeners(){this.#It(),this.#Lt()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of this.#U)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.#U)if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#I?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const t of this.#lt){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.#U)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 st(`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.#Dt(e);this.#Rt(t)},n=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:n,mustExec:!0})}catch(t){st(`paste: "${t.message}".`)}}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0),this.#ot===L.NONE||this.isEditorHandlingKeyboard||t._keyboardManager.exec(this,e)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#Q&&(this.#Q=!1,this.#Pt("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#Et(t){Object.entries(t).some((([t,e])=>this.#pt[t]!==e))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#pt,t)}),this.#ot===L.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#Nt([[D.HIGHLIGHT_FREE,!0]]))}#Nt(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#Tt(),this.#kt(),this.#Et({isEditing:this.#ot!==L.NONE,isEmpty:this.#Ft(),hasSomethingToUndo:this.#F.hasSomethingToUndo(),hasSomethingToRedo:this.#F.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Mt(),this.#Lt(),this.#Et({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#U){this.#U=t;for(const t of this.#U)this.#Nt(t.defaultPropertiesToUpdate)}}getId(){return this.#J.id}get currentLayer(){return this.#L.get(this.#j)}getLayer(t){return this.#L.get(t)}get currentPageIndex(){return this.#j}addLayer(t){this.#L.set(t.pageIndex,t),this.#tt?t.enable():t.disable()}removeLayer(t){this.#L.delete(t.pageIndex)}async updateMode(t,e=null,i=!1){if(this.#ot!==t&&(!this.#vt||(await this.#vt.promise,this.#vt))){if(this.#vt=Promise.withResolvers(),this.#B?.commitOrRemove(),this.#ot=t,t===L.NONE)return this.setEditingState(!1),this.#Ot(),this._editorUndoBar?.hide(),void this.#vt.resolve();t===L.SIGNATURE&&await(this.#dt?.loadSignatures()),this.setEditingState(!0),await this.#Bt(),this.unselectAll();for(const e of this.#L.values())e.updateMode(t);if(!e)return i&&this.addNewEditorFromKeyboard(),void this.#vt.resolve();for(const t of this.#k.values())t.annotationElementId===e?(this.setSelected(t),t.enterInEditMode()):t.unselect();this.#vt.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#ot&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#U){switch(t){case D.CREATE:return void this.currentLayer.addNewEditor(e);case D.HIGHLIGHT_DEFAULT_COLOR:this.#nt?.updateColor(e);break;case D.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#ut||=new Map).set(t,e),this.showAllEditors("highlight",e)}for(const i of this.#lt)i.updateParams(t,e);for(const i of this.#U)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(const i of this.#k.values())i.editorType===t&&i.show(e);(this.#ut?.get(D.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#Nt([[D.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#et!==t){this.#et=t;for(const e of this.#L.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#Bt(){if(!this.#tt){this.#tt=!0;const t=[];for(const e of this.#L.values())t.push(e.enable());await Promise.all(t);for(const t of this.#k.values())t.enable()}}#Ot(){if(this.unselectAll(),this.#tt){this.#tt=!1;for(const t of this.#L.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.#X&&clearTimeout(this.#X),this.#X=setTimeout((()=>{this.focusMainContainer(),this.#X=null}),0)),this.#k.delete(t.id),t.annotationElementId&&this.#at?.delete(t.annotationElementId),this.unselect(t),t.annotationElementId&&this.#V.has(t.annotationElementId)||this.#R?.remove(t.id)}addDeletedAnnotationElement(t){this.#V.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#V.has(t)}removeDeletedAnnotationElement(t){this.#V.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#Dt(t){const e=this.#L.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#I!==t&&(this.#I=t,t&&this.#Nt(t.propertiesToUpdate))}get#jt(){let t=null;for(t of this.#lt);return t}updateUI(t){this.#jt===t&&this.#Nt(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#Nt(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#lt.has(t))return this.#lt.delete(t),t.unselect(),void this.#Et({hasSelectedEditor:this.hasSelection});this.#lt.add(t),t.select(),this.#Nt(t.propertiesToUpdate),this.#Et({hasSelectedEditor:!0})}setSelected(t){this.#B?.commitOrRemove();for(const e of this.#lt)e!==t&&e.unselect();this.#lt.clear(),this.#lt.add(t),t.select(),this.#Nt(t.propertiesToUpdate),this.#Et({hasSelectedEditor:!0})}isSelected(t){return this.#lt.has(t)}get firstSelectedEditor(){return this.#lt.values().next().value}unselect(t){t.unselect(),this.#lt.delete(t),this.#Et({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#lt.size}get isEnterHandled(){return 1===this.#lt.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#F.undo(),this.#Et({hasSomethingToUndo:this.#F.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Ft()}),this._editorUndoBar?.hide()}redo(){this.#F.redo(),this.#Et({hasSomethingToUndo:!0,hasSomethingToRedo:this.#F.hasSomethingToRedo(),isEmpty:this.#Ft()})}addCommands(t){this.#F.add(t),this.#Et({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Ft()})}cleanUndoStack(t){this.#F.cleanType(t)}#Ft(){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.#lt],i=()=>{for(const t of e)this.#Dt(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.#I?.commitOrRemove()}hasSomethingToControl(){return this.#I||this.hasSelection}#Rt(t){for(const t of this.#lt)t.unselect();this.#lt.clear();for(const e of t)e.isEmpty()||(this.#lt.add(e),e.select());this.#Et({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#lt)t.commit();this.#Rt(this.#k.values())}unselectAll(){if((!this.#I||(this.#I.commitOrRemove(),this.#ot===L.NONE))&&!this.#B?.commitOrRemove()&&this.hasSelection){for(const t of this.#lt)t.unselect();this.#lt.clear(),this.#Et({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#gt[0]+=t,this.#gt[1]+=e;const[s,n]=this.#gt,a=[...this.#lt];this.#ft&&clearTimeout(this.#ft),this.#ft=setTimeout((()=>{this.#ft=null,this.#gt[0]=this.#gt[1]=0,this.addCommands({cmd:()=>{for(const t of a)this.#k.has(t.id)&&(t.translateInPage(s,n),t.translationDone())},undo:()=>{for(const t of a)this.#k.has(t.id)&&(t.translateInPage(-s,-n),t.translationDone())},mustExec:!1})}),1e3);for(const i of a)i.translateInPage(t,e),i.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#H=new Map;for(const t of this.#lt)this.#H.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#H)return!1;this.disableUserSelect(!1);const t=this.#H;this.#H=null;let e=!1;for(const[{x:i,y:s,pageIndex:n},a]of t)a.newX=i,a.newY=s,a.newPageIndex=n,e||=i!==a.savedX||s!==a.savedY||n!==a.savedPageIndex;if(!e)return!1;const i=(t,e,i,s)=>{if(this.#k.has(t.id)){const n=this.#L.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:a}]of t)i(e,s,n,a)},undo:()=>{for(const[e,{savedX:s,savedY:n,savedPageIndex:a}]of t)i(e,s,n,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#H)for(const i of this.#H.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.#lt.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#I===t}getActive(){return this.#I}getMode(){return this.#ot}get imageManager(){return lt(this,"imageManager",new Qt)}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:a}=t.getBoundingClientRect();let r;switch(t.getAttribute("data-main-rotation")){case"90":r=(t,e,r,o)=>({x:(e-s)/a,y:1-(t+r-i)/n,width:o/a,height:r/n});break;case"180":r=(t,e,r,o)=>({x:1-(t+r-i)/n,y:1-(e+o-s)/a,width:r/n,height:o/a});break;case"270":r=(t,e,r,o)=>({x:1-(e+o-s)/a,y:(t-i)/n,width:o/a,height:r/n});break;default:r=(t,e,r,o)=>({x:(t-i)/n,y:(e-s)/a,width:r/n,height:o/a})}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(r(t,e,s,n))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#N||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#N?.delete(t)}renderAnnotationElement(t){const e=this.#N?.get(t.data.id);if(!e)return;const i=this.#R.getRawValue(e);i&&(this.#ot!==L.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}setMissingCanvas(t,e,i){const s=this.#at?.get(t);s&&(s.setCanvas(e,i),this.#at.delete(t))}addMissingCanvas(t,e){(this.#at||=new Map).set(t,e)}};class ie{#o=null;#Vt=!1;#Ht=null;#Ut=null;#zt=null;#$t=null;#Wt=!1;#Gt=null;#a=null;#qt=null;#Xt=null;#Kt=!1;static#Yt=null;static _l10n=null;constructor(t){this.#a=t,this.#Kt=t._uiManager.useNewAltTextFlow,ie.#Yt||=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){ie._l10n??=t}async render(){const t=this.#Ht=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#Ut=document.createElement("span");t.append(e),this.#Kt?(t.classList.add("new"),t.setAttribute("data-l10n-id",ie.#Yt.missing),e.setAttribute("data-l10n-id",ie.#Yt["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.#a._uiManager._signal;t.addEventListener("contextmenu",Ot,{signal:i}),t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:i});const s=t=>{t.preventDefault(),this.#a._uiManager.editAltText(this.#a),this.#Kt&&this.#a._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#Qt}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",(e=>{e.target===t&&"Enter"===e.key&&(this.#Wt=!0,s(e))}),{signal:i}),await this.#Zt(),t}get#Qt(){return(this.#o?"added":null===this.#o&&this.guessedText&&"review")||"missing"}finish(){this.#Ht&&(this.#Ht.focus({focusVisible:this.#Wt}),this.#Wt=!1)}isEmpty(){return this.#Kt?null===this.#o:!this.#o&&!this.#Vt}hasData(){return this.#Kt?null!==this.#o||!!this.#qt:this.isEmpty()}get guessedText(){return this.#qt}async setGuessedText(t){null===this.#o&&(this.#qt=t,this.#Xt=await ie._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#Zt())}toggleAltTextBadge(t=!1){if(!this.#Kt||this.#o)return this.#Gt?.remove(),void(this.#Gt=null);if(!this.#Gt){const t=this.#Gt=document.createElement("div");t.className="noAltTextBadge",this.#a.div.append(t)}this.#Gt.classList.toggle("hidden",!t)}serialize(t){let e=this.#o;return t||this.#qt!==e||(e=this.#Xt),{altText:e,decorative:this.#Vt,guessedText:this.#qt,textWithDisclaimer:this.#Xt}}get data(){return{altText:this.#o,decorative:this.#Vt}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:n=!1}){i&&(this.#qt=i,this.#Xt=s),this.#o===t&&this.#Vt===e||(n||(this.#o=t,this.#Vt=e),this.#Zt())}toggle(t=!1){this.#Ht&&(!t&&this.#$t&&(clearTimeout(this.#$t),this.#$t=null),this.#Ht.disabled=!t)}shown(){this.#a._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#Qt}})}destroy(){this.#Ht?.remove(),this.#Ht=null,this.#Ut=null,this.#zt=null,this.#Gt?.remove(),this.#Gt=null}async#Zt(){const t=this.#Ht;if(!t)return;if(this.#Kt){if(t.classList.toggle("done",!!this.#o),t.setAttribute("data-l10n-id",ie.#Yt[this.#Qt]),this.#Ut?.setAttribute("data-l10n-id",ie.#Yt[`${this.#Qt}-label`]),!this.#o)return void this.#zt?.remove()}else{if(!this.#o&&!this.#Vt)return t.classList.remove("done"),void this.#zt?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#zt;if(!e){this.#zt=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#a.id}`;const i=100,s=this.#a._uiManager._signal;s.addEventListener("abort",(()=>{clearTimeout(this.#$t),this.#$t=null}),{once:!0}),t.addEventListener("mouseenter",(()=>{this.#$t=setTimeout((()=>{this.#$t=null,this.#zt.classList.add("show"),this.#a._reportTelemetry({action:"alt_text_tooltip"})}),i)}),{signal:s}),t.addEventListener("mouseleave",(()=>{this.#$t&&(clearTimeout(this.#$t),this.#$t=null),this.#zt?.classList.remove("show")}),{signal:s})}this.#Vt?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.#a.getElementForAltText();i?.setAttribute("aria-describedby",e.id)}}let se=class t{#mt;#Jt=!1;#te=null;#ee;#ie;#se;#ne;#ae=null;#re;#oe=null;#le;#he=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:a=null,signal:r}){this.#mt=t,this.#te=i,this.#ee=e,this.#ie=s,this.#se=n,this.#ne=a,this.#le=new AbortController,this.#re=AbortSignal.any([r,this.#le.signal]),t.addEventListener("touchstart",this.#de.bind(this),{passive:!1,signal:this.#re})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Wt.pixelRatio}#de(t){if(this.#ee?.())return;if(1===t.touches.length){if(this.#ae)return;const t=this.#ae=new AbortController,e=AbortSignal.any([this.#re,t.signal]),i=this.#mt,s={capture:!0,signal:e,passive:!1},n=t=>{"touch"===t.pointerType&&(this.#ae?.abort(),this.#ae=null)};return i.addEventListener("pointerdown",(t=>{"touch"===t.pointerType&&(Bt(t),n(t))}),s),i.addEventListener("pointerup",n,s),void i.addEventListener("pointercancel",n,s)}if(!this.#he){this.#he=new AbortController;const t=AbortSignal.any([this.#re,this.#he.signal]),e=this.#mt,i={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",this.#ce.bind(this),i);const s=this.#ue.bind(this);e.addEventListener("touchend",s,i),e.addEventListener("touchcancel",s,i),i.capture=!0,e.addEventListener("pointerdown",Bt,i),e.addEventListener("pointermove",Bt,i),e.addEventListener("pointercancel",Bt,i),e.addEventListener("pointerup",Bt,i),this.#ie?.()}if(Bt(t),2!==t.touches.length||this.#te?.())return void(this.#oe=null);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#oe={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#ce(e){if(!this.#oe||2!==e.touches.length)return;Bt(e);let[i,s]=e.touches;i.identifier>s.identifier&&([i,s]=[s,i]);const{screenX:n,screenY:a}=i,{screenX:r,screenY:o}=s,l=this.#oe,{touch0X:h,touch0Y:d,touch1X:c,touch1Y:u}=l,p=c-h,g=u-d,f=r-n,m=o-a,b=Math.hypot(f,m)||1,v=Math.hypot(p,g)||1;if(!this.#Jt&&Math.abs(v-b)<=t.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=n,l.touch0Y=a,l.touch1X=r,l.touch1Y=o,!this.#Jt)return void(this.#Jt=!0);const w=[(n+r)/2,(a+o)/2];this.#se?.(w,v,b)}#ue(t){t.touches.length>=2||(this.#he&&(this.#he.abort(),this.#he=null,this.#ne?.()),this.#oe&&(Bt(t),this.#oe=null,this.#Jt=!1))}destroy(){this.#le?.abort(),this.#le=null,this.#ae?.abort(),this.#ae=null}};class ne{#pe=null;#ge=null;#o=null;#fe=!1;#me=null;#be="";#ve=!1;#we=null;#ye=null;#Ae=null;#_e=null;#xe="";#Se=!1;#Ce=null;#Ee=!1;#Pe=!1;#Te=!1;#Me=null;#Ie=0;#ke=0;#Le=null;#De=null;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#Re=!1;#Ne=ne._zIndex++;static _borderLineWidth=-1;static _colorManager=new te;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=ne.prototype._resizeWithKeyboard,e=ee.TRANSLATE_SMALL,i=ee.TRANSLATE_BIG;return lt(this,"_resizerKeyboardManager",new Jt([[["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"],ne.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:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[n,a];const[r,o]=this.parentDimensions;this.x=t.x/r,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 lt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new ae({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(ne._l10n??=t,ne._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!==ne._borderLineWidth)return;const i=getComputedStyle(document.documentElement);ne._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){nt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#Re}set _isDraggable(t){this.#Re=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.#Ne}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#Fe(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#Se?this.#Se=!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,a]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/a,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s),this._onTranslated()}#Oe([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.#Oe(this.parentDimensions,t,e)}translateInPage(t,e){this.#Ce||=[this.x,this.y,this.width,this.height],this.#Oe(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#Ce||=[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:a,y:r}=this;const[o,l]=this.getBaseTranslation();a+=o,r+=l;const{style:h}=i;h.left=`${(100*a).toFixed(2)}%`,h.top=`${(100*r).toFixed(2)}%`,this._onTranslating(a,r),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#Ce&&(this.#Ce[0]!==this.x||this.#Ce[1]!==this.y)}get _hasBeenResized(){return!!this.#Ce&&(this.#Ce[2]!==this.width||this.#Ce[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=ne,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:a,width:r,height:o}=this;if(r*=i,o*=s,n*=i,a*=s,this._mustFixPosition)switch(t){case 0:n=Ct(n,0,i-r),a=Ct(a,0,s-o);break;case 90:n=Ct(n,0,i-o),a=Ct(a,r,s);break;case 180:n=Ct(n,r,i),a=Ct(a,o,s);break;case 270:n=Ct(n,o,i),a=Ct(a,0,s-r)}this.x=n/=i,this.y=a/=s;const[l,h]=this.getBaseTranslation();n+=l,a+=h,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}static#Be(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 ne.#Be(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return ne.#Be(t,e,360-this.parentRotation)}#je(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.#ve||(n.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:i}=t,s=i.endsWith("%"),n=!this.#ve&&e.endsWith("%");if(s&&n)return;const[a,r]=this.parentDimensions;s||(t.width=`${(100*parseFloat(i)/a).toFixed(2)}%`),this.#ve||n||(t.height=`${(100*parseFloat(e)/r).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#Ve(){if(this.#we)return;this.#we=document.createElement("div"),this.#we.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.#we.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#He.bind(this,i),{signal:e}),t.addEventListener("contextmenu",Ot,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#we)}#He(t,e){e.preventDefault();const{isMac:i}=vt.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#o?.toggle(!1);const s=this._isDraggable;this._isDraggable=!1,this.#ye=[e.screenX,e.screenY];const n=new AbortController,a=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#Ue.bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Bt,{passive:!1,signal:a}),window.addEventListener("contextmenu",Ot,{signal:a}),this.#Ae={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const r=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=r,this.div.style.cursor=o,this.#ze()};window.addEventListener("pointerup",l,{signal:a}),window.addEventListener("blur",l,{signal:a})}#$e(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e;const[n,a]=this.parentDimensions;this.setDims(n*i,a*s),this.fixAndSetPosition(),this._onResized()}_onResized(){}#ze(){if(!this.#Ae)return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#Ae;this.#Ae=null;const n=this.x,a=this.y,r=this.width,o=this.height;n===t&&a===e&&r===i&&o===s||this.addCommands({cmd:this.#$e.bind(this,n,a,r,o),undo:this.#$e.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#Ue(t,e){const[i,s]=this.parentDimensions,n=this.x,a=this.y,r=this.width,o=this.height,l=ne.MIN_SIZE/i,h=ne.MIN_SIZE/s,d=this.#je(this.rotation),c=(t,e)=>[d[0]*t+d[2]*e,d[1]*t+d[3]*e],u=this.#je(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(r,o),v=g(r,o);let w=c(...v);const y=ne._round(n+w[0]),A=ne._round(a+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.#ye;[_,x]=this.screenToPageTranslation(t-s,i-n),this.#ye[0]=t,this.#ye[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(r,o);S=C=Math.max(Math.min(Math.hypot(v[0]-b[0]-_,v[1]-b[1]-x)/t,1/r,1/o),l/r,h/o)}else m?S=Ct(Math.abs(v[0]-b[0]-_),l,1)/r:C=Ct(Math.abs(v[1]-b[1]-x),h,1)/o;const T=ne._round(r*S),M=ne._round(o*C);w=c(...g(T,M));const I=y-w[0],k=A-w[1];this.#Ce||=[this.x,this.y,this.width,this.height],this.width=T,this.height=M,this.x=I,this.y=k,this.setDims(i*T,s*M),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#o?.finish()}async addEditToolbar(){return this._editToolbar||this.#Pe||(this._editToolbar=new qt(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||(ie.initialize(ne._l10n),this.#o=new ie(this),this.#pe&&(this.#o.data=this.#pe,this.#pe=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(){const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#fe?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#We();const[e,i]=this.parentDimensions;this.parentRotation%180!=0&&(t.style.maxWidth=`${(100*i/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/i).toFixed(2)}%`);const[s,n]=this.getInitialTranslation();return this.translate(s,n),Kt(this,t,["keydown","pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#De||=new se({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#Ge.bind(this),onPinching:this.#qe.bind(this),onPinchEnd:this.#Xe.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),t}#Ge(){this.#Ae={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#o?.toggle(!1),this.parent.togglePointerEvents(!1)}#qe(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;const n=this.#je(this.rotation),a=(t,e)=>[n[0]*t+n[2]*e,n[1]*t+n[3]*e],[r,o]=this.parentDimensions,l=this.x,h=this.y,d=this.width,c=this.height,u=ne.MIN_SIZE/r,p=ne.MIN_SIZE/o;s=Math.max(Math.min(s,1/d,1/c),u/d,p/c);const g=ne._round(d*s),f=ne._round(c*s);if(g===d&&f===c)return;this.#Ce||=[l,h,d,c];const m=a(d/2,c/2),b=ne._round(l+m[0]),v=ne._round(h+m[1]),w=a(g/2,f/2);this.x=b-w[0],this.y=v-w[1],this.width=g,this.height=f,this.setDims(r*g,o*f),this.fixAndSetPosition(),this._onResizing()}#Xe(){this.#o?.toggle(!0),this.parent.togglePointerEvents(!0),this.#ze()}pointerdown(t){const{isMac:e}=vt.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#Se=!0,this._isDraggable?this.#Ke(t):this.#Ye(t))}get isSelected(){return this._uiManager.isSelected(this)}#Ye(t){const{isMac:e}=vt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#Ke(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const s=new AbortController,n=this._uiManager.combinedSignal(s),a={capture:!0,passive:!1,signal:n},r=t=>{s.abort(),this.#me=null,this.#Se=!1,this._uiManager.endDragSession()||this.#Ye(t),i&&this._onStopDragging()};e&&(this.#Ie=t.clientX,this.#ke=t.clientY,this.#me=t.pointerId,this.#be=t.pointerType,window.addEventListener("pointermove",(t=>{i||(i=!0,this._onStartDragging());const{clientX:e,clientY:s,pointerId:n}=t;if(n!==this.#me)return void Bt(t);const[a,r]=this.screenToPageTranslation(e-this.#Ie,s-this.#ke);this.#Ie=e,this.#ke=s,this._uiManager.dragSelectedEditors(a,r)}),a),window.addEventListener("touchmove",Bt,a),window.addEventListener("pointerdown",(t=>{t.pointerType===this.#be&&(this.#De||t.isPrimary)&&r(t),Bt(t)}),a));const o=t=>{this.#me&&this.#me!==t.pointerId?Bt(t):r(t)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#Me&&clearTimeout(this.#Me),this.#Me=setTimeout((()=>{this.#Me=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,a]=this.pageDimensions,[r,o]=this.pageTranslation,l=t/s,h=e/s,d=this.x*n,c=this.y*a,u=this.width*n,p=this.height*a;switch(i){case 0:return[d+l+r,a-c-h-p+o,d+l+u+r,a-c-h+o];case 90:return[d+h+r,a-c+l+o,d+h+p+r,a-c+l+u+o];case 180:return[d-l-u+r,a-c+h+o,d-l+r,a-c+h+p+o];case 270:return[d-h-p+r,a-c-l-u+o,d-h+r,a-c-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,s,n,a]=t,r=n-i,o=a-s;switch(this.rotation){case 0:return[i,e-a,r,o];case 90:return[i,e-s,o,r];case 180:return[n,e-s,r,o];case 270:return[n,e-a,o,r];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){this.#Pe=!0}disableEditMode(){this.#Pe=!1}isInEditMode(){return this.#Pe}shouldGetKeyboardEvents(){return this.#Te}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:n,innerWidth:a}=window;return e<a&&s>0&&t<n&&i>0}#We(){if(this.#_e||!this.div)return;this.#_e=new AbortController;const t=this._uiManager.combinedSignal(this.#_e);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#We()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){nt("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.#pe=t.accessibilityData,s._isCopy=t.isCopy||!1;const[n,a]=s.pageDimensions,[r,o,l,h]=s.getRectInCurrentCoords(t.rect,a);return s.x=r/n,s.y=o/a,s.width=l/n,s.height=h/a,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#_e?.abort(),this.#_e=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#Me&&(clearTimeout(this.#Me),this.#Me=null),this.#Fe(),this.removeEditToolbar(),this.#Le){for(const t of this.#Le.values())clearTimeout(t);this.#Le=null}this.parent=null,this.#De?.destroy(),this.#De=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#Ve(),this.#we.classList.remove("hidden"))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#Ae={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#we.children;if(!this.#ge){this.#ge=Array.from(e);const t=this.#Qe.bind(this),i=this.#Ze.bind(this),s=this._uiManager._signal;for(const e of this.#ge){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.#Je.bind(this,n),{signal:s}),e.setAttribute("data-l10n-id",ne._l10nResizer[n])}}const i=this.#ge[0];let s=0;for(const t of e){if(t===i)break;s++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#ge.length/4);if(n!==s){if(n<s)for(let t=0;t<s-n;t++)this.#we.append(this.#we.firstChild);else if(n>s)for(let t=0;t<n-s;t++)this.#we.firstChild.before(this.#we.lastChild);let t=0;for(const i of e){const e=this.#ge[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",ne._l10nResizer[e])}}this.#ti(0),this.#Te=!0,this.#we.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#Qe(t){ne._resizerKeyboardManager.exec(this,t)}#Ze(t){this.#Te&&t.relatedTarget?.parentNode!==this.#we&&this.#Fe()}#Je(t){this.#xe=this.#Te?t:""}#ti(t){if(this.#ge)for(const e of this.#ge)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#Te&&this.#Ue(this.#xe,{deltaX:t,deltaY:e,fromKeyboard:!0})}#Fe(){this.#Te=!1,this.#ti(-1),this.#ze()}_stopResizingWithKeyboard(){this.#Fe(),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.#we?.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(){}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#Ee}set isEditing(t){this.#Ee=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#ve=!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.#Le||=new Map;const{action:e}=t;let i=this.#Le.get(e);return i&&clearTimeout(i),i=setTimeout((()=>{this._reportTelemetry(t),this.#Le.delete(e),0===this.#Le.size&&(this.#Le=null)}),ne._telemetryTimeout),void this.#Le.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.#fe=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#fe=!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 ae extends ne{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const re=3285377520,oe=4294901760,le=65535;class he{constructor(t){this.h1=t?4294967295&t:re,this.h2=t?4294967295&t:re}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,a=new Uint32Array(e.buffer,0,s);let r=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?(r=a[t],r=r*d&oe|r*u&le,r=r<<15|r>>>17,r=r*c&oe|r*p&le,l^=r,l=l<<13|l>>>19,l=5*l+3864292196):(o=a[t],o=o*d&oe|o*u&le,o=o<<15|o>>>17,o=o*c&oe|o*p&le,h^=o,h=h<<13|h>>>19,h=5*h+3864292196);switch(r=0,n){case 3:r^=e[4*s+2]<<16;case 2:r^=e[4*s+1]<<8;case 1:r^=e[4*s],r=r*d&oe|r*u&le,r=r<<15|r>>>17,r=r*c&oe|r*p&le,1&s?l^=r:h^=r}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&oe|36045*t&le,e=4283543511*e&oe|(2950163797*(e<<16|t>>>16)&oe)>>>16,t^=e>>>1,t=444984403*t&oe|60499*t&le,e=3301882366*e&oe|(3120437893*(e<<16|t>>>16)&oe)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const de=Object.freeze({map:null,hash:"",transfer:void 0});class ce{#ei=!1;#ii=null;#si=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=this.#si.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#si.get(t)}remove(t){if(this.#si.delete(t),0===this.#si.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of this.#si.values())if(t instanceof ne)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=this.#si.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.#si.set(t,e);s&&this.#ni(),e instanceof ne&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#si.has(t)}get size(){return this.#si.size}#ni(){this.#ei||(this.#ei=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#ei&&(this.#ei=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new ue(this)}get serializable(){if(0===this.#si.size)return de;const t=new Map,e=new he,i=[],s=Object.create(null);let n=!1;for(const[i,a]of this.#si){const r=a instanceof ne?a.serialize(!1,s):a;r&&(t.set(i,r),e.update(`${i}:${JSON.stringify(r)}`),n||=!!r.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}:de}get editorStats(){let t=null;const e=new Map;for(const i of this.#si.values()){if(!(i instanceof ne))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 a=t[n]||=new Map;for(const[t,e]of Object.entries(s)){if("type"===t)continue;let i=a.get(t);i||(i=new Map,a.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.#ii=null}get modifiedIds(){if(this.#ii)return this.#ii;const t=[];for(const e of this.#si.values())e instanceof ne&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return this.#ii={ids:new Set(t),hash:t.join(",")}}[Symbol.iterator](){return this.#si.entries()}}class ue extends ce{#ai;constructor(t){super();const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);this.#ai={map:n,hash:i,transfer:s}}get print(){nt("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ai}get modifiedIds(){return lt(this,"modifiedIds",{ids:new Set,hash:""})}}class pe{#ri=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.#ri.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}){if(t&&!this.#ri.has(t.loadedName))if(at(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:e,src:s,style:n}=t,a=new FontFace(e,s,n);this.addNativeFontFace(a);try{await a.load(),this.#ri.add(e),i?.(t)}catch{st(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}}else nt("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 st(`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 lt(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return lt(this,"isSyncFontLoadingSupported",y||vt.platform.isFirefox)}_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 lt(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,a;const r=this._document.createElement("canvas");r.width=1,r.height=1;const o=r.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,a=h.length-3;n<a;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 st("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 ge{constructor(t,e=null){this.compiledGlyphs=Object.create(null);for(const e in t)this[e]=t[e];this._inspectFont=e}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,${Et(this.data)});`;let e;if(this.cssFontInfo){let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`}else e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;return this._inspectFont?.(this,t),e}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){st(`getPathGenerator - ignoring character: "${t}".`)}const n=new Path2D(s||"");return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=n}}const fe=1,me=2,be=1,ve=2,we=3,ye=4,Ae=5,_e=6,xe=7,Se=8;function Ce(){}function Ee(t){if(t instanceof ft||t instanceof ut||t instanceof dt||t instanceof pt||t instanceof ct)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||nt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new ft(t.message);case"InvalidPDFException":return new ut(t.message);case"PasswordException":return new dt(t.message,t.code);case"ResponseException":return new pt(t.message,t.status,t.missing);case"UnknownErrorException":return new ct(t.message,t.details)}return new ct(t.message,t.toString())}class Pe{#oi=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.#li.bind(this),{signal:this.#oi.signal})}#li({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#hi(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===fe)i.resolve(t.data);else{if(t.callback!==me)throw new Error("Unexpected callback case");i.reject(Ee(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:fe,callbackId:t.callbackId,data:e})}),(function(e){n.postMessage({sourceName:i,targetName:s,callback:me,callbackId:t.callbackId,reason:Ee(e)})}))}else t.streamId?this.#di(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++,a=this.sourceName,r=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:a,targetName:r,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:a,targetName:r,stream:_e,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:a,targetName:r,stream:be,streamId:n,reason:Ee(t)}),e.promise}},i)}#di(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,a=this,r=this.actionHandler[t.action],o={enqueue(t,a=1,r){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=a,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:i,targetName:s,stream:ye,streamId:e,chunk:t},r)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:we,streamId:e}),delete a.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:Ae,streamId:e,reason:Ee(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(r,t.data,o).then((function(){n.postMessage({sourceName:i,targetName:s,stream:Se,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Se,streamId:e,reason:Ee(t)})}))}#hi(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,a=this.streamControllers[e],r=this.streamSinks[e];switch(t.stream){case Se:t.success?a.startCall.resolve():a.startCall.reject(Ee(t.reason));break;case xe:t.success?a.pullCall.resolve():a.pullCall.reject(Ee(t.reason));break;case _e:if(!r){n.postMessage({sourceName:i,targetName:s,stream:xe,streamId:e,success:!0});break}r.desiredSize<=0&&t.desiredSize>0&&r.sinkCapability.resolve(),r.desiredSize=t.desiredSize,Promise.try(r.onPull||Ce).then((function(){n.postMessage({sourceName:i,targetName:s,stream:xe,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:xe,streamId:e,reason:Ee(t)})}));break;case ye:if(at(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case we:if(at(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),this.#ci(a,e);break;case Ae:at(a,"error should have stream controller"),a.controller.error(Ee(t.reason)),this.#ci(a,e);break;case ve:t.success?a.cancelCall.resolve():a.cancelCall.reject(Ee(t.reason)),this.#ci(a,e);break;case be:if(!r)break;const o=Ee(t.reason);Promise.try(r.onCancel||Ce,o).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:Ee(t)})})),r.sinkCapability.reject(o),r.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#ci(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#oi?.abort(),this.#oi=null}}class Te{#ui=!1;constructor({enableHWA:t=!1}){this.#ui=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.#ui})}}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){nt("Abstract method `_createCanvas` called.")}}class Me extends Te{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}}class Ie{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){nt("Abstract method `_fetch` called.")}}class ke extends Ie{async _fetch(t){const e=await Mt(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):bt(e)}}class Le{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 De extends Le{#pi;#gi;#fi;#mi;#bi;#vi;#y=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#mi=t,this.#bi=e}get#_(){return this.#gi||=new Map}get#wi(){return this.#vi||=new Map}get#yi(){if(!this.#fi){const t=this.#bi.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.#bi.createElementNS(Pt,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#fi=this.#bi.createElementNS(Pt,"defs"),t.append(i),i.append(this.#fi),this.#bi.body.append(t)}return this.#fi}#Ai(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),a=new Array(256),r=new Array(256);for(let t=0;t<256;t++)n[t]=e[t]/255,a[t]=i[t]/255,r[t]=s[t]/255;return[n.join(","),a.join(","),r.join(",")]}#_i(t){if(void 0===this.#pi){this.#pi="";const t=this.#bi.URL;t!==this.#bi.baseURI&&(Lt(t)?st('#createUrl: ignore "data:"-URL for performance reasons.'):this.#pi=ot(t,""))}return`url(${this.#pi}#${t})`}addFilter(t){if(!t)return"none";let e=this.#_.get(t);if(e)return e;const[i,s,n]=this.#Ai(t),a=1===t.length?i:`${i}${s}${n}`;if(e=this.#_.get(a),e)return this.#_.set(t,e),e;const r=`g_${this.#mi}_transfer_map_${this.#y++}`,o=this.#_i(r);this.#_.set(t,o),this.#_.set(a,o);const l=this.#xi(r);return this.#Si(i,s,n,l),o}addHCMFilter(t,e){const i=`${t}-${e}`,s="base";let n=this.#wi.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.#wi.set(s,n)),!t||!e)return n.url;const a=this.#Ci(t);t=yt.makeHexColor(...a);const r=this.#Ci(e);if(e=yt.makeHexColor(...r),this.#yi.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.#mi}_hcm_filter`,d=n.filter=this.#xi(h);this.#Si(l,l,l,d),this.#Ei(d);const c=(t,e)=>{const i=a[t]/255,s=r[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.#Si(c(0,5),c(1,5),c(2,5),d),n.url=this.#_i(h),n.url}addAlphaFilter(t){let e=this.#_.get(t);if(e)return e;const[i]=this.#Ai([t]),s=`alpha_${i}`;if(e=this.#_.get(s),e)return this.#_.set(t,e),e;const n=`g_${this.#mi}_alpha_map_${this.#y++}`,a=this.#_i(n);this.#_.set(t,a),this.#_.set(s,a);const r=this.#xi(n);return this.#Pi(i,r),a}addLuminosityFilter(t){let e,i,s=this.#_.get(t||"luminosity");if(s)return s;if(t?([e]=this.#Ai([t]),i=`luminosity_${e}`):i="luminosity",s=this.#_.get(i),s)return this.#_.set(t,s),s;const n=`g_${this.#mi}_luminosity_map_${this.#y++}`,a=this.#_i(n);this.#_.set(t,a),this.#_.set(i,a);const r=this.#xi(n);return this.#Ti(r),t&&this.#Pi(e,r),a}addHighlightHCMFilter(t,e,i,s,n){const a=`${e}-${i}-${s}-${n}`;let r=this.#wi.get(t);if(r?.key===a)return r.url;if(r?(r.filter?.remove(),r.key=a,r.url="none",r.filter=null):(r={key:a,url:"none",filter:null},this.#wi.set(t,r)),!e||!i)return r.url;const[o,l]=[e,i].map(this.#Ci.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.#Ci.bind(this));d<h&&([h,d,c,u]=[d,h,u,c]),this.#yi.style.color="";const p=(t,e,i)=>{const s=new Array(256),n=(d-h)/i,a=t/255,r=(e-t)/(255*i);let o=0;for(let t=0;t<=i;t++){const e=Math.round(h+t*n),i=a+t*r;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.#mi}_hcm_${t}_filter`,f=r.filter=this.#xi(g);return this.#Ei(f),this.#Si(p(c[0],u[0],5),p(c[1],u[1],5),p(c[2],u[2],5),f),r.url=this.#_i(g),r.url}destroy(t=!1){t&&this.#vi?.size||(this.#fi?.parentNode.parentNode.remove(),this.#fi=null,this.#gi?.clear(),this.#gi=null,this.#vi?.clear(),this.#vi=null,this.#y=0)}#Ti(t){const e=this.#bi.createElementNS(Pt,"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)}#Ei(t){const e=this.#bi.createElementNS(Pt,"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)}#xi(t){const e=this.#bi.createElementNS(Pt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#yi.append(e),e}#Mi(t,e,i){const s=this.#bi.createElementNS(Pt,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#Si(t,e,i,s){const n=this.#bi.createElementNS(Pt,"feComponentTransfer");s.append(n),this.#Mi(n,"feFuncR",t),this.#Mi(n,"feFuncG",e),this.#Mi(n,"feFuncB",i)}#Pi(t,e){const i=this.#bi.createElementNS(Pt,"feComponentTransfer");e.append(i),this.#Mi(i,"feFuncA",t)}#Ci(t){return this.#yi.style.color=t,Ht(getComputedStyle(this.#yi).getPropertyValue("color"))}}class Re{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){nt("Abstract method `_fetch` called.")}}class Ne extends Re{async _fetch(t){const e=await Mt(t,"arraybuffer");return new Uint8Array(e)}}class Fe{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw new Error("Wasm filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch((t=>{throw new Error(`Unable to load wasm data at: ${e}`)}))}async _fetch(t){nt("Abstract method `_fetch` called.")}}class Oe extends Fe{async _fetch(t){const e=await Mt(t,"arraybuffer");return new Uint8Array(e)}}async function Be(t){const e=process.getBuiltinModule("fs"),i=await e.promises.readFile(t);return new Uint8Array(i)}y&&st("Please use the `legacy` build in Node.js environments.");class je extends Le{}class Ve extends Te{_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 He extends Ie{async _fetch(t){return Be(t)}}class Ue extends Re{async _fetch(t){return Be(t)}}class ze extends Fe{async _fetch(t){return Be(t)}}const $e="Fill",We="Stroke",Ge="Shading";function qe(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 Xe{isModifyingCurrentTransform(){return!1}getPattern(){nt("Abstract method `getPattern` called.")}}class Ke extends Xe{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===We||s===$e){const a=e.current.getClippedPathBoundingBox(s,Ut(t))||[0,0,0,0],r=Math.ceil(a[2]-a[0])||1,o=Math.ceil(a[3]-a[1])||1,l=e.cachedCanvases.getCanvas("pattern",r,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(-a[0],-a[1]),i=yt.transform(i,[1,0,0,1,a[0],a[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),qe(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 qe(t,this._bbox),n=this._createGradient(t);return n}}function Ye(t,e,i,s,n,a,r,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=a,a=r,r=u),l[s+1]>l[n+1]&&(u=s,s=n,n=u,u=r,r=o,o=u),l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=a,a=r,r=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[a],y=h[a+1],A=h[a+2],_=h[r],x=h[r+1],S=h[r+2],C=h[o],E=h[o+1],P=h[o+2],T=Math.round(g),M=Math.round(v);let I,k,L,D,R,N,F,O;for(let t=T;t<=M;t++){if(t<m){const e=t<g?0:(g-t)/(g-m);I=p-(p-f)*e,k=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),I=f-(f-b)*e,k=_-(_-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(I,R)),s=Math.round(Math.max(I,R));let n=c*t+4*i;for(let t=i;t<=s;t++)e=(I-t)/(I-R),e<0?e=0:e>1&&(e=1),d[n++]=k-(k-N)*e|0,d[n++]=L-(L-F)*e|0,d[n++]=D-(D-O)*e|0,d[n++]=255}}function Qe(t,e,i){const s=e.coords,n=e.colors;let a,r;switch(e.type){case"lattice":const o=e.verticesPerRow,l=Math.floor(s.length/o)-1,h=o-1;for(a=0;a<l;a++){let e=a*o;for(let a=0;a<h;a++,e++)Ye(t,i,s[e],s[e+1],s[e+o],n[e],n[e+1],n[e+o]),Ye(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(a=0,r=s.length;a<r;a+=3)Ye(t,i,s[a],s[a+1],s[a+2],n[a],n[a+1],n[a+2]);break;default:throw new Error("illegal figure")}}class Ze extends Xe{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,i){const s=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),a=Math.ceil(this._bounds[2])-s,r=Math.ceil(this._bounds[3])-n,o=Math.min(Math.ceil(Math.abs(a*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(r*t[1]*1.1)),3e3),h=a/o,d=r/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)Qe(m,t,c);f.putImageData(m,2,2);return{canvas:g.canvas,offsetX:s-2*h,offsetY:n-2*d,scaleX:h,scaleY:d}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,s){qe(t,this._bbox);const n=new Float32Array(2);if(s===Ge)yt.singularValueDecompose2dScale(Ut(t),n);else if(this.matrix){yt.singularValueDecompose2dScale(this.matrix,n);const[t,i]=n;yt.singularValueDecompose2dScale(e.baseTransform,n),n[0]*=t,n[1]*=i}else yt.singularValueDecompose2dScale(e.baseTransform,n);const a=this._createMeshCanvas(n,s===Ge?null:this._background,e.cachedCanvases);return s!==Ge&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY),t.createPattern(a.canvas,"no-repeat")}}class Je extends Xe{getPattern(){return"hotpink"}}const ti=1,ei=2;class ii{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s){this.color=t[1],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.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=s}createPatternCanvas(t){const{bbox:e,operatorList:i,paintType:s,tilingType:n,color:a,canvasGraphicsFactory:r}=this;let{xstep:o,ystep:l}=this;o=Math.abs(o),l=Math.abs(l),it("TilingType: "+n);const h=e[0],d=e[1],c=e[2],u=e[3],p=c-h,g=u-d,f=new Float32Array(2);yt.singularValueDecompose2dScale(this.matrix,f);const[m,b]=f;yt.singularValueDecompose2dScale(this.baseTransform,f);const v=m*f[0],w=b*f[1];let y=p,A=g,_=!1,x=!1;const S=Math.ceil(o*v),C=Math.ceil(l*w);S>=Math.ceil(p*v)?y=o:_=!0,C>=Math.ceil(g*w)?A=l:x=!0;const E=this.getSizeAndScale(y,this.ctx.canvas.width,v),P=this.getSizeAndScale(A,this.ctx.canvas.height,w),T=t.cachedCanvases.getCanvas("pattern",E.size,P.size),M=T.context,I=r.createCanvasGraphics(M);if(I.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(I,s,a),M.translate(-E.scale*h,-P.scale*d),I.transform(E.scale,0,0,P.scale,0,0),M.save(),this.clipBbox(I,h,d,c,u),I.baseTransform=Ut(I.ctx),I.executeOperatorList(i),I.endDrawing(),M.restore(),_||x){const e=T.canvas;_&&(y=o),x&&(A=l);const i=this.getSizeAndScale(y,this.ctx.canvas.width,v),s=this.getSizeAndScale(A,this.ctx.canvas.height,w),n=i.size,a=s.size,r=t.cachedCanvases.getCanvas("pattern-workaround",n,a),c=r.context,u=_?Math.floor(p/o):0,f=x?Math.floor(g/l):0;for(let t=0;t<=u;t++)for(let i=0;i<=f;i++)c.drawImage(e,n*t,a*i,n,a,0,0,n,a);return{canvas:r.canvas,scaleX:i.scale,scaleY:s.scale,offsetX:h,offsetY:d}}return{canvas:T.canvas,scaleX:E.scale,scaleY:P.scale,offsetX:h,offsetY:d}}getSizeAndScale(t,e,i){const s=Math.max(ii.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 a=s-e,r=n-i;t.ctx.rect(e,i,a,r),yt.axialAlignedBoundingBox([e,i,s,n],Ut(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const s=t.ctx,n=t.current;switch(e){case ti:const t=this.ctx;s.fillStyle=t.fillStyle,s.strokeStyle=t.strokeStyle,n.fillColor=t.fillStyle,n.strokeColor=t.strokeStyle;break;case ei:const a=yt.makeHexColor(i[0],i[1],i[2]);s.fillStyle=a,s.strokeStyle=a,n.fillColor=a,n.strokeColor=a;break;default:throw new gt(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,s){let n=i;s!==Ge&&(n=yt.transform(n,e.baseTransform),this.matrix&&(n=yt.transform(n,this.matrix)));const a=this.createPatternCanvas(e);let r=new DOMMatrix(n);r=r.translate(a.offsetX,a.offsetY),r=r.scale(1/a.scaleX,1/a.scaleY);const o=t.createPattern(a.canvas,"repeat");return o.setTransform(r),o}}function si({src:t,srcPos:e=0,dest:i,width:s,height:n,nonBlackColor:a=4294967295,inverseDecode:r=!1}){const o=vt.isLittleEndian?4278190080:255,[l,h]=r?[a,o]:[o,a],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 ni=16,ai=new DOMMatrix,ri=new Float32Array(2),oi=new Float32Array([1/0,1/0,-1/0,-1/0]);class li{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 hi(t,e,i,s,n,a,r,o,l,h){const[d,c,u,p,g,f]=Ut(t);if(0===c&&0===u){const m=r*d+g,b=Math.round(m),v=o*p+f,w=Math.round(v),y=(r+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,a,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=r*c+f,w=Math.round(v),y=(o+h)*u+g,A=Math.abs(Math.round(y)-b)||1,_=(r+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,a,0,0,x,A),t.setTransform(d,c,u,p,g,f),[x,A]}t.drawImage(e,i,s,n,a,r,o,l,h);return[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class di{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=A;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=R;textRise=0;fillColor="#000000";strokeColor="#000000";patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";constructor(t,e){this.clipBox=new Float32Array([0,0,t,e]),this.minMax=oi.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=$e,e=null){const i=this.minMax.slice();if(t===We){e||nt("Stroke bounding box must include transform."),yt.singularValueDecompose2dScale(e,ri);const t=ri[0]*this.lineWidth/2,s=ri[1]*this.lineWidth/2;i[0]-=t,i[1]-=s,i[2]+=t,i[3]+=s}return i}updateClipFromPath(){const t=yt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(oi,0)}getClippedPathBoundingBox(t=$e,e=null){return yt.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function ci(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,s=e.width,n=i%ni,a=(i-n)/ni,r=0===n?a:a+1,o=t.createImageData(s,ni);let l,h=0;const d=e.data,c=o.data;let u,p,g,f;if(e.kind===V.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=vt.isLittleEndian?4278190080:255;for(u=0;u<r;u++){for(g=u<a?ni:n,l=0,p=0;p<g;p++){const t=e-h;let n=0;const a=t>m?s:8*t-7,r=-8&a;let o=0,c=0;for(;n<r;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<a;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*ni)}}else if(e.kind===V.RGBA_32BPP){for(p=0,f=s*ni*4,u=0;u<a;u++)c.set(d.subarray(h,h+f)),h+=f,t.putImageData(o,0,p),p+=ni;u<r&&(f=s*n*4,c.set(d.subarray(h,h+f)),t.putImageData(o,0,p))}else{if(e.kind!==V.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=ni,f=s*g,u=0;u<r;u++){for(u>=a&&(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*ni)}}}function ui(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,s=e.width,n=i%ni,a=(i-n)/ni,r=0===n?a:a+1,o=t.createImageData(s,ni);let l=0;const h=e.data,d=o.data;for(let e=0;e<r;e++){const i=e<a?ni:n;({srcPos:l}=si({src:h,srcPos:l,dest:d,width:s,height:i,nonBlackColor:0})),t.putImageData(o,0,e*ni)}}function pi(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 gi(t){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 fi(t,e){if(e)return!0;yt.singularValueDecompose2dScale(t,ri);const i=Math.fround(Wt.pixelRatio*Tt.PDF_TO_CSS_UNITS);return ri[0]<=i&&ri[1]<=i}const mi=["butt","round","square"],bi=["miter","round","bevel"],vi={},wi={};class yi{constructor(t,e,i,s,n,{optionalContentConfig:a,markedContentStack:r=null},o,l){this.ctx=t,this.current=new di(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.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=r||[],this.optionalContentConfig=a,this.cachedCanvases=new li(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,a=this.ctx.canvas.height,r=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,n,a),this.ctx.fillStyle=r,i){const t=this.cachedCanvases.getCanvas("transparent",n,a);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...Ut(this.compositeCtx))}this.ctx.save(),gi(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=Ut(this.ctx)}executeOperatorList(t,e,i,s){const n=t.argsArray,a=t.fnArray;let r=e||0;const o=n.length;if(o===r)return r;const l=o-r>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&&r===s.nextBreakPoint)return s.breakIt(r,i),r;if(p=a[r],p!==X.dependency)this[p].apply(this,n[r]);else for(const t of n[r]){const e=t.startsWith("g_")?c:u;if(!e.has(t))return e.get(t,i),r}if(r++,r===o)return r;if(l&&++d>10){if(Date.now()>h)return i(),r;d=0}}}#Ii(){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.#Ii(),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.#ki()}#ki(){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,a,r=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(;r>2&&l>1||o>2&&h>1;){let e=l,i=h;r>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),r/=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),a=n.context,a.clearRect(0,0,e,i),a.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,a=this.current.patternFill,r=Ut(e);let o,l,h,d;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;l=JSON.stringify(a?r:[r.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&&!a){return{canvas:i,offsetX:Math.round(Math.min(r[0],r[2])+r[4]),offsetY:Math.round(Math.min(r[1],r[3])+r[5])}}h=i}h||(d=this.cachedCanvases.getCanvas("maskCanvas",i,s),ui(d.context,t));let c=yt.transform(r,[1/i,0,0,-1/s,0,0]);c=yt.transform(c,[1,0,0,1,0,-s]);const u=oi.slice();yt.axialAlignedBoundingBox([0,0,i,s],c,u);const[p,g,f,m]=u,b=Math.round(f-p)||1,v=Math.round(m-g)||1,w=this.cachedCanvases.getCanvas("fillCanvas",b,v),y=w.context,A=p,_=g;y.translate(-A,-_),y.transform(...c),h||(h=this._scaleImage(d.canvas,zt(y)),h=h.img,o&&a&&o.set(l,h)),y.imageSmoothingEnabled=fi(Ut(y),t.interpolate),hi(y,h,0,0,h.width,h.height,0,0,i,s),y.globalCompositeOperation="source-in";const x=yt.transform(zt(y),[1,0,0,1,-A,-_]);return y.fillStyle=a?n.getPattern(e,this,x,$e):n,y.fillRect(0,0,i,s),o&&!a&&(this.cachedCanvases.delete("fillCanvas"),o.set(l,w.canvas)),{canvas:w.canvas,offsetX:Math.round(A),offsetY:Math.round(_)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=mi[t]}setLineJoin(t){this.ctx.lineJoin=bi[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.ctx.globalAlpha=this.current.fillAlpha=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;const n=this.ctx=s.context;n.setTransform(this.suspendedCtx.getTransform()),pi(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,a,r){e.transform(t,i,s,n,a,r),this.__originalTransform(t,i,s,n,a,r)},t.setTransform=function(t,i,s,n,a,r){e.setTransform(t,i,s,n,a,r),this.__originalSetTransform(t,i,s,n,a,r)},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,a,r){e.bezierCurveTo(t,i,s,n,a,r),this.__originalBezierCurveTo(t,i,s,n,a,r)},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"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),pi(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],a=s[1],r=s[2]-n,o=s[3]-a;0!==r&&0!==o&&(this.genericComposeSMask(e.context,i,r,o,e.subtype,e.backdrop,e.transferMap,n,a,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,a,r,o,l,h,d){let c=t.canvas,u=o-h,p=l-d;if(a){const e=yt.makeHexColor(...a);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&&r?e.filter=this.filterFactory.addAlphaFilter(r):"Luminosity"===n&&(e.filter=this.filterFactory.addLuminosityFilter(r));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&&pi(this.ctx,this.suspendedCtx),this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0!==this.stateStack.length?(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&pi(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null):this.inSMaskMode&&this.endSMaskMode()}transform(t,e,i,s,n,a){this.ctx.transform(t,e,i,s,n,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i){let[s]=e;if(!i)return s||=e[0]=new Path2D,void this[t](s);if(!(s instanceof Path2D)){const t=e[0]=new Path2D;for(let e=0,i=s.length;e<i;)switch(s[e++]){case K:t.moveTo(s[e++],s[e++]);break;case Y:t.lineTo(s[e++],s[e++]);break;case Q:t.bezierCurveTo(s[e++],s[e++],s[e++],s[e++],s[e++],s[e++]);break;case Z:t.closePath();break;default:st(`Unrecognized drawing path operator: ${s[e-1]}`)}s=t}yt.axialAlignedBoundingBox(i,Ut(this.ctx),this.current.minMax),this[t](s)}closePath(){this.ctx.closePath()}stroke(t,e=!0){const i=this.ctx,s=this.current.strokeColor;if(i.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof s&&s?.getPattern){const e=s.isModifyingCurrentTransform()?i.getTransform():null;if(i.save(),i.strokeStyle=s.getPattern(i,this,zt(i),We),e){const s=new Path2D;s.addPath(t,i.getTransform().invertSelf().multiplySelf(e)),t=s}this.rescaleAndStroke(t,!1),i.restore()}else this.rescaleAndStroke(t,!0);e&&this.consumePath(t,this.current.getClippedPathBoundingBox(We,Ut(this.ctx))),i.globalAlpha=this.current.fillAlpha}closeStroke(t){this.stroke(t)}fill(t,e=!0){const i=this.ctx,s=this.current.fillColor;let n=!1;if(this.current.patternFill){const e=s.isModifyingCurrentTransform()?i.getTransform():null;if(i.save(),i.fillStyle=s.getPattern(i,this,zt(i),$e),e){const s=new Path2D;s.addPath(t,i.getTransform().invertSelf().multiplySelf(e)),t=s}n=!0}const a=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==a&&(this.pendingEOFill?(i.fill(t,"evenodd"),this.pendingEOFill=!1):i.fill(t)),n&&i.restore(),e&&this.consumePath(t,a)}eoFill(t){this.pendingEOFill=!0,this.fill(t)}fillStroke(t){this.fill(t,!1),this.stroke(t,!1),this.consumePath(t)}eoFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}closeFillStroke(t){this.fillStroke(t)}closeEOFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}endPath(t){this.consumePath(t)}rawFillPath(t){this.ctx.fill(t)}clip(){this.pendingClip=vi}eoClip(){this.pendingClip=wi}beginText(){this.current.textMatrix=null,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;const i=new Path2D,s=e.getTransform().invertSelf();for(const{transform:e,x:n,y:a,fontSize:r,path:o}of t)i.addPath(o,new DOMMatrix(e).preMultiplySelf(s).translate(n,a).scale(r,-r));e.clip(i),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||A,0!==s.fontMatrix[0]&&0!==s.fontMatrix[3]||st("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",a=i.systemFontInfo?.css||`"${n}", ${i.fallbackName}`;let r="normal";i.black?r="900":i.bold&&(r="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} ${r} ${l}px ${a}`}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){const{current:e}=this;e.textMatrix=t,e.textMatrixScale=Math.hypot(t[0],t[1]),e.x=e.lineX=0,e.y=e.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#Li(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 a=this.ctx,r=this.current,o=r.font,l=r.textRenderingMode,h=r.fontSize/r.fontSizeScale,d=l&B,c=!!(l&j),u=r.patternFill&&!o.missingFile,p=r.patternStroke&&!o.missingFile;let g;if((o.disableFontFace||c||u||p)&&(g=o.getPathGenerator(this.commonObjs,t)),o.disableFontFace||u||p){let t;if(a.save(),a.translate(e,i),a.scale(h,-h),d!==R&&d!==F||(s?(t=a.getTransform(),a.setTransform(...s),a.fill(this.#Li(g,t,s))):a.fill(g)),d===N||d===F)if(n){t||=a.getTransform(),a.setTransform(...n);const{a:e,b:i,c:s,d:r}=t,o=yt.inverseTransform(n),l=yt.transform([e,i,s,r,0,0],o);yt.singularValueDecompose2dScale(l,ri),a.lineWidth*=Math.max(ri[0],ri[1])/h,a.stroke(this.#Li(g,t,n))}else a.lineWidth/=h,a.stroke(g);a.restore()}else d!==R&&d!==F||a.fillText(t,e,i),d!==N&&d!==F||a.strokeText(t,e,i);if(c){(this.pendingTextPaths||=[]).push({transform:Ut(a),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 lt(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,a=e.fontSizeScale,r=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===R&&!i.disableFontFace&&!e.patternFill;let m,b;if(n.save(),e.textMatrix&&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,zt(n),$e);m=Ut(n),n.restore(),n.fillStyle=t}if(e.patternStroke){n.save();const t=e.strokeColor.getPattern(n,this,zt(n),We);b=Ut(n),n.restore(),n.strokeStyle=t}let v=e.lineWidth;const w=e.textMatrixScale;if(0===w||0===v){const t=e.textRenderingMode&B;t!==N&&t!==F||(v=this.getSinglePixelWidth())}else v/=w;if(1!==a&&(n.scale(a,a),v/=a),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)+r,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/a,x=(A+s)/a}else _=A/a,x=0;if(i.remeasure&&S>0){const t=1e3*n.measureText(v).width/s*a;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/a)}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/a,e=x-s*w.offset.y/a;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,a=i.fontDirection,r=s.vertical?1:-1,o=i.charSpacing,l=i.wordSpacing,h=i.textHScale*a,d=i.fontMatrix||A,c=t.length;let u,p,g,f;if(!(i.textRenderingMode===O)&&0!==n){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),i.textMatrix&&e.transform(...i.textMatrix),e.translate(i.x,i.y+i.textRise),e.scale(h,a),u=0;u<c;++u){if(p=t[u],"number"==typeof p){f=r*p*n/1e3,this.ctx.translate(f,0),i.x+=f*h;continue}const a=(p.isSpace?l:0)+o,c=s.charProcOperatorList[p.operatorListId];c?this.contentVisible&&(this.save(),e.scale(n,n),e.transform(...d),this.executeOperatorList(c),this.restore()):st(`Type3 character "${p.operatorListId}" is not available.`);const m=[p.width,0];yt.applyTransform(m,d),g=m[0]*n+a,e.translate(g,0),i.x+=g*h}e.restore()}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,i,s,n,a){const r=new Path2D;r.rect(i,s,n-i,a-s),this.ctx.clip(r),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){const i=this.baseTransform||Ut(this.ctx),s={createCanvasGraphics:t=>new yi(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new ii(t,this.ctx,s,i)}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=yt.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=yt.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 Ke(t);case"Mesh":return new Ze(t);case"Dummy":return new Je}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,zt(e),Ge);const s=zt(e);if(s){const{width:t,height:i}=e.canvas,n=oi.slice();yt.axialAlignedBoundingBox([0,0,t,i],s,n);const[a,r,o,l]=n;this.ctx.fillRect(a,r,o-a,l-r)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){nt("Should not call beginInlineImage")}beginImageData(){nt("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Ut(this.ctx),e)){yt.axialAlignedBoundingBox(e,this.baseTransform,this.current.minMax);const[t,i,s,n]=e,a=new Path2D;a.rect(t,i,s-t,n-i),this.ctx.clip(a),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||it("TODO: Support non-isolated groups."),t.knockout&&st("Knockout groups not supported.");const i=Ut(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let s=oi.slice();yt.axialAlignedBoundingBox(t.bbox,Ut(e),s);const n=[0,0,e.canvas.width,e.canvas.height];s=yt.intersect(s,n)||[0,0,0,0];const a=Math.floor(s[0]),r=Math.floor(s[1]),o=Math.max(Math.ceil(s[2])-a,1),l=Math.max(Math.ceil(s[3])-r,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(-a,-r),c.transform(...i);let u=new Path2D;const[p,g,f,m]=t.bbox;if(u.rect(p,g,f-p,m-g),t.matrix){const e=new Path2D;e.addPath(u,new DOMMatrix(t.matrix)),u=e}c.clip(u),t.smask?this.smaskStack.push({canvas:d.canvas,context:c,offsetX:a,offsetY:r,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(a,r),e.save()),pi(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=Ut(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const i=oi.slice();yt.axialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t,i),this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(t,e,i,s,n){if(this.#Ii(),gi(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const s=e[2]-e[0],a=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]=a,yt.singularValueDecompose2dScale(Ut(this.ctx),ri);const{viewportScale:n}=this,r=Math.ceil(s*this.outputScaleX*n),o=Math.ceil(a*this.outputScaleY*n);this.annotationCanvas=this.canvasFactory.create(r,o);const{canvas:l,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(t,l),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(ri[0],0,0,-ri[1],0,a*ri[1]),gi(this.ctx)}else{gi(this.ctx),this.endPath();const t=new Path2D;t.rect(e[0],e[1],s,a),this.ctx.clip(t)}}this.current=new di(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#ki(),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._createMaskCanvas(t),n=s.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(n,s.offsetX,s.offsetY),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i=0,s=0,n,a){if(!this.contentVisible)return;t=this.getObject(t.data,t);const r=this.ctx;r.save();const o=Ut(r);r.transform(e,i,s,n,0,0);const l=this._createMaskCanvas(t);r.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(let t=0,h=a.length;t<h;t+=2){const h=yt.transform(o,[e,i,s,n,a[t],a[t+1]]);r.drawImage(l.canvas,h[4],h[5])}r.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:a,height:r,transform:o}=n,l=this.cachedCanvases.getCanvas("maskCanvas",a,r),h=l.context;h.save();ui(h,this.getObject(t,n)),h.globalCompositeOperation="source-in",h.fillStyle=s?i.getPattern(h,this,zt(e),$e):i,h.fillRect(0,0,a,r),h.restore(),e.save(),e.transform(...o),e.scale(1,-1),hi(e,l.canvas,0,0,a,r,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):st("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s){if(!this.contentVisible)return;const n=this.getObject(t);if(!n)return void st("Dependent image isn't ready yet");const a=n.width,r=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:a,h:r});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),a=n.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,i=t.height,s=this.ctx;this.save();const{filter:n}=s;let a;if("none"!==n&&""!==n&&(s.filter="none"),s.scale(1/e,-1/i),t.bitmap)a=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)a=t;else{const s=this.cachedCanvases.getCanvas("inlineImage",e,i).context;ci(s,t),a=this.applyTransferMapsToCanvas(s)}const r=this._scaleImage(a,zt(s));s.imageSmoothingEnabled=fi(Ut(s),t.interpolate),hi(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;ci(n,t),s=this.applyTransferMapsToCanvas(n)}for(const t of e)i.save(),i.transform(...t.transform),i.scale(1,-1),hi(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,e){const i=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);const s=this.ctx;this.pendingClip&&(i||(this.pendingClip===wi?s.clip(t,"evenodd"):s.clip(t)),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Ut(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 a,r;if(0===i&&0===s){const i=Math.abs(e),s=Math.abs(n);if(i===s)if(0===t)a=r=1/i;else{const e=i*t;a=r=e<1?1/e:1}else if(0===t)a=1/i,r=1/s;else{const e=i*t,n=s*t;a=e<1?1/e:1,r=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)a=h/o,r=l/o;else{const e=t*o;a=h>e?h/e:1,r=l>e?l/e:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=r}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:i,current:{lineWidth:s}}=this,[n,a]=this.getScaleForStroking();if(n===a)return i.lineWidth=(s||1)*n,void i.stroke(t);const r=i.getLineDash();e&&i.save(),i.scale(n,a),ai.a=1/n,ai.d=1/a;const o=new Path2D;if(o.addPath(t,ai),r.length>0){const t=Math.max(n,a);i.setLineDash(r.map((e=>e/t))),i.lineDashOffset/=t}i.lineWidth=s||1,i.stroke(o),e&&i.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 X)void 0!==yi.prototype[t]&&(yi.prototype[X[t]]=yi.prototype[t]);let Ai=class{static#Di=null;static#Ri="";static get workerPort(){return this.#Di}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#Di=t}static get workerSrc(){return this.#Ri}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#Ri=t}};class _i{#Ni;#Fi;constructor({parsedData:t,rawData:e}){this.#Ni=t,this.#Fi=e}getRaw(){return this.#Fi}get(t){return this.#Ni.get(t)??null}[Symbol.iterator](){return this.#Ni.entries()}}const xi=Symbol("INTERNAL");class Si{#Oi=!1;#Bi=!1;#ji=!1;#Vi=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){this.#Oi=!!(t&S),this.#Bi=!!(t&C),this.name=e,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(this.#ji)return this.#Vi;if(!this.#Vi)return!1;const{print:t,view:e}=this.usage;return this.#Oi?"OFF"!==e?.viewState:!this.#Bi||"OFF"!==t?.printState}_setVisible(t,e,i=!1){t!==xi&&nt("Internal method `_setVisible` called."),this.#ji=i,this.#Vi=e}}class Ci{#Hi=null;#Ui=new Map;#zi=null;#$i=null;constructor(t,e=S){if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#$i=t.order;for(const i of t.groups)this.#Ui.set(i.id,new Si(e,i));if("OFF"===t.baseState)for(const t of this.#Ui.values())t._setVisible(xi,!1);for(const e of t.on)this.#Ui.get(e)._setVisible(xi,!0);for(const e of t.off)this.#Ui.get(e)._setVisible(xi,!1);this.#zi=this.getHash()}}#Wi(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.#Wi(e);else{if(!this.#Ui.has(e))return st(`Optional content group not found: ${e}`),!0;n=this.#Ui.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.#Ui.size)return!0;if(!t)return it("Optional content group not defined."),!0;if("OCG"===t.type)return this.#Ui.has(t.id)?this.#Ui.get(t.id).visible:(st(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#Wi(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this.#Ui.has(e))return st(`Optional content group not found: ${e}`),!0;if(this.#Ui.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this.#Ui.has(e))return st(`Optional content group not found: ${e}`),!0;if(!this.#Ui.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this.#Ui.has(e))return st(`Optional content group not found: ${e}`),!0;if(!this.#Ui.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this.#Ui.has(e))return st(`Optional content group not found: ${e}`),!0;if(this.#Ui.get(e).visible)return!1}return!0}return st(`Unknown optional content policy ${t.policy}.`),!0}return st(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){const s=this.#Ui.get(t);if(s){if(i&&e&&s.rbGroups.length)for(const e of s.rbGroups)for(const i of e)i!==t&&this.#Ui.get(i)?._setVisible(xi,!1,!0);s._setVisible(xi,!!e,!0),this.#Hi=null}else st(`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.#Ui.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.#Hi=null}get hasInitialVisibility(){return null===this.#zi||this.getHash()===this.#zi}getOrder(){return this.#Ui.size?this.#$i?this.#$i.slice():[...this.#Ui.keys()]:null}getGroup(t){return this.#Ui.get(t)||null}getHash(){if(null!==this.#Hi)return this.#Hi;const t=new he;for(const[e,i]of this.#Ui)t.update(`${e}:${i.visible}`);return this.#Hi=t.hexdigest()}[Symbol.iterator](){return this.#Ui.entries()}}class Ei{constructor(t,{disableRange:e=!1,disableStream:i=!1}){at(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:n,progressiveDone:a,contentDispositionFilename:r}=t;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=r,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 Pi(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Ti(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 Pi{constructor(t,e,i=!1,s=null){this._stream=t,this._done=i||!1,this._filename=Dt(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 Ti{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 Mi(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 Ii(t){return URL.parse(t)?.origin??null}function ki({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){const n={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(a))return n;if(n.suggestedLength=a,a<=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 Li(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=r(i);return t=unescape(t),t=o(t),t=l(t),a(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 a=[];for(let t=0;t<e.length&&t in e;++t){let[i,s]=e[t];s=r(s),i&&(s=unescape(s),0===t&&(s=o(s))),a.push(s)}return a.join("")}(t),i)return a(l(i));if(i=s("filename","i").exec(t),i){i=i[1];let t=r(i);return t=l(t),a(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=bt(i);i=s.decode(n),e=!1}catch{}}return i}function a(t){return e&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),e&&(t=n("iso-8859-1",t))),t}function r(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(Dt(t))return t}return null}function Di(t,e){return new pt(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,404===t||0===t&&e.startsWith("file:"))}function Ri(t){return 200===t||206===t}function Ni(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function Fi(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(st(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class Oi{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=Mi(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 Bi(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 Bi{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,Ni(i,this._withCredentials,this._abortController)).then((e=>{if(t._responseOrigin=Ii(e.url),!Ri(e.status))throw Di(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();const i=e.headers,{allowRangeRequests:n,suggestedLength:a}=ki({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=a||this._contentLength,this._filename=Li(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new ft("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:Fi(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class ji{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 a=s.url;fetch(a,Ni(n,this._withCredentials,this._abortController)).then((e=>{const i=Ii(e.url);if(i!==t._responseOrigin)throw new Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!Ri(e.status))throw Di(e.status,a);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:Fi(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Vi{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Mi(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 a=function(t){const e=t.response;return"string"!=typeof e?e:bt(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:a}):(st('Missing or invalid "Content-Range" header.'),i.onError(0))}else a?i.onDone({begin:0,chunk:a}):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 Hi{constructor(t){this._source=t,this._manager=new Vi(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 Ui(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new zi(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 Ui{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=Ii(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:a}=ki({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=Li(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=Di(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 zi{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=Ii(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??=Di(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 $i=/^[a-z][a-z0-9\-+.]+:/i;class Wi{constructor(t){this.source=t,this.url=function(t){if($i.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 Gi(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new qi(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 Gi{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=Di(0,this._url.href)),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 ft("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class qi{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)}}let Xi=class t{#Gi=Promise.withResolvers();#mt=null;#qi=!1;#Xi=!!globalThis.FontInspector?.enabled;#Ki=null;#Yi=null;#Qi=0;#Zi=0;#Ji=null;#ts=null;#es=0;#is=0;#ss=Object.create(null);#ns=[];#as=null;#rs=[];#os=new WeakMap;#ls=null;static#hs=new Map;static#ds=new Map;static#cs=new WeakMap;static#us=null;static#ps=new Set;constructor({textContentSource:e,container:i,viewport:s}){if(e instanceof ReadableStream)this.#as=e;else{if("object"!=typeof e)throw new Error('No "textContentSource" parameter specified.');this.#as=new ReadableStream({start(t){t.enqueue(e),t.close()}})}this.#mt=this.#ts=i,this.#is=s.scale*Wt.pixelRatio,this.#es=s.rotation,this.#Yi={div:null,properties:null,ctx:null};const{pageWidth:n,pageHeight:a,pageX:r,pageY:o}=s.rawDims;this.#ls=[1,0,0,-1,-r,o+a],this.#Zi=n,this.#Qi=a,t.#gs(),$t(i,s),this.#Gi.promise.finally((()=>{t.#ps.delete(this),this.#Yi=null,this.#ss=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=vt.platform;return lt(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const e=()=>{this.#Ji.read().then((({value:t,done:i})=>{i?this.#Gi.resolve():(this.#Ki??=t.lang,Object.assign(this.#ss,t.styles),this.#fs(t.items),e())}),this.#Gi.reject)};return this.#Ji=this.#as.getReader(),t.#ps.add(this),e(),this.#Gi.promise}update({viewport:e,onBefore:i=null}){const s=e.scale*Wt.pixelRatio,n=e.rotation;if(n!==this.#es&&(i?.(),this.#es=n,$t(this.#ts,{rotation:n})),s!==this.#is){i?.(),this.#is=s;const e={div:null,properties:null,ctx:t.#ms(this.#Ki)};for(const t of this.#rs)e.properties=this.#os.get(t),e.div=t,this.#bs(e)}}cancel(){const t=new ft("TextLayer task cancelled.");this.#Ji?.cancel(t).catch((()=>{})),this.#Ji=null,this.#Gi.reject(t)}get textDivs(){return this.#rs}get textContentItemsStr(){return this.#ns}#fs(e){if(this.#qi)return;this.#Yi.ctx??=t.#ms(this.#Ki);const i=this.#rs,s=this.#ns;for(const t of e){if(i.length>1e5)return st("Ignoring additional textDivs for performance reasons."),void(this.#qi=!0);if(void 0!==t.str)s.push(t.str),this.#vs(t);else if("beginMarkedContentProps"===t.type||"beginMarkedContent"===t.type){const e=this.#mt;this.#mt=document.createElement("span"),this.#mt.classList.add("markedContent"),null!==t.id&&this.#mt.setAttribute("id",`${t.id}`),e.append(this.#mt)}else"endMarkedContent"===t.type&&(this.#mt=this.#mt.parentNode)}}#vs(e){const i=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,fontSize:0};this.#rs.push(i);const n=yt.transform(this.#ls,e.transform);let a=Math.atan2(n[1],n[0]);const r=this.#ss[e.fontName];r.vertical&&(a+=Math.PI/2);let o=this.#Xi&&r.fontSubstitution||r.fontFamily;o=t.fontFamilyMap.get(o)||o;const l=Math.hypot(n[2],n[3]),h=l*t.#ws(o,r,this.#Ki);let d,c;0===a?(d=n[4],c=n[5]-h):(d=n[4]+h*Math.sin(a),c=n[5]-h*Math.cos(a));const u="calc(var(--total-scale-factor) *",p=i.style;this.#mt===this.#ts?(p.left=`${(100*d/this.#Zi).toFixed(2)}%`,p.top=`${(100*c/this.#Qi).toFixed(2)}%`):(p.left=`${u}${d.toFixed(2)}px)`,p.top=`${u}${c.toFixed(2)}px)`),p.fontSize=`${u}${(t.#us*l).toFixed(2)}px)`,p.fontFamily=o,s.fontSize=l,i.setAttribute("role","presentation"),i.textContent=e.str,i.dir=e.dir,this.#Xi&&(i.dataset.fontName=r.fontSubstitutionLoadedName||e.fontName),0!==a&&(s.angle=a*(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=r.vertical?e.height:e.width),this.#os.set(i,s),this.#Yi.div=i,this.#Yi.properties=s,this.#bs(this.#Yi),s.hasText&&this.#mt.append(i),s.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#mt.append(t)}}#bs(e){const{div:i,properties:s,ctx:n}=e,{style:a}=i;let r="";if(t.#us>1&&(r=`scale(${1/t.#us})`),0!==s.canvasWidth&&s.hasText){const{fontFamily:e}=a,{canvasWidth:o,fontSize:l}=s;t.#ys(n,l*this.#is,e);const{width:h}=n.measureText(i.textContent);h>0&&(r=`scaleX(${o*this.#is/h}) ${r}`)}0!==s.angle&&(r=`rotate(${s.angle}deg) ${r}`),r.length>0&&(a.transform=r)}static cleanup(){if(!(this.#ps.size>0)){this.#hs.clear();for(const{canvas:t}of this.#ds.values())t.remove();this.#ds.clear()}}static#ms(t=null){let e=this.#ds.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.#ds.set(t,e),this.#cs.set(e,{size:0,family:""})}return e}static#ys(t,e,i){const s=this.#cs.get(t);e===s.size&&i===s.family||(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static#gs(){if(null!==this.#us)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.#us=t.getBoundingClientRect().height,t.remove()}static#ws(t,e,i){const s=this.#hs.get(t);if(s)return s;const n=this.#ms(i);n.canvas.width=n.canvas.height=30,this.#ys(n,30,t);const a=n.measureText(""),r=a.fontBoundingBoxAscent,o=Math.abs(a.fontBoundingBoxDescent);n.canvas.width=n.canvas.height=0;let l=.8;return r?l=r/(r+o):(vt.platform.isFirefox&&st("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?l=e.ascent:e.descent&&(l=1+e.descent)),this.#hs.set(t,l),l}};class Ki{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(!Ki.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)}}function Yi(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new ts,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;if("string"==typeof t){if(y)return t;const e=URL.parse(t,window.location);if(e)return e.href}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 bt(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,a=t.httpHeaders||null,r=!0===t.withCredentials,o=t.password??null,l=t.range instanceof es?t.range:null,h=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536;let d=t.worker instanceof as?t.worker:null;const c=t.verbosity,u="string"!=typeof t.docBaseUrl||Lt(t.docBaseUrl)?null:t.docBaseUrl,p=Qi(t.cMapUrl),g=!1!==t.cMapPacked,f=t.CMapReaderFactory||(y?He:ke),m=Qi(t.iccUrl),b=Qi(t.standardFontDataUrl),v=t.StandardFontDataFactory||(y?Ue:Ne),w=Qi(t.wasmUrl),A=t.WasmFactory||(y?ze:Oe),_=!0!==t.stopAtErrors,x=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,S=!1!==t.isEvalSupported,C="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!y,E="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!y&&(vt.platform.isFirefox||!globalThis.chrome),P=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,T="boolean"==typeof t.disableFontFace?t.disableFontFace:y,M=!0===t.fontExtraProperties,I=!0===t.enableXfa,k=t.ownerDocument||globalThis.document,L=!0===t.disableRange,D=!0===t.disableStream,R=!0===t.disableAutoFetch,N=!0===t.pdfBug,F=t.CanvasFactory||(y?Ve:Me),O=t.FilterFactory||(y?je:De),B=!0===t.enableHWA,j=!1!==t.useWasm,V=l?l.length:t.length??NaN,H="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!y&&!T,U="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(f===ke&&v===Ne&&A===Oe&&p&&b&&w&&Ft(p,document.baseURI)&&Ft(b,document.baseURI)&&Ft(w,document.baseURI));tt(c);const z={canvasFactory:new F({ownerDocument:k,enableHWA:B}),filterFactory:new O({docId:i,ownerDocument:k}),cMapReaderFactory:U?null:new f({baseUrl:p,isCompressed:g}),standardFontDataFactory:U?null:new v({baseUrl:b}),wasmFactory:U?null:new A({baseUrl:w})};if(!d){const t={verbosity:c,port:Ai.workerPort};d=t.port?as.fromPort(t):new as(t),e._worker=d}const $={docId:i,apiVersion:"5.2.133",data:n,password:o,disableAutoFetch:R,rangeChunkSize:h,length:V,docBaseUrl:u,enableXfa:I,evaluatorOptions:{maxImageSize:x,disableFontFace:T,ignoreErrors:_,isEvalSupported:S,isOffscreenCanvasSupported:C,isImageDecoderSupported:E,canvasMaxAreaInBytes:P,fontExtraProperties:M,useSystemFonts:H,useWasm:j,useWorkerFetch:U,cMapUrl:p,iccUrl:m,standardFontDataUrl:b,wasmUrl:w}},W={ownerDocument:k,pdfBug:N,styleElement:null,loadingParams:{disableAutoFetch:R,enableXfa:I}};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",$,n?[n.buffer]:null);let o;if(l)o=new Ei(l,{disableRange:L,disableStream:D});else if(!n){if(!s)throw new Error("getDocument - no `url` parameter provided.");let t;if(y)if(Ft(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=Oi}else t=Wi;else t=Ft(s)?Oi:Hi;o=new t({url:s,length:V,httpHeaders:a,withCredentials:r,rangeChunkSize:h,disableRange:L,disableStream:D})}return t.then((t=>{if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const s=new Pe(i,t,d.port),n=new rs(s,e,o,W,z);e._transport=n,s.send("Ready",null)}))})).catch(e._capability.reject),e}function Qi(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}const Zi=t=>"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,Ji=function(t,e,i){if(!Array.isArray(i)||i.length<2)return!1;const[s,n,...a]=i;if(!t(s)&&!Number.isInteger(s))return!1;if(!e(n))return!1;const r=a.length;let o=!0;switch(n.name){case"XYZ":if(r<2||r>3)return!1;break;case"Fit":case"FitB":return 0===r;case"FitH":case"FitBH":case"FitV":case"FitBV":if(r>1)return!1;break;case"FitR":if(4!==r)return!1;o=!1;break;default:return!1}for(const t of a)if(!("number"==typeof t||o&&null===t))return!1;return!0}.bind(null,Zi,(t=>"object"==typeof t&&"string"==typeof t?.name));class ts{static#mi=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId="d"+ts.#mi++;destroyed=!1;onPassword=null;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}async getData(){return this._transport.getData()}}let es=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){nt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class is{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 lt(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 ss{#As=!1;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new Nt:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new ls,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 It({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 lt(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=k.ENABLE,transform:n=null,background:a=null,optionalContentConfigPromise:r=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.#As=!1,r||=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&C);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),f&&(this.#As=!0),this.#_s(),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 ds({callback:m,params:{canvasContext:t,viewport:e,transform:n,background:a},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,r]).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=k.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){const n=this._transport.getRenderingIntent(t,e,i,s,!0);let a,r=this._intentStates.get(n.cacheKey);return r||(r=Object.create(null),this._intentStates.set(n.cacheKey,r)),r.opListReadCapability||(a=Object.create(null),a.operatorListChanged=function(){r.operatorList.lastChunk&&(r.opListReadCapability.resolve(r.operatorList),r.renderTasks.delete(a))},r.opListReadCapability=Promise.withResolvers(),(r.renderTasks||=new Set).add(a),r.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),r.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=>Ki.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.#As=!1,Promise.all(t)}cleanup(t=!1){this.#As=!0;const e=this.#_s();return t&&e&&(this._stats&&=new Nt),e}#_s(){if(!this.#As||this.destroyed)return!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.#As=!1,!0}_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.#_s()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){const{map:n,transfer:a}=i,r=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:s},a).getReader(),o=this._intentStates.get(e);o.streamReader=r;const l=()=>{r.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.#_s()}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 kt){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 ft(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 ns{#xs=new Map;#Ss=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#Ss.then((()=>{for(const[t]of this.#xs)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 st("LoopbackPort - cannot use an `aborted` signal.");const a=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",a),n.addEventListener("abort",a)}this.#xs.set(e,s)}removeEventListener(t,e){const i=this.#xs.get(e);i?.(),this.#xs.delete(e)}terminate(){for(const[,t]of this.#xs)t?.();this.#xs.clear()}}let as=class t{static#Cs=0;static#Es=!1;static#Ps;static{y&&(this.#Es=!0,Ai.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{const i=URL.parse(t);if(!i?.origin||"null"===i.origin)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=et()}={}){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.#Ps?.has(i))throw new Error("Cannot use more than one PDFWorker per port.");return(t.#Ps||=new WeakMap).set(i,this),void this._initializeFromPort(i)}this._initialize()}get promise(){return this._readyCapability.promise}#Ts(){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 Pe("main","worker",t),this._messageHandler.on("ready",(function(){})),this.#Ts()}_initialize(){if(t.#Es||t.#Ms)return void this._setupFakeWorker();let{workerSrc:e}=t;try{t._isSameOrigin(window.location,e)||(e=t._createCDNWrapper(new URL(e,window.location).href));const i=new Worker(e,{type:"module"}),s=new Pe("main","worker",i),n=()=>{a.abort(),s.destroy(),i.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},a=new AbortController;i.addEventListener("error",(()=>{this._webWorker||n()}),{signal:a.signal}),s.on("test",(t=>{a.abort(),!this.destroyed&&t?(this._messageHandler=s,this._port=i,this._webWorker=i,this.#Ts()):n()})),s.on("ready",(t=>{if(a.abort(),this.destroyed)n();else try{r()}catch{this._setupFakeWorker()}}));const r=()=>{const t=new Uint8Array;s.send("test",t,[t.buffer])};return void r()}catch{it("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){t.#Es||(st("Setting up fake worker."),t.#Es=!0),t._setupFakeWorkerGlobal.then((e=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const i=new ns;this._port=i;const s="fake"+t.#Cs++,n=new Pe(s+"_worker",s,i);e.setup(n,i),this._messageHandler=new Pe(s,s+"_worker",i),this.#Ts()})).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.#Ps?.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.#Ps?.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(Ai.workerSrc)return Ai.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#Ms(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return lt(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#Ms)return this.#Ms;return(await import(this.workerSrc)).WorkerMessageHandler})())}};class rs{#Is=new Map;#ks=new Map;#Ls=new Map;#Ds=new Map;#Rs=null;constructor(t,e,i,s,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new ls,this.fontLoader=new pe({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.wasmFactory=n.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#Ns(t,e=null){const i=this.#Is.get(t);if(i)return i;const s=this.messageHandler.sendWithPromise(t,e);return this.#Is.set(t,s),s}get annotationStorage(){return lt(this,"annotationStorage",new ce)}getRenderingIntent(t,e=k.ENABLE,i=null,s=!1,n=!1){let a=S,r=de;switch(t){case"any":a=x;break;case"display":break;case"print":a=C;break;default:st(`getRenderingIntent - invalid intent: ${t}`)}const o=a&C&&i instanceof ue?i:this.annotationStorage;switch(e){case k.DISABLE:a+=T;break;case k.ENABLE:break;case k.ENABLE_FORMS:a+=E;break;case k.ENABLE_STORAGE:a+=P,r=o.serializable;break;default:st(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(a+=M),n&&(a+=I);const{ids:l,hash:h}=o.modifiedIds;return{renderingIntent:a,cacheKey:[a,r.hash,h].join("_"),annotationStorageSerializable:r,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#Rs?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#ks.values())t.push(e._destroy());this.#ks.clear(),this.#Ls.clear(),this.#Ds.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.#Is.clear(),this.filterFactory.destroy(),Xi.cleanup(),this._networkStream?.cancelAllRequests(new ft("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 is(t,this))})),t.on("DocException",(t=>{e._capability.reject(Ee(t))})),t.on("PasswordRequest",(t=>{this.#Rs=Promise.withResolvers();try{if(!e.onPassword)throw Ee(t);const i=t=>{t instanceof Error?this.#Rs.reject(t):this.#Rs.resolve({password:t})};e.onPassword(i,t.code)}catch(t){this.#Rs.reject(t)}return this.#Rs.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.#ks.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":if("error"in s){const t=s.error;st(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const n=this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,a=new ge(s,n);this.fontLoader.bind(a).catch((()=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!a.fontExtraProperties&&a.data&&(a.data=null),this.commonObjs.resolve(e,a)}));break;case"CopyLocalImage":const{imageRef:r}=s;at(r,"The imageRef must be defined.");for(const t of this.#ks.values())for(const[,i]of t.objs)if(i?.ref===r)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.#ks.get(e);if(!n.objs.has(t))if(0!==n._intentStates.size)switch(i){case"Image":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("FetchBinaryData",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");const e=this[t.type];if(!e)throw new Error(`${t.type} not initialized, see the \`useWorkerFetch\` parameter.`);return e.fetch(t)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&st("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.#Ls.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.#Ds.set(i.refStr,t);const s=new ss(e,i,this,this._params.pdfBug);return this.#ks.set(e,s),s}));return this.#Ls.set(e,s),s}getPageIndex(t){return Zi(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.#Ns("GetFieldObjects")}hasJSActions(){return this.#Ns("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.#Ns("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.#Ns("GetOptionalContentConfig").then((e=>new Ci(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#Is.get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new _i(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#Is.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.#ks.values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),this.#Is.clear(),this.filterFactory.destroy(!0),Xi.cleanup()}}cachedPageNumber(t){if(!Zi(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#Ds.get(e)??null}}const os=Symbol("INITIAL_DATA");class ls{#Fs=Object.create(null);#Os(t){return this.#Fs[t]||={...Promise.withResolvers(),data:os}}get(t,e=null){if(e){const i=this.#Os(t);return i.promise.then((()=>e(i.data))),null}const i=this.#Fs[t];if(!i||i.data===os)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#Fs[t];return!!e&&e.data!==os}delete(t){const e=this.#Fs[t];return!(!e||e.data===os)&&(delete this.#Fs[t],!0)}resolve(t,e=null){const i=this.#Os(t);i.data=e,i.resolve()}clear(){for(const t in this.#Fs){const{data:e}=this.#Fs[t];e?.bitmap?.close()}this.#Fs=Object.create(null)}*[Symbol.iterator](){for(const t in this.#Fs){const{data:e}=this.#Fs[t];e!==os&&(yield[t,e])}}}class hs{#Bs=null;onContinue=null;onError=null;constructor(t){this.#Bs=t}get promise(){return this.#Bs.capability.promise}cancel(t=0){this.#Bs.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#Bs.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#Bs;return t.form||t.canvas&&e?.size>0}}class ds{#js=null;static#Vs=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:n,operatorList:a,pageIndex:r,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=a,this._pageIndex=r,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 hs(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(ds.#Vs.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.");ds.#Vs.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:a}=this.params;this.gfx=new yi(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:a}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#js&&(window.cancelAnimationFrame(this.#js),this.#js=null),ds.#Vs.delete(this._canvas),t||=new kt(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}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.#js=window.requestAnimationFrame((()=>{this.#js=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(),ds.#Vs.delete(this._canvas),this.callback())))}}function cs(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function us(t){return Math.max(0,Math.min(255,255*t))}class ps{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=us(t),t,t]}static G_HTML([t]){const e=cs(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(us)}static RGB_HTML(t){return`#${t.map(cs).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[us(1-Math.min(1,t+s)),us(1-Math.min(1,i+s)),us(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,a=1-i;return["CMYK",s,n,a,Math.min(s,n,a)]}}class gs{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){nt("Abstract method `_createSVG` called.")}}let fs=class extends gs{_createSVG(t){return document.createElementNS(Pt,t)}},ms=class{static setupStorage(t,e,i,s,n){const a=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==a.value&&(t.textContent=a.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(a.value===i.attributes.xfaOn?t.setAttribute("checked",!0):a.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!==a.value&&t.setAttribute("value",a.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==a.value){t.setAttribute("value",a.value);for(const t of i.children)t.attributes.value===a.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:a}=e,r=t instanceof HTMLAnchorElement;"radio"===a.type&&(a.name=`${a.name}-${s}`);for(const[e,i]of Object.entries(a))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:(!r||"href"!==e&&"newWindow"!==e)&&t.setAttribute(e,i)}r&&n.addLinkAttributes(t,a.href,a.newWindow),i&&a.dataId&&this.setupStorage(t,a.dataId,e,i)}static render(t){const e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,n=t.intent||"display",a=document.createElement(s.name);s.attributes&&this.setAttributes({html:a,element:s,intent:n,linkService:i});const r="richText"!==n,o=t.div;if(o.append(a),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}r&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(0===s.children.length){if(s.value){const t=document.createTextNode(s.value);a.append(t),r&&Ki.shouldBuildText(s.name)&&l.push(t)}return{textDivs:l}}const h=[[s,-1,a]];for(;h.length>0;){const[t,s,a]=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),a.append(t);continue}const c=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,d):document.createElement(d);if(a.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);r&&Ki.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 bs=1e3,vs=new WeakSet;class ws{static create(t){switch(t.data.annotationType){case H.LINK:return new As(t);case H.TEXT:return new _s(t);case H.WIDGET:switch(t.data.fieldType){case"Tx":return new Ss(t);case"Btn":return t.data.radioButton?new Ps(t):t.data.checkBox?new Es(t):new Ts(t);case"Ch":return new Ms(t);case"Sig":return new Cs(t)}return new xs(t);case H.POPUP:return new Is(t);case H.FREETEXT:return new Ls(t);case H.LINE:return new Ds(t);case H.SQUARE:return new Rs(t);case H.CIRCLE:return new Ns(t);case H.POLYLINE:return new Fs(t);case H.CARET:return new Bs(t);case H.INK:return new js(t);case H.POLYGON:return new Os(t);case H.HIGHLIGHT:return new Vs(t);case H.UNDERLINE:return new Hs(t);case H.SQUIGGLY:return new Us(t);case H.STRIKEOUT:return new zs(t);case H.STAMP:return new $s(t);case H.FILEATTACHMENT:return new Ws(t);default:return new ys(t)}}}class ys{#Hs=null;#Us=!1;#zs=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 ys._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#Hs||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#$s(e),this.#zs?.popup.updateEdited(t)}resetEdited(){this.#Hs&&(this.#$s(this.#Hs.rect),this.#zs?.popup.resetEdited(),this.#Hs=null)}#$s(t){const{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:a,pageX:r,pageY:o}}}}=this;i?.splice(0,4,...t),e.left=100*(t[0]-r)/n+"%",e.top=100*(a-t[3]+o)/a+"%",0===s?(e.width=100*(t[2]-t[0])/n+"%",e.height=100*(t[3]-t[1])/a+"%"):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 xs||(n.tabIndex=bs);const{style:a}=n;if(a.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Is){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:r,height:o}=this;if(!t&&e.borderStyle.width>0){a.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(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`;a.borderRadius=e}else if(this instanceof Ps){const t=`calc(${r}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`;a.borderRadius=t}switch(e.borderStyle.style){case U:a.borderStyle="solid";break;case z:a.borderStyle="dashed";break;case $:st("Unimplemented border style: beveled");break;case W:st("Unimplemented border style: inset");break;case G:a.borderBottomStyle="solid"}const s=e.borderColor||null;s?(this.#Us=!0,a.borderColor=yt.makeHexColor(0|s[0],0|s[1],0|s[2])):a.borderWidth=0}const l=yt.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;a.left=100*(l[0]-c)/h+"%",a.top=100*(l[1]-u)/d+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(a.width=100*r/h+"%",a.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;let{width:n,height:a}=this;t%180!=0&&([n,a]=[a,n]),e.style.width=100*n/i+"%",e.style.height=100*a/s+"%",e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,i)=>{const s=i.detail[t],n=s[0],a=s.slice(1);i.target.style[e]=ps[`${n}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[e]:ps[`${n}_rgb`](a)})};return lt(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 a=i[s];if(a){a({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[a,r,o,l]=t.subarray(2,6);if(s===a&&n===r&&e===o&&i===l)return}const{style:a}=this.container;let r;if(this.#Us){const{borderColor:t,borderWidth:e}=a;a.borderWidth=0,r=["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],a=t[i+1],d=t[i+2],c=t[i+3],p=h.createElement("rect"),g=(d-e)/o,f=(n-a)/l,m=(s-d)/o,b=(a-c)/l;p.setAttribute("x",g),p.setAttribute("y",f),p.setAttribute("width",m),p.setAttribute("height",b),u.append(p),r?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${f}" width="${m}" height="${b}"/>`)}this.#Us&&(r.push("</g></svg>')"),a.backgroundImage=r.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(){const{data:t}=this,e=this.#zs=new Is({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(){nt("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:a}of s){if(-1===t)continue;if(n===e)continue;const s="string"==typeof a?a:null,r=document.querySelector(`[data-element-id="${n}"]`);!r||vs.has(r)?i.push({id:n,exportValue:s,domElement:r}):st(`_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&&(vs.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})}))}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}class As extends ys{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.#Ws(i,t.attachment,t.attachmentDest),s=!0):t.setOCGState?(this.#Gs(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}#qs(){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.#qs()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#qs()}#Ws(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.#qs()}#Gs(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#qs()}_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.#qs()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#qs(),!this._fieldObjects)return st('_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,a=[];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&&a.push(i)}else for(const t of Object.values(this._fieldObjects))a.push(...t);const r=this.annotationStorage,o=[];for(const t of a){const{id:e}=t;switch(o.push(e),t.type){case"text":{const i=t.defaultValue||"";r.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{const i=t.defaultValue===t.exportValues;r.setValue(e,{value:i});break}case"combobox":case"listbox":{const i=t.defaultValue||"";r.setValue(e,{value:i});break}default:continue}const i=document.querySelector(`[data-element-id="${e}"]`);i&&(vs.has(i)?i.dispatchEvent(new Event("resetform")):st(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class _s extends ys{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 xs extends ys{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return vt.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,a]of i)("Action"===a||this.data.actions?.[a])&&("Focus"!==a&&"Blur"!==a||(e||={focused:!1}),this._setEventListener(t,e,n,a,s),"Focus"!==a||this.data.actions?.Blur?"Blur"!==a||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":yt.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 a;const r=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/(_*s))||1);a=Math.min(s,r(e/_))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(s,r(t/_))}n.fontSize=`calc(${a}px * var(--total-scale-factor))`,n.color=yt.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 Ss extends xs{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 a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=i),n.setValue(a.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 a=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;a&&n.length>a&&(n=n.slice(0,a));let r=s.formattedValue||this.data.textContent?.join("\n")||null;r&&this.data.comb&&(r=r.replaceAll(/\s+/g,""));const o={userValue:n,formattedValue:r,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=r??n,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type=this.data.password?"password":"text",i.setAttribute("value",r??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),vs.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=bs,this._setRequired(i,this.data.required),a&&(i.maxLength=a),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 a=o.userValue;!a||a.length<=s||(a=a.slice(0,s),n.value=o.userValue=a,t.setValue(e,{value:a}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,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:a,selectionEnd:r}=s;let l=a,h=r;switch(t.inputType){case"deleteWordBackward":{const t=n.substring(0,a).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{const t=n.substring(a).match(/^[^\w]*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":a===r&&(l-=1);break;case"deleteContentForward":a===r&&(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])/a;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--total-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 Cs extends xs{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Es extends xs{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 vs.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=bs,n.addEventListener("change",(s=>{const{name:n,checked:a}=s.target;for(const s of this._getElementsByName(n,i)){const i=a&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:a})})),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 Ps extends xs{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(vs.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=bs,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 Ts extends As{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 Ms extends xs{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");vs.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=bs;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 a=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),a=()=>{t.remove(),s.removeEventListener("input",a),a=null},s.addEventListener("input",a)}const r=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=r(!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){a?.();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:r(!0)}),o=r(!1)},multipleSelection(t){s.multiple=!0},remove(i){const n=s.options,a=i.detail.remove;if(n[a].selected=!1,s.remove(a),n.length>0){-1===Array.prototype.findIndex.call(n,(t=>t.selected))&&(n[0].selected=!0)}t.setValue(e,{value:r(!0),items:l(i)}),o=r(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),o=r(!1)},insert(i){const{index:n,displayValue:a,exportValue:h}=i.detail.insert,d=s.children[n],c=document.createElement("option");c.textContent=a,c.value=h,d?d.before(c):s.append(c),t.setValue(e,{value:r(!0),items:l(i)}),o=r(!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:r(!0),items:l(i)}),o=r(!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:r(!0)}),o=r(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(n,i)})),s.addEventListener("input",(i=>{const s=r(!0),n=r(!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:r(!0)})})),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Is extends ys{constructor(t){const{data:e,elements:i}=t;super(t,{isRenderable:ys._hasPopupData(e)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new ks({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=>`${St}${t}`)).join(",")),this.container}}class ks{#Xs=this.#Ks.bind(this);#Ys=this.#Qs.bind(this);#Zs=this.#Js.bind(this);#tn=this.#en.bind(this);#in=null;#mt=null;#sn=null;#nn=null;#an=null;#rn=null;#on=null;#ln=!1;#hn=null;#P=null;#dn=null;#cn=null;#un=null;#Hs=null;#pn=!1;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:n,contentsObj:a,richText:r,parent:o,rect:l,parentRect:h,open:d}){this.#mt=t,this.#un=s,this.#sn=a,this.#cn=r,this.#rn=o,this.#in=e,this.#dn=l,this.#on=h,this.#an=i,this.#nn=jt.toDateObject(n),this.trigger=i.flatMap((t=>t.getElementsToTriggerPopup()));for(const t of this.trigger)t.addEventListener("click",this.#tn),t.addEventListener("mouseenter",this.#Zs),t.addEventListener("mouseleave",this.#Ys),t.classList.add("popupTriggerArea");for(const t of i)t.container?.addEventListener("keydown",this.#Xs);this.#mt.hidden=!0,d&&this.#en()}render(){if(this.#hn)return;const t=this.#hn=document.createElement("div");if(t.className="popup",this.#in){const e=t.style.outlineColor=yt.makeHexColor(...this.#in);t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}const e=document.createElement("span");e.className="header";const i=document.createElement("h1");if(e.append(i),({dir:i.dir,str:i.textContent}=this.#un),t.append(e),this.#nn){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.#nn.valueOf()})),e.append(t)}const s=this.#gn;if(s)ms.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(this.#sn);t.append(e)}this.#mt.append(t)}get#gn(){const t=this.#cn,e=this.#sn;return!t?.str||e?.str&&e.str!==t.str?null:this.#cn.html||null}get#fn(){return this.#gn?.attributes?.style?.fontSize||0}get#mn(){return this.#gn?.attributes?.style?.color||null}#bn(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:this.#mn,fontSize:this.#fn?`calc(${this.#fn}px * var(--total-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}#Ks(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#ln)&&this.#en()}updateEdited({rect:t,popupContent:e}){this.#Hs||={contentsObj:this.#sn,richText:this.#cn},t&&(this.#P=null),e&&(this.#cn=this.#bn(e),this.#sn=null),this.#hn?.remove(),this.#hn=null}resetEdited(){this.#Hs&&(({contentsObj:this.#sn,richText:this.#cn}=this.#Hs),this.#Hs=null,this.#hn?.remove(),this.#hn=null,this.#P=null)}#vn(){if(null!==this.#P)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=this.#rn;let a=!!this.#on,r=a?this.#on:this.#dn;for(const t of this.#an)if(!r||null!==yt.intersect(t.data.rect,r)){r=t.data.rect,a=!0;break}const o=yt.normalizeRect([r[0],t[3]-r[1]+t[1],r[2],t[3]-r[3]+t[1]]),l=a?r[2]-r[0]+5:0,h=o[0]+l,d=o[1];this.#P=[100*(h-s)/e,100*(d-n)/i];const{style:c}=this.#mt;c.left=`${this.#P[0]}%`,c.top=`${this.#P[1]}%`}#en(){this.#ln=!this.#ln,this.#ln?(this.#Js(),this.#mt.addEventListener("click",this.#tn),this.#mt.addEventListener("keydown",this.#Xs)):(this.#Qs(),this.#mt.removeEventListener("click",this.#tn),this.#mt.removeEventListener("keydown",this.#Xs))}#Js(){this.#hn||this.render(),this.isVisible?this.#ln&&this.#mt.classList.add("focused"):(this.#vn(),this.#mt.hidden=!1,this.#mt.style.zIndex=parseInt(this.#mt.style.zIndex)+1e3)}#Qs(){this.#mt.classList.remove("focused"),!this.#ln&&this.isVisible&&(this.#mt.hidden=!0,this.#mt.style.zIndex=parseInt(this.#mt.style.zIndex)-1e3)}forceHide(){this.#pn=this.isVisible,this.#pn&&(this.#mt.hidden=!0)}maybeShow(){this.#pn&&(this.#hn||this.#Js(),this.#pn=!1,this.#mt.hidden=!1)}get isVisible(){return!1===this.#mt.hidden}}class Ls extends ys{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=L.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 Ds extends ys{#wn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=this.#wn=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.#wn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Rs extends ys{#yn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,a=this.#yn=this.svgFactory.createElement("svg:rect");return a.setAttribute("x",n/2),a.setAttribute("y",n/2),a.setAttribute("width",e-n),a.setAttribute("height",i-n),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),s.append(a),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#yn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ns extends ys{#An=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,a=this.#An=this.svgFactory.createElement("svg:ellipse");return a.setAttribute("cx",e/2),a.setAttribute("cy",i/2),a.setAttribute("rx",e/2-n/2),a.setAttribute("ry",i/2-n/2),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),s.append(a),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#An}addHighlightArea(){this.container.classList.add("highlightArea")}}class Fs extends ys{#_n=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},width:n,height:a}=this;if(!e)return this.container;const r=this.svgFactory.create(n,a,!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.#_n=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"),r.append(l),this.container.append(r),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#_n}addHighlightArea(){this.container.classList.add("highlightArea")}}class Os extends Fs{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Bs extends ys{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 js extends ys{#xn=null;#Sn=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?L.HIGHLIGHT:L.INK}#Cn(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:a,width:r,height:o}=this.#Cn(e,t),l=this.svgFactory.create(r,o,!0),h=this.#xn=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",a);for(let t=0,e=i.length;t<e;t++){const e=this.svgFactory.createElement(this.svgElementName);this.#Sn.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.#xn;if(e>=0&&n.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#Sn.length;t<e;t++)this.#Sn[t].setAttribute("points",i[t].join(","));if(s){const{transform:t,width:e,height:i}=this.#Cn(this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#Sn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Vs extends ys{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=L.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Hs extends ys{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 Us extends ys{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 ys{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 $s extends ys{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=L.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 Ws extends ys{#En=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.#Pn.bind(this)),this.#En=i;const{isMac:s}=vt.platform;return t.addEventListener("keydown",(t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#Pn()})),!e.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#En}addHighlightArea(){this.container.classList.add("highlightArea")}#Pn(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}const Gs=/\r\n?|\n/g;class qs extends ne{#in;#Tn="";#Mn=`${this.id}-editor`;#In=null;#fn;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=qs.prototype,e=t=>t.isEmpty(),i=ee.TRANSLATE_SMALL,s=ee.TRANSLATE_BIG;return lt(this,"_keyboardManager",new Jt([[["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=L.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#in=t.color||qs._defaultColor||ne._defaultLineColor,this.#fn=t.fontSize||qs._defaultFontSize}static initialize(t,e){ne.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case D.FREETEXT_SIZE:qs._defaultFontSize=e;break;case D.FREETEXT_COLOR:qs._defaultColor=e}}updateParams(t,e){switch(t){case D.FREETEXT_SIZE:this.#kn(e);break;case D.FREETEXT_COLOR:this.#Ln(e)}}static get defaultPropertiesToUpdate(){return[[D.FREETEXT_SIZE,qs._defaultFontSize],[D.FREETEXT_COLOR,qs._defaultColor||ne._defaultLineColor]]}get propertiesToUpdate(){return[[D.FREETEXT_SIZE,this.#fn],[D.FREETEXT_COLOR,this.#in]]}#kn(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-this.#fn)*this.parentScale),this.#fn=t,this.#Dn()},i=this.#fn;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:D.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#Ln(t){const e=t=>{this.#in=this.editorDiv.style.color=t},i=this.#in;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:D.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-qs._internalPadding*t,-(qs._internalPadding+this.#fn)*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(L.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#In=new AbortController;const t=this._uiManager.combinedSignal(this.#In);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.#Mn),this._isDraggable=!0,this.#In?.abort(),this.#In=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()}#Rn(){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(qs.#Nn(i)),e=i);return t.join("\n")}#Dn(){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.#Tn,e=this.#Tn=this.#Rn().trimEnd();if(t===e)return;const i=t=>{this.#Tn=t,t?(this.#Fn(),this._uiManager.rebuild(this),this.#Dn()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#Dn()}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){qs._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._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#Mn),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.#fn}px * var(--total-scale-factor))`,i.color=this.#in,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Kt(this,this.div,["dblclick","keydown"]),this._isCopy||this.annotationElementId){const[i,s]=this.parentDimensions;if(this.annotationElementId){const{position:n}=this._initialData;let[a,r]=this.getInitialTranslation();[a,r]=this.pageTranslationToScreen(a,r);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,[a,r]=[r,-a];break;case 180:c=t-this.width+(n[0]-h)/o,u=e-(n[1]-d)/l,[a,r]=[-a,-r];break;case 270:c=t+(n[0]-h-this.height*l)/o,u=e+(n[1]-d-this.width*o)/l,[a,r]=[-r,a]}this.setAt(c*i,u*s,a,r)}else this._moveAfterPaste(t,e);this.#Fn(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#Nn(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Gs,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const s=qs.#On(e.getData("text")||"").replaceAll(Gs,"\n");if(!s)return;const n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();const a=n.getRangeAt(0);if(!s.includes("\n"))return a.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),void n.collapseToStart();const{startContainer:r,startOffset:o}=a,l=[],h=[];if(r.nodeType===Node.TEXT_NODE){const t=r.parentElement;if(h.push(r.nodeValue.slice(o).replaceAll(Gs,"")),t!==this.editorDiv){let e=l;for(const i of this.editorDiv.childNodes)i!==t?e.push(qs.#Nn(i)):e=h}l.push(r.nodeValue.slice(0,o).replaceAll(Gs,""))}else if(r===this.editorDiv){let t=l,e=0;for(const i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(qs.#Nn(i))}this.#Tn=`${l.join("\n")}${s}${h.join("\n")}`,this.#Fn();const d=new Range;let c=Math.sumPrecise(l.map((t=>t.length)));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)}#Fn(){if(this.editorDiv.replaceChildren(),this.#Tn)for(const t of this.#Tn.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#Bn(){return this.#Tn.replaceAll(" "," ")}static#On(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,i){let s=null;if(t instanceof Ls){const{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:n,rotation:a,id:r,popupRef:o},textContent:l,textPosition:h,parent:{page:{pageNumber:d}}}=t;if(!l||0===l.length)return null;s=t={annotationType:L.FREETEXT,color:Array.from(i),fontSize:e,value:l.join("\n"),position:h,pageIndex:d-1,rect:n.slice(0),rotation:a,id:r,deleted:!1,popupRef:o}}const n=await super.deserialize(t,e,i);return n.#fn=t.fontSize,n.#in=yt.makeHexColor(...t.color),n.#Tn=qs.#On(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=qs._internalPadding*this.parentScale,i=this.getRect(e,e),s=ne._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#in),n={annotationType:L.FREETEXT,color:s,fontSize:this.#fn,value:this.#Bn(),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(n.isCopy=!0,n):this.annotationElementId&&!this.#jn(n)?null:(n.id=this.annotationElementId,n)}#jn(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.#fn}px * var(--total-scale-factor))`,i.color=this.#in,e.replaceChildren();for(const t of this.#Tn.split("\n")){const i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}const s=qs._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:this.#Tn}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class Xs{static PRECISION=1e-4;toSVGPath(){nt("Abstract method `toSVGPath` must be implemented.")}get box(){nt("Abstract getter `box` must be implemented.")}serialize(t,e){nt("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,n,a){a||=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r+=2)a[r]=e+t[r]*s,a[r+1]=i+t[r+1]*n;return a}static _rescaleAndSwap(t,e,i,s,n,a){a||=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r+=2)a[r]=e+t[r+1]*s,a[r+1]=i+t[r]*n;return a}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let n=0,a=t.length;n<a;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,a){return[(t+5*i)/6,(e+5*s)/6,(5*i+n)/6,(5*s+a)/6,(i+n)/2,(s+a)/2]}}class Ks{#Vn;#Hn=[];#Un;#zn;#$n=[];#Wn=new Float32Array(18);#Gn;#qn;#Xn;#Kn;#Yn;#Qn;#Zn=[];static#Jn=8;static#ta=2;static#ea=Ks.#Jn+Ks.#ta;constructor({x:t,y:e},i,s,n,a,r=0){this.#Vn=i,this.#Qn=n*s,this.#zn=a,this.#Wn.set([NaN,NaN,NaN,NaN,t,e],6),this.#Un=r,this.#Kn=Ks.#Jn*s,this.#Xn=Ks.#ea*s,this.#Yn=s,this.#Zn.push(t,e)}isEmpty(){return isNaN(this.#Wn[8])}#ia(){const t=this.#Wn.subarray(4,6),e=this.#Wn.subarray(16,18),[i,s,n,a]=this.#Vn;return[(this.#Gn+(t[0]-e[0])/2-i)/n,(this.#qn+(t[1]-e[1])/2-s)/a,(this.#Gn+(e[0]-t[0])/2-i)/n,(this.#qn+(e[1]-t[1])/2-s)/a]}add({x:t,y:e}){this.#Gn=t,this.#qn=e;const[i,s,n,a]=this.#Vn;let[r,o,l,h]=this.#Wn.subarray(8,12);const d=t-l,c=e-h,u=Math.hypot(d,c);if(u<this.#Xn)return!1;const p=u-this.#Kn,g=p/u,f=g*d,m=g*c;let b=r,v=o;r=l,o=h,l+=f,h+=m,this.#Zn?.push(t,e);const w=f/p,y=-m/p*this.#Qn,A=w*this.#Qn;if(this.#Wn.set(this.#Wn.subarray(2,8),0),this.#Wn.set([l+y,h+A],4),this.#Wn.set(this.#Wn.subarray(14,18),12),this.#Wn.set([l-y,h-A],16),isNaN(this.#Wn[6]))return 0===this.#$n.length&&(this.#Wn.set([r+y,o+A],2),this.#$n.push(NaN,NaN,NaN,NaN,(r+y-i)/n,(o+A-s)/a),this.#Wn.set([r-y,o-A],14),this.#Hn.push(NaN,NaN,NaN,NaN,(r-y-i)/n,(o-A-s)/a)),this.#Wn.set([b,v,r,o,l,h],6),!this.isEmpty();this.#Wn.set([b,v,r,o,l,h],6);return Math.abs(Math.atan2(v-o,b-r)-Math.atan2(m,f))<Math.PI/2?([r,o,l,h]=this.#Wn.subarray(2,6),this.#$n.push(NaN,NaN,NaN,NaN,((r+l)/2-i)/n,((o+h)/2-s)/a),[r,o,b,v]=this.#Wn.subarray(14,18),this.#Hn.push(NaN,NaN,NaN,NaN,((b+r)/2-i)/n,((v+o)/2-s)/a),!0):([b,v,r,o,l,h]=this.#Wn.subarray(0,6),this.#$n.push(((b+5*r)/6-i)/n,((v+5*o)/6-s)/a,((5*r+l)/6-i)/n,((5*o+h)/6-s)/a,((r+l)/2-i)/n,((o+h)/2-s)/a),[l,h,r,o,b,v]=this.#Wn.subarray(12,18),this.#Hn.push(((b+5*r)/6-i)/n,((v+5*o)/6-s)/a,((5*r+l)/6-i)/n,((5*o+h)/6-s)/a,((r+l)/2-i)/n,((o+h)/2-s)/a),!0)}toSVGPath(){if(this.isEmpty())return"";const t=this.#$n,e=this.#Hn;if(isNaN(this.#Wn[6])&&!this.isEmpty())return this.#sa();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.#na(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.#aa(i),i.join(" ")}#sa(){const[t,e,i,s]=this.#Vn,[n,a,r,o]=this.#ia();return`M${(this.#Wn[2]-t)/i} ${(this.#Wn[3]-e)/s} L${(this.#Wn[4]-t)/i} ${(this.#Wn[5]-e)/s} L${n} ${a} L${r} ${o} L${(this.#Wn[16]-t)/i} ${(this.#Wn[17]-e)/s} L${(this.#Wn[14]-t)/i} ${(this.#Wn[15]-e)/s} Z`}#aa(t){const e=this.#Hn;t.push(`L${e[4]} ${e[5]} Z`)}#na(t){const[e,i,s,n]=this.#Vn,a=this.#Wn.subarray(4,6),r=this.#Wn.subarray(16,18),[o,l,h,d]=this.#ia();t.push(`L${(a[0]-e)/s} ${(a[1]-i)/n} L${o} ${l} L${h} ${d} L${(r[0]-e)/s} ${(r[1]-i)/n}`)}newFreeDrawOutline(t,e,i,s,n,a){return new Ys(t,e,i,s,n,a)}getOutlines(){const t=this.#$n,e=this.#Hn,i=this.#Wn,[s,n,a,r]=this.#Vn,o=new Float32Array((this.#Zn?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#Zn[t]-s)/a,o[t+1]=(this.#Zn[t+1]-n)/r;if(o[o.length-2]=(this.#Gn-s)/a,o[o.length-1]=(this.#qn-n)/r,isNaN(i[6])&&!this.isEmpty())return this.#ra(o);const l=new Float32Array(this.#$n.length+24+this.#Hn.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.#oa(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.#la(l,h),this.newFreeDrawOutline(l,o,this.#Vn,this.#Yn,this.#Un,this.#zn)}#ra(t){const e=this.#Wn,[i,s,n,a]=this.#Vn,[r,o,l,h]=this.#ia(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/n,(e[3]-s)/a,NaN,NaN,NaN,NaN,(e[4]-i)/n,(e[5]-s)/a,NaN,NaN,NaN,NaN,r,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/n,(e[17]-s)/a,NaN,NaN,NaN,NaN,(e[14]-i)/n,(e[15]-s)/a],0),this.newFreeDrawOutline(d,t,this.#Vn,this.#Yn,this.#Un,this.#zn)}#la(t,e){const i=this.#Hn;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#oa(t,e){const i=this.#Wn.subarray(4,6),s=this.#Wn.subarray(16,18),[n,a,r,o]=this.#Vn,[l,h,d,c]=this.#ia();return t.set([NaN,NaN,NaN,NaN,(i[0]-n)/r,(i[1]-a)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,d,c,NaN,NaN,NaN,NaN,(s[0]-n)/r,(s[1]-a)/o],e),e+24}}class Ys extends Xs{#Vn;#ha=new Float32Array(4);#Un;#zn;#Zn;#Yn;#da;constructor(t,e,i,s,n,a){super(),this.#da=t,this.#Zn=e,this.#Vn=i,this.#Yn=s,this.#Un=n,this.#zn=a,this.lastPoint=[NaN,NaN],this.#ca(a);const[r,o,l,h]=this.#ha;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-r)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-r)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){const t=[`M${this.#da[4]} ${this.#da[5]}`];for(let e=6,i=this.#da.length;e<i;e+=6)isNaN(this.#da[e])?t.push(`L${this.#da[e+4]} ${this.#da[e+5]}`):t.push(`C${this.#da[e]} ${this.#da[e+1]} ${this.#da[e+2]} ${this.#da[e+3]} ${this.#da[e+4]} ${this.#da[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,i,s],n){const a=i-t,r=s-e;let o,l;switch(n){case 0:o=Xs._rescale(this.#da,t,s,a,-r),l=Xs._rescale(this.#Zn,t,s,a,-r);break;case 90:o=Xs._rescaleAndSwap(this.#da,t,e,a,r),l=Xs._rescaleAndSwap(this.#Zn,t,e,a,r);break;case 180:o=Xs._rescale(this.#da,i,e,-a,r),l=Xs._rescale(this.#Zn,i,e,-a,r);break;case 270:o=Xs._rescaleAndSwap(this.#da,i,s,-a,-r),l=Xs._rescaleAndSwap(this.#Zn,i,s,-a,-r)}return{outline:Array.from(o),points:[Array.from(l)]}}#ca(t){const e=this.#da;let i=e[4],s=e[5];const n=[i,s,i,s];let a=i,r=s;const o=t?Math.max:Math.min;for(let t=6,l=e.length;t<l;t+=6){const l=e[t+4],h=e[t+5];if(isNaN(e[t]))yt.pointBoundingBox(l,h,n),r<h?(a=l,r=h):r===h&&(a=o(a,l));else{const l=[1/0,1/0,-1/0,-1/0];yt.bezierBoundingBox(i,s,...e.slice(t,t+6),l),yt.rectBoundingBox(...l,n),r<l[3]?(a=l[2],r=l[3]):r===l[3]&&(a=o(a,l[2]))}i=l,s=h}const l=this.#ha;l[0]=n[0]-this.#Un,l[1]=n[1]-this.#Un,l[2]=n[2]-n[0]+2*this.#Un,l[3]=n[3]-n[1]+2*this.#Un,this.lastPoint=[a,r]}get box(){return this.#ha}newOutliner(t,e,i,s,n,a=0){return new Ks(t,e,i,s,n,a)}getNewOutline(t,e){const[i,s,n,a]=this.#ha,[r,o,l,h]=this.#Vn,d=n*l,c=a*h,u=i*l+r,p=s*h+o,g=this.newOutliner({x:this.#Zn[0]*d+u,y:this.#Zn[1]*c+p},this.#Vn,this.#Yn,t,this.#zn,e??this.#Un);for(let t=2;t<this.#Zn.length;t+=2)g.add({x:this.#Zn[t]*d+u,y:this.#Zn[t+1]*c+p});return g.getOutlines()}}class Qs{#Vn;#ua;#pa=[];#ga=[];constructor(t,e=0,i=0,s=!0){const n=[1/0,1/0,-1/0,-1/0],a=10**-4;for(const{x:i,y:s,width:r,height:o}of t){const t=Math.floor((i-e)/a)*a,l=Math.ceil((i+r+e)/a)*a,h=Math.floor((s-e)/a)*a,d=Math.ceil((s+o+e)/a)*a,c=[t,h,d,!0],u=[l,h,d,!1];this.#pa.push(c,u),yt.rectBoundingBox(t,h,l,d,n)}const r=n[2]-n[0]+2*i,o=n[3]-n[1]+2*i,l=n[0]-i,h=n[1]-i,d=this.#pa.at(s?-1:-2),c=[d[0],d[2]];for(const t of this.#pa){const[e,i,s]=t;t[0]=(e-l)/r,t[1]=(i-h)/o,t[2]=(s-h)/o}this.#Vn=new Float32Array([l,h,r,o]),this.#ua=c}getOutlines(){this.#pa.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of this.#pa)e[3]?(t.push(...this.#fa(e)),this.#ma(e)):(this.#ba(e),t.push(...this.#fa(e)));return this.#va(t)}#va(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,a,r,o,l]=t;i.delete(t);let h=e,d=a;for(n=[e,r],s.push(n);;){let t;if(i.has(o))t=o;else{if(!i.has(l))break;t=l}i.delete(t),[e,a,r,o,l]=t,h!==e&&(n.push(h,d,e,d===a?a:r),h=e),d=d===a?r:a}n.push(h,d)}return new Zs(s,this.#Vn,this.#ua)}#wa(t){const e=this.#ga;let i=0,s=e.length-1;for(;i<=s;){const n=i+s>>1,a=e[n][0];if(a===t)return n;a<t?i=n+1:s=n-1}return s+1}#ma([,t,e]){const i=this.#wa(t);this.#ga.splice(i,0,[t,e])}#ba([,t,e]){const i=this.#wa(t);for(let s=i;s<this.#ga.length;s++){const[i,n]=this.#ga[s];if(i!==t)break;if(i===t&&n===e)return void this.#ga.splice(s,1)}for(let s=i-1;s>=0;s--){const[i,n]=this.#ga[s];if(i!==t)break;if(i===t&&n===e)return void this.#ga.splice(s,1)}}#fa(t){const[e,i,s]=t,n=[[e,i,s]],a=this.#wa(s);for(let t=0;t<a;t++){const[i,s]=this.#ga[t];for(let t=0,a=n.length;t<a;t++){const[,r,o]=n[t];if(!(s<=r||o<=i))if(r>=i)if(o>s)n[t][1]=s;else{if(1===a)return[];n.splice(t,1),t--,a--}else n[t][2]=i,o>s&&n.push([e,s,o])}}return n}}class Zs extends Xs{#Vn;#ya;constructor(t,e,i){super(),this.#ya=t,this.#Vn=e,this.lastPoint=i}toSVGPath(){const t=[];for(const e of this.#ya){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n<e.length;n+=2){const a=e[n],r=e[n+1];a===i?(t.push(`V${r}`),s=r):r===s&&(t.push(`H${a}`),i=a)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],n){const a=[],r=i-t,o=s-e;for(const e of this.#ya){const i=new Array(e.length);for(let n=0;n<e.length;n+=2)i[n]=t+e[n]*r,i[n+1]=s-e[n+1]*o;a.push(i)}return a}get box(){return this.#Vn}get classNamesForOutlining(){return["highlightOutline"]}}class Js extends Ks{newFreeDrawOutline(t,e,i,s,n,a){return new tn(t,e,i,s,n,a)}}class tn extends Ys{newOutliner(t,e,i,s,n,a=0){return new Js(t,e,i,s,n,a)}}let en=class t{#Aa=null;#_a=null;#xa;#Sa=null;#Ca=!1;#Ea=!1;#a=null;#Pa;#Ta=null;#m=null;#Ma;static#Ia=null;static get _keyboardManager(){return lt(this,"_keyboardManager",new Jt([[["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.#Ea=!1,this.#Ma=D.HIGHLIGHT_COLOR,this.#a=e):(this.#Ea=!0,this.#Ma=D.HIGHLIGHT_DEFAULT_COLOR),this.#m=e?._uiManager||i,this.#Pa=this.#m._eventBus,this.#xa=e?.color||this.#m?.highlightColors.values().next().value||"#FFFF98",t.#Ia||=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.#Aa=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.#m._signal;t.addEventListener("click",this.#ka.bind(this),{signal:e}),t.addEventListener("keydown",this.#Ks.bind(this),{signal:e});const i=this.#_a=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#xa,t.append(i),t}renderMainDropdown(){const t=this.#Sa=this.#La();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#La(){const e=document.createElement("div"),i=this.#m._signal;e.addEventListener("contextmenu",Ot,{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.#m.highlightColors){const a=document.createElement("button");a.tabIndex="0",a.role="option",a.setAttribute("data-color",n),a.title=s,a.setAttribute("data-l10n-id",t.#Ia[s]);const r=document.createElement("span");a.append(r),r.className="swatch",r.style.backgroundColor=n,a.setAttribute("aria-selected",n===this.#xa),a.addEventListener("click",this.#Da.bind(this,n),{signal:i}),e.append(a)}return e.addEventListener("keydown",this.#Ks.bind(this),{signal:i}),e}#Da(t,e){e.stopPropagation(),this.#Pa.dispatch("switchannotationeditorparams",{source:this,type:this.#Ma,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#Aa)return void this.#ka(t);const e=t.target.getAttribute("data-color");e&&this.#Da(e,t)}_moveToNext(t){this.#Ra?t.target!==this.#Aa?t.target.nextSibling?.focus():this.#Sa.firstChild?.focus():this.#ka(t)}_moveToPrevious(t){t.target!==this.#Sa?.firstChild&&t.target!==this.#Aa?(this.#Ra||this.#ka(t),t.target.previousSibling?.focus()):this.#Ra&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#Ra?this.#Sa.firstChild?.focus():this.#ka(t)}_moveToEnd(t){this.#Ra?this.#Sa.lastChild?.focus():this.#ka(t)}#Ks(e){t._keyboardManager.exec(this,e)}#ka(t){if(this.#Ra)return void this.hideDropdown();if(this.#Ca=0===t.detail,this.#Ta||(this.#Ta=new AbortController,window.addEventListener("pointerdown",this.#d.bind(this),{signal:this.#m.combinedSignal(this.#Ta)})),this.#Sa)return void this.#Sa.classList.remove("hidden");const e=this.#Sa=this.#La();this.#Aa.append(e)}#d(t){this.#Sa?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#Sa?.classList.add("hidden"),this.#Ta?.abort(),this.#Ta=null}get#Ra(){return this.#Sa&&!this.#Sa.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#Ea||(this.#Ra?(this.hideDropdown(),this.#Aa.focus({preventScroll:!0,focusVisible:this.#Ca})):this.#a?.unselect())}updateColor(t){if(this.#_a&&(this.#_a.style.backgroundColor=t),!this.#Sa)return;const e=this.#m.highlightColors.values();for(const i of this.#Sa.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#Aa?.remove(),this.#Aa=null,this.#_a=null,this.#Sa?.remove(),this.#Sa=null}};class sn extends ne{#Na=null;#Fa=0;#Oa;#Ba=null;#n=null;#ja=null;#Va=null;#Ha=0;#Ua=null;#za=null;#y=null;#$a=!1;#ua=null;#Wa;#Ga=null;#qa="";#Qn;#Xa="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=L.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=sn.prototype;return lt(this,"_keyboardManager",new Jt([[["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||sn._defaultColor,this.#Qn=t.thickness||sn._defaultThickness,this.#Wa=t.opacity||sn._defaultOpacity,this.#Oa=t.boxes||null,this.#Xa=t.methodOfCreation||"",this.#qa=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#$a=!0,this.#Ka(t),this.#Ya()):this.#Oa&&(this.#Na=t.anchorNode,this.#Fa=t.anchorOffset,this.#Va=t.focusNode,this.#Ha=t.focusOffset,this.#Qa(),this.#Ya(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#$a?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#Qn,methodOfCreation:this.#Xa}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#Qa(){const t=new Qs(this.#Oa,.001);this.#za=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#za.box;const e=new Qs(this.#Oa,.0025,.001,"ltr"===this._uiManager.direction);this.#ja=e.getOutlines();const{lastPoint:i}=this.#ja;this.#ua=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#Ka({highlightOutlines:t,highlightId:e,clipPathId:i}){this.#za=t;if(this.#ja=t.getNewOutline(this.#Qn/2+1.5,.0025),e>=0)this.#y=e,this.#Ba=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#Ga=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#ja.box,path:{d:this.#ja.toSVGPath()}},!0);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#y,{bbox:sn.#Za(this.#za.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#Ga,{bbox:sn.#Za(this.#ja.box,e),path:{d:this.#ja.toSVGPath()}})}const[s,n,a,r]=t.box;switch(this.rotation){case 0:this.x=s,this.y=n,this.width=a,this.height=r;break;case 90:{const[t,e]=this.parentDimensions;this.x=n,this.y=1-s,this.width=a*e/t,this.height=r*t/e;break}case 180:this.x=1-s,this.y=1-n,this.width=a,this.height=r;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-n,this.y=s,this.width=a*e/t,this.height=r*t/e;break}}const{lastPoint:o}=this.#ja;this.#ua=[(o[0]-s)/a,(o[1]-n)/r]}static initialize(t,e){ne.initialize(t,e),sn._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case D.HIGHLIGHT_DEFAULT_COLOR:sn._defaultColor=e;break;case D.HIGHLIGHT_THICKNESS:sn._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#ua}updateParams(t,e){switch(t){case D.HIGHLIGHT_COLOR:this.#Ln(e);break;case D.HIGHLIGHT_THICKNESS:this.#Ja(e)}}static get defaultPropertiesToUpdate(){return[[D.HIGHLIGHT_DEFAULT_COLOR,sn._defaultColor],[D.HIGHLIGHT_THICKNESS,sn._defaultThickness]]}get propertiesToUpdate(){return[[D.HIGHLIGHT_COLOR,this.color||sn._defaultColor],[D.HIGHLIGHT_THICKNESS,this.#Qn||sn._defaultThickness],[D.HIGHLIGHT_FREE,this.#$a]]}#Ln(t){const e=(t,e)=>{this.color=t,this.#Wa=e,this.parent?.drawLayer.updateProperties(this.#y,{root:{fill:t,"fill-opacity":e}}),this.#n?.updateColor(t)},i=this.color,s=this.#Wa;this.addCommands({cmd:e.bind(this,t,sn._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:D.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#Ja(t){const e=this.#Qn,i=t=>{this.#Qn=t,this.#tr(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:D.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 en({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.#er())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#er())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#ir(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#Ya(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#ir():t&&(this.#Ya(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#tr(t){if(!this.#$a)return;this.#Ka({highlightOutlines:this.#za.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#ir(){null!==this.#y&&this.parent&&(this.parent.drawLayer.remove(this.#y),this.#y=null,this.parent.drawLayer.remove(this.#Ga),this.#Ga=null)}#Ya(t=this.parent){null===this.#y&&(({id:this.#y,clipPathId:this.#Ba}=t.drawLayer.draw({bbox:this.#za.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#Wa},rootClass:{highlight:!0,free:this.#$a},path:{d:this.#za.toSVGPath()}},!1,!0)),this.#Ga=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#$a},bbox:this.#ja.box,path:{d:this.#ja.toSVGPath()}},this.#$a),this.#Ua&&(this.#Ua.style.clipPath=this.#Ba))}static#Za([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.#$a?(t=(t-this.rotation+360)%360,i=sn.#Za(this.#za.box,t)):i=sn.#Za([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#y,{bbox:i,root:{"data-main-rotation":t}}),e.updateProperties(this.#Ga,{bbox:sn.#Za(this.#ja.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#qa&&(t.setAttribute("aria-label",this.#qa),t.setAttribute("role","mark")),this.#$a?t.classList.add("free"):this.div.addEventListener("keydown",this.#sr.bind(this),{signal:this._uiManager._signal});const e=this.#Ua=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#Ba;const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),Kt(this,this.#Ua,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Ga,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Ga,{rootClass:{hovered:!1}})}#sr(t){sn._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#nr(!0);break;case 1:case 3:this.#nr(!1)}}#nr(t){if(!this.#Na)return;const e=window.getSelection();t?e.setPosition(this.#Na,this.#Fa):e.setPosition(this.#Va,this.#Ha)}select(){super.select(),this.#Ga&&this.parent?.drawLayer.updateProperties(this.#Ga,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#Ga&&(this.parent?.drawLayer.updateProperties(this.#Ga,{rootClass:{selected:!1}}),this.#$a||this.#nr(!1))}get _mustFixPosition(){return!this.#$a}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#y,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#Ga,{rootClass:{hidden:!t}}))}#er(){return this.#$a?this.rotation:0}#ar(){if(this.#$a)return null;const[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=this.#Oa,a=new Float32Array(8*n.length);let r=0;for(const{x:o,y:l,width:h,height:d}of n){const n=o*t+i,c=(1-l)*e+s;a[r]=a[r+4]=n,a[r+1]=a[r+3]=c,a[r+2]=a[r+6]=n+h*t,a[r+5]=a[r+7]=c-d*e,r+=8}return a}#rr(t){return this.#za.serialize(t,this.#er())}static startHighlighting(t,e,{target:i,x:s,y:n}){const{x:a,y:r,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,d=t.combinedSignal(h),c=e=>{h.abort(),this.#or(t,e)};window.addEventListener("blur",c,{signal:d}),window.addEventListener("pointerup",c,{signal:d}),window.addEventListener("pointerdown",Bt,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",Ot,{signal:d}),i.addEventListener("pointermove",this.#lr.bind(this,t),{signal:d}),this._freeHighlight=new Js({x:s,y:n},[a,r,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#lr(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#or(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 Vs){const{data:{quadPoints:e,rect:i,rotation:n,id:a,color:r,opacity:o,popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:L.HIGHLIGHT,color:Array.from(r),opacity:o,quadPoints:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:a,deleted:!1,popupRef:l}}else if(t instanceof js){const{data:{inkLists:e,rect:i,rotation:n,id:a,color:r,borderStyle:{rawWidth:o},popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:L.HIGHLIGHT,color:Array.from(r),thickness:o,inkLists:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:a,deleted:!1,popupRef:l}}const{color:n,quadPoints:a,inkLists:r,opacity:o}=t,l=await super.deserialize(t,e,i);l.color=yt.makeHexColor(...n),l.#Wa=o||1,r&&(l.#Qn=t.thickness),l.annotationElementId=t.id||null,l._initialData=s;const[h,d]=l.pageDimensions,[c,u]=l.pageTranslation;if(a){const t=l.#Oa=[];for(let e=0;e<a.length;e+=8)t.push({x:(a[e]-c)/h,y:1-(a[e+1]-u)/d,width:(a[e+2]-a[e])/h,height:(a[e+1]-a[e+5])/d});l.#Qa(),l.#Ya(),l.rotate(l.rotation)}else if(r){l.#$a=!0;const t=r[0],i={x:t[0]-c,y:d-(t[1]-u)},s=new Js(i,[0,0,h,d],1,l.#Qn/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:a}=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.#Ka({highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:a}),l.#Ya(),l.rotate(l.parentRotation)}return l}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),i=ne._colorManager.convert(this.color),s={annotationType:L.HIGHLIGHT,color:i,opacity:this.#Wa,thickness:this.#Qn,quadPoints:this.#ar(),outlines:this.#rr(e),pageIndex:this.pageIndex,rect:e,rotation:this.#er(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#jn(s)?null:(s.id=this.annotationElementId,s)}#jn(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 nn{#hr=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))e.startsWith("_")||this.updateProperty(e,i)}updateSVGProperty(t,e){this.#hr[t]=e}toSVGProperties(){const t=this.#hr;return this.#hr=Object.create(null),{root:t}}reset(){this.#hr=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){nt("Not implemented")}}class an extends ne{#dr=null;#cr;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#ur=null;static#pr=null;static#gr=null;static#fr=NaN;static#mr=null;static#br=null;static#vr=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#cr=t.mustBeCommitted||!1,this._addOutlines(t)}_addOutlines(t){t.drawOutlines&&(this.#wr(t),this.#Ya())}#wr({drawOutlines:t,drawId:e,drawingOptions:i}){this.#dr=t,this._drawingOptions||=i,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#yr(t,this.parent),this.#Ar(t.box)}#yr(t,e){const{id:i}=e.drawLayer.draw(an._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){nt("Not implemented")}static get typesMap(){nt("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&&(an.#ur.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],a=t=>{s.updateProperty(e,t);const i=this.#dr.updateProperty(e,t);i&&this.#Ar(i),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties())};this.addCommands({cmd:a.bind(this,i),undo:a.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,an._mergeSVGProperties(this.#dr.getPathResizingSVGProperties(this.#_r()),{bbox:this.#xr()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,an._mergeSVGProperties(this.#dr.getPathResizedSVGProperties(this.#_r()),{bbox:this.#xr()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#xr()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,an._mergeSVGProperties(this.#dr.getPathTranslatedSVGProperties(this.#_r(),this.parentDimensions),{bbox:this.#xr()}))}_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.#cr&&(this.#cr=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#ir(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#Ya(),this.#Ar(this.#dr.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#ir()):t&&(this._uiManager.addShouldRescale(this),this.#Ya(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#ir(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#Ya(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#yr(this.#dr,t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}#Sr([t,e,i,s]){const{parentDimensions:[n,a],rotation:r}=this;switch(r){case 90:return[e,1-t,i*(a/n),s*(n/a)];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,i*(a/n),s*(n/a)];default:return[t,e,i,s]}}#_r(){const{x:t,y:e,width:i,height:s,parentDimensions:[n,a],rotation:r}=this;switch(r){case 90:return[1-e,t,i*(n/a),s*(a/n)];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,i*(n/a),s*(a/n)];default:return[t,e,i,s]}}#Ar(t){if([this.x,this.y,this.width,this.height]=this.#Sr(t),this.div){this.fixAndSetPosition();const[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()}#xr(){const{x:t,y:e,width:i,height:s,rotation:n,parentRotation:a,parentDimensions:[r,o]}=this;switch((4*n+a)/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*(r/o),s*(o/r),i*(r/o)];case 5:return[1-e,t,i*(r/o),s*(o/r)];case 6:return[1-t-s*(o/r),1-e,s*(o/r),i*(r/o)];case 7:return[e-i*(r/o),1-t-s*(o/r),i*(r/o),s*(o/r)];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/r),e,s*(o/r),i*(r/o)];case 13:return[1-e-i*(r/o),t-s*(o/r),i*(r/o),s*(o/r)];case 14:return[1-t,1-e-i*(r/o),s*(o/r),i*(r/o)];case 15:return[e,1-t,i*(r/o),s*(o/r)];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,an._mergeSVGProperties({bbox:this.#xr()},this.#dr.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#Ar(this.#dr.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const i=super.render();i.classList.add("draw");const s=document.createElement("div");i.append(s),s.setAttribute("aria-hidden","true"),s.className="internal";const[n,a]=this.parentDimensions;return this.setDims(this.width*n,this.height*a),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),i}static createDrawerInstance(t,e,i,s,n){nt("Not implemented")}static startDrawing(t,e,i,s){const{target:n,offsetX:a,offsetY:r,pointerId:o,pointerType:l}=s;if(an.#mr&&an.#mr!==l)return;const{viewport:{rotation:h}}=t,{width:d,height:c}=n.getBoundingClientRect(),u=an.#pr=new AbortController,p=t.combinedSignal(u);an.#fr||=o,an.#mr??=l,window.addEventListener("pointerup",(t=>{an.#fr===t.pointerId?this._endDraw(t):an.#br?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointercancel",(t=>{an.#fr===t.pointerId?this._currentParent.endDrawingSession():an.#br?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointerdown",(t=>{an.#mr===t.pointerType&&((an.#br||=new Set).add(t.pointerId),an.#ur.isCancellable()&&(an.#ur.removeLastElement(),an.#ur.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",Ot,{signal:p}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),n.addEventListener("touchmove",(t=>{t.timeStamp===an.#vr&&Bt(t)}),{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),an.#ur?t.drawLayer.updateProperties(this._currentDrawId,an.#ur.startNew(a,r,d,c,h)):(e.updateUIForDefaultProperties(this),an.#ur=this.createDrawerInstance(a,r,d,c,h),an.#gr=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(an.#gr.toSVGProperties(),an.#ur.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(an.#vr=-1,!an.#ur)return;const{offsetX:e,offsetY:i,pointerId:s}=t;an.#fr===s&&(an.#br?.size>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,an.#ur.add(e,i)),an.#vr=t.timeStamp,Bt(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,an.#ur=null,an.#gr=null,an.#mr=null,an.#vr=NaN),an.#pr&&(an.#pr.abort(),an.#pr=null,an.#fr=NaN,an.#br=null)}static _endDraw(t){const e=this._currentParent;if(e)if(e.toggleDrawing(!0),this._cleanup(!1),t?.target===e.div&&e.drawLayer.updateProperties(this._currentDrawId,an.#ur.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const t=an.#ur,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:D.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(D.DRAW_STEP),!an.#ur.isEmpty()){const{pageDimensions:[i,s],scale:n}=e,a=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:an.#ur.getOutlines(i*n,s*n,n,this._INNER_MARGIN),drawingOptions:an.#gr,mustBeCommitted:!t});return this._cleanup(!0),a}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,n,a){nt("Not implemented")}static async deserialize(t,e,i){const{rawDims:{pageWidth:s,pageHeight:n,pageX:a,pageY:r}}=e.viewport,o=this.deserializeDraw(a,r,s,n,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#wr({drawOutlines:o}),l.#Ya(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){const[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return this.#dr.serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class rn{#Wn=new Float64Array(6);#wn;#Cr;#es;#Qn;#Zn;#Er="";#Pr=0;#ya=new on;#Tr;#Mr;constructor(t,e,i,s,n,a){this.#Tr=i,this.#Mr=s,this.#es=n,this.#Qn=a,[t,e]=this.#Ir(t,e);const r=this.#wn=[NaN,NaN,NaN,NaN,t,e];this.#Zn=[t,e],this.#Cr=[{line:r,points:this.#Zn}],this.#Wn.set(r,0)}updateProperty(t,e){"stroke-width"===t&&(this.#Qn=e)}#Ir(t,e){return Xs._normalizePoint(t,e,this.#Tr,this.#Mr,this.#es)}isEmpty(){return!this.#Cr||0===this.#Cr.length}isCancellable(){return this.#Zn.length<=10}add(t,e){[t,e]=this.#Ir(t,e);const[i,s,n,a]=this.#Wn.subarray(2,6),r=t-n,o=e-a;return Math.hypot(this.#Tr*r,this.#Mr*o)<=2?null:(this.#Zn.push(t,e),isNaN(i)?(this.#Wn.set([n,a,t,e],2),this.#wn.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#Wn[0])&&this.#wn.splice(6,6),this.#Wn.set([i,s,n,a,t,e],0),this.#wn.push(...Xs.createBezierPoints(i,s,n,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const i=this.add(t,e);return i||(2===this.#Zn.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,n){this.#Tr=i,this.#Mr=s,this.#es=n,[t,e]=this.#Ir(t,e);const a=this.#wn=[NaN,NaN,NaN,NaN,t,e];this.#Zn=[t,e];const r=this.#Cr.at(-1);return r&&(r.line=new Float32Array(r.line),r.points=new Float32Array(r.points)),this.#Cr.push({line:a,points:this.#Zn}),this.#Wn.set(a,0),this.#Pr=0,this.toSVGPath(),null}getLastElement(){return this.#Cr.at(-1)}setLastElement(t){return this.#Cr?(this.#Cr.push(t),this.#wn=t.line,this.#Zn=t.points,this.#Pr=0,{path:{d:this.toSVGPath()}}):this.#ya.setLastElement(t)}removeLastElement(){if(!this.#Cr)return this.#ya.removeLastElement();this.#Cr.pop(),this.#Er="";for(let t=0,e=this.#Cr.length;t<e;t++){const{line:e,points:i}=this.#Cr[t];this.#wn=e,this.#Zn=i,this.#Pr=0,this.toSVGPath()}return{path:{d:this.#Er}}}toSVGPath(){const t=Xs.svgRound(this.#wn[4]),e=Xs.svgRound(this.#wn[5]);if(2===this.#Zn.length)return this.#Er=`${this.#Er} M ${t} ${e} Z`,this.#Er;if(this.#Zn.length<=6){const i=this.#Er.lastIndexOf("M");this.#Er=`${this.#Er.slice(0,i)} M ${t} ${e}`,this.#Pr=6}if(4===this.#Zn.length){const t=Xs.svgRound(this.#wn[10]),e=Xs.svgRound(this.#wn[11]);return this.#Er=`${this.#Er} L ${t} ${e}`,this.#Pr=12,this.#Er}const i=[];0===this.#Pr&&(i.push(`M ${t} ${e}`),this.#Pr=6);for(let t=this.#Pr,e=this.#wn.length;t<e;t+=6){const[e,s,n,a,r,o]=this.#wn.slice(t,t+6).map(Xs.svgRound);i.push(`C${e} ${s} ${n} ${a} ${r} ${o}`)}return this.#Er+=i.join(" "),this.#Pr=this.#wn.length,this.#Er}getOutlines(t,e,i,s){const n=this.#Cr.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#ya.build(this.#Cr,t,e,i,this.#es,this.#Qn,s),this.#Wn=null,this.#wn=null,this.#Cr=null,this.#Er=null,this.#ya}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class on extends Xs{#ha;#kr=0;#Un;#Cr;#Tr;#Mr;#Lr;#es;#Qn;build(t,e,i,s,n,a,r){this.#Tr=e,this.#Mr=i,this.#Lr=s,this.#es=n,this.#Qn=a,this.#Un=r??0,this.#Cr=t,this.#Dr()}get thickness(){return this.#Qn}setLastElement(t){return this.#Cr.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#Cr.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#Cr)if(t.push(`M${Xs.svgRound(e[4])} ${Xs.svgRound(e[5])}`),6!==e.length)if(12===e.length&&isNaN(e[6]))t.push(`L${Xs.svgRound(e[10])} ${Xs.svgRound(e[11])}`);else for(let i=6,s=e.length;i<s;i+=6){const[s,n,a,r,o,l]=e.subarray(i,i+6).map(Xs.svgRound);t.push(`C${s} ${n} ${a} ${r} ${o} ${l}`)}else t.push("Z");return t.join("")}serialize([t,e,i,s],n){const a=[],r=[],[o,l,h,d]=this.#Rr();let c,u,p,g,f,m,b,v,w;switch(this.#es){case 0:w=Xs._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=Xs._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=Xs._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=Xs._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.#Cr)a.push(w(t,c,u,p,g,n?new Array(t.length):null)),r.push(w(e,c,u,p,g,n?new Array(e.length):null));return{lines:a,points:r,rect:[f,m,b,v]}}static deserialize(t,e,i,s,n,{paths:{lines:a,points:r},rotation:o,thickness:l}){const h=[];let d,c,u,p,g;switch(o){case 0:g=Xs._rescale,d=-t/i,c=e/s+1,u=1/i,p=-1/s;break;case 90:g=Xs._rescaleAndSwap,d=-e/s,c=-t/i,u=1/s,p=1/i;break;case 180:g=Xs._rescale,d=t/i+1,c=-e/s,u=-1/i,p=1/s;break;case 270:g=Xs._rescaleAndSwap,d=e/s+1,c=t/i+1,u=-1/s,p=-1/i}if(!a){a=[];for(const t of r){const e=t.length;if(2===e){a.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){a.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));a.push(i);let[s,n,r,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,n],0);for(let a=4;a<e;a+=2){const e=t[a],l=t[a+1];i.set(Xs.createBezierPoints(s,n,r,o,e,l),3*(a-2)),[s,n,r,o]=[r,o,e,l]}}}for(let t=0,e=a.length;t<e;t++)h.push({line:g(a[t].map((t=>t??NaN)),d,c,u,p),points:g(r[t].map((t=>t??NaN)),d,c,u,p)});const f=new this.prototype.constructor;return f.build(h,i,s,1,o,l,n),f}#Nr(t=this.#Qn){const e=this.#Un+t/2*this.#Lr;return this.#es%180==0?[e/this.#Tr,e/this.#Mr]:[e/this.#Mr,e/this.#Tr]}#Rr(){const[t,e,i,s]=this.#ha,[n,a]=this.#Nr(0);return[t+n,e+a,i-2*n,s-2*a]}#Dr(){const t=this.#ha=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:e}of this.#Cr){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6)yt.pointBoundingBox(e[i],e[i+1],t);continue}let i=e[4],s=e[5];for(let n=6,a=e.length;n<a;n+=6){const[a,r,o,l,h,d]=e.subarray(n,n+6);yt.bezierBoundingBox(i,s,a,r,o,l,h,d,t),i=h,s=d}}const[e,i]=this.#Nr();t[0]=Ct(t[0]-e,0,1),t[1]=Ct(t[1]-i,0,1),t[2]=Ct(t[2]+e,0,1),t[3]=Ct(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#ha}updateProperty(t,e){return"stroke-width"===t?this.#Ja(e):null}#Ja(t){const[e,i]=this.#Nr();this.#Qn=t;const[s,n]=this.#Nr(),[a,r]=[s-e,n-i],o=this.#ha;return o[0]-=a,o[1]-=r,o[2]+=2*a,o[3]+=2*r,o}updateParentDimensions([t,e],i){const[s,n]=this.#Nr();this.#Tr=t,this.#Mr=e,this.#Lr=i;const[a,r]=this.#Nr(),o=a-s,l=r-n,h=this.#ha;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#kr=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#ha.map(Xs.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#ha;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Xs.svgRound(t)} ${Xs.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#ha;let i=0,s=0,n=0,a=0,r=0,o=0;switch(this.#kr){case 90:s=e/t,n=-t/e,r=t;break;case 180:i=-1,a=-1,r=t,o=e;break;case 270:s=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${n} ${a} ${Xs.svgRound(r)} ${Xs.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){const[n,a]=this.#Nr(),[r,o,l,h]=this.#ha;if(Math.abs(l-n)<=Xs.PRECISION||Math.abs(h-a)<=Xs.PRECISION){const n=t+i/2-(r+l/2),a=e+s/2-(o+h/2);return{path:{"transform-origin":`${Xs.svgRound(t)} ${Xs.svgRound(e)}`,transform:`${this.rotationTransform} translate(${n} ${a})`}}}const d=(i-2*n)/(l-2*n),c=(s-2*a)/(h-2*a),u=l/i,p=h/s;return{path:{"transform-origin":`${Xs.svgRound(r)} ${Xs.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${p}) translate(${Xs.svgRound(n)} ${Xs.svgRound(a)}) scale(${d} ${c}) translate(${Xs.svgRound(-n)} ${Xs.svgRound(-a)})`}}}getPathResizedSVGProperties([t,e,i,s]){const[n,a]=this.#Nr(),r=this.#ha,[o,l,h,d]=r;if(r[0]=t,r[1]=e,r[2]=i,r[3]=s,Math.abs(h-n)<=Xs.PRECISION||Math.abs(d-a)<=Xs.PRECISION){const n=t+i/2-(o+h/2),a=e+s/2-(l+d/2);for(const{line:t,points:e}of this.#Cr)Xs._translate(t,n,a,t),Xs._translate(e,n,a,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Xs.svgRound(t)} ${Xs.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const c=(i-2*n)/(h-2*n),u=(s-2*a)/(d-2*a),p=-c*(o+n)+t+n,g=-u*(l+a)+e+a;if(1!==c||1!==u||0!==p||0!==g)for(const{line:t,points:e}of this.#Cr)Xs._rescale(t,p,g,c,u,t),Xs._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Xs.svgRound(t)} ${Xs.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[s,n]=i,a=this.#ha,r=t-a[0],o=e-a[1];if(this.#Tr===s&&this.#Mr===n)for(const{line:t,points:e}of this.#Cr)Xs._translate(t,r,o,t),Xs._translate(e,r,o,e);else{const t=this.#Tr/s,e=this.#Mr/n;this.#Tr=s,this.#Mr=n;for(const{line:i,points:s}of this.#Cr)Xs._rescale(i,r,o,t,e,i),Xs._rescale(s,r,o,t,e,s);a[2]*=t,a[3]*=e}return a[0]=t,a[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Xs.svgRound(t)} ${Xs.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#ha;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Xs.svgRound(t[0])} ${Xs.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class ln extends nn{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:ne._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._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new ln(this._viewParameters);return t.updateAll(this),t}}class hn extends an{static _type="ink";static _editorType=L.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){ne.initialize(t,e),this._defaultDrawingOptions=new ln(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return lt(this,"typesMap",new Map([[D.INK_THICKNESS,"stroke-width"],[D.INK_COLOR,"stroke"],[D.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,n){return new rn(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,a){return on.deserialize(t,e,i,s,n,a)}static async deserialize(t,e,i){let s=null;if(t instanceof js){const{data:{inkLists:e,rect:i,rotation:n,id:a,color:r,opacity:o,borderStyle:{rawWidth:l},popupRef:h},parent:{page:{pageNumber:d}}}=t;s=t={annotationType:L.INK,color:Array.from(r),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:d-1,rect:i.slice(0),rotation:n,id:a,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=hn.getDefaultDrawingOptions({stroke:yt.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":a,"stroke-width":r}}=this,o={annotationType:L.INK,color:ne._colorManager.convert(n),opacity:a,thickness:r,paths:{lines:e,points:i},pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(o.isCopy=!0,o):this.annotationElementId&&!this.#jn(o)?null:(o.id=this.annotationElementId,o)}#jn(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 dn extends on{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}let cn=class{static#Fr={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#Or(t,e,i,s){return s-=e,0===(i-=t)?s>0?0:4:1===i?s+6:2-s}static#Br=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#jr(t,e,i,s,n,a,r){const o=this.#Or(i,s,n,a);for(let n=0;n<8;n++){const a=(-n+o-r+16)%8;if(0!==t[(i+this.#Br[2*a])*e+(s+this.#Br[2*a+1])])return a}return-1}static#Vr(t,e,i,s,n,a,r){const o=this.#Or(i,s,n,a);for(let n=0;n<8;n++){const a=(n+o+r+16)%8;if(0!==t[(i+this.#Br[2*a])*e+(s+this.#Br[2*a+1])])return a}return-1}static#Hr(t,e,i,s){const n=t.length,a=new Int32Array(n);for(let e=0;e<n;e++)a[e]=t[e]<=s?1:0;for(let t=1;t<i-1;t++)a[t*e]=a[t*e+e-1]=0;for(let t=0;t<e;t++)a[t]=a[e*i-1-t]=0;let r,o=1;const l=[];for(let t=1;t<i-1;t++){r=1;for(let i=1;i<e-1;i++){const s=t*e+i,n=a[s];if(0===n)continue;let h=t,d=i;if(1===n&&0===a[s-1])o+=1,d-=1;else{if(!(n>=1&&0===a[s+1])){1!==n&&(r=Math.abs(n));continue}o+=1,d+=1,n>1&&(r=n)}const c=[i,t],u=d===i+1,p={isHole:u,points:c,id:o,parent:0};let g;l.push(p);for(const t of l)if(t.id===r){g=t;break}g?g.isHole?p.parent=u?g.parent:r:p.parent=u?r:g.parent:p.parent=u?r:0;const f=this.#jr(a,e,t,i,h,d,0);if(-1===f){a[s]=-o,1!==a[s]&&(r=Math.abs(a[s]));continue}let m=this.#Br[2*f],b=this.#Br[2*f+1];const v=t+m,w=i+b;h=v,d=w;let y=t,A=i;for(;;){const n=this.#Vr(a,e,y,A,h,d,1);m=this.#Br[2*n],b=this.#Br[2*n+1];const l=y+m,u=A+b;c.push(u,l);const p=y*e+A;if(0===a[p+1]?a[p]=-o:1===a[p]&&(a[p]=o),l===t&&u===i&&y===v&&A===w){1!==a[s]&&(r=Math.abs(a[s]));break}h=y,d=A,y=l,A=u}}}return l}static#Ur(t,e,i,s){if(i-e<=4){for(let n=e;n<i-2;n+=2)s.push(t[n],t[n+1]);return}const n=t[e],a=t[e+1],r=t[i-4]-n,o=t[i-3]-a,l=Math.hypot(r,o),h=r/l,d=o/l,c=h*a-d*n,u=o/r,p=1/l,g=Math.atan(u),f=Math.cos(g),m=Math.sin(g),b=p*(Math.abs(f)+Math.abs(m)),v=p*(1-b+b**2),w=Math.max(Math.atan(Math.abs(m+f)*v),Math.atan(Math.abs(m-f)*v));let y=0,A=e;for(let s=e+2;s<i-2;s+=2){const e=Math.abs(c-h*t[s+1]+d*t[s]);e>y&&(A=s,y=e)}y>(l*w)**2?(this.#Ur(t,e,A+2,s),this.#Ur(t,A,i,s)):s.push(n,a)}static#zr(t){const e=[],i=t.length;return this.#Ur(t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e}static#$r(t,e,i,s,n,a){const r=new Float32Array(a**2),o=-2*s**2,l=a>>1;for(let t=0;t<a;t++){const e=(t-l)**2;for(let i=0;i<a;i++)r[t*a+i]=Math.exp((e+(i-l)**2)/o)}const h=new Float32Array(256),d=-2*n**2;for(let t=0;t<256;t++)h[t]=Math.exp(t**2/d);const c=t.length,u=new Uint8Array(c),p=new Uint32Array(256);for(let s=0;s<i;s++)for(let n=0;n<e;n++){const o=s*e+n,d=t[o];let c=0,g=0;for(let o=0;o<a;o++){const u=s+o-l;if(!(u<0||u>=i))for(let i=0;i<a;i++){const s=n+i-l;if(s<0||s>=e)continue;const p=t[u*e+s],f=r[o*a+i]*h[Math.abs(p-d)];c+=p*f,g+=f}}p[u[o]=Math.round(c/g)]++}return[u,p]}static#Wr(t){const e=new Uint32Array(256);for(const i of t)e[i]++;return e}static#Gr(t){const e=t.length,i=new Uint8ClampedArray(e>>2);let s=-1/0,n=1/0;for(let e=0,a=i.length;e<a;e++){if(0===t[3+(e<<2)]){s=i[e]=255;continue}const a=i[e]=t[e<<2];a>s&&(s=a),a<n&&(n=a)}const a=255/(s-n);for(let t=0;t<e;t++)i[t]=(i[t]-n)*a;return i}static#qr(t){let e,i=-1/0,s=-1/0;const n=t.findIndex((t=>0!==t));let a=n,r=n;for(e=n;e<256;e++){const n=t[e];n>i&&(e-a>s&&(s=e-a,r=e-1),i=n,a=e)}for(e=r-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static#Xr(t){const e=t,{width:i,height:s}=t,{maxDim:n}=this.#Fr;let a=i,r=s;if(i>n||s>n){let o=i,l=s,h=Math.log2(Math.max(i,s)/n);const d=Math.floor(h);h=h===d?d-1:d;for(let i=0;i<h;i++){a=o,r=l,a>n&&(a=Math.ceil(a/2)),r>n&&(r=Math.ceil(r/2));const i=new OffscreenCanvas(a,r);i.getContext("2d").drawImage(t,0,0,o,l,0,0,a,r),o=a,l=r,t!==e&&t.close(),t=i.transferToImageBitmap()}const c=Math.min(n/a,n/r);a=Math.round(a*c),r=Math.round(r*c)}const o=new OffscreenCanvas(a,r).getContext("2d",{willReadFrequently:!0});o.filter="grayscale(1)",o.drawImage(t,0,0,t.width,t.height,0,0,a,r);const l=o.getImageData(0,0,a,r).data;return[this.#Gr(l),a,r]}static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:s},n,a,r,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1});const d=h.font=`${i} ${s} 200px ${e}`,{actualBoundingBoxLeft:c,actualBoundingBoxRight:u,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:f,fontBoundingBoxDescent:m,width:b}=h.measureText(t),v=1.5,w=Math.ceil(Math.max(Math.abs(c)+Math.abs(u)||0,b)*v),y=Math.ceil(Math.max(Math.abs(p)+Math.abs(g)||200,Math.abs(f)+Math.abs(m)||200)*v);l=new OffscreenCanvas(w,y),h=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=d,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,w,y),h.fillStyle="black",h.fillText(t,.5*w/2,1.5*y/2);const A=this.#Gr(h.getImageData(0,0,w,y).data),_=this.#Wr(A),x=this.#qr(_),S=this.#Hr(A,w,y,x);return this.processDrawnLines({lines:{curves:S,width:w,height:y},pageWidth:n,pageHeight:a,rotation:r,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,i,s,n){const[a,r,o]=this.#Xr(t),[l,h]=this.#$r(a,r,o,Math.hypot(r,o)*this.#Fr.sigmaSFactor,this.#Fr.sigmaR,this.#Fr.kernelSize),d=this.#qr(h),c=this.#Hr(l,r,o,d);return this.processDrawnLines({lines:{curves:c,width:r,height:o},pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:a,areContours:r}){s%180!=0&&([e,i]=[i,e]);const{curves:o,width:l,height:h}=t,d=t.thickness??0,c=[],u=Math.min(e/l,i/h),p=u/e,g=u/i,f=[];for(const{points:t}of o){const e=a?this.#zr(t):t;if(!e)continue;f.push(e);const i=e.length,s=new Float32Array(i),n=new Float32Array(3*(2===i?2:i-2));if(c.push({line:n,points:s}),2===i){s[0]=e[0]*p,s[1]=e[1]*g,n.set([NaN,NaN,NaN,NaN,s[0],s[1]],0);continue}let[r,o,l,h]=e;r*=p,o*=g,l*=p,h*=g,s.set([r,o,l,h],0),n.set([NaN,NaN,NaN,NaN,r,o],0);for(let t=4;t<i;t+=2){const i=s[t]=e[t]*p,a=s[t+1]=e[t+1]*g;n.set(Xs.createBezierPoints(r,o,l,h,i,a),3*(t-2)),[r,o,l,h]=[l,h,i,a]}}if(0===c.length)return null;const m=r?new dn:new on;return m.build(c,e,i,1,s,r?0:d,n),{outline:m,newCurves:f,areContours:r,thickness:d,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:s,height:n}){let a,r=1/0,o=-1/0,l=0;for(const e of t){l+=e.length;for(let t=2,i=e.length;t<i;t++){const i=e[t]-e[t-2];r=Math.min(r,i),o=Math.max(o,i)}}a=r>=-128&&o<=127?Int8Array:r>=-32768&&o<=32767?Int16Array:Int32Array;const h=t.length,d=8+3*h,c=new Uint32Array(d);let u=0;c[u++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*a.BYTES_PER_ELEMENT,c[u++]=0,c[u++]=s,c[u++]=n,c[u++]=e?0:1,c[u++]=Math.max(0,Math.floor(i??0)),c[u++]=h,c[u++]=a.BYTES_PER_ELEMENT;for(const e of t)c[u++]=e.length-2,c[u++]=e[0],c[u++]=e[1];const p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(c);const f=a.prototype.constructor;for(const e of t){const t=new f(e.length-2);for(let i=2,s=e.length;i<s;i++)t[i-2]=e[i]-e[i-2];g.write(t)}g.close();const m=await new Response(p.readable).arrayBuffer();return Et(new Uint8Array(m))}static async decompressSignature(t){try{const i=(e=t,Uint8Array.fromBase64?Uint8Array.fromBase64(e):bt(atob(e))),{readable:s,writable:n}=new DecompressionStream("deflate-raw"),a=n.getWriter();await a.ready,a.write(i).then((async()=>{await a.ready,await a.close()})).catch((()=>{}));let r=null,o=0;for await(const t of s)r||=new Uint8Array(new Uint32Array(t.buffer,0,4)[0]),r.set(t,o),o+=t.length;const l=new Uint32Array(r.buffer,0,r.length>>2),h=l[1];if(0!==h)throw new Error(`Invalid version: ${h}`);const d=l[2],c=l[3],u=0===l[4],p=l[5],g=l[6],f=l[7],m=[],b=(8+3*g)*Uint32Array.BYTES_PER_ELEMENT;let v;switch(f){case Int8Array.BYTES_PER_ELEMENT:v=new Int8Array(r.buffer,b);break;case Int16Array.BYTES_PER_ELEMENT:v=new Int16Array(r.buffer,b);break;case Int32Array.BYTES_PER_ELEMENT:v=new Int32Array(r.buffer,b)}o=0;for(let t=0;t<g;t++){const e=l[3*t+8],i=new Float32Array(e+2);m.push(i);for(let e=0;e<2;e++)i[e]=l[3*t+8+e+1];for(let t=0;t<e;t++)i[t+2]=i[t]+v[o++]}return{areContours:u,thickness:p,outlines:m,width:d,height:c}}catch(t){return st(`decompressSignature: ${t}`),null}var e}};class un extends nn{constructor(){super(),super.updateProperties({fill:ne._defaultLineColor,"stroke-width":0})}clone(){const t=new un;return t.updateAll(this),t}}class pn extends ln{constructor(t){super(t),super.updateProperties({stroke:ne._defaultLineColor,"stroke-width":1})}clone(){const t=new pn(this._viewParameters);return t.updateAll(this),t}}class gn extends an{#Kr=!1;#Yr=null;#Qr=null;#Zr=null;static _type="signature";static _editorType=L.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#Qr=t.signatureData||null,this.#Yr=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){ne.initialize(t,e),this._defaultDrawingOptions=new un,this._defaultDrawnSignatureOptions=new pn(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return lt(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#Yr}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),null===this._drawId)if(this.#Qr){const{lines:t,mustSmooth:e,areContours:i,description:s,uuid:n,heightInPage:a}=this.#Qr,{rawDims:{pageWidth:r,pageHeight:o},rotation:l}=this.parent.viewport,h=cn.processDrawnLines({lines:t,pageWidth:r,pageHeight:o,rotation:l,innerMargin:gn._INNER_MARGIN,mustSmooth:e,areContours:i});this.addSignature(h,a,s,n)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);return i&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#Zr=t,this.addEditToolbar()}getUuid(){return this.#Zr}get description(){return this.#Yr}set description(t){this.#Yr=t,super.addEditToolbar().then((e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:i,width:s,height:n}=this.#Qr,a=Math.max(s,n);return{areContours:e,outline:cn.processDrawnLines({lines:{curves:t.map((t=>({points:t}))),thickness:i,width:s,height:n},pageWidth:a,pageHeight:a,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e}).outline}}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.signatureManager&&null!==this.#Yr&&(await t.addEditSignatureButton(this._uiManager.signatureManager,this.#Zr,this.#Yr),t.show()),t):null}addSignature(t,e,i,s){const{x:n,y:a}=this,{outline:r}=this.#Qr=t;let o;this.#Kr=r instanceof dn,this.#Yr=i,this.div.setAttribute("data-l10n-args",JSON.stringify({description:i})),this.#Kr?o=gn.getDefaultDrawingOptions():(o=gn._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":r.thickness})),this._addOutlines({drawOutlines:r,drawingOptions:o});const[l,h]=this.parentDimensions,[,d]=this.pageDimensions;let c=e/d;c=c>=1?.5:c,this.width*=c/this.height,this.width>=1&&(c*=.9/this.width,this.width=.9),this.height=c,this.setDims(l*this.width,h*this.height),this.x=n,this.y=a,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(s),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!s,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return cn.process(t,e,i,s,gn._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:i,pageHeight:s},rotation:n}=this.parent.viewport;return cn.extractContoursFromText(t,e,i,s,n,gn._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return cn.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:gn._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=gn.getDefaultDrawingOptions():(this._drawingOptions=gn._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:i,rect:s}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":n}}=this,a={annotationType:L.SIGNATURE,isSignature:!0,areContours:this.#Kr,color:[0,0,0],thickness:this.#Kr?0:n,pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(a.paths={lines:e,points:i},a.uuid=this.#Zr,a.isCopy=!0):a.lines=e,this.#Yr&&(a.accessibilityData={type:"Figure",alt:this.#Yr}),a}static deserializeDraw(t,e,i,s,n,a){return a.areContours?dn.deserialize(t,e,i,s,n,a):on.deserialize(t,e,i,s,n,a)}static async deserialize(t,e,i){const s=await super.deserialize(t,e,i);return s.#Kr=t.areContours,s.#Yr=t.accessibilityData?.alt||"",s.#Zr=t.uuid,s}}class fn extends ne{#Jr=null;#to=null;#eo=null;#io=null;#so=null;#no="";#ao=null;#ro=!1;#oo=null;#lo=!1;#ho=!1;static _type="stamp";static _editorType=L.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#io=t.bitmapUrl,this.#so=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){ne.initialize(t,e)}static isHandlingMimeForPasting(t){return Gt.includes(t)}static paste(t,e){e.pasteEditor(L.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}}#do(t,e=!1){t?(this.#Jr=t.bitmap,e||(this.#to=t.id,this.#lo=t.isSvg),t.file&&(this.#no=t.file.name),this.#co()):this.remove()}#uo(){if(this.#eo=null,this._uiManager.enableWaiting(!1),this.#ao){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Jr)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Jr){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:a}=t||this.copyCanvas(null,null,!0).imageData,r=await i.guess({name:"altText",request:{data:s,width:n,height:a,channels:s.length/(n*a)}});if(!r)throw new Error("No response from the AI service.");if(r.error)throw new Error("Error from the AI service.");if(r.cancel)return null;if(!r.output)throw new Error("No valid response from the AI service.");const o=r.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#po(){if(this.#to)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#to).then((t=>this.#do(t,!0))).finally((()=>this.#uo()));if(this.#io){const t=this.#io;return this.#io=null,this._uiManager.enableWaiting(!0),void(this.#eo=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#do(t))).finally((()=>this.#uo())))}if(this.#so){const t=this.#so;return this.#so=null,this._uiManager.enableWaiting(!0),void(this.#eo=this._uiManager.imageManager.getFromFile(t).then((t=>this.#do(t))).finally((()=>this.#uo())))}const t=document.createElement("input");t.type="file",t.accept=Gt.join(",");const e=this._uiManager._signal;this.#eo=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.#do(e)}else this.remove();i()}),{signal:e}),t.addEventListener("cancel",(()=>{this.remove(),i()}),{signal:e})})).finally((()=>this.#uo())),t.click()}remove(){this.#to&&(this.#Jr=null,this._uiManager.imageManager.deleteId(this.#to),this.#ao?.remove(),this.#ao=null,this.#oo&&(clearTimeout(this.#oo),this.#oo=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#to&&null===this.#ao&&this.#po(),this.isAttachedToDOM||this.parent.add(this))):this.#to&&this.#po()}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#eo||this.#Jr||this.#io||this.#so||this.#to||this.#ro)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.addAltTextButton(),this.#ro||(this.#Jr?this.#co():this.#po()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:i,bitmap:s}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(this.#to=i,s&&(this.#Jr=s),this.#ro=!1,this.#co())}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==this.#oo&&clearTimeout(this.#oo);this.#oo=setTimeout((()=>{this.#oo=null,this.#go()}),200)}#co(){const{div:t}=this;let{width:e,height:i}=this.#Jr;const[s,n]=this.pageDimensions,a=.75;if(this.width)e=this.width*s,i=this.height*n;else if(e>a*s||i>a*n){const t=Math.min(a*s/e,a*n/i);e*=t,i*=t}const[r,o]=this.parentDimensions;this.setDims(e*r/s,i*o/n),this._uiManager.enableWaiting(!1);const l=this.#ao=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.#go(),this.#ho||(this.parent.addUndoableEditor(this),this.#ho=!0),this._reportTelemetry({action:"inserted_image"}),this.#no&&this.div.setAttribute("aria-description",this.#no)}copyCanvas(t,e,i=!1){t||(t=224);const{width:s,height:n}=this.#Jr,a=new Wt;let r=this.#Jr,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*a.sx),i=h.height=Math.ceil(l*a.sy);this.#lo||(r=this.#fo(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*a.sx,f=p*a.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(r,0,0,r.width,r.height,0,0,t,i)}let d=null;if(i){let e,i;if(a.symmetric&&r.width<t&&r.height<t)e=r.width,i=r.height;else if(r=this.#Jr,s>t||n>t){const a=Math.min(t/s,t/n);e=Math.floor(s*a),i=Math.floor(n*a),this.#lo||(r=this.#fo(e,i))}const o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(r,0,0,r.width,r.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}}#fo(t,e){const{width:i,height:s}=this.#Jr;let n=i,a=s,r=this.#Jr;for(;n>2*t||a>2*e;){const i=n,s=a;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));const o=new OffscreenCanvas(n,a);o.getContext("2d").drawImage(r,0,0,i,s,0,0,n,a),r=o.transferToImageBitmap()}return r}#go(){const[t,e]=this.parentDimensions,{width:i,height:s}=this,n=new Wt,a=Math.ceil(i*t*n.sx),r=Math.ceil(s*e*n.sy),o=this.#ao;if(!o||o.width===a&&o.height===r)return;o.width=a,o.height=r;const l=this.#lo?this.#Jr:this.#fo(a,r),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,a,r)}#mo(t){if(t){if(this.#lo){const t=this._uiManager.imageManager.getSvgUrl(this.#to);if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=this.#Jr);return t.getContext("2d").drawImage(this.#Jr,0,0),t.toDataURL()}if(this.#lo){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*Tt.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*Tt.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(this.#Jr,0,0,this.#Jr.width,this.#Jr.height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(this.#Jr)}static async deserialize(t,e,i){let s=null,n=!1;if(t instanceof $s){const{data:{rect:a,rotation:r,id:o,structParent:l,popupRef:h},container:d,parent:{page:{pageNumber:c}},canvas:u}=t;let p,g;u?(delete t.canvas,({id:p,bitmap:g}=i.imageManager.getFromCanvas(d.id,u)),u.remove()):(n=!0,t._hasNoCanvas=!0);const f=(await e._structTree.getAriaAttributes(`${St}${o}`))?.get("aria-label")||"";s=t={annotationType:L.STAMP,bitmapId:p,bitmap:g,pageIndex:c-1,rect:a.slice(0),rotation:r,id:o,deleted:!1,accessibilityData:{decorative:!1,altText:f},isSvg:!1,structParent:l,popupRef:h}}const a=await super.deserialize(t,e,i),{rect:r,bitmap:o,bitmapUrl:l,bitmapId:h,isSvg:d,accessibilityData:c}=t;n?(i.addMissingCanvas(t.id,a),a.#ro=!0):h&&i.imageManager.isValidId(h)?(a.#to=h,o&&(a.#Jr=o)):a.#io=l,a.#lo=d;const[u,p]=a.pageDimensions;return a.width=(r[2]-r[0])/u,a.height=(r[3]-r[1])/p,a.annotationElementId=t.id||null,c&&(a.altTextData=c),a._initialData=s,a.#ho=!!s,a}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:L.STAMP,bitmapId:this.#to,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#lo,structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=this.#mo(!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(i.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const t=this.#jn(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 a=this.#lo?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#to)){if(this.#lo){const t=e.stamps.get(this.#to);a>t.area&&(t.area=a,t.serialized.bitmap.close(),t.serialized.bitmap=this.#mo(!1))}}else e.stamps.set(this.#to,{area:a,serialized:i}),i.bitmap=this.#mo(!1);return i}#jn(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 mn=class t{#bo;#vo=!1;#wo=null;#yo=null;#Ao=null;#_o=new Map;#xo=!1;#So=!1;#Co=!1;#Eo=null;#Po=null;#To=null;#Mo=null;#m;static _initialized=!1;static#U=new Map([qs,hn,fn,sn,gn].map((t=>[t._editorType,t])));constructor({uiManager:e,pageIndex:i,div:s,structTreeLayer:n,accessibilityManager:a,annotationLayer:r,drawLayer:o,textLayer:l,viewport:h,l10n:d}){const c=[...t.#U.values()];if(!t._initialized){t._initialized=!0;for(const t of c)t.initialize(d,e)}e.registerEditorTypes(c),this.#m=e,this.pageIndex=i,this.div=s,this.#bo=a,this.#wo=r,this.viewport=h,this.#To=l,this.drawLayer=o,this._structTree=n,this.#m.addLayer(this)}get isEmpty(){return 0===this.#_o.size}get isInvisible(){return this.isEmpty&&this.#m.getMode()===L.NONE}updateToolbar(t){this.#m.updateToolbar(t)}updateMode(e=this.#m.getMode()){switch(this.#Io(),e){case L.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case L.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case L.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.#U.values())i.toggle(`${s._type}Editing`,e===s._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#To?.div}setEditingState(t){this.#m.setEditingState(t)}addCommands(t){this.#m.addCommands(t)}cleanUndoStack(t){this.#m.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#wo?.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.#_o.values())e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#m.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(!this.#wo)return void(this.#Co=!1);const e=this.#wo.getEditableAnnotations();for(const i of e){if(i.hide(),this.#m.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.#So=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,i=new Map;for(const t of this.#_o.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.#wo){const t=this.#wo.getEditableAnnotations();for(const s of t){const{id:t}=s.data;if(this.#m.isDeletedAnnotationElement(t))continue;let n=i.get(t);n?(n.resetAnnotationElement(s),n.show(!1),s.show()):(n=e.get(t),n&&(this.#m.addChangedExistingAnnotation(n),n.renderAnnotationElement(s)&&n.show(!1)),s.show())}}this.#Io(),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const e of t.#U.values())s.remove(`${e._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#So=!1}getEditableAnnotation(t){return this.#wo?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#m.getActive()!==t&&this.#m.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#To?.div&&!this.#Mo){this.#Mo=new AbortController;const t=this.#m.combinedSignal(this.#Mo);this.#To.div.addEventListener("pointerdown",this.#ko.bind(this),{signal:t}),this.#To.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#To?.div&&this.#Mo&&(this.#Mo.abort(),this.#Mo=null,this.#To.div.classList.remove("highlighting"))}#ko(t){this.#m.unselectAll();const{target:e}=t;if(e===this.#To.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#To.div.contains(e)){const{isMac:e}=vt.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#m.showAllEditors("highlight",!0,!0),this.#To.div.classList.add("free"),this.toggleDrawing(),sn.startHighlighting(this,"ltr"===this.#m.direction,{target:this.#To.div,x:t.x,y:t.y}),this.#To.div.addEventListener("pointerup",(()=>{this.#To.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#m._signal}),t.preventDefault()}}enableClick(){if(this.#yo)return;this.#yo=new AbortController;const t=this.#m.combinedSignal(this.#yo);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.#yo?.abort(),this.#yo=null}attach(t){this.#_o.set(t.id,t);const{annotationElementId:e}=t;e&&this.#m.isDeletedAnnotationElement(e)&&this.#m.removeDeletedAnnotationElement(t)}detach(t){this.#_o.delete(t.id),this.#bo?.removePointerInTextLayer(t.contentDiv),!this.#So&&t.annotationElementId&&this.#m.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#m.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#m.addDeletedAnnotationElement(t.annotationElementId),ne.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.#m.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.#m.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#Ao&&(t._focusEventsAllowed=!1,this.#Ao=setTimeout((()=>{this.#Ao=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this.#m._signal}),e.focus())}),0)),t._structTreeParentId=this.#bo?.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.#m.getId()}get#Lo(){return t.#U.get(this.#m.getMode())}combinedSignal(t){return this.#m.combinedSignal(t)}#Do(t){const e=this.#Lo;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#Lo?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.#m.updateToolbar(t),await this.#m.updateMode(t);const{offsetX:i,offsetY:s}=this.#Ro(),n=this.getNextId(),a=this.#Do({parent:this,id:n,x:i,y:s,uiManager:this.#m,isCentered:!0,...e});a&&this.add(a)}async deserialize(e){return await(t.#U.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#m))||null}createAndAddNewEditor(t,e,i={}){const s=this.getNextId(),n=this.#Do({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#m,isCentered:e,...i});return n&&this.add(n),n}#Ro(){const{x:t,y:e,width:i,height:s}=this.div.getBoundingClientRect(),n=Math.max(0,t),a=Math.max(0,e),r=(n+Math.min(window.innerWidth,t+i))/2-t,o=(a+Math.min(window.innerHeight,e+s))/2-e,[l,h]=this.viewport.rotation%180==0?[r,o]:[o,r];return{offsetX:l,offsetY:h}}addNewEditor(t={}){this.createAndAddNewEditor(this.#Ro(),!0,t)}setSelected(t){this.#m.setSelected(t)}toggleSelected(t){this.#m.toggleSelected(t)}unselect(t){this.#m.unselect(t)}pointerup(t){const{isMac:e}=vt.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(!this.#xo)return;if(this.#xo=!1,this.#Lo?.isDrawer&&this.#Lo.supportMultipleDrawings)return;if(!this.#vo)return void(this.#vo=!0);const i=this.#m.getMode();i!==L.STAMP&&i!==L.SIGNATURE?this.createAndAddNewEditor(t,!1):this.#m.unselectAll()}pointerdown(t){if(this.#m.getMode()===L.HIGHLIGHT&&this.enableTextSelection(),this.#xo)return void(this.#xo=!1);const{isMac:e}=vt.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#xo=!0,this.#Lo?.isDrawer)return void this.startDrawingSession(t);const i=this.#m.getActive();this.#vo=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#Eo)return void this.#Lo.startDrawing(this,this.#m,!1,t);this.#m.setCurrentDrawingSession(this),this.#Eo=new AbortController;const e=this.#m.combinedSignal(this.#Eo);this.div.addEventListener("blur",(({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#Po=null,this.commitOrRemove())}),{signal:e}),this.#Lo.startDrawing(this,this.#m,!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.#Eo?(this.#m.setCurrentDrawingSession(null),this.#Eo.abort(),this.#Eo=null,this.#Po=null,this.#Lo.endDrawing(t)):null}findNewParent(t,e,i){const s=this.#m.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#Eo&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#Eo&&this.#Lo.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#m.getActive()?.parent===this&&(this.#m.commitOrRemove(),this.#m.setActiveEditor(null)),this.#Ao&&(clearTimeout(this.#Ao),this.#Ao=null);for(const t of this.#_o.values())this.#bo?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#_o.clear(),this.#m.removeLayer(this)}#Io(){for(const t of this.#_o.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,$t(this.div,t);for(const t of this.#m.getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:t}){this.#m.commitOrRemove(),this.#Io();const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,$t(this.div,{rotation:i}),e!==i)for(const t of this.#_o.values())t.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#m.viewParameters.realScale}};globalThis.pdfjsTestingUtils={HighlightOutliner:Qs},globalThis.pdfjsLib={AbortException:ft,AnnotationEditorLayer:mn,AnnotationEditorParamsType:D,AnnotationEditorType:L,AnnotationEditorUIManager:ee,AnnotationLayer:class t{#bo=null;#No=null;#Fo=new Map;#Oo=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:a,structTreeLayer:r}){this.div=t,this.#bo=e,this.#No=i,this.#Oo=r||null,this.page=n,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return this.#Fo.size>0}async#Bo(t,e){const i=t.firstChild||t,s=i.id=`${St}${e}`,n=await(this.#Oo?.getAriaAttributes(s));if(n)for(const[t,e]of n)i.setAttribute(t,e);this.div.append(t),this.#bo?.moveElementInDOM(this.div,t,i,!1)}async render(t){const{annotations:e}=t,i=this.div;$t(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 fs,annotationStorage:t.annotationStorage||new ce,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===H.POPUP;if(e){const e=s.get(t.id);if(!e)continue;n.elements=e}else if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1])continue;n.data=t;const i=ws.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 a=i.render();t.hidden&&(a.style.visibility="hidden"),await this.#Bo(a,t.id),i._isEditable&&(this.#Fo.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}this.#jo()}async addLinkAnnotations(e,i){const s={data:null,layer:this.div,linkService:i,svgFactory:new fs,parent:this};for(const i of e){i.borderStyle||=t._defaultBorderStyle,s.data=i;const e=ws.create(s);if(!e.isRenderable)continue;const n=e.render();await this.#Bo(n,i.id)}}update({viewport:t}){const e=this.div;this.viewport=t,$t(e,{rotation:t.rotation}),this.#jo(),e.hidden=!1}#jo(){if(!this.#No)return;const t=this.div;for(const[e,i]of this.#No){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);const a=this.#Fo.get(e);a&&(a._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,s.id,i),a._hasNoCanvas=!1):a.canvas=i)}this.#No.clear()}getEditableAnnotations(){return Array.from(this.#Fo.values())}getEditableAnnotation(t){return this.#Fo.get(t)}static get _defaultBorderStyle(){return lt(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:U,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}},AnnotationMode:k,AnnotationType:H,build:"4f7761353",ColorPicker:en,createValidAbsoluteUrl:rt,DOMSVGFactory:fs,DrawLayer:class t{#rn=null;#Vo=new Map;#Ho=new Map;static#y=0;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#rn){if(this.#rn!==t){if(this.#Vo.size>0)for(const e of this.#Vo.values())e.remove(),t.append(e);this.#rn=t}}else this.#rn=t}static get _svgFactory(){return lt(this,"_svgFactory",new fs)}static#Uo(t,[e,i,s,n]){const{style:a}=t;a.top=100*i+"%",a.left=100*e+"%",a.width=100*s+"%",a.height=100*n+"%"}#zo(){const e=t._svgFactory.create(1,1,!0);return this.#rn.append(e),e.setAttribute("aria-hidden",!0),e}#$o(e,i){const s=t._svgFactory.createElement("clipPath");e.append(s);const n=`clip_${i}`;s.setAttribute("id",n),s.setAttribute("clipPathUnits","objectBoundingBox");const a=t._svgFactory.createElement("use");return s.append(a),a.setAttribute("href",`#${i}`),a.classList.add("clip"),n}#Wo(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=t.#y++,a=this.#zo(),r=t._svgFactory.createElement("defs");a.append(r);const o=t._svgFactory.createElement("path");r.append(o);const l=`path_p${this.pageIndex}_${n}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),i&&this.#Ho.set(n,o);const h=s?this.#$o(r,l):null,d=t._svgFactory.createElement("use");return a.append(d),d.setAttribute("href",`#${l}`),this.updateProperties(a,e),this.#Vo.set(n,a),{id:n,clipPathId:`url(#${h})`}}drawOutline(e,i){const s=t.#y++,n=this.#zo(),a=t._svgFactory.createElement("defs");n.append(a);const r=t._svgFactory.createElement("path");a.append(r);const o=`path_p${this.pageIndex}_${s}`;let l;if(r.setAttribute("id",o),r.setAttribute("vector-effect","non-scaling-stroke"),i){const e=t._svgFactory.createElement("mask");a.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.#Vo.set(s,n),s}finalizeDraw(t,e){this.#Ho.delete(t),this.updateProperties(t,e)}updateProperties(e,i){if(!i)return;const{root:s,bbox:n,rootClass:a,path:r}=i,o="number"==typeof e?this.#Vo.get(e):e;if(o){if(s&&this.#Wo(o,s),n&&t.#Uo(o,n),a){const{classList:t}=o;for(const[e,i]of Object.entries(a))t.toggle(e,i)}if(r){const t=o.firstChild.firstChild;this.#Wo(t,r)}}}updateParent(t,e){if(e===this)return;const i=this.#Vo.get(t);i&&(e.#rn.append(i),this.#Vo.delete(t),e.#Vo.set(t,i))}remove(t){this.#Ho.delete(t),null!==this.#rn&&(this.#Vo.get(t).remove(),this.#Vo.delete(t))}destroy(){this.#rn=null;for(const t of this.#Vo.values())t.remove();this.#Vo.clear(),this.#Ho.clear()}},FeatureTest:vt,fetchData:Mt,getDocument:Yi,getFilenameFromUrl:function(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)},getPdfFilenameFromUrl:Rt,getUuid:xt,getXfaPageViewport:Vt,GlobalWorkerOptions:Ai,ImageKind:V,InvalidPDFException:ut,isDataScheme:Lt,isPdfFile:Dt,isValidExplicitDest:Ji,MathClamp:Ct,noContextMenu:Ot,normalizeUnicode:function(t){return At||(At=/([\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,_t=new Map([["ſt","ſt"]])),t.replaceAll(At,((t,e,i)=>e?e.normalize("NFKC"):_t.get(i)))},OPS:X,OutputScale:Wt,PasswordResponses:{NEED_PASSWORD:1,INCORRECT_PASSWORD:2},PDFDataRangeTransport:es,PDFDateString:jt,PDFWorker:as,PermissionFlag:{PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},PixelsPerInch:Tt,RenderingCancelledException:kt,ResponseException:pt,setLayerDimensions:$t,shadow:lt,SignatureExtractor:cn,stopEvent:Bt,SupportedImageMimeTypes:Gt,TextLayer:Xi,TouchManager:se,updateUrlHash:ot,Util:yt,VerbosityLevel:q,version:"5.2.133",XfaLayer:ms};
32
+ const y=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),x=[1/0,1/0,-1/0,-1/0],A=new Float32Array(x),C=[.001,0,0,.001,0,0],S=1.35,P="http://www.w3.org/2000/svg",_=1,E=2,T=4,M=16,k=32,D=64,I=128,L=256,N={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},R="pdfjs_internal_id_",F="pdfjs_internal_editor_",O={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},B={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},j=0,U=1,H=2,V=3,z=3,$=4,W={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},G={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},X=1,K=2,q=3,Y=4,Q=5,Z={ERRORS:0,WARNINGS:1,INFOS:5},J={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,rawFillPath:94},tt=0,et=1,it=2,nt=3,st=4;let at=Z.WARNINGS;function rt(t){Number.isInteger(t)&&(at=t)}function ot(){return at}function lt(t){at>=Z.INFOS&&console.info(`Info: ${t}`)}function ht(t){at>=Z.WARNINGS&&console.warn(`Warning: ${t}`)}function dt(t){throw new Error(t)}function ct(t,e){t||dt(e)}function ut(t,e=null,i=null){if(!t)return null;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 n=e?URL.parse(t,e):URL.parse(t);return function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(n)?n:null}function pt(t,e,i=!1){const n=URL.parse(t);return n?(n.hash=e,n.href):i&&ut(t,"http://example.com")?t.split("#",1)[0]+""+(e?`#${e}`:""):""}function gt(t){return t.substring(t.lastIndexOf("/")+1)}function mt(t,e,i,n=!1){return Object.defineProperty(t,e,{value:i,enumerable:!n,configurable:!0,writable:!1}),i}const ft=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class bt extends ft{constructor(t,e){super(t,"PasswordException"),this.code=e}}class vt extends ft{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}let wt=class extends ft{constructor(t){super(t,"InvalidPDFException")}},yt=class extends ft{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}};class xt extends ft{constructor(t){super(t,"FormatError")}}let At=class extends ft{constructor(t){super(t,"AbortException")}};function Ct(t){"string"!=typeof t&&dt("Invalid argument for stringToBytes");const e=t.length,i=new Uint8Array(e);for(let n=0;n<e;++n)i[n]=255&t.charCodeAt(n);return i}let St=class{static get isLittleEndian(){const t=new Uint8Array(4);t[0]=1;return mt(this,"isLittleEndian",1===new Uint32Array(t.buffer,0,1)[0])}static get isOffscreenCanvasSupported(){return mt(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return mt(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get isFloat16ArraySupported(){return mt(this,"isFloat16ArraySupported","undefined"!=typeof Float16Array)}static get isSanitizerSupported(){return mt(this,"isSanitizerSupported","undefined"!=typeof Sanitizer)}static get platform(){const{platform:t,userAgent:e}=navigator;return mt(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCanvasFilterSupported(){let t;return this.isOffscreenCanvasSupported?t=new OffscreenCanvas(1,1).getContext("2d"):"undefined"!=typeof document&&(t=document.createElement("canvas").getContext("2d")),mt(this,"isCanvasFilterSupported",void 0!==t?.filter)}static get isAlphaColorInputSupported(){if("undefined"==typeof document)return mt(this,"isAlphaColorInputSupported",!1);const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",mt(this,"isAlphaColorInputSupported","#ff0000"!==t.value)}},Pt=class{static get hexNums(){return mt(this,"hexNums",Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0")))}static makeHexColor(t,e,i){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[i]}`}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 multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,i=0){const n=t[i],s=t[i+1];t[i]=n*e[0]+s*e[2]+e[4],t[i+1]=n*e[1]+s*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){const n=e[0],s=e[1],a=e[2],r=e[3],o=e[4],l=e[5];for(let e=0;e<6;e+=2){const h=t[i+e],d=t[i+e+1];t[i+e]=h*n+d*a+o,t[i+e+1]=h*s+d*r+l}}static applyInverseTransform(t,e){const i=t[0],n=t[1],s=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-n*e[2]+e[2]*e[5]-e[4]*e[3])/s,t[1]=(-i*e[1]+n*e[0]+e[4]*e[1]-e[5]*e[0])/s}static axialAlignedBoundingBox(t,e,i){const n=e[0],s=e[1],a=e[2],r=e[3],o=e[4],l=e[5],h=t[0],d=t[1],c=t[2],u=t[3];let p=n*h+o,g=p,m=n*c+o,f=m,b=r*d+l,v=b,w=r*u+l,y=w;if(0!==s||0!==a){const t=s*h,e=s*c,i=a*d,n=a*u;p+=i,f+=i,m+=n,g+=n,b+=t,y+=t,w+=e,v+=e}i[0]=Math.min(i[0],p,m,g,f),i[1]=Math.min(i[1],b,w,v,y),i[2]=Math.max(i[2],p,m,g,f),i[3]=Math.max(i[3],b,w,v,y)}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,e){const i=t[0],n=t[1],s=t[2],a=t[3],r=i**2+n**2,o=i*s+n*a,l=s**2+a**2,h=(r+l)/2,d=Math.sqrt(h**2-(r*l-o**2));e[0]=Math.sqrt(h+d||1),e[1]=Math.sqrt(h-d||1)}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])),n=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>n)return null;const s=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return s>a?null:[i,s,n,a]}static pointBoundingBox(t,e,i){i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],t),i[3]=Math.max(i[3],e)}static rectBoundingBox(t,e,i,n,s){s[0]=Math.min(s[0],t,i),s[1]=Math.min(s[1],e,n),s[2]=Math.max(s[2],t,i),s[3]=Math.max(s[3],e,n)}static#t(t,e,i,n,s,a,r,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*n,g=d*(d*(d*s+3*l*a)+3*c*r)+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,n,s,a,r,o,l,h,d,c){if(Math.abs(l)<1e-12)return void(Math.abs(h)>=1e-12&&this.#t(t,e,i,n,s,a,r,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,n,s,a,r,o,(-h+p)/g,c),this.#t(t,e,i,n,s,a,r,o,(-h-p)/g,c)}static bezierBoundingBox(t,e,i,n,s,a,r,o,l){l[0]=Math.min(l[0],t,r),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,r),l[3]=Math.max(l[3],e,o),this.#e(t,i,s,r,e,n,a,o,3*(3*(i-s)-t+r),6*(t-2*i+s),3*(i-t),l),this.#e(t,i,s,r,e,n,a,o,3*(3*(n-a)-e+o),6*(e-2*n+a),3*(n-e),l)}};let _t=null,Et=null;function Tt(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),function(t){"object"==typeof t&&void 0!==t?.length||dt("Invalid argument for bytesToString");const e=t.length,i=8192;if(e<i)return String.fromCharCode.apply(null,t);const n=[];for(let s=0;s<e;s+=i){const a=Math.min(s+i,e),r=t.subarray(s,a);n.push(String.fromCharCode.apply(null,r))}return n.join("")}(t)}const Mt=()=>[],kt=()=>new Map,Dt=()=>Object.create(null);function It(t,e,i){return Math.min(Math.max(t,e),i)}class Lt{constructor({viewBox:t,userUnit:e,scale:i,rotation:n,offsetX:s=0,offsetY:a=0,dontFlip:r=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=n,this.offsetX=s,this.offsetY=a,i*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let h,d,c,u,p,g,m,f;switch((n%=360)<0&&(n+=360),n){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.")}r&&(c=-c,u=-u),0===h?(p=Math.abs(l-t[1])*i+s,g=Math.abs(o-t[0])*i+a,m=(t[3]-t[1])*i,f=(t[2]-t[0])*i):(p=Math.abs(o-t[0])*i+s,g=Math.abs(l-t[1])*i+a,m=(t[2]-t[0])*i,f=(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=m,this.height=f}get rawDims(){const t=this.viewBox;return mt(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:n=this.offsetY,dontFlip:s=!1}={}){return new Lt({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:n,dontFlip:s})}convertToViewportPoint(t,e){const i=[t,e];return Pt.applyTransform(i,this.transform),i}convertToViewportRectangle(t){const e=[t[0],t[1]];Pt.applyTransform(e,this.transform);const i=[t[2],t[3]];return Pt.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){const i=[t,e];return Pt.applyInverseTransform(i,this.transform),i}}class Nt{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};return function t(i){if(!i)return;let n=null;const s=i.name;if("#text"===s)n=i.value;else{if(!Nt.shouldBuildText(s))return;i?.attributes?.textContent?n=i.attributes.textContent:i.value&&(n=i.value)}if(null!==n&&e.push({str:n}),i.children)for(const e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}let Rt=class{static setupStorage(t,e,i,n,s){const a=n.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==a.value&&(t.textContent=a.value),"print"===s)break;t.addEventListener("input",t=>{n.setValue(e,{value:t.target.value})});break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(a.value===i.attributes.xfaOn?t.setAttribute("checked",!0):a.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===s)break;t.addEventListener("change",t=>{n.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})})}else{if(null!==a.value&&t.setAttribute("value",a.value),"print"===s)break;t.addEventListener("input",t=>{n.setValue(e,{value:t.target.value})})}break;case"select":if(null!==a.value){t.setAttribute("value",a.value);for(const t of i.children)t.attributes.value===a.value?t.attributes.selected=!0:Object.hasOwn(t.attributes,"selected")&&delete t.attributes.selected}t.addEventListener("input",t=>{const i=t.target.options,s=-1===i.selectedIndex?"":i[i.selectedIndex].value;n.setValue(e,{value:s})})}}static setAttributes({html:t,element:e,storage:i=null,intent:n,linkService:s}){const{attributes:a}=e,r=t instanceof HTMLAnchorElement;"radio"===a.type&&(a.name=`${a.name}-${n}`);for(const[e,i]of Object.entries(a))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:(!r||"href"!==e&&"newWindow"!==e)&&t.setAttribute(e,i)}r&&s.addLinkAttributes(t,a.href,a.newWindow),i&&a.dataId&&this.setupStorage(t,a.dataId,e,i)}static render(t){const e=t.annotationStorage,i=t.linkService,n=t.xfaHtml,s=t.intent||"display",a=document.createElement(n.name);n.attributes&&this.setAttributes({html:a,element:n,intent:s,linkService:i});const r="richText"!==s,o=t.div;if(o.append(a),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}r&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(0===n.children.length){if(n.value){const t=document.createTextNode(n.value);a.append(t),r&&Nt.shouldBuildText(n.name)&&l.push(t)}return{textDivs:l}}const h=[[n,-1,a]];for(;h.length>0;){const[t,n,a]=h.at(-1);if(n+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),a.append(t);continue}const c=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,d):document.createElement(d);if(a.append(c),o.attributes&&this.setAttributes({html:c,element:o,storage:e,intent:s,linkService:i}),o.children?.length>0)h.push([o,-1,c]);else if(o.value){const t=document.createTextNode(o.value);r&&Nt.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}static getPageViewport(t,{scale:e=1,rotation:i=0}){const{width:n,height:s}=t.attributes.style;return new Lt({viewBox:[0,0,parseInt(n,10),parseInt(s,10)],userUnit:1,scale:e,rotation:i})}},Ft=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function Ot(t,e="text"){if(zt(t,document.baseURI)){const i=await fetch(t);if(!i.ok)throw new Error(i.statusText);switch(e){case"blob":return i.blob();case"bytes":return i.bytes();case"json":return i.json()}return i.text()}return new Promise((i,n)=>{const s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="bytes"===e?"arraybuffer":e,s.onreadystatechange=()=>{if(s.readyState===XMLHttpRequest.DONE)if(200!==s.status&&0!==s.status)n(new Error(s.statusText));else{switch(e){case"bytes":return void i(new Uint8Array(s.response));case"blob":case"json":return void i(s.response)}i(s.responseText)}},s.send(null)})}let Bt=class extends ft{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};function jt(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function Ut(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function Ht(t,e="document.pdf"){if("string"!=typeof t)return e;if(jt(t))return ht('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const i=(t=>{try{return new URL(t)}catch{}try{return new URL(decodeURIComponent(t))}catch{}try{return new URL(t,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(t),"https://foo.bar")}catch{}return null})(t);if(!i)return e;const n=t=>{try{let e=decodeURIComponent(t);return e.includes("/")&&(e=gt(e),4===e.length&&s.test(e))?t:e}catch{return t}},s=/\.pdf$/i,a=gt(i.pathname);if(s.test(a))return n(a);if(i.searchParams.size>0){const t=t=>[...t].findLast(t=>s.test(t)),e=t(i.searchParams.values())??t(i.searchParams.keys());if(e)return n(e)}if(i.hash){const t=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(i.hash);if(t)return n(t[0])}return e}class Vt{#i=new Map;times=[];time(t){this.#i.has(t)&&ht(`Timer is already running for ${t}`),this.#i.set(t,Date.now())}timeEnd(t){this.#i.has(t)||ht(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.#i.get(t),end:Date.now()}),this.#i.delete(t)}toString(){const t=Math.max(...this.times.map(t=>t.name.length));return this.times.map(e=>`${e.name.padEnd(t)} ${e.end-e.start}ms\n`).join("")}}function zt(t,e){const i=e?URL.parse(t,e):URL.parse(t);return/https?:/.test(i?.protocol??"")}function $t(t){t.preventDefault()}function Wt(t){t.preventDefault(),t.stopPropagation()}let Gt=class{static#n;static toDateObject(t){if(t instanceof Date)return t;if(!t||"string"!=typeof t)return null;this.#n||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#n.exec(t);if(!e)return null;const i=parseInt(e[1],10);let n=parseInt(e[2],10);n=n>=1&&n<=12?n-1:0;let s=parseInt(e[3],10);s=s>=1&&s<=31?s:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let r=parseInt(e[5],10);r=r>=0&&r<=59?r: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?(a+=h,r+=d):"+"===l&&(a-=h,r-=d),new Date(Date.UTC(i,n,s,a,r,o))}};function Xt(t){if(t.startsWith("#")){const e=t.slice(1);return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16),e.length>=8?parseInt(e.slice(6,8),16)/255:1]}if(t.startsWith("rgb(")){const[e,i,n]=t.slice(4,-1).split(",").map(t=>parseInt(t,10));return[e,i,n,1]}if(t.startsWith("rgba(")){const e=t.slice(5,-1).split(",");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10),parseFloat(e[3])]}const e=t.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return e?[Math.round(255*parseFloat(e[1])),Math.round(255*parseFloat(e[2])),Math.round(255*parseFloat(e[3])),void 0!==e[4]&&"none"!==e[4]?parseFloat(e[4]):1]:null}function Kt(t){const e=Xt(t);return e?e.slice(0,3):(ht(`Not a valid color format: "${t}"`),[0,0,0])}function qt(t){const{a:e,b:i,c:n,d:s,e:a,f:r}=t.getTransform();return[e,i,n,s,a,r]}function Yt(t){const{a:e,b:i,c:n,d:s,e:a,f:r}=t.getTransform().invertSelf();return[e,i,n,s,a,r]}function Qt(t,e,i=!1,n=!0){if(e instanceof Lt){const{pageWidth:n,pageHeight:s}=e.rawDims,{style:a}=t,r=`round(down, var(--total-scale-factor) * ${n}px, var(--scale-round-x))`,o=`round(down, var(--total-scale-factor) * ${s}px, var(--scale-round-y))`;i&&e.rotation%180!=0?(a.width=o,a.height=r):(a.width=r,a.height=o)}n&&t.setAttribute("data-main-rotation",e.rotation)}let Zt=class t{constructor(){const{pixelRatio:e}=t;this.sx=e,this.sy=e}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(e,i,n,s,a=-1){let r=1/0,o=1/0,l=1/0;(n=t.capPixels(n,a))>0&&(r=Math.sqrt(n/(e*i))),-1!==s&&(o=s/e,l=s/i);const h=Math.min(r,o,l);return(this.sx>h||this.sy>h)&&(this.sx=h,this.sy=h,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,i):i}return t}};const Jt=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class te{static get isDarkMode(){return mt(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}function ee(t,e){const i=t[0]/255,n=t[1]/255,s=t[2]/255,a=Math.max(i,n,s),r=Math.min(i,n,s),o=(a+r)/2;if(a===r)e[0]=e[1]=0;else{const t=a-r;switch(e[1]=o<.5?t/(a+r):t/(2-a-r),a){case i:e[0]=60*((n-s)/t+(n<s?6:0));break;case n:e[0]=60*((s-i)/t+2);break;case s:e[0]=60*((i-n)/t+4)}}e[2]=o}function ie(t,e){const i=t[0],n=t[1],s=t[2],a=(1-Math.abs(2*s-1))*n,r=a*(1-Math.abs(i/60%2-1)),o=s-a/2;switch(Math.floor(i/60)){case 0:e[0]=a+o,e[1]=r+o,e[2]=o;break;case 1:e[0]=r+o,e[1]=a+o,e[2]=o;break;case 2:e[0]=o,e[1]=a+o,e[2]=r+o;break;case 3:e[0]=o,e[1]=r+o,e[2]=a+o;break;case 4:e[0]=r+o,e[1]=o,e[2]=a+o;break;case 5:case 6:e[0]=a+o,e[1]=o,e[2]=r+o}}function ne(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function se(t,e,i){ie(t,i),i.map(ne);const n=.2126*i[0]+.7152*i[1]+.0722*i[2];ie(e,i),i.map(ne);const s=.2126*i[0]+.7152*i[1]+.0722*i[2];return n>s?(n+.05)/(s+.05):(s+.05)/(n+.05)}const ae=new Map;function re({html:t,dir:e,className:i},n){const s=document.createDocumentFragment();if("string"==typeof t){const i=document.createElement("p");i.dir=e||"auto";const n=t.split(/\r\n?|\n/);for(let t=0,e=n.length;t<e;++t){const s=n[t];i.append(document.createTextNode(s)),t<e-1&&i.append(document.createElement("br"))}s.append(i)}else Rt.render({xfaHtml:t,div:s,intent:"richText"});s.firstElementChild.classList.add("richText",i),n.append(s)}function oe(t){const e=new Path2D;if(!t)return e;for(let i=0,n=t.length;i<n;)switch(t[i++]){case tt:e.moveTo(t[i++],t[i++]);break;case et:e.lineTo(t[i++],t[i++]);break;case it:e.bezierCurveTo(t[i++],t[i++],t[i++],t[i++],t[i++],t[i++]);break;case nt:e.quadraticCurveTo(t[i++],t[i++],t[i++],t[i++]);break;case st:e.closePath();break;default:ht(`Unrecognized drawing path operator: ${t[i-1]}`)}return e}class le{#s=null;#a=null;#r;#o=null;#l=null;#h=null;#d=null;#c=null;static#u=null;constructor(t){this.#r=t,le.#u||=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",signature:"pdfjs-editor-remove-signature-button"})}render(){const t=this.#s=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#r._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",$t,{signal:e}),t.addEventListener("pointerdown",le.#p,{signal:e}));const i=this.#o=document.createElement("div");i.className="buttons",t.append(i);const n=this.#r.toolbarPosition;if(n){const{style:e}=t,i="ltr"===this.#r._uiManager.direction?1-n[0]:n[0];e.insetInlineEnd=100*i+"%",e.top=`calc(${100*n[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#s}static#p(t){t.stopPropagation()}#g(t){this.#r._focusEventsAllowed=!1,Wt(t)}#m(t){this.#r._focusEventsAllowed=!0,Wt(t)}#f(t){const e=this.#r._uiManager._signal;return e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("focusin",this.#g.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#m.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",$t,{signal:e}),!0)}hide(){this.#s.classList.add("hidden"),this.#a?.hideDropdown()}show(){this.#s.classList.remove("hidden"),this.#l?.shown(),this.#h?.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=this.#r,i=document.createElement("button");i.classList.add("basic","deleteButton"),i.tabIndex=0,i.setAttribute("data-l10n-id",le.#u[t]),this.#f(i)&&i.addEventListener("click",t=>{e.delete()},{signal:e._signal}),this.#o.append(i)}get#b(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#f(e),this.#o.append(e,this.#b),this.#l=t}addComment(t,e=null){if(this.#h)return;const i=t.renderForToolbar();if(!i)return;this.#f(i);const n=this.#d=this.#b;e?(this.#o.insertBefore(i,e),this.#o.insertBefore(n,e)):this.#o.append(i,n),this.#h=t,t.toolbar=this}addColorPicker(t){if(this.#a)return;this.#a=t;const e=t.renderButton();this.#f(e),this.#o.append(e,this.#b)}async addEditSignatureButton(t){const e=this.#c=await t.renderEditButton(this.#r);this.#f(e),this.#o.append(e,this.#b)}removeButton(t){if("comment"===t)this.#h?.removeToolbarCommentButton(),this.#h=null,this.#d?.remove(),this.#d=null}async addButton(t,e){switch(t){case"colorPicker":e&&this.addColorPicker(e);break;case"altText":e&&await this.addAltText(e);break;case"editSignature":e&&await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":e&&this.addComment(e)}}async addButtonBefore(t,e,i){if(!e&&"comment"===t)return;const n=this.#o.querySelector(i);n&&"comment"===t&&this.addComment(e,n)}updateEditSignatureButton(t){this.#c&&(this.#c.title=t)}remove(){this.#s.remove(),this.#a?.destroy(),this.#a=null}}class he{#o=null;#s=null;#v;constructor(t){this.#v=t}#w(){const t=this.#s=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");const e=this.#v._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",$t,{signal:e});const i=this.#o=document.createElement("div");return i.className="buttons",t.append(i),this.#v.hasCommentManager()&&this.#y("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#v.commentSelection("floating_button")}),this.#y("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#v.highlightSelection("floating_button")}),t}#x(t,e){let i=0,n=0;for(const s of t){const t=s.y+s.height;if(t<i)continue;const a=s.x+(e?s.width:0);t>i?(n=a,i=t):e?a>n&&(n=a):a<n&&(n=a)}return[e?1-n:n,i]}show(t,e,i){const[n,s]=this.#x(e,i),{style:a}=this.#s||=this.#w();t.append(this.#s),a.insetInlineEnd=100*n+"%",a.top=`calc(${100*s}% + var(--editor-toolbar-vert-offset))`}hide(){this.#s.remove()}#y(t,e,i,n){const s=document.createElement("button");s.classList.add("basic",t),s.tabIndex=0,s.setAttribute("data-l10n-id",e);const a=document.createElement("span");s.append(a),a.className="visuallyHidden",a.setAttribute("data-l10n-id",i);const r=this.#v._signal;r instanceof AbortSignal&&!r.aborted&&(s.addEventListener("contextmenu",$t,{signal:r}),s.addEventListener("click",n,{signal:r})),this.#o.append(s)}}const de=Object.freeze({internal:"9556e50a-f4f8-4f57-9831-f9ddff0176eb"});function ce(t,e,i){for(const n of i)e.addEventListener(n,t[n].bind(t))}class ue{static#A=NaN;static#C=null;static#S=NaN;static#P=null;static initializeAndAddPointerId(t){(ue.#C||=new Set).add(t)}static setPointer(t,e){ue.#A||=e,ue.#P??=t}static setTimeStamp(t){ue.#S=t}static isSamePointerId(t){return ue.#A===t}static isSamePointerIdOrRemove(t){return ue.#A===t||(ue.#C?.delete(t),!1)}static isSamePointerType(t){return ue.#P===t}static isInitializedAndDifferentPointerType(t){return null!==ue.#P&&!ue.isSamePointerType(t)}static isSameTimeStamp(t){return ue.#S===t}static isUsingMultiplePointers(){return ue.#C?.size>=1}static clearPointerType(){ue.#P=null}static clearPointerIds(){ue.#A=NaN,ue.#C=null}static clearTimeStamp(){ue.#S=NaN}}class pe{#_=0;get id(){return`${F}${this.#_++}`}}class ge{#E=Tt();#_=0;#T=null;static get _isSVGFittingCanvas(){const t=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${P}"><rect width="1" height="1" style="fill:red;"/></svg>`,e=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;return mt(this,"_isSVGFittingCanvas",i.decode().then(()=>(e.drawImage(i,0,0,1,1,0,0,1,3),0===new Uint32Array(e.getImageData(0,0,1,1).data.buffer)[0])))}async#M(t,e){this.#T||=new Map;let i=this.#T.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.#E}_${this.#_++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await Ot(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=ge._isSVGFittingCanvas,n=new FileReader,s=new Image,a=new Promise((t,a)=>{s.onload=()=>{i.bitmap=s,i.isSvg=!0,t()},n.onload=async()=>{const t=i.svgUrl=n.result;s.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},s.onerror=n.onerror=a});n.readAsDataURL(t),await a}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){ht(t),i=null}return this.#T.set(t,i),i&&this.#T.set(i.id,i),i}async getFromFile(t){const{lastModified:e,name:i,size:n,type:s}=t;return this.#M(`${e}_${i}_${n}_${s}`,t)}async getFromUrl(t){return this.#M(t,t)}async getFromBlob(t,e){const i=await e;return this.#M(t,i)}async getFromId(t){this.#T||=new Map;const e=this.#T.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.#T||=new Map;let i=this.#T.get(t);if(i?.bitmap)return i.refCounter+=1,i;const n=new OffscreenCanvas(e.width,e.height);return n.getContext("2d").drawImage(e,0,0),i={bitmap:n.transferToImageBitmap(),id:`image_${this.#E}_${this.#_++}`,refCounter:1,isSvg:!1},this.#T.set(t,i),this.#T.set(i.id,i),i}getSvgUrl(t){const e=this.#T.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#T||=new Map;const e=this.#T.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.#E}_`)}}class me{#k=[];#D=!1;#I;#L=-1;constructor(t=128){this.#I=t}add({cmd:t,undo:e,post:i,mustExec:n,type:s=NaN,overwriteIfSameType:a=!1,keepUndo:r=!1}){if(n&&t(),this.#D)return;const o={cmd:t,undo:e,post:i,type:s};if(-1===this.#L)return this.#k.length>0&&(this.#k.length=0),this.#L=0,void this.#k.push(o);if(a&&this.#k[this.#L].type===s)return r&&(o.undo=this.#k[this.#L].undo),void(this.#k[this.#L]=o);const l=this.#L+1;l===this.#I?this.#k.splice(0,1):(this.#L=l,l<this.#k.length&&this.#k.splice(l)),this.#k.push(o)}undo(){if(-1===this.#L)return;this.#D=!0;const{undo:t,post:e}=this.#k[this.#L];t(),e?.(),this.#D=!1,this.#L-=1}redo(){if(this.#L<this.#k.length-1){this.#L+=1,this.#D=!0;const{cmd:t,post:e}=this.#k[this.#L];t(),e?.(),this.#D=!1}}hasSomethingToUndo(){return-1!==this.#L}hasSomethingToRedo(){return this.#L<this.#k.length-1}cleanType(t){if(-1!==this.#L){for(let e=this.#L;e>=0;e--)if(this.#k[e].type!==t)return this.#k.splice(e+1,this.#L-e),void(this.#L=e);this.#k.length=0,this.#L=-1}}destroy(){this.#k=null}}class fe{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=St.platform;for(const[i,n,s={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:n,options:s}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:n,options:s}),this.allKeys.add(t.split("+").at(-1)))}}#N(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.#N(e));if(!i)return;const{callback:n,options:{bubbles:s=!1,args:a=[],checker:r=null}}=i;r&&!r(t,e)||(n.bind(t,...a,e)(),s||Wt(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",e.style.colorScheme="only light",document.body.append(e);for(const i of t.keys()){e.style.color=i;const n=window.getComputedStyle(e).color;t.set(i,Kt(n))}e.remove()}(t),mt(this,"_colors",t)}convert(t){const e=Kt(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?Pt.makeHexColor(...e):t}}let ve=class t{#R=new AbortController;#F=null;#O=null;#B=new Map;#j=new Map;#U=null;#H=null;#V=null;#z=null;#$=new me;#W=null;#G=null;#X=null;#K=0;#q=new Set;#Y=null;#Q=null;#Z=new Set;_editorUndoBar=null;#J=!1;#tt=!1;#et=!1;#it=null;#nt=null;#st=null;#at=null;#rt=!1;#ot=null;#lt=new pe;#ht=!1;#dt=!1;#ct=!1;#ut=null;#pt=null;#gt=null;#mt=null;#ft=null;#bt=O.NONE;#vt=new Set;#wt=null;#yt=null;#xt=null;#At=null;#Ct=null;#St={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#Pt=[0,0];#_t=null;#Et=null;#Tt=null;#Mt=null;#kt=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const e=t.prototype,i=t=>t.#Et.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),n=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},s=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return mt(this,"_keyboardManager",new fe([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:n}],[["ctrl+z","mac+meta+z"],e.undo,{checker:n}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:n}],[["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:n}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#Et.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#Et.contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-s,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-a,0],checker:i}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[s,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[a,0],checker:i}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-s],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-a],checker:i}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,s],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,a],checker:i}]]))}constructor(t,e,i,n,s,a,r,o,l,h,d,c,u,p,g,m){const f=this._signal=this.#R.signal;this.#Et=t,this.#Tt=e,this.#Mt=i,this.#H=n,this.#W=s,this.#yt=a,this.#Ct=o,this._eventBus=r;const b={signal:f,...de};r.on("editingaction",this.onEditingAction.bind(this),b),r.on("pagechanging",this.onPageChanging.bind(this),b),r.on("scalechanging",this.onScaleChanging.bind(this),b),r.on("rotationchanging",this.onRotationChanging.bind(this),b),r.on("setpreference",this.onSetPreference.bind(this),b),r.on("switchannotationeditorparams",t=>this.updateParams(t.type,t.value),b),window.addEventListener("pointerdown",()=>{this.#dt=!0},{capture:!0,signal:f}),window.addEventListener("pointerup",()=>{this.#dt=!1},{capture:!0,signal:f}),window.addEventListener("beforeunload",this.#Dt.bind(this),{capture:!0,signal:f}),this.#It(),this.#Lt(),this.#Nt(),this.#V=o.annotationStorage,this.#it=o.filterFactory,this.#xt=l,this.#at=h||null,this.#J=d,this.#tt=c,this.#et=u,this.#ft=p||null,this.viewParameters={realScale:Ft.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=!1!==m,s?.setSidebarUiManager(this)}destroy(){this.#kt?.resolve(),this.#kt=null,this.#R?.abort(),this.#R=null,this._signal=null;for(const t of this.#j.values())t.destroy();this.#j.clear(),this.#B.clear(),this.#Z.clear(),this.#mt?.clear(),this.#F=null,this.#vt.clear(),this.#$.destroy(),this.#H?.destroy(),this.#W?.destroy(),this.#yt?.destroy(),this.#ot?.hide(),this.#ot=null,this.#gt?.destroy(),this.#gt=null,this.#O=null,this.#nt&&(clearTimeout(this.#nt),this.#nt=null),this.#_t&&(clearTimeout(this.#_t),this.#_t=null),this._editorUndoBar?.destroy(),this.#Ct=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#ft}get useNewAltTextFlow(){return this.#tt}get useNewAltTextWhenAddingImage(){return this.#et}get hcmFilter(){return mt(this,"hcmFilter",this.#xt?this.#it.addHCMFilter(this.#xt.foreground,this.#xt.background):"none")}get direction(){return mt(this,"direction",getComputedStyle(this.#Et).direction)}get _highlightColors(){return mt(this,"_highlightColors",this.#at?new Map(this.#at.split(",").map(t=>((t=t.split("=").map(t=>t.trim()))[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return mt(this,"highlightColors",null);const e=new Map,i=!!this.#xt;for(const[n,s]of t){const t=n.endsWith("_HCM");i&&t?e.set(n.replace("_HCM",""),s):i||t||e.set(n,s)}return mt(this,"highlightColors",e)}get highlightColorNames(){return mt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#X=t}setMainHighlightColorPicker(t){this.#gt=t}editAltText(t,e=!1){this.#H?.editAltText(this,t,e)}hasCommentManager(){return!!this.#W}editComment(t,e,i,n){this.#W?.showDialog(this,t,e,i,n)}selectComment(t,e){const i=this.#j.get(t),n=i?.getEditorByUID(e);n?.toggleComment(!0,!0)}updateComment(t){this.#W?.updateComment(t.getData())}updatePopupColor(t){this.#W?.updatePopupColor(t)}removeComment(t){this.#W?.removeComments([t.uid])}deleteComment(t,e){const i=()=>{t.comment=e};this.addCommands({cmd:()=>{this._editorUndoBar?.show(i,"comment"),this.toggleComment(null),t.comment=null},undo:i,mustExec:!0})}toggleComment(t,e,i=void 0){this.#W?.toggleCommentPopup(t,e,i)}makeCommentColor(t,e){return t&&this.#W?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#W?.dialogElement||null}async waitForEditorsRendered(t){if(this.#j.has(t-1))return;const{resolve:e,promise:i}=Promise.withResolvers(),n=i=>{i.pageNumber===t&&(this._eventBus.off("editorsrendered",n),e())};this._eventBus.on("editorsrendered",n),await i}getSignature(t){this.#yt?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#yt}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.#et=e}onPageChanging({pageNumber:t}){this.#K=t-1}deletePage(t){for(const e of this.getEditors(t))e.remove();this.#j.delete(t),this.#K===t&&(this.#K=0)}focusMainContainer(){this.#Et.focus()}findParent(t,e){for(const i of this.#j.values()){const{x:n,y:s,width:a,height:r}=i.div.getBoundingClientRect();if(t>=n&&t<=n+a&&e>=s&&e<=s+r)return i}return null}disableUserSelect(t=!1){this.#Tt.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*Ft.PDF_TO_CSS_UNITS;for(const t of this.#Z)t.onScaleChanging();this.#X?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#Rt({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#Ft(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const e of this.#j.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t="",e=!1){const i=document.getSelection();if(!i||i.isCollapsed)return;const{anchorNode:n,anchorOffset:s,focusNode:a,focusOffset:r}=i,o=i.toString(),l=this.#Rt(i).closest(".textLayer"),h=this.getSelectionBoxes(l);if(!h)return;i.empty();const d=this.#Ft(l),c=this.#bt===O.NONE,u=()=>{const i=d?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:n,anchorOffset:s,focusNode:a,focusOffset:r,text:o});c&&this.showAllEditors("highlight",!0,!0),e&&i?.editComment()};c?this.switchToMode(O.HIGHLIGHT,u):u()}commentSelection(t=""){this.highlightSelection(t,!0)}#Dt(t){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#Ot(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#Rt(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#ot||=new he(this),this.#ot.show(e,i,"ltr"===this.direction))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#V)return null;const e=`${F}${t}`,i=this.#V.getRawValue(e);return i&&this.#V.remove(e),i}addToAnnotationStorage(t){t.isEmpty()||!this.#V||this.#V.has(t.id)||this.#V.setValue(t.id,t)}a11yAlert(t,e=null){const i=this.#Mt;i&&(i.setAttribute("data-l10n-id",t),e?i.setAttribute("data-l10n-args",JSON.stringify(e)):i.removeAttribute("data-l10n-args"))}#Bt(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#wt&&(this.#ot?.hide(),this.#wt=null,this.#jt({hasSelectedText:!1})));const{anchorNode:e}=t;if(e===this.#wt)return;const i=this.#Rt(t).closest(".textLayer");if(i){if(this.#ot?.hide(),this.#wt=e,this.#jt({hasSelectedText:!0}),(this.#bt===O.HIGHLIGHT||this.#bt===O.NONE)&&(this.#bt===O.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#rt=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#bt===O.HIGHLIGHT?this.#Ft(i):null;if(t?.toggleDrawing(),this.#dt){const e=new AbortController,i=this.combinedSignal(e),n=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#Ut("main_toolbar"))};window.addEventListener("pointerup",n,{signal:i}),window.addEventListener("blur",n,{signal:i})}else t?.toggleDrawing(!0),this.#Ut("main_toolbar")}}else this.#wt&&(this.#ot?.hide(),this.#wt=null,this.#jt({hasSelectedText:!1}))}#Ut(t=""){this.#bt===O.HIGHLIGHT?this.highlightSelection(t):this.#J&&this.#Ot()}#It(){document.addEventListener("selectionchange",this.#Bt.bind(this),{signal:this._signal})}#Ht(){if(this.#st)return;this.#st=new AbortController;const t=this.combinedSignal(this.#st);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#Vt(){this.#st?.abort(),this.#st=null}blur(){if(this.isShiftKeyDown=!1,this.#rt&&(this.#rt=!1,this.#Ut("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#vt)if(e.div.contains(t)){this.#pt=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#pt)return;const[t,e]=this.#pt;this.#pt=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#Nt(){if(this.#ut)return;this.#ut=new AbortController;const t=this.combinedSignal(this.#ut);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#zt(){this.#ut?.abort(),this.#ut=null}#$t(){if(this.#G)return;this.#G=new AbortController;const t=this.combinedSignal(this.#G);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})}#Wt(){this.#G?.abort(),this.#G=null}#Lt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#Nt(),this.setEditingState(!0)}removeEditListeners(){this.#zt(),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of this.#Q)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.#Q)if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#F?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const t of this.#vt){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.#Q)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 ht(`paste: "${t.message}".`)}if(!Array.isArray(i))return;this.unselectAll();const n=this.currentLayer;try{const t=[];for(const e of i){const i=await n.deserialize(e);if(!i)return;t.push(i)}const e=()=>{for(const e of t)this.#Gt(e);this.#Xt(t)},s=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:s,mustExec:!0})}catch(t){ht(`paste: "${t.message}".`)}}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0),this.#bt===O.NONE||this.isEditorHandlingKeyboard||t._keyboardManager.exec(this,e)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#rt&&(this.#rt=!1,this.#Ut("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu")}}updatePageIndex(t,e){for(const i of this.getEditors(t))i.pageIndex=e;const i=this.#U.get(t);i&&(i.pageIndex=e,this.#j.set(e,i),this.#ht?i.enable():i.disable())}startUpdatePages(){this.#U=new Map(this.#j),this.#j.clear()}endUpdatePages(){this.#U=null}clonePage(t,e){for(const i of this.getEditors(t)){const t=i.serialize(i.mode!==O.HIGHLIGHT);t&&(t.pageIndex=e,t.id=this.getId(),t.isClone=!0,delete t.popupRef,this.#V.setValue(t.id,t))}}findClonesForPage(t){const e=[],{pageIndex:i}=t;for(const[n,s]of this.#V)s.pageIndex===i&&s.isClone&&(this.#V.remove(n),e.push(t.deserialize(s).then(e=>{e&&(e.isClone=!0,t.addOrRebuild(e))})));return Promise.all(e)}#jt(t){Object.entries(t).some(([t,e])=>this.#St[t]!==e)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(this.#St,t)}),this.#bt===O.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#Kt([[B.HIGHLIGHT_FREE,!0]]))}#Kt(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#Ht(),this.#$t(),this.#jt({isEditing:this.#bt!==O.NONE,isEmpty:this.#qt(),hasSomethingToUndo:this.#$.hasSomethingToUndo(),hasSomethingToRedo:this.#$.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Vt(),this.#Wt(),this.#jt({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#Q){this.#Q=t;for(const t of this.#Q)this.#Kt(t.defaultPropertiesToUpdate)}}getId(){return this.#lt.id}get currentLayer(){return this.#j.get(this.#K)}getLayer(t){return this.#j.get(t)}get currentPageIndex(){return this.#K}addLayer(t){this.#j.set(t.pageIndex,t),this.#ht?t.enable():t.disable()}removeLayer(t){this.#j.delete(t.pageIndex)}async updateMode(t,e=null,i=!1,n=!1,s=!1,a=!1){if(this.#bt!==t&&(!this.#kt||(await this.#kt.promise,this.#kt))){if(this.#kt=Promise.withResolvers(),this.#X?.commitOrRemove(),this.#bt===O.POPUP&&this.#W?.hideSidebar(),this.#W?.destroyPopup(),this.#bt=t,t===O.NONE){this.setEditingState(!1),this.#Yt();for(const t of this.#B.values())t.hideStandaloneCommentButton();return this._editorUndoBar?.hide(),this.toggleComment(null),void this.#kt.resolve()}for(const t of this.#B.values())t.addStandaloneCommentButton();t===O.SIGNATURE&&await(this.#yt?.loadSignatures()),i&&ue.clearPointerType(),this.setEditingState(!0),await this.#Qt(),this.unselectAll();for(const e of this.#j.values())e.updateMode(t);if(t===O.POPUP){this.#O||=await this.#Ct.getAnnotationsByType(new Set(this.#Q.map(t=>t._editorType)));const t=new Set,e=[];for(const i of this.#B.values()){const{annotationElementId:n,hasComment:s,deleted:a}=i;n&&t.add(n),s&&!a&&e.push(i.getData())}for(const i of this.#O){const{id:n,popupRef:s,contentsObj:a}=i;s&&a?.str&&!t.has(n)&&!this.#q.has(n)&&e.push(i)}this.#W?.showSidebar(e)}if(!e)return n&&this.addNewEditorFromKeyboard(),void this.#kt.resolve();for(const t of this.#B.values())t.uid===e?(this.setSelected(t),a?t.editComment():s?t.enterInEditMode():t.focus()):t.unselect();this.#kt.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#bt&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#Q){switch(t){case B.CREATE:return void this.currentLayer.addNewEditor(e);case B.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#At||=new Map).set(t,e),this.showAllEditors("highlight",e)}if(this.hasSelection)for(const i of this.#vt)i.updateParams(t,e);else for(const i of this.#Q)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(const i of this.#B.values())i.editorType===t&&i.show(e);(this.#At?.get(B.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#Kt([[B.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#ct!==t){this.#ct=t;for(const e of this.#j.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#Qt(){if(!this.#ht){this.#ht=!0;const t=[];for(const e of this.#j.values())t.push(e.enable());await Promise.all(t);for(const t of this.#B.values())t.enable()}}#Yt(){if(this.unselectAll(),this.#ht){this.#ht=!1;for(const t of this.#j.values())t.disable();for(const t of this.#B.values())t.disable()}}*getEditors(t){for(const e of this.#B.values())e.pageIndex===t&&(yield e)}getEditor(t){return this.#B.get(t)}addEditor(t){this.#B.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#nt&&clearTimeout(this.#nt),this.#nt=setTimeout(()=>{this.focusMainContainer(),this.#nt=null},0)),this.#B.delete(t.id),t.annotationElementId&&this.#mt?.delete(t.annotationElementId),this.unselect(t),t.annotationElementId&&this.#q.has(t.annotationElementId)||this.#V?.remove(t.id)}addDeletedAnnotationElement(t){this.#q.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#q.has(t)}removeDeletedAnnotationElement(t){this.#q.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#Gt(t){const e=this.#j.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#F!==t&&(this.#F=t,t&&this.#Kt(t.propertiesToUpdate))}get#Zt(){let t=null;for(t of this.#vt);return t}updateUI(t){this.#Zt===t&&this.#Kt(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#Kt(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#vt.has(t))return this.#vt.delete(t),t.unselect(),void this.#jt({hasSelectedEditor:this.hasSelection});this.#vt.add(t),t.select(),this.#Kt(t.propertiesToUpdate),this.#jt({hasSelectedEditor:!0})}setSelected(t){this.updateToolbar({mode:t.mode,editId:t.uid}),this.#X?.commitOrRemove();for(const e of this.#vt)e!==t&&e.unselect();this.#W?.destroyPopup(),this.#vt.clear(),this.#vt.add(t),t.select(),this.#Kt(t.propertiesToUpdate),this.#jt({hasSelectedEditor:!0})}isSelected(t){return this.#vt.has(t)}get firstSelectedEditor(){return this.#vt.values().next().value}unselect(t){t.unselect(),this.#vt.delete(t),this.#jt({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#vt.size}get isEnterHandled(){return 1===this.#vt.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#$.undo(),this.#jt({hasSomethingToUndo:this.#$.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#qt()}),this._editorUndoBar?.hide()}redo(){this.#$.redo(),this.#jt({hasSomethingToUndo:!0,hasSomethingToRedo:this.#$.hasSomethingToRedo(),isEmpty:this.#qt()})}addCommands(t){this.#$.add(t),this.#jt({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#qt()})}cleanUndoStack(t){this.#$.cleanType(t)}#qt(){if(0===this.#B.size)return!0;if(1===this.#B.size)for(const t of this.#B.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.#vt],i=()=>{for(const t of e)this.#Gt(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.#F?.commitOrRemove()}hasSomethingToControl(){return this.#F||this.hasSelection}#Xt(t){for(const t of this.#vt)t.unselect();this.#vt.clear();for(const e of t)e.isEmpty()||(this.#vt.add(e),e.select());this.#jt({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#vt)t.commit();this.#Xt(this.#B.values())}unselectAll(){if((!this.#F||(this.#F.commitOrRemove(),this.#bt===O.NONE))&&!this.#X?.commitOrRemove()&&(this.#W?.destroyPopup(),this.hasSelection)){for(const t of this.#vt)t.unselect();this.#vt.clear(),this.#jt({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#Pt[0]+=t,this.#Pt[1]+=e;const[n,s]=this.#Pt,a=[...this.#vt];this.#_t&&clearTimeout(this.#_t),this.#_t=setTimeout(()=>{this.#_t=null,this.#Pt[0]=this.#Pt[1]=0,this.addCommands({cmd:()=>{for(const t of a)this.#B.has(t.id)&&(t.translateInPage(n,s),t.translationDone())},undo:()=>{for(const t of a)this.#B.has(t.id)&&(t.translateInPage(-n,-s),t.translationDone())},mustExec:!1})},1e3);for(const i of a)i.translateInPage(t,e),i.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#Y=new Map;for(const t of this.#vt)this.#Y.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#Y)return!1;this.disableUserSelect(!1);const t=this.#Y;this.#Y=null;let e=!1;for(const[{x:i,y:n,pageIndex:s},a]of t)a.newX=i,a.newY=n,a.newPageIndex=s,e||=i!==a.savedX||n!==a.savedY||s!==a.savedPageIndex;if(!e)return!1;const i=(t,e,i,n)=>{if(this.#B.has(t.id)){const s=this.#j.get(n);s?t._setParentAndPosition(s,e,i):(t.pageIndex=n,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(const[e,{newX:n,newY:s,newPageIndex:a}]of t)i(e,n,s,a)},undo:()=>{for(const[e,{savedX:n,savedY:s,savedPageIndex:a}]of t)i(e,n,s,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#Y)for(const i of this.#Y.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.#vt.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#F===t}getActive(){return this.#F}getMode(){return this.#bt}isEditingMode(){return this.#bt!==O.NONE}get imageManager(){return mt(this,"imageManager",new ge)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let i=0,n=e.rangeCount;i<n;i++)if(!t.contains(e.getRangeAt(i).commonAncestorContainer))return null;const{x:i,y:n,width:s,height:a}=t.getBoundingClientRect();let r;switch(t.getAttribute("data-main-rotation")){case"90":r=(t,e,r,o)=>({x:(e-n)/a,y:1-(t+r-i)/s,width:o/a,height:r/s});break;case"180":r=(t,e,r,o)=>({x:1-(t+r-i)/s,y:1-(e+o-n)/a,width:r/s,height:o/a});break;case"270":r=(t,e,r,o)=>({x:1-(e+o-n)/a,y:(t-i)/s,width:o/a,height:r/s});break;default:r=(t,e,r,o)=>({x:(t-i)/s,y:(e-n)/a,width:r/s,height:o/a})}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:n,height:s}of i.getClientRects())0!==n&&0!==s&&o.push(r(t,e,n,s))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#z||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#z?.delete(t)}renderAnnotationElement(t){const e=this.#z?.get(t.data.id);if(!e)return;const i=this.#V.getRawValue(e);i&&(this.#bt!==O.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}setMissingCanvas(t,e,i){const n=this.#mt?.get(t);n&&(n.setCanvas(e,i),this.#mt.delete(t))}addMissingCanvas(t,e){(this.#mt||=new Map).set(t,e)}};class we{#l=null;#Jt=!1;#te=null;#ee=null;#ie=null;#ne=null;#se=!1;#ae=null;#r=null;#re=null;#oe=null;#le=!1;static#he=null;static _l10n=null;constructor(t){this.#r=t,this.#le=t._uiManager.useNewAltTextFlow,we.#he||=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.#te=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#ee=document.createElement("span");t.append(e),this.#le?(t.classList.add("new"),t.setAttribute("data-l10n-id",we.#he.missing),e.setAttribute("data-l10n-id",we.#he["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",$t,{signal:i}),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});const n=t=>{t.preventDefault(),this.#r._uiManager.editAltText(this.#r),this.#le&&this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#de}})};return t.addEventListener("click",n,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#se=!0,n(e))},{signal:i}),await this.#ce(),t}get#de(){return(this.#l?"added":null===this.#l&&this.guessedText&&"review")||"missing"}finish(){this.#te&&(this.#te.focus({focusVisible:this.#se}),this.#se=!1)}isEmpty(){return this.#le?null===this.#l:!this.#l&&!this.#Jt}hasData(){return this.#le?null!==this.#l||!!this.#re:this.isEmpty()}get guessedText(){return this.#re}async setGuessedText(t){null===this.#l&&(this.#re=t,this.#oe=await we._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#ce())}toggleAltTextBadge(t=!1){if(!this.#le||this.#l)return this.#ae?.remove(),void(this.#ae=null);if(!this.#ae){const t=this.#ae=document.createElement("div");t.className="noAltTextBadge",this.#r.div.append(t)}this.#ae.classList.toggle("hidden",!t)}serialize(t){let e=this.#l;return t||this.#re!==e||(e=this.#oe),{altText:e,decorative:this.#Jt,guessedText:this.#re,textWithDisclaimer:this.#oe}}get data(){return{altText:this.#l,decorative:this.#Jt}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:n,cancel:s=!1}){i&&(this.#re=i,this.#oe=n),this.#l===t&&this.#Jt===e||(s||(this.#l=t,this.#Jt=e),this.#ce())}toggle(t=!1){this.#te&&(!t&&this.#ne&&(clearTimeout(this.#ne),this.#ne=null),this.#te.disabled=!t)}shown(){this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#de}})}destroy(){this.#te?.remove(),this.#te=null,this.#ee=null,this.#ie=null,this.#ae?.remove(),this.#ae=null}async#ce(){const t=this.#te;if(!t)return;if(this.#le){if(t.classList.toggle("done",!!this.#l),t.setAttribute("data-l10n-id",we.#he[this.#de]),this.#ee?.setAttribute("data-l10n-id",we.#he[`${this.#de}-label`]),!this.#l)return void this.#ie?.remove()}else{if(!this.#l&&!this.#Jt)return t.classList.remove("done"),void this.#ie?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#ie;if(!e){this.#ie=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#r.id}`;const i=100,n=this.#r._uiManager._signal;n.addEventListener("abort",()=>{clearTimeout(this.#ne),this.#ne=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#ne=setTimeout(()=>{this.#ne=null,this.#ie.classList.add("show"),this.#r._reportTelemetry({action:"alt_text_tooltip"})},i)},{signal:n}),t.addEventListener("mouseleave",()=>{this.#ne&&(clearTimeout(this.#ne),this.#ne=null),this.#ie?.classList.remove("show")},{signal:n})}this.#Jt?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#l),e.parentNode||t.append(e);const i=this.#r.getElementForAltText();i?.setAttribute("aria-describedby",e.id)}}class ye{#ue=null;#pe=null;#ge=!1;#r=null;#me=null;#fe=null;#be=null;#ve=null;#we=!1;#ye=null;constructor(t){this.#r=t}renderForToolbar(){const t=this.#pe=document.createElement("button");return t.className="comment",this.#w(t,!1)}renderForStandalone(){const t=this.#ue=document.createElement("button");t.className="annotationCommentButton";const e=this.#r.commentButtonPosition;if(e){const{style:i}=t;i.insetInlineEnd=`calc(${100*("ltr"===this.#r._uiManager.direction?1-e[0]:e[0])}% - var(--comment-button-dim))`,i.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const n=this.#r.commentButtonColor;n&&(i.backgroundColor=n)}return this.#w(t,!0)}focusButton(){setTimeout(()=>{(this.#ue??this.#pe)?.focus()},0)}onUpdatedColor(){if(!this.#ue)return;const t=this.#r.commentButtonColor;t&&(this.#ue.style.backgroundColor=t),this.#r._uiManager.updatePopupColor(this.#r)}get commentButtonWidth(){return(this.#ue?.getBoundingClientRect().width??0)/this.#r.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#ye)return this.#ye;if(!this.#ue)return null;const{x:t,y:e,height:i}=this.#ue.getBoundingClientRect(),{x:n,y:s,width:a,height:r}=this.#r.parent.boundingClientRect;return[(t-n)/a,(e+i-s)/r]}set commentPopupPositionInLayer(t){this.#ye=t}hasDefaultPopupPosition(){return null===this.#ye}removeStandaloneCommentButton(){this.#ue?.remove(),this.#ue=null}removeToolbarCommentButton(){this.#pe?.remove(),this.#pe=null}setCommentButtonStates({selected:t,hasPopup:e}){this.#ue&&(this.#ue.classList.toggle("selected",t),this.#ue.ariaExpanded=e)}#w(t,e){if(!this.#r._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[this.#r._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const i=this.#r._uiManager._signal;if(!(i instanceof AbortSignal)||i.aborted)return t;t.addEventListener("contextmenu",$t,{signal:i}),e&&(t.addEventListener("focusin",t=>{this.#r._focusEventsAllowed=!1,Wt(t)},{capture:!0,signal:i}),t.addEventListener("focusout",t=>{this.#r._focusEventsAllowed=!0,Wt(t)},{capture:!0,signal:i})),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});const n=e=>{e.preventDefault(),t===this.#pe?this.edit():this.#r.toggleComment(!0)};return t.addEventListener("click",n,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#ge=!0,n(e))},{signal:i}),t.addEventListener("pointerenter",()=>{this.#r.toggleComment(!1,!0)},{signal:i}),t.addEventListener("pointerleave",()=>{this.#r.toggleComment(!1,!1)},{signal:i}),t}edit(t){const e=this.commentPopupPositionInLayer;let i,n;if(e)[i,n]=e;else{[i,n]=this.#r.commentButtonPosition;const{width:t,height:e,x:s,y:a}=this.#r;i=s+i*t,n=a+n*e}const s=this.#r.parent.boundingClientRect,{x:a,y:r,width:o,height:l}=s;this.#r._uiManager.editComment(this.#r,a+i*o,r+n*l,{...t,parentDimensions:s})}finish(){this.#pe&&(this.#pe.focus({focusVisible:this.#ge}),this.#ge=!1)}isDeleted(){return this.#we||""===this.#be}isEmpty(){return null===this.#be}hasBeenEdited(){return this.isDeleted()||this.#be!==this.#me}serialize(){return this.data}get data(){return{text:this.#be,richText:this.#fe,date:this.#ve,deleted:this.isDeleted()}}set data(t){if(t!==this.#be&&(this.#fe=null),null===t)return this.#be="",void(this.#we=!0);this.#be=t,this.#ve=new Date,this.#we=!1}restoreData({text:t,richText:e,date:i}){this.#be=t,this.#fe=e,this.#ve=i,this.#we=!1}setInitialText(t,e=null){this.#me=t,this.data=t,this.#ve=null,this.#fe=e}shown(){}destroy(){this.#pe?.remove(),this.#pe=null,this.#ue?.remove(),this.#ue=null,this.#be="",this.#fe=null,this.#ve=null,this.#r=null,this.#ge=!1,this.#we=!1}}let xe=class t{#Et;#xe=!1;#Ae=null;#Ce;#Se;#Pe;#_e;#Ee=null;#Te;#Me=null;#ke;#De=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:n=null,onPinching:s=null,onPinchEnd:a=null,signal:r}){this.#Et=t,this.#Ae=i,this.#Ce=e,this.#Se=n,this.#Pe=s,this.#_e=a,this.#ke=new AbortController,this.#Te=AbortSignal.any([r,this.#ke.signal]),t.addEventListener("touchstart",this.#Ie.bind(this),{passive:!1,signal:this.#Te})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Zt.pixelRatio}#Ie(t){if(this.#Ce?.())return;if(1===t.touches.length){if(this.#Ee)return;const t=this.#Ee=new AbortController,e=AbortSignal.any([this.#Te,t.signal]),i=this.#Et,n={capture:!0,signal:e,passive:!1},s=t=>{"touch"===t.pointerType&&(this.#Ee?.abort(),this.#Ee=null)};return i.addEventListener("pointerdown",t=>{"touch"===t.pointerType&&(Wt(t),s(t))},n),i.addEventListener("pointerup",s,n),void i.addEventListener("pointercancel",s,n)}if(!this.#De){this.#De=new AbortController;const t=AbortSignal.any([this.#Te,this.#De.signal]),e=this.#Et,i={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",this.#Le.bind(this),i);const n=this.#Ne.bind(this);e.addEventListener("touchend",n,i),e.addEventListener("touchcancel",n,i),i.capture=!0,e.addEventListener("pointerdown",Wt,i),e.addEventListener("pointermove",Wt,i),e.addEventListener("pointercancel",Wt,i),e.addEventListener("pointerup",Wt,i),this.#Se?.()}if(Wt(t),2!==t.touches.length||this.#Ae?.())return void(this.#Me=null);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#Me={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#Le(e){if(!this.#Me||2!==e.touches.length)return;Wt(e);let[i,n]=e.touches;i.identifier>n.identifier&&([i,n]=[n,i]);const{screenX:s,screenY:a}=i,{screenX:r,screenY:o}=n,l=this.#Me,{touch0X:h,touch0Y:d,touch1X:c,touch1Y:u}=l,p=c-h,g=u-d,m=r-s,f=o-a,b=Math.hypot(m,f)||1,v=Math.hypot(p,g)||1;if(!this.#xe&&Math.abs(v-b)<=t.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=s,l.touch0Y=a,l.touch1X=r,l.touch1Y=o,!this.#xe)return void(this.#xe=!0);const w=[(s+r)/2,(a+o)/2];this.#Pe?.(w,v,b)}#Ne(t){t.touches.length>=2||(this.#De&&(this.#De.abort(),this.#De=null,this.#_e?.()),this.#Me&&(Wt(t),this.#Me=null,this.#xe=!1))}destroy(){this.#ke?.abort(),this.#ke=null,this.#Ee?.abort(),this.#Ee=null}};class Ae{#Re=null;#Fe=null;#l=null;#h=null;#ue=null;#Oe=!1;#Be=null;#je="";#Ue=null;#He=null;#Ve=null;#ze=null;#$e=null;#We="";#Ge=!1;#Xe=null;#Ke=!1;#qe=!1;#Ye=!1;#Qe=null;#Ze=0;#Je=0;#ti=null;#ei=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nAlert=null;static _l10nResizer=null;#ii=!1;#ni=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 mt(this,"_resizerKeyboardManager",new fe([[["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,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;const{rotation:e,rawDims:{pageWidth:i,pageHeight:n,pageX:s,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,n],this.pageTranslation=[s,a];const[r,o]=this.parentDimensions;this.x=t.x/r,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}updatePageIndex(t){this.pageIndex=t}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return mt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new Ce({id:t._uiManager.getId(),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._l10nAlert??=Object.freeze({highlight:"pdfjs-editor-highlight-added-alert",freetext:"pdfjs-editor-freetext-added-alert",ink:"pdfjs-editor-ink-added-alert",stamp:"pdfjs-editor-stamp-added-alert",signature:"pdfjs-editor-signature-added-alert"}),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){dt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#ii}set _isDraggable(t){this.#ii=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}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.#ni}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#si(),this.#ze?.remove(),this.#ze=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#Ge?this.#Ge=!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.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,n){const[s,a]=this.parentDimensions;[i,n]=this.screenToPageTranslation(i,n),this.x=(t+i)/s,this.y=(e+n)/a,this.fixAndSetPosition()}_moveAfterPaste(t,e){if(this.isClone)return void delete this.isClone;const[i,n]=this.parentDimensions;this.setAt(t*i,e*n,this.width*i,this.height*n),this._onTranslated()}#ai([t,e],i,n){[i,n]=this.screenToPageTranslation(i,n),this.x+=i/t,this.y+=n/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#ai(this.parentDimensions,t,e)}translateInPage(t,e){this.#Xe||=[this.x,this.y,this.width,this.height],this.#ai(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#Xe||=[this.x,this.y,this.width,this.height];const{div:i,parentDimensions:[n,s]}=this;if(this.x+=t/n,this.y+=e/s,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:a,y:r}=this;const[o,l]=this.getBaseTranslation();a+=o,r+=l;const{style:h}=i;h.left=`${(100*a).toFixed(2)}%`,h.top=`${(100*r).toFixed(2)}%`,this._onTranslating(a,r),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#Xe&&(this.#Xe[0]!==this.x||this.#Xe[1]!==this.y)}get _hasBeenResized(){return!!this.#Xe&&(this.#Xe[2]!==this.width||this.#Xe[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=Ae,n=i/t,s=i/e;switch(this.rotation){case 90:return[-n,s];case 180:return[n,s];case 270:return[n,-s];default:return[-n,-s]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[i,n]}=this;let{x:s,y:a,width:r,height:o}=this;if(r*=i,o*=n,s*=i,a*=n,this._mustFixPosition)switch(t){case 0:s=It(s,0,i-r),a=It(a,0,n-o);break;case 90:s=It(s,0,i-o),a=It(a,r,n);break;case 180:s=It(s,r,i),a=It(a,o,n);break;case 270:s=It(s,o,i),a=It(a,0,n-r)}this.x=s/=i,this.y=a/=n;const[l,h]=this.getBaseTranslation();s+=l,a+=h,e.left=`${(100*s).toFixed(2)}%`,e.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}static#ri(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.#ri(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return Ae.#ri(t,e,360-this.parentRotation)}#oi(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(){const{div:{style:t},width:e,height:i}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*i).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#li(){if(this.#Ue)return;this.#Ue=document.createElement("div"),this.#Ue.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.#Ue.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#hi.bind(this,i),{signal:e}),t.addEventListener("contextmenu",$t,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#Ue)}#hi(t,e){e.preventDefault();const{isMac:i}=St.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#l?.toggle(!1);const n=this._isDraggable;this._isDraggable=!1,this.#He=[e.screenX,e.screenY];const s=new AbortController,a=this._uiManager.combinedSignal(s);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#di.bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Wt,{passive:!1,signal:a}),window.addEventListener("contextmenu",$t,{signal:a}),this.#Ve={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const r=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=()=>{s.abort(),this.parent.togglePointerEvents(!0),this.#l?.toggle(!0),this._isDraggable=n,this.parent.div.style.cursor=r,this.div.style.cursor=o,this.#ci()};window.addEventListener("pointerup",l,{signal:a}),window.addEventListener("blur",l,{signal:a})}#ui(t,e,i,n){this.width=i,this.height=n,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#ci(){if(!this.#Ve)return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:n}=this.#Ve;this.#Ve=null;const s=this.x,a=this.y,r=this.width,o=this.height;s===t&&a===e&&r===i&&o===n||this.addCommands({cmd:this.#ui.bind(this,s,a,r,o),undo:this.#ui.bind(this,t,e,i,n),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#di(t,e){const[i,n]=this.parentDimensions,s=this.x,a=this.y,r=this.width,o=this.height,l=Ae.MIN_SIZE/i,h=Ae.MIN_SIZE/n,d=this.#oi(this.rotation),c=(t,e)=>[d[0]*t+d[2]*e,d[1]*t+d[3]*e],u=this.#oi(360-this.rotation);let p,g,m=!1,f=!1;switch(t){case"topLeft":m=!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":m=!0,p=(t,e)=>[t,0],g=(t,e)=>[0,e];break;case"middleRight":f=!0,p=(t,e)=>[t,e/2],g=(t,e)=>[0,e/2];break;case"bottomRight":m=!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":m=!0,p=(t,e)=>[0,e],g=(t,e)=>[t,0];break;case"middleLeft":f=!0,p=(t,e)=>[0,e/2],g=(t,e)=>[t,e/2]}const b=p(r,o),v=g(r,o);let w=c(...v);const y=Ae._round(s+w[0]),x=Ae._round(a+w[1]);let A,C,S=1,P=1;if(e.fromKeyboard)({deltaX:A,deltaY:C}=e);else{const{screenX:t,screenY:i}=e,[n,s]=this.#He;[A,C]=this.screenToPageTranslation(t-n,i-s),this.#He[0]=t,this.#He[1]=i}var _,E;if([A,C]=(_=A/i,E=C/n,[u[0]*_+u[2]*E,u[1]*_+u[3]*E]),m){const t=Math.hypot(r,o);S=P=Math.max(Math.min(Math.hypot(v[0]-b[0]-A,v[1]-b[1]-C)/t,1/r,1/o),l/r,h/o)}else f?S=It(Math.abs(v[0]-b[0]-A),l,1)/r:P=It(Math.abs(v[1]-b[1]-C),h,1)/o;const T=Ae._round(r*S),M=Ae._round(o*P);w=c(...g(T,M));const k=y-w[0],D=x-w[1];this.#Xe||=[this.x,this.y,this.width,this.height],this.width=T,this.height=M,this.x=k,this.y=D,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#l?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#qe)return this._editToolbar;this._editToolbar=new le(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,i]of t)await this._editToolbar.addButton(e,i);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#l?.destroy()}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#l||(we.initialize(Ae._l10n),this.#l=new we(this),this.#Re&&(this.#l.data=this.#Re,this.#Re=null)),this.#l}get altTextData(){return this.#l?.data}set altTextData(t){this.#l&&(this.#l.data=t)}get guessedAltText(){return this.#l?.guessedText}async setGuessedAltText(t){await(this.#l?.setGuessedText(t))}serializeAltText(t){return this.#l?.serialize(t)}hasAltText(){return!!this.#l&&!this.#l.isEmpty()}hasAltTextData(){return this.#l?.hasData()??!1}focusCommentButton(){this.#h?.focusButton()}addCommentButton(){return this.canAddComment?this.#h||=new ye(this):null}addStandaloneCommentButton(){this._uiManager.hasCommentManager()&&(this.#ue?this._uiManager.isEditingMode()&&this.#ue.classList.remove("hidden"):this.hasComment&&(this.#ue=this.#h.renderForStandalone(),this.div.append(this.#ue)))}removeStandaloneCommentButton(){this.#h.removeStandaloneCommentButton(),this.#ue=null}hideStandaloneCommentButton(){this.#ue?.classList.add("hidden")}get comment(){if(!this.#h)return null;const{data:{richText:t,text:e,date:i,deleted:n}}=this.#h;return{text:e,richText:t,date:i,deleted:n,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#h||=new ye(this),"object"==typeof t&&null!==t?this.#h.restoreData(t):this.#h.data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:i}){if(!e)return;if(this.#h||=new ye(this),this.#h.setInitialText(t,i),!this.annotationElementId)return;const n=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);n&&this.updateFromAnnotationLayer(n)}get hasEditedComment(){return this.#h?.hasBeenEdited()}get hasDeletedComment(){return this.#h?.isDeleted()}get hasComment(){return!!this.#h&&!this.#h.isEmpty()&&!this.#h.isDeleted()}async editComment(t){this.#h||=new ye(this),this.#h.edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#h.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const e=180,i=100,[,,,n]=t.rect,[s]=this.pageDimensions,[a]=this.pageTranslation,r=a+s+1,o=n-i,l=r+e;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[r,o,l,n]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#h.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#Oe?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#pi();const[e,i]=this.parentDimensions;this.parentRotation%180!=0&&(t.style.maxWidth=`${(100*i/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/i).toFixed(2)}%`);const[n,s]=this.getInitialTranslation();return this.translate(n,s),ce(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#ei||=new xe({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#gi.bind(this),onPinching:this.#mi.bind(this),onPinchEnd:this.#fi.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#gi(){this.#Ve={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#l?.toggle(!1),this.parent.togglePointerEvents(!1)}#mi(t,e,i){let n=i/e*.7+1-.7;if(1===n)return;const s=this.#oi(this.rotation),a=(t,e)=>[s[0]*t+s[2]*e,s[1]*t+s[3]*e],[r,o]=this.parentDimensions,l=this.x,h=this.y,d=this.width,c=this.height,u=Ae.MIN_SIZE/r,p=Ae.MIN_SIZE/o;n=Math.max(Math.min(n,1/d,1/c),u/d,p/c);const g=Ae._round(d*n),m=Ae._round(c*n);if(g===d&&m===c)return;this.#Xe||=[l,h,d,c];const f=a(d/2,c/2),b=Ae._round(l+f[0]),v=Ae._round(h+f[1]),w=a(g/2,m/2);this.x=b-w[0],this.y=v-w[1],this.width=g,this.height=m,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#fi(){this.#l?.toggle(!0),this.parent.togglePointerEvents(!0),this.#ci()}pointerdown(t){const{isMac:e}=St.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#Ge=!0,this._isDraggable?this.#bi(t):this.#vi(t))}#vi(t){const{isMac:e}=St.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#bi(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const n=new AbortController,s=this._uiManager.combinedSignal(n),a={capture:!0,passive:!1,signal:s},r=t=>{n.abort(),this.#Be=null,this.#Ge=!1,this._uiManager.endDragSession()||this.#vi(t),i&&this._onStopDragging()};e&&(this.#Ze=t.clientX,this.#Je=t.clientY,this.#Be=t.pointerId,this.#je=t.pointerType,window.addEventListener("pointermove",t=>{i||(i=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:e,clientY:n,pointerId:s}=t;if(s!==this.#Be)return void Wt(t);const[a,r]=this.screenToPageTranslation(e-this.#Ze,n-this.#Je);this.#Ze=e,this.#Je=n,this._uiManager.dragSelectedEditors(a,r)},a),window.addEventListener("touchmove",Wt,a),window.addEventListener("pointerdown",t=>{t.pointerType===this.#je&&(this.#ei||t.isPrimary)&&r(t),Wt(t)},a));const o=t=>{this.#Be&&this.#Be!==t.pointerId?Wt(t):r(t)};window.addEventListener("pointerup",o,{signal:s}),window.addEventListener("blur",o,{signal:s})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#Qe&&clearTimeout(this.#Qe),this.#Qe=setTimeout(()=>{this.#Qe=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 n=this.parentScale,[s,a]=this.pageDimensions,[r,o]=this.pageTranslation,l=t/n,h=e/n,d=this.x*s,c=this.y*a,u=this.width*s,p=this.height*a;switch(i){case 0:return[d+l+r,a-c-h-p+o,d+l+u+r,a-c-h+o];case 90:return[d+h+r,a-c+l+o,d+h+p+r,a-c+l+u+o];case 180:return[d-l-u+r,a-c+h+o,d-l+r,a-c+h+p+o];case 270:return[d-h-p+r,a-c-l-u+o,d-h+r,a-c-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,n,s,a]=t,r=s-i,o=a-n;switch(this.rotation){case 0:return[i,e-a,r,o];case 90:return[i,e-n,o,r];case 180:return[s,e-n,r,o];case 270:return[s,e-a,o,r];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&Ae._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#h?.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:i,opacity:n,deleted:s,richText:a},uid:r,pageIndex:o,creationDate:l,modificationDate:h}=this;return{id:r,pageIndex:o,rect:this.getPDFRect(),richText:a,contentsObj:{str:t},creationDate:l,modificationDate:i||h,popupRef:!s,color:e,opacity:n}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#qe=!0,!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),this.#qe=!1,!0)}isInEditMode(){return this.#qe}shouldGetKeyboardEvents(){return this.#Ye}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:n}=this.getClientDimensions(),{innerHeight:s,innerWidth:a}=window;return e<a&&n>0&&t<s&&i>0}#pi(){if(this.#$e||!this.div)return;this.#$e=new AbortController;const t=this._uiManager.combinedSignal(this.#$e);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#pi()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,e,i){const n=new this.prototype.constructor({parent:e,id:i.getId(),uiManager:i,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});n.rotation=t.rotation,n.#Re=t.accessibilityData,n._isCopy=t.isCopy||!1;const[s,a]=n.pageDimensions,[r,o,l,h]=n.getRectInCurrentCoords(t.rect,a);return n.x=r/s,n.y=o/a,n.width=l/s,n.height=h/a,n}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#$e?.abort(),this.#$e=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#Qe&&(clearTimeout(this.#Qe),this.#Qe=null),this.#si(),this.removeEditToolbar(),this.#ti){for(const t of this.#ti.values())clearTimeout(t);this.#ti=null}this.parent=null,this.#ei?.destroy(),this.#ei=null,this.#ze?.remove(),this.#ze=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#li(),this.#Ue.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return"ltr"===this._uiManager.direction?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,e]}=this,[i,n,s,a]=this.getPDFRect();return[Ae._round(i+(s-i)*t),Ae._round(n+(a-n)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#h.commentPopupPositionInLayer}set commentPopupPosition(t){this.#h.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#h.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#h.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#h?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#Ve={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#Ue.children;if(!this.#Fe){this.#Fe=Array.from(e);const t=this.#wi.bind(this),i=this.#yi.bind(this),n=this._uiManager._signal;for(const e of this.#Fe){const s=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:n}),e.addEventListener("blur",i,{signal:n}),e.addEventListener("focus",this.#xi.bind(this,s),{signal:n}),e.setAttribute("data-l10n-id",Ae._l10nResizer[s])}}const i=this.#Fe[0];let n=0;for(const t of e){if(t===i)break;n++}const s=(360-this.rotation+this.parentRotation)%360/90*(this.#Fe.length/4);if(s!==n){if(s<n)for(let t=0;t<n-s;t++)this.#Ue.append(this.#Ue.firstElementChild);else if(s>n)for(let t=0;t<s-n;t++)this.#Ue.firstElementChild.before(this.#Ue.lastElementChild);let t=0;for(const i of e){const e=this.#Fe[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",Ae._l10nResizer[e])}}this.#Ai(0),this.#Ye=!0,this.#Ue.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#wi(t){Ae._resizerKeyboardManager.exec(this,t)}#yi(t){this.#Ye&&t.relatedTarget?.parentNode!==this.#Ue&&this.#si()}#xi(t){this.#We=this.#Ye?t:""}#Ai(t){if(this.#Fe)for(const e of this.#Fe)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#Ye&&this.#di(this.#We,{deltaX:t,deltaY:e,fromKeyboard:!0})}#si(){this.#Ye=!1,this.#Ai(-1),this.#ci()}_stopResizingWithKeyboard(){this.#si(),this.div.focus()}select(){this.isSelected&&this._editToolbar?this._editToolbar.show():(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#l?.toggleAltTextBadge(!1)):this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()}))}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#Ue?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#l?.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){"BUTTON"!==t.target.nodeName&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#Ke}set isEditing(t){this.#Ke=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}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.#ti||=new Map;const{action:e}=t;let i=this.#ti.get(e);return i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#ti.delete(e),0===this.#ti.size&&(this.#ti=null)},Ae._telemetryTimeout),void this.#ti.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.#Oe=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#Oe=!0}updateFakeAnnotationElement(t){if(this.#ze||this.deleted)return this.deleted?(this.#ze.remove(),void(this.#ze=null)):void((this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#ze.updateEdited({rect:this.getPDFRect(),popup:this.comment}));this.#ze=t.addFakeAnnotation(this)}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;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{firstElementChild:e}=t.container;"DIV"===e?.nodeName&&e.classList.contains("annotationContent")&&e.remove()}}class Ce extends Ae{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Se=3285377520,Pe=4294901760,_e=65535;class Ee{constructor(t){this.h1=t?4294967295&t:Se,this.h2=t?4294967295&t:Se}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let n=0,s=t.length;n<s;n++){const s=t.charCodeAt(n);s<=255?e[i++]=s:(e[i++]=s>>>8,e[i++]=255&s)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),i=e.byteLength}const n=i>>2,s=i-4*n,a=new Uint32Array(e.buffer,0,n);let r=0,o=0,l=this.h1,h=this.h2;const d=3432918353,c=461845907,u=11601,p=13715;for(let t=0;t<n;t++)1&t?(r=a[t],r=r*d&Pe|r*u&_e,r=r<<15|r>>>17,r=r*c&Pe|r*p&_e,l^=r,l=l<<13|l>>>19,l=5*l+3864292196):(o=a[t],o=o*d&Pe|o*u&_e,o=o<<15|o>>>17,o=o*c&Pe|o*p&_e,h^=o,h=h<<13|h>>>19,h=5*h+3864292196);switch(r=0,s){case 3:r^=e[4*n+2]<<16;case 2:r^=e[4*n+1]<<8;case 1:r^=e[4*n],r=r*d&Pe|r*u&_e,r=r<<15|r>>>17,r=r*c&Pe|r*p&_e,1&n?l^=r:h^=r}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&Pe|36045*t&_e,e=4283543511*e&Pe|(2950163797*(e<<16|t>>>16)&Pe)>>>16,t^=e>>>1,t=444984403*t&Pe|60499*t&_e,e=3301882366*e&Pe|(3120437893*(e<<16|t>>>16)&Pe)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Te=Object.freeze({map:null,hash:"",transfer:void 0});class Me{#Ci=!1;#Si=null;#Pi=null;#_i=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(t,e){const i=this.#_i.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#_i.get(t)}remove(t){const e=this.#_i.get(t);void 0!==e&&(e instanceof Ae&&this.#Pi.delete(e.annotationElementId),this.#_i.delete(t),0===this.#_i.size&&this.resetModified(),this.#_i.values().some(t=>t instanceof Ae)||this.onAnnotationEditor?.(null))}setValue(t,e){const i=this.#_i.get(t);let n=!1;if(void 0!==i)for(const[t,s]of Object.entries(e))i[t]!==s&&(n=!0,i[t]=s);else n=!0,this.#_i.set(t,e);n&&this.#Ei(),e instanceof Ae&&((this.#Pi||=new Map).set(e.annotationElementId,e),this.onAnnotationEditor?.(e.constructor._type))}has(t){return this.#_i.has(t)}get size(){return this.#_i.size}#Ei(){this.#Ci||(this.#Ci=!0,this.onSetModified?.())}resetModified(){this.#Ci&&(this.#Ci=!1,this.onResetModified?.())}get print(){return new ke(this)}get serializable(){if(0===this.#_i.size)return Te;const t=new Map,e=new Ee,i=[],n=Object.create(null);let s=!1;for(const[i,a]of this.#_i){const r=a instanceof Ae?a.serialize(!1,n):a;a.page&&(a.pageIndex=a.page._pageIndex,delete a.page),r&&(t.set(i,r),e.update(`${i}:${JSON.stringify(r)}`),s||=!!r.bitmap)}if(s)for(const e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:Te}get editorStats(){let t=null;const e=new Map;let i=0,n=0;for(const s of this.#_i.values()){if(!(s instanceof Ae)){s.popup&&(s.popup.deleted?n+=1:i+=1);continue}s.isCommentDeleted?n+=1:s.hasEditedComment&&(i+=1);const a=s.telemetryFinalData;if(!a)continue;const{type:r}=a;e.has(r)||e.set(r,Object.getPrototypeOf(s).constructor),t||=Object.create(null);const o=t[r]||=new Map;for(const[t,e]of Object.entries(a)){if("type"===t)continue;const i=o.getOrInsertComputed(t,kt);i.set(e,(i.get(e)??0)+1)}}if((n>0||i>0)&&(t||=Object.create(null),t.comments={deleted:n,edited:i}),!t)return null;for(const[i,n]of e)t[i]=n.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#Si=null}updateEditor(t,e){const i=this.#Pi?.get(t);return!!i&&(i.updateFromAnnotationLayer(e),!0)}getEditor(t){return this.#Pi?.get(t)||null}get modifiedIds(){if(this.#Si)return this.#Si;const t=[];if(this.#Pi)for(const e of this.#Pi.values())e.serialize()&&t.push(e.annotationElementId);let e="";if(t.length){const i=new Ee;i.update(t.join(",")),e=i.hexdigest()}return this.#Si={ids:new Set(t),hash:e}}[Symbol.iterator](){return this.#_i.entries()}}class ke extends Me{#Ti=Te;constructor(t){super();const{serializable:e}=t;if(e===Te)return;const{map:i,hash:n,transfer:s}=e,a=structuredClone(i,s?{transfer:s}:null);this.#Ti={map:a,hash:n,transfer:[]}}get print(){dt("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#Ti}get modifiedIds(){return mt(this,"modifiedIds",{ids:new Set,hash:""})}}const De="__forcedDependency",{floor:Ie,ceil:Le}=Math;function Ne(t,e,i,n,s,a){t[4*e+0]=Math.min(t[4*e+0],i),t[4*e+1]=Math.min(t[4*e+1],n),t[4*e+2]=Math.max(t[4*e+2],s),t[4*e+3]=Math.max(t[4*e+3],a)}const Re=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class Fe{#Mi;#ki;constructor(t,e){this.#Mi=t,this.#ki=e}get length(){return this.#Mi.length}isEmpty(t){return this.#Mi[t]===Re}minX(t){return this.#ki[4*t+0]/256}minY(t){return this.#ki[4*t+1]/256}maxX(t){return(this.#ki[4*t+2]+1)/256}maxY(t){return(this.#ki[4*t+3]+1)/256}}const Oe=(t,e)=>t?.getOrInsertComputed(e,()=>({dependencies:new Set,isRenderingOperation:!1}));class Be{#Di=[[1,0,0,1,0,0]];#Ii=[-1/0,-1/0,1/0,1/0];#Li=new Float64Array(x);_pendingBBoxIdx=-1;#Ni;#Ri;#Fi;#Mi;_savesStack=[];_markedContentStack=[];constructor(t,e){this.#Ni=t.width,this.#Ri=t.height,this.#Oi(e)}growOperationsCount(t){t>=this.#Mi.length&&this.#Oi(t,this.#Mi)}#Oi(t,e){const i=new ArrayBuffer(4*t);this.#Fi=new Uint8ClampedArray(i),this.#Mi=new Uint32Array(i),e&&e.length>0?(this.#Mi.set(e),this.#Mi.fill(Re,e.length)):this.#Mi.fill(Re)}get clipBox(){return this.#Ii}save(t){return this.#Ii={__proto__:this.#Ii},this._savesStack.push(t),this}restore(t,e){const i=Object.getPrototypeOf(this.#Ii);if(null===i)return this;this.#Ii=i;const n=this._savesStack.pop();return void 0!==n&&(e?.(n,t),this.#Mi[t]=this.#Mi[n]),this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return 0===this._savesStack.length?null:this._savesStack.at(-1)}recordCloseMarker(t,e){const i=this._savesStack.pop();return void 0!==i&&(e?.(i,t),this.#Mi[t]=this.#Mi[i]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){const i=this._markedContentStack.pop();return void 0!==i&&(e?.(i,t),this.#Mi[t]=this.#Mi[i]),this}pushBaseTransform(t){return this.#Di.push(Pt.multiplyByDOMMatrix(this.#Di.at(-1),t.getTransform())),this}popBaseTransform(){return this.#Di.length>1&&this.#Di.pop(),this}resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,this.#Li.set(x,0)),this}recordClipBox(t,e,i,n,s,a){const r=Pt.multiplyByDOMMatrix(this.#Di.at(-1),e.getTransform()),o=x.slice();Pt.axialAlignedBoundingBox([i,s,n,a],r,o);const l=Pt.intersect(this.#Ii,o);return l?(this.#Ii[0]=l[0],this.#Ii[1]=l[1],this.#Ii[2]=l[2],this.#Ii[3]=l[3]):(this.#Ii[0]=this.#Ii[1]=1/0,this.#Ii[2]=this.#Ii[3]=-1/0),this}recordBBox(t,e,i,n,s,a){const r=this.#Ii;if(r[0]===1/0)return this;const o=Pt.multiplyByDOMMatrix(this.#Di.at(-1),e.getTransform());if(r[0]===-1/0)return Pt.axialAlignedBoundingBox([i,s,n,a],o,this.#Li),this;const l=x.slice();return Pt.axialAlignedBoundingBox([i,s,n,a],o,l),this.#Li[0]=It(l[0],r[0],this.#Li[0]),this.#Li[1]=It(l[1],r[1],this.#Li[1]),this.#Li[2]=It(l[2],this.#Li[2],r[2]),this.#Li[3]=It(l[3],this.#Li[3],r[3]),this}recordFullPageBBox(t){return this.#Li[0]=Math.max(0,this.#Ii[0]),this.#Li[1]=Math.max(0,this.#Ii[1]),this.#Li[2]=Math.min(this.#Ni,this.#Ii[2]),this.#Li[3]=Math.min(this.#Ri,this.#Ii[3]),this}recordOperation(t,e=!1,i){if(this._pendingBBoxIdx!==t)return this;const n=Ie(256*this.#Li[0]/this.#Ni),s=Ie(256*this.#Li[1]/this.#Ri),a=Le(256*this.#Li[2]/this.#Ni),r=Le(256*this.#Li[3]/this.#Ri);if(Ne(this.#Fi,t,n,s,a,r),i)for(const e of i)for(const i of e)i!==t&&Ne(this.#Fi,i,n,s,a,r);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,this.#Ii[0]=Math.max(this.#Ii[0],this.#Li[0]),this.#Ii[1]=Math.max(this.#Ii[1],this.#Li[1]),this.#Ii[2]=Math.min(this.#Ii[2],this.#Li[2]),this.#Ii[3]=Math.min(this.#Ii[3],this.#Li[3])),this}take(){return new Fe(this.#Mi,this.#Fi)}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,i){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,i,n=1,s=0,a=0,r){return this}getSimpleIndex(t){}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}}class je{#Bi={__proto__:null};#ji={__proto__:null,transform:[],moveText:[],sameLineText:[],[De]:[]};#Ui=new Map;#Hi=new Set;#Vi=new Map;#zi;#$i;#Wi;constructor(t,e=!1){this.#Wi=t,e&&(this.#zi=new Map,this.#$i=(t,e)=>{Oe(this.#zi,e).dependencies.add(t)})}get clipBox(){return this.#Wi.clipBox}growOperationsCount(t){this.#Wi.growOperationsCount(t)}save(t){return this.#Bi={__proto__:this.#Bi},this.#ji={__proto__:this.#ji,transform:{__proto__:this.#ji.transform},moveText:{__proto__:this.#ji.moveText},sameLineText:{__proto__:this.#ji.sameLineText},[De]:{__proto__:this.#ji[De]}},this.#Wi.save(t),this}restore(t){this.#Wi.restore(t,this.#$i);const e=Object.getPrototypeOf(this.#Bi);return null===e||(this.#Bi=e,this.#ji=Object.getPrototypeOf(this.#ji)),this}recordOpenMarker(t){return this.#Wi.recordOpenMarker(t,this.#$i),this}getOpenMarker(){return this.#Wi.getOpenMarker()}recordCloseMarker(t){return this.#Wi.recordCloseMarker(t,this.#$i),this}beginMarkedContent(t){return this.#Wi.beginMarkedContent(t),this}endMarkedContent(t){return this.#Wi.endMarkedContent(t,this.#$i),this}pushBaseTransform(t){return this.#Wi.pushBaseTransform(t),this}popBaseTransform(){return this.#Wi.popBaseTransform(),this}recordSimpleData(t,e){return this.#Bi[t]=e,this}recordIncrementalData(t,e){return this.#ji[t].push(e),this}resetIncrementalData(t,e){return this.#ji[t].length=0,this}recordNamedData(t,e){return this.#Ui.set(t,e),this}recordSimpleDataFromNamed(t,e,i){this.#Bi[t]=this.#Ui.get(e)??i}recordFutureForcedDependency(t,e){return this.recordIncrementalData(De,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in this.#Bi&&this.recordFutureForcedDependency(e,this.#Bi[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of this.#Hi)this.recordFutureForcedDependency(De,t);return this}resetBBox(t){return this.#Wi.resetBBox(t),this}recordClipBox(t,e,i,n,s,a){return this.#Wi.recordClipBox(t,e,i,n,s,a),this}recordBBox(t,e,i,n,s,a){return this.#Wi.recordBBox(t,e,i,n,s,a),this}recordCharacterBBox(t,e,i,n=1,s=0,a=0,r){const o=i.bbox;let l,h;if(o&&(l=o[2]!==o[0]&&o[3]!==o[1]&&this.#Vi.get(i),!1!==l&&(h=[0,0,0,0],Pt.axialAlignedBoundingBox(o,i.fontMatrix,h),1===n&&0===s&&0===a||function(t,e,i,n,s){let a;t?(t<0&&(a=s[0],s[0]=s[2],s[2]=a),s[0]*=t,s[2]*=t,e<0&&(a=s[1],s[1]=s[3],s[3]=a),s[1]*=e,s[3]*=e):s.fill(0),s[0]+=i,s[1]+=n,s[2]+=i,s[3]+=n}(n,-n,s,a,h),l)))return this.recordBBox(t,e,h[0],h[2],h[1],h[3]);if(!r)return this.recordFullPageBBox(t);const d=r();return o&&h&&void 0===l&&(l=h[0]<=s-d.actualBoundingBoxLeft&&h[2]>=s+d.actualBoundingBoxRight&&h[1]<=a-d.actualBoundingBoxAscent&&h[3]>=a+d.actualBoundingBoxDescent,this.#Vi.set(i,l),l)?this.recordBBox(t,e,h[0],h[2],h[1],h[3]):this.recordBBox(t,e,s-d.actualBoundingBoxLeft,s+d.actualBoundingBoxRight,a-d.actualBoundingBoxAscent,a+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#Wi.recordFullPageBBox(t),this}getSimpleIndex(t){return this.#Bi[t]}recordDependencies(t,e){const i=this.#Hi,n=this.#Bi,s=this.#ji;for(const t of e)t in this.#Bi?i.add(n[t]):t in s&&s[t].forEach(i.add,i);return this}recordNamedDependency(t,e){return this.#Ui.has(e)&&this.#Hi.add(this.#Ui.get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[De]),this.#zi){const e=Oe(this.#zi,t),{dependencies:i}=e;this.#Hi.forEach(i.add,i),this.#Wi._savesStack.forEach(i.add,i),this.#Wi._markedContentStack.forEach(i.add,i),i.delete(t),e.isRenderingOperation=!0}const i=!e&&t===this.#Wi._pendingBBoxIdx;return this.#Wi.recordOperation(t,e,[this.#Hi,this.#Wi._savesStack,this.#Wi._markedContentStack]),i&&this.#Hi.clear(),this}recordShowTextOperation(t,e=!1){const i=Array.from(this.#Hi);this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const t of i)this.recordIncrementalData("sameLineText",t);return this}bboxToClipBoxDropOperation(t,e=!1){const i=!e&&t===this.#Wi._pendingBBoxIdx;return this.#Wi.bboxToClipBoxDropOperation(t),i&&this.#Hi.clear(),this}take(){return this.#Vi.clear(),this.#Wi.take()}takeDebugMetadata(){return this.#zi}}class Ue{#Gi;#Xi;#Ki;#qi=0;#Yi=0;constructor(t,e,i){if(t instanceof Ue&&t.#Ki===!!i)return t;this.#Gi=t,this.#Xi=e,this.#Ki=!!i}get clipBox(){return this.#Gi.clipBox}growOperationsCount(){throw new Error("Unreachable")}save(t){return this.#Yi++,this.#Gi.save(this.#Xi),this}restore(t){return this.#Yi>0&&(this.#Gi.restore(this.#Xi),this.#Yi--),this}recordOpenMarker(t){return this.#qi++,this}getOpenMarker(){return this.#qi>0?this.#Xi:this.#Gi.getOpenMarker()}recordCloseMarker(t){return this.#qi--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#Gi.pushBaseTransform(t),this}popBaseTransform(){return this.#Gi.popBaseTransform(),this}recordSimpleData(t,e){return this.#Gi.recordSimpleData(t,this.#Xi),this}recordIncrementalData(t,e){return this.#Gi.recordIncrementalData(t,this.#Xi),this}resetIncrementalData(t,e){return this.#Gi.resetIncrementalData(t,this.#Xi),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,i){return this.#Gi.recordSimpleDataFromNamed(t,e,this.#Xi),this}recordFutureForcedDependency(t,e){return this.#Gi.recordFutureForcedDependency(t,this.#Xi),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#Gi.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#Gi.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#Ki||this.#Gi.resetBBox(this.#Xi),this}recordClipBox(t,e,i,n,s,a){return this.#Ki||this.#Gi.recordClipBox(this.#Xi,e,i,n,s,a),this}recordBBox(t,e,i,n,s,a){return this.#Ki||this.#Gi.recordBBox(this.#Xi,e,i,n,s,a),this}recordCharacterBBox(t,e,i,n,s,a,r){return this.#Ki||this.#Gi.recordCharacterBBox(this.#Xi,e,i,n,s,a,r),this}recordFullPageBBox(t){return this.#Ki||this.#Gi.recordFullPageBBox(this.#Xi),this}getSimpleIndex(t){return this.#Gi.getSimpleIndex(t)}recordDependencies(t,e){return this.#Gi.recordDependencies(this.#Xi,e),this}recordNamedDependency(t,e){return this.#Gi.recordNamedDependency(this.#Xi,e),this}recordOperation(t){return this.#Gi.recordOperation(this.#Xi,!0),this}recordShowTextOperation(t){return this.#Gi.recordShowTextOperation(this.#Xi,!0),this}bboxToClipBoxDropOperation(t){return this.#Ki||this.#Gi.bboxToClipBoxDropOperation(this.#Xi,!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}}const He=["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],Ve=["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],ze=["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],$e=["filter","fillColor","fillAlpha"],We=["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],Ge=["transform"],Xe=["transform","fillColor"];class Ke{#Ni;#Ri;#Qi=4;#Zi=0;#ki=new Ke.#Ji(6*this.#Qi);static#Ji=St.isFloat16ArraySupported?Float16Array:Float32Array;constructor(t){this.#Ni=t.width,this.#Ri=t.height}record(t,e,i,n){if(this.#Zi===this.#Qi){this.#Qi*=2;const t=new Ke.#Ji(6*this.#Qi);t.set(this.#ki),this.#ki=t}const s=qt(t);let a;if(n[0]!==1/0){const t=x.slice();Pt.axialAlignedBoundingBox([0,-i,e,0],s,t);const r=Pt.intersect(n,t);if(!r)return;const[o,l,h,d]=r;if(o!==t[0]||l!==t[1]||h!==t[2]||d!==t[3]){const t=Math.atan2(s[1],s[0]),e=Math.abs(Math.sin(t)),i=Math.abs(Math.cos(t));if(e<1e-6||i<1e-6||Math.abs(e-i)<1e-6)a=[o,l,o,d,h,l];else{const t=h-o,n=d-l,s=e*e,r=i*i,c=i*e,u=r-s,p=(n*r-t*c)/u;a=[o+(n*c-t*s)/u,l,o,l+p,h,d-p]}}}a||(a=[0,-i,0,0,e,-i],Pt.applyTransform(a,s,0),Pt.applyTransform(a,s,2),Pt.applyTransform(a,s,4)),a[0]/=this.#Ni,a[1]/=this.#Ri,a[2]/=this.#Ni,a[3]/=this.#Ri,a[4]/=this.#Ni,a[5]/=this.#Ri,this.#ki.set(a,6*this.#Zi),this.#Zi++}take(){return this.#ki.subarray(0,6*this.#Zi)}}class qe{#tn=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.#tn.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}){if(t&&!this.#tn.has(t.loadedName)){if(ct(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:e,src:n,style:s}=t,a=new FontFace(e,n,s);this.addNativeFontFace(a);try{await a.load(),this.#tn.add(e),i?.(t)}catch{ht(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}dt("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 ht(`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 mt(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return mt(this,"isSyncFontLoadingSupported",y||St.platform.isFirefox)}_queueLoadingCallback(t){const{loadingRequests:e}=this,i={done:!1,complete:function(){for(ct(!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 mt(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 n(t,e,i,n){return t.substring(0,e)+n+t.substring(e+i)}let s,a;const r=this._document.createElement("canvas");r.width=1,r.height=1;const o=r.getContext("2d");let l=0;const h=`lt${Date.now()}${this.loadTestFontId++}`;let d=this._loadTestFont;d=n(d,976,h.length,h);const c=1482184792;let u=i(d,16);for(s=0,a=h.length-3;s<a;s+=4)u=u-c+i(h,s)|0;var p;s<h.length&&(u=u-c+i(h+"XXX",s)|0),d=n(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 m=this._document.createElement("div");m.style.visibility="hidden",m.style.width=m.style.height="10px",m.style.position="absolute",m.style.top=m.style.left="0px";for(const e of[t.loadedName,h]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,m.append(t)}this._document.body.append(m),function t(e,i){if(++l>30)return ht("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,()=>{m.remove(),e.complete()})}}class Ye{compiledGlyphs=Object.create(null);#en;constructor(t,e=null,i,n){this.#en=t,this._inspectFont=e,i&&(this.charProcOperatorList=i),n&&Object.assign(this,n)}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,${this.data.toBase64()});`;let e;if(this.cssFontInfo){let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`}else e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];const i=this.loadedName+"_path_"+e;let n;try{n=t.get(i)}catch(t){ht(`getPathGenerator - ignoring character: "${t}".`)}const s=oe(n?.path);return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=s}get black(){return this.#en.black}get bold(){return this.#en.bold}get disableFontFace(){return this.#en.disableFontFace}set disableFontFace(t){mt(this,"disableFontFace",!!t)}get fontExtraProperties(){return this.#en.fontExtraProperties}get isInvalidPDFjsFont(){return this.#en.isInvalidPDFjsFont}get isType3Font(){return this.#en.isType3Font}get italic(){return this.#en.italic}get missingFile(){return this.#en.missingFile}get remeasure(){return this.#en.remeasure}get vertical(){return this.#en.vertical}get ascent(){return this.#en.ascent}get defaultWidth(){return this.#en.defaultWidth}get descent(){return this.#en.descent}get bbox(){return this.#en.bbox}get fontMatrix(){return this.#en.fontMatrix}get fallbackName(){return this.#en.fallbackName}get loadedName(){return this.#en.loadedName}get mimetype(){return this.#en.mimetype}get name(){return this.#en.name}get data(){return this.#en.data}clearData(){this.#en.clearData()}get cssFontInfo(){return this.#en.cssFontInfo}get systemFontInfo(){return this.#en.systemFontInfo}get defaultVMetrics(){return this.#en.defaultVMetrics}}class Qe{static strings=["fontFamily","fontWeight","italicAngle"]}class Ze{static strings=["css","loadedName","baseFontName","src"]}class Je{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static OFFSET_NUMBERS=Math.ceil(2*this.bools.length/8);static OFFSET_BBOX=this.OFFSET_NUMBERS+8*this.numbers.length;static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_DEFAULT_VMETRICS=this.OFFSET_FONT_MATRIX+1+48;static OFFSET_STRINGS=this.OFFSET_DEFAULT_VMETRICS+1+6}class ti{static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16}class ei{#in;#nn=new TextDecoder;#sn;constructor(t){this.#in=t,this.#sn=new DataView(t)}#an(t){ct(t<Qe.strings.length,"Invalid string index");let e=0;for(let i=0;i<t;i++)e+=this.#sn.getUint32(e)+4;const i=this.#sn.getUint32(e);return this.#nn.decode(new Uint8Array(this.#in,e+4,i))}get fontFamily(){return this.#an(0)}get fontWeight(){return this.#an(1)}get italicAngle(){return this.#an(2)}}class ii{#in;#nn=new TextDecoder;#sn;constructor(t){this.#in=t,this.#sn=new DataView(t)}get guessFallback(){return 0!==this.#sn.getUint8(0)}#an(t){ct(t<Ze.strings.length,"Invalid string index");let e=5;for(let i=0;i<t;i++)e+=this.#sn.getUint32(e)+4;const i=this.#sn.getUint32(e);return this.#nn.decode(new Uint8Array(this.#in,e+4,i))}get css(){return this.#an(0)}get loadedName(){return this.#an(1)}get baseFontName(){return this.#an(2)}get src(){return this.#an(3)}get style(){let t=1;t+=4+this.#sn.getUint32(t);const e=this.#sn.getUint32(t),i=this.#nn.decode(new Uint8Array(this.#in,t+4,e));t+=4+e;const n=this.#sn.getUint32(t);return{style:i,weight:this.#nn.decode(new Uint8Array(this.#in,t+4,n))}}}class ni{#in;#nn=new TextDecoder;#sn;constructor({buffer:t,extra:e}){this.#in=t,this.#sn=new DataView(t),e&&Object.assign(this,e)}#rn(t){ct(t<Je.bools.length,"Invalid boolean index");const e=Math.floor(t/4),i=2*t%8,n=this.#sn.getUint8(e)>>i&3;return 0===n?void 0:2===n}get black(){return this.#rn(0)}get bold(){return this.#rn(1)}get disableFontFace(){return this.#rn(2)}get fontExtraProperties(){return this.#rn(3)}get isInvalidPDFjsFont(){return this.#rn(4)}get isType3Font(){return this.#rn(5)}get italic(){return this.#rn(6)}get missingFile(){return this.#rn(7)}get remeasure(){return this.#rn(8)}get vertical(){return this.#rn(9)}#on(t){return ct(t<Je.numbers.length,"Invalid number index"),this.#sn.getFloat64(Je.OFFSET_NUMBERS+8*t)}get ascent(){return this.#on(0)}get defaultWidth(){return this.#on(1)}get descent(){return this.#on(2)}#ln(t,e,i,n){const s=this.#sn.getUint8(t);if(0===s)return;ct(s===e,"Invalid array length."),t+=1;const a=new Array(s);for(let e=0;e<s;e++)a[e]=this.#sn[i](t,!0),t+=n;return a}get bbox(){return this.#ln(Je.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return this.#ln(Je.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return this.#ln(Je.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}#an(t){ct(t<Je.strings.length,"Invalid string index");let e=Je.OFFSET_STRINGS+4;for(let i=0;i<t;i++)e+=this.#sn.getUint32(e)+4;const i=this.#sn.getUint32(e);return this.#nn.decode(new Uint8Array(this.#in,e+4,i))}get fallbackName(){return this.#an(0)}get loadedName(){return this.#an(1)}get mimetype(){return this.#an(2)}get name(){return this.#an(3)}#hn(){let t=Je.OFFSET_STRINGS;t+=4+this.#sn.getUint32(t);t+=4+this.#sn.getUint32(t);t+=4+this.#sn.getUint32(t);return{offset:t,length:this.#sn.getUint32(t)}}get data(){const{offset:t,length:e}=this.#hn();return 0===e?void 0:new Uint8Array(this.#in,t+4,e)}clearData(){const{offset:t,length:e}=this.#hn();0!==e&&(this.#sn.setUint32(t,0),this.#in=new Uint8Array(this.#in,0,t+4).slice().buffer,this.#sn=new DataView(this.#in))}get cssFontInfo(){let t=Je.OFFSET_STRINGS;t+=4+this.#sn.getUint32(t);t+=4+this.#sn.getUint32(t);const e=this.#sn.getUint32(t);if(0===e)return null;const i=new Uint8Array(e);return i.set(new Uint8Array(this.#in,t+4,e)),new ei(i.buffer)}get systemFontInfo(){let t=Je.OFFSET_STRINGS;t+=4+this.#sn.getUint32(t);const e=this.#sn.getUint32(t);if(0===e)return null;const i=new Uint8Array(e);return i.set(new Uint8Array(this.#in,t+4,e)),new ii(i.buffer)}}class si{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){const t=this.view,e=this.data[ti.KIND],i=!!this.data[ti.HAS_BBOX],n=!!this.data[ti.HAS_BACKGROUND],s=t.getUint32(ti.N_COORD,!0),a=t.getUint32(ti.N_COLOR,!0),r=t.getUint32(ti.N_STOP,!0);let o=20;const l=new Float32Array(this.buffer,o,2*s);o+=8*s;const h=new Uint8Array(this.buffer,o,4*a);o+=4*a;const d=[];for(let e=0;e<r;++e){const e=t.getFloat32(o,!0);o+=4;const i=t.getUint32(o,!0);o+=4,d.push([e,`#${i.toString(16).padStart(6,"0")}`])}let c=null;if(i){c=[];for(let e=0;e<4;++e)c.push(t.getFloat32(o,!0)),o+=4}let u=null;if(n&&(u=new Uint8Array(this.buffer,o,3),o+=3),1===e)return["RadialAxial","axial",c,d,Array.from(l.slice(0,2)),Array.from(l.slice(2,4)),null,null];if(2===e)return["RadialAxial","radial",c,d,[l[0],l[1]],[l[3],l[4]],l[2],l[5]];if(3===e){const t=this.data[ti.SHADING_TYPE];let e=null;if(l.length>0){e=x.slice();for(let t=0,i=l.length;t<i;t+=2)Pt.pointBoundingBox(l[t],l[t+1],e)}return["Mesh",t,l,h,s,e,c,u]}throw new Error(`Unsupported pattern kind: ${e}`)}}class ai{#in;constructor(t){this.#in=t}get path(){return St.isFloat16ArraySupported?new Float16Array(this.#in):new Float32Array(this.#in)}}function ri(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}const oi=t=>"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,li=function(t,e,i){if(!Array.isArray(i)||i.length<2)return!1;const[n,s,...a]=i;if(!t(n)&&!Number.isInteger(n))return!1;if(!e(s))return!1;const r=a.length;let o=!0;switch(s.name){case"XYZ":if(r<2||r>3)return!1;break;case"Fit":case"FitB":return 0===r;case"FitH":case"FitBH":case"FitV":case"FitBV":if(r>1)return!1;break;case"FitR":if(4!==r)return!1;o=!1;break;default:return!1}for(const t of a)if(!("number"==typeof t||o&&null===t))return!1;return!0}.bind(null,oi,t=>"object"==typeof t&&"string"==typeof t?.name);class hi{#dn=new Map;#cn=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#cn.then(()=>{for(const[t]of this.#dn)t.call(this,i)})}addEventListener(t,e,i=null){let n=null;if(i?.signal instanceof AbortSignal){const{signal:s}=i;if(s.aborted)return void ht("LoopbackPort - cannot use an `aborted` signal.");const a=()=>this.removeEventListener(t,e);n=()=>s.removeEventListener("abort",a),s.addEventListener("abort",a)}this.#dn.set(e,n)}removeEventListener(t,e){const i=this.#dn.get(e);i?.(),this.#dn.delete(e)}terminate(){for(const[,t]of this.#dn)t?.();this.#dn.clear()}}const di=1,ci=2,ui=1,pi=2,gi=3,mi=4,fi=5,bi=6,vi=7,wi=8;function yi(){}function xi(t){if(t instanceof At||t instanceof wt||t instanceof bt||t instanceof yt||t instanceof vt)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||dt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new At(t.message);case"InvalidPDFException":return new wt(t.message);case"PasswordException":return new bt(t.message,t.code);case"ResponseException":return new yt(t.message,t.status,t.missing);case"UnknownErrorException":return new vt(t.message,t.details)}return new vt(t.message,t.toString())}class Ai{#un=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.#pn.bind(this),{signal:this.#un.signal})}#pn({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#gn(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===di)i.resolve(t.data);else{if(t.callback!==ci)throw new Error("Unexpected callback case");i.reject(xi(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,n=t.sourceName,s=this.comObj;return void Promise.try(e,t.data).then(function(e){s.postMessage({sourceName:i,targetName:n,callback:di,callbackId:t.callbackId,data:e})},function(e){s.postMessage({sourceName:i,targetName:n,callback:ci,callbackId:t.callbackId,reason:xi(e)})})}t.streamId?this.#mn(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 n=this.callbackId++,s=Promise.withResolvers();this.callbackCapabilities[n]=s;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:n,data:e},i)}catch(t){s.reject(t)}return s.promise}sendWithStream(t,e,i,n){const s=this.streamId++,a=this.sourceName,r=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{const l=Promise.withResolvers();return this.streamControllers[s]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:a,targetName:r,action:t,streamId:s,data:e,desiredSize:i.desiredSize},n),l.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[s].pullCall=e,o.postMessage({sourceName:a,targetName:r,stream:bi,streamId:s,desiredSize:t.desiredSize}),e.promise},cancel:t=>{ct(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[s].cancelCall=e,this.streamControllers[s].isClosed=!0,o.postMessage({sourceName:a,targetName:r,stream:ui,streamId:s,reason:xi(t)}),e.promise}},i)}#mn(t){const e=t.streamId,i=this.sourceName,n=t.sourceName,s=this.comObj,a=this,r=this.actionHandler[t.action],o={enqueue(t,a=1,r){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=a,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),s.postMessage({sourceName:i,targetName:n,stream:mi,streamId:e,chunk:t},r)},close(){this.isCancelled||(this.isCancelled=!0,s.postMessage({sourceName:i,targetName:n,stream:gi,streamId:e}),delete a.streamSinks[e])},error(t){ct(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,s.postMessage({sourceName:i,targetName:n,stream:fi,streamId:e,reason:xi(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(r,t.data,o).then(function(){s.postMessage({sourceName:i,targetName:n,stream:wi,streamId:e,success:!0})},function(t){s.postMessage({sourceName:i,targetName:n,stream:wi,streamId:e,reason:xi(t)})})}#gn(t){const e=t.streamId,i=this.sourceName,n=t.sourceName,s=this.comObj,a=this.streamControllers[e],r=this.streamSinks[e];switch(t.stream){case wi:t.success?a.startCall.resolve():a.startCall.reject(xi(t.reason));break;case vi:t.success?a.pullCall.resolve():a.pullCall.reject(xi(t.reason));break;case bi:if(!r){s.postMessage({sourceName:i,targetName:n,stream:vi,streamId:e,success:!0});break}r.desiredSize<=0&&t.desiredSize>0&&r.sinkCapability.resolve(),r.desiredSize=t.desiredSize,Promise.try(r.onPull||yi).then(function(){s.postMessage({sourceName:i,targetName:n,stream:vi,streamId:e,success:!0})},function(t){s.postMessage({sourceName:i,targetName:n,stream:vi,streamId:e,reason:xi(t)})});break;case mi:if(ct(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case gi:if(ct(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),this.#fn(a,e);break;case fi:ct(a,"error should have stream controller"),a.controller.error(xi(t.reason)),this.#fn(a,e);break;case pi:t.success?a.cancelCall.resolve():a.cancelCall.reject(xi(t.reason)),this.#fn(a,e);break;case ui:if(!r)break;const o=xi(t.reason);Promise.try(r.onCancel||yi,o).then(function(){s.postMessage({sourceName:i,targetName:n,stream:pi,streamId:e,success:!0})},function(t){s.postMessage({sourceName:i,targetName:n,stream:pi,streamId:e,reason:xi(t)})}),r.sinkCapability.reject(o),r.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#fn(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#un?.abort(),this.#un=null}}class Ci{#bn=Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"});constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:i=null}){this.cMapUrl=t,this.standardFontDataUrl=e,this.wasmUrl=i}async fetch({kind:t,filename:e}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:dt(`Not implemented: ${t}`)}const i=this[t];if(!i)throw new Error(`Ensure that the \`${t}\` API parameter is provided.`);const n=`${i}${e}`;return this._fetch(n,t).catch(e=>{throw new Error(`Unable to load ${this.#bn[t]} data at: ${n}`)})}async _fetch(t,e){dt("Abstract method `_fetch` called.")}}class Si extends Ci{async _fetch(t,e){const i="cMapUrl"!==e||t.endsWith(".bcmap")?"bytes":"text",n=await Ot(t,i);return n instanceof Uint8Array?n:Ct(n)}}class Pi{#vn=!1;constructor({enableHWA:t=!1}){this.#vn=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.#vn})}}reset({canvas:t},e,i){if(!t)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.width=e,t.height=i}destroy(t){const{canvas:e}=t;if(!e)throw new Error("Canvas is not specified");e.width=e.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){dt("Abstract method `_createCanvas` called.")}}class _i extends Pi{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}}class Ei{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addKnockoutFilter(t=0){return"none"}addHighlightHCMFilter(t,e,i,n,s){return"none"}addSelectionHCMFilter(t,e){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(t=null){return null}destroy(t=!1){}}class Ti extends Ei{#wn;#yn;#xn;#An;#Cn;#Sn;#_=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#An=t,this.#Cn=e}get#T(){return this.#yn||=new Map}get#Pn(){return this.#Sn||=new Map}get#_n(){if(!this.#xn){const t=this.#Cn.createElement("div"),{style:e}=t;e.colorScheme="only light",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.#Cn.createElementNS(P,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#xn=this.#Cn.createElementNS(P,"defs"),t.append(i),i.append(this.#xn),this.#Cn.body.append(t)}return this.#xn}#En(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 n=i.join(",");return[n,n,n]}const[e,i,n]=t,s=new Array(256),a=new Array(256),r=new Array(256);for(let t=0;t<256;t++)s[t]=e[t]/255,a[t]=i[t]/255,r[t]=n[t]/255;return[s.join(","),a.join(","),r.join(",")]}#Tn(t){if(void 0===this.#wn){this.#wn="";const t=this.#Cn.URL;t!==this.#Cn.baseURI&&(jt(t)?ht('#createUrl: ignore "data:"-URL for performance reasons.'):this.#wn=pt(t,""))}return`url(${this.#wn}#${t})`}addFilter(t){if(!t)return"none";let e=this.#T.get(t);if(e)return e;const[i,n,s]=this.#En(t),a=1===t.length?i:`${i}${n}${s}`;if(e=this.#T.get(a),e)return this.#T.set(t,e),e;const r=`g_${this.#An}_transfer_map_${this.#_++}`,o=this.#Tn(r);this.#T.set(t,o),this.#T.set(a,o);const l=this.#Mn(r);return this.#kn(i,n,s,l),o}addHCMFilter(t,e){const i=`${t}-${e}`,n="base";let s=this.#Pn.get(n);if(s?.key===i)return s.url;if(s?(s.filter?.remove(),s.key=i,s.url="none",s.filter=null):(s={key:i,url:"none",filter:null},this.#Pn.set(n,s)),!t||!e)return s.url;const a=this.#Dn(t);t=Pt.makeHexColor(...a);const r=this.#Dn(e);if(e=Pt.makeHexColor(...r),this.#_n.style.color="","#000000"===t&&"#ffffff"===e||t===e)return s.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.#An}_hcm_filter`,d=s.filter=this.#Mn(h);this.#kn(l,l,l,d),this.#In(d);const c=(t,e)=>{const i=a[t]/255,n=r[t]/255,s=new Array(e+1);for(let t=0;t<=e;t++)s[t]=i+t/e*(n-i);return s.join(",")};return this.#kn(c(0,5),c(1,5),c(2,5),d),s.url=this.#Tn(h),s.url}addSelectionHCMFilter(t,e){return this.addHighlightHCMFilter("selection",t,e,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(t=null){const e=t?this.addSelectionHCMFilter(t.foreground,t.background):this.addSelectionFilter();return"none"!==e&&St.platform.isFirefox?{"backdrop-filter":e,"background-color":"transparent"}:null}addAlphaFilter(t){let e=this.#T.get(t);if(e)return e;const[i]=this.#En([t]),n=`alpha_${i}`;if(e=this.#T.get(n),e)return this.#T.set(t,e),e;const s=`g_${this.#An}_alpha_map_${this.#_++}`,a=this.#Tn(s);this.#T.set(t,a),this.#T.set(n,a);const r=this.#Mn(s);return this.#Ln(i,r),a}addLuminosityFilter(t){let e,i,n=this.#T.get(t||"luminosity");if(n)return n;if(t?([e]=this.#En([t]),i=`luminosity_${e}`):i="luminosity",n=this.#T.get(i),n)return this.#T.set(t,n),n;const s=`g_${this.#An}_luminosity_map_${this.#_++}`,a=this.#Tn(s);this.#T.set(t,a),this.#T.set(i,a);const r=this.#Mn(s);return this.#Nn(r),t&&this.#Ln(e,r),a}addKnockoutFilter(t=0){const e=t>0?Math.min(1/t,1e6):1e6,i=`knockout_${e}`,n=this.#T.get(i);if(n)return n;const s=`g_${this.#An}_knockout_filter_${this.#_++}`,a=this.#Tn(s);this.#T.set(i,a);const r=this.#Mn(s),o=this.#Cn.createElementNS(P,"feComponentTransfer");r.append(o);const l=this.#Cn.createElementNS(P,"feFuncA");return l.setAttribute("type","linear"),l.setAttribute("slope",`${e}`),l.setAttribute("intercept","0"),o.append(l),a}addHighlightHCMFilter(t,e,i,n,s){const a=`${e}-${i}-${n}-${s}`;let r=this.#Pn.get(t);if(r?.key===a)return r.url;if(r?(r.filter?.remove(),r.key=a,r.url="none",r.filter=null):(r={key:a,url:"none",filter:null},this.#Pn.set(t,r)),!e||!i)return r.url;const[o,l]=[e,i].map(this.#Dn.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]=[n,s].map(this.#Rn.bind(this));d<h&&([h,d,c,u]=[d,h,u,c]),this.#_n.style.color="";const p=(t,e,i)=>{const n=new Array(256),s=(d-h)/i,a=t/255,r=(e-t)/(255*i);let o=0;for(let t=0;t<=i;t++){const e=Math.round(h+t*s),i=a+t*r;for(let t=o;t<=e;t++)n[t]=i;o=e+1}for(let t=o;t<256;t++)n[t]=n[o-1];return n.join(",")},g=`g_${this.#An}_hcm_${t}_filter`,m=r.filter=this.#Mn(g);return this.#In(m),this.#kn(p(c[0],u[0],5),p(c[1],u[1],5),p(c[2],u[2],5),m),r.url=this.#Tn(g),r.url}destroy(t=!1){t&&this.#Sn?.size||(this.#xn?.parentNode.parentNode.remove(),this.#xn=null,this.#yn?.clear(),this.#yn=null,this.#Sn?.clear(),this.#Sn=null,this.#_=0)}#Nn(t){const e=this.#Cn.createElementNS(P,"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)}#In(t){const e=this.#Cn.createElementNS(P,"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)}#Mn(t){const e=this.#Cn.createElementNS(P,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#_n.append(e),e}#Fn(t,e,i){const n=this.#Cn.createElementNS(P,e);n.setAttribute("type","discrete"),n.setAttribute("tableValues",i),t.append(n)}#kn(t,e,i,n){const s=this.#Cn.createElementNS(P,"feComponentTransfer");n.append(s),this.#Fn(s,"feFuncR",t),this.#Fn(s,"feFuncG",e),this.#Fn(s,"feFuncB",i)}#Ln(t,e){const i=this.#Cn.createElementNS(P,"feComponentTransfer");e.append(i),this.#Fn(i,"feFuncA",t)}#Dn(t){return this.#_n.style.color=t,Kt(getComputedStyle(this.#_n).getPropertyValue("color"))}#On(t){return this.#_n.style.color=t,Xt(getComputedStyle(this.#_n).getPropertyValue("color"))}#Rn(t){const[e,i,n,s]=this.#On(t);if(1===s)return[e,i,n];const[a,r,o]=this.#Dn("Canvas");return[Mi(e,a,s),Mi(i,r,s),Mi(n,o,s)]}}function Mi(t,e,i){return Math.round(i*t+(1-i)*e)}y&&ht("Please use the `legacy` build in Node.js environments.");class ki extends Ei{}class Di extends Pi{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire("undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:s&&"SCRIPT"===s.tagName.toUpperCase()&&s.src||new URL("index.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(t,e)}}class Ii extends Ci{async _fetch(t,e){return async function(t){const e=process.getBuiltinModule("fs/promises"),i=await e.readFile(t);return new Uint8Array(i)}(t)}}const Li=new class{#Bn=null;#jn=null;#Un=null;#Hn=null;async#Vn(){if(!globalThis.navigator?.gpu)return!1;try{const t=await navigator.gpu.requestAdapter();return!!t&&(this.#Hn=navigator.gpu.getPreferredCanvasFormat(),this.#jn=await t.requestDevice(),!0)}catch{return!1}}init(){return this.#Bn||=this.#Vn()}get isReady(){return null!==this.#jn}loadMeshShader(){if(!this.#jn||this.#Un)return;const t=this.#jn.createShaderModule({code:"\nstruct Uniforms {\n offsetX : f32,\n offsetY : f32,\n scaleX : f32,\n scaleY : f32,\n paddedWidth : f32,\n paddedHeight : f32,\n borderSize : f32,\n _pad : f32,\n};\n\n@group(0) @binding(0) var<uniform> u : Uniforms;\n\nstruct VertexInput {\n @location(0) position : vec2<f32>,\n @location(1) color : vec4<f32>,\n};\n\nstruct VertexOutput {\n @builtin(position) position : vec4<f32>,\n @location(0) color : vec3<f32>,\n};\n\n@vertex\nfn vs_main(in : VertexInput) -> VertexOutput {\n var out : VertexOutput;\n let cx = (in.position.x + u.offsetX) * u.scaleX;\n let cy = (in.position.y + u.offsetY) * u.scaleY;\n out.position = vec4<f32>(\n ((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,\n 1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,\n 0.0,\n 1.0\n );\n out.color = in.color.rgb;\n return out;\n}\n\n@fragment\nfn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {\n return vec4<f32>(in.color, 1.0);\n}\n"});this.#Un=this.#jn.createRenderPipeline({layout:"auto",vertex:{module:t,entryPoint:"vs_main",buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:t,entryPoint:"fs_main",targets:[{format:this.#Hn}]},primitive:{topology:"triangle-list"}})}draw(t,e,i,n,s,a,r,o){this.loadMeshShader();const l=this.#jn,{offsetX:h,offsetY:d,scaleX:c,scaleY:u}=n,p=l.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&l.queue.writeBuffer(p,0,t);const g=l.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&l.queue.writeBuffer(g,0,e);const m=l.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});l.queue.writeBuffer(m,0,new Float32Array([h,d,c,u,a,r,o,0]));const f=l.createBindGroup({layout:this.#Un.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:m}}]}),b=new OffscreenCanvas(a,r),v=b.getContext("webgpu");v.configure({device:l,format:this.#Hn,alphaMode:s?"opaque":"premultiplied"});const w=s?{r:s[0]/255,g:s[1]/255,b:s[2]/255,a:1}:{r:0,g:0,b:0,a:0},y=l.createCommandEncoder(),x=y.beginRenderPass({colorAttachments:[{view:v.getCurrentTexture().createView(),clearValue:w,loadOp:"clear",storeOp:"store"}]});return i>0&&(x.setPipeline(this.#Un),x.setBindGroup(0,f),x.setVertexBuffer(0,p),x.setVertexBuffer(1,g),x.draw(i)),x.end(),l.queue.submit([y.finish()]),p.destroy(),g.destroy(),m.destroy(),b.transferToImageBitmap()}};const Ni="Fill",Ri="Stroke",Fi="Shading";function Oi(t,e){if(!e)return;const i=e[2]-e[0],n=e[3]-e[1],s=new Path2D;s.rect(e[0],e[1],i,n),t.clip(s)}class Bi{isModifyingCurrentTransform(){return!1}getPattern(){dt("Abstract method `getPattern` called.")}}class ji extends Bi{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}isOriginBased(){return 0===this._p0[0]&&0===this._p0[1]&&(!this.isRadial()||0===this._p1[0]&&0===this._p1[1])}isRadial(){return"radial"===this._type}areConic(){if(!this.isRadial())return!1;const t=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return t+this._r1>this._r0&&t+this._r0>this._r1}_createGradient(t,e=null){let i,n=this._p0,s=this._p1;if(e&&(n=n.slice(),s=s.slice(),Pt.applyTransform(n,e),Pt.applyTransform(s,e)),"axial"===this._type)i=t.createLinearGradient(n[0],n[1],s[0],s[1]);else if("radial"===this._type){let a=this._r0,r=this._r1;if(e){const t=new Float32Array(2);Pt.singularValueDecompose2dScale(e,t),a*=t[0],r*=t[0]}i=t.createRadialGradient(n[0],n[1],a,s[0],s[1],r)}for(const t of this._colorStops)i.addColorStop(t[0],t[1]);return i}_createReversedGradient(t,e=null){let i=this._p1,n=this._p0;e&&(i=i.slice(),n=n.slice(),Pt.applyTransform(i,e),Pt.applyTransform(n,e));let s=this._r1,a=this._r0;if(e){const t=new Float32Array(2);Pt.singularValueDecompose2dScale(e,t),s*=t[0],a*=t[0]}const r=t.createRadialGradient(i[0],i[1],s,n[0],n[1],a),o=this._colorStops.map(([t,e])=>[1-t,e]).reverse();for(const[t,e]of o)r.addColorStop(t,e);return r}getPattern(t,e,i,n){let s;if(n===Ri||n===Ni){if(this.isOriginBased()){let n=Pt.transform(i,e.baseTransform);this.matrix&&(n=Pt.transform(n,this.matrix));const s=.001,a=Math.hypot(n[0],n[1]),r=Math.hypot(n[2],n[3]),o=(n[0]*n[2]+n[1]*n[3])/(a*r);if(Math.abs(o)<s){if(!this.isRadial())return this._createGradient(t,n);if(Math.abs(a-r)<s)return this._createGradient(t,n)}}const a=e.current.getClippedPathBoundingBox(n,qt(t))||[0,0,0,0],r=Math.ceil(a[2]-a[0])||1,o=Math.ceil(a[3]-a[1])||1,l=e.canvasFactory.create(r,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(-a[0],-a[1]),i=Pt.transform(i,[1,0,0,1,a[0],a[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),Oi(h,this._bbox),this.areConic()&&(h.fillStyle=this._createReversedGradient(h),h.fill()),h.fillStyle=this._createGradient(h),h.fill(),s=t.createPattern(l.canvas,"no-repeat"),e.canvasFactory.destroy(l);const d=new DOMMatrix(i);s.setTransform(d)}else this.areConic()&&(t.save(),Oi(t,this._bbox),t.fillStyle=this._createReversedGradient(t),t.fillRect(-1e10,-1e10,2e10,2e10),t.restore()),Oi(t,this._bbox),s=this._createGradient(t);return s}}function Ui(t,e,i,n,s,a,r,o){const l=e.coords,h=e.colors,d=t.data,c=4*t.width;let u;l[2*i+1]>l[2*n+1]&&(u=i,i=n,n=u,u=a,a=r,r=u),l[2*n+1]>l[2*s+1]&&(u=n,n=s,s=u,u=r,r=o,o=u),l[2*i+1]>l[2*n+1]&&(u=i,i=n,n=u,u=a,a=r,r=u);const p=(l[2*i]+e.offsetX)*e.scaleX,g=(l[2*i+1]+e.offsetY)*e.scaleY,m=(l[2*n]+e.offsetX)*e.scaleX,f=(l[2*n+1]+e.offsetY)*e.scaleY,b=(l[2*s]+e.offsetX)*e.scaleX,v=(l[2*s+1]+e.offsetY)*e.scaleY;if(g>=v)return;const w=h[4*a],y=h[4*a+1],x=h[4*a+2],A=h[4*r],C=h[4*r+1],S=h[4*r+2],P=h[4*o],_=h[4*o+1],E=h[4*o+2],T=Math.round(g),M=Math.round(v);let k,D,I,L,N,R,F,O;for(let t=T;t<=M;t++){if(t<f){const e=t<g?0:(g-t)/(g-f);k=p-(p-m)*e,D=w-(w-A)*e,I=y-(y-C)*e,L=x-(x-S)*e}else{let e;e=t>v?1:f===v?0:(f-t)/(f-v),k=m-(m-b)*e,D=A-(A-P)*e,I=C-(C-_)*e,L=S-(S-E)*e}let e;e=t<g?0:t>v?1:(g-t)/(g-v),N=p-(p-b)*e,R=w-(w-P)*e,F=y-(y-_)*e,O=x-(x-E)*e;const i=Math.round(Math.min(k,N)),n=Math.round(Math.max(k,N));let s=c*t+4*i;for(let t=i;t<=n;t++)e=(k-t)/(k-N),e<0?e=0:e>1&&(e=1),d[s++]=D-(D-R)*e|0,d[s++]=I-(I-F)*e|0,d[s++]=L-(L-O)*e|0,d[s++]=255}}class Hi extends Bi{constructor(t){super(),this._posData=t[2],this._colData=t[3],this._vertexCount=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null,Li.loadMeshShader()}_createMeshCanvas(t,e,i){const n=Math.floor(this._bounds[0]),s=Math.floor(this._bounds[1]),a=Math.ceil(this._bounds[2])-n,r=Math.ceil(this._bounds[3])-s,o=Math.min(Math.ceil(Math.abs(a*t[0]*1.1)),3e3)||1,l=Math.min(Math.ceil(Math.abs(r*t[1]*1.1)),3e3)||1,h=a?a/o:1,d=r?r/l:1,c={coords:this._posData,colors:this._colData,offsetX:-n,offsetY:-s,scaleX:1/h,scaleY:1/d},u=o+4,p=l+4,g=i.create(u,p);if(Li.isReady&&this._vertexCount>48)g.context.drawImage(function(t,e,i,n,s,a,r,o){return Li.draw(t,e,i,n,s,a,r,o)}(this._posData,this._colData,this._vertexCount,c,e,u,p,2),0,0);else{const t=g.context.createImageData(o,l);if(e){const i=t.data;for(let t=0,n=i.length;t<n;t+=4)i[t]=e[0],i[t+1]=e[1],i[t+2]=e[2],i[t+3]=255}for(let e=0,i=this._vertexCount;e<i;e+=3)Ui(t,c,e,e+1,e+2,e,e+1,e+2);g.context.putImageData(t,2,2)}return{canvas:g.canvas,offsetX:n-2*h,offsetY:s-2*d,scaleX:h,scaleY:d}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,n){Oi(t,this._bbox);const s=new Float32Array(2);if(n===Fi)Pt.singularValueDecompose2dScale(qt(t),s);else if(this.matrix){Pt.singularValueDecompose2dScale(this.matrix,s);const[t,i]=s;Pt.singularValueDecompose2dScale(e.baseTransform,s),s[0]*=t,s[1]*=i}else Pt.singularValueDecompose2dScale(e.baseTransform,s);const a=this._createMeshCanvas(s,n===Fi?null:this._background,e.canvasFactory);n!==Fi&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY);const r=t.createPattern(a.canvas,"no-repeat");return e.canvasFactory.destroy(a),r}}class Vi extends Bi{getPattern(){return"hotpink"}}const zi=1,$i=2;class Wi{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,n){this.color=t[1],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.needsIsolation=t[9]??!0,this.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=n,this.patternBaseMatrix=this.matrix?Pt.transform(n,this.matrix):n}canSkipPatternCanvas([t,e,i,n]){const[s,a,r,o]=this.bbox,l=Math.abs(this.xstep),h=Math.abs(this.ystep);if(t>l+1e-6||e>h+1e-6)return null;const d=Math.floor((i-r)/l)+1,c=Math.ceil((i+t-s)/l)-1,u=Math.floor((n-o)/h)+1,p=Math.ceil((n+e-a)/h)-1;return c<=d&&p<=u?[d,u]:null}updatePatternDims(t,e){const i=Pt.inverseTransform(this.patternBaseMatrix),n=[t[0],t[1]],s=[t[2],t[3]];Pt.applyTransform(n,i),Pt.applyTransform(s,i),e[0]=Math.abs(s[0]-n[0]),e[1]=Math.abs(s[1]-n[1]),e[2]=Math.min(n[0],s[0]),e[3]=Math.min(n[1],s[1])}_renderTileCanvas(t,e,i,n){const[s,a,r,o]=this.bbox,l=t.canvasFactory.create(i.size,n.size),h=l.context,d=this.canvasGraphicsFactory.createCanvasGraphics(h,e);return d.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(d,this.paintType,this.color),h.translate(-i.scale*s,-n.scale*a),d.transform(0,i.scale,0,0,n.scale,0,0),h.save(),d.dependencyTracker?.save(),this.clipBbox(d,s,a,r,o),d.baseTransform=qt(d.ctx),d.executeOperatorList(this.operatorList),d.endDrawing(),d.dependencyTracker?.restore(),h.restore(),l}_getCombinedScales(){const t=new Float32Array(2);Pt.singularValueDecompose2dScale(this.matrix,t);const[e,i]=t;return Pt.singularValueDecompose2dScale(this.baseTransform,t),[e*t[0],i*t[1]]}drawPattern(t,e,i=!1,[n,s],a){const[r,o,l,h]=this.bbox,d=t.dependencyTracker;if(d&&(t.dependencyTracker=new Ue(d,a)),t.save(),i?t.ctx.clip(e,"evenodd"):t.ctx.clip(e),t.ctx.setTransform(...this.patternBaseMatrix),t.ctx.translate(n*this.xstep,s*this.ystep),this.needsIsolation||1!==t.ctx.globalAlpha||"source-over"!==t.ctx.globalCompositeOperation||t.inSMaskMode){const e=l-r,i=h-o,[n,s]=this._getCombinedScales(),d=this.getSizeAndScale(e,this.ctx.canvas.width,n),c=this.getSizeAndScale(i,this.ctx.canvas.height,s),u=this._renderTileCanvas(t,a,d,c);t.ctx.drawImage(u.canvas,r,o,e,i),t.canvasFactory.destroy(u)}else this.setFillAndStrokeStyleToContext(t,this.paintType,this.color),this.clipBbox(t,r,o,l,h),t.baseTransformStack.push(t.baseTransform),t.baseTransform=qt(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();t.restore(),d&&(t.dependencyTracker=d)}createPatternCanvas(t,e){const[i,n,s,a]=this.bbox,r=s-i,o=a-n;let{xstep:l,ystep:h}=this;l=Math.abs(l),h=Math.abs(h),lt("TilingType: "+this.tilingType);const[d,c]=this._getCombinedScales();let u=r,p=o,g=!1,m=!1;Math.ceil(l*d)>=Math.ceil(r*d)?u=l:g=!0,Math.ceil(h*c)>=Math.ceil(o*c)?p=h:m=!0;const f=this.getSizeAndScale(u,this.ctx.canvas.width,d),b=this.getSizeAndScale(p,this.ctx.canvas.height,c),v=this._renderTileCanvas(t,e,f,b);if(g||m){const e=v.canvas;g&&(u=l),m&&(p=h);const s=this.getSizeAndScale(u,this.ctx.canvas.width,d),a=this.getSizeAndScale(p,this.ctx.canvas.height,c),f=s.size,b=a.size,w=t.canvasFactory.create(f,b),y=w.context,x=g?Math.floor(r/l):0,A=m?Math.floor(o/h):0;for(let t=0;t<=x;t++)for(let i=0;i<=A;i++)y.drawImage(e,f*t,b*i,f,b,0,0,f,b);return t.canvasFactory.destroy(v),{canvas:w.canvas,canvasEntry:w,scaleX:s.scale,scaleY:a.scale,offsetX:i,offsetY:n}}return{canvas:v.canvas,canvasEntry:v,scaleX:f.scale,scaleY:b.scale,offsetX:i,offsetY:n}}getSizeAndScale(t,e,i){const n=Math.max(Wi.MAX_PATTERN_SIZE,e);let s=Math.ceil(t*i);return s>=n?s=n:i=s/t,{scale:i,size:s}}clipBbox(t,e,i,n,s){const a=n-e,r=s-i,o=new Path2D;o.rect(e,i,a,r),Pt.axialAlignedBoundingBox([e,i,n,s],qt(t.ctx),t.current.minMax),t.ctx.clip(o),t.current.updateClipFromPath()}setFillAndStrokeStyleToContext(t,e,i){const n=t.ctx,s=t.current;switch(s.patternFill=s.patternStroke=!1,e){case zi:const{fillStyle:t,strokeStyle:a}=this.ctx;n.fillStyle=s.fillColor=t,n.strokeStyle=s.strokeColor=a;break;case $i:n.fillStyle=n.strokeStyle=i,s.fillColor=s.strokeColor=i;break;default:throw new xt(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,n,s){const a=n!==Fi?Pt.transform(i,this.patternBaseMatrix):i,r=this.createPatternCanvas(e,s);let o=new DOMMatrix(a);o=o.translate(r.offsetX,r.offsetY),o=o.scale(1/r.scaleX,1/r.scaleY);const l=t.createPattern(r.canvas,"repeat");return e.canvasFactory.destroy(r.canvasEntry),l.setTransform(o),l}}function Gi({src:t,srcPos:e=0,dest:i,width:n,height:s,nonBlackColor:a=4294967295,inverseDecode:r=!1}){const o=St.isLittleEndian?4278190080:255,[l,h]=r?[a,o]:[o,a],d=n>>3,c=7&n,u=l^h,p=t.length;i=new Uint32Array(i.buffer);let g=0;for(let n=0;n<s;++n){for(const n=e+d;e<n;++e,g+=8){const n=t[e];i[g]=l^-(n>>7&1)&u,i[g+1]=l^-(n>>6&1)&u,i[g+2]=l^-(n>>5&1)&u,i[g+3]=l^-(n>>4&1)&u,i[g+4]=l^-(n>>3&1)&u,i[g+5]=l^-(n>>2&1)&u,i[g+6]=l^-(n>>1&1)&u,i[g+7]=l^-(1&n)&u}if(0===c)continue;const n=e<p?t[e++]:255;for(let t=0;t<c;++t,++g)i[g]=l^-(n>>7-t&1)&u}return{srcPos:e,destPos:g}}const Xi=16,Ki=new DOMMatrix,qi=new Float32Array(2);function Yi(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");const i=new Map;for(const n of["save","restore","rotate","scale","translate","transform","setTransform","resetTransform","clip","moveTo","lineTo","bezierCurveTo","quadraticCurveTo","arc","arcTo","ellipse","rect","roundRect","closePath","beginPath"]){const s=t[n];"function"==typeof s&&"function"==typeof e[n]&&(i.set(n,s),t[n]=function(...t){return e[n](...t),s.apply(this,t)})}t._removeMirroring=()=>{for(const[e,n]of i)t[e]=n;delete t._removeMirroring}}function Qi(t,e,i,n,s,a,r,o,l,h){const[d,c,u,p,g,m]=qt(t);if(0===c&&0===u){const f=r*d+g,b=Math.round(f),v=o*p+m,w=Math.round(v),y=(r+l)*d+g,x=Math.abs(Math.round(y)-b)||1,A=(o+h)*p+m,C=Math.abs(Math.round(A)-w)||1;return t.setTransform(Math.sign(d),0,0,Math.sign(p),b,w),t.drawImage(e,i,n,s,a,0,0,x,C),t.setTransform(d,c,u,p,g,m),[x,C]}if(0===d&&0===p){const f=o*u+g,b=Math.round(f),v=r*c+m,w=Math.round(v),y=(o+h)*u+g,x=Math.abs(Math.round(y)-b)||1,A=(r+l)*c+m,C=Math.abs(Math.round(A)-w)||1;return t.setTransform(0,Math.sign(c),Math.sign(u),0,b,w),t.drawImage(e,i,n,s,a,0,0,C,x),t.setTransform(d,c,u,p,g,m),[C,x]}t.drawImage(e,i,n,s,a,r,o,l,h);return[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class Zi{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=C;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=j;textRise=0;fillColor="#000000";strokeColor="#000000";tilingPatternDims=null;patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";minMax=A.slice();constructor(t,e){this.clipBox=new Float32Array([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=this.tilingPatternDims?.slice(),t}getPathBoundingBox(t=Ni,e=null){const i=this.minMax.slice();if(t===Ri){e||dt("Stroke bounding box must include transform."),Pt.singularValueDecompose2dScale(e,qi);const t=qi[0]*this.lineWidth/2,n=qi[1]*this.lineWidth/2;i[0]-=t,i[1]-=n,i[2]+=t,i[3]+=n}return i}updateClipFromPath(){const t=Pt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(A,0)}getClippedPathBoundingBox(t=Ni,e=null){return Pt.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Ji(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,n=e.width,s=i%Xi,a=(i-s)/Xi,r=0===s?a:a+1,o=t.createImageData(n,Xi);let l,h=0;const d=e.data,c=o.data;let u,p,g,m;if(e.kind===W.GRAYSCALE_1BPP){const e=d.byteLength,i=new Uint32Array(c.buffer,0,c.byteLength>>2),m=i.length,f=n+7>>3,b=4294967295,v=St.isLittleEndian?4278190080:255;for(u=0;u<r;u++){for(g=u<a?Xi:s,l=0,p=0;p<g;p++){const t=e-h;let s=0;const a=t>f?n:8*t-7,r=-8&a;let o=0,c=0;for(;s<r;s+=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(;s<a;s++)0===o&&(c=d[h++],o=128),i[l++]=c&o?b:v,o>>=1}for(;l<m;)i[l++]=0;t.putImageData(o,0,u*Xi)}}else if(e.kind===W.RGBA_32BPP){for(p=0,m=n*Xi*4,u=0;u<a;u++)c.set(d.subarray(h,h+m)),h+=m,t.putImageData(o,0,p),p+=Xi;u<r&&(m=n*s*4,c.set(d.subarray(h,h+m)),t.putImageData(o,0,p))}else{if(e.kind!==W.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=Xi,m=n*g,u=0;u<r;u++){for(u>=a&&(g=s,m=n*g),l=0,p=m;p--;)c[l++]=d[h++],c[l++]=d[h++],c[l++]=d[h++],c[l++]=255;t.putImageData(o,0,u*Xi)}}}function tn(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,n=e.width,s=i%Xi,a=(i-s)/Xi,r=0===s?a:a+1,o=t.createImageData(n,Xi);let l=0;const h=e.data,d=o.data;for(let e=0;e<r;e++){const i=e<a?Xi:s;({srcPos:l}=Gi({src:h,srcPos:l,dest:d,width:n,height:i,nonBlackColor:0})),t.putImageData(o,0,e*Xi)}}function en(t,e){const i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const n of i)void 0!==t[n]&&(e[n]=t[n]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function nn(t){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 sn(t,e){if(e)return!0;Pt.singularValueDecompose2dScale(t,qi);const i=Math.fround(Zt.pixelRatio*Ft.PDF_TO_CSS_UNITS);return qi[0]<=i&&qi[1]<=i}const an=["butt","round","square"],rn=["miter","round","bevel"],on={},ln={};class hn{#zn=0;#$n=0;#Wn=null;#Gn=null;#Xn=null;#Kn=null;#qn=1;#Yn;#Qn=null;#Zn=[];constructor(t,e,i,n,s,{optionalContentConfig:a,markedContentStack:r=null},o,l,h,d){this.ctx=t,this.current=new Zi(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=e,this.objs=i,this.canvasFactory=n,this.filterFactory=s,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.tempSMask=null,this.smaskGroupCanvases=[],this.smaskPreparedEntry=null,this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=r||[],this.optionalContentConfig=a,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,this.dependencyTracker=h??null,this.imagesTracker=d??null}getObject(t,e,i=null){return"string"==typeof e?(this.dependencyTracker?.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):i}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:n=null}){const s=this.ctx.canvas.width,a=this.ctx.canvas.height,r=this.ctx.fillStyle;if(this.ctx.fillStyle=n||"#ffffff",this.ctx.fillRect(0,0,s,a),this.ctx.fillStyle=r,i){const t=this.transparentCanvasEntry=this.canvasFactory.create(s,a);this.compositeCtx=this.ctx,({canvas:this.transparentCanvas,context:this.ctx}=t),this.ctx.save(),this.ctx.transform(...qt(this.compositeCtx))}this.ctx.save(),nn(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[3]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=qt(this.ctx)}executeOperatorList(t,e,i,n,s){const a=t.argsArray,r=t.fnArray;let o=e||0;const l=a.length;if(l===o)return o;const h=l-o>10&&"function"==typeof i,d=h?Date.now()+15:0;let c=0;const u=this.commonObjs,p=this.objs;let g,m;for(;;){if(void 0!==n){if(o===n.nextBreakPoint)return n.breakIt(o,i),o;if(n.shouldSkip(o)){if(++o===l)return o;continue}}if(!s||s(o))if(g=r[o],m=a[o]??null,g!==J.dependency)null===m?this[g](o):this[g](o,...m);else for(const t of m){this.dependencyTracker?.recordNamedData(t,o);const e=t.startsWith("g_")?u:p;if(!e.has(t))return e.get(t,i),o}if(o++,o===l)return o;if(h&&++c>10){if(Date.now()>d)return i(),o;c=0}}}#Jn(){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.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null)}endDrawing(){this.#Jn();for(const t of this.smaskGroupCanvases)this.canvasFactory.destroy(t);this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0;for(const t of this.#Zn)this.#ts(t);this.#Zn.length=0,this.#Wn=null,this.#Gn=null,this.#Xn=null,this.#Kn=null,this.#qn=1,this.#Qn=null,this.#$n=0,this.#zn=0,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.#es()}#es(){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,n=t.height??t.displayHeight,s=[];let a=Math.max(Math.hypot(e[0],e[1]),1),r=Math.max(Math.hypot(e[2],e[3]),1),o=i,l=n;for(;a>2&&o>1||r>2&&l>1;){let t=o,e=l;a>2&&o>1&&(t=Math.ceil(o/2),a/=o/t),r>2&&l>1&&(e=Math.ceil(l/2),r/=l/e),s.push({newWidth:t,newHeight:e}),o=t,l=e}if(0===s.length)return{img:t,paintWidth:i,paintHeight:n,tmpCanvas:null};if(1===s.length){const{newWidth:e,newHeight:a}=s[0],r=this.canvasFactory.create(e,a);return r.context.drawImage(t,0,0,i,n,0,0,e,a),{img:r.canvas,paintWidth:e,paintHeight:a,tmpCanvas:r}}let h=this.canvasFactory.create(1,1),d=this.canvasFactory.create(1,1),c=i,u=n,p=t;for(const{newWidth:t,newHeight:e}of s)this.canvasFactory.reset(d,t,e),d.context.drawImage(p,0,0,c,u,0,0,t,e),[h,d]=[d,h],p=h.canvas,c=t,u=e;return this.canvasFactory.destroy(d),{img:h.canvas,paintWidth:c,paintHeight:u,tmpCanvas:h}}_createMaskCanvas(t,e){const i=this.ctx,{width:n,height:s}=e,a=this.current.fillColor,r=this.current.patternFill,o=qt(i);let l,h,d,c;if((e.bitmap||e.data)&&e.count>1){const i=e.bitmap||e.data.buffer;h=JSON.stringify(r?o:[o.slice(0,4),a]),l=this._cachedBitmapsMap.getOrInsertComputed(i,kt);const n=l.get(h);if(n&&!r){const e=Math.round(Math.min(o[0],o[2])+o[4]),i=Math.round(Math.min(o[1],o[3])+o[5]);return this.dependencyTracker?.recordDependencies(t,Xe),{canvas:n,offsetX:e,offsetY:i}}d=n}d||(c=this.canvasFactory.create(n,s),tn(c.context,e));let u=Pt.transform(o,[1/n,0,0,-1/s,0,0]);u=Pt.transform(u,[1,0,0,1,0,-s]);const p=A.slice();Pt.axialAlignedBoundingBox([0,0,n,s],u,p);const[g,m,f,b]=p,v=Math.round(f-g)||1,w=Math.round(b-m)||1,y=this.canvasFactory.create(v,w),x=y.context,C=g,S=m;x.translate(-C,-S),x.transform(...u);let P=null;if(!d){const t=this._scaleImage(c.canvas,Yt(x));d=t.img,P=t.tmpCanvas,d!==c.canvas&&(this.canvasFactory.destroy(c),c=null),l&&r&&(l.set(h,d),P=null,c=null)}x.imageSmoothingEnabled=sn(qt(x),e.interpolate),Qi(x,d,0,0,d.width,d.height,0,0,n,s),P&&this.canvasFactory.destroy(P),c&&this.canvasFactory.destroy(c),x.globalCompositeOperation="source-in";const _=Pt.transform(Yt(x),[1,0,0,1,-C,-S]);return x.fillStyle=r?a.getPattern(i,this,_,Ni,t):a,x.fillRect(0,0,n,s),l&&!r&&l.set(h,y.canvas),this.dependencyTracker?.recordDependencies(t,Xe),{canvas:y.canvas,canvasEntry:l&&!r?null:y,offsetX:Math.round(C),offsetY:Math.round(S)}}setLineWidth(t,e){this.dependencyTracker?.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){this.dependencyTracker?.recordSimpleData("lineCap",t),this.ctx.lineCap=an[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=rn[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,i){this.dependencyTracker?.recordSimpleData("dash",t);const n=this.ctx;void 0!==n.setLineDash&&(n.setLineDash(e),n.lineDashOffset=i)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(const[i,n]of e)switch(i){case"LW":this.setLineWidth(t,n);break;case"LC":this.setLineCap(t,n);break;case"LJ":this.setLineJoin(t,n);break;case"ML":this.setMiterLimit(t,n);break;case"D":this.setDash(t,n[0],n[1]);break;case"RI":this.setRenderingIntent(t,n);break;case"FL":this.setFlatness(t,n);break;case"Font":this.setFont(t,n[0],n[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=n;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=n;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=n;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=n?this.tempSMask:null,this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation),this.tempSMask=null,this.checkSMaskState(t);break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n)}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){this.smaskPreparedEntry&&(this.canvasFactory.destroy(this.smaskPreparedEntry),this.smaskPreparedEntry=null),this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null}_ensurePreparedSMask(t){t!==this.smaskPreparedFor&&(this._clearPreparedSMask(),this._prepareSMaskCanvas(t))}checkSMaskState(t){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode(t):!this.current.activeSMask&&e?this.endSMaskMode():this.current.activeSMask&&e&&this._ensurePreparedSMask(this.current.activeSMask)}_prepareSMaskCanvas(t){const{canvas:e,subtype:i,backdrop:n,transferMap:s}=t,a="Luminosity"===i||"Alpha"===i&&s;if(!(a||"Luminosity"===i&&n))return void(this.smaskPreparedFor=t);let r;if("Luminosity"===i&&n){const[t,e,i]=Xt(n),a=Math.round(.3*t+.59*e+.11*i);r=s?.[a]??a}else r=s?.[0]??0;const{width:o,height:l}=this.ctx.canvas,h=o*l<4*(e.width*e.height),d=a?{url:"Alpha"===i?this.filterFactory.addAlphaFilter(s):this.filterFactory.addLuminosityFilter(s),subtype:i,transferMap:s}:null,c="Luminosity"===i?n:null;let u,p,g;h?(u=this._bakeSMaskCanvas(e,t.offsetX,t.offsetY,o,l,c,d),p=0,g=0):(u=this._bakeSMaskCanvas(e,0,0,e.width,e.height,c,d),p=t.offsetX,g=t.offsetY),this.smaskPreparedEntry=u,this.smaskPreparedFor=t,this.smaskPreparedOffsetX=p,this.smaskPreparedOffsetY=g,this.smaskPreparedOOBAlpha=h||0===r?null:r}_bakeSMaskCanvas(t,e,i,n,s,a,r){a||r||dt("_bakeSMaskCanvas with neither backdrop nor filter");const o=this.canvasFactory.create(n,s),l=o.context;if(l.drawImage(t,e,i),a&&(l.globalCompositeOperation="destination-atop",l.fillStyle=a,l.fillRect(0,0,n,s)),!r)return o;const h=this.canvasFactory.create(n,s),d=h.context;d.filter=r.url;const c=St.isCanvasFilterSupported&&"none"!==d.filter&&""!==d.filter;if(d.drawImage(o.canvas,0,0),St.isCanvasFilterSupported&&(d.filter="none"),!c){const t=d.getImageData(0,0,n,s),{data:e}=t,{transferMap:i}=r;if("Luminosity"===r.subtype)for(let t=0,n=e.length;t<n;t+=4){const n=.3*e[t]+.59*e[t+1]+.11*e[t+2]+.5|0;e[t]=e[t+1]=e[t+2]=0,e[t+3]=i?.[n]??n}else for(let t=3,n=e.length;t<n;t+=4)e[t]=i[e[t]];d.putImageData(t,0,0)}return this.canvasFactory.destroy(o),h}beginSMaskMode(t){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const{width:e,height:i}=this.ctx.canvas,n=this.canvasFactory.create(e,i);this.smaskScratchCanvas=n,this.suspendedCtx=this.ctx;const s=this.ctx=n.context;s.setTransform(this.suspendedCtx.getTransform()),en(this.suspendedCtx,s),Yi(s,this.suspendedCtx),this._ensurePreparedSMask(this.current.activeSMask),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),en(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}#is(t,e=null,i=1){const{width:n,height:s}=t,a=e??this.canvasFactory.create(n,s),r=a.context,o=(i=Math.round(255*i)/255)<1;o&&void 0===this.#Yn&&(this.#Yn=St.isCanvasFilterSupported?new Map:"none");let l="none";if(o&&this.#Yn instanceof Map&&(l=this.#Yn.get(i),l||(l=this.filterFactory.addKnockoutFilter(i),this.#Yn.set(i,l))),!o||"none"!==l)return e&&(r.save(),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,n,s),r.restore()),r.filter=l,r.drawImage(t,0,0),r.filter="none",a;const h=t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,n,s),d=r.createImageData(n,s),c=h.data,u=d.data,p=i>0?1/i:1e6;for(let t=3,e=c.length;t<e;t+=4)u[t]=Math.min(Math.round(c[t]*p),255);return r.putImageData(d,0,0),a}#ns(t,e,i,n){let s=t?.[e]??null;if(!s||s.canvas.width===i&&s.canvas.height===n||(this.canvasFactory.destroy(s),s=null),!s)return s=this.canvasFactory.create(i,n),t&&(t[e]=s),s;const a=s.context;return a.save(),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,i,n),a.restore(),s}#ss(t,e,i={}){const{backdropCanvas:n=null,destTransform:s=[1,0,0,1,0,0],backdropOffset:a=[0,0],reuseMaskEntry:r=null,poolMeta:o=null,sourceAlpha:l=1,sourceFilter:h="none",knockoutAlpha:d=1}=i,{width:c,height:u}=e,p=this.#is(e,r,d),g=t.globalCompositeOperation;if(t.save(),t.setTransform(...s),t.globalAlpha=1,St.isCanvasFilterSupported&&(t.filter="none"),t.globalCompositeOperation="destination-out",t.drawImage(p.canvas,0,0),n){const[e,i]=a,s=this.#ns(o,"knockoutBackdropEntry",c,u),r=s.context;r.drawImage(n,e,i,c,u,0,0,c,u),r.globalCompositeOperation="destination-in",r.drawImage(p.canvas,0,0),r.globalCompositeOperation="source-over",t.globalCompositeOperation="destination-over",t.drawImage(s.canvas,0,0),o||this.canvasFactory.destroy(s)}t.globalCompositeOperation=g,t.globalAlpha=l,St.isCanvasFilterSupported&&(t.filter=h??"none"),t.drawImage(e,0,0),t.restore(),r||this.canvasFactory.destroy(p)}#as(t=1){if(0===this.#zn||this.#$n>0||!this.contentVisible)return!1;this.#$n++,this.#qn=t;const e=this.#Zn.at(-1),{canvas:i}=this.ctx,n=this.#ns(e,"knockoutTempEntry",i.width,i.height);this.#Wn=n;const s=n.context;return s.save(),s.setTransform(this.ctx.getTransform()),en(this.ctx,s),this.#Kn=s.globalCompositeOperation,s.globalCompositeOperation="source-over",Yi(s,this.ctx),this.#Qn=e,this.#Gn=this.ctx,this.#Xn=this.suspendedCtx,this.ctx=s,this.inSMaskMode&&(this.suspendedCtx=s),!0}#rs(t){if(!t)return;const e=this.#Wn,i=this.#Gn,n=this.#Xn,s=e.context;this.#Wn=null,this.#Gn=null,this.#Xn=null,this.inSMaskMode&&this.suspendedCtx===s&&this.ctx!==s&&this.endSMaskMode(),this.inSMaskMode&&(this.suspendedCtx=n),this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=this.#Kn,this.#Kn=null,en(this.ctx,i),this.ctx=i;const a=this.#Qn;this.#Qn=null;const r=this.#qn;this.#qn=1;try{this.#ss(n??i,e.canvas,{backdropCanvas:a?.backdropCtx?.canvas??null,backdropOffset:a?.backdropCtx?[a.offsetX,a.offsetY]:[0,0],reuseMaskEntry:a?.knockoutMaskEntry??null,poolMeta:a,knockoutAlpha:r})}finally{s.restore(),this.#$n--,a||this.canvasFactory.destroy(e)}}compose(t){if(!this.current.activeSMask)return;t=t?[Math.floor(t[0]),Math.floor(t[1]),Math.ceil(t[2]),Math.ceil(t[3])]:[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,i=this.suspendedCtx,n=this.#$n>0&&i===this.ctx;this.composeSMask(n?null:i,e,this.ctx,t),n||(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,n){const s=n[0],a=n[1],r=n[2]-s,o=n[3]-a;if(0===r||0===o)return;const l=this.smaskPreparedEntry;if(l){let t=s,n=a,h=r,d=o;const c=this.smaskPreparedOOBAlpha,u=null!==c;if(u){t=Math.max(s,e.offsetX),n=Math.max(a,e.offsetY);h=Math.min(s+r,e.offsetX+e.canvas.width)-t,d=Math.min(a+o,e.offsetY+e.canvas.height)-n}if(h>0&&d>0){const e=t-this.smaskPreparedOffsetX,s=n-this.smaskPreparedOffsetY;i.save(),i.globalAlpha=1,i.setTransform(1,0,0,1,0,0);const a=new Path2D;a.rect(t,n,h,d),i.clip(a),i.globalCompositeOperation="destination-in",i.drawImage(l.canvas,e,s,h,d,t,n,h,d),i.restore()}u&&c<255&&this._applySMaskOOBAlpha(i,s,a,r,o,t,n,t+h,n+d,c)}else this.genericComposeSMask(e,i,r,o,s,a);t&&(t.save(),t.globalAlpha=1,t.globalCompositeOperation=e.blendMode||"source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,s,a,r,o,s,a,r,o),t.restore())}_applySMaskOOBAlpha(t,e,i,n,s,a,r,o,l,h){const d=a<o&&r<l;if(d&&a===e&&r===i&&o===e+n&&l===i+s)return;const c=new Path2D;c.rect(e,i,n,s),d&&c.rect(a,r,o-a,l-r),t.save(),t.globalAlpha=h/255,t.setTransform(1,0,0,1,0,0),t.clip(c,"evenodd"),t.globalCompositeOperation="destination-in",t.fillStyle="#000000",t.fillRect(e,i,n,s),t.restore()}genericComposeSMask(t,e,i,n,s,a){const{context:r,offsetX:o,offsetY:l}=t;e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const h=new Path2D;h.rect(s,a,i,n),e.clip(h),e.globalCompositeOperation="destination-in",e.drawImage(r.canvas,s-o,a-l,i,n,s,a,i,n),e.restore()}save(t){this.inSMaskMode&&en(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone(),this.dependencyTracker?.save(t)}restore(t){this.dependencyTracker?.restore(t),0!==this.stateStack.length?(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&(en(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform())),this.checkSMaskState(t),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null):this.inSMaskMode&&this.endSMaskMode()}transform(t,e,i,n,s,a,r){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(e,i,n,s,a,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i,n){let[s]=i;if(!n)return s||=i[0]=new Path2D,e!==J.stroke&&e!==J.closeStroke&&(this.current.tilingPatternDims=null),void this[e](t,s);if(null!==this.dependencyTracker){const i=e===J.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,n[0]-i,n[2]+i,n[1]-i,n[3]+i).recordDependencies(t,["transform"])}s instanceof Path2D||(s=i[0]=oe(s)),Pt.axialAlignedBoundingBox(n,qt(this.ctx),this.current.minMax);const a=this.current.tilingPatternDims;if(a&&e!==J.stroke&&e!==J.closeStroke&&this.current.fillColor instanceof Wi){const t=Pt.intersect(this.current.clipBox,this.current.minMax);t?this.current.fillColor.updatePatternDims(t,a):this.current.tilingPatternDims=null}this[e](t,s),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,i=!0){const n=i&&this.#as(this.current.strokeAlpha),s=this.ctx,a=this.current.strokeColor;if(s.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof a&&a?.getPattern){const i=a.isModifyingCurrentTransform()?s.getTransform():null;if(s.save(),s.strokeStyle=a.getPattern(s,this,Yt(s),Ri,t),i){const t=new Path2D;t.addPath(e,s.getTransform().invertSelf().multiplySelf(i)),e=t}this.rescaleAndStroke(e,!1),s.restore()}else this.rescaleAndStroke(e,!0);this.dependencyTracker?.recordDependencies(t,He),i&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(Ri,qt(this.ctx))),s.globalAlpha=this.current.fillAlpha,this.#rs(n)}closeStroke(t,e){this.stroke(t,e)}fill(t,e,i=!0){const n=i&&this.#as(this.current.fillAlpha),s=this.ctx,a=this.current.fillColor,r=this.current.patternFill;let o=!1;const l=this.current.getClippedPathBoundingBox();if(this.dependencyTracker?.recordDependencies(t,Ve),r){const r=this.current.tilingPatternDims,h=r&&a.canSkipPatternCanvas(r);if(h)return a.drawPattern(this,e,this.pendingEOFill,h,t),this.pendingEOFill=!1,i&&this.consumePath(t,e,l),this.current.tilingPatternDims=null,void this.#rs(n);const d=a.isModifyingCurrentTransform()?s.getTransform():null;if(this.dependencyTracker?.save(t),s.save(),s.fillStyle=a.getPattern(s,this,Yt(s),Ni,t),d){const t=new Path2D;t.addPath(e,s.getTransform().invertSelf().multiplySelf(d)),e=t}o=!0}this.contentVisible&&null!==l&&(this.pendingEOFill?(s.fill(e,"evenodd"),this.pendingEOFill=!1):s.fill(e)),o&&(s.restore(),this.dependencyTracker?.restore(t)),i&&this.consumePath(t,e,l),this.#rs(n)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){const i=this.#as(Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e),this.#rs(i)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){const i=this.#as(this.current.fillAlpha);this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,$e).recordOperation(t),this.#rs(i)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=on}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=ln}beginText(t){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,this.dependencyTracker?.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,i=this.ctx;if(this.dependencyTracker){const{dependencyTracker:i}=this;void 0!==e&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(void 0!==e){const t=new Path2D,n=i.getTransform().invertSelf();for(const{transform:i,x:s,y:a,fontSize:r,path:o}of e)o&&t.addPath(o,new DOMMatrix(i).preMultiplySelf(n).translate(s,a).scale(r,-r));i.clip(t)}delete this.pendingTextPaths}setCharSpacing(t,e){this.dependencyTracker?.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){this.dependencyTracker?.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){this.dependencyTracker?.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){this.dependencyTracker?.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,i){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const n=this.commonObjs.get(e),s=this.current;if(!n)throw new Error(`Can't find font for ${e}`);if(s.fontMatrix=n.fontMatrix||C,0!==s.fontMatrix[0]&&0!==s.fontMatrix[3]||ht("Invalid font matrix for font "+e),i<0?(i=-i,s.fontDirection=-1):s.fontDirection=1,this.current.font=n,this.current.fontSize=i,n.isType3Font)return;const a=n.loadedName||"sans-serif",r=n.systemFontInfo?.css||`"${a}", ${n.fallbackName}`;let o="normal";n.black?o="900":n.bold&&(o="bold");const l=n.italic?"italic":"normal";let h=i;i<16?h=16:i>100&&(h=100),this.current.fontSizeScale=i/h,this.ctx.font=`${l} ${o} ${h}px ${r}`}setTextRenderingMode(t,e){this.dependencyTracker?.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){this.dependencyTracker?.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,i){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=i}setLeadingMoveText(t,e,i){this.setLeading(t,-i),this.moveText(t,e,i)}setTextMatrix(t,e){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);const{current:i}=this;i.textMatrix=e,i.textMatrixScale=Math.hypot(e[0],e[1]),i.x=i.lineX=0,i.y=i.lineY=0}nextLine(t){this.moveText(t,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}#os(t,e,i){const n=new Path2D;return n.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),n}paintChar(t,e,i,n,s,a){const r=this.ctx,o=this.current,l=o.font,h=o.textRenderingMode,d=o.fontSize/o.fontSizeScale,c=h&z,u=!!(h&$),p=o.patternFill&&!l.missingFile,g=o.patternStroke&&!l.missingFile;let m;if((l.disableFontFace||u||p||g)&&!l.missingFile&&(m=l.getPathGenerator(this.commonObjs,e)),m&&(l.disableFontFace||p||g)){let e;if(r.save(),r.translate(i,n),r.scale(d,-d),this.dependencyTracker?.recordCharacterBBox(t,r,l),c===j||c===H)if(s){e=r.getTransform(),r.setTransform(...s);const t=this.#os(m,e,s);r.fill(t)}else r.fill(m);if(c===U||c===H)if(a){e||=r.getTransform(),r.setTransform(...a);const{a:t,b:i,c:n,d:s}=e,o=Pt.inverseTransform(a),l=Pt.transform([t,i,n,s,0,0],o);Pt.singularValueDecompose2dScale(l,qi),r.lineWidth*=Math.max(qi[0],qi[1])/d,r.stroke(this.#os(m,e,a))}else r.lineWidth/=d,r.stroke(m);r.restore()}else c!==j&&c!==H||(r.fillText(e,i,n),this.dependencyTracker?.recordCharacterBBox(t,r,l,d,i,n,()=>r.measureText(e))),c!==U&&c!==H||(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(t,r,l,d,i,n,()=>r.measureText(e)).recordDependencies(t,He),r.strokeText(e,i,n));if(u){(this.pendingTextPaths||=[]).push({transform:qt(r),x:i,y:n,fontSize:d,path:m}),this.dependencyTracker?.recordCharacterBBox(t,r,l,d,i,n)}}get isFontSubpixelAAEnabled(){const t=this.canvasFactory.create(10,10),e=t.context;e.scale(1.5,1),e.fillText("I",0,10);const i=e.getImageData(0,0,10,10).data;this.canvasFactory.destroy(t);let n=!1;for(let t=3;t<i.length;t+=4)if(i[t]>0&&i[t]<255){n=!0;break}return mt(this,"isFontSubpixelAAEnabled",n)}showText(t,e){this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,We).resetBBox(t),this.current.textRenderingMode&$&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const i=this.current,n=i.font;if(n.isType3Font){const n=this.#as(i.fillAlpha);return this.showType3Text(t,e),this.dependencyTracker?.recordShowTextOperation(t),void this.#rs(n)}const s=i.fontSize;if(0===s)return void this.dependencyTracker?.recordOperation(t);const a=this.#as(i.fillAlpha),r=this.ctx,o=i.fontSizeScale,l=i.charSpacing,h=i.wordSpacing,d=i.fontDirection,c=i.textHScale*d,u=e.length,p=n.vertical,g=p?1:-1,m=n.defaultVMetrics,f=s*i.fontMatrix[0],b=i.textRenderingMode===j&&!n.disableFontFace&&!i.patternFill;let v,w;r.save(),i.textMatrix&&r.transform(...i.textMatrix),r.translate(i.x,i.y+i.textRise),d>0?r.scale(c,-1):r.scale(c,1);const y=i.textRenderingMode&z,x=y===j||y===H,A=y===U||y===H;let C=i.lineWidth;const S=i.textMatrixScale;if(0===S||0===C?A&&(C=this.getSinglePixelWidth()):C/=S,1!==o&&(r.scale(o,o),C/=o),r.lineWidth=C,x&&i.patternFill){r.save();const e=i.fillColor.getPattern(r,this,Yt(r),Ni,t);v=qt(r),r.restore(),r.fillStyle=e}if(A&&i.patternStroke){r.save();const e=i.strokeColor.getPattern(r,this,Yt(r),Ri,t);w=qt(r),r.restore(),r.strokeStyle=e}if(n.isInvalidPDFjsFont){const n=[];let s=0;for(const t of e)n.push(t.unicode),s+=t.width;const o=n.join("");if(r.fillText(o,0,0),null!==this.dependencyTracker){const e=r.measureText(o);this.dependencyTracker.recordBBox(t,this.ctx,-e.actualBoundingBoxLeft,e.actualBoundingBoxRight,-e.actualBoundingBoxAscent,e.actualBoundingBoxDescent).recordShowTextOperation(t)}return i.x+=s*f*c,r.restore(),this.compose(),void this.#rs(a)}let P,_=0;for(P=0;P<u;++P){const i=e[P];if("number"==typeof i){_+=g*i*s/1e3;continue}let a=!1;const c=(i.isSpace?h:0)+l,u=i.fontChar,y=i.accent;let x,A,C,S=i.width;if(p){const t=i.vmetric||m,e=-(i.vmetric?t[1]:.5*S)*f,n=t[2]*f;S=t?-t[0]:S,x=e/o,A=(_+n)/o}else x=_/o,A=0;if(n.remeasure&&S>0){C=r.measureText(u);const t=1e3*C.width/s*o;if(S<t&&this.isFontSubpixelAAEnabled){const e=S/t;a=!0,r.save(),r.scale(e,1),x/=e}else S!==t&&(x+=(S-t)/2e3*s/o)}if(this.contentVisible&&(i.isInFont||n.missingFile))if(b&&!y)r.fillText(u,x,A),this.dependencyTracker?.recordCharacterBBox(t,r,C?{bbox:null}:n,s/o,x,A,()=>C??r.measureText(u));else if(this.paintChar(t,u,x,A,v,w),y){const e=x+s*y.offset.x/o,i=A-s*y.offset.y/o;this.paintChar(t,y.fontChar,e,i,v,w)}_+=p?S*f-c*d:S*f+c*d,a&&r.restore()}p?i.y-=_:i.x+=_*c,r.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t),this.#rs(a)}showType3Text(t,e){const i=this.ctx,n=this.current,s=n.font,a=n.fontSize,r=n.fontDirection,o=s.vertical?1:-1,l=n.charSpacing,h=n.wordSpacing,d=n.textHScale*r,c=n.fontMatrix||C,u=e.length;let p,g,m,f;if(n.textRenderingMode===V||0===a)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,i.save(),n.textMatrix&&i.transform(...n.textMatrix),i.translate(n.x,n.y+n.textRise),i.scale(d,r);const b=this.dependencyTracker;for(this.dependencyTracker=b?new Ue(b,t):null,p=0;p<u;++p){if(g=e[p],"number"==typeof g){f=o*g*a/1e3,this.ctx.translate(f,0),n.x+=f*d;continue}const t=(g.isSpace?h:0)+l,r=s.charProcOperatorList[g.operatorListId];r?this.contentVisible&&(this.save(),i.scale(a,a),i.transform(...c),this.executeOperatorList(r),this.restore()):ht(`Type3 character "${g.operatorListId}" is not available.`);const u=[g.width,0];Pt.applyTransform(u,c),m=u[0]*a+t,i.translate(m,0),n.x+=m*d}i.restore(),b&&(this.dependencyTracker=b)}setCharWidth(t,e,i){}setCharWidthAndBounds(t,e,i,n,s,a,r){const o=new Path2D;o.rect(n,s,a-n,r-s),this.ctx.clip(o),this.dependencyTracker?.recordBBox(t,this.ctx,n,a,s,r).recordClipBox(t,this.ctx,n,a,s,r),this.endPath(t)}getColorN_Pattern(t,e){let i;if("TilingPattern"===e[0]){const t=this.baseTransform||qt(this.ctx),n={createCanvasGraphics:(t,e)=>new hn(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new Ue(this.dependencyTracker,e,!0):null)};i=new Wi(e,this.ctx,n,t)}else i=this._getPattern(t,e[1],e[2]);return i}setStrokeColorN(t,...e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){this.dependencyTracker?.recordSimpleData("fillColor",t);const i=this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=!0,this.current.tilingPatternDims=i instanceof Wi?[0,0,0,0]:null}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1,this.current.tilingPatternDims=null}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(t,e,i=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=function(t){switch(t[0]){case"RadialAxial":return new ji(t);case"Mesh":return new Hi(t);case"Dummy":return new Vi}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t,e)),this.cachedPatterns.set(e,n)),i&&(n.matrix=i),n}shadingFill(t,e){if(!this.contentVisible)return;const i=this.#as(this.current.fillAlpha),n=this.ctx;this.save(t);const s=this._getPattern(t,e);n.fillStyle=s.getPattern(n,this,Yt(n),Fi,t);const a=Yt(n);if(a){const{width:t,height:e}=n.canvas,i=A.slice();Pt.axialAlignedBoundingBox([0,0,t,e],a,i);const[s,r,o,l]=i;this.ctx.fillRect(s,r,o-s,l-r)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,Ge).recordDependencies(t,Ve).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t),this.#rs(i)}beginInlineImage(){dt("Should not call beginInlineImage")}beginImageData(){dt("Should not call beginImageData")}paintFormXObjectBegin(t,e,i){if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=qt(this.ctx),i)){Pt.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);const[e,n,s,a]=i,r=new Path2D;r.rect(e,n,s-e,a-n),this.ctx.clip(r),this.dependencyTracker?.recordClipBox(t,this.ctx,e,s,n,a),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){if(!this.contentVisible)return;this.save(t);const{inSMaskMode:i}=this;i&&(this.endSMaskMode(),this.current.activeSMask=null);const n=this.ctx;if(e.isolated||e.knockout||0!==this.#zn||lt("TODO: Fully support non-isolated non-knockout groups."),!e.needsIsolation&&!e.knockout&&0===this.#zn&&1===n.globalAlpha&&"source-over"===n.globalCompositeOperation&&!i){if(e.bbox){let t=new Path2D;const[i,s,a,r]=e.bbox;if(t.rect(i,s,a-i,r-s),e.matrix){const i=new Path2D;i.addPath(t,new DOMMatrix(e.matrix)),t=i}n.clip(t)}return this.groupStack.push(null),this.#Zn.push(null),void this.groupLevel++}const s=qt(n);e.matrix&&n.transform(...e.matrix);const a=[0,0,n.canvas.width,n.canvas.height];let r;e.bbox?(r=A.slice(),Pt.axialAlignedBoundingBox(e.bbox,qt(n),r),r=Pt.intersect(r,a)||[0,0,0,0]):r=a;const o=Math.floor(r[0]),l=Math.floor(r[1]),h=Math.max(Math.ceil(r[2])-o,1),d=Math.max(Math.ceil(r[3])-l,1);this.current.startNewPathAndClipBox([0,0,h,d]);const c=this.canvasFactory.create(h,d);e.smask&&this.smaskGroupCanvases.push(c);const u=c.context,p=e.knockout&&!e.isolated?n:null,g=!e.isolated&&!e.knockout&&!e.smask&&e.needsIsolation&&this.#zn>0,m=e.knockout?this.canvasFactory.create(h,d):null,f=this.#zn;if(e.knockout?this.#zn++:this.#zn=0,u.translate(-o,-l),u.transform(...s),!e.isolated&&!e.smask&&i&&e.needsIsolation&&(u.save(),u.setTransform(1,0,0,1,0,0),u.drawImage(n.canvas,-o,-l),u.restore()),e.bbox){let t=new Path2D;const[i,n,s,a]=e.bbox;if(t.rect(i,n,s-i,a-n),e.matrix){const i=new Path2D;i.addPath(t,new DOMMatrix(e.matrix)),t=i}u.clip(t)}e.smask&&this.smaskStack.push({canvas:c.canvas,context:u,offsetX:o,offsetY:l,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null}),e.smask&&!this.dependencyTracker||(n.setTransform(1,0,0,1,0,0),n.translate(o,l),n.save()),en(n,u),this.ctx=u,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(n),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(n),this.#Zn.push({backdropCtx:p,savedKnockoutLevel:f,offsetX:o,offsetY:l,hasInnerBackdrop:g,knockoutMaskEntry:m,knockoutTempEntry:null,knockoutBackdropEntry:null}),this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--;const i=this.ctx,n=this.groupStack.pop(),s=this.#Zn.pop();if(s&&(this.#zn=s.savedKnockoutLevel),null!==n)if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&(this.ctx.restore(),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())),this.#ts(s);else{this.ctx.restore();const e=qt(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...e);const a=A.slice();Pt.axialAlignedBoundingBox([0,0,i.canvas.width,i.canvas.height],e,a);const r=this.#Zn.at(-1);if(this.#zn>0)if(s.hasInnerBackdrop){const{width:t,height:a}=i.canvas,r=this.canvasFactory.create(t,a),o=r.context;o.drawImage(n.canvas,s.offsetX,s.offsetY,t,a,0,0,t,a),o.globalCompositeOperation="source-over",o.drawImage(i.canvas,0,0);const l=this.#is(i.canvas);o.globalCompositeOperation="destination-in",o.drawImage(l.canvas,0,0);const h=this.ctx.globalCompositeOperation,d=this.ctx.globalAlpha,c=this.ctx.filter;this.ctx.save(),this.ctx.setTransform(...e),this.ctx.globalAlpha=1,St.isCanvasFilterSupported&&(this.ctx.filter="none"),this.ctx.globalCompositeOperation="destination-out",this.ctx.drawImage(l.canvas,0,0),this.ctx.globalCompositeOperation=h,this.ctx.globalAlpha=d,St.isCanvasFilterSupported&&(this.ctx.filter=c??"none"),this.ctx.drawImage(r.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(l),this.canvasFactory.destroy(r)}else{const t=r?.backdropCtx??null;this.#ss(this.ctx,i.canvas,{backdropCanvas:t?.canvas??null,destTransform:e,backdropOffset:t?[r.offsetX+s.offsetX,r.offsetY+s.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else this.ctx.drawImage(i.canvas,0,0);this.ctx.restore(),this.canvasFactory.destroy({canvas:i.canvas,context:i}),this.#ts(s),this.compose(a)}else this.restore(t)}#ts(t){t&&(t.knockoutMaskEntry&&(this.canvasFactory.destroy(t.knockoutMaskEntry),t.knockoutMaskEntry=null),t.knockoutTempEntry&&(this.canvasFactory.destroy(t.knockoutTempEntry),t.knockoutTempEntry=null),t.knockoutBackdropEntry&&(this.canvasFactory.destroy(t.knockoutBackdropEntry),t.knockoutBackdropEntry=null))}beginAnnotation(t,e,i,n,s,a){if(this.#Jn(),nn(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),i){const s=i[2]-i[0],r=i[3]-i[1];if(a&&this.annotationCanvasMap){(n=n.slice())[4]-=i[0],n[5]-=i[1],(i=i.slice())[0]=i[1]=0,i[2]=s,i[3]=r,Pt.singularValueDecompose2dScale(qt(this.ctx),qi);const{viewportScale:t}=this,a=Math.ceil(s*this.outputScaleX*t),o=Math.ceil(r*this.outputScaleY*t);this.annotationCanvas=this.canvasFactory.create(a,o);const{canvas:l,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(e,l),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(qi[0],0,0,-qi[1],0,r*qi[1]),nn(this.ctx)}else{nn(this.ctx),this.endPath(t);const e=new Path2D;e.rect(i[0],i[1],s,r),this.ctx.clip(e)}}this.current=new Zi(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...n),this.transform(t,...s),this.baseTransform=qt(this.ctx)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),this.#es(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(t,e){if(!this.contentVisible)return;const i=e.count;(e=this.getObject(t,e.data,e)).count=i;const n=this.#as(this.current.fillAlpha),s=this.ctx,a=this._createMaskCanvas(t,e),r=a.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(r,a.offsetX,a.offsetY),this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,a.offsetX,a.offsetX+r.width,a.offsetY,a.offsetY+r.height).recordOperation(t),s.restore(),a.canvasEntry&&this.canvasFactory.destroy(a.canvasEntry),this.compose(),this.#rs(n)}paintImageMaskXObjectRepeat(t,e,i,n=0,s=0,a,r){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const o=this.#as(this.current.fillAlpha),l=this.ctx;l.save();const h=qt(l);l.transform(i,n,s,a,0,0);const d=this._createMaskCanvas(t,e);l.setTransform(1,0,0,1,d.offsetX-h[4],d.offsetY-h[5]),this.dependencyTracker?.resetBBox(t);for(let e=0,o=r.length;e<o;e+=2){const o=Pt.transform(h,[i,n,s,a,r[e],r[e+1]]);l.drawImage(d.canvas,o[4],o[5]),this.dependencyTracker?.recordBBox(t,this.ctx,o[4],o[4]+d.canvas.width,o[5],o[5]+d.canvas.height)}l.restore(),d.canvasEntry&&this.canvasFactory.destroy(d.canvasEntry),this.compose(),this.dependencyTracker?.recordOperation(t),this.#rs(o)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;const i=this.#as(this.current.fillAlpha),n=this.ctx,s=this.current.fillColor,a=this.current.patternFill;this.dependencyTracker?.resetBBox(t).recordDependencies(t,Xe);for(const i of e){const{data:e,width:r,height:o,transform:l}=i,h=this.canvasFactory.create(r,o),d=h.context;d.save();tn(d,this.getObject(t,e,i)),d.globalCompositeOperation="source-in",d.fillStyle=a?s.getPattern(d,this,Yt(n),Ni,t):s,d.fillRect(0,0,r,o),d.restore(),n.save(),n.transform(...l),n.scale(1,-1),Qi(n,h.canvas,0,0,r,o,0,-1,1,1),this.canvasFactory.destroy(h),this.dependencyTracker?.recordBBox(t,n,0,r,0,o),n.restore()}this.compose(),this.dependencyTracker?.recordOperation(t),this.#rs(i)}paintImageXObject(t,e){if(!this.contentVisible)return;const i=this.getObject(t,e);i?this.paintInlineImageXObject(t,i):ht("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,n,s){if(!this.contentVisible)return;const a=this.getObject(t,e);if(!a)return void ht("Dependent image isn't ready yet");const r=a.width,o=a.height,l=[];for(let t=0,e=s.length;t<e;t+=2)l.push({transform:[i,0,0,n,s[t],s[t+1]],x:0,y:0,w:r,h:o});this.paintInlineImageXObjectGroup(t,a,l)}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{img:t.bitmap,canvasEntry:null};const{bitmap:e,width:i,height:n}=t,s=this.canvasFactory.create(i,n),a=s.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",{img:s.canvas,canvasEntry:s}}paintInlineImageXObject(t,e){if(!this.contentVisible)return;const i=e.width,n=e.height,s=this.#as(this.current.fillAlpha),a=this.ctx;this.save(t);const{filter:r}=a;let o;"none"!==r&&""!==r&&(a.filter="none"),a.scale(1/i,-1/n);let l=null;if(e.bitmap){const t=this.applyTransferMapsToBitmap(e);o=t.img,l=t.canvasEntry}else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)o=e;else{const t=this.canvasFactory.create(i,n);Ji(t.context,e),o=this.applyTransferMapsToCanvas(t.context),l=t}const h=this._scaleImage(o,Yt(a));a.imageSmoothingEnabled=sn(qt(a),e.interpolate),this.dependencyTracker&&(this.dependencyTracker.resetBBox(t).recordBBox(t,a,0,i,-n,0).recordDependencies(t,ze).recordOperation(t),this.imagesTracker?.record(a,i,n,this.dependencyTracker.clipBox)),Qi(a,h.img,0,0,h.paintWidth,h.paintHeight,0,-n,i,n),h.tmpCanvas&&this.canvasFactory.destroy(h.tmpCanvas),l&&this.canvasFactory.destroy(l),this.compose(),this.restore(t),this.#rs(s)}paintInlineImageXObjectGroup(t,e,i){if(!this.contentVisible)return;const n=this.#as(this.current.fillAlpha),s=this.ctx;let a,r=null;if(e.bitmap)a=e.bitmap;else{const t=e.width,i=e.height,n=this.canvasFactory.create(t,i);Ji(n.context,e),a=this.applyTransferMapsToCanvas(n.context),r=n}this.dependencyTracker?.resetBBox(t);for(const e of i)s.save(),s.transform(...e.transform),s.scale(1,-1),Qi(s,a,e.x,e.y,e.w,e.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,s,0,1,-1,0),s.restore();r&&this.canvasFactory.destroy(r),this.dependencyTracker?.recordOperation(t),this.compose(),this.#rs(n)}paintSolidColorImageMask(t){if(!this.contentVisible)return;const e=this.#as(this.current.fillAlpha);this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,Ve).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose(),this.#rs(e)}markPoint(t,e){}markPointProps(t,e,i){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,i){this.dependencyTracker?.beginMarkedContent(t),"OC"===e?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(i)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){this.dependencyTracker?.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,i){const n=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(i);const s=this.ctx;this.pendingClip?(n||(this.pendingClip===ln?s.clip(e,"evenodd"):s.clip(e)),this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):this.dependencyTracker?.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=qt(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]),n=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,n)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:i,c:n,d:s}=this.ctx.getTransform();let a,r;if(0===i&&0===n){const i=Math.abs(e),n=Math.abs(s);if(i===n)if(0===t)a=r=1/i;else{const e=i*t;a=r=e<1?1/e:1}else if(0===t)a=1/i,r=1/n;else{const e=i*t,s=n*t;a=e<1?1/e:1,r=s<1?1/s:1}}else{const o=Math.abs(e*s-i*n),l=Math.hypot(e,i),h=Math.hypot(n,s);if(0===t)a=h/o,r=l/o;else{const e=t*o;a=h>e?h/e:1,r=l>e?l/e:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=r}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:i,current:{lineWidth:n}}=this,[s,a]=this.getScaleForStroking();if(s===a)return i.lineWidth=(n||1)*s,void i.stroke(t);const r=i.getLineDash();e&&i.save(),i.scale(s,a),Ki.a=1/s,Ki.d=1/a;const o=new Path2D;if(o.addPath(t,Ki),r.length>0){const t=Math.max(s,a);i.setLineDash(r.map(e=>e/t)),i.lineDashOffset/=t}i.lineWidth=n||1,i.stroke(o),e&&i.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 J)void 0!==hn.prototype[t]&&(hn.prototype[J[t]]=hn.prototype[t]);class dn{#ls=null;#hs=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(t,e,i){this._source=t,this.#ls=e,this.#hs=i}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return ct(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new this.#ls(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new this.#hs(this,t,e);return this._rangeReaders.add(i),i}cancelAllRequests(t){this._fullReader?.cancel(t);for(const e of new Set(this._rangeReaders))e.cancel(t)}}class cn{onProgress=null;_contentLength=0;_filename=null;_headersCapability=Promise.withResolvers();_isRangeSupported=!1;_isStreamingSupported=!1;_loaded=0;_stream=null;constructor(t){this._stream=t}_callOnProgress(){this.onProgress?.({loaded:this._loaded,total:this._contentLength})}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(){dt("Abstract method `read` called")}cancel(t){dt("Abstract method `cancel` called")}}class un{_stream=null;constructor(t,e,i){this._stream=t}async read(){dt("Abstract method `read` called")}cancel(t){dt("Abstract method `cancel` called")}}function pn(t,e){const i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(const t in e){const n=e[t];void 0!==n&&i.append(t,n)}return i}function gn(t){return URL.parse(t)?.origin??null}function mn({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:n}){const s={contentLength:0,isRangeSupported:!1},a=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(a))return s;if(s.contentLength=a,a<=2*i)return s;if(n||!e)return s;if("bytes"!==t.get("Accept-Ranges"))return s;return"identity"===(t.get("Content-Encoding")||"identity")&&(s.isRangeSupported=!0),s}function fn(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=n("filename\\*","i").exec(t);if(i){i=i[1];let t=r(i);return t=unescape(t),t=o(t),t=l(t),a(t)}if(i=function(t){const e=[];let i;const s=n("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=s.exec(t));){let[,t,n,s]=i;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[n,s]}const a=[];for(let t=0;t<e.length&&t in e;++t){let[i,n]=e[t];n=r(n),i&&(n=unescape(n),0===t&&(n=o(n))),a.push(n)}return a.join("")}(t),i)return a(l(i));if(i=n("filename","i").exec(t),i){i=i[1];let t=r(i);return t=l(t),a(t)}function n(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function s(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const n=new TextDecoder(t,{fatal:!0}),s=Ct(i);i=n.decode(s),e=!1}catch{}}return i}function a(t){return e&&/[\x80-\xff]/.test(t)&&(t=s("utf-8",t),e&&(t=s("iso-8859-1",t))),t}function r(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:s(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-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(t,e,i,n){if("q"===i||"Q"===i)return s(e,n=(n=n.replaceAll("_"," ")).replaceAll(/=([0-9a-f]{2})/gi,function(t,e){return String.fromCharCode(parseInt(e,16))}));try{n=atob(n)}catch{}return s(e,n)})}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(Ut(t))return t}return null}function bn(t,e){return new yt(`Unexpected server response (${t}) while retrieving PDF "${e.href}".`,t,404===t||0===t&&"file:"===e.protocol)}function vn(t,e){if(t!==e)throw new Error(`Expected range response-origin "${t}" to match "${e}".`)}function wn(t,e,i,n){return fetch(t,{method:"GET",headers:e,signal:n.signal,mode:"cors",credentials:i?"include":"same-origin",redirect:"follow"})}function yn(t,e){if(200!==t&&206!==t)throw bn(t,e)}function xn(t){if(t instanceof Uint8Array)return t.buffer;if(t instanceof ArrayBuffer)return t;throw new Error(`getArrayBuffer - unexpected data: ${t}`)}class An extends dn{_responseOrigin=null;constructor(t){super(t,Cn,Sn);const{httpHeaders:e,url:i}=t;ct(/https?:/.test(i.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=pn(!0,e)}}class Cn extends cn{_abortController=new AbortController;_reader=null;constructor(t){super(t);const{disableRange:e,disableStream:i,rangeChunkSize:n,url:s,withCredentials:a}=t._source;this._isStreamingSupported=!i;const r=new Headers(t.headers);wn(s,r,a,this._abortController).then(i=>{t._responseOrigin=gn(i.url),yn(i.status,s),this._reader=i.body.getReader();const a=i.headers,{contentLength:r,isRangeSupported:o}=mn({responseHeaders:a,isHttp:!0,rangeChunkSize:n,disableRange:e});this._contentLength=r,this._isRangeSupported=o,this._filename=fn(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new At("Streaming is disabled.")),this._headersCapability.resolve()}).catch(this._headersCapability.reject)}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._callOnProgress(),{value:xn(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Sn extends un{_abortController=new AbortController;_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,i){super(t,e,i);const{url:n,withCredentials:s}=t._source,a=new Headers(t.headers);a.append("Range",`bytes=${e}-${i-1}`),wn(n,a,s,this._abortController).then(e=>{vn(gn(e.url),t._responseOrigin),yn(e.status,n),this._reader=e.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:xn(t),done:!1}}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}function Pn(t){return t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer}function _n(){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}class En extends dn{_progressiveDone=!1;_queuedChunks=[];constructor(t){super(t,Tn,Mn);const{pdfDataRangeTransport:e}=t,{initialData:i,progressiveDone:n}=e;if(i?.length>0){const t=Pn(i);this._queuedChunks.push(t)}this._progressiveDone=n;e.transportReady(t=>{switch(t.type){case"range":case"progressiveRead":this.#ds(t.begin,t.chunk);break;case"progressiveDone":this._fullReader?.progressiveDone(),this._progressiveDone=!0}})}#ds(t,e){const i=Pn(e);if(void 0===t)this._fullReader?this._fullReader._enqueue(i):this._queuedChunks.push(i);else{const e=this._rangeReaders.keys().find(e=>e._begin===t);ct(e,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),e._enqueue(i)}}getFullReader(){const t=super.getFullReader();return this._queuedChunks=null,t}getRangeReader(t,e){const i=super.getRangeReader(t,e);return i&&(i.onDone=()=>this._rangeReaders.delete(i),this._source.pdfDataRangeTransport.requestDataRange(t,e)),i}cancelAllRequests(t){super.cancelAllRequests(t),this._source.pdfDataRangeTransport.abort()}}class Tn extends cn{#cs=_n.bind(this);_done=!1;_queuedChunks=null;_requests=[];constructor(t){super(t);const{pdfDataRangeTransport:e,disableRange:i,disableStream:n}=t._source,{length:s,contentDispositionFilename:a}=e;this._queuedChunks=t._queuedChunks||[];for(const t of this._queuedChunks)this._loaded+=t.byteLength;this._done=t._progressiveDone,this._contentLength=s,this._isStreamingSupported=!n,this._isRangeSupported=!i,Ut(a)&&(this._filename=a),this._headersCapability.resolve();const r=this._loaded;Promise.resolve().then(()=>{r>0&&this._loaded===r&&this._callOnProgress()})}_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,this._callOnProgress()}}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,this.#cs()}progressiveDone(){this._done||=!0,0===this._queuedChunks.length&&this.#cs()}}class Mn extends un{#cs=_n.bind(this);onDone=null;_begin=-1;_done=!1;_queuedChunk=null;_requests=[];constructor(t,e,i){super(t,e,i),this._begin=e}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1}),this.#cs()}this._done=!0,this.onDone?.()}}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,this.#cs(),this.onDone?.()}}class kn extends dn{#us=new WeakMap;_responseOrigin=null;constructor(t){super(t,Dn,In);const{httpHeaders:e,url:i}=t;this.url=i,this.isHttp=/https?:/.test(i.protocol),this.headers=pn(this.isHttp,e)}_request(t){const e=new XMLHttpRequest,i={validateStatus:null,onHeadersReceived:t.onHeadersReceived,onDone:t.onDone,onError:t.onError,onProgress:t.onProgress};this.#us.set(e,i),e.open("GET",this.url),e.withCredentials=this._source.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}`),i.validateStatus=t=>206===t||200===t):i.validateStatus=t=>200===t,e.responseType="arraybuffer",ct(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>t.onError(e.status),e.onreadystatechange=this.#ps.bind(this,e),e.onprogress=this.#gs.bind(this,e),e.send(null),e}#gs(t,e){const i=this.#us.get(t);i?.onProgress?.(e)}#ps(t,e){const i=this.#us.get(t);if(!i)return;if(t.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==t.readyState)return;if(!this.#us.has(t))return;if(this.#us.delete(t),0===t.status&&this.isHttp)return void i.onError(t.status);const n=t.status||200;if(!i.validateStatus(n))return void i.onError(t.status);const s="string"!=typeof(a=t.response)?a:Ct(a).buffer;var a;if(206===n){const e=t.getResponseHeader("Content-Range");/bytes \d+-\d+\/\d+/.test(e)?i.onDone(s):(ht('Missing or invalid "Content-Range" header.'),i.onError(0))}else s?i.onDone(s):i.onError(t.status)}_abortRequest(t){this.#us.has(t)&&(this.#us.delete(t),t.abort())}getRangeReader(t,e){const i=super.getRangeReader(t,e);return i&&(i.onClosed=()=>this._rangeReaders.delete(i)),i}}class Dn extends cn{#cs=_n.bind(this);_cachedChunks=[];_done=!1;_requests=[];_storedError=null;constructor(t){super(t),this._fullRequestXhr=t._request({onHeadersReceived:this.#ms.bind(this),onDone:this.#fs.bind(this),onError:this.#bs.bind(this),onProgress:this.#gs.bind(this)})}#ms(){const t=this._stream,{disableRange:e,rangeChunkSize:i}=t._source,n=this._fullRequestXhr;t._responseOrigin=gn(n.responseURL);const s=n.getAllResponseHeaders(),a=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(t=>{const[e,...i]=t.split(": ");return[e,i.join(": ")]}):[]),{contentLength:r,isRangeSupported:o}=mn({responseHeaders:a,isHttp:t.isHttp,rangeChunkSize:i,disableRange:e});this._contentLength=r,this._isRangeSupported=o,this._filename=fn(a),this._isRangeSupported&&t._abortRequest(n),this._headersCapability.resolve()}#fs(t){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._cachedChunks.push(t);this._done=!0,0===this._cachedChunks.length&&this.#cs()}#bs(t){this._storedError=bn(t,this._stream.url),this._headersCapability.reject(this._storedError);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}#gs(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}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),this.#cs(),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}class In extends un{#cs=_n.bind(this);onClosed=null;_done=!1;_queuedChunk=null;_requests=[];_storedError=null;constructor(t,e,i){super(t,e,i),this._requestXhr=t._request({begin:e,end:i,onHeadersReceived:this.#ms.bind(this),onDone:this.#fs.bind(this),onError:this.#bs.bind(this),onProgress:null})}#ms(){const t=gn(this._requestXhr?.responseURL);try{vn(t,this._stream._responseOrigin)}catch(t){this._storedError=t,this.#bs(0)}}#fs(t){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._queuedChunk=t;this._done=!0,this.#cs(),this.onClosed?.()}#bs(t){this._storedError??=bn(t,this._stream.url);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}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,this.#cs(),this._stream._abortRequest(this._requestXhr),this.onClosed?.()}}function Ln(t,e=null){const i=process.getBuiltinModule("fs"),{Readable:n}=process.getBuiltinModule("stream"),s=i.createReadStream(t,e);return n.toWeb(s)}class Nn extends dn{constructor(t){super(t,Rn,Fn);const{url:e}=t;ct("file:"===e.protocol,"PDFNodeStream only supports file:// URLs.")}}class Rn extends cn{_reader=null;constructor(t){super(t);const{disableRange:e,disableStream:i,rangeChunkSize:n,url:s}=t._source;this._isStreamingSupported=!i;process.getBuiltinModule("fs/promises").lstat(s).then(t=>{const i=Ln(s);this._reader=i.getReader();const{size:a}=t;this._contentLength=a,this._isRangeSupported=!e&&a>2*n,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new At("Streaming is disabled.")),this._headersCapability.resolve()}).catch(t=>{"ENOENT"===t.code&&(t=bn(0,s)),this._headersCapability.reject(t)})}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._callOnProgress(),{value:xn(t),done:!1})}cancel(t){this._reader?.cancel(t)}}class Fn extends un{_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,i){super(t,e,i);const{url:n}=t._source;try{const t=Ln(n,{start:e,end:i-1});this._reader=t.getReader(),this._readCapability.resolve()}catch(t){this._readCapability.reject(t)}}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:xn(t),done:!1}}cancel(t){this._reader?.cancel(t)}}let On=class{static#vs=null;static#ws="";static get workerPort(){return this.#vs}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#vs=t}static get workerSrc(){return this.#ws}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#ws=t}};class Bn{#ys;#xs;constructor({parsedData:t,rawData:e}){this.#ys=t,this.#xs=e}getRaw(){return this.#xs}get(t){return this.#ys.get(t)??null}[Symbol.iterator](){return this.#ys.entries()}}const jn=Symbol("INTERNAL");class Un{#As=!1;#Cs=!1;#Ss=!1;#Ps=!0;constructor(t,{name:e,intent:i,usage:n,rbGroups:s}){this.#As=!!(t&E),this.#Cs=!!(t&T),this.name=e,this.intent=i,this.usage=n,this.rbGroups=s}get visible(){if(this.#Ss)return this.#Ps;if(!this.#Ps)return!1;const{print:t,view:e}=this.usage;return this.#As?"OFF"!==e?.viewState:!this.#Cs||"OFF"!==t?.printState}_setVisible(t,e,i=!1){t!==jn&&dt("Internal method `_setVisible` called."),this.#Ss=i,this.#Ps=e}}class Hn{#_s=null;#Es=new Map;#Ts=null;#Ms=null;constructor(t,e=E){if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#Ms=t.order;for(const i of t.groups)this.#Es.set(i.id,new Un(e,i));if("OFF"===t.baseState)for(const t of this.#Es.values())t._setVisible(jn,!1);for(const e of t.on)this.#Es.get(e)._setVisible(jn,!0);for(const e of t.off)this.#Es.get(e)._setVisible(jn,!1);this.#Ts=this.getHash()}}#ks(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let n=1;n<e;n++){const e=t[n];let s;if(Array.isArray(e))s=this.#ks(e);else{if(!this.#Es.has(e))return ht(`Optional content group not found: ${e}`),!0;s=this.#Es.get(e).visible}switch(i){case"And":if(!s)return!1;break;case"Or":if(s)return!0;break;case"Not":return!s;default:return!0}}return"And"===i}isVisible(t){if(0===this.#Es.size)return!0;if(!t)return lt("Optional content group not defined."),!0;if("OCG"===t.type)return this.#Es.has(t.id)?this.#Es.get(t.id).visible:(ht(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#ks(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this.#Es.has(e))return ht(`Optional content group not found: ${e}`),!0;if(this.#Es.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this.#Es.has(e))return ht(`Optional content group not found: ${e}`),!0;if(!this.#Es.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this.#Es.has(e))return ht(`Optional content group not found: ${e}`),!0;if(!this.#Es.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this.#Es.has(e))return ht(`Optional content group not found: ${e}`),!0;if(this.#Es.get(e).visible)return!1}return!0}return ht(`Unknown optional content policy ${t.policy}.`),!0}return ht(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){const n=this.#Es.get(t);if(n){if(i&&e&&n.rbGroups.length)for(const e of n.rbGroups)for(const i of e)i!==t&&this.#Es.get(i)?._setVisible(jn,!1,!0);n._setVisible(jn,!!e,!0),this.#_s=null}else ht(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let i;for(const n of t){switch(n){case"ON":case"OFF":case"Toggle":i=n;continue}const t=this.#Es.get(n);if(t)switch(i){case"ON":this.setVisibility(n,!0,e);break;case"OFF":this.setVisibility(n,!1,e);break;case"Toggle":this.setVisibility(n,!t.visible,e)}}this.#_s=null}get hasInitialVisibility(){return null===this.#Ts||this.getHash()===this.#Ts}getOrder(){return this.#Es.size?this.#Ms?this.#Ms.slice():[...this.#Es.keys()]:null}getGroup(t){return this.#Es.get(t)||null}getHash(){if(null!==this.#_s)return this.#_s;const t=new Ee;for(const[e,i]of this.#Es)t.update(`${e}:${i.visible}`);return this.#_s=t.hexdigest()}[Symbol.iterator](){return this.#Es.entries()}}class Vn{#Ds=null;#Is=null;#Ls=0;#Ns=null;#Rs=null;get pagesNumber(){return this.#Ls}set pagesNumber(t){this.#Ls!==t&&(this.#Ls=t,this.#Ds=null,this.#Is=null)}#Fs(){if(this.#Ds)return;const t=this.#Ls,e=this.#Ds=new Uint32Array(t);for(let i=0;i<t;i++)e[i]=i+1;this.#Is=new Int32Array(e)}#Os(){const t=new Map,e=this.#Ds;for(let i=0,n=this.#Ls;i<n;i++){const n=e[i],s=t.get(n);s?s.push(i+1):t.set(n,[i+1])}return t}movePages(t,e,i){this.#Fs();const n=this.#Ds,s=this.#Os(),a=e.length,r=new Uint32Array(a);let o=0;for(let t=0;t<a;t++){const s=e[t]-1;r[t]=n[s],s<i&&o++}const l=this.#Ls,h=l-a,d=It(i-o,0,h);for(let e=0,i=0;e<l;e++)t.has(e+1)||(n[i++]=n[e]);n.copyWithin(d+a,d,h),n.set(r,d),this.#Bs(s),n.every((t,e)=>t===e+1)&&(this.#Ds=null)}deletePages(t){this.#Fs();const e=this.#Ds,i=this.#Os();this.#Rs={pageNumberToId:e.slice(),pagesNumber:this.#Ls,prevPageNumbers:this.#Is.slice()};const n=this.#Ls-t.length;this.#Ls=n;const s=this.#Ds=new Uint32Array(n);this.#Is=new Int32Array(n);let a=0,r=0;for(const i of t){const t=i-1;t!==a&&(s.set(e.subarray(a,t),r),r+=t-a),a=t+1}a<e.length&&s.set(e.subarray(a),r),this.#Bs(i,new Set(t))}cancelDelete(){this.#Rs&&(this.#Ds=this.#Rs.pageNumberToId,this.#Ls=this.#Rs.pagesNumber,this.#Is=this.#Rs.prevPageNumbers,this.#Rs=null)}cleanSavedData(){this.#Rs=null}copyPages(t){this.#Fs(),this.#Ns={pageNumbers:t,pageIds:t.map(t=>this.#Ds[t-1])}}cancelCopy(){this.#Ns=null}pastePages(t){this.#Fs();const e=this.#Ds,i=this.#Os(),{pageNumbers:n,pageIds:s}=this.#Ns,a=this.#Ls+n.length;this.#Ls=a;const r=this.#Ds=new Uint32Array(a);this.#Is=new Int32Array(a),r.set(e.subarray(0,t),0),r.set(s,t),r.set(e.subarray(t),t+n.length),this.#Bs(i,null,t,n),this.#Ns=null}#Bs(t,e=null,i=-1,n=null){const s=this.#Is,a=this.#Ds,r=i+(n?.length??0),o=new Map;for(let l=0,h=this.#Ls;l<h;l++){if(l>=i&&l<r){s[l]=-n[l-i];continue}const h=a[l],d=t.get(h);let c=o.get(h)||0;if(e&&d)for(;c<d.length&&e.has(d[c]);)c++;s[l]=d?.[c],o.set(h,c+1)}}hasBeenAltered(){return null!==this.#Ds}getPageMappingForSaving(t=null){t??=this.#Os();let e=0;for(const i of t.values())e=Math.max(e,i.length);const i=new Array(e);for(let t=0;t<e;t++)i[t]={document:null,pageIndices:[],includePages:[]};for(const[e,n]of t)for(let t=0,s=n.length;t<s;t++)i[t].includePages.push([e-1,n[t]-1]);for(const{includePages:t,pageIndices:e}of i){t.sort((t,e)=>t[0]-e[0]);for(let i=0,n=t.length;i<n;i++)e.push(t[i][1]),t[i]=t[i][0]}return i}extractPages(t){t=Array.from(t).sort((t,e)=>t-e);const e=new Map;for(let i=0,n=t.length;i<n;i++){const n=this.getPageId(t[i]);e.getOrInsertComputed(n,Mt).push(i+1)}return this.getPageMappingForSaving(e)}getPrevPageNumber(t){return this.#Is?.[t-1]??0}getPageNumber(t){if(!this.#Ds)return t;const e=this.#Ds;for(let i=0,n=this.#Ls;i<n;i++)if(e[i]===t)return i+1;return 0}getPageId(t){return this.#Ds?.[t-1]??t}getMapping(){return this.#Ds?.subarray(0,this.pagesNumber)}}const zn=Symbol("INITIAL_DATA"),$n=()=>({...Promise.withResolvers(),data:zn});class Wn{#js=new Map;get(t,e=null){if(e){const i=this.#js.getOrInsertComputed(t,$n);return i.promise.then(()=>e(i.data)),null}const i=this.#js.get(t);if(!i||i.data===zn)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#js.get(t);return!!e&&e.data!==zn}delete(t){const e=this.#js.get(t);return!(!e||e.data===zn)&&(this.#js.delete(t),!0)}resolve(t,e=null){const i=this.#js.getOrInsertComputed(t,$n);if(i.data!==zn)throw new Error(`Object already resolved ${t}.`);i.data=e,i.resolve()}clear(){for(const{data:t}of this.#js.values())t?.bitmap?.close();this.#js.clear()}*[Symbol.iterator](){for(const[t,{data:e}]of this.#js)e!==zn&&(yield[t,e])}}let Gn=class t{#Us=Promise.withResolvers();#Et=null;#Hs=!1;#Vs=!!globalThis.FontInspector?.enabled;#zs=null;#$s=null;#Ws=null;#Gs=0;#Xs=0;#Ks=null;#qs=null;#Ys=0;#Qs=0;#Zs=Object.create(null);#Js=[];#ta=null;#ea=[];#ia=new WeakMap;#na=null;static#sa=new Map;static#aa=new Map;static#ra=new WeakMap;static#oa=null;static#la=new Set;constructor({textContentSource:e,images:i,container:n,viewport:s}){if(e instanceof ReadableStream)this.#ta=e;else{if("object"!=typeof e)throw new Error('No "textContentSource" parameter specified.');this.#ta=new ReadableStream({start(t){t.enqueue(e),t.close()}})}this.#Et=this.#qs=n,this.#zs=i,this.#Qs=s.scale*Zt.pixelRatio,this.#Ys=s.rotation,this.#Ws={div:null,properties:null,ctx:null};const{pageWidth:a,pageHeight:r,pageX:o,pageY:l}=s.rawDims;this.#na=[1,0,0,-1,-o,l+r],this.#Xs=a,this.#Gs=r,t.#ha(),n.style.setProperty("--min-font-size",t.#oa),Qt(n,s),this.#Us.promise.finally(()=>{t.#la.delete(this),this.#Ws=null,this.#Zs=null}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=St.platform;return mt(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){this.#zs&&this.#Et.append(this.#zs.render());const e=()=>{this.#Ks.read().then(({value:t,done:i})=>{i?this.#Us.resolve():(this.#$s??=t.lang,Object.assign(this.#Zs,t.styles),this.#da(t.items),e())},this.#Us.reject)};return this.#Ks=this.#ta.getReader(),t.#la.add(this),e(),this.#Us.promise}update({viewport:e,onBefore:i=null}){const n=e.scale*Zt.pixelRatio,s=e.rotation;if(s!==this.#Ys&&(i?.(),this.#Ys=s,Qt(this.#qs,{rotation:s})),n!==this.#Qs){i?.(),this.#Qs=n;const e={div:null,properties:null,ctx:t.#ca(this.#$s)};for(const t of this.#ea)e.properties=this.#ia.get(t),e.div=t,this.#ua(e)}}cancel(){const t=new At("TextLayer task cancelled.");this.#Ks?.cancel(t).catch(()=>{}),this.#Ks=null,this.#Us.reject(t)}get textDivs(){return this.#ea}get textContentItemsStr(){return this.#Js}#da(e){if(this.#Hs)return;this.#Ws.ctx??=t.#ca(this.#$s);const i=this.#ea,n=this.#Js;for(const t of e){if(i.length>1e5)return ht("Ignoring additional textDivs for performance reasons."),void(this.#Hs=!0);if(void 0!==t.str)n.push(t.str),this.#pa(t);else if("beginMarkedContentProps"===t.type||"beginMarkedContent"===t.type){const e=this.#Et;this.#Et=document.createElement("span"),this.#Et.classList.add("markedContent"),t.id&&this.#Et.setAttribute("id",`${t.id}`),"Artifact"===t.tag&&(this.#Et.ariaHidden=!0),e.append(this.#Et)}else"endMarkedContent"===t.type&&(this.#Et=this.#Et.parentNode)}}#pa(e){const i=document.createElement("span"),n={angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,fontSize:0};this.#ea.push(i);const s=Pt.transform(this.#na,e.transform);let a=Math.atan2(s[1],s[0]);const r=this.#Zs[e.fontName];r.vertical&&(a+=Math.PI/2);let o=this.#Vs&&r.fontSubstitution||r.fontFamily;o=t.fontFamilyMap.get(o)||o;const l=Math.hypot(s[2],s[3]),h=l*t.#ga(o,r,this.#$s);let d,c;0===a?(d=s[4],c=s[5]-h):(d=s[4]+h*Math.sin(a),c=s[5]-h*Math.cos(a));const u=i.style;u.left=`${(100*d/this.#Xs).toFixed(2)}%`,u.top=`${(100*c/this.#Gs).toFixed(2)}%`,u.setProperty("--font-height",`${l.toFixed(2)}px`),u.fontFamily=o,n.fontSize=l,i.setAttribute("role","presentation"),i.textContent=e.str,i.dir=e.dir,this.#Vs&&(i.dataset.fontName=r.fontSubstitutionLoadedName||e.fontName),0!==a&&(n.angle=a*(180/Math.PI));let p=!1;if(e.str.length>1)p=!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&&(p=!0)}if(p&&(n.canvasWidth=r.vertical?e.height:e.width),this.#ia.set(i,n),this.#Ws.div=i,this.#Ws.properties=n,this.#ua(this.#Ws),n.hasText&&this.#Et.append(i),n.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#Et.append(t)}}#ua(e){const{div:i,properties:n,ctx:s}=e,{style:a}=i;if(0!==n.canvasWidth&&n.hasText){const{fontFamily:e}=a,{canvasWidth:r,fontSize:o}=n;t.#ma(s,o*this.#Qs,e);const{width:l}=s.measureText(i.textContent);l>0&&a.setProperty("--scale-x",r*this.#Qs/l)}0!==n.angle&&a.setProperty("--rotate",`${n.angle}deg`)}static cleanup(){if(!(this.#la.size>0)){this.#sa.clear();for(const{canvas:t}of this.#aa.values())t.remove();this.#aa.clear()}}static#ca(t=null){let e=this.#aa.get(t||="");if(!e){const i=document.createElement("canvas");i.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#aa.set(t,e),this.#ra.set(e,{size:0,family:""})}return e}static#ma(t,e,i){const n=this.#ra.get(t);e===n.size&&i===n.family||(t.font=`${e}px ${i}`,n.size=e,n.family=i)}static#ha(){if(null!==this.#oa)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.#oa=t.getBoundingClientRect().height,t.remove()}static#ga(t,e,i){const n=this.#sa.get(t);if(n)return n;const s=this.#ca(i);s.canvas.width=s.canvas.height=30,this.#ma(s,30,t);const a=s.measureText(""),r=a.fontBoundingBoxAscent,o=Math.abs(a.fontBoundingBoxDescent);s.canvas.width=s.canvas.height=0;let l=.8;return r?l=r/(r+o):(St.platform.isFirefox&&ht("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?l=e.ascent:e.descent&&(l=1+e.descent)),this.#sa.set(t,l),l}};function Xn(t={}){const e=new Kn,{docId:i}=e,n=t.url?function(t){if(t instanceof URL)return t;if("string"==typeof t){if(y){if(/^[a-z][a-z0-9\-+.]+:/i.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}const e=URL.parse(t,window.location);if(e)return e}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,s=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 Ct(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,a=t.httpHeaders||null,r=!0===t.withCredentials,o=t.password??null,l=t.range instanceof qn?t.range:null,h=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536;let d=t.worker instanceof Zn?t.worker:null;const c=t.verbosity,u="string"!=typeof t.docBaseUrl||jt(t.docBaseUrl)?null:t.docBaseUrl,p=ri(t.cMapUrl),g=!1!==t.cMapPacked,m=ri(t.iccUrl),f=ri(t.standardFontDataUrl),b=ri(t.wasmUrl),v=!0!==t.stopAtErrors,w=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,x="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!y,A="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!y,C=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,S="boolean"==typeof t.disableFontFace?t.disableFontFace:y,P=!0===t.fontExtraProperties,_=!0===t.enableXfa,E=t.ownerDocument||globalThis.document,T=!0===t.disableRange,M=!0===t.disableStream,k=!0===t.disableAutoFetch,D=!0===t.pdfBug,I=t.CanvasFactory||(y?Di:_i),L=t.FilterFactory||(y?ki:Ti),N=t.BinaryDataFactory||(y?Ii:Si),R=!0===t.enableHWA,F=!0===t.enableWebGPU?Li.init():Promise.resolve(!1),O=!1!==t.useWasm,B=t.pagesMapper||new Vn,j="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!y&&!S,U="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(N===Si&&p&&g&&f&&b&&zt(p,document.baseURI)&&zt(f,document.baseURI)&&zt(b,document.baseURI));rt(c);const H={canvasFactory:new I({ownerDocument:E,enableHWA:R}),filterFactory:new L({docId:i,ownerDocument:E}),binaryDataFactory:U?null:new N({cMapUrl:p,standardFontDataUrl:f,wasmUrl:b})};d||(d=Zn.create({verbosity:c,port:On.workerPort}),e._worker=d);const V={docId:i,apiVersion:"6.0.227",data:s,password:o,disableAutoFetch:k,rangeChunkSize:h,docBaseUrl:u,enableXfa:_,evaluatorOptions:{maxImageSize:w,disableFontFace:S,ignoreErrors:v,isOffscreenCanvasSupported:x,isImageDecoderSupported:A,canvasMaxAreaInBytes:C,fontExtraProperties:P,useSystemFonts:j,useWasm:O,useWorkerFetch:U,cMapUrl:p,cMapPacked:g,iccUrl:m,standardFontDataUrl:f,wasmUrl:b,hasGPU:!1}},z={ownerDocument:E,pdfBug:D,styleElement:null,enableHWA:R,loadingParams:{disableAutoFetch:k,enableXfa:_}};return Promise.all([d.promise,F]).then(function([,t]){if(d.destroyed)throw new Error("Worker was destroyed");V.evaluatorOptions.hasGPU=t;const o=d.messageHandler.sendWithPromise("GetDocRequest",V,s?[s.buffer]:null);let c;if(s);else if(l)c=new En({pdfDataRangeTransport:l,disableRange:T,disableStream:M});else{if(!n)throw new Error("getDocument - expected either `data`, `range`, or `url` parameter.");{const t=function(t){return zt(t)?An:y?Nn:kn}(n);c=new t({url:n,httpHeaders:a,withCredentials:r,rangeChunkSize:h,disableRange:T,disableStream:M})}}return o.then(t=>{if(d.destroyed)throw new Error("Worker was destroyed");const n=new Ai(i,t,d.port),s=new Jn(n,e,c,z,H,B);if(e._transport=s,e.destroyed)throw new Error("Loading aborted");n.send("Ready",null)})}).catch(e._capability.reject).finally(e._setupCapability.resolve),e}class Kn{static#An=0;_capability=Promise.withResolvers();_setupCapability=Promise.withResolvers();_transport=null;_worker=null;docId="d"+Kn.#An++;destroyed=!1;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=!0,this._capability.promise.catch(()=>{});try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._setupCapability.promise,await(this._transport?.destroy())}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}async getData(){return this._transport.getData()}}let qn=class{#Us=Promise.withResolvers();#fa=null;constructor(t,e,i=!1,n=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=n}onDataRange(t,e){this.#fa({type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){this.#Us.promise.then(()=>{this.#fa({type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){this.#Us.promise.then(()=>{this.#fa({type:"progressiveDone"})})}transportReady(t){this.#fa=t,this.#Us.resolve()}requestDataRange(t,e){dt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class Yn{constructor(t,e){this._pdfInfo=t,this._transport=e}get pagesMapper(){return this._transport.pagesMapper}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 mt(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()}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}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()}extractPages(t){return this._transport.extractPages(t)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}getRawData(t){return this._transport.getRawData(t)}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}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 Qn{#ba=!1;#va=null;constructor(t,e,i,n,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new Vt:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new Wn,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,this.#va=n,this.imageCoordinates=null}clone(t){const e=new Qn(t,this._pageInfo,this._transport,this.#va,this._pdfBug);return e.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(e),e}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-1,this._transport.updatePage(this)}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:n=0,dontFlip:s=!1}={}){return new Lt({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:n,dontFlip:s})}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 mt(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,canvas:e=t.canvas,viewport:i,intent:n="display",annotationMode:s=N.ENABLE,transform:a=null,background:r=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:h=null,printAnnotationStorage:d=null,isEditing:c=!1,recordImages:u=!1,recordOperations:p=!1,operationsFilter:g=null}){this._stats?.time("Overall");const m=this._transport.getRenderingIntent(n,s,d,c),{renderingIntent:f,cacheKey:b}=m;this.#ba=!1,o||=this._transport.getOptionalContentConfig(f);const v=this._intentStates.getOrInsertComputed(b,Dt);v.streamReaderCancelTimeout&&(clearTimeout(v.streamReaderCancelTimeout),v.streamReaderCancelTimeout=null);const w=!!(f&T);v.displayReadyCapability||(v.displayReadyCapability=Promise.withResolvers(),v.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(m));const y=!(!this._pdfBug||!globalThis.StepperManager?.enabled),x=!!e&&!this.recordedBBoxes&&(p||y),A=!!e&&!this.imageCoordinates&&u,C=t=>{if(v.renderTasks.delete(_),x){const t=_.gfx?.dependencyTracker.take();t&&(_.stepper?.setOperatorBBoxes(t,_.gfx.dependencyTracker.takeDebugMetadata()),p&&(this.recordedBBoxes=t))}A&&!t&&(this.imageCoordinates=_.gfx?.imagesTracker.take()),w&&(this.#ba=!0),this.#wa(),t?(_.capability.reject(t),this._abortOperatorList({intentState:v,reason:t instanceof Error?t:new Error(t)})):_.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))};let S=null,P=null;(x||A)&&(P=new Be(e,v.operatorList.length)),x&&(S=new je(P,y));const _=new es({callback:C,params:{canvas:e,canvasContext:t,dependencyTracker:S??P,imagesTracker:A?new Ke(e):null,viewport:i,transform:a,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:v.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!w,pdfBug:this._pdfBug,pageColors:h,enableHWA:this._transport.enableHWA,operationsFilter:g});(v.renderTasks||=new Set).add(_);const E=_.task;return Promise.all([v.displayReadyCapability.promise,o]).then(([t,e])=>{if(this.destroyed)C();else{if(this._stats?.time("Rendering"),!(e.renderingIntent&f))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");_.initializeGraphics({transparency:t,optionalContentConfig:e}),_.operatorListChanged()}}).catch(C),E}getOperatorList({intent:t="display",annotationMode:e=N.ENABLE,printAnnotationStorage:i=null,isEditing:n=!1}={}){const s=this._transport.getRenderingIntent(t,e,i,n,!0),a=this._intentStates.getOrInsertComputed(s.cacheKey,Dt);let r;return 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(s)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:this.#va.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(t=>Nt.textContent(t));const e=this.streamTextContent(t),i={items:[],styles:Object.create(null),lang:null};for await(const t of e)i.lang??=t.lang,Object.assign(i.styles,t.styles),i.items.push(...t.items);return 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.#ba=!1,Promise.all(t)}cleanup(t=!1){this.#ba=!0;const e=this.#wa();return t&&e&&(this._stats&&=new Vt),e}#wa(){if(!this.#ba||this.destroyed)return!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.#ba=!1,!0}_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,n=t.length;i<n;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.#wa()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:n}){const{map:s,transfer:a}=i,r=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:this.#va.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:s,modifiedIds:n},void 0,a).getReader(),o=this._intentStates.get(e);o.streamReader=r;const l=()=>{r.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.#wa()}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 Bt){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 At(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}}let Zn=class t{#Us=Promise.withResolvers();#ya=null;#vs=null;#xa=null;static#Aa=0;static#Ca=!1;static#Sa=new WeakMap;static{y&&(this.#Ca=!0,On.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{const i=URL.parse(t);if(!i?.origin||"null"===i.origin)return!1;const n=new URL(e,i);return i.origin===n.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:n=ot()}={}){if(this.name=e,this.destroyed=!1,this.verbosity=n,i){if(t.#Sa.has(i))throw new Error("Cannot use more than one PDFWorker per port.");t.#Sa.set(i,this),this.#Pa(i)}else this.#_a()}get promise(){return this.#Us.promise}#Ea(){this.#Us.resolve(),this.#ya.send("configure",{verbosity:this.verbosity})}get port(){return this.#vs}get messageHandler(){return this.#ya}#Pa(t){this.#vs=t,this.#ya=new Ai("main","worker",t),this.#ya.on("ready",()=>{}),this.#Ea()}#_a(){if(t.#Ca||t.#Ta)return void this.#Ma();let{workerSrc:e}=t;try{t._isSameOrigin(window.location,e)||(e=t._createCDNWrapper(new URL(e,window.location).href));const i=new Worker(e,{type:"module"}),n=new Ai("main","worker",i),s=()=>{a.abort(),n.destroy(),i.terminate(),this.destroyed?this.#Us.reject(new Error("Worker was destroyed")):this.#Ma()},a=new AbortController;i.addEventListener("error",()=>{this.#xa||s()},{signal:a.signal}),n.on("test",t=>{a.abort(),!this.destroyed&&t?(this.#ya=n,this.#vs=i,this.#xa=i,this.#Ea()):s()}),n.on("ready",t=>{if(a.abort(),this.destroyed)s();else try{r()}catch{this.#Ma()}});const r=()=>{const t=new Uint8Array;n.send("test",t,[t.buffer])};return void r()}catch{lt("The worker has been disabled.")}this.#Ma()}#Ma(){t.#Ca||(ht("Setting up fake worker."),t.#Ca=!0),t._setupFakeWorkerGlobal.then(e=>{if(this.destroyed)return void this.#Us.reject(new Error("Worker was destroyed"));const i=new hi;this.#vs=i;const n="fake"+t.#Aa++,s=new Ai(n+"_worker",n,i);e.setup(s,i),this.#ya=new Ai(n,n+"_worker",i),this.#Ea()}).catch(t=>{this.#Us.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this.#xa?.terminate(),this.#xa=null,t.#Sa.delete(this.#vs),this.#vs=null,this.#ya?.destroy(),this.#ya=null}static create(e){const i=this.#Sa.get(e?.port);if(i){if(i._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return i}return new t(e)}static get workerSrc(){if(On.workerSrc)return On.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#Ta(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return mt(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#Ta)return this.#Ta;return(await import(this.workerSrc)).WorkerMessageHandler})())}};class Jn{downloadInfoCapability=Promise.withResolvers();#ka=null;#Da=new Map;#Ia=null;#La=new Map;#Na=new Map;#Ra=new Map;#Fa=null;constructor(t,e,i,n,s,a){this.messageHandler=t,this.loadingTask=e,this.#Ia=i,this.commonObjs=new Wn,this.fontLoader=new qe({ownerDocument:n.ownerDocument,styleElement:n.styleElement}),this.enableHWA=n.enableHWA,this.loadingParams=n.loadingParams,this._params=n,this.canvasFactory=s.canvasFactory,this.filterFactory=s.filterFactory,this.binaryDataFactory=s.binaryDataFactory,this.pagesMapper=a,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(t){const{_pageIndex:e}=t;this.#La.set(e,t),this.#Na.set(e,Promise.resolve(t))}#Oa(t,e=null){return this.#Da.getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,e))}#gs({loaded:t,total:e}){this.loadingTask.onProgress?.({loaded:t,total:e,percent:e?It(Math.round(t/e*100),0,100):NaN})}get annotationStorage(){return mt(this,"annotationStorage",new Me)}getRenderingIntent(t,e=N.ENABLE,i=null,n=!1,s=!1){let a=E,r=Te;switch(t){case"any":a=_;break;case"display":break;case"print":a=T;break;default:ht(`getRenderingIntent - invalid intent: ${t}`)}const o=a&T&&i instanceof ke?i:this.annotationStorage;switch(e){case N.DISABLE:a+=D;break;case N.ENABLE:break;case N.ENABLE_FORMS:a+=M;break;case N.ENABLE_STORAGE:a+=k,r=o.serializable;break;default:ht(`getRenderingIntent - invalid annotationMode: ${e}`)}n&&(a+=I),s&&(a+=L);const{ids:l,hash:h}=o.modifiedIds;return{renderingIntent:a,cacheKey:[a,r.hash,h].join("_"),annotationStorageSerializable:r,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#Fa?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#La.values())t.push(e._destroy());this.#La.clear(),this.#Na.clear(),this.#Ra.clear(),Object.hasOwn(this,"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.#Da.clear(),this.filterFactory.destroy(),Gn.cleanup(),this.#Ia?.cancelAllRequests(new At("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)=>{ct(this.#Ia,"GetReader - no `BasePDFStream` instance available."),this.#ka=this.#Ia.getFullReader(),this.#ka.onProgress=t=>this.#gs(t),e.onPull=()=>{this.#ka.read().then(function({value:t,done:i}){i?e.close():(ct(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{this.#ka.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("ReaderHeadersReady",async t=>{await this.#ka.headersReady;const{isStreamingSupported:e,isRangeSupported:i,contentLength:n}=this.#ka;return e&&i&&(this.#ka.onProgress=null),{isStreamingSupported:e,isRangeSupported:i,contentLength:n}}),t.on("GetRangeReader",(t,e)=>{ct(this.#Ia,"GetRangeReader - no `BasePDFStream` instance available.");const i=this.#Ia.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then(function({value:t,done:i}){i?e.close():(ct(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.pagesMapper.pagesNumber=t.numPages,this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new Yn(t,this))}),t.on("DocException",t=>{e._capability.reject(xi(t))}),t.on("PasswordRequest",t=>{this.#Fa=Promise.withResolvers();try{if(!e.onPassword)throw xi(t);const i=t=>{t instanceof Error?this.#Fa.reject(t):this.#Fa.resolve({password:t})};e.onPassword(i,t.code)}catch(t){this.#Fa.reject(t)}return this.#Fa.promise}),t.on("DataLoaded",t=>{this.#gs({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)}),t.on("StartRenderPage",t=>{if(this.destroyed)return;this.#La.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}),t.on("commonobj",([e,i,n])=>{if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(i){case"Font":if("error"in n){const t=n.error;ht(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const s=new ni(n),a=this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,r=new Ye(s,a,n.charProcOperatorList,n.extra);this.fontLoader.bind(r).catch(()=>t.sendWithPromise("FontFallback",{id:e})).finally(()=>{r.fontExtraProperties||r.clearData(),this.commonObjs.resolve(e,r)});break;case"CopyLocalImage":const{imageRef:o}=n;ct(o,"The imageRef must be defined.");for(const t of this.#La.values())for(const[,i]of t.objs){if(i?.ref!==o)continue;if(!i.dataLen)return null;const t=structuredClone(i);return this.commonObjs.resolve(e,t),i.dataLen}break;case"FontPath":this.commonObjs.resolve(e,new ai(n));break;case"Image":this.commonObjs.resolve(e,n);break;case"Pattern":const l=new si(n);this.commonObjs.resolve(e,l.getIR());break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([t,e,i,n])=>{if(this.destroyed)return;const s=this.#La.get(e);if(!s.objs.has(t))if(0!==s._intentStates.size)switch(i){case"Image":case"Pattern":s.objs.resolve(t,n);break;default:throw new Error(`Got unknown object type ${i}`)}else n?.bitmap?.close()}),t.on("DocProgress",t=>{this.destroyed||this.#gs(t)}),t.on("FetchBinaryData",async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.binaryDataFactory)throw new Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(t)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&ht("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.#ka?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}extractPages(t){const e={pageInfos:t};let i;const n=globalThis.ImageBitmap;if("function"==typeof n){const e=Array.isArray(t)?t:[t];for(const t of e)t?.image instanceof n&&(i||=[]).push(t.image)}if(this.annotationStorage.size>0){const t=this.annotationStorage.serializable;let{map:n}=t;t.transfer?.length&&(i?i.push(...t.transfer):i=t.transfer);const s=this.pagesMapper.getMapping();if(s){const t=new Map;for(const[e,i]of n){if(void 0!==i?.pageIndex&&i.pageIndex>=0&&i.pageIndex<s.length){const n=s[i.pageIndex]-1;if(n!==i.pageIndex){t.set(e,{...i,pageIndex:n});continue}}t.set(e,i)}n=t}e.annotationStorage=n}return this.messageHandler.sendWithPromise("ExtractPages",e,i).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(new Error("Invalid page request."));const e=t-1,i=this.pagesMapper.getPageId(t)-1,n=this.#Na.get(e);if(n)return n;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:i}).then(t=>{if(this.destroyed)throw new Error("Transport destroyed");t.refStr&&this.#Ra.set(t.refStr,i);const n=new Qn(e,t,this,this.pagesMapper,this._params.pdfBug);return this.#La.set(e,n),n});return this.#Na.set(e,s),s}async getPageIndex(t){if(!oi(t))throw new Error("Invalid pageIndex request.");const e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),i=this.pagesMapper.getPageNumber(e+1);if(0===i)throw new Error("GetPageIndex: page has been removed.");return i-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:e})}getFieldObjects(){return this.#Oa("GetFieldObjects")}hasJSActions(){return this.#Oa("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)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#Oa("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#Oa("GetOptionalContentConfig").then(e=>new Hn(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata";return this.#Da.getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,null).then(t=>({info:t[0],metadata:t[1]?new Bn(t[1]):null,contentDispositionFilename:this.#ka?.filename??null,contentLength:this.#ka?.contentLength??null,hasStructTree:t[2]})))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}getRawData(t){return this.messageHandler.sendWithPromise("GetRawData",t)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of this.#La.values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),this.#Da.clear(),this.filterFactory.destroy(!0),Gn.cleanup()}}cachedPageNumber(t){if(!oi(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`,i=this.#Ra.get(e);if(i>=0){const t=this.pagesMapper.getPageNumber(i+1);if(0!==t)return t}return null}}class ts{_internalRenderTask=null;onContinue=null;onError=null;constructor(t){this._internalRenderTask=t}get promise(){return this._internalRenderTask.capability.promise}cancel(t=0){this._internalRenderTask.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this._internalRenderTask.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this._internalRenderTask;return t.form||t.canvas&&e?.size>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}class es{#Ba=null;static#ja=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:n,annotationCanvasMap:s,operatorList:a,pageIndex:r,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:c=null,enableHWA:u=!1,operationsFilter:p=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=n,this.annotationCanvasMap=s,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=r,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 ts(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.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=u,this._dependencyTracker=e.dependencyTracker,this._imagesTracker=e.imagesTracker,this._operationsFilter=p}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(es.#ja.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.");es.#ja.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{viewport:i,transform:n,background:s,dependencyTracker:a,imagesTracker:r}=this.params,o=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new hn(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,a,r),this.gfx.beginDrawing({transform:n,viewport:i,transparency:t,background:s}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#Ba&&(window.cancelAnimationFrame(this.#Ba),this.#Ba=null),es.#ja.delete(this._canvas),t||=new Bt(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){this.graphicsReady?(this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),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.#Ba=window.requestAnimationFrame(()=>{this.#Ba=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._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),es.#ja.delete(this._canvas),this.callback())))}}let is=class t{#Ua=null;#Ha=null;#Va;#za=null;#$a=!1;#Wa=!1;#r=null;#Ga;#Xa=null;#v=null;static#Ka=null;static get _keyboardManager(){return mt(this,"_keyboardManager",new fe([[["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.#Wa=!1,this.#r=e):this.#Wa=!0,this.#v=e?._uiManager||i,this.#Ga=this.#v._eventBus,this.#Va=e?.color?.toUpperCase()||this.#v?.highlightColors.values().next().value||"#FFFF98",t.#Ka||=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.#Ua=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#r&&(t.ariaControls=`${this.#r.id}_colorpicker_dropdown`);const e=this.#v._signal;t.addEventListener("click",this.#qa.bind(this),{signal:e}),t.addEventListener("keydown",this.#Ya.bind(this),{signal:e});const i=this.#Ha=document.createElement("span");return i.className="swatch",i.ariaHidden="true",i.style.backgroundColor=this.#Va,t.append(i),t}renderMainDropdown(){const t=this.#za=this.#Qa();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#Qa(){const e=document.createElement("div"),i=this.#v._signal;e.addEventListener("contextmenu",$t,{signal:i}),e.className="dropdown",e.role="listbox",e.ariaMultiSelectable="false",e.ariaOrientation="vertical",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#r&&(e.id=`${this.#r.id}_colorpicker_dropdown`);for(const[n,s]of this.#v.highlightColors){const a=document.createElement("button");a.tabIndex="0",a.role="option",a.setAttribute("data-color",s),a.title=n,a.setAttribute("data-l10n-id",t.#Ka[n]);const r=document.createElement("span");a.append(r),r.className="swatch",r.style.backgroundColor=s,a.ariaSelected=s===this.#Va,a.addEventListener("click",this.#Za.bind(this,s),{signal:i}),e.append(a)}return e.addEventListener("keydown",this.#Ya.bind(this),{signal:i}),e}#Za(t,e){e.stopPropagation(),this.#Ga.dispatch("switchannotationeditorparams",{source:this,type:B.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)}_colorSelectFromKeyboard(t){if(t.target===this.#Ua)return void this.#qa(t);const e=t.target.getAttribute("data-color");e&&this.#Za(e,t)}_moveToNext(t){this.#Ja?t.target!==this.#Ua?t.target.nextSibling?.focus():this.#za.firstElementChild?.focus():this.#qa(t)}_moveToPrevious(t){t.target!==this.#za?.firstElementChild&&t.target!==this.#Ua?(this.#Ja||this.#qa(t),t.target.previousSibling?.focus()):this.#Ja&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#Ja?this.#za.firstElementChild?.focus():this.#qa(t)}_moveToEnd(t){this.#Ja?this.#za.lastElementChild?.focus():this.#qa(t)}#Ya(e){t._keyboardManager.exec(this,e)}#qa(t){if(this.#Ja)return void this.hideDropdown();if(this.#$a=0===t.detail,this.#Xa||(this.#Xa=new AbortController,window.addEventListener("pointerdown",this.#p.bind(this),{signal:this.#v.combinedSignal(this.#Xa)})),this.#Ua.ariaExpanded="true",this.#za)return void this.#za.classList.remove("hidden");const e=this.#za=this.#Qa();this.#Ua.append(e)}#p(t){this.#za?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#za?.classList.add("hidden"),this.#Ua.ariaExpanded="false",this.#Xa?.abort(),this.#Xa=null}get#Ja(){return this.#za&&!this.#za.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#Wa||(this.#Ja?(this.hideDropdown(),this.#Ua.focus({preventScroll:!0,focusVisible:this.#$a})):this.#r?.unselect())}updateColor(t){if(this.#Ha&&(this.#Ha.style.backgroundColor=t),!this.#za)return;const e=this.#v.highlightColors.values();for(const i of this.#za.children)i.ariaSelected=e.next().value===t.toUpperCase()}destroy(){this.#Ua?.remove(),this.#Ua=null,this.#Ha=null,this.#za?.remove(),this.#za=null}};class ns{#tr=null;#er=!1;#r=null;#v=null;static#Ka=null;constructor(t){this.#r=t,this.#v=t._uiManager,ns.#Ka||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#tr)return this.#tr;const{editorType:t,colorType:e,colorAndOpacityType:i,opacityType:n,color:s,opacity:a}=this.#r,r=this.#er=St.isAlphaColorInputSupported&&void 0!==n,o=this.#tr=document.createElement("input");if(o.type="color",r){o.setAttribute("alpha","");const t=Pt.hexNums[Math.round(255*(a??1))];o.value=(s||"#000000")+t}else o.value=s||"#000000";return o.className="basicColorPicker",o.tabIndex=0,o.setAttribute("data-l10n-id",ns.#Ka[t]),o.addEventListener("input",()=>{if(r){const t=Xt(o.value);if(!t)return;const[s,a,r,l]=t,h=Pt.makeHexColor(s,a,r);void 0!==i?this.#v.updateParams(i,{color:h,opacity:l}):(this.#v.updateParams(e,h),this.#v.updateParams(n,l))}else this.#v.updateParams(e,o.value)},{signal:this.#v._signal}),o}update(t){if(this.#tr)if(this.#er){const e=Pt.hexNums[Math.round(255*this.#r.opacity)];this.#tr.value=t+e}else this.#tr.value=t}updateOpacity(t){if(!this.#tr||!this.#er)return;const e=Pt.hexNums[Math.round(255*t)];this.#tr.value=this.#r.color+e}destroy(){this.#tr?.remove(),this.#tr=null}hideDropdown(){}}function ss(t){return Math.floor(255*It(t,0,1)).toString(16).padStart(2,"0")}function as(t){return 255*It(t,0,1)}class rs{static CMYK_G([t,e,i,n]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+n)]}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=ss(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(ss).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,n]){return["RGB",1-Math.min(1,t+n),1-Math.min(1,i+n),1-Math.min(1,e+n)]}static CMYK_rgb([t,e,i,n]){return[as(1-Math.min(1,t+n)),as(1-Math.min(1,i+n)),as(1-Math.min(1,e+n))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const n=1-t,s=1-e,a=1-i;return["CMYK",n,s,a,Math.min(n,s,a)]}}class os{create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const n=this._createSVG("svg:svg");return n.setAttribute("version","1.1"),i||(n.setAttribute("width",`${t}px`),n.setAttribute("height",`${e}px`)),n.setAttribute("preserveAspectRatio","none"),n.setAttribute("viewBox",`0 0 ${t} ${e}`),n}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){dt("Abstract method `_createSVG` called.")}}let ls=class extends os{_createSVG(t){return document.createElementNS(P,t)}};const hs=new WeakSet,ds=60*(new Date).getTimezoneOffset()*1e3;class cs{static create(t){switch(t.data.annotationType){case G.LINK:return new gs(t);case G.TEXT:return new ms(t);case G.WIDGET:switch(t.data.fieldType){case"Tx":return new bs(t);case"Btn":return t.data.radioButton?new ys(t):t.data.checkBox?new ws(t):new xs(t);case"Ch":return new As(t);case"Sig":return new vs(t)}return new fs(t);case G.POPUP:return new Cs(t);case G.FREETEXT:return new Ps(t);case G.LINE:return new _s(t);case G.SQUARE:return new Es(t);case G.CIRCLE:return new Ts(t);case G.POLYLINE:return new Ms(t);case G.CARET:return new Ds(t);case G.INK:return new Is(t);case G.POLYGON:return new ks(t);case G.HIGHLIGHT:return new Ls(t);case G.UNDERLINE:return new Ns(t);case G.SQUIGGLY:return new Rs(t);case G.STRIKEOUT:return new Fs(t);case G.STAMP:return new Os(t);case G.FILEATTACHMENT:return new Bs(t);default:return new us(t)}}}class us{#ir=null;#nr=!1;#sr=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:n=!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.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,this.hasOwnCommentButton=!1,e&&(this.contentElement=this.container=this._createContainer(i)),n&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!(!t?.str&&!e?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return us._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){const{data:t}=this,e=this.annotationStorage?.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){const t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:e,inkLists:i,rect:n}=this.data;let s=-1/0,a=-1/0;if(e?.length>=8){for(let t=0;t<e.length;t+=8)e[t+1]>a?(a=e[t+1],s=e[t+2]):e[t+1]===a&&(s=Math.max(s,e[t+2]));return[s,a]}if(i?.length>=1){for(const t of i)for(let e=0,i=t.length;e<i;e+=2)t[e+1]>a?(a=t[e+1],s=t[e]):t[e+1]===a&&(s=Math.max(s,t[e]));if(s!==1/0)return[s,a]}return n?[n[2],n[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:i,pageHeight:n,pageX:s,pageY:a}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-s)/i,t[1]=100*(t[1]-a)/n,t}get commentText(){const{data:t}=this;return this.annotationStorage.getRawValue(`${F}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){const{data:e}=this,i={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:i})||this.annotationStorage.setValue(`${F}${e.id}`,{id:e.id,annotationType:e.annotationType,page:this.parent.page,popup:i,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){(this.#sr?.popup||this.popup)?.remove(),this.#sr=this.popup=null}updateEdited(t){if(!this.container)return;t.rect&&(this.#ir||={rect:this.data.rect.slice(0)});const{rect:e,popup:i}=t;e&&this.#ar(e);let n=this.#sr?.popup||this.popup;!n&&i?.text&&(this._createPopup(i),n=this.#sr.popup),n&&(n.updateEdited(t),i?.deleted&&(n.remove(),this.#sr=null,this.popup=null))}resetEdited(){this.#ir&&(this.#ar(this.#ir.rect),this.#sr?.popup.resetEdited(),this.#ir=null)}#ar(t){const{container:{style:e},data:{rect:i,rotation:n},parent:{viewport:{rawDims:{pageWidth:s,pageHeight:a,pageX:r,pageY:o}}}}=this;i?.splice(0,4,...t),e.left=100*(t[0]-r)/s+"%",e.top=100*(a-t[3]+o)/a+"%",0===n?(e.width=100*(t[2]-t[0])/s+"%",e.height=100*(t[3]-t[1])/a+"%"):this.setRotation(n)}_createContainer(t){const{data:e,parent:{page:i,viewport:n}}=this,s=document.createElement("section");s.setAttribute("data-annotation-id",e.id),this instanceof fs||this instanceof gs||(s.tabIndex=0);const{style:a}=s;if(a.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(s.title=e.alternativeText),e.noRotate&&s.classList.add("norotate"),!e.rect||this instanceof Cs){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,s),s}const{width:r,height:o}=this;if(!t&&e.borderStyle.width>0){a.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(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`;a.borderRadius=e}else if(this instanceof ys){const t=`calc(${r}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`;a.borderRadius=t}switch(e.borderStyle.style){case X:a.borderStyle="solid";break;case K:a.borderStyle="dashed";break;case q:ht("Unimplemented border style: beveled");break;case Y:ht("Unimplemented border style: inset");break;case Q:a.borderBottomStyle="solid"}const n=e.borderColor||null;n?(this.#nr=!0,a.borderColor=Pt.makeHexColor(...n)):a.borderWidth=0}const l=Pt.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}=n.rawDims;a.left=100*(l[0]-c)/h+"%",a.top=100*(l[1]-u)/d+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(a.width=100*r/h+"%",a.height=100*o/d+"%"):this.setRotation(p,s),s}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:n}=this.parent.viewport.rawDims;let{width:s,height:a}=this;t%180!=0&&([s,a]=[a,s]),e.style.width=100*s/i+"%",e.style.height=100*a/n+"%",e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,i)=>{const n=i.detail[t],s=n[0],a=n.slice(1);i.target.style[e]=rs[`${s}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[e]:rs[`${s}_rgb`](a)})};return mt(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 n of Object.keys(e.detail)){const s=t[n]||i[n];s?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[n,s]of Object.entries(e)){const a=i[n];if(a){a({detail:{[n]:s},target:t}),delete e[n]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,n,s]=this.data.rect.map(t=>Math.fround(t));if(8===t.length){const[a,r,o,l]=t.subarray(2,6);if(n===a&&s===r&&e===o&&i===l)return}const{style:a}=this.container;let r;if(this.#nr){const{borderColor:t,borderWidth:e}=a;a.borderWidth=0,r=["url('data:image/svg+xml;utf8,",`<svg xmlns="${P}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const o=n-e,l=s-i,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0),d.role="none";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,n=t.length;i<n;i+=8){const n=t[i],a=t[i+1],d=t[i+2],c=t[i+3],p=h.createElement("rect"),g=(d-e)/o,m=(s-a)/l,f=(n-d)/o,b=(a-c)/l;p.setAttribute("x",g),p.setAttribute("y",m),p.setAttribute("width",f),p.setAttribute("height",b),u.append(p),r?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${m}" width="${f}" height="${b}"/>`)}this.#nr&&(r.push("</g></svg>')"),a.backgroundImage=r.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(t=null){const{data:e}=this;let i,n;t?(i={str:t.text},n=t.date):(i=e.contentsObj,n=e.modificationDate),this.#sr=new Cs({data:{color:e.color,titleObj:e.titleObj,modificationDate:n,contentsObj:i,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]})}get hasPopupElement(){return!!(this.#sr||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#sr}render(){dt("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const n=this._fieldObjects[t];if(n)for(const{page:t,id:s,exportValues:a}of n){if(-1===t)continue;if(s===e)continue;const n="string"==typeof a?a:null,r=document.querySelector(`[data-element-id="${s}"]`);!r||hs.has(r)?i.push({id:s,exportValue:n,domElement:r}):ht(`_getElementsByName - element not allowed: ${s}`)}return i}for(const n of document.getElementsByName(t)){const{exportValue:t}=n,s=n.getAttribute("data-element-id");s!==e&&(hs.has(n)&&i.push({id:s,exportValue:t,domElement:n}))}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,mustEnterInEditMode:!0})})}updateOC(t){if(!this.data.oc||!t)return;t.isVisible(this.data.oc)?this.show():this.hide()}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}class ps extends us{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:t}=this;t.hasComment&&this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}class gs extends us{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 n=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),n=!0):t.action?(this._bindNamedAction(i,t.action,t.overlaidText),n=!0):t.attachment?(this.#rr(i,t.attachment,t.overlaidText,t.attachmentDest),n=!0):t.setOCGState?(this.#or(i,t.setOCGState,t.overlaidText),n=!0):t.dest?(this._bindLink(i,t.dest,t.overlaidText),n=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),n=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),n=!0):this.isTooltipOnly&&!n&&(this._bindLink(i,""),n=!0)),this.container.classList.add("linkAnnotation"),n&&(this.contentElement=i,this.container.append(i)),this.container}#lr(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e,i=""){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#lr(),i&&(t.title=i)}_bindNamedAction(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),i&&(t.title=i),this.#lr()}#rr(t,e,i="",n=null){t.href=this.linkService.getAnchorUrl(""),e.description?t.title=e.description:i&&(t.title=i),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,n),!1),this.#lr()}#or(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),i&&(t.title=i),this.#lr()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const n of Object.keys(e.actions)){const s=i.get(n);s&&(t[s]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:n}}),!1))}e.overlaidText&&(t.title=e.overlaidText),t.onclick||(t.onclick=()=>!1),this.#lr()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#lr(),!this._fieldObjects)return ht('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(i||(t.onclick=()=>!1));t.onclick=()=>{i?.();const{fields:t,refs:n,include:s}=e,a=[];if(0!==t.length||0!==n.length){const e=new Set(n);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)===s&&a.push(i)}else for(const t of Object.values(this._fieldObjects))a.push(...t);const r=this.annotationStorage,o=[];for(const t of a){const{id:e}=t;switch(o.push(e),t.type){case"text":{const i=t.defaultValue||"";r.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{const i=t.defaultValue===t.exportValues;r.setValue(e,{value:i});break}case"combobox":case"listbox":{const i=t.defaultValue||"";r.setValue(e,{value:i});break}default:continue}const i=document.querySelector(`[data-element-id="${e}"]`);i&&(hs.has(i)?i.dispatchEvent(new Event("resetform")):ht(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class ms extends us{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.hasOwnCommentButton=!0,this._createPopup()),this.container.append(t),this.container}}class fs extends us{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return St.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,n,s){i.includes("mouse")?t.addEventListener(i,t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:s(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}s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:s(t)}})})}_setEventListeners(t,e,i,n){for(const[s,a]of i)("Action"===a||this.data.actions?.[a])&&("Focus"!==a&&"Blur"!==a||(e||={focused:!1}),this._setEventListener(t,e,s,a,n),"Focus"!==a||this.data.actions?.Blur?"Blur"!==a||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":Pt.makeHexColor(...e)}_setTextStyle(t){const e=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||9,s=t.style;let a;const r=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/(S*n))||1);a=Math.min(n,r(e/S))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(n,r(t/S))}s.fontSize=`calc(${a}px * var(--total-scale-factor))`,s.color=Pt.makeHexColor(...i),null!==this.data.textAlignment&&(s.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class bs extends fs{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,n){const s=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=i),s.setValue(a.id,{[n]:i})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const n=t.getValue(e,{value:this.data.fieldValue});let s=n.value||"";const a=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;a&&s.length>a&&(s=s.slice(0,a));let r=n.formattedValue||this.data.textContent?.join("\n")||null;r&&this.data.comb&&(r=r.replaceAll(/\s+/g,""));const o={userValue:s,formattedValue:r,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=r??s,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type=this.data.password?"password":"text",i.setAttribute("value",r??s),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),hs.add(i),this.contentElement=i,i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=0;const{datetimeFormat:l,datetimeType:h,timeStep:d}=this.data,c=!!h&&this.enableScripting;l&&(i.title=l),this._setRequired(i,this.data.required),a&&(i.maxLength=a),i.addEventListener("input",n=>{t.setValue(e,{value:n.target.value}),this.setPropertyOnSiblings(i,"value",n.target.value,"value"),o.formattedValue=null}),i.addEventListener("resetform",t=>{const e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null});let u=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;if(c&&(e.type=h,d&&(e.step=d)),o.userValue){const t=o.userValue;if(c)if("time"===h){const i=new Date(t),n=[i.getHours(),i.getMinutes(),i.getSeconds()];e.value=n.map(t=>t.toString().padStart(2,"0")).join(":")}else e.value=new Date(t-ds).toISOString().split("date"===h?"T":".",1)[0];else e.value=t}o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),i.addEventListener("updatefromsandbox",i=>{this.showElementAndHideCanvas(i.target);const n={value(i){o.userValue=i.detail.value??"",c||t.setValue(e,{value:o.userValue.toString()}),i.target.value=o.userValue},formattedValue(i){const{formattedValue:n}=i.detail;o.formattedValue=n,null!=n&&i.target!==document.activeElement&&(i.target.value=n);const s={formattedValue:n};c&&(s.value=n),t.setValue(e,s)},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{const{charLimit:n}=i.detail,{target:s}=i;if(0===n)return void s.removeAttribute("maxLength");s.setAttribute("maxLength",n);let a=o.userValue;!a||a.length<=n||(a=a.slice(0,n),s.value=o.userValue=a,t.setValue(e,{value:a}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,willCommit:!0,commitKey:1,selStart:s.selectionStart,selEnd:s.selectionEnd}}))}};this._dispatchEventFromSandbox(n,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:n}=t.target;o.lastCommittedValue!==n&&(o.lastCommittedValue=n,o.userValue=n,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))});const n=u;u=null,i.addEventListener("blur",t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{target:i}=t;let{value:s}=i;if(c){if(s&&"time"===h){const t=s.split(":").map(t=>parseInt(t,10));s=new Date(2e3,0,1,t[0],t[1],t[2]||0).valueOf(),i.step=""}else s.includes("T")||(s=`${s}T00:00`),s=new Date(s).valueOf();i.type="text"}o.userValue=s,o.lastCommittedValue!==s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),n(t)}),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",t=>{o.lastCommittedValue=null;const{data:i,target:n}=t,{value:s,selectionStart:a,selectionEnd:r}=n;let l=a,h=r;switch(t.inputType){case"deleteWordBackward":{const t=s.substring(0,a).match(/\w*\W*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{const t=s.substring(a).match(/^\W*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":a===r&&(l-=1);break;case"deleteContentForward":a===r&&(h+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,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(u&&i.addEventListener("blur",u),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/a;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--total-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 vs extends fs{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class ws extends fs{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let n=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof n&&(n="Off"!==n,t.setValue(i,{value:n})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const s=document.createElement("input");return hs.add(s),s.setAttribute("data-element-id",i),s.disabled=e.readOnly,this._setRequired(s,this.data.required),s.type="checkbox",s.name=e.fieldName,n&&s.setAttribute("checked",!0),s.setAttribute("exportValue",e.exportValue),s.tabIndex=0,s.addEventListener("change",n=>{const{name:s,checked:a}=n.target;for(const n of this._getElementsByName(s,i)){const i=a&&n.exportValue===e.exportValue;n.domElement&&(n.domElement.checked=i),t.setValue(n.id,{value:i})}t.setValue(i,{value:a})}),s.addEventListener("resetform",t=>{const i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue}),this.enableScripting&&this.hasJSActions&&(s.addEventListener("updatefromsandbox",e=>{const n={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}};this._dispatchEventFromSandbox(n,e)}),this._setEventListeners(s,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(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class ys extends fs{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 n=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof n&&(n=n!==e.buttonValue,t.setValue(i,{value:n})),n)for(const n of this._getElementsByName(e.fieldName,i))t.setValue(n.id,{value:!1});const s=document.createElement("input");if(hs.add(s),s.setAttribute("data-element-id",i),s.disabled=e.readOnly,this._setRequired(s,this.data.required),s.type="radio",s.name=e.fieldName,n&&s.setAttribute("checked",!0),s.tabIndex=0,s.addEventListener("change",e=>{const{name:n,checked:s}=e.target;for(const e of this._getElementsByName(n,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:s})}),s.addEventListener("resetform",t=>{const i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue}),this.enableScripting&&this.hasJSActions){const n=e.buttonValue;s.addEventListener("updatefromsandbox",e=>{const s={value:e=>{const s=n===e.detail.value;for(const n of this._getElementsByName(e.target.name)){const e=s&&n.id===i;n.domElement&&(n.domElement.checked=e),t.setValue(n.id,{value:e})}}};this._dispatchEventFromSandbox(s,e)}),this._setEventListeners(s,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(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class xs extends gs{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 As extends fs{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}),n=document.createElement("select");hs.add(n),n.setAttribute("data-element-id",e),n.disabled=this.data.readOnly,this._setRequired(n,this.data.required),n.name=this.data.fieldName,n.tabIndex=0;let s=this.data.combo&&this.data.options.length>0;this.data.combo||(n.size=this.data.options.length,this.data.multiSelect&&(n.multiple=!0)),n.addEventListener("resetform",t=>{const e=this.data.defaultFieldValue;for(const t of n.options)t.selected=t.value===e});const a=(t,e)=>{const i=e.replaceAll(" "," ");t.textContent=i,i!==e&&t.setAttribute("display-value",e)};for(const t of this.data.options){const e=document.createElement("option");a(e,t.displayValue),e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),s=!1),n.append(e)}let r=null;if(s){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),n.prepend(t),r=()=>{t.remove(),n.removeEventListener("input",r),r=null},n.addEventListener("input",r)}const o=t=>{const e=t?"value":"textContent",{options:i,multiple:s}=n;return s?Array.prototype.filter.call(i,t=>t.selected).map(t=>t[e]):-1===i.selectedIndex?null:i[i.selectedIndex][e]};let l=o(!1);const h=t=>{const e=t.target.options;return Array.prototype.map.call(e,t=>({displayValue:t.getAttribute("display-value")||t.textContent,exportValue:t.value}))};return this.enableScripting&&this.hasJSActions?(n.addEventListener("updatefromsandbox",i=>{const s={value(i){r?.();const s=i.detail.value,a=new Set(Array.isArray(s)?s:[s]);for(const t of n.options)t.selected=a.has(t.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(t){n.multiple=!0},remove(i){const s=n.options,a=i.detail.remove;if(s[a].selected=!1,n.remove(a),s.length>0){-1===Array.prototype.findIndex.call(s,t=>t.selected)&&(s[0].selected=!0)}t.setValue(e,{value:o(!0),items:h(i)}),l=o(!1)},clear(i){for(;0!==n.length;)n.remove(0);t.setValue(e,{value:null,items:[]}),l=o(!1)},insert(i){const{index:s,displayValue:r,exportValue:d}=i.detail.insert,c=n.children[s],u=document.createElement("option");a(u,r),u.value=d,c?c.before(u):n.append(u),t.setValue(e,{value:o(!0),items:h(i)}),l=o(!1)},items(i){const{items:s}=i.detail;for(;0!==n.length;)n.remove(0);for(const t of s){const{displayValue:e,exportValue:i}=t,s=document.createElement("option");a(s,e),s.value=i,n.append(s)}n.options.length>0&&(n.options[0].selected=!0),t.setValue(e,{value:o(!0),items:h(i)}),l=o(!1)},indices(i){const n=new Set(i.detail.indices);for(const t of i.target.options)t.selected=n.has(t.index);t.setValue(e,{value:o(!0)}),l=o(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(s,i)}),n.addEventListener("input",i=>{const n=o(!0),s=o(!1);t.setValue(e,{value:n}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:s,changeEx:n,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(n,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)):n.addEventListener("input",function(i){t.setValue(e,{value:o(!0)})}),this.data.combo&&this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Cs extends us{constructor(t){const{data:e,elements:i,parent:n}=t,s=!!n._commentManager;if(super(t,{isRenderable:!s&&us._hasPopupData(e)}),this.elements=i,s&&us._hasPopupData(e)){const t=this.popup=this.#hr();for(const e of i)e.popup=t}else this.popup=null}#hr(){return new Ss({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,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,commentManager:this.parent._commentManager})}render(){const{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";const e=this.popup=this.#hr(),i=[];for(const t of this.elements)t.popup=e,t.container.ariaHasPopup="dialog",i.push(t.data.id),t.addHighlightArea();return this.container.setAttribute("aria-controls",i.map(t=>`${R}${t}`).join(",")),this.container}}class Ss{#W=null;#dr=this.#Ya.bind(this);#cr=this.#ur.bind(this);#pr=this.#gr.bind(this);#mr=this.#fr.bind(this);#br=null;#Et=null;#vr=null;#wr=null;#yr=null;#xr=null;#Ar=null;#Cr=!1;#Sr=null;#Pr=null;#L=null;#_r=null;#Er=null;#ye=null;#Tr=null;#fe=null;#Mr=null;#ir=null;#kr=!1;#Dr=null;#Ir=null;constructor({container:t,color:e,elements:i,titleObj:n,modificationDate:s,contentsObj:a,richText:r,parent:o,rect:l,parentRect:h,open:d,commentManager:c=null}){this.#Et=t,this.#Mr=n,this.#vr=a,this.#fe=r,this.#xr=o,this.#br=e,this.#Tr=l,this.#Ar=h,this.#yr=i,this.#W=c,this.#Dr=i[0],this.#wr=Gt.toDateObject(s),this.trigger=i.flatMap(t=>t.getElementsToTriggerPopup()),c||(this.#Lr(),this.#Et.hidden=!0,d&&this.#fr())}#Lr(){if(this.#Pr)return;this.#Pr=new AbortController;const{signal:t}=this.#Pr;for(const e of this.trigger)e.addEventListener("click",this.#mr,{signal:t}),e.addEventListener("pointerenter",this.#pr,{signal:t}),e.addEventListener("pointerleave",this.#cr,{signal:t}),e.classList.add("popupTriggerArea");for(const e of this.#yr)e.container?.addEventListener("keydown",this.#dr,{signal:t})}#Nr(){const t=this.#yr.find(t=>t.hasCommentButton);t&&(this.#Er=t._normalizePoint(t.commentButtonPosition))}renderCommentButton(){if(this.#_r)return void(this.#_r.parentNode||this.#Dr.container.after(this.#_r));if(this.#Er||this.#Nr(),!this.#Er)return;const{signal:t}=this.#Pr=new AbortController,e=this.#Dr.hasOwnCommentButton,i=()=>{this.#W.toggleCommentPopup(this,!0,void 0,!e)},n=()=>{this.#W.toggleCommentPopup(this,!1,!0,!e)},s=()=>{this.#W.toggleCommentPopup(this,!1,!1)};if(e){this.#_r=this.#Dr.container;for(const e of this.trigger)e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.addEventListener("keydown",this.#dr,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",n,{signal:t}),e.addEventListener("pointerleave",s,{signal:t}),e.classList.add("popupTriggerArea")}else{const e=this.#_r=document.createElement("button");e.className="annotationCommentButton";const a=this.#Dr.container;e.style.zIndex=parseInt(a.style.zIndex,10)+1,e.tabIndex=0,e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#Rr(),this.#Fr(),e.addEventListener("keydown",this.#dr,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",n,{signal:t}),e.addEventListener("pointerleave",s,{signal:t}),a.after(e)}}#Fr(){if(this.#Dr.extraPopupElement&&!this.#Dr.editor)return;this.#_r||this.renderCommentButton();const[t,e]=this.#Er,{style:i}=this.#_r;i.left=`calc(${t}%)`,i.top=`calc(${e}% - var(--comment-button-dim))`}#Rr(){this.#Dr.extraPopupElement||(this.#_r||this.renderCommentButton(),this.#_r.style.backgroundColor=this.commentButtonColor||"")}get commentButtonColor(){const{color:t,opacity:e}=this.#Dr.commentData;return t?this.#xr._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{this.#_r?.focus()},0)}getData(){const{richText:t,color:e,opacity:i,creationDate:n,modificationDate:s}=this.#Dr.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:i,creationDate:n,modificationDate:s}}get elementBeforePopup(){return this.#_r}get comment(){return this.#Ir||=this.#Dr.commentText,this.#Ir}set comment(t){t!==this.comment&&(this.#Dr.commentText=this.#Ir=t)}focus(){this.#Dr.container?.focus()}get parentBoundingClientRect(){return this.#Dr.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){this.#_r&&(this.#_r.classList.toggle("selected",t),this.#_r.ariaExpanded=e)}setSelectedCommentButton(t){this.#_r.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#ye)return this.#ye;const{x:t,y:e,height:i}=this.#_r.getBoundingClientRect(),{x:n,y:s,width:a,height:r}=this.#Dr.layer.getBoundingClientRect();return[(t-n)/a,(e+i-s)/r]}set commentPopupPosition(t){this.#ye=t}hasDefaultPopupPosition(){return null===this.#ye}get commentButtonPosition(){return this.#Er}get commentButtonWidth(){return this.#_r.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,i]=this.#ye||this.commentButtonPosition.map(t=>t/100),n=this.parentBoundingClientRect,{x:s,y:a,width:r,height:o}=n;this.#W.showDialog(null,this,s+e*r,a+i*o,{...t,parentDimensions:n})}render(){if(this.#Sr)return;const t=this.#Sr=document.createElement("div");if(t.className="popup",this.#br){const e=t.style.outlineColor=Pt.makeHexColor(...this.#br);t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}const e=document.createElement("span");if(e.className="header",this.#Mr?.str){const t=document.createElement("span");t.className="title",e.append(t),({dir:t.dir,str:t.textContent}=this.#Mr)}if(t.append(e),this.#wr){const t=document.createElement("time");t.className="popupDate",t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#wr.valueOf()})),t.dateTime=this.#wr.toISOString(),e.append(t)}re({html:this.#Or||this.#vr.str,dir:this.#vr?.dir,className:"popupContent"},t),this.#Et.append(t)}get#Or(){const t=this.#fe,e=this.#vr;return!t?.str||e?.str&&e.str!==t.str?null:this.#fe.html||null}get#Br(){return this.#Or?.attributes?.style?.fontSize||0}get#jr(){return this.#Or?.attributes?.style?.color||null}#Ur(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},n={style:{color:this.#jr,fontSize:this.#Br?`calc(${this.#Br}px * var(--total-scale-factor))`:""}};for(const i of t.split("\n"))e.push({name:"span",value:i,attributes:n});return i}#Ya(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#Cr)&&this.#fr()}updateEdited({rect:t,popup:e,deleted:i}){if(this.#W)return i?(this.remove(),this.#Ir=null):e&&(e.deleted?this.remove():(this.#Rr(),this.#Ir=e.text)),void(t&&(this.#Er=null,this.#Nr(),this.#Fr()));i||e?.deleted?this.remove():(this.#Lr(),this.#ir||={contentsObj:this.#vr,richText:this.#fe},t&&(this.#L=null),e&&e.text&&(this.#fe=this.#Ur(e.text),this.#wr=Gt.toDateObject(e.date),this.#vr=null),this.#Sr?.remove(),this.#Sr=null)}resetEdited(){this.#ir&&(({contentsObj:this.#vr,richText:this.#fe}=this.#ir),this.#ir=null,this.#Sr?.remove(),this.#Sr=null,this.#L=null)}remove(){if(this.#Pr?.abort(),this.#Pr=null,this.#Sr?.remove(),this.#Sr=null,this.#kr=!1,this.#Cr=!1,this.#_r?.remove(),this.#_r=null,this.trigger)for(const t of this.trigger)t.classList.remove("popupTriggerArea")}#Hr(){if(null!==this.#L)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:n,pageY:s}}}=this.#xr;let a=!!this.#Ar,r=a?this.#Ar:this.#Tr;for(const t of this.#yr)if(!r||null!==Pt.intersect(t.data.rect,r)){r=t.data.rect,a=!0;break}const o=Pt.normalizeRect([r[0],t[3]-r[1]+t[1],r[2],t[3]-r[3]+t[1]]),l=a?r[2]-r[0]+5:0,h=o[0]+l,d=o[1];this.#L=[100*(h-n)/e,100*(d-s)/i];const{style:c}=this.#Et;c.left=`${this.#L[0]}%`,c.top=`${this.#L[1]}%`}#fr(){this.#W?this.#W.toggleCommentPopup(this,!1):(this.#Cr=!this.#Cr,this.#Cr?(this.#gr(),this.#Et.addEventListener("click",this.#mr),this.#Et.addEventListener("keydown",this.#dr)):(this.#ur(),this.#Et.removeEventListener("click",this.#mr),this.#Et.removeEventListener("keydown",this.#dr)))}#gr(){this.#Sr||this.render(),this.isVisible?this.#Cr&&this.#Et.classList.add("focused"):(this.#Hr(),this.#Et.hidden=!1,this.#Et.style.zIndex=parseInt(this.#Et.style.zIndex,10)+1e3)}#ur(){this.#Et.classList.remove("focused"),!this.#Cr&&this.isVisible&&(this.#Et.hidden=!0,this.#Et.style.zIndex=parseInt(this.#Et.style.zIndex,10)-1e3)}forceHide(){this.#kr=this.isVisible,this.#kr&&(this.#Et.hidden=!0)}maybeShow(){this.#W||(this.#Lr(),this.#kr&&(this.#Sr||this.#gr(),this.#kr=!1,this.#Et.hidden=!1))}get isVisible(){return!this.#W&&!1===this.#Et.hidden}}class Ps extends us{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=O.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=this.contentElement=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.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class _s extends us{#Vr=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:i}=this,n=this.svgFactory.create(e,i,!0),s=this.#Vr=this.svgFactory.createElement("svg:line");return s.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),s.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),s.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),s.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),s.setAttribute("stroke-width",t.borderStyle.width||1),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),n.append(s),this.container.append(n),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#Vr}addHighlightArea(){this.container.classList.add("highlightArea")}}class Es extends us{#zr=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:i}=this,n=this.svgFactory.create(e,i,!0),s=t.borderStyle.width,a=this.#zr=this.svgFactory.createElement("svg:rect");return a.setAttribute("x",s/2),a.setAttribute("y",s/2),a.setAttribute("width",e-s),a.setAttribute("height",i-s),a.setAttribute("stroke-width",s||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),n.append(a),this.container.append(n),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#zr}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ts extends us{#$r=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:i}=this,n=this.svgFactory.create(e,i,!0),s=t.borderStyle.width,a=this.#$r=this.svgFactory.createElement("svg:ellipse");return a.setAttribute("cx",e/2),a.setAttribute("cy",i/2),a.setAttribute("rx",e/2-s/2),a.setAttribute("ry",i/2-s/2),a.setAttribute("stroke-width",s||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),n.append(a),this.container.append(n),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#$r}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ms extends us{#Wr=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:n},width:s,height:a}=this;if(!e)return this.container;const r=this.svgFactory.create(s,a,!0);let o=[];for(let i=0,n=e.length;i<n;i+=2){const n=e[i]-t[0],s=t[3]-e[i+1];o.push(`${n},${s}`)}o=o.join(" ");const l=this.#Wr=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"),r.append(l),this.container.append(r),!n&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#Wr}addHighlightArea(){this.container.classList.add("highlightArea")}}class ks extends Ms{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Ds extends us{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}}class Is extends us{#Gr=null;#Xr=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?O.HIGHLIGHT:O.INK}#Kr(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:n,popupRef:s}}=this,{transform:a,width:r,height:o}=this.#Kr(e,t),l=this.svgFactory.create(r,o,!0),h=this.#Gr=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",n.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",a);for(let t=0,e=i.length;t<e;t++){const e=this.svgFactory.createElement(this.svgElementName);this.#Xr.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!s&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:i,rect:n}=t,s=this.#Gr;if(e>=0&&s.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#Xr.length;t<e;t++)this.#Xr[t].setAttribute("points",i[t].join(","));if(n){const{transform:t,width:e,height:i}=this.#Kr(this.data.rotation,n);s.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),s.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#Xr}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ls extends us{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=O.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const e=document.createElement("mark");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Ns extends us{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("underlineAnnotation"),t){const e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Rs extends us{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("squigglyAnnotation"),t){const e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Fs extends us{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("strikeoutAnnotation"),t){const e=document.createElement("s");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Os extends us{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=O.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class Bs extends us{#qr=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.#Yr.bind(this)),this.#qr=i;const{isMac:n}=St.platform;return t.addEventListener("keydown",t=>{"Enter"===t.key&&(n?t.metaKey:t.ctrlKey)&&this.#Yr()}),!e.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#qr}addHighlightArea(){this.container.classList.add("highlightArea")}#Yr(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}const js=/\r\n?|\n/g;class Us extends Ae{#Qr="";#Zr=`${this.id}-editor`;#Jr=null;#Br;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=Us.prototype,e=t=>t.isEmpty(),i=ve.TRANSLATE_SMALL,n=ve.TRANSLATE_BIG;return mt(this,"_keyboardManager",new fe([[["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:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,n],checker:e}]]))}static _type="freetext";static _editorType=O.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.color=t.color||Us._defaultColor||Ae._defaultLineColor,this.#Br=t.fontSize||Us._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert(Ae._l10nAlert.freetext),this.canAddComment=!1}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 B.FREETEXT_SIZE:Us._defaultFontSize=e;break;case B.FREETEXT_COLOR:Us._defaultColor=e}}updateParams(t,e){switch(t){case B.FREETEXT_SIZE:this.#to(e);break;case B.FREETEXT_COLOR:this.#Rr(e)}}static get defaultPropertiesToUpdate(){return[[B.FREETEXT_SIZE,Us._defaultFontSize],[B.FREETEXT_COLOR,Us._defaultColor||Ae._defaultLineColor]]}get propertiesToUpdate(){return[[B.FREETEXT_SIZE,this.#Br],[B.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new ns(this),[["colorPicker",this._colorPicker]]}get colorType(){return B.FREETEXT_COLOR}#to(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-this.#Br)*this.parentScale),this.#Br=t,this.#eo()},i=this.#Br;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:B.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#Rr(t){const e=t=>{this.color=t,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:B.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-Us._internalPadding*t,-(Us._internalPadding+this.#Br)*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#Jr=new AbortController;const t=this._uiManager.combinedSignal(this.#Jr);return 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}),!0}disableEditMode(){return!!super.disableEditMode()&&(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#Zr),this._isDraggable=!0,this.#Jr?.abort(),this.#Jr=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0)}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()}#io(){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(Us.#no(i)),e=i);return t.join("\n")}#eo(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,n=e.style.display,s=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=n,e.classList.toggle("hidden",s)}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.#Qr,e=this.#Qr=this.#io().trimEnd();if(t===e)return;const i=t=>{this.#Qr=t,t?(this.#so(),this._uiManager.rebuild(this),this.#eo()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#eo()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){Us._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)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let t,e;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#Zr),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.#Br}px * var(--total-scale-factor))`,i.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[i,n]=this.parentDimensions;if(this.annotationElementId){const{position:s}=this._initialData;let[a,r]=this.getInitialTranslation();[a,r]=this.pageTranslationToScreen(a,r);const[o,l]=this.pageDimensions,[h,d]=this.pageTranslation;let c,u;switch(this.rotation){case 0:c=t+(s[0]-h)/o,u=e+this.height-(s[1]-d)/l;break;case 90:c=t+(s[0]-h)/o,u=e-(s[1]-d)/l,[a,r]=[r,-a];break;case 180:c=t-this.width+(s[0]-h)/o,u=e-(s[1]-d)/l,[a,r]=[-a,-r];break;case 270:c=t+(s[0]-h-this.height*l)/o,u=e+(s[1]-d-this.width*o)/l,[a,r]=[-r,a]}this.setAt(c*i,u*n,a,r)}else this._moveAfterPaste(t,e);this.#so(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#no(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(js,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const n=Us.#ao(e.getData("text")||"").replaceAll(js,"\n");if(!n)return;const s=window.getSelection();if(!s.rangeCount)return;this.editorDiv.normalize(),s.deleteFromDocument();const a=s.getRangeAt(0);if(!n.includes("\n"))return a.insertNode(document.createTextNode(n)),this.editorDiv.normalize(),void s.collapseToStart();const{startContainer:r,startOffset:o}=a,l=[],h=[];if(r.nodeType===Node.TEXT_NODE){const t=r.parentElement;if(h.push(r.nodeValue.slice(o).replaceAll(js,"")),t!==this.editorDiv){let e=l;for(const i of this.editorDiv.childNodes)i!==t?e.push(Us.#no(i)):e=h}l.push(r.nodeValue.slice(0,o).replaceAll(js,""))}else if(r===this.editorDiv){let t=l,e=0;for(const i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(Us.#no(i))}this.#Qr=`${l.join("\n")}${n}${h.join("\n")}`,this.#so();const d=new Range;let c=Math.sumPrecise(l.map(t=>t.length));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}s.removeAllRanges(),s.addRange(d)}#so(){if(this.editorDiv.replaceChildren(),this.#Qr)for(const t of this.#Qr.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#ro(){return this.#Qr.replaceAll(" "," ")}static#ao(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){const t=Us._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,i){let n=null;if(t instanceof Ps){const{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:s,rotation:a,id:r,popupRef:o,richText:l,contentsObj:h,creationDate:d,modificationDate:c},textContent:u,textPosition:p,parent:{page:{pageNumber:g}}}=t;if(!u||0===u.length)return null;n=t={annotationType:O.FREETEXT,color:Array.from(i),fontSize:e,value:u.join("\n"),position:p,pageIndex:g-1,rect:s.slice(0),rotation:a,annotationElementId:r,id:r,deleted:!1,popupRef:o,comment:h?.str||null,richText:l,creationDate:d,modificationDate:c}}const s=await super.deserialize(t,e,i);return s.#Br=t.fontSize,s.color=Pt.makeHexColor(...t.color),s.#Qr=Us.#ao(t.value),s._initialData=n,t.comment&&s.setCommentData(t),s}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=Ae._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(t),{color:e,fontSize:this.#Br,value:this.#ro()});return this.addComment(i),t?(i.isCopy=!0,i):this.annotationElementId&&!this.#oo(i)?null:(i.id=this.annotationElementId,i)}#oo(t){const{value:e,fontSize:i,color:n,pageIndex:s}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some((t,e)=>t!==n[e])||t.pageIndex!==s}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(!e)return null;const{style:i}=e;i.fontSize=`calc(${this.#Br}px * var(--total-scale-factor))`,i.color=this.color,e.replaceChildren();for(const t of this.#Qr.split("\n")){const i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#Qr}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class Hs{static PRECISION=1e-4;toSVGPath(){dt("Abstract method `toSVGPath` must be implemented.")}get box(){dt("Abstract getter `box` must be implemented.")}serialize(t,e){dt("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,n,s,a){a||=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r+=2)a[r]=e+t[r]*n,a[r+1]=i+t[r+1]*s;return a}static _rescaleAndSwap(t,e,i,n,s,a){a||=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r+=2)a[r]=e+t[r+1]*n,a[r+1]=i+t[r]*s;return a}static _translate(t,e,i,n){n||=new Float32Array(t.length);for(let s=0,a=t.length;s<a;s+=2)n[s]=e+t[s],n[s+1]=i+t[s+1];return n}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,n,s){switch(s){case 90:return[1-e/i,t/n];case 180:return[1-t/i,1-e/n];case 270:return[e/i,1-t/n];default:return[t/i,e/n]}}static createBezierPoints(t,e,i,n,s,a){return[(t+5*i)/6,(e+5*n)/6,(5*i+s)/6,(5*n+a)/6,(i+s)/2,(n+a)/2]}}class Vs{#lo;#ho=[];#do;#co;#uo=[];#po=new Float32Array(18);#go;#mo;#fo;#bo;#vo;#wo;#yo=[];static#xo=8;static#Ao=2;static#Co=Vs.#xo+Vs.#Ao;constructor({x:t,y:e},i,n,s,a,r=0){this.#lo=i,this.#wo=s*n,this.#co=a,this.#po.set([NaN,NaN,NaN,NaN,t,e],6),this.#do=r,this.#bo=Vs.#xo*n,this.#fo=Vs.#Co*n,this.#vo=n,this.#yo.push(t,e)}isEmpty(){return isNaN(this.#po[8])}#So(){const t=this.#po.subarray(4,6),e=this.#po.subarray(16,18),[i,n,s,a]=this.#lo;return[(this.#go+(t[0]-e[0])/2-i)/s,(this.#mo+(t[1]-e[1])/2-n)/a,(this.#go+(e[0]-t[0])/2-i)/s,(this.#mo+(e[1]-t[1])/2-n)/a]}add({x:t,y:e}){this.#go=t,this.#mo=e;const[i,n,s,a]=this.#lo;let[r,o,l,h]=this.#po.subarray(8,12);const d=t-l,c=e-h,u=Math.hypot(d,c);if(u<this.#fo)return!1;const p=u-this.#bo,g=p/u,m=g*d,f=g*c;let b=r,v=o;r=l,o=h,l+=m,h+=f,this.#yo?.push(t,e);const w=m/p,y=-f/p*this.#wo,x=w*this.#wo;if(this.#po.set(this.#po.subarray(2,8),0),this.#po.set([l+y,h+x],4),this.#po.set(this.#po.subarray(14,18),12),this.#po.set([l-y,h-x],16),isNaN(this.#po[6]))return 0===this.#uo.length&&(this.#po.set([r+y,o+x],2),this.#uo.push(NaN,NaN,NaN,NaN,(r+y-i)/s,(o+x-n)/a),this.#po.set([r-y,o-x],14),this.#ho.push(NaN,NaN,NaN,NaN,(r-y-i)/s,(o-x-n)/a)),this.#po.set([b,v,r,o,l,h],6),!this.isEmpty();this.#po.set([b,v,r,o,l,h],6);return Math.abs(Math.atan2(v-o,b-r)-Math.atan2(f,m))<Math.PI/2?([r,o,l,h]=this.#po.subarray(2,6),this.#uo.push(NaN,NaN,NaN,NaN,((r+l)/2-i)/s,((o+h)/2-n)/a),[r,o,b,v]=this.#po.subarray(14,18),this.#ho.push(NaN,NaN,NaN,NaN,((b+r)/2-i)/s,((v+o)/2-n)/a),!0):([b,v,r,o,l,h]=this.#po.subarray(0,6),this.#uo.push(((b+5*r)/6-i)/s,((v+5*o)/6-n)/a,((5*r+l)/6-i)/s,((5*o+h)/6-n)/a,((r+l)/2-i)/s,((o+h)/2-n)/a),[l,h,r,o,b,v]=this.#po.subarray(12,18),this.#ho.push(((b+5*r)/6-i)/s,((v+5*o)/6-n)/a,((5*r+l)/6-i)/s,((5*o+h)/6-n)/a,((r+l)/2-i)/s,((o+h)/2-n)/a),!0)}toSVGPath(){if(this.isEmpty())return"";const t=this.#uo,e=this.#ho;if(isNaN(this.#po[6])&&!this.isEmpty())return this.#Po();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.#_o(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.#Eo(i),i.join(" ")}#Po(){const[t,e,i,n]=this.#lo,[s,a,r,o]=this.#So();return`M${(this.#po[2]-t)/i} ${(this.#po[3]-e)/n} L${(this.#po[4]-t)/i} ${(this.#po[5]-e)/n} L${s} ${a} L${r} ${o} L${(this.#po[16]-t)/i} ${(this.#po[17]-e)/n} L${(this.#po[14]-t)/i} ${(this.#po[15]-e)/n} Z`}#Eo(t){const e=this.#ho;t.push(`L${e[4]} ${e[5]} Z`)}#_o(t){const[e,i,n,s]=this.#lo,a=this.#po.subarray(4,6),r=this.#po.subarray(16,18),[o,l,h,d]=this.#So();t.push(`L${(a[0]-e)/n} ${(a[1]-i)/s} L${o} ${l} L${h} ${d} L${(r[0]-e)/n} ${(r[1]-i)/s}`)}newFreeDrawOutline(t,e,i,n,s,a){return new zs(t,e,i,n,s,a)}getOutlines(){const t=this.#uo,e=this.#ho,i=this.#po,[n,s,a,r]=this.#lo,o=new Float32Array((this.#yo?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#yo[t]-n)/a,o[t+1]=(this.#yo[t+1]-s)/r;if(o[o.length-2]=(this.#go-n)/a,o[o.length-1]=(this.#mo-s)/r,isNaN(i[6])&&!this.isEmpty())return this.#To(o);const l=new Float32Array(this.#uo.length+24+this.#ho.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.#Mo(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.#ko(l,h),this.newFreeDrawOutline(l,o,this.#lo,this.#vo,this.#do,this.#co)}#To(t){const e=this.#po,[i,n,s,a]=this.#lo,[r,o,l,h]=this.#So(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/s,(e[3]-n)/a,NaN,NaN,NaN,NaN,(e[4]-i)/s,(e[5]-n)/a,NaN,NaN,NaN,NaN,r,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/s,(e[17]-n)/a,NaN,NaN,NaN,NaN,(e[14]-i)/s,(e[15]-n)/a],0),this.newFreeDrawOutline(d,t,this.#lo,this.#vo,this.#do,this.#co)}#ko(t,e){const i=this.#ho;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#Mo(t,e){const i=this.#po.subarray(4,6),n=this.#po.subarray(16,18),[s,a,r,o]=this.#lo,[l,h,d,c]=this.#So();return t.set([NaN,NaN,NaN,NaN,(i[0]-s)/r,(i[1]-a)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,d,c,NaN,NaN,NaN,NaN,(n[0]-s)/r,(n[1]-a)/o],e),e+24}}class zs extends Hs{#lo;#Do=new Float32Array(4);#do;#co;#yo;#vo;#Io;constructor(t,e,i,n,s,a){super(),this.#Io=t,this.#yo=e,this.#lo=i,this.#vo=n,this.#do=s,this.#co=a,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#Lo(a);const[r,o,l,h]=this.#Do;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-r)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-r)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){const t=[`M${this.#Io[4]} ${this.#Io[5]}`];for(let e=6,i=this.#Io.length;e<i;e+=6)isNaN(this.#Io[e])?t.push(`L${this.#Io[e+4]} ${this.#Io[e+5]}`):t.push(`C${this.#Io[e]} ${this.#Io[e+1]} ${this.#Io[e+2]} ${this.#Io[e+3]} ${this.#Io[e+4]} ${this.#Io[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,i,n],s){const a=i-t,r=n-e;let o,l;switch(s){case 0:o=Hs._rescale(this.#Io,t,n,a,-r),l=Hs._rescale(this.#yo,t,n,a,-r);break;case 90:o=Hs._rescaleAndSwap(this.#Io,t,e,a,r),l=Hs._rescaleAndSwap(this.#yo,t,e,a,r);break;case 180:o=Hs._rescale(this.#Io,i,e,-a,r),l=Hs._rescale(this.#yo,i,e,-a,r);break;case 270:o=Hs._rescaleAndSwap(this.#Io,i,n,-a,-r),l=Hs._rescaleAndSwap(this.#yo,i,n,-a,-r)}return{outline:Array.from(o),points:[Array.from(l)]}}#Lo(t){const e=this.#Io;let i=e[4],n=e[5];const s=[i,n,i,n];let a=i,r=n,o=i,l=n;const h=t?Math.max:Math.min,d=new Float32Array(4);for(let t=6,c=e.length;t<c;t+=6){const c=e[t+4],u=e[t+5];isNaN(e[t])?(Pt.pointBoundingBox(c,u,s),r>u?(a=c,r=u):r===u&&(a=h(a,c)),l<u?(o=c,l=u):l===u&&(o=h(o,c))):(d.set(x,0),Pt.bezierBoundingBox(i,n,...e.slice(t,t+6),d),Pt.rectBoundingBox(...d,s),r>d[1]?(a=d[0],r=d[1]):r===d[1]&&(a=h(a,d[0])),l<d[3]?(o=d[2],l=d[3]):l===d[3]&&(o=h(o,d[2]))),i=c,n=u}const c=this.#Do;c[0]=s[0]-this.#do,c[1]=s[1]-this.#do,c[2]=s[2]-s[0]+2*this.#do,c[3]=s[3]-s[1]+2*this.#do,this.firstPoint=[a,r],this.lastPoint=[o,l]}get box(){return this.#Do}newOutliner(t,e,i,n,s,a=0){return new Vs(t,e,i,n,s,a)}getNewOutline(t,e){const[i,n,s,a]=this.#Do,[r,o,l,h]=this.#lo,d=s*l,c=a*h,u=i*l+r,p=n*h+o,g=this.newOutliner({x:this.#yo[0]*d+u,y:this.#yo[1]*c+p},this.#lo,this.#vo,t,this.#co,e??this.#do);for(let t=2;t<this.#yo.length;t+=2)g.add({x:this.#yo[t]*d+u,y:this.#yo[t+1]*c+p});return g.getOutlines()}}class $s{#lo;#No;#Ro;#Fo=[];#Oo=[];constructor(t,e=0,i=0,n=!0){const s=x.slice(),a=10**-4;for(const{x:i,y:n,width:r,height:o}of t){const t=Math.floor((i-e)/a)*a,l=Math.ceil((i+r+e)/a)*a,h=Math.floor((n-e)/a)*a,d=Math.ceil((n+o+e)/a)*a,c=[t,h,d,!0],u=[l,h,d,!1];this.#Fo.push(c,u),Pt.rectBoundingBox(t,h,l,d,s)}const r=s[2]-s[0]+2*i,o=s[3]-s[1]+2*i,l=s[0]-i,h=s[1]-i;let d=n?-1/0:1/0,c=1/0;const u=this.#Fo.at(n?-1:-2),p=[u[0],u[2]];for(const t of this.#Fo){const[e,i,s,a]=t;!a&&n?i<c?(c=i,d=e):i===c&&(d=Math.max(d,e)):a&&!n&&(i<c?(c=i,d=e):i===c&&(d=Math.min(d,e))),t[0]=(e-l)/r,t[1]=(i-h)/o,t[2]=(s-h)/o}this.#lo=new Float32Array([l,h,r,o]),this.#No=[d,c],this.#Ro=p}getOutlines(){this.#Fo.sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);const t=[];for(const e of this.#Fo)e[3]?(t.push(...this.#Bo(e)),this.#jo(e)):(this.#Uo(e),t.push(...this.#Bo(e)));return this.#Ho(t)}#Ho(t){const e=[],i=new Set;for(const i of t){const[t,n,s]=i;e.push([t,n,i],[t,s,i])}e.sort((t,e)=>t[1]-e[1]||t[0]-e[0]);for(let t=0,n=e.length;t<n;t+=2){const n=e[t][2],s=e[t+1][2];n.push(s),s.push(n),i.add(n),i.add(s)}const n=[];let s;for(;i.size>0;){const t=i.values().next().value;let[e,a,r,o,l]=t;i.delete(t);let h=e,d=a;for(s=[e,r],n.push(s);;){let t;if(i.has(o))t=o;else{if(!i.has(l))break;t=l}i.delete(t),[e,a,r,o,l]=t,h!==e&&(s.push(h,d,e,d===a?a:r),h=e),d=d===a?r:a}s.push(h,d)}return new Ws(n,this.#lo,this.#No,this.#Ro)}#Vo(t){const e=this.#Oo;let i=0,n=e.length-1;for(;i<=n;){const s=i+n>>1,a=e[s][0];if(a===t)return s;a<t?i=s+1:n=s-1}return n+1}#jo([,t,e]){const i=this.#Vo(t);this.#Oo.splice(i,0,[t,e])}#Uo([,t,e]){const i=this.#Vo(t);for(let n=i;n<this.#Oo.length;n++){const[i,s]=this.#Oo[n];if(i!==t)break;if(i===t&&s===e)return void this.#Oo.splice(n,1)}for(let n=i-1;n>=0;n--){const[i,s]=this.#Oo[n];if(i!==t)break;if(i===t&&s===e)return void this.#Oo.splice(n,1)}}#Bo(t){const[e,i,n]=t,s=[[e,i,n]],a=this.#Vo(n);for(let t=0;t<a;t++){const[i,n]=this.#Oo[t];for(let t=0,a=s.length;t<a;t++){const[,r,o]=s[t];if(!(n<=r||o<=i))if(r>=i)if(o>n)s[t][1]=n;else{if(1===a)return[];s.splice(t,1),t--,a--}else s[t][2]=i,o>n&&s.push([e,n,o])}}return s}}class Ws extends Hs{#lo;#zo;constructor(t,e,i,n){super(),this.#zo=t,this.#lo=e,this.firstPoint=i,this.lastPoint=n}toSVGPath(){const t=[];for(const e of this.#zo){let[i,n]=e;t.push(`M${i} ${n}`);for(let s=2;s<e.length;s+=2){const a=e[s],r=e[s+1];a===i?(t.push(`V${r}`),n=r):r===n&&(t.push(`H${a}`),i=a)}t.push("Z")}return t.join(" ")}serialize([t,e,i,n],s){const a=[],r=i-t,o=n-e;for(const e of this.#zo){const i=new Array(e.length);for(let s=0;s<e.length;s+=2)i[s]=t+e[s]*r,i[s+1]=n-e[s+1]*o;a.push(i)}return a}get box(){return this.#lo}get classNamesForOutlining(){return["highlightOutline"]}}class Gs extends Vs{newFreeDrawOutline(t,e,i,n,s,a){return new Xs(t,e,i,n,s,a)}}class Xs extends zs{newOutliner(t,e,i,n,s,a=0){return new Gs(t,e,i,n,s,a)}}class Ks extends Ae{#$o=null;#Wo=0;#Go;#Xo=null;#a=null;#Ko=null;#qo=null;#Yo=0;#Qo=null;#Zo=null;#_=null;#Jo=!1;#No=null;#Ro=null;#tl=null;#be="";#wo;#el="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=O.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=Ks.prototype;return mt(this,"_keyboardManager",new fe([[["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||Ks._defaultColor,this.#wo=t.thickness||Ks._defaultThickness,this.opacity=t.opacity||Ks._defaultOpacity,this.#Go=t.boxes||null,this.#el=t.methodOfCreation||"",this.#be=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#Jo=!0,this.#il(t),this.#nl()):this.#Go&&(this.#$o=t.anchorNode,this.#Wo=t.anchorOffset,this.#qo=t.focusNode,this.#Yo=t.focusOffset,this.#sl(),this.#nl(),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert(Ae._l10nAlert.highlight)}get telemetryInitialData(){return{action:"added",type:this.#Jo?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#wo,methodOfCreation:this.#el}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#sl(){const t=new $s(this.#Go,.001);this.#Zo=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#Zo.box;const e=new $s(this.#Go,.0025,.001,"ltr"===this._uiManager.direction);this.#Ko=e.getOutlines();const{firstPoint:i}=this.#Zo;this.#No=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height];const{lastPoint:n}=this.#Ko;this.#Ro=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]}#il({highlightOutlines:t,highlightId:e,clipPathId:i}){this.#Zo=t;if(this.#Ko=t.getNewOutline(this.#wo/2+1.5,.0025),e>=0)this.#_=e,this.#Xo=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#tl=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#Ko.box,path:{d:this.#Ko.toSVGPath()}},!0);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#_,{bbox:Ks.#al(this.#Zo.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#tl,{bbox:Ks.#al(this.#Ko.box,e),path:{d:this.#Ko.toSVGPath()}})}const[n,s,a,r]=t.box;switch(this.rotation){case 0:this.x=n,this.y=s,this.width=a,this.height=r;break;case 90:{const[t,e]=this.parentDimensions;this.x=s,this.y=1-n,this.width=a*e/t,this.height=r*t/e;break}case 180:this.x=1-n,this.y=1-s,this.width=a,this.height=r;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-s,this.y=n,this.width=a*e/t,this.height=r*t/e;break}}const{firstPoint:o}=t;this.#No=[(o[0]-n)/a,(o[1]-s)/r];const{lastPoint:l}=this.#Ko;this.#Ro=[(l[0]-n)/a,(l[1]-s)/r]}static initialize(t,e){Ae.initialize(t,e),Ks._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case B.HIGHLIGHT_COLOR:Ks._defaultColor=e;break;case B.HIGHLIGHT_THICKNESS:Ks._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#Ro}get commentButtonPosition(){return this.#No}updateParams(t,e){switch(t){case B.HIGHLIGHT_COLOR:this.#Rr(e);break;case B.HIGHLIGHT_THICKNESS:this.#rl(e)}}static get defaultPropertiesToUpdate(){return[[B.HIGHLIGHT_COLOR,Ks._defaultColor],[B.HIGHLIGHT_THICKNESS,Ks._defaultThickness]]}get propertiesToUpdate(){return[[B.HIGHLIGHT_COLOR,this.color||Ks._defaultColor],[B.HIGHLIGHT_THICKNESS,this.#wo||Ks._defaultThickness],[B.HIGHLIGHT_FREE,this.#Jo]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#_,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#a?.updateColor(this.color),super.onUpdatedColor()}#Rr(t){const e=(t,e)=>{this.color=t,this.opacity=e,this.onUpdatedColor()},i=this.color,n=this.opacity;this.addCommands({cmd:e.bind(this,t,Ks._defaultOpacity),undo:e.bind(this,i,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:B.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)}#rl(t){const e=this.#wo,i=t=>{this.#wo=t,this.#ol(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:B.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}get toolbarButtons(){if(this._uiManager.highlightColors){return[["colorPicker",this.#a=new is({editor:this})]]}return super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#ll())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#ll())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#hl(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#nl(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#hl():t&&(this.#nl(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#ol(t){this.#Jo&&(this.#il({highlightOutlines:this.#Zo.getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims())}#hl(){null!==this.#_&&this.parent&&(this.parent.drawLayer.remove(this.#_),this.#_=null,this.parent.drawLayer.remove(this.#tl),this.#tl=null)}#nl(t=this.parent){null===this.#_&&(({id:this.#_,clipPathId:this.#Xo}=t.drawLayer.draw({bbox:this.#Zo.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#Jo},path:{d:this.#Zo.toSVGPath()}},!1,!0)),this.#tl=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#Jo},bbox:this.#Ko.box,path:{d:this.#Ko.toSVGPath()}},this.#Jo),this.#Qo&&(this.#Qo.style.clipPath=this.#Xo))}static#al([t,e,i,n],s){switch(s){case 90:return[1-e-n,t,n,i];case 180:return[1-t-i,1-e-n,i,n];case 270:return[e,1-t-i,n,i]}return[t,e,i,n]}rotate(t){const{drawLayer:e}=this.parent;let i;this.#Jo?(t=(t-this.rotation+360)%360,i=Ks.#al(this.#Zo.box,t)):i=Ks.#al([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#_,{bbox:i,root:{"data-main-rotation":t}}),e.updateProperties(this.#tl,{bbox:Ks.#al(this.#Ko.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#be&&(t.setAttribute("aria-label",this.#be),t.setAttribute("role","mark")),this.#Jo?t.classList.add("free"):this.div.addEventListener("keydown",this.#dl.bind(this),{signal:this._uiManager._signal});const e=this.#Qo=document.createElement("div");return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#Xo,this.setDims(),ce(this,this.#Qo,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#tl,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#tl,{rootClass:{hovered:!1}})}#dl(t){Ks._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#cl(!0);break;case 1:case 3:this.#cl(!1)}}#cl(t){if(!this.#$o)return;const e=window.getSelection();t?e.setPosition(this.#$o,this.#Wo):e.setPosition(this.#qo,this.#Yo)}select(){super.select(),this.#tl&&this.parent?.drawLayer.updateProperties(this.#tl,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#tl&&(this.parent?.drawLayer.updateProperties(this.#tl,{rootClass:{selected:!1}}),this.#Jo||this.#cl(!1))}get _mustFixPosition(){return!this.#Jo}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#_,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#tl,{rootClass:{hidden:!t}}))}#ll(){return this.#Jo?this.rotation:0}#ul(){if(this.#Jo)return null;const[t,e]=this.pageDimensions,[i,n]=this.pageTranslation,s=this.#Go,a=new Float32Array(8*s.length);let r=0;for(const{x:o,y:l,width:h,height:d}of s){const s=o*t+i,c=(1-l)*e+n;a[r]=a[r+4]=s,a[r+1]=a[r+3]=c,a[r+2]=a[r+6]=s+h*t,a[r+5]=a[r+7]=c-d*e,r+=8}return a}#pl(t){return this.#Zo.serialize(t,this.#ll())}static startHighlighting(t,e,{target:i,x:n,y:s}){const{x:a,y:r,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,d=t.combinedSignal(h),c=e=>{h.abort(),this.#gl(t,e)};window.addEventListener("blur",c,{signal:d}),window.addEventListener("pointerup",c,{signal:d}),window.addEventListener("pointerdown",Wt,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",$t,{signal:d}),i.addEventListener("pointermove",this.#ml.bind(this,t),{signal:d}),this._freeHighlight=new Gs({x:n,y:s},[a,r,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#ml(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#gl(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 n=null;if(t instanceof Ls){const{data:{quadPoints:e,rect:i,rotation:s,id:a,color:r,opacity:o,popupRef:l,richText:h,contentsObj:d,creationDate:c,modificationDate:u},parent:{page:{pageNumber:p}}}=t;n=t={annotationType:O.HIGHLIGHT,color:Array.from(r),opacity:o,quadPoints:e,boxes:null,pageIndex:p-1,rect:i.slice(0),rotation:s,annotationElementId:a,id:a,deleted:!1,popupRef:l,richText:h,comment:d?.str||null,creationDate:c,modificationDate:u}}else if(t instanceof Is){const{data:{inkLists:e,rect:i,rotation:s,id:a,color:r,borderStyle:{rawWidth:o},popupRef:l,richText:h,contentsObj:d,creationDate:c,modificationDate:u},parent:{page:{pageNumber:p}}}=t;n=t={annotationType:O.HIGHLIGHT,color:Array.from(r),thickness:o,inkLists:e,boxes:null,pageIndex:p-1,rect:i.slice(0),rotation:s,annotationElementId:a,id:a,deleted:!1,popupRef:l,richText:h,comment:d?.str||null,creationDate:c,modificationDate:u}}const{color:s,quadPoints:a,inkLists:r,outlines:o,opacity:l}=t,h=await super.deserialize(t,e,i);h.color=Pt.makeHexColor(...s),h.opacity=l||1,r&&(h.#wo=t.thickness),h._initialData=n,t.comment&&h.setCommentData(t);const[d,c]=h.pageDimensions,[u,p]=h.pageTranslation;if(a){const t=h.#Go=[];for(let e=0;e<a.length;e+=8)t.push({x:(a[e]-u)/d,y:1-(a[e+1]-p)/c,width:(a[e+2]-a[e])/d,height:(a[e+1]-a[e+5])/c});h.#sl(),h.#nl(),h.rotate(h.rotation)}else if(r||o){h.#Jo=!0;const t=(r||o.points)[0],i={x:t[0]-u,y:c-(t[1]-p)},n=new Gs(i,[0,0,d,c],1,h.#wo/2,!0,.001);for(let e=0,s=t.length;e<s;e+=2)i.x=t[e]-u,i.y=c-(t[e+1]-p),n.add(i);const{id:s,clipPathId:a}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:h.color,"fill-opacity":h._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:n.toSVGPath()}},!0,!0);h.#il({highlightOutlines:n.getOutlines(),highlightId:s,clipPathId:a}),h.#nl(),h.rotate(h.parentRotation)}return h}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=Ae._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i=super.serialize(t);return Object.assign(i,{color:e,opacity:this.opacity,thickness:this.#wo,quadPoints:this.#ul(),outlines:this.#pl(i.rect)}),this.addComment(i),this.annotationElementId&&!this.#oo(i)?null:(i.id=this.annotationElementId,i)}#oo(t){const{color:e}=this._initialData;return this.hasEditedComment||t.color.some((t,i)=>t!==e[i])}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}}class qs{#fl=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))e.startsWith("_")||this.updateProperty(e,i)}updateSVGProperty(t,e){this.#fl[t]=e}toSVGProperties(){const t=this.#fl;return this.#fl=Object.create(null),{root:t}}reset(){this.#fl=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){dt("Not implemented")}}class Ys extends Ae{#bl=null;#vl;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#wl=null;static#yl=null;static#xl=null;static _INNER_MARGIN=3;constructor(t){super(t),this.#vl=t.mustBeCommitted||!1,this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(t){t.drawOutlines&&(this.#Al(t),this.#nl())}#Al({drawOutlines:t,drawId:e,drawingOptions:i}){this.#bl=t,this._drawingOptions||=i,this.annotationElementId||this._uiManager.a11yAlert(Ae._l10nAlert[this.editorType]),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#Cl(t,this.parent),this.#Sl(t.box)}#Cl(t,e){const{id:i}=e.drawLayer.draw(Ys._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){const i=new Set(Object.keys(t));for(const[n,s]of Object.entries(e))i.has(n)?Object.assign(t[n],s):t[n]=s;return t}static getDefaultDrawingOptions(t){dt("Not implemented")}static get typesMap(){dt("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&&(Ys.#wl.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,n]of this.typesMap)t.push([i,e[n]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[i,n]of this.constructor.typesMap)t.push([i,e[n]]);return t}_updateProperty(t,e,i){const n=this._drawingOptions,s=n[e],a=i=>{n.updateProperty(e,i);const s=this.#bl.updateProperty(e,i);s&&this.#Sl(s),this.parent?.drawLayer.updateProperties(this._drawId,n.toSVGProperties()),t===this.colorType?this.onUpdatedColor():t===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:a.bind(this,i),undo:a.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(t,e){const i=this.constructor.typesMap.get(this.colorType),n=this.constructor.typesMap.get(this.opacityType),s=this._drawingOptions,a=s[i],r=s[n],o=(t,e)=>{s.updateProperty(i,t),s.updateProperty(n,e),this.#bl.updateProperty(i,t),this.#bl.updateProperty(n,e),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:o.bind(this,t,e),undo:o.bind(this,a,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:B.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,Ys._mergeSVGProperties(this.#bl.getPathResizingSVGProperties(this.#Pl()),{bbox:this.#_l()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,Ys._mergeSVGProperties(this.#bl.getPathResizedSVGProperties(this.#Pl()),{bbox:this.#_l()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#_l()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,Ys._mergeSVGProperties(this.#bl.getPathTranslatedSVGProperties(this.#Pl(),this.parentDimensions),{bbox:this.#_l()}))}_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.#vl&&(this.#vl=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#hl(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#nl(),this.#Sl(this.#bl.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#hl()):t&&(this._uiManager.addShouldRescale(this),this.#nl(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#hl(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#nl(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#Cl(this.#bl,t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}#El([t,e,i,n]){const{parentDimensions:[s,a],rotation:r}=this;switch(r){case 90:return[e,1-t,i*(a/s),n*(s/a)];case 180:return[1-t,1-e,i,n];case 270:return[1-e,t,i*(a/s),n*(s/a)];default:return[t,e,i,n]}}#Pl(){const{x:t,y:e,width:i,height:n,parentDimensions:[s,a],rotation:r}=this;switch(r){case 90:return[1-e,t,i*(s/a),n*(a/s)];case 180:return[1-t,1-e,i,n];case 270:return[e,1-t,i*(s/a),n*(a/s)];default:return[t,e,i,n]}}#Sl(t){[this.x,this.y,this.width,this.height]=this.#El(t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#_l(){const{x:t,y:e,width:i,height:n,rotation:s,parentRotation:a,parentDimensions:[r,o]}=this;switch((4*s+a)/90){case 1:return[1-e-n,t,n,i];case 2:return[1-t-i,1-e-n,i,n];case 3:return[e,1-t-i,n,i];case 4:return[t,e-i*(r/o),n*(o/r),i*(r/o)];case 5:return[1-e,t,i*(r/o),n*(o/r)];case 6:return[1-t-n*(o/r),1-e,n*(o/r),i*(r/o)];case 7:return[e-i*(r/o),1-t-n*(o/r),i*(r/o),n*(o/r)];case 8:return[t-i,e-n,i,n];case 9:return[1-e,t-i,n,i];case 10:return[1-t,1-e,i,n];case 11:return[e-n,1-t,n,i];case 12:return[t-n*(o/r),e,n*(o/r),i*(r/o)];case 13:return[1-e-i*(r/o),t-n*(o/r),i*(r/o),n*(o/r)];case 14:return[1-t,1-e-i*(r/o),n*(o/r),i*(r/o)];case 15:return[e,1-t,i*(r/o),n*(o/r)];default:return[t,e,i,n]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,Ys._mergeSVGProperties({bbox:this.#_l()},this.#bl.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#Sl(this.#bl.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const i=super.render();i.classList.add("draw");const n=document.createElement("div");return i.append(n),n.setAttribute("aria-hidden","true"),n.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),i}static createDrawerInstance(t,e,i,n,s){dt("Not implemented")}static startDrawing(t,e,i,n){const{target:s,offsetX:a,offsetY:r,pointerId:o,pointerType:l}=n;if(ue.isInitializedAndDifferentPointerType(l))return;const{viewport:{rotation:h}}=t,{width:d,height:c}=s.getBoundingClientRect(),u=Ys.#yl=new AbortController,p=t.combinedSignal(u);ue.setPointer(l,o),window.addEventListener("pointerup",t=>{ue.isSamePointerIdOrRemove(t.pointerId)&&this._endDraw(t)},{signal:p}),window.addEventListener("pointercancel",t=>{ue.isSamePointerIdOrRemove(t.pointerId)&&this._currentParent.endDrawingSession()},{signal:p}),window.addEventListener("pointerdown",t=>{ue.isSamePointerType(t.pointerType)&&(ue.initializeAndAddPointerId(t.pointerId),Ys.#wl.isCancellable()&&(Ys.#wl.removeLastElement(),Ys.#wl.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",$t,{signal:p}),s.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),s.addEventListener("touchmove",t=>{ue.isSameTimeStamp(t.timeStamp)&&Wt(t)},{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),Ys.#wl?t.drawLayer.updateProperties(this._currentDrawId,Ys.#wl.startNew(a,r,d,c,h)):(e.updateUIForDefaultProperties(this),Ys.#wl=this.createDrawerInstance(a,r,d,c,h),Ys.#xl=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(Ys.#xl.toSVGProperties(),Ys.#wl.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(ue.isSameTimeStamp(t.timeStamp),!Ys.#wl)return;const{offsetX:e,offsetY:i,pointerId:n}=t;ue.isSamePointerId(n)&&(ue.isUsingMultiplePointers()?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,Ys.#wl.add(e,i)),ue.setTimeStamp(t.timeStamp),Wt(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,Ys.#wl=null,Ys.#xl=null,ue.clearTimeStamp()),Ys.#yl&&(Ys.#yl.abort(),Ys.#yl=null,ue.clearPointerIds())}static _endDraw(t){const e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t?.target===e.div&&e.drawLayer.updateProperties(this._currentDrawId,Ys.#wl.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const t=Ys.#wl,i=this._currentDrawId,n=t.getLastElement();return void e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(n))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:B.DRAW_STEP})}this.endDrawing(!1)}}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(B.DRAW_STEP),!Ys.#wl.isEmpty()){const{pageDimensions:[i,n],scale:s}=e,a=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:Ys.#wl.getOutlines(i*s,n*s,s,this._INNER_MARGIN),drawingOptions:Ys.#xl,mustBeCommitted:!t});return this._cleanup(!0),a}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,n,s,a){dt("Not implemented")}static async deserialize(t,e,i){const{rawDims:{pageWidth:n,pageHeight:s,pageX:a,pageY:r}}=e.viewport,o=this.deserializeDraw(a,r,n,s,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#Al({drawOutlines:o}),l.#nl(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){const[e,i]=this.pageTranslation,[n,s]=this.pageDimensions;return this.#bl.serialize([e,i,n,s],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class Qs{#po=new Float64Array(6);#Vr;#Tl;#Ys;#wo;#yo;#Ml="";#kl=0;#zo=new Zs;#Dl;#Il;constructor(t,e,i,n,s,a){this.#Dl=i,this.#Il=n,this.#Ys=s,this.#wo=a,[t,e]=this.#Ll(t,e);const r=this.#Vr=[NaN,NaN,NaN,NaN,t,e];this.#yo=[t,e],this.#Tl=[{line:r,points:this.#yo}],this.#po.set(r,0)}updateProperty(t,e){"stroke-width"===t&&(this.#wo=e)}#Ll(t,e){return Hs._normalizePoint(t,e,this.#Dl,this.#Il,this.#Ys)}isEmpty(){return!this.#Tl||0===this.#Tl.length}isCancellable(){return this.#yo.length<=10}add(t,e){[t,e]=this.#Ll(t,e);const[i,n,s,a]=this.#po.subarray(2,6),r=t-s,o=e-a;return Math.hypot(this.#Dl*r,this.#Il*o)<=2?null:(this.#yo.push(t,e),isNaN(i)?(this.#po.set([s,a,t,e],2),this.#Vr.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#po[0])&&this.#Vr.splice(6,6),this.#po.set([i,n,s,a,t,e],0),this.#Vr.push(...Hs.createBezierPoints(i,n,s,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const i=this.add(t,e);return i||(2===this.#yo.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,n,s){this.#Dl=i,this.#Il=n,this.#Ys=s,[t,e]=this.#Ll(t,e);const a=this.#Vr=[NaN,NaN,NaN,NaN,t,e];this.#yo=[t,e];const r=this.#Tl.at(-1);return r&&(r.line=new Float32Array(r.line),r.points=new Float32Array(r.points)),this.#Tl.push({line:a,points:this.#yo}),this.#po.set(a,0),this.#kl=0,this.toSVGPath(),null}getLastElement(){return this.#Tl.at(-1)}setLastElement(t){return this.#Tl?(this.#Tl.push(t),this.#Vr=t.line,this.#yo=t.points,this.#kl=0,{path:{d:this.toSVGPath()}}):this.#zo.setLastElement(t)}removeLastElement(){if(!this.#Tl)return this.#zo.removeLastElement();this.#Tl.pop(),this.#Ml="";for(let t=0,e=this.#Tl.length;t<e;t++){const{line:e,points:i}=this.#Tl[t];this.#Vr=e,this.#yo=i,this.#kl=0,this.toSVGPath()}return{path:{d:this.#Ml}}}toSVGPath(){const t=Hs.svgRound(this.#Vr[4]),e=Hs.svgRound(this.#Vr[5]);if(2===this.#yo.length)return this.#Ml=`${this.#Ml} M ${t} ${e} Z`,this.#Ml;if(this.#yo.length<=6){const i=this.#Ml.lastIndexOf("M");this.#Ml=`${this.#Ml.slice(0,i)} M ${t} ${e}`,this.#kl=6}if(4===this.#yo.length){const t=Hs.svgRound(this.#Vr[10]),e=Hs.svgRound(this.#Vr[11]);return this.#Ml=`${this.#Ml} L ${t} ${e}`,this.#kl=12,this.#Ml}const i=[];0===this.#kl&&(i.push(`M ${t} ${e}`),this.#kl=6);for(let t=this.#kl,e=this.#Vr.length;t<e;t+=6){const[e,n,s,a,r,o]=this.#Vr.slice(t,t+6).map(Hs.svgRound);i.push(`C${e} ${n} ${s} ${a} ${r} ${o}`)}return this.#Ml+=i.join(" "),this.#kl=this.#Vr.length,this.#Ml}getOutlines(t,e,i,n){const s=this.#Tl.at(-1);return s.line=new Float32Array(s.line),s.points=new Float32Array(s.points),this.#zo.build(this.#Tl,t,e,i,this.#Ys,this.#wo,n),this.#po=null,this.#Vr=null,this.#Tl=null,this.#Ml=null,this.#zo}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class Zs extends Hs{#Do;#Nl=0;#do;#Tl;#Dl;#Il;#Rl;#Ys;#wo;build(t,e,i,n,s,a,r){this.#Dl=e,this.#Il=i,this.#Rl=n,this.#Ys=s,this.#wo=a,this.#do=r??0,this.#Tl=t,this.#Fl()}get thickness(){return this.#wo}setLastElement(t){return this.#Tl.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#Tl.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#Tl)if(t.push(`M${Hs.svgRound(e[4])} ${Hs.svgRound(e[5])}`),6!==e.length)if(12===e.length&&isNaN(e[6]))t.push(`L${Hs.svgRound(e[10])} ${Hs.svgRound(e[11])}`);else for(let i=6,n=e.length;i<n;i+=6){const[n,s,a,r,o,l]=e.subarray(i,i+6).map(Hs.svgRound);t.push(`C${n} ${s} ${a} ${r} ${o} ${l}`)}else t.push("Z");return t.join("")}serialize([t,e,i,n],s){const a=[],r=[],[o,l,h,d]=this.#Ol();let c,u,p,g,m,f,b,v,w;switch(this.#Ys){case 0:w=Hs._rescale,c=t,u=e+n,p=i,g=-n,m=t+o*i,f=e+(1-l-d)*n,b=t+(o+h)*i,v=e+(1-l)*n;break;case 90:w=Hs._rescaleAndSwap,c=t,u=e,p=i,g=n,m=t+l*i,f=e+o*n,b=t+(l+d)*i,v=e+(o+h)*n;break;case 180:w=Hs._rescale,c=t+i,u=e,p=-i,g=n,m=t+(1-o-h)*i,f=e+l*n,b=t+(1-o)*i,v=e+(l+d)*n;break;case 270:w=Hs._rescaleAndSwap,c=t+i,u=e+n,p=-i,g=-n,m=t+(1-l-d)*i,f=e+(1-o-h)*n,b=t+(1-l)*i,v=e+(1-o)*n}for(const{line:t,points:e}of this.#Tl)a.push(w(t,c,u,p,g,s?new Array(t.length):null)),r.push(w(e,c,u,p,g,s?new Array(e.length):null));return{lines:a,points:r,rect:[m,f,b,v]}}static deserialize(t,e,i,n,s,{paths:{lines:a,points:r},rotation:o,thickness:l}){const h=[];let d,c,u,p,g;switch(o){case 0:g=Hs._rescale,d=-t/i,c=e/n+1,u=1/i,p=-1/n;break;case 90:g=Hs._rescaleAndSwap,d=-e/n,c=-t/i,u=1/n,p=1/i;break;case 180:g=Hs._rescale,d=t/i+1,c=-e/n,u=-1/i,p=1/n;break;case 270:g=Hs._rescaleAndSwap,d=e/n+1,c=t/i+1,u=-1/n,p=-1/i}if(!a){a=[];for(const t of r){const e=t.length;if(2===e){a.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){a.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));a.push(i);let[n,s,r,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,n,s],0);for(let a=4;a<e;a+=2){const e=t[a],l=t[a+1];i.set(Hs.createBezierPoints(n,s,r,o,e,l),3*(a-2)),[n,s,r,o]=[r,o,e,l]}}}for(let t=0,e=a.length;t<e;t++)h.push({line:g(a[t].map(t=>t??NaN),d,c,u,p),points:g(r[t].map(t=>t??NaN),d,c,u,p)});const m=new this.prototype.constructor;return m.build(h,i,n,1,o,l,s),m}#Bl(t=this.#wo){const e=this.#do+t/2*this.#Rl;return this.#Ys%180==0?[e/this.#Dl,e/this.#Il]:[e/this.#Il,e/this.#Dl]}#Ol(){const[t,e,i,n]=this.#Do,[s,a]=this.#Bl(0);return[t+s,e+a,i-2*s,n-2*a]}#Fl(){const t=this.#Do=A.slice();for(const{line:e}of this.#Tl){if(e.length<=12){for(let i=4,n=e.length;i<n;i+=6)Pt.pointBoundingBox(e[i],e[i+1],t);continue}let i=e[4],n=e[5];for(let s=6,a=e.length;s<a;s+=6){const[a,r,o,l,h,d]=e.subarray(s,s+6);Pt.bezierBoundingBox(i,n,a,r,o,l,h,d,t),i=h,n=d}}const[e,i]=this.#Bl();t[0]=It(t[0]-e,0,1),t[1]=It(t[1]-i,0,1),t[2]=It(t[2]+e,0,1),t[3]=It(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#Do}updateProperty(t,e){return"stroke-width"===t?this.#rl(e):null}#rl(t){const[e,i]=this.#Bl();this.#wo=t;const[n,s]=this.#Bl(),[a,r]=[n-e,s-i],o=this.#Do;return o[0]-=a,o[1]-=r,o[2]+=2*a,o[3]+=2*r,o}updateParentDimensions([t,e],i){const[n,s]=this.#Bl();this.#Dl=t,this.#Il=e,this.#Rl=i;const[a,r]=this.#Bl(),o=a-n,l=r-s,h=this.#Do;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#Nl=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#Do.map(Hs.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#Do;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Hs.svgRound(t)} ${Hs.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#Do;let i=0,n=0,s=0,a=0,r=0,o=0;switch(this.#Nl){case 90:n=e/t,s=-t/e,r=t;break;case 180:i=-1,a=-1,r=t,o=e;break;case 270:n=-e/t,s=t/e,o=e;break;default:return""}return`matrix(${i} ${n} ${s} ${a} ${Hs.svgRound(r)} ${Hs.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,n]){const[s,a]=this.#Bl(),[r,o,l,h]=this.#Do;if(Math.abs(l-s)<=Hs.PRECISION||Math.abs(h-a)<=Hs.PRECISION){const s=t+i/2-(r+l/2),a=e+n/2-(o+h/2);return{path:{"transform-origin":`${Hs.svgRound(t)} ${Hs.svgRound(e)}`,transform:`${this.rotationTransform} translate(${s} ${a})`}}}const d=(i-2*s)/(l-2*s),c=(n-2*a)/(h-2*a),u=l/i,p=h/n;return{path:{"transform-origin":`${Hs.svgRound(r)} ${Hs.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${p}) translate(${Hs.svgRound(s)} ${Hs.svgRound(a)}) scale(${d} ${c}) translate(${Hs.svgRound(-s)} ${Hs.svgRound(-a)})`}}}getPathResizedSVGProperties([t,e,i,n]){const[s,a]=this.#Bl(),r=this.#Do,[o,l,h,d]=r;if(r[0]=t,r[1]=e,r[2]=i,r[3]=n,Math.abs(h-s)<=Hs.PRECISION||Math.abs(d-a)<=Hs.PRECISION){const s=t+i/2-(o+h/2),a=e+n/2-(l+d/2);for(const{line:t,points:e}of this.#Tl)Hs._translate(t,s,a,t),Hs._translate(e,s,a,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Hs.svgRound(t)} ${Hs.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const c=(i-2*s)/(h-2*s),u=(n-2*a)/(d-2*a),p=-c*(o+s)+t+s,g=-u*(l+a)+e+a;if(1!==c||1!==u||0!==p||0!==g)for(const{line:t,points:e}of this.#Tl)Hs._rescale(t,p,g,c,u,t),Hs._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Hs.svgRound(t)} ${Hs.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[n,s]=i,a=this.#Do,r=t-a[0],o=e-a[1];if(this.#Dl===n&&this.#Il===s)for(const{line:t,points:e}of this.#Tl)Hs._translate(t,r,o,t),Hs._translate(e,r,o,e);else{const t=this.#Dl/n,e=this.#Il/s;this.#Dl=n,this.#Il=s;for(const{line:i,points:n}of this.#Tl)Hs._rescale(i,r,o,t,e,i),Hs._rescale(n,r,o,t,e,n);a[2]*=t,a[3]*=e}return a[0]=t,a[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Hs.svgRound(t)} ${Hs.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#Do;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Hs.svgRound(t[0])} ${Hs.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class Js extends qs{constructor(t){super(),this._viewParameters=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._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new Js(this._viewParameters);return t.updateAll(this),t}}class ta extends Ys{static _type="ink";static _editorType=O.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){Ae.initialize(t,e),this._defaultDrawingOptions=new Js(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return mt(this,"typesMap",new Map([[B.INK_THICKNESS,"stroke-width"],[B.INK_COLOR,"stroke"],[B.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,n,s){return new Qs(t,e,i,n,s,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,n,s,a){return Zs.deserialize(t,e,i,n,s,a)}static async deserialize(t,e,i){let n=null;if(t instanceof Is){const{data:{inkLists:e,rect:i,rotation:s,id:a,color:r,opacity:o,borderStyle:{rawWidth:l},popupRef:h,richText:d,contentsObj:c,creationDate:u,modificationDate:p},parent:{page:{pageNumber:g}}}=t;n=t={annotationType:O.INK,color:Array.from(r),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:g-1,rect:i.slice(0),rotation:s,annotationElementId:a,id:a,deleted:!1,popupRef:h,richText:d,comment:c?.str||null,creationDate:u,modificationDate:p}}const s=await super.deserialize(t,e,i);return s._initialData=n,t.comment&&s.setCommentData(t),s}get toolbarButtons(){return this._colorPicker||=new ns(this),[["colorPicker",this._colorPicker]]}get colorType(){return B.INK_COLOR}get colorAndOpacityType(){return B.INK_COLOR_AND_OPACITY}get opacityType(){return B.INK_OPACITY}updateParams(t,e){t!==B.INK_COLOR_AND_OPACITY?super.updateParams(t,e):this._updateColorAndOpacity(e.color,e.opacity)}static updateDefaultParams(t,e){if(t===B.INK_COLOR_AND_OPACITY)return super.updateDefaultParams(B.INK_COLOR,e.color),void super.updateDefaultParams(B.INK_OPACITY,e.opacity);super.updateDefaultParams(t,e)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}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=ta.getDefaultDrawingOptions({stroke:Pt.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}=this.serializeDraw(t),{_drawingOptions:{stroke:n,"stroke-opacity":s,"stroke-width":a}}=this,r=Object.assign(super.serialize(t),{color:Ae._colorManager.convert(n),opacity:s,thickness:a,paths:{lines:e,points:i}});return this.addComment(r),t?(r.isCopy=!0,r):this.annotationElementId&&!this.#oo(r)?null:(r.id=this.annotationElementId,r)}#oo(t){const{color:e,thickness:i,opacity:n,pageIndex:s}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((t,i)=>t!==e[i])||t.thickness!==i||t.opacity!==n||t.pageIndex!==s}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;const{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class ea extends Zs{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}let ia=class{static#jl={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#Ul(t,e,i,n){return n-=e,0===(i-=t)?n>0?0:4:1===i?n+6:2-n}static#Hl=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#Vl(t,e,i,n,s,a,r){const o=this.#Ul(i,n,s,a);for(let s=0;s<8;s++){const a=(-s+o-r+16)%8;if(0!==t[(i+this.#Hl[2*a])*e+(n+this.#Hl[2*a+1])])return a}return-1}static#zl(t,e,i,n,s,a,r){const o=this.#Ul(i,n,s,a);for(let s=0;s<8;s++){const a=(s+o+r+16)%8;if(0!==t[(i+this.#Hl[2*a])*e+(n+this.#Hl[2*a+1])])return a}return-1}static#$l(t,e,i,n){const s=t.length,a=new Int32Array(s);for(let e=0;e<s;e++)a[e]=t[e]<=n?1:0;for(let t=1;t<i-1;t++)a[t*e]=a[t*e+e-1]=0;for(let t=0;t<e;t++)a[t]=a[e*i-1-t]=0;let r,o=1;const l=[];for(let t=1;t<i-1;t++){r=1;for(let i=1;i<e-1;i++){const n=t*e+i,s=a[n];if(0===s)continue;let h=t,d=i;if(1===s&&0===a[n-1])o+=1,d-=1;else{if(!(s>=1&&0===a[n+1])){1!==s&&(r=Math.abs(s));continue}o+=1,d+=1,s>1&&(r=s)}const c=[i,t],u=d===i+1,p={isHole:u,points:c,id:o,parent:0};let g;l.push(p);for(const t of l)if(t.id===r){g=t;break}g?g.isHole?p.parent=u?g.parent:r:p.parent=u?r:g.parent:p.parent=u?r:0;const m=this.#Vl(a,e,t,i,h,d,0);if(-1===m){a[n]=-o,1!==a[n]&&(r=Math.abs(a[n]));continue}let f=this.#Hl[2*m],b=this.#Hl[2*m+1];const v=t+f,w=i+b;h=v,d=w;let y=t,x=i;for(;;){const s=this.#zl(a,e,y,x,h,d,1);f=this.#Hl[2*s],b=this.#Hl[2*s+1];const l=y+f,u=x+b;c.push(u,l);const p=y*e+x;if(0===a[p+1]?a[p]=-o:1===a[p]&&(a[p]=o),l===t&&u===i&&y===v&&x===w){1!==a[n]&&(r=Math.abs(a[n]));break}h=y,d=x,y=l,x=u}}}return l}static#Wl(t,e,i,n){if(i-e<=4){for(let s=e;s<i-2;s+=2)n.push(t[s],t[s+1]);return}const s=t[e],a=t[e+1],r=t[i-4]-s,o=t[i-3]-a,l=Math.hypot(r,o),h=r/l,d=o/l,c=h*a-d*s,u=o/r,p=1/l,g=Math.atan(u),m=Math.cos(g),f=Math.sin(g),b=p*(Math.abs(m)+Math.abs(f)),v=p*(1-b+b**2),w=Math.max(Math.atan(Math.abs(f+m)*v),Math.atan(Math.abs(f-m)*v));let y=0,x=e;for(let n=e+2;n<i-2;n+=2){const e=Math.abs(c-h*t[n+1]+d*t[n]);e>y&&(x=n,y=e)}y>(l*w)**2?(this.#Wl(t,e,x+2,n),this.#Wl(t,x,i,n)):n.push(s,a)}static#Gl(t){const e=[],i=t.length;return this.#Wl(t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e}static#Xl(t,e,i,n,s,a){const r=new Float32Array(a**2),o=-2*n**2,l=a>>1;for(let t=0;t<a;t++){const e=(t-l)**2;for(let i=0;i<a;i++)r[t*a+i]=Math.exp((e+(i-l)**2)/o)}const h=new Float32Array(256),d=-2*s**2;for(let t=0;t<256;t++)h[t]=Math.exp(t**2/d);const c=t.length,u=new Uint8Array(c),p=new Uint32Array(256);for(let n=0;n<i;n++)for(let s=0;s<e;s++){const o=n*e+s,d=t[o];let c=0,g=0;for(let o=0;o<a;o++){const u=n+o-l;if(!(u<0||u>=i))for(let i=0;i<a;i++){const n=s+i-l;if(n<0||n>=e)continue;const p=t[u*e+n],m=r[o*a+i]*h[Math.abs(p-d)];c+=p*m,g+=m}}p[u[o]=Math.round(c/g)]++}return[u,p]}static#Kl(t){const e=new Uint32Array(256);for(const i of t)e[i]++;return e}static#ql(t){const e=t.length,i=new Uint8ClampedArray(e>>2);let n=-1/0,s=1/0;for(let e=0,a=i.length;e<a;e++){const a=i[e]=t[e<<2];n=Math.max(n,a),s=Math.min(s,a)}const a=255/(n-s);for(let t=0,e=i.length;t<e;t++)i[t]=(i[t]-s)*a;return i}static#Yl(t){let e,i=-1/0,n=-1/0;const s=t.findIndex(t=>0!==t);let a=s,r=s;for(e=s;e<256;e++){const s=t[e];s>i&&(e-a>n&&(n=e-a,r=e-1),i=s,a=e)}for(e=r-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static#Ql(t){const e=t,{width:i,height:n}=t,{maxDim:s}=this.#jl;let a=i,r=n;if(i>s||n>s){let o=i,l=n,h=Math.log2(Math.max(i,n)/s);const d=Math.floor(h);h=h===d?d-1:d;for(let i=0;i<h;i++){a=Math.ceil(o/2),r=Math.ceil(l/2);const i=new OffscreenCanvas(a,r);i.getContext("2d").drawImage(t,0,0,o,l,0,0,a,r),o=a,l=r,t!==e&&t.close(),t=i.transferToImageBitmap()}const c=Math.min(s/a,s/r);a=Math.round(a*c),r=Math.round(r*c)}const o=new OffscreenCanvas(a,r).getContext("2d",{willReadFrequently:!0});o.fillStyle="white",o.fillRect(0,0,a,r),o.filter="grayscale(1)",o.drawImage(t,0,0,t.width,t.height,0,0,a,r);const l=o.getImageData(0,0,a,r).data;return[this.#ql(l),a,r]}static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:n},s,a,r,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1});const d=h.font=`${i} ${n} 200px ${e}`,{actualBoundingBoxLeft:c,actualBoundingBoxRight:u,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:m,fontBoundingBoxDescent:f,width:b}=h.measureText(t),v=1.5,w=Math.ceil(Math.max(Math.abs(c)+Math.abs(u)||0,b)*v),y=Math.ceil(Math.max(Math.abs(p)+Math.abs(g)||200,Math.abs(m)+Math.abs(f)||200)*v);l=new OffscreenCanvas(w,y),h=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=d,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,w,y),h.fillStyle="black",h.fillText(t,.5*w/2,1.5*y/2);const x=this.#ql(h.getImageData(0,0,w,y).data),A=this.#Kl(x),C=this.#Yl(A),S=this.#$l(x,w,y,C);return this.processDrawnLines({lines:{curves:S,width:w,height:y},pageWidth:s,pageHeight:a,rotation:r,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,i,n,s){const[a,r,o]=this.#Ql(t),[l,h]=this.#Xl(a,r,o,Math.hypot(r,o)*this.#jl.sigmaSFactor,this.#jl.sigmaR,this.#jl.kernelSize),d=this.#Yl(h),c=this.#$l(l,r,o,d);return this.processDrawnLines({lines:{curves:c,width:r,height:o},pageWidth:e,pageHeight:i,rotation:n,innerMargin:s,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:n,innerMargin:s,mustSmooth:a,areContours:r}){n%180!=0&&([e,i]=[i,e]);const{curves:o,width:l,height:h}=t,d=t.thickness??0,c=[],u=Math.min(e/l,i/h),p=u/e,g=u/i,m=[];for(const{points:t}of o){const e=a?this.#Gl(t):t;if(!e)continue;m.push(e);const i=e.length,n=new Float32Array(i),s=new Float32Array(3*(2===i?2:i-2));if(c.push({line:s,points:n}),2===i){n[0]=e[0]*p,n[1]=e[1]*g,s.set([NaN,NaN,NaN,NaN,n[0],n[1]],0);continue}let[r,o,l,h]=e;r*=p,o*=g,l*=p,h*=g,n.set([r,o,l,h],0),s.set([NaN,NaN,NaN,NaN,r,o],0);for(let t=4;t<i;t+=2){const i=n[t]=e[t]*p,a=n[t+1]=e[t+1]*g;s.set(Hs.createBezierPoints(r,o,l,h,i,a),3*(t-2)),[r,o,l,h]=[l,h,i,a]}}if(0===c.length)return null;const f=r?new ea:new Zs;return f.build(c,e,i,1,n,r?0:d,s),{outline:f,newCurves:m,areContours:r,thickness:d,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:n,height:s}){let a,r=1/0,o=-1/0,l=0;for(const e of t){l+=e.length;for(let t=2,i=e.length;t<i;t++){const i=e[t]-e[t-2];r=Math.min(r,i),o=Math.max(o,i)}}a=r>=-128&&o<=127?Int8Array:r>=-32768&&o<=32767?Int16Array:Int32Array;const h=t.length,d=8+3*h,c=new Uint32Array(d);let u=0;c[u++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*a.BYTES_PER_ELEMENT,c[u++]=0,c[u++]=n,c[u++]=s,c[u++]=e?0:1,c[u++]=Math.max(0,Math.floor(i??0)),c[u++]=h,c[u++]=a.BYTES_PER_ELEMENT;for(const e of t)c[u++]=e.length-2,c[u++]=e[0],c[u++]=e[1];const p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(c);const m=a.prototype.constructor;for(const e of t){const t=new m(e.length-2);for(let i=2,n=e.length;i<n;i++)t[i-2]=e[i]-e[i-2];g.write(t)}g.close();return(await new Response(p.readable).bytes()).toBase64()}static async decompressSignature(t){try{const e=Uint8Array.fromBase64(t),{readable:i,writable:n}=new DecompressionStream("deflate-raw"),s=n.getWriter();await s.ready,s.write(e).then(async()=>{await s.ready,await s.close()}).catch(()=>{});let a=null,r=0;for await(const t of i)a||=new Uint8Array(new Uint32Array(t.buffer,0,4)[0]),a.set(t,r),r+=t.length;const o=new Uint32Array(a.buffer,0,a.length>>2),l=o[1];if(0!==l)throw new Error(`Invalid version: ${l}`);const h=o[2],d=o[3],c=0===o[4],u=o[5],p=o[6],g=o[7],m=[],f=(8+3*p)*Uint32Array.BYTES_PER_ELEMENT;let b;switch(g){case Int8Array.BYTES_PER_ELEMENT:b=new Int8Array(a.buffer,f);break;case Int16Array.BYTES_PER_ELEMENT:b=new Int16Array(a.buffer,f);break;case Int32Array.BYTES_PER_ELEMENT:b=new Int32Array(a.buffer,f)}r=0;for(let t=0;t<p;t++){const e=o[3*t+8],i=new Float32Array(e+2);m.push(i);for(let e=0;e<2;e++)i[e]=o[3*t+8+e+1];for(let t=0;t<e;t++)i[t+2]=i[t]+b[r++]}return{areContours:c,thickness:u,outlines:m,width:h,height:d}}catch(t){return ht(`decompressSignature: ${t}`),null}}};class na extends qs{constructor(){super(),super.updateProperties({fill:Ae._defaultLineColor,"stroke-width":0})}clone(){const t=new na;return t.updateAll(this),t}}class sa extends Js{constructor(t){super(t),super.updateProperties({stroke:Ae._defaultLineColor,"stroke-width":1})}clone(){const t=new sa(this._viewParameters);return t.updateAll(this),t}}class aa extends Ys{#Zl=!1;#Jl=null;#th=null;#eh=null;static _type="signature";static _editorType=O.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#th=t.signatureData||null,this.#Jl=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){Ae.initialize(t,e),this._defaultDrawingOptions=new na,this._defaultDrawnSignatureOptions=new sa(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return mt(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#Jl}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),null===this._drawId)if(this.#th){const{lines:t,mustSmooth:e,areContours:i,description:n,uuid:s,heightInPage:a}=this.#th,{rawDims:{pageWidth:r,pageHeight:o},rotation:l}=this.parent.viewport,h=ia.processDrawnLines({lines:t,pageWidth:r,pageHeight:o,rotation:l,innerMargin:aa._INNER_MARGIN,mustSmooth:e,areContours:i});this.addSignature(h,a,n,s)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:this.#Jl||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#eh=t,this.addEditToolbar()}getUuid(){return this.#eh}get description(){return this.#Jl}set description(t){this.#Jl=t,this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:i,width:n,height:s}=this.#th,a=Math.max(n,s);return{areContours:e,outline:ia.processDrawnLines({lines:{curves:t.map(t=>({points:t})),thickness:i,width:n,height:s},pageWidth:a,pageHeight:a,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,i,n){const{x:s,y:a}=this,{outline:r}=this.#th=t;let o;this.#Zl=r instanceof ea,this.description=i,this.#Zl?o=aa.getDefaultDrawingOptions():(o=aa._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":r.thickness})),this._addOutlines({drawOutlines:r,drawingOptions:o});const[,l]=this.pageDimensions;let h=e/l;h=h>=1?.5:h,this.width*=h/this.height,this.width>=1&&(h*=.9/this.width,this.width=.9),this.height=h,this.setDims(),this.x=s,this.y=a,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(n),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!n,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:n}=this.parent.viewport;return ia.process(t,e,i,n,aa._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:i,pageHeight:n},rotation:s}=this.parent.viewport;return ia.extractContoursFromText(t,e,i,n,s,aa._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:n}=this.parent.viewport;return ia.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:n,innerMargin:aa._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=aa.getDefaultDrawingOptions():(this._drawingOptions=aa._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":n}}=this,s=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#Zl,color:[0,0,0],thickness:this.#Zl?0:n});return this.addComment(s),t?(s.paths={lines:e,points:i},s.uuid=this.#eh,s.isCopy=!0):s.lines=e,this.#Jl&&(s.accessibilityData={type:"Figure",alt:this.#Jl}),s}static deserializeDraw(t,e,i,n,s,a){return a.areContours?ea.deserialize(t,e,i,n,s,a):Zs.deserialize(t,e,i,n,s,a)}static async deserialize(t,e,i){const n=await super.deserialize(t,e,i);return n.#Zl=t.areContours,n.description=t.accessibilityData?.alt||"",n.#eh=t.uuid,n}}class ra extends Ae{#ih=null;#nh=null;#sh=null;#ah=null;#rh=null;#oh="";#lh=null;#hh=!1;#dh=null;#ch=!1;#uh=!1;static _type="stamp";static _editorType=O.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#ah=t.bitmapUrl,this.#rh=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){Ae.initialize(t,e)}static isHandlingMimeForPasting(t){return Jt.includes(t)}static paste(t,e){e.pasteEditor({mode:O.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}}#ph(t,e=!1){t?(this.#ih=t.bitmap,e||(this.#nh=t.id,this.#ch=t.isSvg),t.file&&(this.#oh=t.file.name),this.#gh()):this.remove()}#mh(){if(this.#sh=null,this._uiManager.enableWaiting(!1),this.#lh)if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#ih)this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#ih){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:n,width:s,height:a}=t||this.copyCanvas(null,null,!0).imageData,r=await i.guess({name:"altText",request:{data:n,width:s,height:a,channels:n.length/(s*a)}});if(!r)throw new Error("No response from the AI service.");if(r.error)throw new Error("Error from the AI service.");if(r.cancel)return null;if(!r.output)throw new Error("No valid response from the AI service.");const o=r.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#fh(){if(this.#nh)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#nh).then(t=>this.#ph(t,!0)).finally(()=>this.#mh());if(this.#ah){const t=this.#ah;return this.#ah=null,this._uiManager.enableWaiting(!0),void(this.#sh=this._uiManager.imageManager.getFromUrl(t).then(t=>this.#ph(t)).finally(()=>this.#mh()))}if(this.#rh){const t=this.#rh;return this.#rh=null,this._uiManager.enableWaiting(!0),void(this.#sh=this._uiManager.imageManager.getFromFile(t).then(t=>this.#ph(t)).finally(()=>this.#mh()))}const t=document.createElement("input");t.type="file",t.accept=Jt.join(",");const e=this._uiManager._signal;this.#sh=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.#ph(e)}else this.remove();i()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:e})}).finally(()=>this.#mh()),t.click()}remove(){this.#nh&&(this.#ih=null,this._uiManager.imageManager.deleteId(this.#nh),this.#lh?.remove(),this.#lh=null,this.#dh&&(clearTimeout(this.#dh),this.#dh=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#nh&&null===this.#lh&&this.#fh(),this.isAttachedToDOM||this.parent.add(this))):this.#nh&&this.#fh()}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#sh||this.#ih||this.#ah||this.#rh||this.#nh||this.#hh)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),this.#hh||(this.#ih?this.#gh():this.#fh()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:i,bitmap:n}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(this.#nh=i,n&&(this.#ih=n),this.#hh=!1,this.#gh())}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==this.#dh&&clearTimeout(this.#dh);this.#dh=setTimeout(()=>{this.#dh=null,this.#bh()},200)}#gh(){const{div:t}=this;let{width:e,height:i}=this.#ih;const[n,s]=this.pageDimensions,a=.75;if(this.width)e=this.width*n,i=this.height*s;else if(e>a*n||i>a*s){const t=Math.min(a*n/e,a*s/i);e*=t,i*=t}this._uiManager.enableWaiting(!1);const r=this.#lh=document.createElement("canvas");r.setAttribute("role","img"),this.addContainer(r),this.width=e/n,this.height=i/s,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#bh(),this.#uh||(this.parent.addUndoableEditor(this),this.#uh=!0),this._reportTelemetry({action:"inserted_image"}),this.#oh&&this.div.setAttribute("aria-description",this.#oh),this.annotationElementId||this._uiManager.a11yAlert(Ae._l10nAlert.stamp)}copyCanvas(t,e,i=!1){t||(t=224);const{width:n,height:s}=this.#ih,a=new Zt;let r=this.#ih,o=n,l=s,h=null;if(e){if(n>e||s>e){const t=Math.min(e/n,e/s);o=Math.floor(n*t),l=Math.floor(s*t)}h=document.createElement("canvas");const t=h.width=Math.ceil(o*a.sx),i=h.height=Math.ceil(l*a.sy);this.#ch||(r=this.#vh(t,i));const d=h.getContext("2d");d.filter=this._uiManager.hcmFilter;let c="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":te.isDarkMode&&(c="#8f8f9d",u="#42414d");const p=15,g=p*a.sx,m=p*a.sy,f=new OffscreenCanvas(2*g,2*m),b=f.getContext("2d");b.fillStyle=c,b.fillRect(0,0,2*g,2*m),b.fillStyle=u,b.fillRect(0,0,g,m),b.fillRect(g,m,g,m),d.fillStyle=d.createPattern(f,"repeat"),d.fillRect(0,0,t,i),d.drawImage(r,0,0,r.width,r.height,0,0,t,i)}let d=null;if(i){let e,i;if(a.symmetric&&r.width<t&&r.height<t)e=r.width,i=r.height;else if(r=this.#ih,n>t||s>t){const a=Math.min(t/n,t/s);e=Math.floor(n*a),i=Math.floor(s*a),this.#ch||(r=this.#vh(e,i))}const o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(r,0,0,r.width,r.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}}#vh(t,e){const{width:i,height:n}=this.#ih;let s=i,a=n,r=this.#ih;for(;s>2*t||a>2*e;){const i=s,n=a;s>2*t&&(s=Math.ceil(s/2)),a>2*e&&(a=Math.ceil(a/2));const o=new OffscreenCanvas(s,a);o.getContext("2d").drawImage(r,0,0,i,n,0,0,s,a),r=o.transferToImageBitmap()}return r}#bh(){const[t,e]=this.parentDimensions,{width:i,height:n}=this,s=new Zt,a=Math.ceil(i*t*s.sx),r=Math.ceil(n*e*s.sy),o=this.#lh;if(!o||o.width===a&&o.height===r)return;o.width=a,o.height=r;const l=this.#ch?this.#ih:this.#vh(a,r),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,a,r)}#wh(t){if(t){if(this.#ch){const t=this._uiManager.imageManager.getSvgUrl(this.#nh);if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=this.#ih);return t.getContext("2d").drawImage(this.#ih,0,0),t.toDataURL()}if(this.#ch){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*Ft.PDF_TO_CSS_UNITS),n=Math.round(this.height*e*Ft.PDF_TO_CSS_UNITS),s=new OffscreenCanvas(i,n);return s.getContext("2d").drawImage(this.#ih,0,0,this.#ih.width,this.#ih.height,0,0,i,n),s.transferToImageBitmap()}return structuredClone(this.#ih)}static async deserialize(t,e,i){let n=null,s=!1;if(t instanceof Os){const{data:{rect:a,rotation:r,id:o,structParent:l,popupRef:h,richText:d,contentsObj:c,creationDate:u,modificationDate:p},container:g,parent:{page:{pageNumber:m}},canvas:f}=t;let b,v;f?(delete t.canvas,({id:b,bitmap:v}=i.imageManager.getFromCanvas(g.id,f)),f.remove()):(s=!0,t._hasNoCanvas=!0);const w=(await e._structTree.getAriaAttributes(`${R}${o}`))?.get("aria-label")||"";n=t={annotationType:O.STAMP,bitmapId:b,bitmap:v,pageIndex:m-1,rect:a.slice(0),rotation:r,annotationElementId:o,id:o,deleted:!1,accessibilityData:{decorative:!1,altText:w},isSvg:!1,structParent:l,popupRef:h,richText:d,comment:c?.str||null,creationDate:u,modificationDate:p}}const a=await super.deserialize(t,e,i),{rect:r,bitmap:o,bitmapUrl:l,bitmapId:h,isSvg:d,accessibilityData:c}=t;s?(i.addMissingCanvas(t.id,a),a.#hh=!0):h&&i.imageManager.isValidId(h)?(a.#nh=h,o&&(a.#ih=o)):a.#ah=l,a.#ch=d;const[u,p]=a.pageDimensions;return a.width=(r[2]-r[0])/u,a.height=(r[3]-r[1])/p,c&&(a.altTextData=c),a._initialData=n,t.comment&&a.setCommentData(t),a.#uh=!!n,a}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i=Object.assign(super.serialize(t),{bitmapId:this.#nh,isSvg:this.#ch});if(this.addComment(i),t)return i.bitmapUrl=this.#wh(!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:n,altText:s}=this.serializeAltText(!1);if(!n&&s&&(i.accessibilityData={type:"Figure",alt:s}),this.annotationElementId){const t=this.#oo(i);return t.isSame?null:(t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(null===e)return i;e.stamps||=new Map;const a=this.#ch?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#nh)){if(this.#ch){const t=e.stamps.get(this.#nh);a>t.area&&(t.area=a,t.serialized.bitmap.close(),t.serialized.bitmap=this.#wh(!1))}}else e.stamps.set(this.#nh,{area:a,serialized:i}),i.bitmap=this.#wh(!1);return i}#oo(t){const{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,n=t.pageIndex===e,s=(t.accessibilityData?.alt||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&n&&s,isSameAltText:s}}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}let oa=class t{#yh;#xh=!1;#Ah=null;#Ch=null;#Sh=null;#Ph=new Map;#_h=!1;#Eh=!1;#Th=!1;#Mh=null;#kh=null;#Dh=null;#Ih=null;#Lh=null;#Nh=-1;#v;static _initialized=!1;static#Q=new Map([Us,ta,ra,Ks,aa].map(t=>[t._editorType,t]));constructor({uiManager:e,pageIndex:i,div:n,structTreeLayer:s,accessibilityManager:a,annotationLayer:r,drawLayer:o,textLayer:l,viewport:h,l10n:d}){const c=[...t.#Q.values()];if(!t._initialized){t._initialized=!0;for(const t of c)t.initialize(d,e)}e.registerEditorTypes(c),this.#v=e,this.pageIndex=i,this.div=n,this.#yh=a,this.#Ah=r,this.viewport=h,this.#Dh=l,this.drawLayer=o,this._structTree=s,this.#v.addLayer(this)}get isEmpty(){return 0===this.#Ph.size}get isInvisible(){return this.isEmpty&&this.#v.getMode()===O.NONE}updateToolbar(t){this.#v.updateToolbar(t)}updateMode(e=this.#v.getMode()){switch(this.#Rh(),e){case O.NONE:return this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case O.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case O.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;if(i.toggle("nonEditing",!1),e===O.POPUP)i.toggle("commentEditing",!0);else{i.toggle("commentEditing",!1);for(const n of t.#Q.values())i.toggle(`${n._type}Editing`,e===n._editorType)}this.div.hidden=!1}hasTextLayer(t){return t===this.#Dh?.div}setEditingState(t){this.#v.setEditingState(t)}addCommands(t){this.#v.addCommands(t)}cleanUndoStack(t){this.#v.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#Ah?.togglePointerEvents(t)}get#Fh(){return 0!==this.#Ph.size?this.#Ph.values():this.#v.getEditors(this.pageIndex)}async enable(){this.#Th=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#Lh?.abort(),this.#Lh=null;const t=new Set;for(const e of this.#Fh)e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#v.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));const e=this.#Ah;if(e)for(const i of e.getEditableAnnotations()){if(i.hide(),this.#v.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.#Th=!1,this.#v._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#Eh=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#Dh&&!this.#Lh){this.#Lh=new AbortController;const t=this.#v.combinedSignal(this.#Lh);this.#Dh.div.addEventListener("pointerdown",t=>{const{clientX:e,clientY:i,timeStamp:n}=t;if(n-this.#Nh>500)return void(this.#Nh=n);this.#Nh=-1;const{classList:s}=this.div;s.toggle("getElements",!0);const a=document.elementsFromPoint(e,i);if(s.toggle("getElements",!1),!this.div.contains(a[0]))return;let r;const o=new RegExp(`^${F}[0-9]+$`);for(const t of a)if(o.test(t.id)){r=t.id;break}if(!r)return;const l=this.#Ph.get(r);null===l?.annotationElementId&&(Wt(t),l.dblclick(t))},{signal:t,capture:!0})}const e=this.#Ah,i=[];if(e){const t=new Map,n=new Map;for(const e of this.#Fh)e.disableEditing(),e.annotationElementId?null===e.serialize()?(n.set(e.annotationElementId,e),this.getEditableAnnotation(e.annotationElementId)?.show(),e.remove()):t.set(e.annotationElementId,e):i.push(e);for(const i of e.getEditableAnnotations()){const{id:e}=i.data;if(this.#v.isDeletedAnnotationElement(e)){i.updateEdited({deleted:!0});continue}let s=n.get(e);s?(s.resetAnnotationElement(i),s.show(!1),i.show()):(s=t.get(e),s&&(this.#v.addChangedExistingAnnotation(s),s.renderAnnotationElement(i)&&s.show(!1)),i.show())}}this.#Rh(),this.isEmpty&&(this.div.hidden=!0);const{classList:n}=this.div;for(const e of t.#Q.values())n.remove(`${e._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),e?.updateFakeAnnotations(i),this.#Eh=!1}getEditableAnnotation(t){return this.#Ah?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#v.getActive()!==t&&this.#v.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#Dh?.div&&!this.#Ih){this.#Ih=new AbortController;const t=this.#v.combinedSignal(this.#Ih);this.#Dh.div.addEventListener("pointerdown",this.#Oh.bind(this),{signal:t}),this.#Dh.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#Dh?.div&&this.#Ih&&(this.#Ih.abort(),this.#Ih=null,this.#Dh.div.classList.remove("highlighting"))}#Oh(t){this.#v.unselectAll();const{target:e}=t;if(e===this.#Dh.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&this.#Dh.div.contains(e)){const{isMac:e}=St.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#v.showAllEditors("highlight",!0,!0),this.#Dh.div.classList.add("free"),this.toggleDrawing(),Ks.startHighlighting(this,"ltr"===this.#v.direction,{target:this.#Dh.div,x:t.x,y:t.y}),this.#Dh.div.addEventListener("pointerup",()=>{this.#Dh.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#v._signal}),t.preventDefault()}}enableClick(){if(this.#Ch)return;this.#Ch=new AbortController;const t=this.#v.combinedSignal(this.#Ch);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.#Ch?.abort(),this.#Ch=null}attach(t){this.#Ph.set(t.id,t);const{annotationElementId:e}=t;e&&this.#v.isDeletedAnnotationElement(e)&&this.#v.removeDeletedAnnotationElement(t)}detach(t){this.#Ph.delete(t.id),this.#yh?.removePointerInTextLayer(t.contentDiv),!this.#Eh&&t.annotationElementId&&this.#v.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#v.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#v.addDeletedAnnotationElement(t),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.#v.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#Th),this.#v.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#Sh&&(t._focusEventsAllowed=!1,this.#Sh=setTimeout(()=>{this.#Sh=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#v._signal}),e.focus())},0)),t._structTreeParentId=this.#yh?.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})}getEditorByUID(t){for(const e of this.#Ph.values())if(e.uid===t)return e;return null}get#Bh(){return t.#Q.get(this.#v.getMode())}combinedSignal(t){return this.#v.combinedSignal(t)}#jh(t){const e=this.#Bh;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#Bh?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#v.updateMode(t.mode);const{offsetX:i,offsetY:n}=this.#Uh(),s=this.#v.getId(),a=this.#jh({parent:this,id:s,x:i,y:n,uiManager:this.#v,isCentered:!0,...e});a&&this.add(a)}async deserialize(e){return await(t.#Q.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#v))||null}createAndAddNewEditor(t,e,i={}){const n=this.#v.getId(),s=this.#jh({parent:this,id:n,x:t.offsetX,y:t.offsetY,uiManager:this.#v,isCentered:e,...i});return s&&this.add(s),s}get boundingClientRect(){return this.div.getBoundingClientRect()}#Uh(){const{x:t,y:e,width:i,height:n}=this.boundingClientRect,s=Math.max(0,t),a=Math.max(0,e),r=(s+Math.min(window.innerWidth,t+i))/2-t,o=(a+Math.min(window.innerHeight,e+n))/2-e,[l,h]=this.viewport.rotation%180==0?[r,o]:[o,r];return{offsetX:l,offsetY:h}}addNewEditor(t={}){this.createAndAddNewEditor(this.#Uh(),!0,t)}setSelected(t){this.#v.setSelected(t)}toggleSelected(t){this.#v.toggleSelected(t)}unselect(t){this.#v.unselect(t)}pointerup(t){const{isMac:e}=St.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(!this.#_h)return;if(this.#_h=!1,this.#Bh?.isDrawer&&this.#Bh.supportMultipleDrawings)return;if(!this.#xh)return void(this.#xh=!0);const i=this.#v.getMode();i!==O.STAMP&&i!==O.POPUP&&i!==O.SIGNATURE?this.createAndAddNewEditor(t,!1):this.#v.unselectAll()}pointerdown(t){if(this.#v.getMode()===O.HIGHLIGHT&&this.enableTextSelection(),this.#_h)return void(this.#_h=!1);const{isMac:e}=St.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#_h=!0,this.#Bh?.isDrawer)return void this.startDrawingSession(t);const i=this.#v.getActive();this.#xh=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#Mh)return void this.#Bh.startDrawing(this,this.#v,!1,t);this.#v.setCurrentDrawingSession(this),this.#Mh=new AbortController;const e=this.#v.combinedSignal(this.#Mh);this.div.addEventListener("blur",({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#kh=null,this.commitOrRemove())},{signal:e}),this.#Bh.startDrawing(this,this.#v,!1,t)}pause(t){if(t){const{activeElement:t}=document;return void(this.div.contains(t)&&(this.#kh=t))}this.#kh&&setTimeout(()=>{this.#kh?.focus(),this.#kh=null},0)}endDrawingSession(t=!1){return this.#Mh?(this.#v.setCurrentDrawingSession(null),this.#Mh.abort(),this.#Mh=null,this.#kh=null,this.#Bh.endDrawing(t)):null}findNewParent(t,e,i){const n=this.#v.findParent(e,i);return null!==n&&n!==this&&(n.changeParent(t),!0)}commitOrRemove(){return!!this.#Mh&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#Mh&&this.#Bh.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#v.getActive()?.parent===this&&(this.#v.commitOrRemove(),this.#v.setActiveEditor(null)),this.#Sh&&(clearTimeout(this.#Sh),this.#Sh=null);for(const t of this.#Ph.values())this.#yh?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#Ph.clear(),this.#v.removeLayer(this)}#Rh(){for(const t of this.#Ph.values())t.isEmpty()&&t.remove()}async render({viewport:t}){this.viewport=t,Qt(this.div,t);for(const t of this.#v.getEditors(this.pageIndex))this.add(t),t.rebuild();await this.#v.findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){this.#v.commitOrRemove(),this.#Rh();const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,Qt(this.div,{rotation:i}),e!==i)for(const t of this.#Ph.values())t.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#v.viewParameters.realScale}};function la(t,e){return t===e?0:t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function ha(t){return t?t.nodeType===Node.ELEMENT_NODE?t.closest(".textLayer"):t.parentElement?.closest(".textLayer")||null:null}function da(t,e,i,n){if(t===i)return e<=n;const s=t.compareDocumentPosition(i);return!!(s&Node.DOCUMENT_POSITION_FOLLOWING)||!(s&Node.DOCUMENT_POSITION_PRECEDING)&&null}function ca(t,e,i){if(t.nodeType!==Node.ELEMENT_NODE||!t.classList.contains("textLayer")||e!==t.childNodes.length)return{container:t,offset:e};let n=t.lastChild;return n?.nodeType===Node.ELEMENT_NODE&&n.classList.contains("endOfContent")&&(n=n.previousSibling),n&&i.contains(n)?n.nodeType===Node.TEXT_NODE?{container:n,offset:n.textContent.length}:{container:n,offset:n.childNodes.length}:null}let ua=class t{#xr=null;#Hh=new Map;#Dh=null;#it=null;#xt=null;#Vh=null;#zh=new Map;static#_=0;static#$h=0;static#Wh=null;static#Gh=new Set;static#Xh=!1;static#Kh=new Set;static#qh=new WeakMap;constructor({filterFactory:e=null,pageColors:i=null,pageIndex:n,textLayer:s=null}){if(this.pageIndex=n,this.#it=e,this.#xt=i,s){const e=t.#qh.get(s);if(e?.selectionDiv&&(e.selectionDiv.remove(),t.#Gh.delete(e.selectionDiv)),t.#qh.set(s,{drawLayer:this}),t.#Kh.add(s),this.#Dh=s,this.#Vh=new MutationObserver(e=>{if(this.#xr&&this.#Dh?.isConnected&&t.#Yh())for(const{addedNodes:i}of e)for(const e of i)if(e.nodeType===Node.ELEMENT_NODE&&e.classList.contains("endOfContent"))return void t.#Bt()}),this.#Vh.observe(s,{childList:!0}),null===t.#Wh){t.#Wh=new AbortController;const{signal:e}=t.#Wh;document.addEventListener("selectionchange",t.#Bt.bind(t),{signal:e}),document.addEventListener("pointerdown",()=>{t.#Xh=!0},{signal:e}),document.addEventListener("pointerup",()=>{t.#Xh=!1},{signal:e}),window.addEventListener("blur",()=>{t.#Xh=!1},{signal:e})}}}setParent(e){if(!this.#xr)return this.#xr=e,void(this.#Dh?.isConnected&&t.#Yh()&&t.#Bt());if(this.#xr!==e){if(this.#Hh.size>0)for(const t of this.#Hh.values())t.remove(),e.append(t);this.#xr=e}}static#Qh(t){const e=this.#qh.get(t);e?.selectionDiv&&(e.selectionDiv.remove(),this.#Gh.delete(e.selectionDiv),e.selectionDiv=null,e.path=null)}static#Yh(){const t=document.getSelection();return!!t&&!t.isCollapsed}static#Zh(){return[...this.#Kh].filter(t=>t.isConnected).sort(la)}static#Bt(){const e=document.getSelection();if(!e||e.isCollapsed){for(const t of this.#Gh)t.remove();return void this.#Gh.clear()}const i=new WeakMap,n=this.#Zh(),s=[];for(let t=0,i=e.rangeCount;t<i;t++){const i=e.getRangeAt(t);if(i.collapsed)continue;let{startContainer:a,startOffset:r,endContainer:o,endOffset:l}=i,h=ha(a),d=ha(o);const c=null===h,u=null===d;if(this.#Xh&&c!==u)return;if(1===e.rangeCount){const{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:s}=e,c=ha(t),u=ha(n),p=da(t,i,n,s);c&&u&&null!==p&&(p?(a=t,r=i,h=c,o=n,l=s,d=u):(a=n,r=s,h=u,o=t,l=i,d=c))}const p=n.filter(t=>i.intersectsNode(t));if(0===p.length)continue;let g=!1;if(h||(h=p[0],a=h,r=0,g=!0),d||(d=p.at(-1),o=d,l=d.childNodes.length,g=!0),o.nodeType===Node.ELEMENT_NODE)if(o.classList.contains("endOfContent")){const t=o.previousSibling;if(!t)continue;o=t,l=t.nodeType===Node.TEXT_NODE?t.textContent.length:t.childNodes.length}else if(o.classList.contains("textLayer")&&o.childNodes.length===l){const t=ca(o,l,d);if(!t)continue;o=t.container,l=t.offset}if(a.nodeType===Node.ELEMENT_NODE){const t=ca(a,r,h);if(!t)continue;a=t.container,r=t.offset}if(h!==d||g||!p.includes(h))for(const t of p){const e=t.firstChild;if(!e)continue;const i=document.createRange();if(t===h?i.setStart(a,r):i.setStartBefore(e),t===d)i.setEnd(o,l);else{const e=t.lastChild;if(!e)continue;if(e.nodeType===Node.ELEMENT_NODE&&e.classList.contains("endOfContent")){const t=e.previousSibling;if(!t)continue;i.setEndAfter(t)}else i.setEndAfter(e)}i.collapsed||s.push([i,t])}else s.push([i,h])}const a=new Set(s.map(t=>t[1]));for(const t of this.#Kh)a.has(t)||this.#Qh(t);for(const[e,n]of s){const s=t.#qh.get(n);if(!s)continue;let a=i.get(n);if(!a){const t=n.getBoundingClientRect();a=(e,i,n,s)=>({x:(e-t.x)/t.width,y:(i-t.y)/t.height,width:n/t.width,height:s/t.height}),i.set(n,a)}const r=[];for(let{x:t,y:i,width:n,height:s}of e.getClientRects())0!==n&&0!==s&&(({x:t,y:i,width:n,height:s}=a(t,i,n,s)),1===n&&1===s||r.push(`M${t} ${i} h${n} v${s} h-${n} Z`));if(0===r.length)continue;const o=s.drawLayer;let l=s.selectionDiv,h=s.path;if(!l){const e="clip_selection_"+t.#$h++;l=document.createElement("div"),l.className="selection",l.style.clipPath=`url(#${e})`;const i=o.#it?.createSelectionStyle(o.#xt);if(i)for(const[t,e]of Object.entries(i))l.style.setProperty(t,e);const n=t._svgFactory.create(1,1,!0);n.setAttribute("aria-hidden","true"),n.setAttribute("width","100%"),n.setAttribute("height","100%");const a=t._svgFactory.createElement("clipPath");a.setAttribute("id",e),a.setAttribute("clipPathUnits","objectBoundingBox"),h=t._svgFactory.createElement("path"),a.append(h),n.append(a),l.append(n),s.path=h,s.selectionDiv=l}!l.parentNode&&o.#xr&&(o.#xr.append(l),this.#Gh.add(l)),h.setAttribute("d",r.join(" "))}}static get _svgFactory(){return mt(this,"_svgFactory",new ls)}static#Jh(t,[e,i,n,s]){const{style:a}=t;a.top=100*i+"%",a.left=100*e+"%",a.width=100*n+"%",a.height=100*s+"%"}#td(){const e=t._svgFactory.create(1,1,!0);return this.#xr.append(e),e.setAttribute("aria-hidden","true"),e}#ed(e,i){const n=t._svgFactory.createElement("clipPath");e.append(n);const s=`clip_${i}`;n.setAttribute("id",s),n.setAttribute("clipPathUnits","objectBoundingBox");const a=t._svgFactory.createElement("use");return n.append(a),a.setAttribute("href",`#${i}`),a.classList.add("clip"),s}#id(t,e){for(const[i,n]of Object.entries(e))null===n?t.removeAttribute(i):t.setAttribute(i,n)}draw(e,i=!1,n=!1){const s=t.#_++,a=this.#td(),r=t._svgFactory.createElement("defs");a.append(r);const o=t._svgFactory.createElement("path");r.append(o);const l=`path_${s}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),i&&this.#zh.set(s,o);const h=n?this.#ed(r,l):null,d=t._svgFactory.createElement("use");return a.append(d),d.setAttribute("href",`#${l}`),this.updateProperties(a,e),this.#Hh.set(s,a),{id:s,clipPathId:`url(#${h})`}}drawOutline(e,i){const n=t.#_++,s=this.#td(),a=t._svgFactory.createElement("defs");s.append(a);const r=t._svgFactory.createElement("path");a.append(r);const o=`path_${n}`;let l;if(r.setAttribute("id",o),r.setAttribute("vector-effect","non-scaling-stroke"),i){const e=t._svgFactory.createElement("mask");a.append(e),l=`mask_${n}`,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 s=t._svgFactory.createElement("use");e.append(s),s.setAttribute("href",`#${o}`),s.setAttribute("stroke","none"),s.setAttribute("fill","black"),s.setAttribute("fill-rule","nonzero"),s.classList.add("mask")}const h=t._svgFactory.createElement("use");s.append(h),h.setAttribute("href",`#${o}`),l&&h.setAttribute("mask",`url(#${l})`);const d=h.cloneNode();return s.append(d),h.classList.add("mainOutline"),d.classList.add("secondaryOutline"),this.updateProperties(s,e),this.#Hh.set(n,s),n}finalizeDraw(t,e){this.#zh.delete(t),this.updateProperties(t,e)}updateProperties(e,i){if(!i)return;const{root:n,bbox:s,rootClass:a,path:r}=i,o="number"==typeof e?this.#Hh.get(e):e;if(o){if(n&&this.#id(o,n),s&&t.#Jh(o,s),a){const{classList:t}=o;for(const[e,i]of Object.entries(a))t.toggle(e,i)}if(r){const t=o.firstElementChild.firstElementChild;this.#id(t,r)}}}updateParent(t,e){if(e===this)return;const i=this.#Hh.get(t);i&&(e.#xr.append(i),this.#Hh.delete(t),e.#Hh.set(t,i))}remove(t){this.#zh.delete(t),null!==this.#xr&&(this.#Hh.get(t).remove(),this.#Hh.delete(t))}destroy(){this.#xr=null;for(const t of this.#Hh.values())t.remove();if(this.#Hh.clear(),this.#zh.clear(),this.#Vh?.disconnect(),this.#Vh=null,this.#Dh){const e=t.#qh.get(this.#Dh);e?.drawLayer===this&&(t.#Qh(this.#Dh),t.#qh.delete(this.#Dh),t.#Kh.delete(this.#Dh),0===t.#Kh.size&&(t.#Wh?.abort(),t.#Wh=null,t.#Xh=!1)),this.#Dh=null}}};function pa(t){return`${(100*t).toFixed(2)}%`}globalThis._pdfjsTestingUtils={HighlightOutliner:$s},globalThis.pdfjsLib={AbortException:At,AnnotationEditorLayer:oa,AnnotationEditorParamsType:B,AnnotationEditorType:O,AnnotationEditorUIManager:ve,AnnotationLayer:class t{#yh=null;#nd=null;#V=null;#sd=new Map;#ad=null;#rd=null;#yr=[];#od=!1;zIndex=0;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:n,page:s,viewport:a,structTreeLayer:r,commentManager:o,linkService:l,annotationStorage:h}){this.div=t,this.#yh=e,this.#nd=i,this.#ad=r||null,this.#rd=l||null,this.#V=h||new Me,this.page=s,this.viewport=a,this._annotationEditorUIManager=n,this._commentManager=o||null}hasEditableAnnotations(){return this.#sd.size>0}async render(t){const{annotations:e,optionalContentConfig:i}=t,n=this.div;Qt(n,this.viewport);const s=new Map,a=[],r={data:null,layer:n,linkService:this.#rd,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new ls,annotationStorage:this.#V,enableComment:!0===t.enableComment,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===G.POPUP;if(e){const e=s.get(t.id);if(!e)continue;if(!this._commentManager){a.push(t);continue}r.elements=e}else if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1])continue;r.data=t;const n=cs.create(r);if(!n.isRenderable)continue;e||(this.#yr.push(n),t.popupRef&&s.getOrInsertComputed(t.popupRef,Mt).push(n));const o=n.render();t.hidden&&(o.style.visibility="hidden"),n.updateOC(i),n._isEditable&&(this.#sd.set(n.data.id,n),this._annotationEditorUIManager?.renderAnnotationElement(n))}await this.#ld();for(const t of a){const e=r.elements=s.get(t.id);r.data=t;const i=cs.create(r);if(!i.isRenderable)continue;const n=i.render();i.contentElement.id=`${R}${t.id}`,t.hidden&&(n.style.visibility="hidden"),e.at(-1).container.after(n)}this.#hd()}async#ld(){if(0===this.#yr.length)return;this.div.replaceChildren();const t=[];if(!this.#od){this.#od=!0;for(const{contentElement:e,data:{id:i}}of this.#yr){const n=e.id=`${R}${i}`;t.push(this.#ad?.getAriaAttributes(n).then(t=>{if(t)for(const[i,n]of t)e.setAttribute(i,n)}))}}this.#yr.sort(({data:{rect:[t,e,i,n]}},{data:{rect:[s,a,r,o]}})=>{if(t===i&&e===n)return 1;if(s===r&&a===o)return-1;const l=(e+n)/2,h=(a+o)/2;if(l>=o&&h<=e)return-1;if(h>=n&&l<=a)return 1;return(t+i)/2-(s+r)/2});const e=document.createDocumentFragment();for(const t of this.#yr)e.append(t.container),this._commentManager?(t.extraPopupElement?.popup||t.popup)?.renderCommentButton():t.extraPopupElement&&e.append(t.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),this.#yh)for(const t of this.#yr)this.#yh.addPointerInTextLayer(t.contentElement,!1)}async addLinkAnnotations(e){const i={data:null,layer:this.div,linkService:this.#rd,svgFactory:new ls,parent:this};for(const n of e){n.borderStyle||=t._defaultBorderStyle,i.data=n;const e=cs.create(i);e.isRenderable&&(e.render(),e.contentElement.id=`${R}${n.id}`,this.#yr.push(e))}await this.#ld()}update({viewport:t,optionalContentConfig:e}){const i=this.div;this.viewport=t,Qt(i,{rotation:t.rotation});for(const t of this.#yr)t.updateOC(e);this.#hd(),i.hidden=!1}#hd(){if(!this.#nd)return;const t=this.div;for(const[e,i]of this.#nd){const n=t.querySelector(`[data-annotation-id="${e}"]`);if(!n)continue;i.className="annotationContent";const{firstChild:s}=n;s?"CANVAS"===s.nodeName?s.replaceWith(i):s.classList.contains("annotationContent")?s.after(i):s.before(i):n.append(i);const a=this.#sd.get(e);a&&(a._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,n.id,i),a._hasNoCanvas=!1):a.canvas=i)}this.#nd.clear()}getEditableAnnotations(){return this.#sd.values()}getEditableAnnotation(t){return this.#sd.get(t)}addFakeAnnotation(t){const{div:e}=this,{id:i,rotation:n}=t,s=new ps({data:{id:i,rect:t.getPDFRect(),rotation:n},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:this.#rd,annotationStorage:this.#V});return s.render(),s.contentElement.id=`${R}${i}`,s.createOrUpdatePopup(),this.#yr.push(s),s}removeAnnotation(t){const e=this.#yr.findIndex(e=>e.data.id===t);if(e<0)return;const[i]=this.#yr.splice(e,1);this.#yh?.removePointerInTextLayer(i.contentElement)}updateFakeAnnotations(t){if(0!==t.length){for(const e of t)e.updateFakeAnnotationElement(this);this.#ld()}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return mt(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:X,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}},AnnotationMode:N,AnnotationType:G,applyOpacity:function(t,e){const i=255*(1-(e=It(e??1,0,1)));return t.map(t=>Math.round(t*e+i))},build:"241dbabbf",ColorPicker:is,createValidAbsoluteUrl:ut,CSSConstants:class{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);const{color:i}=window.getComputedStyle(t);return t.remove(),mt(this,"commentForegroundColor",Kt(i))}},DOMSVGFactory:ls,DrawLayer:ua,FeatureTest:St,fetchData:Ot,findContrastColor:function(t,e){const i=t[0]+256*t[1]+65536*t[2]+16777216*e[0]+4294967296*e[1]+1099511627776*e[2];let n=ae.get(i);if(n)return n;const s=new Float32Array(9),a=s.subarray(0,3),r=s.subarray(3,6);ee(t,r);const o=s.subarray(6,9);ee(e,o);const l=o[2]<.5,h=l?12:4.5;if(r[2]=l?Math.sqrt(r[2]):1-Math.sqrt(1-r[2]),se(r,o,a)<h){let t,e;l?(t=r[2],e=1):(t=0,e=r[2]);const i=.005;for(;e-t>i;){const i=r[2]=(t+e)/2;l===se(r,o,a)<h?t=i:e=i}r[2]=l?e:t}return ie(r,a),n=Pt.makeHexColor(Math.round(255*a[0]),Math.round(255*a[1]),Math.round(255*a[2])),ae.set(i,n),n},getDocument:Xn,getFilenameFromUrl:function(t){return[t]=t.split(/[#?]/,1),gt(t)},getPdfFilenameFromUrl:Ht,getRGB:Kt,getRGBA:Xt,getUuid:Tt,GlobalWorkerOptions:On,ImageKind:W,InvalidPDFException:wt,isDataScheme:jt,isPdfFile:Ut,isValidExplicitDest:li,makeArr:Mt,makeMap:kt,makeObj:Dt,MathClamp:It,noContextMenu:$t,normalizeUnicode:function(t){return _t||(_t=/([\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,Et=new Map([["ſt","ſt"]])),t.replaceAll(_t,(t,e,i)=>e?e.normalize("NFKC"):Et.get(i))},OPS:J,OutputScale:Zt,PasswordResponses:{NEED_PASSWORD:1,INCORRECT_PASSWORD:2},PDFDataRangeTransport:qn,PDFDateString:Gt,PDFWorker:Zn,PermissionFlag:{PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},PixelsPerInch:Ft,RenderingCancelledException:Bt,renderRichText:re,ResponseException:yt,setLayerDimensions:Qt,shadow:mt,SignatureExtractor:ia,stopEvent:Wt,SupportedImageMimeTypes:Jt,TextLayer:Gn,TextLayerImages:class t{#dd=[];#cd=new Map;#ud=null;#pd=0;#Xs=0;#Gs=0;static#gd=null;constructor(t,e,i,n){this.#pd=t,this.#dd=e,this.#Xs=i.rawDims.pageWidth,this.#Gs=i.rawDims.pageHeight,this.#ud=n}render(){const e=document.createElement("div");e.className="textLayerImages";for(let t=0;t<this.#dd.length;t+=6){const i=this.#md(this.#dd.subarray(t,t+6));i&&e.append(i)}return e.addEventListener("contextmenu",e=>{if(!(e.target instanceof HTMLCanvasElement))return;const i=e.target,n=this.#cd.get(i);if(!n)return;const s=t.#gd?.deref();if(s===i)return;s&&(s.width=0,s.height=0),t.#gd=new WeakRef(i);const{inverseTransform:a,x1:r,y1:o,width:l,height:h}=n,d=this.#ud(),c=Math.ceil(r*d.width),u=Math.ceil(o*d.height),p=Math.floor((r+l/this.#Xs)*d.width),g=Math.floor((o+h/this.#Gs)*d.height);i.width=p-c,i.height=g-u;const m=i.getContext("2d");m.setTransform(...a),m.translate(-c,-u),m.drawImage(d,0,0)}),e}#md([t,e,i,n,s,a]){const r=Math.hypot((s-t)*this.#Xs,(a-e)*this.#Gs),o=Math.hypot((i-t)*this.#Xs,(n-e)*this.#Gs);if(r<this.#pd||o<this.#pd)return null;const l=[(s-t)*this.#Xs/r,(a-e)*this.#Gs/r,(i-t)*this.#Xs/o,(n-e)*this.#Gs/o,0,0],h=Pt.inverseTransform(l),d=document.createElement("canvas");return d.className="textLayerImagePlaceholder",d.width=0,d.height=0,Object.assign(d.style,{opacity:0,position:"absolute",left:pa(t),top:pa(e),width:pa(r/this.#Xs),height:pa(o/this.#Gs),transformOrigin:"0% 0%",transform:`matrix(${l.join(",")})`}),this.#cd.set(d,{inverseTransform:h,width:r,height:o,x1:t,y1:e}),d}},TouchManager:xe,updateUrlHash:pt,Util:Pt,VerbosityLevel:Z,version:"6.0.227",XfaLayer:Rt};
33
33
  /**
34
34
  * @licstart The following is the entire license notice for the
35
35
  * JavaScript code in this page
@@ -51,4 +51,4 @@ const y=!("object"!=typeof process||process+""!="[object process]"||process.vers
51
51
  * @licend The above is the entire license notice for the
52
52
  * JavaScript code in this page
53
53
  */
54
- const{AbortException:bn,AnnotationEditorLayer:vn,AnnotationEditorParamsType:wn,AnnotationEditorType:yn,AnnotationEditorUIManager:An,AnnotationLayer:_n,AnnotationMode:xn,AnnotationType:Sn,build:Cn,ColorPicker:En,createValidAbsoluteUrl:Pn,DOMSVGFactory:Tn,DrawLayer:Mn,FeatureTest:In,fetchData:kn,getDocument:Ln,getFilenameFromUrl:Dn,getPdfFilenameFromUrl:Rn,getUuid:Nn,getXfaPageViewport:Fn,GlobalWorkerOptions:On,ImageKind:Bn,InvalidPDFException:jn,isDataScheme:Vn,isPdfFile:Hn,isValidExplicitDest:Un,MathClamp:zn,noContextMenu:$n,normalizeUnicode:Wn,OPS:Gn,OutputScale:qn,PasswordResponses:Xn,PDFDataRangeTransport:Kn,PDFDateString:Yn,PDFWorker:Qn,PermissionFlag:Zn,PixelsPerInch:Jn,RenderingCancelledException:ta,ResponseException:ea,setLayerDimensions:ia,shadow:sa,SignatureExtractor:na,stopEvent:aa,SupportedImageMimeTypes:ra,TextLayer:oa,TouchManager:la,updateUrlHash:ha,Util:da,VerbosityLevel:ca,version:ua,XfaLayer:pa}=globalThis.pdfjsLib,ga={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},fa=0,ma=1,ba=2,va=3,wa=0,ya=1,Aa=2,_a={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},xa={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};function Sa(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,a=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,a+=s.offsetLeft,s=s.offsetParent,!s)return;e&&(void 0!==e.top&&(n+=e.top),void 0!==e.left&&(a+=e.left,s.scrollLeft=a)),s.scrollTop=n}function Ca(t){const e=new Map;for(const[i,s]of new URLSearchParams(t))e.set(i.toLowerCase(),s);return e}const Ea=/[\x00-\x1F]/g;function Pa(t,e=!1){return Ea.test(t)?e?t.replaceAll(Ea,(t=>"\0"===t?"":" ")):t.replaceAll("\0",""):t}function Ta(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 Ma(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,a=1,r=1,o=1;for(;;){const t=n+r,e=a+o;if(e>8)break;i<=t/e?(r=t,o=e):(n=t,a=e)}return s=i-n/a<r/o-i?i===t?[n,a]:[a,n]:i===t?[r,o]:[o,r],s}function Ia(t,e){return t-t%e}function ka(t){return Number.isInteger(t)&&t%90==0}function La(t){return t.width<=t.height}new Promise((function(t){window.requestAnimationFrame(t)}));const Da=document.documentElement.style;const Ra=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}(),Na=0,Fa=1,Oa=2,Ba=3,ja=4,Va=5,Ha=6,Ua=7;function za(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)?Na:function(t){return t>=97&&t<=122||t>=65&&t<=90}(t)||function(t){return t>=48&&t<=57}(t)||95===t?Fa:Oa:function(t){return 3584==(65408&t)}(t)?Ua:160===t?Na:Fa:function(t){return t>=13312&&t<=40959||t>=63744&&t<=64255}(t)?Ba:function(t){return t>=12448&&t<=12543}(t)?ja:function(t){return t>=12352&&t<=12447}(t)?Va:function(t){return t>=65376&&t<=65439}(t)?Ha:Fa}let $a;const Wa={FOUND:0,NOT_FOUND:1,WRAPPED:2,PENDING:3},Ga={"‐":"-","‘":"'","’":"'","‚":"'","‛":"'","“":'"',"”":'"',"„":'"',"‟":'"',"¼":"1/4","½":"1/2","¾":"3/4"},qa=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 Xa;const Ka=/\p{M}+/gu,Ya=/([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu,Qa=/([^\p{M}])\p{M}*$/u,Za=/^\p{M}*([^\p{M}])/u,Ja=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,tr=new Map,er=new Map;let ir=null,sr=null;function nr(t){const e=[];let i;for(;null!==(i=Ja.exec(t));){let{index:t}=i;for(const s of i[0]){let i=tr.get(s);i||(i=s.normalize("NFD").length,tr.set(s,i)),e.push([i,t++])}}const s=e.length>0;let n;if(!s&&ir)n=ir;else if(s&&sr)n=sr;else{const t=Object.keys(Ga).join(""),e=($a||=" ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩",$a);n=new RegExp([`[${t}]`,`[${e}]`,`${"(?:゙|゚)"}\\n`,"\\p{M}+(?:-\\n)?",`${"\\p{Ll}-\\n(?=\\p{Ll})|\\p{Lu}-\\n(?=\\p{L})"}`,"\\S-\\n",`${"(?:\\p{Ideographic}|[぀-ヿ])"}\\n`,"\\n",s?"[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]":"\\u0000"].map((t=>`(${t})`)).join("|"),"gum"),s?sr=n:ir=n}const a=[];for(;null!==(i=Ka.exec(t));)a.push([i[0].length,i.index]);let r=t.normalize("NFD");const o=[0,0];let l=0,h=0,d=0,c=0,u=0,p=!1;r=r.replace(n,((t,i,s,n,r,g,f,m,b,v,w)=>{if(w-=c,i){const t=Ga[i],e=t.length;for(let t=1;t<e;t++)o.push(w-d+t,d-t);return d-=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++)o.push(w-d+t,d-t);return d-=e-1,t}if(n)return p=!0,w+u===a[l]?.[1]?++l:(o.push(w-1-d+1,d-1),d-=1,c+=1),o.push(w-d+1,d),c+=1,u+=1,n.charAt(0);if(r){const t=r.endsWith("\n"),e=t?r.length-2:r.length;p=!0;let i=e;w+u===a[l]?.[1]&&(i-=a[l][0],++l);for(let t=1;t<=i;t++)o.push(w-1-d+t,d-t);return d-=i,c+=i,t?(w+=e-1,o.push(w-d+1,1+d),d+=1,c+=1,u+=1,r.slice(0,e)):r}if(g){const t=g.length-2;return o.push(w-d+t,1+d),d+=1,c+=1,u+=1,g.slice(0,-2)}if(f)return c+=1,u+=1,f.slice(0,-1);if(m){const t=m.length-1;return o.push(w-d+t,d),c+=1,u+=1,m.slice(0,-1)}if(b)return o.push(w-d+1,d-1),d-=1,c+=1,u+=1," ";if(w+u===e[h]?.[1]){const t=e[h][0]-1;++h;for(let e=1;e<=t;e++)o.push(w-(d-e),d-e);d-=t,c+=t}return v})),o.push(r.length,d);const g=new Uint32Array(o.length>>1),f=new Int32Array(o.length>>1);for(let t=0,e=o.length;t<e;t+=2)g[t>>1]=o[t],f[t>>1]=o[t+1];return[r,[g,f],p]}function ar(t,e,i){if(!t)return[e,i];const[s,n]=t,a=e,r=e+i-1;let o=Ta(s,(t=>t>=a));s[o]>a&&--o;let l=Ta(s,(t=>t>=r),o);s[l]>r&&--l;const h=a+n[o];return[h,r+n[l]+1-h]}class rr{#Go=null;#qo=!0;#Xo=0;constructor({linkService:t,eventBus:e,updateMatchesCountOnProgress:i=!0}){this._linkService=t,this._eventBus=e,this.#qo=i,this.onIsPageVisible=null,this.#Ko(),e._on("find",this.#Yo.bind(this)),e._on("findbarclose",this.#Qo.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.#Go}setDocument(t){this._pdfDocument&&this.#Ko(),t&&(this._pdfDocument=t,this._firstPageCapability.resolve())}#Yo(t){if(!t)return;const e=this._pdfDocument,{type:i}=t;(null===this.#Go||this.#Zo(t))&&(this._dirtyMatch=!0),this.#Go=t,"highlightallchange"!==i&&this.#Jo(Wa.PENDING),this._firstPageCapability.promise.then((()=>{if(!this._pdfDocument||e&&this._pdfDocument!==e)return;this.#Rn();const t=!this._highlightMatches,s=!!this._findTimeout;this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),i?this._dirtyMatch?this.#tl():"again"===i?(this.#tl(),t&&this.#Go.highlightAll&&this.#el()):"highlightallchange"===i?(s?this.#tl():this._highlightMatches=!0,this.#el()):this.#tl():this._findTimeout=setTimeout((()=>{this.#tl(),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;Sa(t,{top:-50,left:e+-400},!0)}#Ko(){this._highlightMatches=!1,this._scrollMatches=!1,this._pdfDocument=null,this._pageMatches=[],this._pageMatchesLength=[],this.#Xo=0,this.#Go=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#il(){const{query:t}=this.#Go;return"string"==typeof t?(t!==this._rawQuery&&(this._rawQuery=t,[this._normalizedQuery]=nr(t)),this._normalizedQuery):(t||[]).filter((t=>!!t)).map((t=>nr(t)[0]))}#Zo(t){const e=t.query,i=this.#Go.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}#sl(t,e,i){let s=t.slice(0,e).match(Qa);if(s){const i=t.charCodeAt(e),n=s[1].charCodeAt(0);if(za(i)===za(n))return!1}if(s=t.slice(e+i).match(Za),s){const n=t.charCodeAt(e+i-1),a=s[1].charCodeAt(0);if(za(n)===za(a))return!1}return!0}#nl(t,e){const{matchDiacritics:i}=this.#Go;let s=!1;const n="[ ]*";return(t=t.replaceAll(Ya,((t,n,a,r,o,l)=>n?`[ ]*\\${n}[ ]*`:a?`[ ]*${a}[ ]*`:r?"[ ]+":i?o||l:o?qa.has(o.charCodeAt(0))?o:"":e?(s=!0,`${l}\\p{M}*`):l))).endsWith(n)&&(t=t.slice(0,t.length-4)),i&&e&&(Xa||=String.fromCharCode(...qa),s=!0,t=`${t}(?=[${Xa}]|[^\\p{M}]|$)`),[s,t]}#al(t){if(!this.#Go)return;const e=this.#il;if(0===e.length)return;const i=this._pageContents[t],s=this.match(e,i,t),n=this._pageMatches[t]=[],a=this._pageMatchesLength[t]=[],r=this._pageDiffs[t];s?.forEach((({index:t,length:e})=>{const[i,s]=ar(r,t,e);s&&(n.push(i),a.push(s))})),this.#Go.highlightAll&&this.#rl(t),this._resumePageIdx===t&&(this._resumePageIdx=null,this.#ol());const o=n.length;this._matchesCountTotal+=o,this.#qo?o>0&&this.#ll():++this.#Xo===this._linkService.pagesCount&&this.#ll()}match(t,e,i){const s=this._hasDiacritics[i];let n=!1;if("string"==typeof t?[n,t]=this.#nl(t,s):t=t.sort().reverse().map((t=>{const[e,i]=this.#nl(t,s);return n||=e,`(${i})`})).join("|"),!t)return;const{caseSensitive:a,entireWord:r}=this.#Go;t=new RegExp(t,`g${n?"u":""}${a?"":"i"}`);const o=[];let l;for(;null!==(l=t.exec(e));)r&&!this.#sl(e,l.index,l[0].length)||o.push({index:l.index,length:l[0].length});return o}#Rn(){if(this._extractTextPromises.length>0)return;let t=Promise.resolve();const e={disableNormalization:!0},i=this._pdfDocument;for(let s=0,n=this._linkService.pagesCount;s<n;s++){const{promise:n,resolve:a}=Promise.withResolvers();this._extractTextPromises[s]=n,t=t.then((async()=>{i===this._pdfDocument?await i.getPage(s+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[s],this._pageDiffs[s],this._hasDiacritics[s]]=nr(e.join("")),a()}),(t=>{console.error(`Unable to get text content for page ${s+1}`,t),this._pageContents[s]="",this._pageDiffs[s]=null,this._hasDiacritics[s]=!1,a()})):a()}))}}#rl(t){this._scrollMatches&&this._selected.pageIdx===t&&(this._linkService.page=t+1),this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:t})}#el(){this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:-1})}#tl(){const t=this.#Go.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.#Xo=0,this._matchesCountTotal=0,this.#el();for(let t=0;t<i;t++)this._pendingFindMatches.has(t)||(this._pendingFindMatches.add(t),this._extractTextPromises[t].then((()=>{this._pendingFindMatches.delete(t),this.#al(t)})))}if(0===this.#il.length)return void this.#Jo(Wa.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.#hl(!0);this.#dl(t)}this.#ol()}#cl(t){const e=this._offset,i=t.length,s=this.#Go.findPrevious;return i?(e.matchIdx=s?i-1:0,this.#hl(!0),!0):(this.#dl(s),!!(e.wrapped&&(e.matchIdx=null,this._pagesToSearch<0))&&(this.#hl(!1),!0))}#ol(){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.#cl(t))}#dl(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)}#hl(t=!1){let e=Wa.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?Wa.WRAPPED:Wa.FOUND,-1!==t&&t!==this._selected.pageIdx&&this.#rl(t)}this.#Jo(e,this.#Go.findPrevious),-1!==this._selected.pageIdx&&(this._scrollMatches=!0,this.#rl(this._selected.pageIdx))}#Qo(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.#Jo(Wa.FOUND),this._highlightMatches=!1,this.#el())}))}#ul(){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}}#ll(){this._eventBus.dispatch("updatefindmatchescount",{source:this,matchesCount:this.#ul()})}#Jo(t,e=!1){(this.#qo||this.#Xo===this._linkService.pagesCount&&t!==Wa.PENDING)&&this._eventBus.dispatch("updatefindcontrolstate",{source:this,state:t,previous:e,entireWord:this.#Go?.entireWord??null,matchesCount:this.#ul(),rawQuery:this.#Go?.query??null})}}const or={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?or.BLANK:this.externalLinkTarget,n=this.externalLinkRel;this.externalLinkEnabled?t.href=t.title=e:(t.href="",t.title=`Disabled: ${e}`,t.onclick=()=>!1);let a="";switch(s){case or.NONE:break;case or.SELF:a="_self";break;case or.BLANK:a="_blank";break;case or.PARENT:a="_parent";break;case or.TOP:a="_top"}t.target=a,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=Ca(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||Un(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))}}class hr extends lr{setDocument(t,e=null){}}class dr{#pl=null;#gl=!1;#fl=null;#ml=null;#bl=!1;constructor({pdfPage:t,linkService:e,downloadManager:i,annotationStorage:s=null,imageResourcesPath:n="",renderForms:a=!0,enableScripting:r=!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=a,this.annotationStorage=s,this.enableScripting=r,this._hasJSActionsPromise=o||Promise.resolve(!1),this._fieldObjectsPromise=l||Promise.resolve(null),this._annotationCanvasMap=h,this._accessibilityManager=d,this._annotationEditorUIManager=c,this.#fl=u,this.annotationLayer=null,this.div=null,this._cancelled=!1,this._eventBus=e.eventBus}async render({viewport:t,intent:e="display",structTreeLayer:i=null}){if(this.div){if(this._cancelled||!this.annotationLayer)return;return void this.annotationLayer.update({viewport:t.clone({dontFlip:!0})})}const[s,n,a]=await Promise.all([this.pdfPage.getAnnotations({intent:e}),this._hasJSActionsPromise,this._fieldObjectsPromise]);if(this._cancelled)return;const r=this.div=document.createElement("div");if(r.className="annotationLayer",this.#fl?.(r),0===s.length)return this.#pl=s,void this.hide(!0);this.#vl(t,i),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:a}),this.#pl=s,this.linkService.isInPresentationMode&&this.#wl(va),this.#ml||(this.#ml=new AbortController,this._eventBus?._on("presentationmodechanged",(t=>{this.#wl(t.state)}),{signal:this.#ml.signal}))}#vl(t,e){this.annotationLayer=new _n({div:this.div,accessibilityManager:this._accessibilityManager,annotationCanvasMap:this._annotationCanvasMap,annotationEditorUIManager:this._annotationEditorUIManager,page:this.pdfPage,viewport:t.clone({dontFlip:!0}),structTreeLayer:e})}cancel(){this._cancelled=!0,this.#ml?.abort(),this.#ml=null}hide(t=!1){this.#gl=!t,this.div&&(this.div.hidden=!0)}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}async injectLinkAnnotations({inferredLinks:t,viewport:e,structTreeLayer:i=null}){if(null===this.#pl)throw new Error("`render` method must be called before `injectLinkAnnotations`.");if(this._cancelled||this.#bl)return;this.#bl=!0;const s=this.#pl.length?this.#yl(t):t;s.length&&(this.annotationLayer||(this.#vl(e,i),ia(this.div,e)),await this.annotationLayer.addLinkAnnotations(s,this.linkService),this.#gl||(this.div.hidden=!1))}#wl(t){if(!this.div)return;let e=!1;switch(t){case va:e=!0;break;case ma:break;default:return}for(const t of this.div.childNodes)t.hasAttribute("data-internal-link")||(t.inert=e)}#yl(t){function e(t){if(!t.quadPoints)return[t.rect];const e=[];for(let i=2,s=t.quadPoints.length;i<s;i+=8){const s=t.quadPoints[i],n=t.quadPoints[i+1],a=t.quadPoints[i+2],r=t.quadPoints[i+3];e.push([a,r,s,n])}return e}function i(t,i){const s=[],n=e(t),a=e(i);for(const t of n)for(const e of a){const i=da.intersect(t,e);i&&s.push(i)}return s}function s(t){let e=0;for(const i of t)e+=Math.abs((i[2]-i[0])*(i[3]-i[1]));return e}return t.filter((t=>{let n;for(const a of this.#pl){if(a.annotationType!==Sn.LINK||!a.url)continue;const r=i(a,t);if(0!==r.length&&(n??=s(e(t)),s(r)/n>.5))return!1}return!0}))}}function cr(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 ur{#Al=new WeakMap;downloadData(t,e,i){cr(URL.createObjectURL(new Blob([t],{type:i})),e)}openOrDownloadData(t,e,i=null){const s=Hn(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(!Pn(e,"http://example.com"))return void console.error(`download - not a valid URL: ${e}`);s=e+"#pdfjs.action=download"}cr(s,i)}}const pr="event",gr="timeout";class fr{#xs=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.#xs[t];if(!i||0===i.length)return;let s;for(const{listener:n,external:a,once:r}of i.slice(0))r&&this._off(t,n),a?(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 a=()=>this._off(t,e);s=()=>n.removeEventListener("abort",a),n.addEventListener("abort",a)}(this.#xs[t]||=[]).push({listener:e,external:!0===i?.external,once:!0===i?.once,rmAbort:s})}_off(t,e,i=null){const s=this.#xs[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 mr{constructor(t){this.value=t}valueOf(){return this.value}}class br extends mr{constructor(t="???"){super(t)}toString(t){return`{${this.value}}`}}class vr extends mr{constructor(t,e={}){super(t),this.opts=e}toString(t){if(t)try{return t.memoizeIntlObject(Intl.NumberFormat,this.opts).format(this.value)}catch(e){t.reportError(e)}return this.value.toString(10)}}class wr extends mr{static supportsValue(t){if("number"==typeof t)return!0;if(t instanceof Date)return!0;if(t instanceof mr)return wr.supportsValue(t.valueOf());if("Temporal"in globalThis){const e=globalThis.Temporal;if(t instanceof e.Instant||t instanceof e.PlainDateTime||t instanceof e.PlainDate||t instanceof e.PlainMonthDay||t instanceof e.PlainTime||t instanceof e.PlainYearMonth)return!0}return!1}constructor(t,e={}){t instanceof wr?(e={...t.opts,...e},t=t.value):t instanceof mr&&(t=t.valueOf()),"object"==typeof t&&"calendarId"in t&&void 0===e.calendar&&(e={...e,calendar:t.calendarId}),super(t),this.opts=e}[Symbol.toPrimitive](t){return"string"===t?this.toString():this.toNumber()}toNumber(){const t=this.value;if("number"==typeof t)return t;if(t instanceof Date)return t.getTime();if("epochMilliseconds"in t)return t.epochMilliseconds;if("toZonedDateTime"in t)return t.toZonedDateTime("UTC").epochMilliseconds;throw new TypeError("Unwrapping a non-number value as a number")}toString(t){if(t)try{return t.memoizeIntlObject(Intl.DateTimeFormat,this.opts).format(this.value)}catch(e){t.reportError(e)}return"number"==typeof this.value||this.value instanceof Date?new Date(this.value).toISOString():this.value.toString()}}function yr(t,e,i){if(i===e)return!0;if(i instanceof vr&&e instanceof vr&&i.value===e.value)return!0;if(e instanceof vr&&"string"==typeof i){if(i===t.memoizeIntlObject(Intl.PluralRules,e.opts).select(e.value))return!0}return!1}function Ar(t,e,i){return e[i]?Cr(t,e[i].value):(t.reportError(new RangeError("No default")),new br)}function _r(t,e){const i=[],s=Object.create(null);for(const n of e)"narg"===n.type?s[n.name]=xr(t,n.value):i.push(xr(t,n));return{positional:i,named:s}}function xr(t,e){switch(e.type){case"str":return e.value;case"num":return new vr(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 br(`$${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 br(`$${e}`);i=t.args[e]}if(i instanceof mr)return i;switch(typeof i){case"string":return i;case"number":return new vr(i);case"object":if(wr.supportsValue(i))return new wr(i);default:return t.reportError(new TypeError(`Variable type not supported: $${e}, ${typeof i}`)),new br(`$${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 br(e);if(i){const n=s.attributes[i];return n?Cr(t,n):(t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new br(`${e}.${i}`))}if(s.value)return Cr(t,s.value);return t.reportError(new ReferenceError(`No value: ${e}`)),new br(e)}(t,e);case"term":return function(t,{name:e,attr:i,args:s}){const n=`-${e}`,a=t.bundle._terms.get(n);if(!a)return t.reportError(new ReferenceError(`Unknown term: ${n}`)),new br(n);if(i){const e=a.attributes[i];if(e){t.params=_r(t,s).named;const i=Cr(t,e);return t.params=null,i}return t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new br(`${n}.${i}`)}t.params=_r(t,s).named;const r=Cr(t,a.value);return t.params=null,r}(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 br(`${e}()`);if("function"!=typeof s)return t.reportError(new TypeError(`Function ${e}() is not callable`)),new br(`${e}()`);try{let e=_r(t,i);return s(e.positional,e.named)}catch(i){return t.reportError(i),new br(`${e}()`)}}(t,e);case"select":return function(t,{selector:e,variants:i,star:s}){let n=xr(t,e);if(n instanceof br)return Ar(t,i,s);for(const e of i){if(yr(t,n,xr(t,e.key)))return Cr(t,e.value)}return Ar(t,i,s)}(t,e);default:return new br}}function Sr(t,e){if(t.dirty.has(e))return t.reportError(new RangeError("Cyclic reference")),new br;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(xr(t,n).toString(t)),s&&i.push("⁩")}else i.push(t.bundle._transform(n));return t.dirty.delete(e),i.join("")}function Cr(t,e){return"string"==typeof e?t.bundle._transform(e):Sr(t,e)}class Er{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 Pr(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 Tr=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function Mr(t,e){let i=t[0];if(i instanceof br)return new br(`NUMBER(${i.valueOf()})`);if(i instanceof vr)return new vr(i.valueOf(),{...i.opts,...Pr(e,Tr)});if(i instanceof wr)return new vr(i.toNumber(),{...Pr(e,Tr)});throw new TypeError("Invalid argument to NUMBER")}const Ir=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function kr(t,e){let i=t[0];if(i instanceof br)return new br(`DATETIME(${i.valueOf()})`);if(i instanceof wr||i instanceof vr)return new wr(i,Pr(e,Ir));throw new TypeError("Invalid argument to DATETIME")}const Lr=new Map;class Dr{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:Mr,DATETIME:kr,...e},this._useIsolating=i,this._transform=s,this._intls=function(t){const e=Array.isArray(t)?t.join(" "):t;let i=Lr.get(e);return void 0===i&&(i=new Map,Lr.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 Er(this,i,e);try{return Sr(s,t).toString(s)}catch(t){if(s.errors&&t instanceof Error)return s.errors.push(t),(new br).toString(s);throw t}}}const Rr=/^(-?[a-zA-Z][\w-]*) *= */gm,Nr=/\.([a-zA-Z][\w-]*) *= */y,Fr=/\*?\[/y,Or=/(-?[0-9]+(?:\.([0-9]+))?)/y,Br=/([a-zA-Z][\w-]*)/y,jr=/([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y,Vr=/^[A-Z][A-Z0-9_-]*$/,Hr=/([^{}\n\r]+)/y,Ur=/([^\\"\n\r]*)/y,zr=/\\([\\"])/y,$r=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y,Wr=/^\n+/,Gr=/ +$/,qr=/ *\r?\n/g,Xr=/( *)$/,Kr=/{\s*/y,Yr=/\s*}/y,Qr=/\[\s*/y,Zr=/\s*] */y,Jr=/\s*\(\s*/y,to=/\s*->\s*/y,eo=/\s*:\s*/y,io=/\s*,?\s*/y,so=/\s+/y;class no{constructor(t){this.body=[],Rr.lastIndex=0;let e=0;for(;;){let i=Rr.exec(t);if(null===i)break;e=Rr.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 a(i){i.lastIndex=e;let s=i.exec(t);if(null===s)throw new SyntaxError(`Expected ${i.toString()}`);return e=i.lastIndex,s}function r(t){return a(t)[1]}function o(t){let e=l(),s=function(){let t=Object.create(null);for(;i(Nr);){let e=r(Nr),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(Hr)&&(s=r(Hr)),"{"===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,Wr),h([n],n.length)):s?v(s,Gr):null}function h(s=[],n){for(;;){if(i(Hr)){s.push(r(Hr));continue}if("{"===t[e]){s.push(d());continue}if("}"===t[e])throw new SyntaxError("Unbalanced closing brace");let a=b();if(!a)break;s.push(a),n=Math.min(n,a.length)}let a=s.length-1,o=s[a];"string"==typeof o&&(s[a]=v(o,Gr));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(Kr,SyntaxError);let t=c();if(n(Yr))return t;if(n(to)){let e=function(){let t,e=[],n=0;for(;i(Fr);){s("*")&&(t=n);let i=p(),a=l();if(null===a)throw new SyntaxError("Expected variant value");e[n++]={key:i,value:a}}if(0===n)return null;if(void 0===t)throw new SyntaxError("Expected default variant");return{variants:e,star:t}}();return n(Yr,SyntaxError),{type:"select",selector:t,...e}}throw new SyntaxError("Unclosed placeable")}function c(){if("{"===t[e])return d();if(i(jr)){let[,i,s,r=null]=a(jr);if("$"===i)return{type:"var",name:s};if(n(Jr)){let a=function(){let i=[];for(;;){switch(t[e]){case")":return e++,i;case void 0:throw new SyntaxError("Unclosed argument list")}i.push(u()),n(io)}}();if("-"===i)return{type:"term",name:s,attr:r,args:a};if(Vr.test(s))return{type:"func",name:s,args:a};throw new SyntaxError("Function names must be all upper-case")}return"-"===i?{type:"term",name:s,attr:r,args:[]}:{type:"mesg",name:s,attr:r}}return g()}function u(){let t=c();return"mesg"!==t.type?t:n(eo)?{type:"narg",name:t.name,value:g()}:t}function p(){let t;return n(Qr,SyntaxError),t=i(Or)?f():{type:"str",value:r(Br)},n(Zr,SyntaxError),t}function g(){if(i(Or))return f();if('"'===t[e])return function(){s('"',SyntaxError);let i="";for(;;){if(i+=r(Ur),"\\"!==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=""]=a(Or),i=e.length;return{type:"num",value:parseFloat(t),precision:i}}function m(){if(i(zr))return r(zr);if(i($r)){let[,t,e]=a($r),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(so),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(qr,"\n"),i=Xr.exec(t)[1].length;return new ao(e,i)}}}class ao{constructor(t,e){this.value=t,this.length=e}}const ro=/<|&#?\w+;/,oo={"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"]},lo={"http://www.w3.org/1999/xhtml":{global:["title","aria-description","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 ho(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(ro.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=po(e,i);t.replaceChild(s,i)}else if(mo(i)){const e=go(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(fo(i),i);e.textContent="",e.appendChild(t)}(e.content,t)}else t.textContent=i;uo(e,t)}function co(t,e){if(!t)return!1;for(let i of t)if(i.name===e)return!0;return!1}function uo(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))bo(s.name,e,i)&&!co(t.attributes,s.name)&&e.removeAttribute(s.name);if(t.attributes)for(const s of Array.from(t.attributes))bo(s.name,e,i)&&e.getAttribute(s.name)!==s.value&&e.setAttribute(s.name,s.value)}function po(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.`),fo(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}).`),fo(e);t.removeChild(s);return vo(e,s.cloneNode(!1))}function go(t){const e=t.ownerDocument.createElement(t.localName);return vo(t,e)}function fo(t){return t.ownerDocument.createTextNode(t.textContent)}function mo(t){const e=oo[t.namespaceURI];return e&&e.includes(t.localName)}function bo(t,e,i=null){if(i&&i.includes(t))return!0;const s=lo[e.namespaceURI];if(!s)return!1;const n=t.toLowerCase(),a=e.localName;if(s.global.includes(n))return!0;if(!s[a])return!1;if(s[a].includes(n))return!0;if("http://www.w3.org/1999/xhtml"===e.namespaceURI&&"input"===a&&"value"===n){const t=e.type.toLowerCase();if("submit"===t||"button"===t||"reset"===t)return!0}return!1}function vo(t,e){return e.textContent=t.textContent,uo(t,e),e}class wo extends Array{static from(t){return t instanceof this?t:new this(t)}}class yo extends wo{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 Ao{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 a=So(e,n,t,i);if(0===a.size)break;if("undefined"!=typeof console){const t=n.locales[0],e=Array.from(a).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,xo)}formatValues(t){return this.formatWithFallback(t,_o)}async formatValue(t,e){const[i]=await this.formatValues([{id:t,args:e}]);return i}handleEvent(){this.onChange()}onChange(t=!1){this.bundles=yo.from(this.generateBundles(this.resourceIds)),t&&this.bundles.touchNext(2)}}function _o(t,e,i,s){return i.value?t.formatPattern(i.value,s,e):null}function xo(t,e,i,s){const n={value:null,attributes:null};i.value&&(n.value=t.formatPattern(i.value,s,e));let a=Object.keys(i.attributes);if(a.length>0){n.attributes=new Array(a.length);for(let[r,o]of a.entries()){let a=t.formatPattern(i.attributes[o],s,e);n.attributes[r]={name:o,value:a}}}return n}function So(t,e,i,s){const n=[],a=new Set;return i.forEach((({id:i,args:r},o)=>{if(void 0!==s[o])return;let l=e.getMessage(i);if(l){if(n.length=0,s[o]=t(e,n,l,r),n.length>0&&"undefined"!=typeof console){const t=e.locales[0],s=n.join(", ");console.warn(`[fluent][resolver] errors in ${t}/${i}: ${s}.`)}}else a.add(i)})),a}const Co="data-l10n-id",Eo="data-l10n-args",Po=`[${Co}]`;class To extends Ao{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:[Co,Eo]}}onChange(t=!1){super.onChange(t),this.roots&&this.translateRoots()}setAttributes(t,e,i){return t.setAttribute(Co,e),i?t.setAttribute(Eo,JSON.stringify(i)):t.removeAttribute(Eo),t}getAttributes(t){return{id:t.getAttribute(Co),args:JSON.parse(t.getAttribute(Eo)||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(Co)&&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]&&ho(t[i],e[i]);this.resumeObserving()}getTranslatables(t){const e=Array.from(t.querySelectorAll(Po));return"function"==typeof t.hasAttribute&&t.hasAttribute(Co)&&e.push(t),e}getKeysForElement(t){return{id:t.getAttribute(Co),args:JSON.parse(t.getAttribute(Eo)||null)}}}class Mo{#_l;#an;#Ki;#xl;constructor({lang:t,isRTL:e},i=null){this.#Ki=Mo.#Sl(t),this.#xl=i,this.#_l=e??Mo.#Cl(this.#Ki)?"rtl":"ltr"}_setL10n(t){this.#xl=t}getLanguage(){return this.#Ki}getDirection(){return this.#_l}async get(t,e=null,i){if(Array.isArray(t)){t=t.map((t=>({id:t})));return(await this.#xl.formatMessages(t)).map((t=>t.value))}const s=await this.#xl.formatMessages([{id:t,args:e}]);return s[0]?.value||i}async translate(t){(this.#an||=new Set).add(t);try{this.#xl.connectRoot(t),await this.#xl.translateRoots()}catch{}}async translateOnce(t){try{await this.#xl.translateElements([t])}catch(t){console.error("translateOnce:",t)}}async destroy(){if(this.#an){for(const t of this.#an)this.#xl.disconnectRoot(t);this.#an.clear(),this.#an=null}this.#xl.pauseObserving()}pause(){this.#xl.pauseObserving()}resume(){this.#xl.resumeObserving()}static#Sl(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#Cl(t){const e=t.split("-",1)[0];return["ar","he","fa","ps","ur"].includes(e)}}function Io(){const{isAndroid:t,isLinux:e,isMac:i,isWindows:s}=In.platform;return e?"linux":s?"windows":i?"macos":t?"android":"other"}function ko(t,e){const i=new no(e),s=new Dr(t,{functions:{PLATFORM:Io}}),n=s.addResource(i);return n.length&&console.error("L10n errors",n),s}class Lo extends Mo{constructor(t){super({lang:t});const e=t?Lo.#El.bind(Lo,"en-us",this.getLanguage()):Lo.#Pl.bind(Lo,this.getLanguage());this._setL10n(new To([],e))}static async*#El(t,e){const{baseURL:i,paths:s}=await this.#Tl(),n=[e];if(t!==e){const i=e.split("-",1)[0];i!==e&&n.push(i),n.push(t)}const a=n.map((t=>[t,this.#Ml(t,i,s)]));for(const[t,e]of a){const i=await e;i?yield i:"en-us"===t&&(yield this.#Il(t))}}static async#Ml(t,e,i){const s=i[t];if(!s)return null;const n=new URL(s,e);return ko(t,await kn(n,"text"))}static async#Tl(){try{const{href:t}=document.querySelector('link[type="application/l10n"]'),e=await kn(t,"json");return{baseURL:t.substring(0,t.lastIndexOf("/")+1)||"./",paths:e}}catch{}return{baseURL:"./",paths:Object.create(null)}}static async*#Pl(t){yield this.#Il(t)}static async#Il(t){return ko(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-signature-button =\n .title = Add signature\npdfjs-editor-signature-button-label = Add signature\npdfjs-editor-highlight-editor =\n .aria-label = Highlight editor\npdfjs-editor-ink-editor =\n .aria-label = Drawing editor\npdfjs-editor-signature-editor1 =\n .aria-description = Signature editor: { $description }\npdfjs-editor-stamp-editor =\n .aria-label = Image editor\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-remove-signature-button =\n .title = Remove signature\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-editor-add-signature-container =\n .aria-label = Signature controls and saved signatures\npdfjs-editor-signature-add-signature-button =\n .title = Add new signature\npdfjs-editor-signature-add-signature-button-label = Add new signature\npdfjs-editor-add-saved-signature-button =\n .title = Saved signature: { $description }\npdfjs-free-text2 =\n .aria-label = Text Editor\n .default-content = Start typing…\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-signature = Signature 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\npdfjs-editor-add-signature-dialog-label = This modal allows the user to create a signature to add to a PDF document. The user can edit the name (which also serves as the alt text), and optionally save the signature for repeated use.\npdfjs-editor-add-signature-dialog-title = Add a signature\npdfjs-editor-add-signature-type-button = Type\n .title = Type\npdfjs-editor-add-signature-draw-button = Draw\n .title = Draw\npdfjs-editor-add-signature-image-button = Image\n .title = Image\npdfjs-editor-add-signature-type-input =\n .aria-label = Type your signature\n .placeholder = Type your signature\npdfjs-editor-add-signature-draw-placeholder = Draw your signature\npdfjs-editor-add-signature-draw-thickness-range-label = Thickness\npdfjs-editor-add-signature-draw-thickness-range =\n .title = Drawing thickness: { $thickness }\npdfjs-editor-add-signature-image-placeholder = Drag a file here to upload\npdfjs-editor-add-signature-image-browse-link =\n { PLATFORM() ->\n [macos] Or choose image files\n *[other] Or browse image files\n }\npdfjs-editor-add-signature-description-label = Description (alt text)\npdfjs-editor-add-signature-description-input =\n .title = Description (alt text)\npdfjs-editor-add-signature-description-default-when-drawing = Signature\npdfjs-editor-add-signature-clear-button-label = Clear signature\npdfjs-editor-add-signature-clear-button =\n .title = Clear signature\npdfjs-editor-add-signature-save-checkbox = Save signature\npdfjs-editor-add-signature-save-warning-message = You’ve reached the limit of 5 saved signatures. Remove one to save more.\npdfjs-editor-add-signature-image-upload-error-title = Couldn’t upload image\npdfjs-editor-add-signature-image-upload-error-description = Check your network connection or try another image.\npdfjs-editor-add-signature-error-close-button = Close\npdfjs-editor-add-signature-cancel-button = Cancel\npdfjs-editor-add-signature-add-button = Add\npdfjs-editor-delete-signature-button1 =\n .title = Remove saved signature\npdfjs-editor-delete-signature-button-label1 = Remove saved signature\npdfjs-editor-add-signature-edit-button-label = Edit description\npdfjs-editor-edit-signature-dialog-title = Edit description\npdfjs-editor-edit-signature-update-button = Update')}}function Do(){return document.location.hash}class Ro{#wo=null;#kl=null;#fl=null;#Oo=null;#To=null;#m;constructor(t){this.pdfPage=t.pdfPage,this.accessibilityManager=t.accessibilityManager,this.l10n=t.l10n,this.l10n||=new Lo,this.annotationEditorLayer=null,this.div=null,this._cancelled=!1,this.#m=t.uiManager,this.#wo=t.annotationLayer||null,this.#To=t.textLayer||null,this.#kl=t.drawLayer||null,this.#fl=t.onAppend||null,this.#Oo=t.structTreeLayer||null}async render({viewport:t,intent: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.#m.direction,this.#fl?.(s),this.annotationEditorLayer=new vn({uiManager:this.#m,div:s,structTreeLayer:this.#Oo,accessibilityManager:this.accessibilityManager,pageIndex:this.pdfPage.pageNumber-1,l10n:this.l10n,viewport:i,annotationLayer:this.#wo,textLayer:this.#To,drawLayer:this.#kl});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 No=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)&&No.set("maxCanvasPixels",5242880),s&&No.set("useSystemFonts",!1)}const Fo=1,Oo=2,Bo=4,jo=8,Vo=16,Ho=128,Uo={BOOLEAN:1,NUMBER:2,OBJECT:4,STRING:8,UNDEFINED:16},zo={allowedGlobalEvents:{value:null,kind:Fo},canvasMaxAreaInBytes:{value:-1,kind:Fo+Bo},isInAutomation:{value:!1,kind:Fo},localeProperties:{value:{lang:navigator.language||"en-US"},kind:Fo},maxCanvasDim:{value:32767,kind:Fo+Oo},nimbusDataStr:{value:"",kind:Fo},supportsCaretBrowsingMode:{value:!1,kind:Fo},supportsDocumentFonts:{value:!0,kind:Fo},supportsIntegratedFind:{value:!1,kind:Fo},supportsMouseWheelZoomCtrlKey:{value:!0,kind:Fo},supportsMouseWheelZoomMetaKey:{value:!0,kind:Fo},supportsPinchToZoom:{value:!0,kind:Fo},supportsPrinting:{value:!0,kind:Fo},toolbarDensity:{value:0,kind:Fo+Vo},altTextLearnMoreUrl:{value:"",kind:Oo+Ho},annotationEditorMode:{value:0,kind:Oo+Ho},annotationMode:{value:2,kind:Oo+Ho},cursorToolOnLoad:{value:0,kind:Oo+Ho},debuggerSrc:{value:"./debugger.mjs",kind:Oo},defaultZoomDelay:{value:400,kind:Oo+Ho},defaultZoomValue:{value:"",kind:Oo+Ho},disableHistory:{value:!1,kind:Oo},disablePageLabels:{value:!1,kind:Oo+Ho},enableAltText:{value:!1,kind:Oo+Ho},enableAltTextModelDownload:{value:!0,kind:Oo+Ho+Vo},enableAutoLinking:{value:!0,kind:Oo+Ho},enableDetailCanvas:{value:!0,kind:Oo},enableGuessAltText:{value:!0,kind:Oo+Ho+Vo},enableHighlightFloatingButton:{value:!1,kind:Oo+Ho},enableNewAltTextWhenAddingImage:{value:!0,kind:Oo+Ho},enablePermissions:{value:!1,kind:Oo+Ho},enablePrintAutoRotate:{value:!0,kind:Oo+Ho},enableScripting:{value:!0,kind:Oo+Ho},enableSignatureEditor:{value:!1,kind:Oo+Ho},enableUpdatedAddImage:{value:!1,kind:Oo+Ho},externalLinkRel:{value:"noopener noreferrer nofollow",kind:Oo},externalLinkTarget:{value:0,kind:Oo+Ho},highlightEditorColors:{value:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",kind:Oo+Ho},historyUpdateUrl:{value:!1,kind:Oo+Ho},ignoreDestinationZoom:{value:!1,kind:Oo+Ho},imageResourcesPath:{value:"./images/",kind:Oo},maxCanvasPixels:{value:2**25,kind:Oo},forcePageColors:{value:!1,kind:Oo+Ho},pageColorsBackground:{value:"Canvas",kind:Oo+Ho},pageColorsForeground:{value:"CanvasText",kind:Oo+Ho},pdfBugEnabled:{value:!1,kind:Oo+Ho},printResolution:{value:150,kind:Oo},sidebarViewOnLoad:{value:-1,kind:Oo+Ho},scrollModeOnLoad:{value:-1,kind:Oo+Ho},spreadModeOnLoad:{value:-1,kind:Oo+Ho},textLayerMode:{value:1,kind:Oo+Ho},viewerCssTheme:{value:0,kind:Oo+Ho},viewOnLoad:{value:0,kind:Oo+Ho},cMapPacked:{value:!0,kind:Bo},cMapUrl:{value:"../web/cmaps/",kind:Bo},disableAutoFetch:{value:!1,kind:Bo+Ho},disableFontFace:{value:!1,kind:Bo+Ho},disableRange:{value:!1,kind:Bo+Ho},disableStream:{value:!1,kind:Bo+Ho},docBaseUrl:{value:"",kind:Bo},enableHWA:{value:!0,kind:Bo+Oo+Ho},enableXfa:{value:!0,kind:Bo+Ho},fontExtraProperties:{value:!1,kind:Bo},iccUrl:{value:"../web/iccs/",kind:Bo},isEvalSupported:{value:!0,kind:Bo},isOffscreenCanvasSupported:{value:!0,kind:Bo},maxImageSize:{value:-1,kind:Bo},pdfBug:{value:!1,kind:Bo},standardFontDataUrl:{value:"../web/standard_fonts/",kind:Bo},useSystemFonts:{value:void 0,kind:Bo,type:Uo.BOOLEAN+Uo.UNDEFINED},verbosity:{value:1,kind:Bo},wasmUrl:{value:"../web/wasm/",kind:Bo},workerPort:{value:null,kind:jo},workerSrc:{value:"../build/pdf.worker.mjs",kind:jo}};zo.defaultUrl={value:"compressed.tracemonkey-pldi-09.pdf",kind:Oo},zo.sandboxBundleSrc={value:"../build/pdf.sandbox.mjs",kind:Oo},zo.enableFakeMLManager={value:!0,kind:Oo},zo.disablePreferences={value:!1,kind:Oo};class $o{static eventBus;static#Ll=new Map;static{for(const t in zo)this.#Ll.set(t,zo[t].value);for(const[t,e]of No)this.#Ll.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.#Ll.get(t)}static getAll(t=null,e=!1){const i=Object.create(null);for(const s in zo){const n=zo[s];(!t||t&n.kind)&&(i[s]=e?n.value:this.#Ll.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=zo[s],a=t[s];if(!n||!(typeof a==typeof n.value||Uo[(typeof a).toUpperCase()]&n.type))continue;const{kind:r}=n;(!e||r&Fo||r&Ho)&&(this.eventBus&&r&Vo&&(i||=new Map).set(s,a),this.#Ll.set(s,a))}if(i)for(const[t,e]of i)this.eventBus.dispatch(t.toLowerCase(),{source:this,value:e})}}function Wo({width:t,height:e,left:i,top:s},n){if(0===t||0===e)return null;const a=n.textLayer.div.getBoundingClientRect(),r=n.getPagePoint(i-a.left,s-a.top),o=n.getPagePoint(i-a.left+t,s-a.top+e);return da.normalizeRect([r[0],r[1],o[0],o[1]])}function Go(t,e){const i=t.getClientRects();if(1===i.length)return{rect:Wo(i[0],e)};const s=[1/0,1/0,-1/0,-1/0],n=[];let a=0;for(const t of i){const i=Wo(t,e);null!==i&&(n[a]=n[a+4]=i[0],n[a+1]=n[a+3]=i[3],n[a+2]=n[a+6]=i[2],n[a+5]=n[a+7]=i[1],da.rectBoundingBox(...i,s),a+=8)}return{quadPoints:n,rect:s}}function qo(t,e){let i=t;do{if(i.nodeType===Node.TEXT_NODE){const t=i.textContent.length;if(e<=t)return[i,e];e-=t}else if(i.firstChild){i=i.firstChild;continue}for(;!i.nextSibling&&i!==t;)i=i.parentNode;i!==t&&(i=i.nextSibling)}while(i!==t);throw new Error("Offset is bigger than container's contents length.")}class Xo{static#Dl=0;static#i;static findLinks(t){this.#i??=/\b(?:https?:\/\/|mailto:|www\.)(?:[\S--[\p{P}<>]]|\/|[\S--[\[\]]]+[\S--[\p{P}<>]])+|\b[\S--[@\p{Ps}\p{Pe}<>]]+@([\S--[\p{P}<>]]+(?:\.[\S--[\p{P}<>]]+)+)/gmv;const[e,i]=nr(t),s=e.matchAll(this.#i),n=[];for(const t of s){const[e,s]=t;let a;if(e.startsWith("www.")||e.startsWith("http://")||e.startsWith("https://"))a=e;else{if(!URL.canParse(`http://${s}`))continue;a=e.startsWith("mailto:")?e:`mailto:${e}`}const r=Pn(a,null,{addDefaultProtocol:!0});if(r){const[s,a]=ar(i,t.index,e.length);n.push({url:r.href,index:s,length:a})}}return n}static processLinks(t){return this.findLinks(t._textHighlighter.textContentItemsStr.join("\n")).map((e=>function({url:t,index:e,length:i},s,n){const a=s._textHighlighter,[{begin:r,end:o}]=a._convertMatches([e],[i]),l=new Range;return l.setStart(...qo(a.textDivs[r.divIdx],r.offset)),l.setEnd(...qo(a.textDivs[o.divIdx],o.offset)),{id:`inferred_link_${n}`,unsafeUrl:t,url:t,annotationType:Sn.LINK,rotation:0,...Go(l,s),borderStyle:null}}(e,t,this.#Dl++)))}}class Ko{#ui=!1;#Rl=null;#Nl=null;#Fl=ga.INITIAL;#Ol=null;canvas=null;div=null;eventBus=null;id=null;pageColors=null;renderingQueue=null;renderTask=null;resume=null;constructor(t){this.#ui=#ui in t?t.#ui:t.enableHWA||!1,this.eventBus=t.eventBus,this.id=t.id,this.pageColors=t.pageColors||null,this.renderingQueue=t.renderingQueue}get renderingState(){return this.#Fl}set renderingState(t){if(t!==this.#Fl)switch(this.#Fl=t,this.#Rl&&(clearTimeout(this.#Rl),this.#Rl=null),t){case ga.PAUSED:this.div.classList.remove("loading");break;case ga.RUNNING:this.div.classList.add("loadingIcon"),this.#Rl=setTimeout((()=>{this.div.classList.add("loading"),this.#Rl=null}),0);break;case ga.INITIAL:case ga.FINISHED:this.div.classList.remove("loadingIcon","loading")}}_createCanvas(t,e=!1){const{pageColors:i}=this,s=!(!i?.background||!i?.foreground),n=this.canvas,a=!n&&!s&&!e,r=this.canvas=document.createElement("canvas");this.#Ol=e=>{if(a)return t(r),void(this.#Ol=null);e&&(n?(n.replaceWith(r),n.width=n.height=0):t(r))};const o=r.getContext("2d",{alpha:!1,willReadFrequently:!this.#ui});return{canvas:r,prevCanvas:n,ctx:o}}#Bl=t=>{if(this.#Ol?.(!1),this.renderingQueue&&!this.renderingQueue.isHighestPriority(this))return this.renderingState=ga.PAUSED,void(this.resume=()=>{this.renderingState=ga.RUNNING,t()});t()};_resetCanvas(){const{canvas:t}=this;t&&(t.remove(),t.width=t.height=0,this.canvas=null)}async _drawCanvas(t,e,i){const s=this.renderTask=this.pdfPage.render(t);s.onContinue=this.#Bl,s.onError=t=>{t instanceof ta&&(e(),this.#Nl=null)};let n=null;try{await s.promise,this.#Ol?.(!0)}catch(t){if(t instanceof ta)return;n=t,this.#Ol?.(!0)}finally{this.#Nl=n,s===this.renderTask&&(this.renderTask=null)}if(this.renderingState=ga.FINISHED,i(s),n)throw n}cancelRendering({cancelExtraDelay:t=0}={}){this.renderTask&&(this.renderTask.cancel(t),this.renderTask=null),this.resume=null}dispatchPageRender(){this.eventBus.dispatch("pagerender",{source:this,pageNumber:this.id})}dispatchPageRendered(t,e){this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:t,isDetailView:e,timestamp:performance.now(),error:this.#Nl})}}class Yo{#kl=null;constructor(t){this.pageIndex=t.pageIndex}async render({intent:t="display"}){"display"!==t||this.#kl||this._cancelled||(this.#kl=new Mn({pageIndex:this.pageIndex}))}cancel(){this._cancelled=!0,this.#kl&&(this.#kl.destroy(),this.#kl=null)}setParent(t){this.#kl?.setParent(t)}getDrawLayer(){return this.#kl}}class Qo extends Ko{#jl=null;renderingCancelled=!1;constructor({pageView:t}){super(t),this.pageView=t,this.renderingId="detail"+this.id,this.div=t.div}setPdfPage(t){this.pageView.setPdfPage(t)}get pdfPage(){return this.pageView.pdfPage}get renderingState(){return super.renderingState}set renderingState(t){this.renderingCancelled=!1,super.renderingState=t}reset({keepCanvas:t=!1}={}){const e=this.renderingCancelled||this.renderingState===ga.RUNNING||this.renderingState===ga.PAUSED;this.cancelRendering(),this.renderingState=ga.INITIAL,this.renderingCancelled=e,t||this._resetCanvas()}#Vl(t){if(!this.#jl)return!0;const e=this.#jl.minX,i=this.#jl.minY,s=this.#jl.width+e,n=this.#jl.height+i;if(t.minX<e||t.minY<i||t.maxX>s||t.maxY>n)return!0;const{width:a,height:r,scale:o}=this.pageView.viewport;if(this.#jl.scale!==o)return!0;const l=t.minX-e,h=s-t.maxX,d=t.minY-i,c=n-t.maxY;return e>0&&h/l>3||s<a&&l/h>3||i>0&&c/d>3||n<r&&d/c>3}update({visibleArea:t=null,underlyingViewUpdated:e=!1}={}){if(e)return this.cancelRendering(),void(this.renderingState=ga.INITIAL);if(!this.#Vl(t))return;const{viewport:i,maxCanvasPixels:s}=this.pageView,n=t.maxX-t.minX,a=t.maxY-t.minY,r=n*a*qn.pixelRatio**2,o=(Math.sqrt(s/r)-1)/2;let l=Math.min(1,o);l<0&&(l=0);const h=n*l,d=a*l,c=Math.max(0,t.minX-h),u=Math.min(i.width,t.maxX+h),p=Math.max(0,t.minY-d),g=u-c,f=Math.min(i.height,t.maxY+d)-p;this.#jl={minX:c,minY:p,width:g,height:f,scale:i.scale},this.reset({keepCanvas:!0})}async draw(){if(this.pageView.detailView!==this)return;const t=this.pageView.renderingState===ga.FINISHED||this.renderingState===ga.FINISHED;this.renderingState!==ga.INITIAL&&(console.error("Must be in new state before drawing"),this.reset());const{div:e,pdfPage:i,viewport:s}=this.pageView;if(!i)throw this.renderingState=ga.FINISHED,new Error("pdfPage is not loaded");this.renderingState=ga.RUNNING;const n=this.pageView._ensureCanvasWrapper(),{canvas:a,prevCanvas:r,ctx:o}=this._createCanvas((t=>{"CANVAS"===n.firstElementChild?.tagName?n.firstElementChild.after(t):n.prepend(t)}),t);a.setAttribute("aria-hidden","true");const{width:l,height:h}=s,d=this.#jl,{pixelRatio:c}=qn,u=[c,0,0,c,-d.minX*c,-d.minY*c];a.width=d.width*c,a.height=d.height*c;const{style:p}=a;p.width=100*d.width/l+"%",p.height=100*d.height/h+"%",p.top=100*d.minY/h+"%",p.left=100*d.minX/l+"%";const g=this._drawCanvas(this.pageView._getRenderingContext(o,u),(()=>{this.canvas?.remove(),this.canvas=r}),(()=>{this.dispatchPageRendered(!1,!0)}));return e.setAttribute("data-loaded",!0),this.dispatchPageRender(),g}}const Zo={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},Jo=/^H(\d+)$/;class tl{#Hl;#Ul=null;#zl;#$l=new Map;#Wl;#Gl=null;constructor(t,e){this.#Hl=t.getStructTree(),this.#Wl=e}async render(){if(this.#zl)return this.#zl;const{promise:t,resolve:e,reject:i}=Promise.withResolvers();this.#zl=t;try{this.#Ul=this.#ql(await this.#Hl)}catch(t){i(t)}return this.#Hl=null,this.#Ul?.classList.add("structTree"),e(this.#Ul),t}async getAriaAttributes(t){try{return await this.render(),this.#$l.get(t)}catch{}return null}hide(){this.#Ul&&!this.#Ul.hidden&&(this.#Ul.hidden=!0)}show(){this.#Ul?.hidden&&(this.#Ul.hidden=!1)}#Xl(t,e){const{alt:i,id:s,lang:n}=t;if(void 0!==i){let s=!1;const n=Pa(i);for(const e of t.children)if("annotation"===e.type){let t=this.#$l.get(e.id);t||(t=new Map,this.#$l.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",Pa(n,!0))}#Kl(t,e){const{alt:i,bbox:s,children:n}=t,a=n?.[0];if(!this.#Wl||!i||!s||"content"!==a?.type)return!1;const{id:r}=a;if(!r)return!1;e.setAttribute("aria-owns",r);const o=document.createElement("span");(this.#Gl||=new Map).set(r,o),o.setAttribute("role","img"),o.setAttribute("aria-label",Pa(i));const{pageHeight:l,pageX:h,pageY:d}=this.#Wl,c="calc(var(--total-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.#Gl){for(const[t,e]of this.#Gl)document.getElementById(t)?.append(e);this.#Gl.clear(),this.#Gl=null}}#ql(t){if(!t)return null;const e=document.createElement("span");if("role"in t){const{role:i}=t,s=i.match(Jo);if(s?(e.setAttribute("role","heading"),e.setAttribute("aria-level",s[1])):Zo[i]&&e.setAttribute("role",Zo[i]),"Figure"===i&&this.#Kl(t,e))return e}if(this.#Xl(t,e),t.children)if(1===t.children.length&&"id"in t.children[0])this.#Xl(t.children[0],e);else for(const i of t.children)e.append(this.#ql(i));return e}}class el{#Yl=!1;#Ql=null;#Zl=new Map;#Jl=new Map;setTextMapping(t){this.#Ql=t}static#th(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,a=i.y+i.height,r=i.y+i.height/2,o=s.y,l=s.y+s.height,h=s.y+s.height/2;if(r<=o&&h>=a)return-1;if(h<=n&&r>=l)return 1;return i.x+i.width/2-(s.x+s.width/2)}enable(){if(this.#Yl)throw new Error("TextAccessibilityManager is already enabled.");if(!this.#Ql)throw new Error("Text divs and strings have not been set.");if(this.#Yl=!0,this.#Ql=this.#Ql.slice(),this.#Ql.sort(el.#th),this.#Zl.size>0){const t=this.#Ql;for(const[e,i]of this.#Zl){document.getElementById(e)?this.#eh(e,t[i]):this.#Zl.delete(e)}}for(const[t,e]of this.#Jl)this.addPointerInTextLayer(t,e);this.#Jl.clear()}disable(){this.#Yl&&(this.#Jl.clear(),this.#Ql=null,this.#Yl=!1)}removePointerInTextLayer(t){if(!this.#Yl)return void this.#Jl.delete(t);const e=this.#Ql;if(!e||0===e.length)return;const{id:i}=t,s=this.#Zl.get(i);if(void 0===s)return;const n=e[s];this.#Zl.delete(i);let a=n.getAttribute("aria-owns");a?.includes(i)&&(a=a.split(" ").filter((t=>t!==i)).join(" "),a?n.setAttribute("aria-owns",a):(n.removeAttribute("aria-owns"),n.setAttribute("role","presentation")))}#eh(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.#Yl)return this.#Jl.set(t,e),null;e&&this.removePointerInTextLayer(t);const s=this.#Ql;if(!s||0===s.length)return null;const n=Ta(s,(e=>el.#th(t,e)<0)),a=Math.max(0,n-1),r=s[a];this.#eh(i,r),this.#Zl.set(i,a);const o=r.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 a=Array.from(t.childNodes).filter((t=>t!==e));if(0===a.length)return n;const r=i||e,o=Ta(a,(t=>el.#th(r,t)<0));return 0===o?a[0].before(e):a[o-1].after(e),n}}class il{#ml=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.#ml||(this.#ml=new AbortController,this.eventBus._on("updatetextlayermatches",(t=>{t.pageIndex!==this.pageIdx&&-1!==t.pageIndex||this._updateMatches()}),{signal:this.#ml.signal})),this._updateMatches()}disable(){this.enabled&&(this.enabled=!1,this.#ml?.abort(),this.#ml=null,this._updateMatches(!0))}_convertMatches(t,e){if(!t)return[];const{textContentItemsStr:i}=this;let s=0,n=0;const a=i.length-1,r=[];for(let o=0,l=t.length;o<l;o++){let l=t[o];for(;s!==a&&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!==a&&l>n+i[s].length;)n+=i[s].length,s++;h.end={divIdx:s,offset:l-n},r.push(h)}return r}_renderMatches(t){if(0===t.length)return;const{findController:e,pageIdx:i}=this,{textContentItemsStr:s,textDivs:n}=this,a=i===e.selected.pageIdx,r=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,a){let r=n[t];if(r.nodeType===Node.TEXT_NODE){const e=document.createElement("span");r.before(e),e.append(r),n[t]=e,r=e}const o=s[t].substring(e,i),l=document.createTextNode(o);if(a){const t=document.createElement("span");if(t.className=`${a} appended`,t.append(l),r.append(t),a.includes("selected")){const{left:e}=t.getClientRects()[0];return e-r.getBoundingClientRect().left}return 0}return r.append(l),0}let c=r,u=c+1;if(e.state.highlightAll)c=0,u=t.length;else if(!a)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=a&&s===r,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:r})}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:a}=this;let r=-1;for(const t of i){for(let e=Math.max(r,t.begin.divIdx),i=t.end.divIdx;e<=i;e++){const t=a[e];t.textContent=n[e],t.className=""}r=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 sl{#ih=!1;#fl=null;#sh=!1;#To=null;static#nh=new Map;static#ah=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.#ih=!0===s,this.#fl=n,this.div=document.createElement("div"),this.div.tabIndex=0,this.div.className="textLayer"}async render({viewport:t,textContentParams:e=null}){if(this.#sh&&this.#To)return this.#To.update({viewport:t,onBefore:this.hide.bind(this)}),void this.show();this.cancel(),this.#To=new oa({textContentSource:this.pdfPage.streamTextContent(e||{includeMarkedContent:!0,disableNormalization:!0}),container:this.div,viewport:t});const{textDivs:i,textContentItemsStr:s}=this.#To;this.highlighter?.setTextMapping(i,s),this.accessibilityManager?.setTextMapping(i),await this.#To.render(),this.#sh=!0;const n=document.createElement("div");n.className="endOfContent",this.div.append(n),this.#rh(n),this.#fl?.(this.div),this.highlighter?.enable(),this.accessibilityManager?.enable()}hide(){!this.div.hidden&&this.#sh&&(this.highlighter?.disable(),this.div.hidden=!0)}show(){this.div.hidden&&this.#sh&&(this.div.hidden=!1,this.highlighter?.enable())}cancel(){this.#To?.cancel(),this.#To=null,this.highlighter?.disable(),this.accessibilityManager?.disable(),sl.#oh(this.div)}#rh(t){const{div:e}=this;e.addEventListener("mousedown",(()=>{e.classList.add("selecting")})),e.addEventListener("copy",(t=>{if(!this.#ih){const e=document.getSelection();t.clipboardData.setData("text/plain",Pa(Wn(e.toString())))}aa(t)})),sl.#nh.set(e,t),sl.#lh()}static#oh(t){this.#nh.delete(t),0===this.#nh.size&&(this.#ah?.abort(),this.#ah=null)}static#lh(){if(this.#ah)return;this.#ah=new AbortController;const{signal:t}=this.#ah,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.#nh.forEach(e)}),{signal:t}),window.addEventListener("blur",(()=>{i=!1,this.#nh.forEach(e)}),{signal:t}),document.addEventListener("keyup",(()=>{i||this.#nh.forEach(e)}),{signal:t}),document.addEventListener("selectionchange",(()=>{const t=document.getSelection();if(0===t.rangeCount)return void this.#nh.forEach(e);const i=new Set;for(let e=0;e<t.rangeCount;e++){const s=t.getRangeAt(e);for(const t of this.#nh.keys())!i.has(t)&&s.intersectsNode(t)&&i.add(t)}for(const[t,s]of this.#nh)i.has(t)?t.classList.add("selecting"):e(s,t);if(s??="none"===getComputedStyle(this.#nh.values().next().value).getPropertyValue("-moz-user-select"),s)return;const a=t.getRangeAt(0),r=n&&(0===a.compareBoundaryPoints(Range.END_TO_END,n)||0===a.compareBoundaryPoints(Range.START_TO_END,n));let o=r?a.startContainer:a.endContainer;if(o.nodeType===Node.TEXT_NODE&&(o=o.parentNode),!r&&0===a.endOffset)do{for(;!o.previousSibling;)o=o.parentNode;o=o.previousSibling}while(!o.childNodes.length);const l=o.parentElement?.closest(".textLayer"),h=this.#nh.get(l);h&&(h.style.width=l.style.width,h.style.height=l.style.height,o.parentElement.insertBefore(h,r?o:o.nextSibling)),n=a.cloneRange()}),{signal:t})}}class nl{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({viewport:t,intent: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,pa.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?pa.update(s):(this.div=document.createElement("div"),s.div=this.div,pa.render(s))}cancel(){this._cancelled=!0}hide(){this.div&&(this.div.hidden=!0)}}const al={annotationEditorUIManager:null,annotationStorage:null,downloadManager:null,enableScripting:!1,fieldObjectsPromise:null,findController:null,hasJSActionsPromise:null,get linkService(){return new hr}},rl=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);class ol extends Ko{#hh=xn.ENABLE_FORMS;#dh=null;#ch=!0;#uh=!1;#Ee=!1;#ph=null;#gh=!1;#fh=null;#mh=null;#bh=1;#vh=1;#wh=ya;#yh=1;#Ah={directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0};#_h=[null,null,null,null];constructor(t){super(t);const e=t.container,i=t.defaultViewport;this.renderingId="page"+this.id,this.#ph=t.layerProperties||al,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.#wh=t.textLayerMode??ya,this.#hh=t.annotationMode??xn.ENABLE_FORMS,this.imageResourcesPath=t.imageResourcesPath||"",this.enableDetailCanvas=t.enableDetailCanvas??!0,this.maxCanvasPixels=t.maxCanvasPixels??$o.get("maxCanvasPixels"),this.maxCanvasDim=t.maxCanvasDim||$o.get("maxCanvasDim"),this.#ch=!1!==t.enableAutoLinking,this.l10n=t.l10n,this.l10n||=new Lo,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,this.detailView=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.#xh(),e?.append(s),this._isStandalone){e?.style.setProperty("--scale-factor",this.scale*Jn.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.#Ah.initialOptionalContent=t.hasInitialVisibility)})),t.l10n||this.l10n.translate(this.div)}}#Sh(t,e){const i=rl.get(e),s=this.#_h[i];if(this.#_h[i]=t,s)s.replaceWith(t);else{for(let e=i-1;e>=0;e--){const i=this.#_h[e];if(i)return void i.after(t)}this.div.prepend(t)}}#xh(){const{div:t,viewport:e}=this;if(e.userUnit!==this.#yh&&(1!==e.userUnit?t.style.setProperty("--user-unit",e.userUnit):t.style.removeProperty("--user-unit"),this.#yh=e.userUnit),this.pdfPage){if(this.#mh===e.rotation)return;this.#mh=e.rotation}ia(t,e,!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*Jn.PDF_TO_CSS_UNITS,rotation:e}),this.#xh(),this.reset()}destroy(){this.reset(),this.pdfPage?.cleanup()}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}get _textHighlighter(){return sa(this,"_textHighlighter",new il({pageIndex:this.id-1,eventBus:this.eventBus,findController:this.#ph.findController}))}#Ch(t,e){this.eventBus.dispatch(t,{source:this,pageNumber:this.id,error:e})}async#Eh(){let t=null;try{await this.annotationLayer.render({viewport:this.viewport,intent:"display",structTreeLayer:this.structTreeLayer})}catch(e){console.error("#renderAnnotationLayer:",e),t=e}finally{this.#Ch("annotationlayerrendered",t)}}async#Ph(){let t=null;try{await this.annotationEditorLayer.render({viewport:this.viewport,intent:"display"})}catch(e){console.error("#renderAnnotationEditorLayer:",e),t=e}finally{this.#Ch("annotationeditorlayerrendered",t)}}async#Th(){try{await this.drawLayer.render({intent:"display"})}catch(t){console.error("#renderDrawLayer:",t)}}async#Mh(){let t=null;try{const t=await this.xfaLayer.render({viewport:this.viewport,intent:"display"});t?.textDivs&&this._textHighlighter&&this.#Ih(t.textDivs)}catch(e){console.error("#renderXfaLayer:",e),t=e}finally{this.xfaLayer?.div&&(this.l10n.pause(),this.#Sh(this.xfaLayer.div,"xfaLayer"),this.l10n.resume()),this.#Ch("xfalayerrendered",t)}}async#kh(){if(!this.textLayer)return;let t=null;try{await this.textLayer.render({viewport:this.viewport})}catch(e){if(e instanceof bn)return;console.error("#renderTextLayer:",e),t=e}this.#Ch("textlayerrendered",t),this.#Lh()}async#Lh(){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#Ih(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()}async#Dh(t){try{if(await t,!this.annotationLayer)return;await this.annotationLayer.injectLinkAnnotations({inferredLinks:Xo.processLinks(this),viewport:this.viewport,structTreeLayer:this.structTreeLayer})}catch(t){console.error("#injectLinkAnnotations:",t)}}_resetCanvas(){super._resetCanvas(),this.#fh=null}reset({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:s=!1,keepCanvasWrapper:n=!1,preserveDetailViewState:a=!1}={}){this.cancelRendering({keepAnnotationLayer:t,keepAnnotationEditorLayer:e,keepXfaLayer:i,keepTextLayer:s}),this.renderingState=ga.INITIAL;const r=this.div,o=r.childNodes,l=t&&this.annotationLayer?.div||null,h=e&&this.annotationEditorLayer?.div||null,d=i&&this.xfaLayer?.div||null,c=s&&this.textLayer?.div||null,u=n&&this.#dh||null;for(let t=o.length-1;t>=0;t--){const e=o[t];switch(e){case l:case h:case d:case c:case u:continue}e.remove();const i=this.#_h.indexOf(e);i>=0&&(this.#_h[i]=null)}r.removeAttribute("data-loaded"),l&&this.annotationLayer.hide(),h&&this.annotationEditorLayer.hide(),d&&this.xfaLayer.hide(),c&&this.textLayer.hide(),this.structTreeLayer?.hide(),!n&&this.#dh&&(this.#dh=null,this._resetCanvas()),a||(this.detailView?.reset({keepCanvas:n}),n||(this.detailView=null))}toggleEditingMode(t){this.#Ee=t,this.hasEditableAnnotations()&&this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0})}updateVisibleArea(t){this.enableDetailCanvas&&(this.#gh&&this.maxCanvasPixels>0&&t?(this.detailView??=new Qo({pageView:this}),this.detailView.update({visibleArea:t})):this.detailView&&(this.detailView.reset(),this.detailView=null))}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.#Ah.initialOptionalContent=t.hasInitialVisibility)}))),this.#Ah.directDrawing=!0;const n=(this.rotation+this.pdfPageRotate)%360;if(this.viewport=this.viewport.clone({scale:this.scale*Jn.PDF_TO_CSS_UNITS,rotation:n}),this.#xh(),this._isStandalone&&this._container?.style.setProperty("--scale-factor",this.viewport.scale),this.#Rh(),this.canvas){const t=this.#uh&&this.#gh,e=s>=0&&s<1e3;if(e||t)return e&&!t&&this.renderingState!==ga.FINISHED&&(this.cancelRendering({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:s}),this.renderingState=ga.FINISHED,this.#Ah.directDrawing=!1),this.cssTransform({redrawAnnotationLayer:!0,redrawAnnotationEditorLayer:!0,redrawXfaLayer:!0,redrawTextLayer:!e,hideTextLayer:e}),void(e||(this.detailView?.update({underlyingViewUpdated:!0}),this.dispatchPageRendered(!0,!1)))}this.cssTransform({}),this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0,preserveDetailViewState:!0}),this.detailView?.update({underlyingViewUpdated:!0})}#Rh(){const{width:t,height:e}=this.viewport,i=this.outputScale=new qn;if(0===this.maxCanvasPixels){const t=1/this.scale;i.sx*=t,i.sy*=t,this.#gh=!0}else this.#gh=i.limitCanvas(t,e,this.maxCanvasPixels,this.maxCanvasDim)}cancelRendering({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:s=!1,cancelExtraDelay:n=0}={}){super.cancelRendering({cancelExtraDelay:n}),!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:a}=this;if(!a)return;const r=this.#fh;if(this.viewport!==r){const t=(360+this.viewport.rotation-r.rotation)%360;if(90===t||270===t){const{width:e,height:i}=this.viewport,s=i/e,n=e/i;a.style.transform=`rotate(${t}deg) scale(${s},${n})`}else a.style.transform=0===t?"":`rotate(${t}deg)`}t&&this.annotationLayer&&this.#Eh(),e&&this.annotationEditorLayer&&(this.drawLayer&&this.#Th(),this.#Ph()),i&&this.xfaLayer&&this.#Mh(),this.textLayer&&(n?(this.textLayer.hide(),this.structTreeLayer?.hide()):s&&this.#kh())}get width(){return this.viewport.width}get height(){return this.viewport.height}getPagePoint(t,e){return this.viewport.convertToPdfPoint(t,e)}_ensureCanvasWrapper(){let t=this.#dh;return t||(t=this.#dh=document.createElement("div"),t.classList.add("canvasWrapper"),this.#Sh(t,"canvasWrapper")),t}_getRenderingContext(t,e){return{canvasContext:t,transform:e,viewport:this.viewport,annotationMode:this.#hh,optionalContentConfigPromise:this._optionalContentConfigPromise,annotationCanvasMap:this._annotationCanvasMap,pageColors:this.pageColors,isEditing:this.#Ee}}async draw(){this.renderingState!==ga.INITIAL&&(console.error("Must be in new state before drawing"),this.reset());const{div:t,l10n:e,pdfPage:i,viewport:s}=this;if(!i)throw this.renderingState=ga.FINISHED,new Error("pdfPage is not loaded");this.renderingState=ga.RUNNING;const n=this._ensureCanvasWrapper();if(this.textLayer||this.#wh===wa||i.isPureXfa||(this._accessibilityManager||=new el,this.textLayer=new sl({pdfPage:i,highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,enablePermissions:this.#wh===Aa,onAppend:t=>{this.l10n.pause(),this.#Sh(t,"textLayer"),this.l10n.resume()}})),!this.annotationLayer&&this.#hh!==xn.DISABLE){const{annotationStorage:t,annotationEditorUIManager:e,downloadManager:s,enableScripting:n,fieldObjectsPromise:a,hasJSActionsPromise:r,linkService:o}=this.#ph;this._annotationCanvasMap||=new Map,this.annotationLayer=new dr({pdfPage:i,annotationStorage:t,imageResourcesPath:this.imageResourcesPath,renderForms:this.#hh===xn.ENABLE_FORMS,linkService:o,downloadManager:s,enableScripting:n,hasJSActionsPromise:r,fieldObjectsPromise:a,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager,annotationEditorUIManager:e,onAppend:t=>{this.#Sh(t,"annotationLayer")}})}const{width:a,height:r}=s;this.#fh=s;const{canvas:o,prevCanvas:l,ctx:h}=this._createCanvas((t=>{n.prepend(t)}));o.setAttribute("role","presentation"),this.outputScale||this.#Rh();const{outputScale:d}=this;this.#uh=this.#gh;const c=Ma(d.sx),u=Ma(d.sy),p=o.width=Ia(Ra(a*d.sx),c[0]),g=o.height=Ia(Ra(r*d.sy),u[0]),f=Ia(Ra(a),c[1]),m=Ia(Ra(r),u[1]);d.sx=p/f,d.sy=g/m,this.#bh!==c[1]&&(t.style.setProperty("--scale-round-x",`${c[1]}px`),this.#bh=c[1]),this.#vh!==u[1]&&(t.style.setProperty("--scale-round-y",`${u[1]}px`),this.#vh=u[1]);const b=d.scaled?[d.sx,0,0,d.sy,0,0]:null,v=this._drawCanvas(this._getRenderingContext(h,b),(()=>{l?.remove(),this._resetCanvas()}),(t=>{this.#Ah.regularAnnotations=!t.separateAnnots,this.dispatchPageRendered(!1,!1)})).then((async()=>{this.structTreeLayer||=new tl(i,s.rawDims);const t=this.#kh();this.annotationLayer&&(await this.#Eh(),this.#ch&&this.annotationLayer&&this.textLayer&&await this.#Dh(t));const{annotationEditorUIManager:a}=this.#ph;a&&(this.drawLayer||=new Yo({pageIndex:this.id}),await this.#Th(),this.drawLayer.setParent(n),this.annotationEditorLayer||=new Ro({uiManager:a,pdfPage:i,l10n:e,structTreeLayer:this.structTreeLayer,accessibilityManager:this._accessibilityManager,annotationLayer:this.annotationLayer?.annotationLayer,textLayer:this.textLayer,drawLayer:this.drawLayer.getDrawLayer(),onAppend:t=>{this.#Sh(t,"annotationEditorLayer")}}),this.#Ph())}));if(i.isPureXfa){if(!this.xfaLayer){const{annotationStorage:t,linkService:e}=this.#ph;this.xfaLayer=new nl({pdfPage:i,annotationStorage:t,linkService:e})}this.#Mh()}return t.setAttribute("data-loaded",!0),this.dispatchPageRender(),v}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.#Ah;return t&&e&&i?this.canvas:null}}class ll{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 hl{#Nh=null;#Fh=null;#Oh=null;#ml=null;#Pa=null;#Bh=null;#jh=null;#Vh=null;#Hh=!1;#Uh=null;#zh=null;constructor({eventBus:t,externalServices:e=null,docProperties:i=null}){this.#Pa=t,this.#Bh=e,this.#Oh=i}setViewer(t){this.#Vh=t}async setDocument(t){if(this.#jh&&await this.#$h(),this.#jh=t,!t)return;const[e,i,s]=await Promise.all([t.getFieldObjects(),t.getCalculationOrderIds(),t.getJSActions()]);if(!e&&!s)return void await this.#$h();if(t!==this.#jh)return;try{this.#Uh=this.#Wh()}catch(t){return console.error("setDocument:",t),void await this.#$h()}const n=this.#Pa;this.#ml=new AbortController;const{signal:a}=this.#ml;n._on("updatefromsandbox",(t=>{t?.source===window&&this.#Gh(t.detail)}),{signal:a}),n._on("dispatcheventinsandbox",(t=>{this.#Uh?.dispatchEventInSandbox(t.detail)}),{signal:a}),n._on("pagechanging",(({pageNumber:t,previous:e})=>{t!==e&&(this.#qh(e),this.#Xh(t))}),{signal:a}),n._on("pagerendered",(({pageNumber:t})=>{this._pageOpenPending.has(t)&&t===this.#Vh.currentPageNumber&&this.#Xh(t)}),{signal:a}),n._on("pagesdestroy",(async()=>{await this.#qh(this.#Vh.currentPageNumber),await(this.#Uh?.dispatchEventInSandbox({id:"doc",name:"WillClose"})),this.#Nh?.resolve()}),{signal:a});try{const a=await this.#Oh(t);if(t!==this.#jh)return;await this.#Uh.createSandbox({objects:e,calculationOrder:i,appInfo:{platform:navigator.platform,language:navigator.language},docInfo:{...a,actions:s}}),n.dispatch("sandboxcreated",{source:this})}catch(t){return console.error("setDocument:",t),void await this.#$h()}await(this.#Uh?.dispatchEventInSandbox({id:"doc",name:"Open"})),await this.#Xh(this.#Vh.currentPageNumber,!0),Promise.resolve().then((()=>{t===this.#jh&&(this.#Hh=!0)}))}async dispatchWillSave(){return this.#Uh?.dispatchEventInSandbox({id:"doc",name:"WillSave"})}async dispatchDidSave(){return this.#Uh?.dispatchEventInSandbox({id:"doc",name:"DidSave"})}async dispatchWillPrint(){if(this.#Uh){await(this.#zh?.promise),this.#zh=Promise.withResolvers();try{await this.#Uh.dispatchEventInSandbox({id:"doc",name:"WillPrint"})}catch(t){throw this.#zh.resolve(),this.#zh=null,t}await this.#zh.promise}}async dispatchDidPrint(){return this.#Uh?.dispatchEventInSandbox({id:"doc",name:"DidPrint"})}get destroyPromise(){return this.#Fh?.promise||null}get ready(){return this.#Hh}get _pageOpenPending(){return sa(this,"_pageOpenPending",new Set)}get _visitedPages(){return sa(this,"_visitedPages",new Map)}async#Gh(t){const e=this.#Vh,i=e.isInPresentationMode||e.isChangingPresentationMode,{id:s,siblings:n,command:a,value:r}=t;if(!s){switch(a){case"clear":console.clear();break;case"error":console.error(r);break;case"layout":if(!i){const t=function(t){let e=_a.VERTICAL,i=xa.NONE;switch(t){case"SinglePage":e=_a.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=_a.PAGE;case"TwoColumnLeft":i=xa.ODD;break;case"TwoPageRight":e=_a.PAGE;case"TwoColumnRight":i=xa.EVEN}return{scrollMode:e,spreadMode:i}}(r);e.spreadMode=t.spreadMode}break;case"page-num":e.currentPageNumber=r+1;break;case"print":await e.pagesPromise,this.#Pa.dispatch("print",{source:this});break;case"println":console.log(r);break;case"zoom":i||(e.currentScaleValue=r);break;case"SaveAs":this.#Pa.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.#zh?.resolve(),this.#zh=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.#jh?.annotationStorage.setValue(e,t)}}async#Xh(t,e=!1){const i=this.#jh,s=this._visitedPages;if(e&&(this.#Nh=Promise.withResolvers()),!this.#Nh)return;const n=this.#Vh.getPageView(t-1);if(n?.renderingState!==ga.FINISHED)return void this._pageOpenPending.add(t);this._pageOpenPending.delete(t);const a=(async()=>{const e=await(s.has(t)?null:n.pdfPage?.getJSActions());i===this.#jh&&await(this.#Uh?.dispatchEventInSandbox({id:"page",name:"PageOpen",pageNumber:t,actions:e}))})();s.set(t,a)}async#qh(t){const e=this.#jh,i=this._visitedPages;if(!this.#Nh)return;if(this._pageOpenPending.has(t))return;const s=i.get(t);s&&(i.set(t,null),await s,e===this.#jh&&await(this.#Uh?.dispatchEventInSandbox({id:"page",name:"PageClose",pageNumber:t})))}#Wh(){if(this.#Fh=Promise.withResolvers(),this.#Uh)throw new Error("#initScripting: Scripting already exists.");return this.#Bh.createScripting()}async#$h(){if(!this.#Uh)return this.#jh=null,void this.#Fh?.resolve();this.#Nh&&(await Promise.race([this.#Nh.promise,new Promise((t=>{setTimeout(t,1e3)}))]).catch((()=>{})),this.#Nh=null),this.#jh=null;try{await this.#Uh.destroySandbox()}catch{}this.#zh?.reject(new Error("Scripting destroyed.")),this.#zh=null,this.#ml?.abort(),this.#ml=null,this._pageOpenPending.clear(),this._visitedPages.clear(),this.#Uh=null,this.#Hh=!1,this.#Fh?.resolve()}}let dl=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,n=!1){const a=t.views,r=a.length;if(0===r)return null;for(let t=0;t<r;t++){const e=a[t].view;if(!this.isViewFinished(e))return e}if(!n)for(let t=0;t<r;t++){const{detailView:e}=a[t].view;if(e&&!this.isViewFinished(e))return e}const o=t.first.id,l=t.last.id;if(l-o+1>r){const s=t.ids;for(let t=1,n=l-o;t<n;t++){const n=i?o+t:l-t;if(s.has(n))continue;const a=e[n-1];if(!this.isViewFinished(a))return a}}let h=i?l:o-2,d=e[h];return d&&!this.isViewFinished(d)||s&&(h+=i?1:-1,d=e[h],d&&!this.isViewFinished(d))?d:null}isViewFinished(t){return t.renderingState===ga.FINISHED}renderView(t){switch(t.renderingState){case ga.FINISHED:return!1;case ga.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case ga.RUNNING:this.highestPriorityPage=t.renderingId;break;case ga.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally((()=>{this.renderHighestPriority()})).catch((t=>{t instanceof ta||console.error("renderView:",t)}))}return!0}};const cl=1e4,ul=5e3,pl=250;function gl(t){return Object.values(yn).includes(t)&&t!==yn.DISABLE}class fl{#Kh=new Set;#Yh=0;constructor(t){this.#Yh=t}push(t){const e=this.#Kh;e.has(t)&&e.delete(t),e.add(t),e.size>this.#Yh&&this.#Qh()}resize(t,e=null){this.#Yh=t;const i=this.#Kh;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.#Yh;)this.#Qh()}has(t){return this.#Kh.has(t)}[Symbol.iterator](){return this.#Kh.keys()}#Qh(){const t=this.#Kh.keys().next().value;t?.destroy(),this.#Kh.delete(t)}}class ml{#Zh=null;#D=null;#Jh=null;#td=yn.NONE;#ed=null;#hh=xn.ENABLE_FORMS;#id=null;#sd=null;#ui=!1;#$=!1;#ih=!1;#W=!1;#G=!1;#ch=!0;#ml=null;#rt=null;#nd=null;#ad=null;#rd=null;#od=!1;#ld=null;#hd=!1;#dd=0;#cd=new ResizeObserver(this.#ud.bind(this));#pd=null;#gd=null;#dt=null;#fd=!0;#wh=ya;constructor(t){const e="5.2.133";if(ua!==e)throw new Error(`The API version "${ua}" 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.#cd.observe(this.container),this.eventBus=t.eventBus,this.linkService=t.linkService||new hr,this.downloadManager=t.downloadManager||null,this.findController=t.findController||null,this.#D=t.altTextManager||null,this.#dt=t.signatureManager||null,this.#sd=t.editorUndoBar||null,this.findController&&(this.findController.onIsPageVisible=t=>this._getVisiblePages().ids.has(t)),this._scriptingManager=t.scriptingManager||null,this.#wh=t.textLayerMode??ya,this.#hh=t.annotationMode??xn.ENABLE_FORMS,this.#td=t.annotationEditorMode??yn.NONE,this.#Jh=t.annotationEditorHighlightColors||null,this.#$=!0===t.enableHighlightFloatingButton,this.#W=!0===t.enableUpdatedAddImage,this.#G=!0===t.enableNewAltTextWhenAddingImage,this.imageResourcesPath=t.imageResourcesPath||"",this.enablePrintAutoRotate=t.enablePrintAutoRotate||!1,this.removePageBorders=t.removePageBorders||!1,this.maxCanvasPixels=t.maxCanvasPixels,this.maxCanvasDim=t.maxCanvasDim,this.enableDetailCanvas=t.enableDetailCanvas??!0,this.l10n=t.l10n,this.l10n||=new Lo,this.#ih=t.enablePermissions||!1,this.pageColors=t.pageColors||null,this.#rt=t.mlManager||null,this.#ui=t.enableHWA||!1,this.#fd=!1!==t.supportsPinchToZoom,this.#ch=!1!==t.enableAutoLinking,this.defaultRenderingQueue=!t.renderingQueue,this.defaultRenderingQueue?(this.renderingQueue=new dl,this.renderingQueue.setViewer(this)):this.renderingQueue=t.renderingQueue;const{abortSignal:i}=t;i?.addEventListener("abort",(()=>{this.#cd.disconnect(),this.#cd=null}),{once:!0}),this.scroll=function(t,e,i){const s=function(i){a||(a=window.requestAnimationFrame((function(){a=null;const i=t.scrollLeft,s=n.lastX;i!==s&&(n.right=i>s),n.lastX=i;const r=t.scrollTop,o=n.lastY;r!==o&&(n.down=r>o),n.lastY=r,e(n)})))},n={right:!0,down:!0,lastX:t.scrollLeft,lastY:t.scrollTop,_eventHandler:s};let a=null;return t.addEventListener("scroll",s,{useCapture:!0,signal:i}),i?.addEventListener("abort",(()=>window.cancelAnimationFrame(a)),{once:!0}),n}(this.container,this._scrollUpdate.bind(this),i),this.presentationModeState=fa,this._resetView(),this.removePageBorders&&this.viewer.classList.add("removePageBorders"),this.#md(),this.eventBus._on("thumbnailrendered",(({pageNumber:t,pdfPage:e})=>{const i=this._pages[t-1];this.#Zh.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.#Zh)}get pageViewsReady(){return this._pages.every((t=>t?.pdfPage))}get renderForms(){return this.#hh===xn.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.#bd(),!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.#bd(),!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.#vd(t,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(t){this.pdfDocument&&this.#vd(t,{noScroll:!1})}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!ka(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.#vd(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 sa(this,"_layerProperties",{get annotationEditorUIManager(){return t.#ed},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}})}#wd(t){const e={annotationEditorMode:this.#td,annotationMode:this.#hh,textLayerMode:this.#wh};return t?(t.includes(Zn.COPY)||this.#wh!==ya||(e.textLayerMode=Aa),t.includes(Zn.MODIFY_CONTENTS)||(e.annotationEditorMode=yn.DISABLE),t.includes(Zn.MODIFY_ANNOTATIONS)||t.includes(Zn.FILL_INTERACTIVE_FORMS)||this.#hh!==xn.ENABLE_FORMS||(e.annotationMode=xn.ENABLE),e):e}async#yd(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:AbortSignal.any([t,i.signal])}),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.#hd)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(Pa(e.join("")))}return t.join("\n")}#Ad(t,e){const i=document.getSelection(),{focusNode:s,anchorNode:n}=i;if(n&&s&&i.containsNode(this.#ld)){if(this.#od||t===Aa)return void aa(e);this.#od=!0;const{classList:i}=this.viewer;i.add("copyAll");const s=new AbortController;window.addEventListener("keydown",(t=>this.#hd="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.#od=!1,this.#hd=!1,s.abort(),i.remove("copyAll")})),aa(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.#ed?.destroy(),this.#ed=null),this.pdfDocument=t,!t)return;const e=t.numPages,i=t.getPage(1),s=t.getOptionalContentConfig({intent:"display"}),n=this.#ih?t.getPermissions():Promise.resolve(),{eventBus:a,pageColors:r,viewer:o}=this;this.#ml=new AbortController;const{signal:l}=this.#ml;if(e>cl){console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");const t=this._scrollMode=_a.PAGE;a.dispatch("scrollmodechanged",{source:this,mode:t})}this._pagesCapability.promise.then((()=>{a.dispatch("pagesloaded",{source:this,pagesCount:e})}),(()=>{}));a._on("pagerender",(t=>{const e=this._pages[t.pageNumber-1];e&&this.#Zh.push(e)}),{signal:l});const h=t=>{t.cssTransform||t.isDetailView||(this._onePageRenderedCapability.resolve({timestamp:t.timestamp}),a._off("pagerendered",h))};a._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.#wd(n);if(c!==wa){const t=this.#ld=document.createElement("div");t.id="hiddenCopyElement",o.before(t)}if(h!==yn.DISABLE){const e=h;t.isPureXfa?console.warn("Warning: XFA-editing is not implemented."):gl(e)?(this.#ed=new An(this.container,o,this.#D,this.#dt,a,t,r,this.#Jh,this.#$,this.#W,this.#G,this.#rt,this.#sd,this.#fd),a.dispatch("annotationeditoruimanager",{source:this,uiManager:this.#ed}),e!==yn.NONE&&(this.#_d(e),this.#ed.updateMode(e))):console.error(`Invalid AnnotationEditor mode: ${e}`)}const u=this._scrollMode===_a.PAGE?null:o,p=this.currentScale,g=i.getViewport({scale:p*Jn.PDF_TO_CSS_UNITS});o.style.setProperty("--scale-factor",g.scale),r?.background&&o.style.setProperty("--page-bg-color",r.background),"CanvasText"!==r?.foreground&&"Canvas"!==r?.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 ol({container:u,eventBus:a,id:t,scale:p,defaultViewport:g.clone(),optionalContentConfigPromise:s,renderingQueue:this.renderingQueue,textLayerMode:c,annotationMode:d,imageResourcesPath:this.imageResourcesPath,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,enableDetailCanvas:this.enableDetailCanvas,pageColors:r,l10n:this.l10n,layerProperties:this._layerProperties,enableHWA:this.#ui,enableAutoLinking:this.#ch});this._pages.push(e)}this._pages[0]?.setPdfPage(i),this._scrollMode===_a.PAGE?this.#xd():this._spreadMode!==xa.NONE&&this._updateSpreadMode(),this.#yd(l).then((async()=>{if(t!==this.pdfDocument)return;if(this.findController?.setDocument(t),this._scriptingManager?.setDocument(t),this.#ld&&document.addEventListener("copy",this.#Ad.bind(this,c),{signal:l}),this.#ed&&a.dispatch("annotationeditormodechanged",{source:this,mode:this.#td}),t.loadingParams.disableAutoFetch||e>ul)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%pl==0&&await e}})),a.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.#Zh=new fl(10),this._location=null,this._pagesRotation=0,this._optionalContentConfigPromise=null,this._firstPageCapability=Promise.withResolvers(),this._onePageRenderedCapability=Promise.withResolvers(),this._pagesCapability=Promise.withResolvers(),this._scrollMode=_a.VERTICAL,this._previousScrollMode=_a.UNKNOWN,this._spreadMode=xa.NONE,this.#pd={previousPageNumber:1,scrollDown:!0,pages:[]},this.#ml?.abort(),this.#ml=null,this.viewer.textContent="",this._updateScrollMode(),this.viewer.removeAttribute("lang"),this.#ld?.remove(),this.#ld=null,this.#Sd(),this.#Cd()}#xd(){if(this._scrollMode!==_a.PAGE)throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");const t=this._currentPageNumber,e=this.#pd,i=this.viewer;if(i.textContent="",e.pages.length=0,this._spreadMode!==xa.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 a=document.createElement("div");if(a.className="spread",this.isInPresentationMode){const t=document.createElement("div");t.className="dummyPage",a.append(t)}for(const t of s){const i=this._pages[t];i&&(a.append(i.div),e.pages.push(i))}i.append(a)}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.#nd&&clearTimeout(this.#nd),this.#nd=setTimeout((()=>{this.#nd=null,this.update()}),100),this.update())}#Ed(t,e=null){const{div:i,id:s}=t;if(this._currentPageNumber!==s&&this._setCurrentPageNumber(s),this._scrollMode===_a.PAGE&&(this.#xd(),this.update()),!e&&!this.isInPresentationMode){const t=i.offsetLeft+i.clientLeft,s=t+i.clientWidth,{scrollLeft:n,clientWidth:a}=this.container;(this._scrollMode===_a.HORIZONTAL||t<n||s>n+a)&&(e={left:0,top:0})}Sa(i,e),!this._currentScaleValue&&this._location&&(this._location=null)}#Pd(t){return t===this._currentScale||Math.abs(t-this._currentScale)<1e-15}#Td(t,e,{noScroll:i=!1,preset:s=!1,drawingDelay:n=-1,origin:a=null}){if(this._currentScaleValue=e.toString(),this.#Pd(t))return void(s&&this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:e}));this.viewer.style.setProperty("--scale-factor",t*Jn.PDF_TO_CSS_UNITS);const r=n>=0&&n<1e3;this.refresh(!0,{scale:t,drawingDelay:r?n:-1}),r&&(this.#gd=setTimeout((()=>{this.#gd=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(a)){const e=t/o-1,[i,s]=this.containerTopLeft;this.container.scrollLeft+=(a[0]-s)*e,this.container.scrollTop+=(a[1]-i)*e}}this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:s?e:void 0}),this.defaultRenderingQueue&&this.update()}get#Md(){return this._spreadMode!==xa.NONE&&this._scrollMode!==_a.HORIZONTAL?2:1}#vd(t,e){let i=parseFloat(t);if(i>0)e.preset=!1,this.#Td(i,t,e);else{const s=this._pages[this._currentPageNumber-1];if(!s)return;let n=40,a=5;this.isInPresentationMode?(n=a=4,this._spreadMode!==xa.NONE&&(n*=2)):this.removePageBorders?n=a=0:this._scrollMode===_a.HORIZONTAL&&([n,a]=[a,n]);const r=(this.container.clientWidth-n)/s.width*s.scale/this.#Md,o=(this.container.clientHeight-a)/s.height*s.scale;switch(t){case"page-actual":i=1;break;case"page-width":i=r;break;case"page-height":i=o;break;case"page-fit":i=Math.min(r,o);break;case"auto":const e=La(s)?r:Math.min(o,r);i=Math.min(1.25,e);break;default:return void console.error(`#setScale: "${t}" is an unknown zoom value.`)}e.preset=!0,this.#Td(i,t,e)}}#bd(){const t=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&this.#vd(this._currentScaleValue,{noScroll:!0}),this.#Ed(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 a,r,o=0,l=0,h=0,d=0;const c=n.rotation%180!=0,u=(c?n.height:n.width)/n.scale/Jn.PDF_TO_CSS_UNITS,p=(c?n.width:n.height)/n.scale/Jn.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),a=(this.container.clientWidth-t)/h/Jn.PDF_TO_CSS_UNITS,r=(this.container.clientHeight-i)/d/Jn.PDF_TO_CSS_UNITS,g=Math.min(Math.abs(a),Math.abs(r));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.#Ed(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.#Ed(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,a=this._pages[n-1],r=this.container,o=a.getPagePoint(r.scrollLeft-t.x,r.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.#Zh.resize(s,t.ids);for(const{view:t,visibleArea:i}of e)t.updateVisibleArea(i);for(const e of this.#Zh)t.ids.has(e.id)||e.updateVisibleArea(null);this.renderingQueue.renderHighestPriority(t);const n=this._spreadMode===xa.NONE&&(this._scrollMode===_a.PAGE||this._scrollMode===_a.VERTICAL),a=this._currentPageNumber;let r=!1;for(const t of e){if(t.percent<100)break;if(t.id===a&&n){r=!0;break}}this._setCurrentPageNumber(r?a:e[0].id),this._updateLocation(t.first),this.eventBus.dispatch("updateviewarea",{source:this,location:this._location})}#Id(){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===va}get isChangingPresentationMode(){return this.presentationModeState===ba}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===_a.PAGE?this.#pd.pages:this._pages,e=this._scrollMode===_a.HORIZONTAL,i=e&&this._isContainerRtl;return function({scrollEl:t,views:e,sortByVisibility:i=!1,horizontal:s=!1,rtl:n=!1}){const a=t.scrollTop,r=a+t.clientHeight,o=t.scrollLeft,l=o+t.clientWidth,h=[],d=new Set,c=e.length;let u=Ta(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>a});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,a));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>=r&&(p=b);else if((s?c:u)>p)break;if(b<=a||u>=r||m<=o||c>=l)continue;const v=Math.max(0,a-u),w=Math.max(0,o-c),y=v+Math.max(0,b-r),A=(g-(w+Math.max(0,m-l)))/g,_=(f-y)/f*A*100|0;h.push({id:i.id,x:c,y:u,visibleArea:100===_?null:{minX:w,minY:v,maxX:Math.min(m,l)-c,maxY:Math.min(b,r)-u},view:i,percent:_,widthPercent:100*A|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!==ga.FINISHED&&t.reset()}_cancelRendering(){for(const t of this._pages)t.cancelRendering()}async#kd(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}}#Ld(t){if(1===t.first?.id)return!0;if(t.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case _a.PAGE:return this.#pd.scrollDown;case _a.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(t){const e=t||this._getVisiblePages(),i=this.#Ld(e),s=this._spreadMode!==xa.NONE&&this._scrollMode!==_a.HORIZONTAL,n=null!==this.#gd||null!==this.#nd&&e.views.some((t=>t.detailView?.renderingCancelled)),a=this.renderingQueue.getHighestPriority(e,this._pages,i,s,n);return!!a&&(this.#kd(a).then((()=>{this.renderingQueue.renderView(a)})),!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=La(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(_a).includes(t)&&t!==_a.UNKNOWN}(t))throw new Error(`Invalid scroll mode: ${t}`);this.pagesCount>cl||(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===_a.HORIZONTAL),i.classList.toggle("scrollWrapped",e===_a.WRAPPED),this.pdfDocument&&t&&(e===_a.PAGE?this.#xd():this._previousScrollMode===_a.PAGE&&this._updateSpreadMode(),this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#vd(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(xa).includes(t)&&t!==xa.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===_a.PAGE)this.#xd();else if(e.textContent="",this._spreadMode===xa.NONE)for(const t of this._pages)e.append(t.div);else{const t=this._spreadMode-1;let s=null;for(let n=0,a=i.length;n<a;++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.#vd(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}_getPageAdvance(t,e=!1){switch(this._scrollMode){case _a.WRAPPED:{const{views:i}=this._getVisiblePages(),s=new Map;for(const{id:t,y:e,percent:n,widthPercent:a}of i){if(0===n||a<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,a=n;e<a;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 _a.HORIZONTAL:break;case _a.PAGE:case _a.VERTICAL:{if(this._spreadMode===xa.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=zn(n,.1,10),this.#vd(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)})}#md(t=this.container.clientHeight){t!==this.#dd&&(this.#dd=t,Da.setProperty("--viewer-container-height",`${t}px`))}#ud(t){for(const e of t)if(e.target===this.container){this.#md(Math.floor(e.borderBoxSize[0].blockSize)),this.#id=null;break}}get containerTopLeft(){return this.#id||=[this.container.offsetTop,this.container.offsetLeft]}#Sd(){null!==this.#gd&&(clearTimeout(this.#gd),this.#gd=null),null!==this.#nd&&(clearTimeout(this.#nd),this.#nd=null)}#Cd(){this.#ad?.abort(),this.#ad=null,null!==this.#rd&&(clearTimeout(this.#rd),this.#rd=null)}#_d(t){switch(t){case yn.STAMP:this.#rt?.loadModel("altText");break;case yn.SIGNATURE:this.#dt?.loadSignatures()}}get annotationEditorMode(){return this.#ed?this.#td:yn.DISABLE}set annotationEditorMode({mode:t,editId:e=null,isFromKeyboard:i=!1}){if(!this.#ed)throw new Error("The AnnotationEditor is not enabled.");if(this.#td===t)return;if(!gl(t))throw new Error(`Invalid AnnotationEditor mode: ${t}`);if(!this.pdfDocument)return;this.#_d(t);const{eventBus:s,pdfDocument:n}=this,a=async()=>{this.#Cd(),this.#td=t,await this.#ed.updateMode(t,e,i),t===this.#td&&n===this.pdfDocument&&s.dispatch("annotationeditormodechanged",{source:this,mode:t})};if(t===yn.NONE||this.#td===yn.NONE){const e=t!==yn.NONE;e||this.pdfDocument.annotationStorage.resetModifiedIds();for(const t of this._pages)t.toggleEditingMode(e);const i=this.#Id();if(e&&i){this.#Cd(),this.#ad=new AbortController;const t=AbortSignal.any([this.#ml.signal,this.#ad.signal]);return void s._on("pagerendered",(({pageNumber:t})=>{i.delete(t),0===i.size&&(this.#rd=setTimeout(a,0))}),{signal:t})}}a()}refresh(t=!1,e=Object.create(null)){if(this.pdfDocument){for(const t of this._pages)t.update(e);this.#Sd(),t||this.update()}}}class bl extends ml{_resetView(){super._resetView(),this._scrollMode=_a.PAGE,this._spreadMode=xa.NONE}set scrollMode(t){}_updateScrollMode(){}set spreadMode(t){}_updateSpreadMode(){}}function vl(t,e,i,s){return new(i||(i=Promise))((function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(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(r,o)}l((s=s.apply(t,e||[])).next())}))}function wl(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 yl(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}var Al,_l,xl,Sl,Cl;globalThis.pdfjsViewer={AnnotationLayerBuilder:dr,DownloadManager:ur,EventBus:fr,FindState:Wa,GenericL10n:Lo,LinkTarget:or,parseQueryString:Ca,PDFFindController:rr,PDFHistory:class{#ml=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.#Dd();const n=window.history.state;if(this._popStateInProgress=!1,this._blockHashChange=0,this._currentHash=Do(),this._numPositionUpdates=0,this._uid=this._maxUid=0,this._destination=null,this._position=null,!this.#Rd(n,!0)||e){const{hash:t,page:i,rotation:n}=this.#Nd(!0);return!t||s||e?void this.#Fd(null,!0):void this.#Fd({hash:t,page:i,rotation:n},!0)}const a=n.destination;this.#Od(a,n.uid,!0),void 0!==a.rotation&&(this._initialRotation=a.rotation),a.dest?(this._initialBookmark=JSON.stringify(a.dest),this._destination.page=null):a.hash?this._initialBookmark=a.hash:a.page&&(this._initialBookmark=`page=${a.page}`)}reset(){this._initialized&&(this.#Bd(),this._initialized=!1,this.#jd()),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.#Vd(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(Ca(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.#Fd({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.#Vd(t)?this._destination?.page!==t&&(this._popStateInProgress||(this.#Fd({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.#Hd()}back(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#Rd(t)&&t.uid>0&&window.history.back()}forward(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#Rd(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}#Fd(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.#Od(t,s.uid),this._updateUrl&&t?.hash){const{href:e,protocol:i}=document.location;"file:"!==i&&(n=ha(e,t.hash))}i?window.history.replaceState(s,"",n):window.history.pushState(s,"",n)}#Hd(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.#Fd(e);if(this._destination.temporary)return void this.#Fd(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.#Fd(e,i)}#Vd(t){return Number.isInteger(t)&&t>0&&t<=this.linkService.pagesCount}#Rd(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)}#Od(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}#Nd(t=!1){const e=unescape(Do()).substring(1),i=Ca(e),s=i.get("nameddest")||"";let n=0|i.get("page");return(!this.#Vd(n)||t&&s.length>0)&&(n=null),{hash:e,page:n,rotation:this.linkService.rotation}}#Ud({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.#Hd(!0),this._updateViewareaTimeout=null}),1e3))}#zd({state:t}){const e=Do(),i=this._currentHash!==e;if(this._currentHash=e,!t){this._uid++;const{hash:t,page:e,rotation:i}=this.#Nd();return void this.#Fd({hash:t,page:e,rotation:i},!0)}if(!this.#Rd(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(),a=new AbortController;function r(t){a.abort(),clearTimeout(o),n(t)}t[t instanceof fr?"_on":"addEventListener"](e,r.bind(null,pr),{signal:a.signal});const o=setTimeout(r.bind(null,gr),i);return s}({target:window,name:"hashchange",delay:1e3}).then((()=>{this._blockHashChange--})));const s=t.destination;this.#Od(s,t.uid,!0),ka(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}))}#Bd(){this._destination&&!this._destination.temporary||this.#Hd()}#Dd(){if(this.#ml)return;this.#ml=new AbortController;const{signal:t}=this.#ml;this.eventBus._on("updateviewarea",this.#Ud.bind(this),{signal:t}),window.addEventListener("popstate",this.#zd.bind(this),{signal:t}),window.addEventListener("pagehide",this.#Bd.bind(this),{signal:t})}#jd(){this.#ml?.abort(),this.#ml=null}},PDFLinkService:lr,PDFPageView:ol,PDFScriptingManager:class extends hl{constructor(t){t.externalServices||window.addEventListener("updatefromsandbox",(e=>{t.eventBus.dispatch("updatefromsandbox",{source:window,detail:e.detail})})),t.externalServices||={createScripting:()=>new ll(t.sandboxBundleSrc)},t.docProperties||=t=>async function(t){const{info:e,metadata:i,contentDispositionFilename:s,contentLength:n}=await t.getMetadata();return{...e,baseURL:"",filesize:n||(await t.getDownloadInfo()).length,filename:s||Rn(""),metadata:i?.getRaw(),authors:i?.get("dc:creator"),numPages:t.numPages,URL:""}}(t),super(t)}},PDFSinglePageViewer:bl,PDFViewer:ml,ProgressBar:class{#$d=null;#Wd=null;#Gd=0;#qd=null;#Vi=!0;constructor(t){this.#$d=t.classList,this.#qd=t.style}get percent(){return this.#Gd}set percent(t){this.#Gd=zn(t,0,100),isNaN(t)?this.#$d.add("indeterminate"):(this.#$d.remove("indeterminate"),this.#qd.setProperty("--progressBar-percent",`${this.#Gd}%`))}setWidth(t){if(!t)return;const e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&this.#qd.setProperty("--progressBar-end-offset",`${e}px`)}setDisableAutoFetch(t=5e3){100===this.#Gd||isNaN(this.#Gd)||(this.#Wd&&clearTimeout(this.#Wd),this.show(),this.#Wd=setTimeout((()=>{this.#Wd=null,this.hide()}),t))}hide(){this.#Vi&&(this.#Vi=!1,this.#$d.add("hidden"))}show(){this.#Vi||(this.#Vi=!0,this.#$d.remove("hidden"))}},RenderingStates:ga,ScrollMode:_a,SimpleLinkService:hr,SpreadMode:xa,StructTreeLayerBuilder:tl,TextLayerBuilder:sl,XfaLayerBuilder:nl},"function"==typeof SuppressedError&&SuppressedError;const El={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},Pl={UNKNOWN:0,NORMAL:1,CHANGING:2,FULLSCREEN:3},Tl={UNKNOWN:-1,NONE:0,THUMBS:1,OUTLINE:2,ATTACHMENTS:3,LAYERS:4},Ml={DISABLE:0,ENABLE:1,ENABLE_PERMISSIONS:2},Il={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},kl={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};class Ll{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}}function Dl(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,a=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,a+=s.offsetLeft,s=s.offsetParent,!s)return;e&&(void 0!==e.top&&(n+=e.top),void 0!==e.left&&(a+=e.left,s.scrollLeft=a)),s.scrollTop=n}function Rl(t,e,i=void 0){const s=function(i){a||(a=window.requestAnimationFrame((function(){a=null;const i=t.scrollLeft,s=n.lastX;i!==s&&(n.right=i>s),n.lastX=i;const r=t.scrollTop,o=n.lastY;r!==o&&(n.down=r>o),n.lastY=r,e(n)})))},n={right:!0,down:!0,lastX:t.scrollLeft,lastY:t.scrollTop,_eventHandler:s};let a=null;return t.addEventListener("scroll",s,{useCapture:!0,signal:i}),null==i||i.addEventListener("abort",(()=>window.cancelAnimationFrame(a)),{once:!0}),n}const Nl=/[\x00-\x1F]/g;function Fl(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 Ol({view:t,userUnit:e,rotate:i}){const[s,n,a,r]=t,o=i%180!=0,l=(a-s)/72*e,h=(r-n)/72*e;return{width:o?h:l,height:o?l:h}}function Bl(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 jl({scrollEl:t,views:e,sortByVisibility:i=!1,horizontal:s=!1,rtl:n=!1}){const a=t.scrollTop,r=a+t.clientHeight,o=t.scrollLeft,l=o+t.clientWidth;const h=[],d=new Set,c=e.length;let u=Fl(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>a});u>0&&u<c&&!s&&(u=Bl(u,e,a));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>=r&&(p=b);else if((s?c:u)>p)break;if(b<=a||u>=r||m<=o||c>=l)continue;const v=Math.max(0,a-u)+Math.max(0,b-r),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 Vl(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 Hl(t){const e=t.deltaMode;let i=Vl(t);return e===WheelEvent.DOM_DELTA_PIXEL?i/=900:e===WheelEvent.DOM_DELTA_LINE&&(i/=30),i}function Ul(t){return Number.isInteger(t)&&t%90==0}function zl(t){return Number.isInteger(t)&&Object.values(Il).includes(t)&&t!==Il.UNKNOWN}function $l(t){return Number.isInteger(t)&&Object.values(kl).includes(t)&&t!==kl.UNKNOWN}function Wl(t){return t.width<=t.height}const Gl=new Promise((function(t){window.requestAnimationFrame(t)})),ql=document.documentElement.style;Al=new WeakMap,_l=new WeakMap,xl=new WeakMap,Sl=new WeakMap,Cl=new WeakMap;const Xl=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 Kl{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,a=n.length;if(0===a)return null;for(let t=0;t<a;t++){const e=n[t].view;if(!this.isViewFinished(e))return e}const r=t.first.id,o=t.last.id;if(o-r+1>a){const s=t.ids;for(let t=1,n=o-r;t<n;t++){const n=i?r+t:o-t;if(s.has(n))continue;const a=e[n-1];if(!this.isViewFinished(a))return a}}let l=i?o:r-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===El.FINISHED}renderView(t){switch(t.renderingState){case El.FINISHED:return!1;case El.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case El.RUNNING:this.highestPriorityPage=t.renderingId;break;case El.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally((()=>{this.renderHighestPriority()})).catch((t=>{t instanceof kt||console.error("renderView:",t)}))}return!0}}var Yl,Ql,Zl,Jl,th,eh,ih,sh;class nh{static getCanvas(t,e){const i=yl(this,Yl,wl(this,Yl,"f",Ql)||document.createElement("canvas"),0,Ql);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=wl(this,Yl,"f",Ql);t&&(t.width=0,t.height=0),yl(this,Yl,null,0,Ql)}}Yl=nh,Ql={value:null};class ah{constructor({container:t,eventBus:e,id:i,defaultViewport:s,optionalContentConfigPromise:n,linkService:a,renderingQueue:r,pageColors:o,enableHWA:l,store:h,thumbnailWidth:d}){Zl.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=a,this.renderingQueue=r,this.renderTask=null,this.renderingState=El.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,wl(this,Zl,"m",Jl).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=El.INITIAL,this.div.removeAttribute("data-loaded"),this.loaded=!1,wl(this,Zl,"m",Jl).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 vl(this,void 0,void 0,(function*(){if(this.renderingState!==El.INITIAL)return void console.error("Must be in new state before drawing");const{pdfPage:t}=this;if(!t)throw this.renderingState=El.FINISHED,new Error("pdfPage is not loaded");this.renderingState=El.RUNNING;const{ctx:e,canvas:i,transform:s}=wl(this,Zl,"m",th).call(this,2),n={canvasContext:e,transform:s,viewport:this.viewport.clone({scale:2*this.scale}),optionalContentConfigPromise:this._optionalContentConfigPromise,pageColors:this.pageColors},a=this.renderTask=t.render(n);a.onContinue=t=>{if(!this.renderingQueue.isHighestPriority(this))return this.renderingState=El.PAUSED,void(this.resume=()=>{this.renderingState=El.RUNNING,t()});t()};const r=a.promise.then((()=>wl(this,Zl,"m",ih).call(this,a,i)),(t=>wl(this,Zl,"m",ih).call(this,a,i,t)));return r.finally((()=>{i.width=0,i.height=0,this.eventBus.dispatch("thumbnailrendered",{source:this,pageNumber:this.id,pdfPage:this.pdfPage})})),r}))}setImage(t){if(this.renderingState!==El.INITIAL)return;const{thumbnailCanvas:e,pdfPage:i,scale:s}=t;e&&(this.pdfPage||this.setPdfPage(i),s<this.scale||(this.renderingState=El.FINISHED,wl(this,Zl,"m",eh).call(this,e)))}setPageLabel(t){this.pageLabel="string"==typeof t?t:null}}var rh,oh,lh,hh,dh,ch,uh;Zl=new WeakSet,Jl=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`)},th=function(t=1,e=this.enableHWA){const i=document.createElement("canvas"),s=i.getContext("2d",{alpha:!1,willReadFrequently:!e}),n=new Ll;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}},eh=function(t){if(this.renderingState!==El.FINISHED)throw new Error("#convertCanvasToImage: Rendering has not finished.");const e=wl(this,Zl,"m",sh).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},ih=function(t,e){return vl(this,arguments,void 0,(function*(t,e,i=null){if(t===this.renderTask&&(this.renderTask=null),!(i instanceof kt)&&(this.renderingState=El.FINISHED,wl(this,Zl,"m",eh).call(this,e),i))throw i}))},sh=function(t){const{ctx:e,canvas:i}=wl(this,Zl,"m",th).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[a,r]=nh.getCanvas(s,n);for(;s>t.width||n>t.height;)s>>=1,n>>=1;for(r.drawImage(t,0,0,t.width,t.height,0,0,s,n);s>2*i.width;)r.drawImage(a,0,0,s,n,0,0,s>>1,n>>1),s>>=1,n>>=1;return e.drawImage(a,0,0,s,n,0,0,i.width,i.height),i};const ph="selected";class gh{constructor({container:t,eventBus:e,linkService:i,renderingQueue:s,pageColors:n,abortSignal:a,enableHWA:r,store:o,thumbnailWidth:l}){rh.add(this),this.container=t,this.eventBus=e,this.linkService=i,this.renderingQueue=s,this.pageColors=n||null,this.enableHWA=r||!1,this.store=o,this.thumbnailWidth=l,this.scroll=Rl(this.container,wl(this,rh,"m",oh).bind(this),a),wl(this,rh,"m",hh).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(ph),e.div.classList.add(ph)}const{first:i,last:s,views:n}=wl(this,rh,"m",lh).call(this);if(n.length>0){let a=!1;if(t<=i.id||t>=s.id)a=!0;else for(const{id:e,percent:i}of n)if(e===t){a=i<100;break}a&&Dl(e.div,{top:-19})}this._currentPageNumber=t}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!Ul(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!==El.FINISHED&&t.reset();nh.destroyCanvas()}setDocument(t){if(this.pdfDocument&&(wl(this,rh,"m",dh).call(this),wl(this,rh,"m",hh).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,a=e.getViewport({scale:1});for(let t=1;t<=n;++t){const e=new ah({container:this.container,eventBus:this.eventBus,id:t,defaultViewport:a.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(ph),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=wl(this,rh,"m",lh).call(this),e=wl(this,rh,"m",uh).call(this,t),i=this.renderingQueue.getHighestPriority(t,this._thumbnails,e);return!!i&&(wl(this,rh,"m",ch).call(this,i).then((()=>{this.renderingQueue.renderView(i)})),!0)}}rh=new WeakSet,oh=function(){this.renderingQueue.renderHighestPriority()},lh=function(){return jl({scrollEl:this.container,views:this._thumbnails})},hh=function(){this._thumbnails=[],this._currentPageNumber=1,this._pageLabels=null,this._pagesRotation=0,this.container.textContent=""},dh=function(){for(const t of this._thumbnails)t.cancelRendering()},ch=function(t){return vl(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}}))},uh=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 fh=null;class mh{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(fh!==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,fh=null}renderPages(t){if(this.pdfDocument.isPureXfa)return function(t,e){const i=e.allXfaHtml,s=new hr,n=Math.round(100*Tt.PDF_TO_CSS_UNITS)/100;for(const a of null==i?void 0:i.children){const i=document.createElement("div");i.className="xfaPrintedPage",t.append(i);const r=new nl({pdfPage:null,annotationStorage:e.annotationStorage,linkService:s,xfaHtml:a}),o=Vt(a,{scale:n});r.render({viewport:o,intent:"print"}),i.append(r.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 a=this.currentPage;t({index:a,total:e}),function(t,e,i,s,n,a,r){const o=t.scratchCanvas,l=n/Tt.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),r]).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:k.ENABLE_STORAGE,optionalContentConfigPromise:a,printAnnotationStorage:e};return t.render(i).promise.catch((t=>{throw t instanceof kt||console.error(t),t}))}))}(this,this.pdfDocument,a+1,this.pagesOverview[a],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===fh}throwIfInactive(){if(!this.active)throw new Error("This print request was cancelled or completed.")}}const bh={instance:{supportsPrinting:!0,createPrintService(t){if(fh)throw new Error("The print service is created and active.");return fh=new mh(t)}}};var vh,wh,yh,Ah,_h,xh,Sh,Ch,Eh,Ph,Th,Mh,Ih,kh,Lh,Dh,Rh,Nh,Fh;const Oh="pdfPresentationMode",Bh="pdfPresentationModeControls",jh=Math.PI/6;class Vh{constructor({container:t,pdfViewer:e,eventBus:i}){vh.add(this),wh.set(this,Pl.UNKNOWN),yh.set(this,null),Ah.set(this,null),_h.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 vl(this,void 0,void 0,(function*(){const{container:t,pdfViewer:e}=this;if(this.active||!e.pagesCount||!t.requestFullscreen)return!1;wl(this,vh,"m",Nh).call(this),wl(this,vh,"m",Sh).call(this,Pl.CHANGING);const i=t.requestFullscreen();yl(this,yh,{pageNumber:e.currentPageNumber,scaleValue:e.currentScaleValue,scrollMode:e.scrollMode,spreadMode:null,annotationEditorMode:null}),e.spreadMode===kl.NONE||e.pageViewsReady&&e.hasEqualPageSizes||(console.warn("Ignoring Spread modes when entering PresentationMode, since the document may contain varying page sizes."),wl(this,yh,"f").spreadMode=e.spreadMode),e.annotationEditorMode!==L.DISABLE&&(wl(this,yh,"f").annotationEditorMode=e.annotationEditorMode);try{return yield i,e.focus(),!0}catch(t){wl(this,vh,"m",Fh).call(this),wl(this,vh,"m",Sh).call(this,Pl.NORMAL)}return!1}))}get active(){return wl(this,wh,"f")===Pl.CHANGING||wl(this,wh,"f")===Pl.FULLSCREEN}}wh=new WeakMap,yh=new WeakMap,Ah=new WeakMap,_h=new WeakMap,vh=new WeakSet,xh=function(t){if(!this.active)return;t.preventDefault();const e=Hl(t),i=Date.now(),s=this.mouseScrollTimeStamp;if(!(i>s&&i-s<50)&&((this.mouseScrollDelta>0&&e<0||this.mouseScrollDelta<0&&e>0)&&wl(this,vh,"m",kh).call(this),this.mouseScrollDelta+=e,Math.abs(this.mouseScrollDelta)>=.1)){const t=this.mouseScrollDelta;wl(this,vh,"m",kh).call(this);(t>0?this.pdfViewer.previousPage():this.pdfViewer.nextPage())&&(this.mouseScrollTimeStamp=i)}},Sh=function(t){yl(this,wh,t),this.eventBus.dispatch("presentationmodechanged",{source:this,state:t})},Ch=function(){var t;wl(this,vh,"m",Sh).call(this,Pl.FULLSCREEN),this.container.classList.add(Oh),setTimeout((()=>{this.pdfViewer.scrollMode=Il.PAGE,null!==wl(this,yh,"f").spreadMode&&(this.pdfViewer.spreadMode=kl.NONE),this.pdfViewer.currentPageNumber=wl(this,yh,"f").pageNumber,this.pdfViewer.currentScaleValue="page-fit",null!==wl(this,yh,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:L.NONE})}),0),wl(this,vh,"m",Dh).call(this),wl(this,vh,"m",Mh).call(this),this.contextMenuOpen=!1,null===(t=document.getSelection())||void 0===t||t.empty()},Eh=function(){const t=this.pdfViewer.currentPageNumber;this.container.classList.remove(Oh),setTimeout((()=>{wl(this,vh,"m",Fh).call(this),wl(this,vh,"m",Sh).call(this,Pl.NORMAL),this.pdfViewer.scrollMode=wl(this,yh,"f").scrollMode,null!==wl(this,yh,"f").spreadMode&&(this.pdfViewer.spreadMode=wl(this,yh,"f").spreadMode),this.pdfViewer.currentScaleValue=wl(this,yh,"f").scaleValue,this.pdfViewer.currentPageNumber=t,null!==wl(this,yh,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:wl(this,yh,"f").annotationEditorMode}),yl(this,yh,null)}),0),wl(this,vh,"m",Rh).call(this),wl(this,vh,"m",Ih).call(this),wl(this,vh,"m",kh).call(this),this.contextMenuOpen=!1},Ph=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()))},Th=function(){this.contextMenuOpen=!0},Mh=function(){this.controlsTimeout?clearTimeout(this.controlsTimeout):this.container.classList.add(Bh),this.controlsTimeout=setTimeout((()=>{this.container.classList.remove(Bh),delete this.controlsTimeout}),3e3)},Ih=function(){this.controlsTimeout&&(clearTimeout(this.controlsTimeout),this.container.classList.remove(Bh),delete this.controlsTimeout)},kh=function(){this.mouseScrollTimeStamp=0,this.mouseScrollDelta=0},Lh=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<=jh||n>=Math.PI-jh)?e=i:Math.abs(s)>50&&Math.abs(n-Math.PI/2)<=jh&&(e=s),e>0?this.pdfViewer.previousPage():e<0&&this.pdfViewer.nextPage()}},Dh=function(){if(wl(this,_h,"f"))return;yl(this,_h,new AbortController);const{signal:t}=wl(this,_h,"f"),e=wl(this,vh,"m",Lh).bind(this);window.addEventListener("mousemove",wl(this,vh,"m",Mh).bind(this),{signal:t}),window.addEventListener("mousedown",wl(this,vh,"m",Ph).bind(this),{signal:t}),window.addEventListener("wheel",wl(this,vh,"m",xh).bind(this),{passive:!1,signal:t}),window.addEventListener("keydown",wl(this,vh,"m",kh).bind(this),{signal:t}),window.addEventListener("contextmenu",wl(this,vh,"m",Th).bind(this),{signal:t}),window.addEventListener("touchstart",e,{signal:t}),window.addEventListener("touchmove",e,{signal:t}),window.addEventListener("touchend",e,{signal:t})},Rh=function(){var t;null===(t=wl(this,_h,"f"))||void 0===t||t.abort(),yl(this,_h,null)},Nh=function(){wl(this,Ah,"f")||(yl(this,Ah,new AbortController),window.addEventListener("fullscreenchange",(()=>{document.fullscreenElement?wl(this,vh,"m",Ch).call(this):wl(this,vh,"m",Eh).call(this)}),{signal:wl(this,Ah,"f").signal}))},Fh=function(){var t;null===(t=wl(this,Ah,"f"))||void 0===t||t.abort(),yl(this,Ah,null)};const Hh={isDocumentLoaded:!1,pagesReady:!1,url:null,numPages:0,pageNumber:0,scale:0,scaleValue:"auto",pagesRotation:0,spreadMode:kl.UNKNOWN,scrollMode:Il.UNKNOWN,documentOutline:null,attachments:new Map,thumbnails:new Map,thumbnailViews:new Map,annotationEditorMode:L.NONE,pdfSlick:null},Uh=()=>{return(t=(t,e)=>Object.assign(Object.assign({},Hh),{_setThumbnailView:(i,s)=>{const n=new Map(e().thumbnails),a=new Map(e().thumbnailViews),{canvasWidth:r,canvasHeight:o,scale:l,rotation:h,loaded:d,pageLabel:c,src:u=null}=s;a.set(i,s),n.set(i,{pageNumber:i,width:r,height:o,scale:l,rotation:h,loaded:d,pageLabel:c,src:u}),t({thumbnailViews:a,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:a,pageLabel:r,src:o=null}=t;return[t.id,{pageNumber:t.id,width:e,height:i,scale:s,rotation:n,loaded:a,pageLabel:r,src:o}]})));t({thumbnailViews:i,thumbnails:s})}}))?b(t):b;var t};var zh,$h,Wh,Gh,qh,Xh,Kh,Yh,Qh,Zh,Jh,td,ed,id,sd,nd,ad,rd,od,ld,hd,dd,cd,ud,pd,gd,fd;class md{constructor({eventBus:t,slick:e,printDialog:i}){zh.add(this),$h.set(this,null),Wh.set(this,null),Gh.set(this,null),this.eventBus=t,this.slick=e,this.printDialog=null!=i?i:null,this.bindEvents()}get supportsPrinting(){return bh.instance.supportsPrinting}get printing(){return!!wl(this,$h,"f")}print(){return vl(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=wl(this,$h,"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===wl(this,$h,"f")&&this.abort()}))}else console.error("Expected print service to be initialized."),null===(e=this.printDialog)||void 0===e||e.close()}}}))}abort(){var t;wl(this,$h,"f")&&(wl(this,$h,"f").destroy(),null===(t=this.printDialog)||void 0===t||t.close(),this.eventBus.dispatch("afterprint",{source:this}))}bindEvents(){yl(this,Wh,new AbortController);const{signal:t}=wl(this,Wh,"f"),e={signal:t};this.eventBus._on("beforeprint",wl(this,zh,"m",qh).bind(this),e),this.eventBus._on("afterprint",wl(this,zh,"m",Xh).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=wl(this,Wh,"f"))||void 0===t||t.abort(),yl(this,Wh,null)}}$h=new WeakMap,Wh=new WeakMap,Gh=new WeakMap,zh=new WeakSet,qh=function(){wl(this,$h,"f")||this.supportsPrinting&&(this.slick.viewer.pageViewsReady?(yl(this,Gh,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()}}}()),yl(this,$h,bh.instance.createPrintService({pdfDocument:this.slick.document,pagesOverview:this.slick.viewer.getPagesOverview(),printContainer:wl(this,Gh,"f").element,printResolution:this.slick.printResolution,optionalContentConfigPromise:null,printAnnotationStoragePromise:null})),this.slick.forceRendering(),wl(this,$h,"f").layout()):this.slick.l10n.get("printing_not_ready",null).then((t=>{window.alert(t)})))},Xh=function(){var t,e,i;wl(this,$h,"f")&&(wl(this,$h,"f").destroy(),yl(this,$h,null),null===(t=this.printDialog)||void 0===t||t.close(),null===(e=wl(this,Gh,"f"))||void 0===e||e.remove(),yl(this,Gh,null),null===(i=this.slick.document)||void 0===i||i.annotationStorage.resetModified()),this.slick.forceRendering()};class bd{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 bd(t)}constructor(t){this.dialog=t}open(t){return vl(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}))}}Ai.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 vd={"8.5x11":"Letter","8.5x14":"Legal"},wd={"297x420":"A3","210x297":"A4"};function yd(t,e,i){return i[`${e?t.width:t.height}x${e?t.height:t.width}`]}class Ad{constructor({container:t,viewer:e,thumbs:i,store:s=Uh(),options:n,onError:a,printDialog:r}){var o,l,h,d,c,u,p,g,f,m,b,v,w,y,A;Kh.add(this),Yh.set(this,void 0),Qh.set(this,void 0),Zh.set(this,void 0),Jh.set(this,void 0),td.set(this,void 0),this.downloadManager=null,this.findController=null,this.pdfPresentationMode=null,this.document=null,ed.set(this,void 0),id.set(this,void 0),sd.set(this,void 0),nd.set(this,void 0),yl(this,Qh,t),yl(this,Zh,e),yl(this,Jh,i),yl(this,sd,a),this.l10n=null!==(o=null==n?void 0:n.l10n)&&void 0!==o?o:new Lo(navigator.language),this.downloadManager=new ur,this.textLayerMode=null!==(l=null==n?void 0:n.textLayerMode)&&void 0!==l?l:Ml.ENABLE,yl(this,ed,null!==(h=null==n?void 0:n.annotationMode)&&void 0!==h?h:k.ENABLE_FORMS),yl(this,id,null!==(d=null==n?void 0:n.annotationEditorMode)&&void 0!==d?d:L.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 Kl;_.onIdle=this._cleanup.bind(this),_.isThumbnailViewEnabled=!0,yl(this,Yh,_);const x=new fr,S=new lr({eventBus:x,externalLinkTarget:2,externalLinkRel:"noopener noreferrer nofollow",ignoreDestinationZoom:!1}),C=new rr({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:wl(this,ed,"f"),annotationEditorMode:wl(this,id,"f"),removePageBorders:this.removePageBorders,imageResourcesPath:"/images/"}),P=this.singlePageViewer?new bl(E):new ml(E);_.setViewer(P),i&&(this.thumbnailViewer=new gh({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 Vh({container:t,pdfViewer:P,eventBus:x})),this.eventBus=x,this.linkService=S,this.findController=C,this.viewer=P,this.linkService.setViewer(P),yl(this,td,new md({eventBus:x,slick:this,printDialog:null!=r?r:bd.create()}));const T=null!==(A=null==n?void 0:n.scaleValue)&&void 0!==A?A:"auto";this.store.setState({scaleValue:T})}loadDocument(t,e){return vl(this,void 0,void 0,(function*(){var i,s,n,a,r;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:Rt(null===(a=this.url)||void 0===a?void 0:a.toString());this.filename=o;const l=Yi(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===(r=this.thumbnailViewer)||void 0===r||r.setDocument(h)),wl(this,Kh,"m",ld).call(this),yield wl(this,Kh,"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 wl(this,Kh,"m",rd).call(this),this.forceRendering()}catch(t){wl(this,sd,"f")&&wl(this,sd,"f").call(this,t)}}))}forceRendering(t=!0){wl(this,Yh,"f").printing=!!wl(this,td,"f").printing,wl(this,Yh,"f").isThumbnailViewEnabled=t,wl(this,Yh,"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 vl(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 vl(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 wl(this,td,"f").supportsPrinting}requestPresentationMode(){var t;null===(t=this.pdfPresentationMode)||void 0===t||t.request()}triggerPrinting(){wl(this,td,"f").print()}unbindEvents(){var t;null===(t=wl(this,nd,"f"))||void 0===t||t.abort(),yl(this,nd,null),wl(this,td,"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(L.HIGHLIGHT),this.setAnnotationEditorParams([{type:D.HIGHLIGHT_DEFAULT_COLOR,value:t}]),this.store.setState({highlightDefaultColor:t})}setSpreadMode(t){$l(t)&&(this.viewer.spreadMode=t,this.dispatch("switchspreadmode",{mode:t}))}setScrollMode(t){zl(t)&&(this.viewer.scrollMode=t,this.dispatch("switchscrollmode",{mode:t}))}setRotation(t){Ul(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)}}Yh=new WeakMap,Qh=new WeakMap,Zh=new WeakMap,Jh=new WeakMap,td=new WeakMap,ed=new WeakMap,id=new WeakMap,sd=new WeakMap,nd=new WeakMap,Kh=new WeakSet,ad=function(){return vl(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,a=0;for(let t=0;t<s;t++){const e=i[t];if(e===(t+1).toString())n++;else{if(""!==e)break;a++}}if(n>=s||a>=s)return;const{viewer:r,thumbnailViewer:o}=this;r.setPageLabels(i),null==o||o.setPageLabels(i)}))},rd=function(){return vl(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=>wl(this,Kh,"m",od).call(this,Ol(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:jt.toDateObject(t.CreationDate),modificationDate:jt.toDateObject(t.ModDate),isLinearized:t.IsLinearized,pageSize:i})}))},od=function(t,e){return vl(this,void 0,void 0,(function*(){if(!t)return;e%180!=0&&(t={width:t.height,height:t.width});const i=Wl(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},a=yd(s,i,vd)||yd(n,i,wd);if(!(a||Number.isInteger(n.width)&&Number.isInteger(n.height))){const e={width:25.4*t.width,height:25.4*t.height},r={width:Math.round(n.width),height:Math.round(n.height)};Math.abs(e.width-r.width)<.1&&Math.abs(e.height-r.height)<.1&&(a=yd(r,i,wd),a&&(s={width:Math.round(r.width/25.4*100)/100,height:Math.round(r.height/25.4*100)/100},n=r))}const[{width:r,height:o},l,h,d]=yield Promise.all([s,this.l10n.get("document_properties_page_size_unit_inches",null),a&&this.l10n.get(`document_properties_page_size_name_${a.toLowerCase()}`,null),this.l10n.get("document_properties_page_size_orientation_"+(i?"portrait":"landscape"),null)]);return{width:r.toLocaleString(),height:o.toLocaleString(),unit:l,name:h,orientation:d}}))},ld=function(){yl(this,nd,new AbortController);const{signal:t}=wl(this,nd,"f"),e={signal:t};this.eventBus._on("pagesinit",wl(this,Kh,"m",hd).bind(this),e),this.eventBus._on("scalechanging",wl(this,Kh,"m",pd).bind(this),e),this.eventBus._on("pagechanging",wl(this,Kh,"m",gd).bind(this),e),this.eventBus._on("pagerendered",wl(this,Kh,"m",fd).bind(this),e),this.eventBus._on("rotationchanging",wl(this,Kh,"m",dd).bind(this),e),this.eventBus._on("switchspreadmode",wl(this,Kh,"m",cd).bind(this),e),this.eventBus._on("switchscrollmode",wl(this,Kh,"m",ud).bind(this),e)},hd=function(t){return vl(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})}))},dd=function({pagesRotation:t,pageNumber:e}){this.store.setState({pagesRotation:t}),this.thumbnailViewer&&(this.thumbnailViewer.pagesRotation=t),this.forceRendering(),this.viewer.currentPageNumber=e},cd=function({mode:t}){this.store.setState({spreadMode:t})},ud=function({mode:t}){this.store.setState({scrollMode:t})},pd=function({scale:t,presetValue:e}){this.store.setState({scale:t,scaleValue:e}),this.viewer.update()},gd=function({pageNumber:t}){var e;null===(e=this.thumbnailViewer)||void 0===e||e.scrollThumbnailIntoView(t),this.store.setState({pageNumber:t})},fd=function({pageNumber:t,error:e}){var i;if(wl(this,Jh,"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 _d=function(){},xd="undefined"!=typeof window,Sd=xd?e.useLayoutEffect:e.useEffect;function Cd(t,i,s){void 0===s&&(s=[]);var n=function(t,i){var s=e.useRef(!1),n=e.useRef(),a=e.useRef(t),r=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,a.current()}),i)}),[i]),l=e.useCallback((function(){s.current=null,n.current&&clearTimeout(n.current)}),[]);return e.useEffect((function(){a.current=t}),[t]),e.useEffect((function(){return o(),l}),[i]),[r,l,o]}(t,i),a=n[0],r=n[1],o=n[2];return e.useEffect(o,s),[a,r]}var Ed={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};var Pd=xd&&void 0!==window.ResizeObserver?function(){var t=e.useState(null),i=t[0],s=t[1],n=e.useState(Ed),a=n[0],r=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,a=e.height,o=e.top,l=e.left,h=e.bottom,d=e.right;r({x:i,y:s,width:n,height:a,top:o,left:l,bottom:h,right:d})}}))}),[]);return Sd((function(){if(i)return o.observe(i),function(){o.disconnect()}}),[i]),[s,a]}:function(){return[_d,Ed]};function Td({usePDFSlickStore:t,viewerRef:e,className:s}){const n=t((t=>t.pdfSlick)),a=t((t=>t.scaleValue)),[r,{width:o}]=Pd();return Cd((()=>{o&&(!n||"auto"!==a&&"page-fit"!==a&&"page-width"!==a||(n.viewer.currentScaleValue=a),null==n||n.viewer.update())}),0,[o]),i.jsx("div",{ref:t=>{e(t),r(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 Md({children:t,thumbsRef:e,usePDFSlickStore:n,className:a}){const r=n((t=>t.thumbnailViews)),o=n((t=>t.pdfSlick)),[l,{width:h}]=Pd();return Cd((()=>{h&&(null==o||o.forceRendering())}),0,[h]),i.jsx("div",{ref:t=>{e(t),l(t)},className:a,style:{position:"absolute",overflow:"auto",inset:0},children:Array.from(r).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 Id(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=Ll,t.PDFSlick=Ad,t.PDFSlickThumbnails=Md,t.PDFSlickViewer=Td,t.PresentationModeState=Pl,t.ProgressBar=class{constructor(t){Al.set(this,void 0),_l.set(this,null),xl.set(this,0),Sl.set(this,void 0),Cl.set(this,!0),yl(this,Al,t.classList),yl(this,Sl,t.style)}get percent(){return wl(this,xl,"f")}set percent(t){var e,i,s;yl(this,xl,(e=t,i=0,s=100,Math.min(Math.max(e,i),s))),isNaN(t)?wl(this,Al,"f").add("indeterminate"):(wl(this,Al,"f").remove("indeterminate"),wl(this,Sl,"f").setProperty("--progressBar-percent",`${wl(this,xl,"f")}%`))}setWidth(t){if(!t)return;const e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&wl(this,Sl,"f").setProperty("--progressBar-end-offset",`${e}px`)}setDisableAutoFetch(t=5e3){100===wl(this,xl,"f")||isNaN(wl(this,xl,"f"))||(wl(this,_l,"f")&&clearTimeout(wl(this,_l,"f")),this.show(),yl(this,_l,setTimeout((()=>{yl(this,_l,null),this.hide()}),t)))}hide(){wl(this,Cl,"f")&&(yl(this,Cl,!1),wl(this,Al,"f").add("hidden"))}show(){wl(this,Cl,"f")||(yl(this,Cl,!0),wl(this,Al,"f").remove("hidden"))}},t.RendererType={CANVAS:"canvas",SVG:"svg"},t.RenderingStates=El,t.SCROLLBAR_PADDING=40,t.ScrollMode=Il,t.SidebarView=Tl,t.SpreadMode=kl,t.TextLayerMode=Ml,t.UNKNOWN_SCALE=0,t.VERTICAL_PADDING=5,t.animationStarted=Gl,t.apiPageLayoutToViewerModes=function(t){let e=Il.VERTICAL,i=kl.NONE;switch(t){case"SinglePage":e=Il.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=Il.PAGE;case"TwoColumnLeft":i=kl.ODD;break;case"TwoPageRight":e=Il.PAGE;case"TwoColumnRight":i=kl.EVEN}return{scrollMode:e,spreadMode:i}},t.apiPageModeToSidebarView=function(t){switch(t){case"UseNone":return Tl.NONE;case"UseThumbs":return Tl.THUMBS;case"UseOutlines":return Tl.OUTLINE;case"UseAttachments":return Tl.ATTACHMENTS;case"UseOC":return Tl.LAYERS}return Tl.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,a=1,r=1,o=1;for(;;){const t=n+r,e=a+o;if(e>8)break;i<=t/e?(r=t,o=e):(n=t,a=e)}return s=i-n/a<r/o-i?i===t?[n,a]:[a,n]:i===t?[r,o]:[o,r],s},t.backtrackBeforeAllVisibleElements=Bl,t.binarySearchFirstItem=Fl,t.calcRound=Xl,t.create=Uh,t.createStore=Id,t.docStyle=ql,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=Ol,t.getVisibleElements=jl,t.initialState=Hh,t.isPortraitOrientation=Wl,t.isValidRotation=Ul,t.isValidScrollMode=zl,t.isValidSpreadMode=$l,t.normalizeWheelEventDelta=Hl,t.normalizeWheelEventDirection=Vl,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 Nl.test(t)?e?t.replaceAll(Nl,(t=>"\0"===t?"":" ")):t.replaceAll("\0",""):t},t.scrollIntoView=Dl,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),[a,r]=e.useState(null),[o,l]=e.useState(null),[h,d]=e.useState(null),c=e.useMemo((()=>Uh()),[]),u=e.useMemo((()=>Id(c)),[]),p=e.useCallback((t=>{null!==t&&r(t)}),[]),g=e.useCallback((t=>{null!==t&&l(t)}),[]);return e.useEffect((()=>{if(t&&a){const e=new Ad({container:a,thumbs:o,store:c,options:i,onError:t=>d(t)});e.loadDocument(t,i).then((()=>{n(!0)})),c.setState({pdfSlick:e})}return()=>{}}),[t,a]),{isDocumentLoaded:s,viewerRef:p,thumbsRef:g,usePDFSlickStore:u,store:c,PDFSlickViewer:Td,PDFSlickThumbnails:Md,error:h}},t.watchScroll=Rl}));
54
+ const{AbortException:ga,AnnotationEditorLayer:ma,AnnotationEditorParamsType:fa,AnnotationEditorType:ba,AnnotationEditorUIManager:va,AnnotationLayer:wa,AnnotationMode:ya,AnnotationType:xa,applyOpacity:Aa,build:Ca,ColorPicker:Sa,createValidAbsoluteUrl:Pa,CSSConstants:_a,DOMSVGFactory:Ea,DrawLayer:Ta,FeatureTest:Ma,fetchData:ka,findContrastColor:Da,getDocument:Ia,getFilenameFromUrl:La,getPdfFilenameFromUrl:Na,getRGB:Ra,getRGBA:Fa,getUuid:Oa,GlobalWorkerOptions:Ba,ImageKind:ja,InvalidPDFException:Ua,isDataScheme:Ha,isPdfFile:Va,isValidExplicitDest:za,makeArr:$a,makeMap:Wa,makeObj:Ga,MathClamp:Xa,noContextMenu:Ka,normalizeUnicode:qa,OPS:Ya,OutputScale:Qa,PasswordResponses:Za,PDFDataRangeTransport:Ja,PDFDateString:tr,PDFWorker:er,PermissionFlag:ir,PixelsPerInch:nr,RenderingCancelledException:sr,renderRichText:ar,ResponseException:rr,setLayerDimensions:or,shadow:lr,SignatureExtractor:hr,stopEvent:dr,SupportedImageMimeTypes:cr,TextLayer:ur,TextLayerImages:pr,TouchManager:gr,updateUrlHash:mr,Util:fr,VerbosityLevel:br,version:vr,XfaLayer:wr}=globalThis.pdfjsLib,yr=0,xr=1,Ar=2,Cr=3,Sr=4,Pr=5,_r=6,Er=7;function Tr(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)?yr:function(t){return t>=97&&t<=122||t>=65&&t<=90}(t)||function(t){return t>=48&&t<=57}(t)||95===t?xr:Ar:function(t){return 3584==(65408&t)}(t)?Er:160===t?yr:xr:function(t){return t>=13312&&t<=40959||t>=63744&&t<=64255}(t)?Cr:function(t){return t>=12448&&t<=12543}(t)?Sr:function(t){return t>=12352&&t<=12447}(t)?Pr:function(t){return t>=65376&&t<=65439}(t)?_r:xr}let Mr;const kr=0,Dr=1,Ir=2,Lr=3,Nr=0,Rr=1,Fr=2,Or={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},Br={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};function jr(t){const e=new Map;for(const[i,n]of new URLSearchParams(t))e.set(i.toLowerCase(),n);return e}const Ur=/[\x00-\x1F]/g;function Hr(t,e=!1){return Ur.test(t)?e?t.replaceAll(Ur,t=>"\0"===t?"":" "):t.replaceAll("\0",""):t}function Vr(t,e,i=0){let n=i,s=t.length-1;if(s<0||!e(t[s]))return t.length;if(e(t[n]))return n;for(;n<s;){const i=n+s>>1;e(t[i])?s=i:n=i+1}return n}function zr(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 n=0,s=1,a=1,r=1;for(;;){const t=n+a,e=s+r;if(e>8)break;i<=t/e?(a=t,r=e):(n=t,s=e)}return i-n/s<a/r-i?i===t?[n,s]:[s,n]:i===t?[a,r]:[r,a]}function $r(t,e){return t-t%e}function Wr(t){return Number.isInteger(t)&&t%90==0}function Gr(t){return t.width<=t.height}new Promise(function(t){window.requestAnimationFrame(t)});const Xr=document.documentElement.style;const Kr=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}(),qr="9556e50a-f4f8-4f57-9831-f9ddff0176eb",Yr=Object.freeze({internal:qr}),Qr={FOUND:0,NOT_FOUND:1,WRAPPED:2,PENDING:3},Zr={"‐":"-","‘":"'","’":"'","‚":"'","‛":"'","“":'"',"”":'"',"„":'"',"‟":'"',"¼":"1/4","½":"1/2","¾":"3/4"},Jr=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 to;const eo=/\p{M}+/gu,io=/([+^$|])|(\p{P}+)|(\s+)|(\p{M})|(\p{L})/gu,no=/(\P{M})\p{M}*$/u,so=/^\p{M}*(\P{M})/u,ao=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,ro=new Map,oo=new Map;let lo=null,ho=null;function co(t,e={}){const i=[];let n;for(;null!==(n=ao.exec(t));){let{index:t}=n;for(const e of n[0]){let n=ro.get(e);n||(n=e.normalize("NFD").length,ro.set(e,n)),i.push([n,t++])}}const s=i.length>0,a=e.ignoreDashEOL??!1;let r;if(!s&&lo)r=lo;else if(s&&ho)r=ho;else{const t=Object.keys(Zr).join(""),e=function(){if(!Mr){const t=[],e=[],i=/^\p{M}$/u;for(let n=0;n<65536;n++){if(n>=55296&&n<=57343)continue;const s=String.fromCharCode(n);if(s.normalize("NFKC")!==s&&!i.test(s)){if(2!==e.length){e[0]=e[1]=n;continue}e[1]+1!==n?(e[0]===e[1]?t.push(String.fromCharCode(e[0])):t.push(`${String.fromCharCode(e[0])}-${String.fromCharCode(e[1])}`),e[0]=e[1]=n):e[1]=n}}const n=t.join("");if(Mr){if(n!==Mr){for(let t=1;t<n.length;t++)if(n[t]!==Mr[t]){console.log(`Difference at index ${t}: U+${n.charCodeAt(t).toString(16).toUpperCase().padStart(4,"0")}!== U+${Mr.charCodeAt(t).toString(16).toUpperCase().padStart(4,"0")}`);break}throw new Error("getNormalizeWithNFKC - update the `NormalizeWithNFKC` string.")}}else Mr=n}return Mr}();r=new RegExp([`[${t}]`,`[${e}]`,`${"(?:゙|゚)"}\\n`,"\\p{M}+(?:-\\n)?",`${"\\p{Ll}-\\n(?=\\p{Ll})|\\p{Lu}-\\n(?=\\p{L})"}`,"\\S-\\n",`${"(?:\\p{Ideographic}|[぀-ヿ])"}\\n`,"\\n",s?"[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]":"\\u0000"].map(t=>`(${t})`).join("|"),"gmu"),s?ho=r:lo=r}const o=[];for(;null!==(n=eo.exec(t));)o.push([n[0].length,n.index]);let l=t.normalize("NFD");const h=[0,0];let d=0,c=0,u=0,p=0,g=0,m=!1;l=l.replace(r,(t,e,n,s,r,l,f,b,v,w,y)=>{if(y-=p,e){const t=Zr[e],i=t.length;for(let t=1;t<i;t++)h.push(y-u+t,u-t);return u-=i-1,t}if(n){let t=oo.get(n);t||(t=n.normalize("NFKC"),oo.set(n,t));const e=t.length;for(let t=1;t<e;t++)h.push(y-u+t,u-t);return u-=e-1,t}if(s)return m=!0,y+g===o[d]?.[1]?++d:(h.push(y-1-u+1,u-1),u-=1,p+=1),h.push(y-u+1,u),p+=1,g+=1,s.charAt(0);if(r){const t=r.endsWith("\n"),e=t?r.length-2:r.length;m=!0;let i=e;y+g===o[d]?.[1]&&(i-=o[d][0],++d);for(let t=1;t<=i;t++)h.push(y-1-u+t,u-t);return u-=i,p+=i,t?(y+=e-1,h.push(y-u+1,1+u),u+=1,p+=1,g+=1,r.slice(0,e)):r}if(l){if(a)return p+=1,g+=1,l.slice(0,-1);const t=l.length-2;return h.push(y-u+t,1+u),u+=1,p+=1,g+=1,l.slice(0,-2)}if(f)return p+=1,g+=1,f.slice(0,-1);if(b){const t=b.length-1;return h.push(y-u+t,u),p+=1,g+=1,b.slice(0,-1)}if(v)return h.push(y-u+1,u-1),u-=1,p+=1,g+=1," ";if(y+g===i[c]?.[1]){const t=i[c][0]-1;++c;for(let e=1;e<=t;e++)h.push(y-(u-e),u-e);u-=t,p+=t}return w}),h.push(l.length,u);const f=new Uint32Array(h.length>>1),b=new Int32Array(h.length>>1);for(let t=0,e=h.length;t<e;t+=2)f[t>>1]=h[t],b[t>>1]=h[t+1];return[l,[f,b],m]}function uo(t,e,i){if(!t)return[e,i];const[n,s]=t,a=e,r=e+i-1;let o=Vr(n,t=>t>=a);n[o]>a&&--o;let l=Vr(n,t=>t>=r,o);n[l]>r&&--l;const h=a+s[o];return[h,r+s[l]+1-h]}class po{#fd=null;#bd=!0;#vd=0;#wd=0;#yd=null;#xd=null;constructor({linkService:t,eventBus:e,delay:i=250,updateMatchesCountOnProgress:n=!0}){this._linkService=t,this._eventBus=e,this.#bd=n,this.#vd=i,this.onIsPageVisible=null,this.#Ad(),e.on("find",this.#Cd.bind(this),Yr),e.on("findbarclose",this.#Sd.bind(this),Yr),e.on("pagesedited",this.#Pd.bind(this),Yr)}get highlightMatches(){return this._highlightMatches}get pageMatches(){return this._pageMatches}get pageMatchesLength(){return this._pageMatchesLength}get selected(){return this._selected}get state(){return this.#fd}setDocument(t){this._pdfDocument&&this.#Ad(),t&&(this._pdfDocument=t,this._firstPageCapability.resolve())}#Cd(t){if(!t)return;const e=this._pdfDocument,{type:i}=t;(null===this.#fd||this.#_d(t))&&(this._dirtyMatch=!0),this.#fd=t,"highlightallchange"!==i&&this.#Ed(Qr.PENDING),this._firstPageCapability.promise.then(()=>{if(!this._pdfDocument||e&&this._pdfDocument!==e)return;this.#io();const t=!this._highlightMatches,n=!!this._findTimeout;this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),i?this._dirtyMatch?this.#Td():"again"===i?(this.#Td(),t&&this.#fd.highlightAll&&this.#Md()):"highlightallchange"===i?(n?this.#Td():this._highlightMatches=!0,this.#Md()):this.#Td():this._findTimeout=setTimeout(()=>{this.#Td(),this._findTimeout=null},this.#vd)})}scrollMatchIntoView({element:t=null,pageIndex:e=-1,matchIndex:i=-1}){this._scrollMatches&&t&&-1!==i&&i===this._selected.matchIdx&&-1!==e&&e===this._selected.pageIdx&&(this._scrollMatches=!1,t.scrollIntoView({block:"start",inline:"center"}))}#Ad(){this._highlightMatches=!1,this._scrollMatches=!1,this._pdfDocument=null,this._pageMatches=[],this._pageMatchesLength=[],this.#wd=0,this.#fd=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.#yd=null,this._firstPageCapability=Promise.withResolvers()}get#kd(){const{query:t}=this.#fd;return"string"==typeof t?(t!==this._rawQuery&&(this._rawQuery=t,[this._normalizedQuery]=co(t)),this._normalizedQuery):(t||[]).filter(t=>!!t).map(t=>co(t)[0])}#_d(t){const e=t.query,i=this.#fd.query,n=typeof e;if(n!==typeof i)return!0;if("string"===n){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}#Dd(t,e,i){let n=t.slice(0,e).match(no);if(n){const i=t.charCodeAt(e),s=n[1].charCodeAt(0);if(Tr(i)===Tr(s))return!1}if(n=t.slice(e+i).match(so),n){const s=t.charCodeAt(e+i-1),a=n[1].charCodeAt(0);if(Tr(s)===Tr(a))return!1}return!0}#Id(t,e){const{matchDiacritics:i}=this.#fd;let n=!1;const s=(e,i)=>e===t?i:t.startsWith(e)?`${i}[ ]*`:t.endsWith(e)?`[ ]*${i}`:`[ ]*${i}[ ]*`,a="[ ]*";return(t=t.replaceAll(io,(t,a,r,o,l,h)=>a?s(a,RegExp.escape(a)):r?s(r,RegExp.escape(r)):o?"[ ]+":i?l||h:l?Jr.has(l.charCodeAt(0))?l:"":e?(n=!0,`${h}\\p{M}*`):h)).endsWith(a)&&(t=t.slice(0,t.length-4)),i&&e&&(to||=String.fromCharCode(...Jr),n=!0,t=`${t}(?=[${to}]|[^\\p{M}]|$)`),[n,t]}#Ld(t){if(!this.#fd)return;const e=this.#kd;if(0===e.length)return;const i=this._pageContents[t],n=this.match(e,i,t),s=this._pageMatches[t]=[],a=this._pageMatchesLength[t]=[],r=this._pageDiffs[t];n?.forEach(({index:t,length:e})=>{const[i,n]=uo(r,t,e);n&&(s.push(i),a.push(n))}),this.#fd.highlightAll&&this.#Nd(t),this._resumePageIdx===t&&(this._resumePageIdx=null,this.#Rd());const o=s.length;this._matchesCountTotal+=o,this.#bd?o>0&&this.#Fd():++this.#wd===this._linkService.pagesCount&&this.#Fd()}match(t,e,i){const n=this._hasDiacritics[i];let s=!1;if("string"==typeof t?[s,t]=this.#Id(t,n):t=t.sort().reverse().map(t=>{const[e,i]=this.#Id(t,n);return s||=e,`(${i})`}).join("|"),!t)return;const{caseSensitive:a,entireWord:r}=this.#fd;t=new RegExp(t,`g${s?"u":""}${a?"":"i"}`);const o=[];let l;for(;null!==(l=t.exec(e));)r&&!this.#Dd(e,l.index,l[0].length)||o.push({index:l.index,length:l[0].length});return o}#io(){if(this._extractTextPromises.length>0)return;let t=Promise.resolve();const e={disableNormalization:!0},i=this._pdfDocument;for(let n=0,s=this._linkService.pagesCount;n<s;n++){const{promise:s,resolve:a}=Promise.withResolvers();this._extractTextPromises[n]=s,t=t.then(async()=>{if(i===this._pdfDocument){try{const t=await i.getPage(n+1),s=await t.getTextContent(e);if(i!==this._pdfDocument)return void a();const r=[];for(const t of s.items)r.push(t.str),t.hasEOL&&r.push("\n");[this._pageContents[n],this._pageDiffs[n],this._hasDiacritics[n]]=co(r.join(""))}catch(t){if(i!==this._pdfDocument)return void a();console.error(`Unable to get text content for page ${n+1}`,t),[this._pageContents[n],this._pageDiffs[n],this._hasDiacritics[n]]=["",null,!1]}a()}else a()})}}#Nd(t){this._scrollMatches&&this._selected.pageIdx===t&&(this._linkService.page=t+1),this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:t})}#Md(){this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:-1})}#Td(){const t=this.#fd.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.#wd=0,this._matchesCountTotal=0,this.#Md();for(let t=0;t<i;t++)this._pendingFindMatches.has(t)||(this._pendingFindMatches.add(t),this._extractTextPromises[t].then(()=>{this._pendingFindMatches.delete(t),this.#Ld(t)}))}if(0===this.#kd.length)return void this.#Ed(Qr.FOUND);if(this._resumePageIdx)return;const n=this._offset;if(this._pagesToSearch=i,null!==n.matchIdx){const e=this._pageMatches[n.pageIdx].length;if(!t&&n.matchIdx+1<e||t&&n.matchIdx>0)return n.matchIdx=t?n.matchIdx-1:n.matchIdx+1,void this.#Od(!0);this.#Bd(t)}this.#Rd()}#jd(t){const e=this._offset,i=t.length,n=this.#fd.findPrevious;return i?(e.matchIdx=n?i-1:0,this.#Od(!0),!0):(this.#Bd(n),!!(e.wrapped&&(e.matchIdx=null,this._pagesToSearch<0))&&(this.#Od(!1),!0))}#Rd(){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.#jd(t))}#Bd(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)}#Od(t=!1){let e=Qr.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?Qr.WRAPPED:Qr.FOUND,-1!==t&&t!==this._selected.pageIdx&&this.#Nd(t)}this.#Ed(e,this.#fd.findPrevious),-1!==this._selected.pageIdx&&(this._scrollMatches=!0,this.#Nd(this._selected.pageIdx))}#Pd({pagesMapper:t,type:e,pageNumbers:i}){if(0===this._extractTextPromises.length)return;if("copy"===e){const t=new Map,e=new Map,n=new Map,s=new Map;for(const a of i)t.set(a,this._extractTextPromises[a-1]),e.set(a,this._pageContents[a-1]),n.set(a,this._pageDiffs[a-1]),s.set(a,this._hasDiacritics[a-1]);return void(this.#yd={promises:t,contents:e,diffs:n,diacritics:s})}if("cancelCopy"===e)return void(this.#yd=null);if("delete"===e&&(this.#xd={promises:this._extractTextPromises,contents:this._pageContents,diffs:this._pageDiffs,diacritics:this._hasDiacritics}),"cancelDelete"===e)return this._extractTextPromises=this.#xd.promises,this._pageContents=this.#xd.contents,this._pageDiffs=this.#xd.diffs,void(this._hasDiacritics=this.#xd.diacritics);if("cleanSavedData"===e)return void(this.#xd=null);this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),this._resumePageIdx=null,this._dirtyMatch=!0;const n=this._extractTextPromises,s=this._pageContents,a=this._pageDiffs,r=this._hasDiacritics,o=this._extractTextPromises=[],l=this._pageContents=[],h=this._pageDiffs=[],d=this._hasDiacritics=[];for(let e=1,i=t.pagesNumber;e<=i;e++){const i=t.getPrevPageNumber(e);if(i<0){const t=-i;o.push(this.#yd?.promises.get(t)||Promise.resolve()),l.push(this.#yd?.contents.get(t)??""),h.push(this.#yd?.diffs.get(t)??null),d.push(this.#yd?.diacritics.get(t)??!1);continue}o.push(n[i-1]||Promise.resolve()),l.push(s[i-1]??""),h.push(a[i-1]??null),d.push(r[i-1]??!1)}this.#fd&&this.#Td()}#Sd(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.#Ed(Qr.FOUND),this._highlightMatches=!1,this.#Md())})}#Ud(){const{pageIdx:t,matchIdx:e}=this._selected;let i=0,n=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>n)&&(i=n=0),{current:i,total:n}}#Fd(){this._eventBus.dispatch("updatefindmatchescount",{source:this,matchesCount:this.#Ud()})}#Ed(t,e=!1){(this.#bd||this.#wd===this._linkService.pagesCount&&t!==Qr.PENDING)&&this._eventBus.dispatch("updatefindcontrolstate",{source:this,state:t,previous:e,entireWord:this.#fd?.entireWord??null,matchesCount:this.#Ud(),rawQuery:this.#fd?.query??null})}}const go={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};class mo{externalLinkEnabled=!0;constructor({eventBus:t,externalLinkTarget:e=null,externalLinkRel:i=null,ignoreDestinationZoom:n=!1}={}){this.eventBus=t,this.externalLinkTarget=e,this.externalLinkRel=i,this._ignoreDestinationZoom=n,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?.pagesMapper.pagesNumber||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,n;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[s]=i;if(s&&"object"==typeof s){if(n=this.pdfDocument.cachedPageNumber(s),!n)try{n=await this.pdfDocument.getPageIndex(s)+1}catch{return void console.error(`goToDestination: "${s}" is not a valid page reference, for dest="${t}".`)}}else Number.isInteger(s)&&(n=s+1);if(!n||n<1||n>this.pagesCount)return void console.error(`goToDestination: "${n}" is not a valid page number, for dest="${t}".`);this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.push({namedDest:e,explicitDest:i,pageNumber:n})),this.pdfViewer.scrollPageIntoView({pageNumber:n,destArray:i,ignoreDestinationZoom:this._ignoreDestinationZoom});const a=new AbortController;this.eventBus.on("textlayerrendered",t=>{t.pageNumber===n&&(t.source.textLayer.div.focus(),a.abort())},{signal:a.signal,...Yr})}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.`)}goToXY(t,e,i,n={}){this.pdfViewer.scrollPageIntoView({pageNumber:t,destArray:[null,{name:"XYZ"},e,i],ignoreDestinationZoom:!0,...n})}addLinkAttributes(t,e,i=!1){if(!e||"string"!=typeof e)throw new Error('A valid "url" parameter must provided.');const n=i?go.BLANK:this.externalLinkTarget,s=this.externalLinkRel;let a=e;const r=URL.parse(e);(r?.username||r?.password)&&(r.username=r.password="",a=r.href),this.externalLinkEnabled?(t.href=e,t.title=a):(t.href="",t.title=`Disabled: ${a}`,t.onclick=()=>!1);let o="";switch(n){case go.NONE:break;case go.SELF:o="_self";break;case go.BLANK:o="_blank";break;case go.PARENT:o="_parent";break;case go.TOP:o="_top"}t.target=o,t.rel="string"==typeof s?s:"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 n=jr(t);if(n.has("search")){const t=n.get("search").replaceAll('"',""),e="true"===n.get("phrase");this.eventBus.dispatch("findfromurlhash",{source:this,query:e?t:t.match(/\S+/g)})}if(n.has("page")&&(e=0|n.get("page")||1),n.has("zoom")){const t=n.get("zoom").split(","),e=t[0],s=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,s?s/100:e]}return i?this.pdfViewer.scrollPageIntoView({pageNumber:e||this.page,destArray:i,allowNegativeOffset:!0}):e&&(this.page=e),n.has("pagemode")&&this.eventBus.dispatch("pagemode",{source:this,mode:n.get("pagemode")}),void(n.has("nameddest")&&this.goToDestination(n.get("nameddest")))}i=unescape(t);try{i=JSON.parse(i),Array.isArray(i)||(i=i.toString())}catch{}"string"==typeof i||za(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))}}class fo extends mo{setDocument(t,e=null){}}class bo{#Hd=null;#W=null;#Vd=!1;#zd=null;#$d=null;#Wd=!1;constructor({pdfPage:t,linkService:e,downloadManager:i,annotationStorage:n=null,imageResourcesPath:s="",renderForms:a=!0,enableComment:r=!1,commentManager:o=null,enableScripting:l=!1,hasJSActionsPromise:h=null,fieldObjectsPromise:d=null,annotationCanvasMap:c=null,accessibilityManager:u=null,annotationEditorUIManager:p=null,onAppend:g=null}){this.pdfPage=t,this.linkService=e,this.downloadManager=i,this.imageResourcesPath=s,this.renderForms=a,this.annotationStorage=n,this.enableComment=r,this.#W=o,this.enableScripting=l,this._hasJSActionsPromise=h||Promise.resolve(!1),this._fieldObjectsPromise=d||Promise.resolve(null),this._annotationCanvasMap=c,this._accessibilityManager=u,this._annotationEditorUIManager=p,this.#zd=g,this.annotationLayer=null,this.div=null,this._cancelled=!1,this._eventBus=e.eventBus}async render({viewport:t,intent:e="display",structTreeLayer:i=null,optionalContentConfigPromise:n=null}){if(this.div){const e=await n;if(this._cancelled||!this.annotationLayer)return;return void this.annotationLayer.update({viewport:t.clone({dontFlip:!0}),optionalContentConfig:e})}const[s,a,r,o]=await Promise.all([this.pdfPage.getAnnotations({intent:e}),this._hasJSActionsPromise,this._fieldObjectsPromise,n]);if(this._cancelled)return;const l=this.div=document.createElement("div");if(l.className="annotationLayer",this.#zd?.(l),this.#Gd(t,i),0===s.length)return this.#Hd=s,void or(this.div,t);await this.annotationLayer.render({annotations:s,imageResourcesPath:this.imageResourcesPath,renderForms:this.renderForms,downloadManager:this.downloadManager,enableComment:this.enableComment,enableScripting:this.enableScripting,hasJSActions:a,fieldObjects:r,optionalContentConfig:o}),this.#Hd=s,this.linkService.isInPresentationMode&&this.#Xd(Lr),this.#$d||(this.#$d=new AbortController,this._eventBus?.on("presentationmodechanged",t=>{this.#Xd(t.state)},{signal:this.#$d.signal,...Yr}))}#Gd(t,e){this.annotationLayer=new wa({div:this.div,accessibilityManager:this._accessibilityManager,annotationCanvasMap:this._annotationCanvasMap,annotationEditorUIManager:this._annotationEditorUIManager,annotationStorage:this.annotationStorage,page:this.pdfPage,viewport:t.clone({dontFlip:!0}),structTreeLayer:e,commentManager:this.#W,linkService:this.linkService})}cancel(){this._cancelled=!0,this.#$d?.abort(),this.#$d=null}hide(t=!1){this.#Vd=!t,this.div&&(this.div.hidden=!0)}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}async injectLinkAnnotations(t){if(null===this.#Hd)throw new Error("`render` method must be called before `injectLinkAnnotations`.");if(this._cancelled||this.#Wd)return;this.#Wd=!0;const e=this.#Hd.length?this.#Kd(t):t;e.length&&(await this.annotationLayer.addLinkAnnotations(e),this.#Vd||(this.div.hidden=!1))}#Xd(t){if(!this.div)return;let e=!1;switch(t){case Lr:e=!0;break;case Dr:break;default:return}for(const t of this.div.childNodes)t.hasAttribute("data-internal-link")||(t.inert=e)}#Kd(t){function e(t){if(!t.quadPoints)return[t.rect];const e=[];for(let i=2,n=t.quadPoints.length;i<n;i+=8){const n=t.quadPoints[i],s=t.quadPoints[i+1],a=t.quadPoints[i+2],r=t.quadPoints[i+3];e.push([a,r,n,s])}return e}function i(t,i){const n=[],s=e(t),a=e(i);for(const t of s)for(const e of a){const i=fr.intersect(t,e);i&&n.push(i)}return n}function n(t){let e=0;for(const i of t)e+=Math.abs((i[2]-i[0])*(i[3]-i[1]));return e}return t.filter(t=>{let s;for(const a of this.#Hd){if(a.annotationType!==xa.LINK||!a.url)continue;const r=i(a,t);if(0!==r.length&&(s??=n(e(t)),n(r)/s>.5))return!1}return!0})}}class vo{#qd=new WeakMap;_triggerDownload(t,e,i,n=!1){throw new Error("Not implemented: _triggerDownload")}_getOpenDataUrl(t,e,i=null){throw new Error("Not implemented: _getOpenDataUrl")}downloadData(t,e,i){const n=URL.createObjectURL(new Blob([t],{type:i}));this._triggerDownload(n,n,e,!0)}openOrDownloadData(t,e,i=null){const n=Va(e),s=n?"application/pdf":"";if(n){const n=this.#qd.getOrInsertComputed(t,()=>URL.createObjectURL(new Blob([t],{type:s})));try{const t=this._getOpenDataUrl(n,e,i);return window.open(t),!0}catch(e){console.error("openOrDownloadData:",e),URL.revokeObjectURL(n),this.#qd.delete(t)}}return this.downloadData(t,e,s),!1}download(t,e,i){const n=t?URL.createObjectURL(new Blob([t],{type:"application/pdf"})):null;this._triggerDownload(n,e,i)}}class wo extends vo{_triggerDownload(t,e,i,n=!1){if(!t&&!n){if(!Pa(e,"http://example.com"))throw new Error(`_triggerDownload - not a valid URL: ${e}`);t=e+"#pdfjs.action=download"}const s=document.createElement("a");s.href=t,s.target="_parent","download"in s&&(s.download=i),(document.body||document.documentElement).append(s),s.click(),s.remove()}_getOpenDataUrl(t,e,i=null){throw new Error("Opening data is not supported in `COMPONENTS` builds.")}}const yo="event",xo="timeout";class Ao{#dn=Object.create(null);constructor(){Object.seal(this)}on(t,e,i=null){let n=null;if(i?.signal instanceof AbortSignal){const{signal:s}=i;if(s.aborted)return void console.error("Cannot use an `aborted` signal.");const a=()=>this.off(t,e);n=()=>s.removeEventListener("abort",a),s.addEventListener("abort",a)}(this.#dn[t]??=[]).push({listener:e,internal:i?.internal===qr,once:!0===i?.once,rmAbort:n})}off(t,e,i=null){const n=this.#dn[t];if(n)for(let t=0,i=n.length;t<i;t++){const i=n[t];if(i.listener===e)return i.rmAbort?.(),void n.splice(t,1)}}dispatch(t,e){const i=this.#dn[t];if(!i?.length)return;let n;for(const{listener:s,internal:a,once:r}of i.slice(0))r&&this.off(t,s),a?s(e):(n??=[]).push(s);if(n)for(const t of n)t(e)}}class Co{constructor(t){this.value=t}valueOf(){return this.value}}class So extends Co{constructor(t="???"){super(t)}toString(t){return`{${this.value}}`}}class Po extends Co{constructor(t,e={}){super(t),this.opts=e}toString(t){if(t)try{return t.memoizeIntlObject(Intl.NumberFormat,this.opts).format(this.value)}catch(e){t.reportError(e)}return this.value.toString(10)}}class _o extends Co{static supportsValue(t){if("number"==typeof t)return!0;if(t instanceof Date)return!0;if(t instanceof Co)return _o.supportsValue(t.valueOf());if("Temporal"in globalThis){const e=globalThis.Temporal;if(t instanceof e.Instant||t instanceof e.PlainDateTime||t instanceof e.PlainDate||t instanceof e.PlainMonthDay||t instanceof e.PlainTime||t instanceof e.PlainYearMonth)return!0}return!1}constructor(t,e={}){t instanceof _o?(e={...t.opts,...e},t=t.value):t instanceof Co&&(t=t.valueOf()),"object"==typeof t&&"calendarId"in t&&void 0===e.calendar&&(e={...e,calendar:t.calendarId}),super(t),this.opts=e}[Symbol.toPrimitive](t){return"string"===t?this.toString():this.toNumber()}toNumber(){const t=this.value;if("number"==typeof t)return t;if(t instanceof Date)return t.getTime();if("epochMilliseconds"in t)return t.epochMilliseconds;if("toZonedDateTime"in t)return t.toZonedDateTime("UTC").epochMilliseconds;throw new TypeError("Unwrapping a non-number value as a number")}toString(t){if(t)try{return t.memoizeIntlObject(Intl.DateTimeFormat,this.opts).format(this.value)}catch(e){t.reportError(e)}return"number"==typeof this.value||this.value instanceof Date?new Date(this.value).toISOString():this.value.toString()}}function Eo(t,e,i){if(i===e)return!0;if(i instanceof Po&&e instanceof Po&&i.value===e.value)return!0;if(e instanceof Po&&"string"==typeof i){if(i===t.memoizeIntlObject(Intl.PluralRules,e.opts).select(e.value))return!0}return!1}function To(t,e,i){return e[i]?Io(t,e[i].value):(t.reportError(new RangeError("No default")),new So)}function Mo(t,e){const i=[],n=Object.create(null);for(const s of e)"narg"===s.type?n[s.name]=ko(t,s.value):i.push(ko(t,s));return{positional:i,named:n}}function ko(t,e){switch(e.type){case"str":return e.value;case"num":return new Po(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 So(`$${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 So(`$${e}`);i=t.args[e]}if(i instanceof Co)return i;switch(typeof i){case"string":return i;case"number":return new Po(i);case"object":if(_o.supportsValue(i))return new _o(i);default:return t.reportError(new TypeError(`Variable type not supported: $${e}, ${typeof i}`)),new So(`$${e}`)}}(t,e);case"mesg":return function(t,{name:e,attr:i}){const n=t.bundle._messages.get(e);if(!n)return t.reportError(new ReferenceError(`Unknown message: ${e}`)),new So(e);if(i){const s=n.attributes[i];return s?Io(t,s):(t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new So(`${e}.${i}`))}if(n.value)return Io(t,n.value);return t.reportError(new ReferenceError(`No value: ${e}`)),new So(e)}(t,e);case"term":return function(t,{name:e,attr:i,args:n}){const s=`-${e}`,a=t.bundle._terms.get(s);if(!a)return t.reportError(new ReferenceError(`Unknown term: ${s}`)),new So(s);if(i){const e=a.attributes[i];if(e){t.params=Mo(t,n).named;const i=Io(t,e);return t.params=null,i}return t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new So(`${s}.${i}`)}t.params=Mo(t,n).named;const r=Io(t,a.value);return t.params=null,r}(t,e);case"func":return function(t,{name:e,args:i}){let n=t.bundle._functions[e];if(!n)return t.reportError(new ReferenceError(`Unknown function: ${e}()`)),new So(`${e}()`);if("function"!=typeof n)return t.reportError(new TypeError(`Function ${e}() is not callable`)),new So(`${e}()`);try{let e=Mo(t,i);return n(e.positional,e.named)}catch(i){return t.reportError(i),new So(`${e}()`)}}(t,e);case"select":return function(t,{selector:e,variants:i,star:n}){let s=ko(t,e);if(s instanceof So)return To(t,i,n);for(const e of i){if(Eo(t,s,ko(t,e.key)))return Io(t,e.value)}return To(t,i,n)}(t,e);default:return new So}}function Do(t,e){if(t.dirty.has(e))return t.reportError(new RangeError("Cyclic reference")),new So;t.dirty.add(e);const i=[],n=t.bundle._useIsolating&&e.length>1;for(const s of e)if("string"!=typeof s){if(t.placeables++,t.placeables>100)throw t.dirty.delete(e),new RangeError(`Too many placeables expanded: ${t.placeables}, max allowed is 100`);n&&i.push("⁨"),i.push(ko(t,s).toString(t)),n&&i.push("⁩")}else i.push(t.bundle._transform(s));return t.dirty.delete(e),i.join("")}function Io(t,e){return"string"==typeof e?t.bundle._transform(e):Do(t,e)}class Lo{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 n=JSON.stringify(e);return i[n]||(i[n]=new t(this.bundle.locales,e)),i[n]}}function No(t,e){const i=Object.create(null);for(const[n,s]of Object.entries(t))e.includes(n)&&(i[n]=s.valueOf());return i}const Ro=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function Fo(t,e){let i=t[0];if(i instanceof So)return new So(`NUMBER(${i.valueOf()})`);if(i instanceof Po)return new Po(i.valueOf(),{...i.opts,...No(e,Ro)});if(i instanceof _o)return new Po(i.toNumber(),{...No(e,Ro)});throw new TypeError("Invalid argument to NUMBER")}const Oo=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function Bo(t,e){let i=t[0];if(i instanceof So)return new So(`DATETIME(${i.valueOf()})`);if(i instanceof _o||i instanceof Po)return new _o(i,No(e,Oo));throw new TypeError("Invalid argument to DATETIME")}const jo=new Map;class Uo{constructor(t,{functions:e,useIsolating:i=!0,transform:n=t=>t}={}){this._terms=new Map,this._messages=new Map,this.locales=Array.isArray(t)?t:[t],this._functions={NUMBER:Fo,DATETIME:Bo,...e},this._useIsolating=i,this._transform=n,this._intls=function(t){const e=Array.isArray(t)?t.join(" "):t;let i=jo.get(e);return void 0===i&&(i=new Map,jo.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 n=0;n<t.body.length;n++){let s=t.body[n];if(s.id.startsWith("-")){if(!1===e&&this._terms.has(s.id)){i.push(new Error(`Attempt to override an existing term: "${s.id}"`));continue}this._terms.set(s.id,s)}else{if(!1===e&&this._messages.has(s.id)){i.push(new Error(`Attempt to override an existing message: "${s.id}"`));continue}this._messages.set(s.id,s)}}return i}formatPattern(t,e=null,i=null){if("string"==typeof t)return this._transform(t);let n=new Lo(this,i,e);try{return Do(n,t).toString(n)}catch(t){if(n.errors&&t instanceof Error)return n.errors.push(t),(new So).toString(n);throw t}}}const Ho=/^(-?[a-zA-Z][\w-]*) *= */gm,Vo=/\.([a-zA-Z][\w-]*) *= */y,zo=/\*?\[/y,$o=/(-?[0-9]+(?:\.([0-9]+))?)/y,Wo=/([a-zA-Z][\w-]*)/y,Go=/([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y,Xo=/^[A-Z][A-Z0-9_-]*$/,Ko=/([^{}\n\r]+)/y,qo=/([^\\"\n\r]*)/y,Yo=/\\([\\"])/y,Qo=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y,Zo=/^\n+/,Jo=/ +$/,tl=/ *\r?\n/g,el=/( *)$/,il=/{\s*/y,nl=/\s*}/y,sl=/\[\s*/y,al=/\s*] */y,rl=/\s*\(\s*/y,ol=/\s*->\s*/y,ll=/\s*:\s*/y,hl=/\s*,?\s*/y,dl=/\s+/y;class cl{constructor(t){this.body=[],Ho.lastIndex=0;let e=0;for(;;){let i=Ho.exec(t);if(null===i)break;e=Ho.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 n(i,n){if(t[e]===i)return e++,!0;if(n)throw new n(`Expected ${i}`);return!1}function s(t,n){if(i(t))return e=t.lastIndex,!0;if(n)throw new n(`Expected ${t.toString()}`);return!1}function a(i){i.lastIndex=e;let n=i.exec(t);if(null===n)throw new SyntaxError(`Expected ${i.toString()}`);return e=i.lastIndex,n}function r(t){return a(t)[1]}function o(t){let e=l(),n=function(){let t=Object.create(null);for(;i(Vo);){let e=r(Vo),i=l();if(null===i)throw new SyntaxError("Expected attribute value");t[e]=i}return t}();if(null===e&&0===Object.keys(n).length)throw new SyntaxError("Expected message value or attributes");return{id:t,value:e,attributes:n}}function l(){let n;if(i(Ko)&&(n=r(Ko)),"{"===t[e]||"}"===t[e])return h(n?[n]:[],1/0);let s=b();return s?n?h([n,s],s.length):(s.value=v(s.value,Zo),h([s],s.length)):n?v(n,Jo):null}function h(n=[],s){for(;;){if(i(Ko)){n.push(r(Ko));continue}if("{"===t[e]){n.push(d());continue}if("}"===t[e])throw new SyntaxError("Unbalanced closing brace");let a=b();if(!a)break;n.push(a),s=Math.min(s,a.length)}let a=n.length-1,o=n[a];"string"==typeof o&&(n[a]=v(o,Jo));let l=[];for(let t of n)t instanceof ul&&(t=t.value.slice(0,t.value.length-s)),t&&l.push(t);return l}function d(){s(il,SyntaxError);let t=c();if(s(nl))return t;if(s(ol)){let e=function(){let t,e=[],s=0;for(;i(zo);){n("*")&&(t=s);let i=p(),a=l();if(null===a)throw new SyntaxError("Expected variant value");e[s++]={key:i,value:a}}if(0===s)return null;if(void 0===t)throw new SyntaxError("Expected default variant");return{variants:e,star:t}}();return s(nl,SyntaxError),{type:"select",selector:t,...e}}throw new SyntaxError("Unclosed placeable")}function c(){if("{"===t[e])return d();if(i(Go)){let[,i,n,r=null]=a(Go);if("$"===i)return{type:"var",name:n};if(s(rl)){let a=function(){let i=[];for(;;){switch(t[e]){case")":return e++,i;case void 0:throw new SyntaxError("Unclosed argument list")}i.push(u()),s(hl)}}();if("-"===i)return{type:"term",name:n,attr:r,args:a};if(Xo.test(n))return{type:"func",name:n,args:a};throw new SyntaxError("Function names must be all upper-case")}return"-"===i?{type:"term",name:n,attr:r,args:[]}:{type:"mesg",name:n,attr:r}}return g()}function u(){let t=c();return"mesg"!==t.type?t:s(ll)?{type:"narg",name:t.name,value:g()}:t}function p(){let t;return s(sl,SyntaxError),t=i($o)?m():{type:"str",value:r(Wo)},s(al,SyntaxError),t}function g(){if(i($o))return m();if('"'===t[e])return function(){n('"',SyntaxError);let i="";for(;;){if(i+=r(qo),"\\"!==t[e]){if(n('"'))return{type:"str",value:i};throw new SyntaxError("Unclosed string literal")}i+=f()}}();throw new SyntaxError("Invalid expression")}function m(){let[,t,e=""]=a($o),i=e.length;return{type:"num",value:parseFloat(t),precision:i}}function f(){if(i(Yo))return r(Yo);if(i(Qo)){let[,t,e]=a(Qo),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(s(dl),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(tl,"\n"),i=el.exec(t)[1].length;return new ul(e,i)}}}class ul{constructor(t,e){this.value=t,this.length=e}}const pl=/<|&#?\w+;/,gl={"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"]},ml={"http://www.w3.org/1999/xhtml":{global:["title","aria-description","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 fl(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(pl.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 n=wl(e,i);t.replaceChild(n,i);continue}if(Al(i)){const e=yl(i);t.replaceChild(e,i);continue}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(xl(i),i)}e.textContent="",e.appendChild(t)}(e.content,t)}else t.textContent=i;vl(e,t)}function bl(t,e){if(!t)return!1;for(let i of t)if(i.name===e)return!0;return!1}function vl(t,e){const i=e.hasAttribute("data-l10n-attrs")?e.getAttribute("data-l10n-attrs").split(",").map(t=>t.trim()):null;for(const n of Array.from(e.attributes))Cl(n.name,e,i)&&!bl(t.attributes,n.name)&&e.removeAttribute(n.name);if(t.attributes)for(const n of Array.from(t.attributes))Cl(n.name,e,i)&&e.getAttribute(n.name)!==n.value&&e.setAttribute(n.name,n.value)}function wl(t,e){const i=e.getAttribute("data-l10n-name"),n=t.querySelector(`[data-l10n-name="${i}"]`);if(!n)return console.warn(`An element named "${i}" wasn't found in the source.`),xl(e);if(n.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 (${n.localName}).`),xl(e);t.removeChild(n);return Sl(e,n.cloneNode(!1))}function yl(t){const e=t.ownerDocument.createElement(t.localName);return Sl(t,e)}function xl(t){return t.ownerDocument.createTextNode(t.textContent)}function Al(t){const e=gl[t.namespaceURI];return e&&e.includes(t.localName)}function Cl(t,e,i=null){if(i&&i.includes(t))return!0;const n=ml[e.namespaceURI];if(!n)return!1;const s=t.toLowerCase(),a=e.localName;if(n.global.includes(s))return!0;if(!n[a])return!1;if(n[a].includes(s))return!0;if("http://www.w3.org/1999/xhtml"===e.namespaceURI&&"input"===a&&"value"===s){const t=e.type.toLowerCase();if("submit"===t||"button"===t||"reset"===t)return!0}return!1}function Sl(t,e){return e.textContent=t.textContent,vl(t,e),e}class Pl extends Array{static from(t){return t instanceof this?t:new this(t)}}class _l extends Pl{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 El{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 n=!1;for await(const s of this.bundles){n=!0;const a=kl(e,s,t,i);if(0===a.size)break;if("undefined"!=typeof console){const t=s.locales[0],e=Array.from(a).join(", ");console.warn(`[fluent] Missing translations in ${t}: ${e}`)}}return n||"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,Ml)}formatValues(t){return this.formatWithFallback(t,Tl)}async formatValue(t,e){const[i]=await this.formatValues([{id:t,args:e}]);return i}handleEvent(){this.onChange()}onChange(t=!1){this.bundles=_l.from(this.generateBundles(this.resourceIds)),t&&this.bundles.touchNext(2)}}function Tl(t,e,i,n){return i.value?t.formatPattern(i.value,n,e):null}function Ml(t,e,i,n){const s={value:null,attributes:null};i.value&&(s.value=t.formatPattern(i.value,n,e));let a=Object.keys(i.attributes);if(a.length>0){s.attributes=new Array(a.length);for(let[r,o]of a.entries()){let a=t.formatPattern(i.attributes[o],n,e);s.attributes[r]={name:o,value:a}}}return s}function kl(t,e,i,n){const s=[],a=new Set;return i.forEach(({id:i,args:r},o)=>{if(void 0!==n[o])return;let l=e.getMessage(i);if(l){if(s.length=0,n[o]=t(e,s,l,r),s.length>0&&"undefined"!=typeof console){const t=e.locales[0],n=s.join(", ");console.warn(`[fluent][resolver] errors in ${t}/${i}: ${n}.`)}}else a.add(i)}),a}const Dl="data-l10n-id",Il="data-l10n-args",Ll=`[${Dl}]`;class Nl extends El{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:[Dl,Il]}}onChange(t=!1){super.onChange(t),this.roots&&this.translateRoots()}setAttributes(t,e,i){return t.setAttribute(Dl,e),i?t.setAttribute(Il,JSON.stringify(i)):t.removeAttribute(Il),t}getAttributes(t){return{id:t.getAttribute(Dl),args:JSON.parse(t.getAttribute(Il)||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(Dl)&&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]&&fl(t[i],e[i]);this.resumeObserving()}getTranslatables(t){const e=Array.from(t.querySelectorAll(Ll));return"function"==typeof t.hasAttribute&&t.hasAttribute(Dl)&&e.push(t),e}getKeysForElement(t){return{id:t.getAttribute(Dl),args:JSON.parse(t.getAttribute(Il)||null)}}}class Rl{#Yd;#yr;#$s;#Qd;constructor({lang:t,isRTL:e},i=null){this.#$s=Rl.#Zd(t),this.#Qd=i,this.#Yd=e??Rl.#Jd(this.#$s)?"rtl":"ltr"}_setL10n(t){this.#Qd=t}getLanguage(){return this.#$s}getDirection(){return this.#Yd}async get(t,e=null,i){if(Array.isArray(t)){t=t.map(t=>({id:t}));return(await this.#Qd.formatMessages(t)).map(t=>t.value)}const n=await this.#Qd.formatMessages([{id:t,args:e}]);return n[0]?.value||i}async translate(t){(this.#yr||=new Set).add(t);try{this.#Qd.connectRoot(t),await this.#Qd.translateRoots()}catch{}}async translateOnce(t){try{await this.#Qd.translateElements([t])}catch(t){console.error("translateOnce:",t)}}async destroy(){if(this.#yr){for(const t of this.#yr)this.#Qd.disconnectRoot(t);this.#yr.clear(),this.#yr=null}this.#Qd.pauseObserving()}pause(){this.#Qd.pauseObserving()}resume(){this.#Qd.resumeObserving()}static#Zd(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#Jd(t){const e=t.split("-",1)[0];return["ar","he","fa","ps","ur"].includes(e)}}function Fl(){const{isAndroid:t,isLinux:e,isMac:i,isWindows:n}=Ma.platform;return e?"linux":n?"windows":i?"macos":t?"android":"other"}function Ol(t,e){const i=new cl(e),n=new Uo(t,{functions:{PLATFORM:Fl}}),s=n.addResource(i);return s.length&&console.error("L10n errors",s),n}class Bl extends Rl{constructor(t){super({lang:t});const e=t?Bl.#tc.bind(Bl,"en-us",this.getLanguage()):Bl.#ec.bind(Bl,this.getLanguage());this._setL10n(new Nl([],e))}static async*#tc(t,e){const{baseURL:i,paths:n}=await this.#ic(),s=[e];if(t!==e){const i=e.split("-",1)[0];i!==e&&s.push(i),s.push(t)}const a=s.map(t=>[t,this.#nc(t,i,n)]);for(const[t,e]of a){const i=await e;i?yield i:"en-us"===t&&(yield this.#sc(t))}}static async#nc(t,e,i){const n=i[t];if(!n)return null;const s=new URL(n,e);return Ol(t,await ka(s,"text"))}static async#ic(){try{const{href:t}=document.querySelector('link[type="application/l10n"]'),e=await ka(t,"json");return{baseURL:t.substring(0,t.lastIndexOf("/")+1)||"./",paths:e}}catch{}return{baseURL:"./",paths:Object.create(null)}}static async*#ec(t){yield this.#sc(t)}static async#sc(t){return Ol(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-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-title1 =\n .title = Page { $page } of { $total }\npdfjs-thumb-page-canvas =\n .aria-label = Thumbnail of Page { $page }\npdfjs-thumb-page-checkbox1 =\n .title = Select 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-color-picker-free-text-input =\n .title = Change text color\npdfjs-editor-free-text-button-label = Text\npdfjs-editor-ink-button =\n .title = Draw\npdfjs-editor-color-picker-ink-input =\n .title = Change drawing color\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-comment-floating-button =\n .title = Comment\n .aria-label = Comment\npdfjs-comment-floating-button-label = Comment\npdfjs-editor-comment-button =\n .title = Comment\n .aria-label = Comment\npdfjs-editor-comment-button-label = Comment\npdfjs-editor-signature-button =\n .title = Add signature\npdfjs-editor-signature-button-label = Add signature\npdfjs-editor-highlight-editor =\n .aria-label = Highlight editor\npdfjs-editor-ink-editor =\n .aria-label = Drawing editor\npdfjs-editor-signature-editor1 =\n .aria-description = Signature editor: { $description }\npdfjs-editor-stamp-editor =\n .aria-label = Image editor\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-remove-signature-button =\n .title = Remove signature\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-editor-add-signature-container =\n .aria-label = Signature controls and saved signatures\npdfjs-editor-signature-add-signature-button =\n .title = Add new signature\npdfjs-editor-signature-add-signature-button-label = Add new signature\npdfjs-editor-add-saved-signature-button =\n .title = Saved signature: { $description }\npdfjs-free-text2 =\n .aria-label = Text Editor\n .default-content = Start typing…\npdfjs-editor-comments-sidebar-title =\n { $count ->\n [one] Comment\n *[other] Comments\n }\npdfjs-editor-comments-sidebar-close-button =\n .title = Close the sidebar\n .aria-label = Close the sidebar\npdfjs-editor-comments-sidebar-close-button-label = Close the sidebar\npdfjs-editor-comments-sidebar-no-comments1 = See something noteworthy? Highlight it and leave a comment.\npdfjs-editor-comments-sidebar-no-comments-link = Learn more\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-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-highlight-added-alert = Highlight added\npdfjs-editor-freetext-added-alert = Text added\npdfjs-editor-ink-added-alert = Drawing added\npdfjs-editor-stamp-added-alert = Image added\npdfjs-editor-signature-added-alert = Signature added\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-signature = Signature removed\npdfjs-editor-undo-bar-message-comment = Comment 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\npdfjs-editor-add-signature-dialog-label = This modal allows the user to create a signature to add to a PDF document. The user can edit the name (which also serves as the alt text), and optionally save the signature for repeated use.\npdfjs-editor-add-signature-dialog-title = Add a signature\npdfjs-editor-add-signature-type-button = Type\n .title = Type\npdfjs-editor-add-signature-draw-button = Draw\n .title = Draw\npdfjs-editor-add-signature-image-button = Image\n .title = Image\npdfjs-editor-add-signature-type-input =\n .aria-label = Type your signature\n .placeholder = Type your signature\npdfjs-editor-add-signature-draw-placeholder = Draw your signature\npdfjs-editor-add-signature-draw-thickness-range-label = Thickness\npdfjs-editor-add-signature-draw-thickness-range =\n .title = Drawing thickness: { $thickness }\npdfjs-editor-add-signature-image-placeholder = Drag a file here to upload\npdfjs-editor-add-signature-image-browse-link =\n { PLATFORM() ->\n [macos] Or choose image files\n *[other] Or browse image files\n }\npdfjs-editor-add-signature-description-label = Description (alt text)\npdfjs-editor-add-signature-description-input =\n .title = Description (alt text)\npdfjs-editor-add-signature-description-default-when-drawing = Signature\npdfjs-editor-add-signature-clear-button-label = Clear signature\npdfjs-editor-add-signature-clear-button =\n .title = Clear signature\npdfjs-editor-add-signature-save-checkbox = Save signature\npdfjs-editor-add-signature-save-warning-message = You’ve reached the limit of 5 saved signatures. Remove one to save more.\npdfjs-editor-add-signature-image-upload-error-title = Couldn’t upload image\npdfjs-editor-add-signature-image-upload-error-description = Check your network connection or try another image.\npdfjs-editor-add-signature-image-no-data-error-title = Can’t convert this image into a signature\npdfjs-editor-add-signature-image-no-data-error-description = Please try uploading a different image.\npdfjs-editor-add-signature-error-close-button = Close\npdfjs-editor-add-signature-cancel-button = Cancel\npdfjs-editor-add-signature-add-button = Add\npdfjs-editor-delete-signature-button1 =\n .title = Remove saved signature\npdfjs-editor-delete-signature-button-label1 = Remove saved signature\npdfjs-editor-add-signature-edit-button-label = Edit description\npdfjs-editor-edit-signature-dialog-title = Edit description\npdfjs-editor-edit-signature-update-button = Update\npdfjs-show-comment-button =\n .title = Show comment\npdfjs-editor-edit-comment-popup-button-label = Edit comment\npdfjs-editor-edit-comment-popup-button =\n .title = Edit comment\npdfjs-editor-delete-comment-popup-button-label = Remove comment\npdfjs-editor-delete-comment-popup-button =\n .title = Remove comment\npdfjs-editor-edit-comment-dialog-title-when-editing = Edit comment\npdfjs-editor-edit-comment-dialog-save-button-when-editing = Update\npdfjs-editor-edit-comment-dialog-title-when-adding = Add comment\npdfjs-editor-edit-comment-dialog-save-button-when-adding = Add\npdfjs-editor-edit-comment-dialog-text-input =\n .placeholder = Start typing…\npdfjs-editor-edit-comment-dialog-cancel-button = Cancel\npdfjs-editor-add-comment-button =\n .title = Add comment\npdfjs-toggle-views-manager-button1 =\n .title = Manage pages\npdfjs-toggle-views-manager-notification-button =\n .title = Toggle Sidebar (document contains thumbnails/outline/attachments/layers)\npdfjs-toggle-views-manager-button1-label = Manage pages\npdfjs-views-manager-sidebar =\n .aria-label = Sidebar\npdfjs-views-manager-sidebar-resizer =\n .aria-label = Sidebar resizer\npdfjs-views-manager-view-selector-button =\n .title = Views\npdfjs-views-manager-view-selector-button-label = Views\npdfjs-views-manager-pages-title = Pages\npdfjs-views-manager-outlines-title1 = Document outline\n .title = Document outline (double-click to expand/collapse all items)\npdfjs-views-manager-attachments-title = Attachments\npdfjs-views-manager-layers-title1 = Layers\n .title = Layers (double-click to reset all layers to the default state)\npdfjs-views-manager-pages-option-label = Pages\npdfjs-views-manager-outlines-option-label = Document outline\npdfjs-views-manager-attachments-option-label = Attachments\npdfjs-views-manager-layers-option-label = Layers\npdfjs-views-manager-add-file-button =\n .title = Add file\npdfjs-views-manager-add-file-button-label = Add file\npdfjs-views-manager-pages-status-action-label =\n { $count ->\n [one] { $count } selected\n *[other] { $count } selected\n }\npdfjs-views-manager-pages-status-none-action-label = Select pages\npdfjs-views-manager-pages-status-action-button-label = Manage\npdfjs-views-manager-pages-status-copy-button-label = Copy\npdfjs-views-manager-pages-status-cut-button-label = Cut\npdfjs-views-manager-pages-status-delete-button-label = Delete\npdfjs-views-manager-pages-status-export-selected-button-label = Export selected…\npdfjs-views-manager-status-undo-cut-label =\n { $count ->\n [one] 1 page cut\n *[other] { $count } pages cut\n }\npdfjs-views-manager-pages-status-undo-copy-label =\n { $count ->\n [one] 1 page copied\n *[other] { $count } pages copied\n }\npdfjs-views-manager-pages-status-undo-delete-label =\n { $count ->\n [one] 1 page deleted\n *[other] { $count } pages deleted\n }\npdfjs-views-manager-pages-status-waiting-ready-label = Getting your file ready…\npdfjs-views-manager-pages-status-waiting-uploading-label = Uploading file…\npdfjs-views-manager-status-warning-cut-label = Couldn’t cut. Refresh page and try again.\npdfjs-views-manager-status-warning-copy-label = Couldn’t copy. Refresh page and try again.\npdfjs-views-manager-status-warning-delete-label = Couldn’t delete. Refresh page and try again.\npdfjs-views-manager-status-warning-save-label = Couldn’t save. Refresh page and try again.\npdfjs-views-manager-status-undo-button-label = Undo\npdfjs-views-manager-status-done-button-label = Done\npdfjs-views-manager-status-close-button =\n .title = Close\npdfjs-views-manager-status-close-button-label = Close\npdfjs-views-manager-paste-button-label = Paste\npdfjs-views-manager-paste-button-before =\n .title = Paste before the first page\npdfjs-views-manager-paste-button-after =\n .title = Paste after page { $page }\npdfjs-new-badge-content = NEW\npdfjs-views-manager-waiting-for-file = Uploading file…')}}function jl(){return document.location.hash}class Ul{#Ah=null;#ac=null;#zd=null;#ad=null;#Dh=null;#v;constructor(t){this.pageIndex=t.pageIndex,this.accessibilityManager=t.accessibilityManager,this.l10n=t.l10n,this.l10n||=new Bl,this.annotationEditorLayer=null,this.div=null,this._cancelled=!1,this.#v=t.uiManager,this.#Ah=t.annotationLayer||null,this.#Dh=t.textLayer||null,this.#ac=t.drawLayer||null,this.#zd=t.onAppend||null,this.#ad=t.structTreeLayer||null}updatePageIndex(t){this.pageIndex=t,this.annotationEditorLayer?.updatePageIndex(t)}async render({viewport:t,intent: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 n=this.div=document.createElement("div");n.className="annotationEditorLayer",n.hidden=!0,n.dir=this.#v.direction,this.#zd?.(n),this.annotationEditorLayer=new ma({uiManager:this.#v,div:n,structTreeLayer:this.#ad,accessibilityManager:this.accessibilityManager,pageIndex:this.pageIndex,l10n:this.l10n,viewport:i,annotationLayer:this.#Ah,textLayer:this.#Dh,drawLayer:this.#ac});const s={viewport:i,div:n,annotations:null,intent:e};await this.annotationEditorLayer.render(s),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 Hl=new Map;const{maxTouchPoints:t,platform:e,userAgent:i}=navigator,n=/Android/.test(i);(/\b(?:iPad|iPhone|iPod)(?=;)/.test(i)||"MacIntel"===e&&t>1||n)&&Hl.set("maxCanvasPixels",5242880),n&&Hl.set("useSystemFonts",!1)}const Vl=1,zl=2,$l=4,Wl=8,Gl=16,Xl=128,Kl={BOOLEAN:1,NUMBER:2,OBJECT:4,STRING:8,UNDEFINED:16},ql={allowedGlobalEvents:{value:null,kind:Vl},canvasMaxAreaInBytes:{value:-1,kind:Vl+$l},isInAutomation:{value:!1,kind:Vl},localeProperties:{value:{lang:navigator.language||"en-US"},kind:Vl},maxCanvasDim:{value:32767,kind:Vl+zl},nimbusDataStr:{value:"",kind:Vl},supportsCaretBrowsingMode:{value:!1,kind:Vl},supportsDocumentFonts:{value:!0,kind:Vl},supportsIntegratedFind:{value:!1,kind:Vl},supportsMouseWheelZoomCtrlKey:{value:!0,kind:Vl},supportsMouseWheelZoomMetaKey:{value:!0,kind:Vl},supportsPinchToZoom:{value:!0,kind:Vl},supportsPrinting:{value:!0,kind:Vl},toolbarDensity:{value:0,kind:Vl+Gl},altTextLearnMoreUrl:{value:"",kind:zl+Xl},annotationEditorMode:{value:0,kind:zl+Xl},annotationMode:{value:2,kind:zl+Xl},capCanvasAreaFactor:{value:200,kind:zl+Xl},commentLearnMoreUrl:{value:"",kind:zl+Xl},cursorToolOnLoad:{value:0,kind:zl+Xl},debuggerSrc:{value:"./debugger.mjs",kind:zl},defaultZoomDelay:{value:400,kind:zl+Xl},defaultZoomValue:{value:"",kind:zl+Xl},disableHistory:{value:!1,kind:zl},disablePageLabels:{value:!1,kind:zl+Xl},enableAltText:{value:!1,kind:zl+Xl},enableAltTextModelDownload:{value:!0,kind:zl+Xl+Gl},enableAutoLinking:{value:!0,kind:zl+Xl},enableComment:{value:!1,kind:zl+Xl},enableDetailCanvas:{value:!0,kind:zl},enableGuessAltText:{value:!0,kind:zl+Xl+Gl},enableHighlightFloatingButton:{value:!1,kind:zl+Xl},enableMerge:{value:!1,kind:zl+Xl},enableNewAltTextWhenAddingImage:{value:!0,kind:zl+Xl},enableNewBadge:{value:!1,kind:zl+Xl},enableOptimizedPartialRendering:{value:!1,kind:zl+Xl},enablePermissions:{value:!1,kind:zl+Xl},enablePrintAutoRotate:{value:!0,kind:zl+Xl},enableScripting:{value:!0,kind:zl+Xl},enableSignatureEditor:{value:!1,kind:zl+Xl},enableSplitMerge:{value:!1,kind:zl+Xl},enableUpdatedAddImage:{value:!1,kind:zl+Xl},externalLinkRel:{value:"noopener noreferrer nofollow",kind:zl},externalLinkTarget:{value:0,kind:zl+Xl},highlightEditorColors:{value:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F,yellow_HCM=#FFFFCC,green_HCM=#53FFBC,blue_HCM=#80EBFF,pink_HCM=#F6B8FF,red_HCM=#C50043",kind:zl+Xl},historyUpdateUrl:{value:!1,kind:zl+Xl},ignoreDestinationZoom:{value:!1,kind:zl+Xl},imageResourcesPath:{value:"./images/",kind:zl},enableSelectionRendering:{value:!0,kind:zl+Xl},imagesRightClickMinSize:{value:-1,kind:zl+Xl},maxCanvasPixels:{value:2**25,kind:zl},minDurationToUpdateCanvas:{value:500,kind:zl},forcePageColors:{value:!1,kind:zl+Xl},pageColorsBackground:{value:"Canvas",kind:zl+Xl},pageColorsForeground:{value:"CanvasText",kind:zl+Xl},pdfBugEnabled:{value:!1,kind:zl+Xl},postMessageAfterPrintCallback:{value:!1,kind:zl+Xl},printResolution:{value:150,kind:zl},sidebarViewOnLoad:{value:-1,kind:zl+Xl},scrollModeOnLoad:{value:-1,kind:zl+Xl},spreadModeOnLoad:{value:-1,kind:zl+Xl},textLayerMode:{value:1,kind:zl+Xl},viewerCssTheme:{value:0,kind:zl+Xl},viewOnLoad:{value:0,kind:zl+Xl},cMapPacked:{value:!0,kind:$l},cMapUrl:{value:"../web/cmaps/",kind:$l},disableAutoFetch:{value:!1,kind:$l+Xl},disableFontFace:{value:!1,kind:$l+Xl},disableRange:{value:!1,kind:$l+Xl},disableStream:{value:!1,kind:$l+Xl},docBaseUrl:{value:"",kind:$l},enableHWA:{value:!0,kind:$l+Xl},enableWebGPU:{value:!0,kind:$l+Xl},enableXfa:{value:!0,kind:$l+Xl},fontExtraProperties:{value:!1,kind:$l},iccUrl:{value:"../web/iccs/",kind:$l},isOffscreenCanvasSupported:{value:!0,kind:$l},maxImageSize:{value:-1,kind:$l},pdfBug:{value:!1,kind:$l},standardFontDataUrl:{value:"../web/standard_fonts/",kind:$l},useSystemFonts:{value:void 0,kind:$l,type:Kl.BOOLEAN+Kl.UNDEFINED},verbosity:{value:1,kind:$l},wasmUrl:{value:"../web/wasm/",kind:$l},workerPort:{value:null,kind:Wl},workerSrc:{value:"../build/pdf.worker.mjs",kind:Wl}};ql.defaultUrl={value:"compressed.tracemonkey-pldi-09.pdf",kind:zl},ql.sandboxBundleSrc={value:"../build/pdf.sandbox.mjs",kind:zl},ql.enableFakeMLManager={value:!0,kind:zl},ql.disablePreferences={value:!1,kind:zl};class Yl{static eventBus;static#rc=new Map;static{for(const t in ql)this.#rc.set(t,ql[t].value);for(const[t,e]of Hl)this.#rc.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.#rc.get(t)}static getAll(t=null,e=!1){const i=Object.create(null);for(const n in ql){const s=ql[n];(!t||t&s.kind)&&(i[n]=e?s.value:this.#rc.get(n))}return i}static set(t,e){this.setAll({[t]:e})}static setAll(t,e=!1){let i;this._hasInvokedSet||=!0;for(const n in t){const s=ql[n],a=t[n];if(!s||!(typeof a==typeof s.value||Kl[(typeof a).toUpperCase()]&s.type))continue;const{kind:r}=s;(!e||r&Vl||r&Xl)&&(this.eventBus&&r&Gl&&(i||=new Map).set(n,a),this.#rc.set(n,a))}if(i)for(const[t,e]of i)this.eventBus.dispatch(t.toLowerCase(),{source:this,value:e})}}function Ql({width:t,height:e,left:i,top:n},s){if(0===t||0===e)return null;const a=s.textLayer.div.getBoundingClientRect(),r=s.getPagePoint(i-a.left,n-a.top),o=s.getPagePoint(i-a.left+t,n-a.top+e);return fr.normalizeRect([r[0],r[1],o[0],o[1]])}function Zl(t,e){const i=t.getClientRects();if(1===i.length)return{rect:Ql(i[0],e)};const n=[1/0,1/0,-1/0,-1/0],s=[];let a=0;for(const t of i){const i=Ql(t,e);null!==i&&(s[a]=s[a+4]=i[0],s[a+1]=s[a+3]=i[3],s[a+2]=s[a+6]=i[2],s[a+5]=s[a+7]=i[1],fr.rectBoundingBox(...i,n),a+=8)}return{quadPoints:s,rect:n}}function Jl(t,e){let i=t;do{if(i.nodeType===Node.TEXT_NODE){const t=i.textContent.length;if(e<=t)return[i,e];e-=t}else if(i.firstChild){i=i.firstChild;continue}for(;!i.nextSibling&&i!==t;)i=i.parentNode;i!==t&&(i=i.nextSibling)}while(i!==t);throw new Error("Offset is bigger than container's contents length.")}class th{static#oc=0;static#n;static#lc;static findLinks(t){this.#n??=/\b(?:https?:\/\/|mailto:|www\.)(?:[\S--[\p{P}<>]]|\/|[\S--[\[\]]]+[\S--[\p{P}<>]])+|(?=\p{L})[\S--[@\p{Ps}\p{Pe}<>]]+@([\S--[[\p{P}--\-]<>]]+(?:\.[\S--[[\p{P}--\-]<>]]+)+)/gv;const[e,i]=co(t,{ignoreDashEOL:!0}),n=e.matchAll(this.#n),s=[];for(const t of n){const[e,n]=t;let a;if(e.startsWith("www.")||e.startsWith("http://")||e.startsWith("https://"))a=e;else if(n){const t=URL.parse(`http://${n}`)?.hostname;if(!t)continue;if(this.#lc??=/\.\d+$/,this.#lc.test(t))continue}a??=e.startsWith("mailto:")?e:`mailto:${e}`;const r=Pa(a,null,{addDefaultProtocol:!0});if(r){const[n,a]=uo(i,t.index,e.length);s.push({url:r.href,index:n,length:a})}}return s}static processLinks(t){return this.findLinks(t._textHighlighter.textContentItemsStr.join("\n")).map(e=>function({url:t,index:e,length:i},n,s){const a=n._textHighlighter,[{begin:r,end:o}]=a._convertMatches([e],[i]),l=new Range;return l.setStart(...Jl(a.textDivs[r.divIdx],r.offset)),l.setEnd(...Jl(a.textDivs[o.divIdx],o.offset)),{id:`inferred_link_${s}`,unsafeUrl:t,url:t,annotationType:xa.LINK,rotation:0,...Zl(l,n),borderStyle:null}}(e,t,this.#oc++))}}const eh={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3};class ih{renderingId="";renderTask=null;resume=null;get renderingState(){throw new Error("Abstract getter `renderingState` accessed")}set renderingState(t){throw new Error("Abstract setter `renderingState` accessed")}async draw(){throw new Error("Not implemented: draw")}}class nh extends ih{#hc=null;#dc=null;#cc=eh.INITIAL;#uc=null;#pc=0;#gc=null;canvas=null;div=null;enableOptimizedPartialRendering=!1;enableSelectionRendering=!0;imagesRightClickMinSize=-1;eventBus=null;id=null;imageCoordinates=null;pageColors=null;recordedBBoxes=null;renderingQueue=null;constructor(t){super(),this.eventBus=t.eventBus,this.id=t.id,this.pageColors=t.pageColors||null,this.renderingQueue=t.renderingQueue,this.enableOptimizedPartialRendering=t.enableOptimizedPartialRendering??!1,this.enableSelectionRendering=!1!==t.enableSelectionRendering,this.imagesRightClickMinSize=t.imagesRightClickMinSize??-1,this.minDurationToUpdateCanvas=t.minDurationToUpdateCanvas??500}get renderingState(){return this.#cc}set renderingState(t){if(t!==this.#cc)switch(this.#cc=t,this.#hc&&(clearTimeout(this.#hc),this.#hc=null),t){case eh.PAUSED:this.div.classList.remove("loading"),this.#pc=0,this.#uc?.(!1);break;case eh.RUNNING:this.div.classList.add("loadingIcon"),this.#hc=setTimeout(()=>{this.div.classList.add("loading"),this.#hc=null},0),this.#pc=Date.now();break;case eh.INITIAL:case eh.FINISHED:this.div.classList.remove("loadingIcon","loading"),this.#pc=0}}_createCanvas(t,e=!1){const{pageColors:i}=this,n=!(!i?.background||!i?.foreground),s=this.canvas,a=!s&&!n&&!e;let r=this.canvas=document.createElement("canvas");return this.#uc=e=>{if(a){let i=this.#gc;if(!e&&this.minDurationToUpdateCanvas>0){if(Date.now()-this.#pc<this.minDurationToUpdateCanvas)return;i||(i=this.#gc=r,r=this.canvas=r.cloneNode(!1),t(r))}if(i){return r.getContext("2d",{alpha:!1}).drawImage(i,0,0),void(e?this.#mc():this.#pc=Date.now())}return t(r),void(this.#uc=null)}e&&(s?(s.replaceWith(r),s.width=s.height=0):t(r))},{canvas:r,prevCanvas:s}}#fc=t=>{if(this.#uc?.(!1),this.renderingQueue&&!this.renderingQueue.isHighestPriority(this))return this.renderingState=eh.PAUSED,void(this.resume=()=>{this.renderingState=eh.RUNNING,t()});t()};_resetCanvas(){const{canvas:t}=this;t&&(t.remove(),t.width=t.height=0,this.canvas=null,this.#mc())}#mc(){this.#gc&&(this.#gc.width=this.#gc.height=0,this.#gc=null)}async _drawCanvas(t,e,i){const n=this.renderTask=this.pdfPage.render(t);n.onContinue=this.#fc,n.onError=t=>{t instanceof sr&&(e(),this.#dc=null)};let s=null;try{await n.promise,this.#uc?.(!0)}catch(t){if(t instanceof sr)return;s=t,this.#uc?.(!0)}finally{this.#dc=s,n===this.renderTask&&(this.renderTask=null,this.enableOptimizedPartialRendering&&(this.recordedBBoxes??=n.recordedBBoxes),-1!==this.imagesRightClickMinSize&&(this.imageCoordinates??=this.pdfPage.imageCoordinates))}if(this.renderingState=eh.FINISHED,i(n),s)throw s}cancelRendering({cancelExtraDelay:t=0}={}){this.renderTask&&(this.renderTask.cancel(t),this.renderTask=null),this.resume=null}dispatchPageRender(){this.eventBus.dispatch("pagerender",{source:this,pageNumber:this.id})}dispatchPageRendered(t,e){this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:t,isDetailView:e,timestamp:performance.now(),error:this.#dc})}}class sh{#ac=null;constructor(t){this.pageIndex=t.pageIndex,this.textLayer=t.textLayer||null,this.filterFactory=t.filterFactory||null,this.pageColors=t.pageColors||null}async render({intent:t="display"}){"display"!==t||this.#ac||this._cancelled||(this.#ac=new Ta({pageIndex:this.pageIndex,textLayer:this.textLayer,filterFactory:this.filterFactory,pageColors:this.pageColors}))}cancel(){this._cancelled=!0,this.#ac&&(this.#ac.destroy(),this.#ac=null)}setParent(t){this.#ac?.setParent(t)}getDrawLayer(){return this.#ac}}class ah extends nh{#bc=null;renderingCancelled=!1;constructor({pageView:t}){super(t),this.pageView=t,this.renderingId="detail"+this.id,this.div=t.div}setPdfPage(t){this.pageView.setPdfPage(t)}get pdfPage(){return this.pageView.pdfPage}get renderingState(){return super.renderingState}set renderingState(t){this.renderingCancelled=!1,super.renderingState=t}reset({keepCanvas:t=!1}={}){const e=this.renderingCancelled||this.renderingState===eh.RUNNING||this.renderingState===eh.PAUSED;this.cancelRendering(),this.renderingState=eh.INITIAL,this.renderingCancelled=e,t||this._resetCanvas()}#vc(t){if(!this.#bc)return!0;const e=this.#bc.minX,i=this.#bc.minY,n=this.#bc.width+e,s=this.#bc.height+i;if(t.minX<e||t.minY<i||t.maxX>n||t.maxY>s)return!0;const{width:a,height:r,scale:o}=this.pageView.viewport;if(this.#bc.scale!==o)return!0;const l=t.minX-e,h=n-t.maxX,d=t.minY-i,c=s-t.maxY;return e>0&&h/l>3||n<a&&l/h>3||i>0&&c/d>3||s<r&&d/c>3}update({visibleArea:t=null,underlyingViewUpdated:e=!1}={}){if(e)return this.cancelRendering(),void(this.renderingState=eh.INITIAL);if(!this.#vc(t))return;const{viewport:i,maxCanvasPixels:n,capCanvasAreaFactor:s}=this.pageView,a=t.maxX-t.minX,r=t.maxY-t.minY,o=a*r*Qa.pixelRatio**2,l=(Math.sqrt(Qa.capPixels(n,s)/o)-1)/2;let h=Math.min(1,l);h<0&&(h=0);const d=a*h,c=r*h,u=Math.max(0,t.minX-d),p=Math.min(i.width,t.maxX+d),g=Math.max(0,t.minY-c),m=p-u,f=Math.min(i.height,t.maxY+c)-g;this.#bc={minX:u,minY:g,width:m,height:f,scale:i.scale},this.reset({keepCanvas:!0})}_getRenderingContext(t,e){const i=this.pageView._getRenderingContext(t,e,!1),n=this.pdfPage.recordedBBoxes;if(!n||!this.enableOptimizedPartialRendering)return i;const{viewport:{width:s,height:a}}=this.pageView,{width:r,height:o,minX:l,minY:h}=this.#bc,d=l/s,c=h/a,u=(l+r)/s,p=(h+o)/a;return{...i,operationsFilter:t=>!n.isEmpty(t)&&(n.minX(t)<=u&&n.maxX(t)>=d&&n.minY(t)<=p&&n.maxY(t)>=c)}}async draw(){if(this.pageView.detailView!==this)return;const t=this.pageView.renderingState===eh.FINISHED||this.renderingState===eh.FINISHED;this.renderingState!==eh.INITIAL&&(console.error("Must be in new state before drawing"),this.reset());const{div:e,pdfPage:i,viewport:n}=this.pageView;if(!i)throw this.renderingState=eh.FINISHED,new Error("pdfPage is not loaded");this.renderingState=eh.RUNNING;const s=this.pageView._ensureCanvasWrapper(),{canvas:a,prevCanvas:r}=this._createCanvas(t=>{"CANVAS"===s.firstElementChild?.tagName?s.firstElementChild.after(t):s.prepend(t)},t);a.ariaHidden=!0,this.enableOptimizedPartialRendering&&(a.className="detailView");const{width:o,height:l}=n,h=this.#bc,{pixelRatio:d}=Qa,c=[d,0,0,d,-h.minX*d,-h.minY*d];a.width=h.width*d,a.height=h.height*d;const{style:u}=a;u.width=100*h.width/o+"%",u.height=100*h.height/l+"%",u.top=100*h.minY/l+"%",u.left=100*h.minX/o+"%";const p=this._drawCanvas(this._getRenderingContext(a,c),()=>{this.canvas?.remove(),this.canvas=r},()=>{this.dispatchPageRendered(!1,!0)});return e.setAttribute("data-loaded",!0),this.dispatchPageRender(),p}}const rh={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:"rowgroup",TBody:"rowgroup",TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},oh=new Set(["math","merror","mfrac","mi","mmultiscripts","mn","mo","mover","mpadded","mprescripts","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msubsup","msup","mtable","mtd","mtext","mtr","munder","munderover","semantics"]),lh="http://www.w3.org/1998/Math/MathML";class hh{static get sanitizer(){return lr(this,"sanitizer",Ma.isSanitizerSupported?new Sanitizer({elements:[...oh].map(t=>({name:t,namespace:lh})),replaceWithChildrenElements:[{name:"maction",namespace:lh}],attributes:["dir","displaystyle","mathbackground","mathcolor","mathsize","scriptlevel","encoding","display","linethickness","intent","arg","form","fence","separator","lspace","rspace","stretchy","symmetric","maxsize","minsize","largeop","movablelimits","width","height","depth","voffset","accent","accentunder","columnspan","rowspan"],comments:!1}):null)}}const dh=/^H(\d+)$/;class ch{#wc;#yc=null;#xc;#Ac=new Map;#Cc;#Sc=null;#Pc=null;#_c=null;constructor(t,e){this.#wc=t.getStructTree(),this.#Cc=e}async render(){if(this.#xc)return this.#xc;const{promise:t,resolve:e,reject:i}=Promise.withResolvers();this.#xc=t;try{this.#yc=this.#Ec(await this.#wc)}catch(t){i(t)}return this.#wc=null,this.#yc?.classList.add("structTree"),e(this.#yc),t}async getAriaAttributes(t){try{return await this.render(),this.#Ac.get(t)}catch{}return null}hide(){this.#yc&&!this.#yc.hidden&&(this.#yc.hidden=!0)}show(){this.#yc?.hidden&&(this.#yc.hidden=!1)}#Tc(t,e){const{alt:i,id:n,lang:s}=t;if(void 0!==i){let n=!1;const s=Hr(i);for(const e of t.children)"annotation"===e.type&&(this.#Ac.getOrInsertComputed(e.id,Wa).set("aria-label",s),n=!0);n||e.setAttribute("aria-label",s)}void 0!==n&&e.setAttribute("aria-owns",n),void 0!==s&&e.setAttribute("lang",Hr(s,!0))}#Mc(t,e){const{alt:i,bbox:n,children:s}=t,a=s?.[0];if(!this.#Cc||!i||!n||"content"!==a?.type)return!1;const{id:r}=a;if(!r)return!1;e.setAttribute("aria-owns",r);const o=document.createElement("span");(this.#Sc||=new Map).set(r,o),o.setAttribute("role","img"),o.setAttribute("aria-label",Hr(i));const{pageHeight:l,pageX:h,pageY:d}=this.#Cc,c="calc(var(--total-scale-factor) *",{style:u}=o;return u.width=`${c}${n[2]-n[0]}px)`,u.height=`${c}${n[3]-n[1]}px)`,u.left=`${c}${n[0]-h}px)`,u.top=`${c}${l-n[3]+d}px)`,!0}updateTextLayer(){if(this.#Sc){for(const[t,e]of this.#Sc)document.getElementById(t)?.append(e);this.#Sc.clear(),this.#Sc=null}if(this.#Pc){for(const t of this.#Pc){const e=document.getElementById(t);e&&(e.ariaHidden=!0)}this.#Pc.length=0,this.#Pc=null}if(this.#_c){for(let t=0,e=this.#_c.length;t<e;t+=2){const e=this.#_c[t],i=this.#_c[t+1];let n="";for(const t of i){const e=document.getElementById(t);e&&(n+=e.textContent.trim()||"",e.ariaHidden="true")}n&&(e.textContent=n)}this.#_c.length=0,this.#_c=null}}#kc(t,e){if(t){"id"in t&&e.push(t.id);for(const i of t.children||[])this.#kc(i,e)}}#Ec(t,e=[]){if(!t)return null;let i,n=!0;if("role"in t){const{role:s}=t;if(oh.has(s)){i=document.createElementNS(lh,s);const e=[];(this.#_c||=[]).push(i,e);for(const{type:i,id:n}of t.children||[])"content"===i&&n&&e.push(n)}else i=document.createElement("span");const a=s.match(dh);if(a?(i.setAttribute("role","heading"),i.setAttribute("aria-level",a[1])):rh[s]&&i.setAttribute("role","TH"===s&&"TR"===e.at(-1)?.role&&"TBody"===e.at(-2)?.role?"rowheader":rh[s]),"Figure"===s&&this.#Mc(t,i))return i;"Formula"===s&&(t.mathML&&hh.sanitizer&&(n=!1,i.setHTML(t.mathML,{sanitizer:hh.sanitizer}),this.#kc(t,this.#Pc||=[]),delete t.alt),t.mathML||1!==t.children.length||"math"===t.children[0].role||(i=document.createElementNS(lh,"math"),delete t.alt))}if(i||=document.createElement("span"),this.#Tc(t,i),t.children)if(1===t.children.length&&"id"in t.children[0])this.#Tc(t.children[0],i);else if(n){e.push(t);for(const n of t.children)i.append(this.#Ec(n,e));e.pop()}return i}}class uh{#Dc=!1;#Ic=null;#Lc=new Map;#Nc=new Map;setTextMapping(t){this.#Ic=t}static#Rc(t,e){const i=t.getBoundingClientRect(),n=e.getBoundingClientRect();if(0===i.width&&0===i.height)return 1;if(0===n.width&&0===n.height)return-1;const s=i.y,a=i.y+i.height,r=i.y+i.height/2,o=n.y,l=n.y+n.height,h=n.y+n.height/2;if(r<=o&&h>=a)return-1;if(h<=s&&r>=l)return 1;return i.x+i.width/2-(n.x+n.width/2)}enable(){if(this.#Dc)throw new Error("TextAccessibilityManager is already enabled.");if(!this.#Ic)throw new Error("Text divs and strings have not been set.");if(this.#Dc=!0,this.#Ic=this.#Ic.slice(),this.#Ic.sort(uh.#Rc),this.#Lc.size>0){const t=this.#Ic;for(const[e,i]of this.#Lc){document.getElementById(e)?this.#Fc(e,t[i]):this.#Lc.delete(e)}}for(const[t,e]of this.#Nc)this.addPointerInTextLayer(t,e);this.#Nc.clear()}disable(){this.#Dc&&(this.#Nc.clear(),this.#Ic=null,this.#Dc=!1)}removePointerInTextLayer(t){if(!this.#Dc)return void this.#Nc.delete(t);const e=this.#Ic;if(!e||0===e.length)return;const{id:i}=t,n=this.#Lc.get(i);if(void 0===n)return;const s=e[n];this.#Lc.delete(i);let a=s.getAttribute("aria-owns");a?.includes(i)&&(a=a.split(" ").filter(t=>t!==i).join(" "),a?s.setAttribute("aria-owns",a):(s.removeAttribute("aria-owns"),s.setAttribute("role","presentation")))}#Fc(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.#Dc)return this.#Nc.set(t,e),null;e&&this.removePointerInTextLayer(t);const n=this.#Ic;if(!n||0===n.length)return null;const s=Vr(n,e=>uh.#Rc(t,e)<0),a=Math.max(0,s-1),r=n[a];this.#Fc(i,r),this.#Lc.set(i,a);const o=r.parentNode;return o?.classList.contains("markedContent")?o.id:null}moveElementInDOM(t,e,i,n){const s=this.addPointerInTextLayer(i,n);if(!t.hasChildNodes())return t.append(e),s;const a=Array.from(t.childNodes).filter(t=>t!==e);if(0===a.length)return s;const r=Vr(a,t=>uh.#Rc(e,t)<0);return 0===r?a[0].before(e):a[r-1].after(e),s}}class ph{#$d=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.#$d||(this.#$d=new AbortController,this.eventBus.on("updatetextlayermatches",t=>{t.pageIndex!==this.pageIdx&&-1!==t.pageIndex||this._updateMatches()},{signal:this.#$d.signal,...Yr})),this._updateMatches()}disable(){this.enabled&&(this.enabled=!1,this.#$d?.abort(),this.#$d=null,this._updateMatches(!0))}_convertMatches(t,e){if(!t)return[];const{textContentItemsStr:i}=this;let n=0,s=0;const a=i.length-1,r=[];for(let o=0,l=t.length;o<l;o++){let l=t[o];for(;n!==a&&l>=s+i[n].length;)s+=i[n].length,n++;n===i.length&&console.error("Could not find a matching mapping");const h={begin:{divIdx:n,offset:l-s}};for(l+=e[o];n!==a&&l>s+i[n].length;)s+=i[n].length,n++;h.end={divIdx:n,offset:l-s},r.push(h)}return r}_renderMatches(t){if(0===t.length)return;const{findController:e,pageIdx:i}=this,{textContentItemsStr:n,textDivs:s}=this,a=i===e.selected.pageIdx,r=e.selected.matchIdx;let o=null;const l={offset:void 0};function h(t,e){const i=t.divIdx;return s[i].textContent="",d(i,0,t.offset,e)}function d(t,e,i,a){let r=s[t];if(r.nodeType===Node.TEXT_NODE){const e=document.createElement("span");r.before(e),e.append(r),s[t]=e,r=e}const o=n[t].substring(e,i),l=document.createTextNode(o);if(a){const t=document.createElement("span");return t.className=`${a} appended`,t.append(l),r.append(t),a.includes("selected")?t:null}return r.append(l),0}let c=r,u=c+1;if(e.state.highlightAll)c=0,u=t.length;else if(!a)return;let p=-1,g=-1;for(let n=c;n<u;n++){const c=t[n],u=c.begin;if(u.divIdx===p&&u.offset===g)continue;p=u.divIdx,g=u.offset;const m=c.end,f=a&&n===r,b=f?" selected":"";let v=null;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===m.divIdx)v=d(u.divIdx,u.offset,m.offset,"highlight"+b);else{v=d(u.divIdx,u.offset,l.offset,"highlight begin"+b);for(let t=u.divIdx+1,e=m.divIdx;t<e;t++)s[t].className="highlight middle"+b;h(m,"highlight end"+b)}o=m,f&&e.scrollMatchIntoView({element:v,pageIndex:i,matchIndex:r})}o&&d(o.divIdx,o.offset,l.offset)}_updateMatches(t=!1){if(!this.enabled&&!t)return;const{findController:e,matches:i,pageIdx:n}=this,{textContentItemsStr:s,textDivs:a}=this;let r=-1;for(const t of i){for(let e=Math.max(r,t.begin.divIdx),i=t.end.divIdx;e<=i;e++){const t=a[e];t.textContent=s[e],t.className=""}r=t.end.divIdx+1}if(!e?.highlightMatches||t)return;const o=e.pageMatches[n]||null,l=e.pageMatchesLength[n]||null;this.matches=this._convertMatches(o,l),this._renderMatches(this.matches)}}class gh{#Oc=null;#Bc=!1;#zd=null;#jc=!1;#Dh=null;static#qh=new Map;static#Wh=null;constructor({pdfPage:t,highlighter:e=null,accessibilityManager:i=null,enablePermissions:n=!1,onAppend:s=null,abortSignal:a=null}){this.pdfPage=t,this.highlighter=e,this.accessibilityManager=i,this.#Bc=!0===n,this.#zd=s,this.#Oc=a,this.div=document.createElement("div"),this.div.tabIndex=0,this.div.className="textLayer"}async render({viewport:t,images:e,textContentParams:i=null}){if(this.#jc&&this.#Dh)return this.#Dh.update({viewport:t,onBefore:this.hide.bind(this)}),void this.show();this.cancel(),this.#Dh=new ur({textContentSource:this.pdfPage.streamTextContent(i||{includeMarkedContent:!0,disableNormalization:!0}),images:e,container:this.div,viewport:t});const{textDivs:n,textContentItemsStr:s}=this.#Dh;this.highlighter?.setTextMapping(n,s),this.accessibilityManager?.setTextMapping(n),await this.#Dh.render(),this.#jc=!0;const a=document.createElement("div");a.className="endOfContent",this.div.append(a),this.#Uc(a),this.#zd?.(this.div),this.highlighter?.enable(),this.accessibilityManager?.enable()}hide(){!this.div.hidden&&this.#jc&&(this.highlighter?.disable(),this.div.hidden=!0)}show(){this.div.hidden&&this.#jc&&(this.div.hidden=!1,this.highlighter?.enable())}cancel(){this.#Dh?.cancel(),this.#Dh=null,this.#jc=!1,this.div.replaceChildren(),this.highlighter?.disable(),this.accessibilityManager?.disable(),gh.#Hc(this.div)}#Uc(t){const{div:e}=this,i=this.#Oc,n=i?{signal:i}:null;e.addEventListener("mousedown",()=>{e.classList.add("selecting")},n),e.addEventListener("copy",t=>{if(!this.#Bc){const e=document.getSelection();t.clipboardData.setData("text/plain",Hr(qa(e.toString())))}dr(t)},n),gh.#qh.set(e,t),gh.#Vc(i)}static#Hc(t){this.#qh.delete(t),0===this.#qh.size&&(this.#Wh?.abort(),this.#Wh=null)}static#Vc(t){if(this.#Wh)return;this.#Wh=new AbortController;const e=t?AbortSignal.any([this.#Wh.signal,t]):this.#Wh.signal,i=(t,e)=>{e.append(t),t.style.width="",t.style.height="",e.classList.remove("selecting")};let n=!1;var s,a;document.addEventListener("pointerdown",()=>{n=!0},{signal:e}),document.addEventListener("pointerup",()=>{n=!1,this.#qh.forEach(i)},{signal:e}),window.addEventListener("blur",()=>{n=!1,this.#qh.forEach(i)},{signal:e}),document.addEventListener("keyup",()=>{n||this.#qh.forEach(i)},{signal:e}),document.addEventListener("selectionchange",()=>{const t=document.getSelection();if(0===t.rangeCount)return void this.#qh.forEach(i);const e=new Set;for(let i=0;i<t.rangeCount;i++){const n=t.getRangeAt(i);for(const t of this.#qh.keys())!e.has(t)&&n.intersectsNode(t)&&e.add(t)}for(const[t,n]of this.#qh)e.has(t)?t.classList.add("selecting"):i(n,t);if(s??="none"===getComputedStyle(this.#qh.values().next().value).getPropertyValue("-moz-user-select"),s)return;const n=t.getRangeAt(0),r=a&&(0===n.compareBoundaryPoints(Range.END_TO_END,a)||0===n.compareBoundaryPoints(Range.START_TO_END,a));let o=r?n.startContainer:n.endContainer;if(o.nodeType===Node.TEXT_NODE&&(o=o.parentNode),o.classList?.contains("highlight")&&(o=o.parentNode),!r&&0===n.endOffset)do{for(;!o.previousSibling;)o=o.parentNode;o=o.previousSibling}while(!o.childNodes.length);const l=o.parentElement?.closest(".textLayer"),h=this.#qh.get(l);h&&(h.style.width=l.style.width,h.style.height=l.style.height,h.style.userSelect="text",o.parentElement.insertBefore(h,r?o:o.nextSibling)),a=n.cloneRange()},{signal:e})}}class mh{#zc=!1;div=null;constructor({pdfPage:t,annotationStorage:e=null,linkService:i,xfaHtml:n=null}){this.pdfPage=t,this.annotationStorage=e,this.linkService=i,this.xfaHtml=n}async render({viewport:t,intent:e="display"}){let i;if("print"===e)i=this.xfaHtml;else if(i=await this.pdfPage.getXfa(),this.#zc||!i)return{textDivs:[]};const n=!!this.div,s={viewport:t.clone({dontFlip:!0}),div:this.div??=document.createElement("div"),xfaHtml:i,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:e};return n?wr.update(s):wr.render(s)}cancel(){this.#zc=!0}hide(){this.div&&(this.div.hidden=!0)}}const fh={annotationEditorUIManager:null,annotationStorage:null,downloadManager:null,enableScripting:!1,fieldObjectsPromise:null,findController:null,hasJSActionsPromise:null,get linkService(){return new fo}},bh=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);class vh extends nh{#Oc=null;#$c=ya.ENABLE_FORMS;#Wc=null;#W=null;#Gc=!0;#Xc=!1;#Ke=!1;#Kc=null;#qc=!1;#Yc=null;#Qc=null;#Zc=1;#Jc=1;#tu=Rr;#eu=1;#iu={directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0};#nu=[null,null,null,null];constructor(t){super(t);const{container:e,defaultViewport:i}=t;this.renderingId="page"+this.id,this.#Kc=t.layerProperties||fh,this.#Oc=t.abortSignal||null,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.#tu=t.textLayerMode??Rr,this.#$c=t.annotationMode??ya.ENABLE_FORMS,this.imageResourcesPath=t.imageResourcesPath||"",this.enableDetailCanvas=t.enableDetailCanvas??!0,this.maxCanvasPixels=t.maxCanvasPixels??Yl.get("maxCanvasPixels"),this.maxCanvasDim=t.maxCanvasDim||Yl.get("maxCanvasDim"),this.capCanvasAreaFactor=t.capCanvasAreaFactor??Yl.get("capCanvasAreaFactor"),this.#Gc=!1!==t.enableAutoLinking,this.#W=t.commentManager||null,this.l10n=t.l10n,this.l10n||=new Bl,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,this.detailView=null;const n=document.createElement("div");if(n.className="page",n.setAttribute("data-page-number",this.id),n.setAttribute("role","region"),n.setAttribute("data-l10n-id","pdfjs-page-landmark"),n.setAttribute("data-l10n-args",JSON.stringify({page:this.id})),this.div=n,this.#su(),e?.append(n),this._isStandalone){e?.style.setProperty("--scale-factor",this.scale*nr.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.#iu.initialOptionalContent=t.hasInitialVisibility)}),t.l10n||this.l10n.translate(this.div)}}clone(t){const e=new vh({container:null,eventBus:this.eventBus,pagesColors:this.pageColors,renderingQueue:this.renderingQueue,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,minDurationToUpdateCanvas:this.minDurationToUpdateCanvas,defaultViewport:this.viewport,id:t,layerProperties:this.#Kc,abortSignal:this.#Oc,scale:this.scale,optionalContentConfigPromise:this._optionalContentConfigPromise,textLayerMode:this.#tu,annotationMode:this.#$c,imageResourcesPath:this.imageResourcesPath,enableDetailCanvas:this.enableDetailCanvas,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,capCanvasAreaFactor:this.capCanvasAreaFactor,enableAutoLinking:this.#Gc,commentManager:this.#W,l10n:this.l10n});return e.setPdfPage(this.pdfPage.clone(t-1)),e}#au(t,e){const i=bh.get(e),n=this.#nu[i];if(this.#nu[i]=t,n)n.replaceWith(t);else{for(let e=i-1;e>=0;e--){const i=this.#nu[e];if(i)return void i.after(t)}this.div.prepend(t)}}#su(){const{div:t,viewport:e}=this;if(e.userUnit!==this.#eu&&(1!==e.userUnit?t.style.setProperty("--user-unit",e.userUnit):t.style.removeProperty("--user-unit"),this.#eu=e.userUnit),this.pdfPage){if(this.#Qc===e.rotation)return;this.#Qc=e.rotation}or(t,e,!0,!1)}updatePageNumber(t){if(this.id===t)return;const e=this.id;this.id=t,this.renderingId=`page${t}`,this.pdfPage&&(this.pdfPage.pageNumber=t),this.setPageLabel(this.pageLabel);const{div:i}=this;i.setAttribute("data-page-number",t),i.setAttribute("data-l10n-args",JSON.stringify({page:t})),this._textHighlighter.pageIdx=t-1,this.#Kc.annotationEditorUIManager?.updatePageIndex(e-1,t-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*nr.PDF_TO_CSS_UNITS,rotation:e}),this.#su(),this.reset()}destroy(){this.reset(),this.pdfPage?.cleanup()}deleteMe(t){t?this.div.remove():(this.destroy(),this.#Kc.annotationEditorUIManager?.deletePage(this.id))}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}get _textHighlighter(){return lr(this,"_textHighlighter",new ph({pageIndex:this.id-1,eventBus:this.eventBus,findController:this.#Kc.findController}))}#ru(t,e){this.eventBus.dispatch(t,{source:this,pageNumber:this.id,error:e})}async#ou(){let t=null;try{await this.annotationLayer.render({viewport:this.viewport,intent:"display",structTreeLayer:this.structTreeLayer,optionalContentConfigPromise:this._optionalContentConfigPromise})}catch(e){console.error("#renderAnnotationLayer:",e),t=e}finally{this.#ru("annotationlayerrendered",t)}}async#lu(){let t=null;try{await this.annotationEditorLayer.render({viewport:this.viewport,intent:"display"})}catch(e){console.error("#renderAnnotationEditorLayer:",e),t=e}finally{this.#ru("annotationeditorlayerrendered",t)}}async#hu(){try{await this.drawLayer.render({intent:"display"})}catch(t){console.error("#renderDrawLayer:",t)}}async#du(){let t=null;try{const t=await this.xfaLayer.render({viewport:this.viewport,intent:"display"});t?.textDivs&&this._textHighlighter&&this.#cu(t.textDivs)}catch(e){console.error("#renderXfaLayer:",e),t=e}finally{this.xfaLayer?.div&&(this.l10n.pause(),this.#au(this.xfaLayer.div,"xfaLayer"),this.l10n.resume()),this.#ru("xfalayerrendered",t)}}async#uu(){if(!this.textLayer)return;let t=null;try{await this.textLayer.render({viewport:this.viewport,images:this.imageCoordinates?new pr(this.imagesRightClickMinSize,this.imageCoordinates,this.viewport,()=>this.canvas):null})}catch(e){if(e instanceof ga)return;console.error("#renderTextLayer:",e),t=e}this.#ru("textlayerrendered",t),this.#pu()}async#pu(){if(!this.textLayer)return;const t=await(this.structTreeLayer?.render());t&&(this.l10n.pause(),this.structTreeLayer?.updateTextLayer(),this.canvas&&t.parentNode!==this.canvas&&this.canvas.append(t),this.l10n.resume()),this.structTreeLayer?.show()}async#cu(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()}async#gu(t){try{if(await t,!this.annotationLayer)return;await this.annotationLayer.injectLinkAnnotations(th.processLinks(this))}catch(t){console.error("#injectLinkAnnotations:",t)}}_resetCanvas(){super._resetCanvas(),this.#Yc=null}reset({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:n=!1,keepCanvasWrapper:s=!1,preserveDetailViewState:a=!1}={}){const r=this.pdfPage?._pdfBug??!1;this.cancelRendering({keepAnnotationLayer:t,keepAnnotationEditorLayer:e,keepXfaLayer:i,keepTextLayer:n}),this.renderingState=eh.INITIAL;const o=this.div,l=o.childNodes,h=t&&this.annotationLayer?.div||null,d=e&&this.annotationEditorLayer?.div||null,c=i&&this.xfaLayer?.div||null,u=n&&this.textLayer?.div||null,p=s&&this.#Wc||null;for(let t=l.length-1;t>=0;t--){const e=l[t];switch(e){case h:case d:case c:case u:case p:continue}if(r&&e.classList.contains("pdfBugGroupsLayer"))continue;e.remove();const i=this.#nu.indexOf(e);i>=0&&(this.#nu[i]=null)}o.removeAttribute("data-loaded"),h&&this.annotationLayer.hide(),d&&this.annotationEditorLayer.hide(),c&&this.xfaLayer.hide(),u&&this.textLayer.hide(),this.structTreeLayer?.hide(),!s&&this.#Wc&&(this.#Wc=null,this._resetCanvas()),a||(this.detailView?.reset({keepCanvas:s}),s||(this.detailView=null))}toggleEditingMode(t){this.#Ke=t,this.hasEditableAnnotations()&&this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0})}updateVisibleArea(t){this.enableDetailCanvas&&(this.#qc&&this.maxCanvasPixels>0&&t?(this.detailView??=new ah({pageView:this,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,imagesRightClickMinSize:-1}),this.detailView.update({visibleArea:t})):this.detailView&&(this.detailView.reset(),this.detailView=null))}update({scale:t=0,rotation:e=null,optionalContentConfigPromise:i=null,drawingDelay:n=-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.#iu.initialOptionalContent=t.hasInitialVisibility)})),this.#iu.directDrawing=!0;const s=(this.rotation+this.pdfPageRotate)%360;if(this.viewport=this.viewport.clone({scale:this.scale*nr.PDF_TO_CSS_UNITS,rotation:s}),this.#su(),this._isStandalone&&this._container?.style.setProperty("--scale-factor",this.viewport.scale),this.#mu(),this.canvas){const t=this.#Xc&&this.#qc,e=n>=0&&n<1e3;if(e||t)return e&&!t&&this.renderingState!==eh.FINISHED&&(this.cancelRendering({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:n}),this.renderingState=eh.FINISHED,this.#iu.directDrawing=!1),this.cssTransform({redrawAnnotationLayer:!0,redrawAnnotationEditorLayer:!0,redrawXfaLayer:!0,redrawTextLayer:!e,hideTextLayer:e}),void(e||(this.detailView?.update({underlyingViewUpdated:!0}),this.dispatchPageRendered(!0,!1)))}this.cssTransform({}),this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0,preserveDetailViewState:!0}),this.detailView?.update({underlyingViewUpdated:!0})}#mu(){const{width:t,height:e}=this.viewport,i=this.outputScale=new Qa;if(0===this.maxCanvasPixels){const t=1/this.scale;i.sx*=t,i.sy*=t,this.#qc=!0}else if(this.#qc=i.limitCanvas(t,e,this.maxCanvasPixels,this.maxCanvasDim,this.capCanvasAreaFactor),this.#qc&&this.enableDetailCanvas){const t=this.enableOptimizedPartialRendering?4:2;i.sx/=t,i.sy/=t}}cancelRendering({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:n=!1,cancelExtraDelay:s=0}={}){super.cancelRendering({cancelExtraDelay:s}),!this.textLayer||n&&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:n=!1,hideTextLayer:s=!1}){const{canvas:a}=this;if(!a)return;const r=this.#Yc;if(this.viewport!==r){const t=(360+this.viewport.rotation-r.rotation)%360;if(90===t||270===t){const{width:e,height:i}=this.viewport,n=i/e,s=e/i;a.style.transform=`rotate(${t}deg) scale(${n},${s})`}else a.style.transform=0===t?"":`rotate(${t}deg)`}t&&this.annotationLayer&&this.#ou(),e&&this.annotationEditorLayer&&(this.drawLayer&&this.#hu(),this.#lu()),i&&this.xfaLayer&&this.#du(),this.textLayer&&(s?(this.textLayer.hide(),this.structTreeLayer?.hide()):n&&this.#uu())}get width(){return this.viewport.width}get height(){return this.viewport.height}getPagePoint(t,e){return this.viewport.convertToPdfPoint(t,e)}_ensureCanvasWrapper(){let t=this.#Wc;return t||(t=this.#Wc=document.createElement("div"),t.classList.add("canvasWrapper"),this.#au(t,"canvasWrapper")),t}_getRenderingContext(t,e,i,n){return{canvas:t,transform:e,viewport:this.viewport,annotationMode:this.#$c,optionalContentConfigPromise:this._optionalContentConfigPromise,annotationCanvasMap:this._annotationCanvasMap,pageColors:this.pageColors,isEditing:this.#Ke,recordOperations:i,recordImages:n}}async draw(){this.renderingState!==eh.INITIAL&&(console.error("Must be in new state before drawing"),this.reset());const{div:t,l10n:e,pdfPage:i,viewport:n}=this;if(!i)throw this.renderingState=eh.FINISHED,new Error("pdfPage is not loaded");this.renderingState=eh.RUNNING;const s=this._ensureCanvasWrapper();if(this.textLayer||this.#tu===Nr||i.isPureXfa||(this._accessibilityManager||=new uh,this.textLayer=new gh({pdfPage:i,highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,enablePermissions:this.#tu===Fr,onAppend:t=>{this.l10n.pause(),this.#au(t,"textLayer"),this.l10n.resume()},abortSignal:this.#Oc})),!this.annotationLayer&&this.#$c!==ya.DISABLE){const{annotationStorage:t,annotationEditorUIManager:e,downloadManager:n,enableComment:s,enableScripting:a,fieldObjectsPromise:r,hasJSActionsPromise:o,linkService:l}=this.#Kc;this._annotationCanvasMap||=new Map,this.annotationLayer=new bo({pdfPage:i,annotationStorage:t,imageResourcesPath:this.imageResourcesPath,renderForms:this.#$c===ya.ENABLE_FORMS,linkService:l,downloadManager:n,enableComment:s,enableScripting:a,hasJSActionsPromise:o,fieldObjectsPromise:r,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager,annotationEditorUIManager:e,commentManager:this.#W,onAppend:t=>{this.#au(t,"annotationLayer")}})}const{width:a,height:r}=n;this.#Yc=n;const{canvas:o,prevCanvas:l}=this._createCanvas(t=>{s.prepend(t)});o.setAttribute("role","presentation"),this.outputScale||this.#mu();const{outputScale:h}=this;this.#Xc=this.#qc;const d=zr(h.sx),c=zr(h.sy),u=o.width=$r(Kr(a*h.sx),d[0]),p=o.height=$r(Kr(r*h.sy),c[0]),g=$r(Kr(a),d[1]),m=$r(Kr(r),c[1]);h.sx=u/g,h.sy=p/m,this.#Zc!==d[1]&&(t.style.setProperty("--scale-round-x",`${d[1]}px`),this.#Zc=d[1]),this.#Jc!==c[1]&&(t.style.setProperty("--scale-round-y",`${c[1]}px`),this.#Jc=c[1]);const f=this.enableOptimizedPartialRendering&&this.#Xc&&!this.recordedBBoxes,b=-1!==this.imagesRightClickMinSize&&!this.imageCoordinates,v=h.scaled?[h.sx,0,0,h.sy,0,0]:null,w=this._drawCanvas(this._getRenderingContext(o,v,f,b),()=>{l?.remove(),this._resetCanvas()},t=>{this.#iu.regularAnnotations=!t.separateAnnots,this.dispatchPageRendered(!1,!1)}).then(async()=>{if(this.renderingState!==eh.FINISHED)return;this.structTreeLayer||=new ch(i,n.rawDims);const t=this.#uu();this.annotationLayer&&(await this.#ou(),this.#Gc&&this.annotationLayer&&this.textLayer&&await this.#gu(t)),this.drawLayer||=new sh({pageIndex:this.id,textLayer:this.enableSelectionRendering?this.textLayer?.div:null,filterFactory:this.pdfPage?.filterFactory,pageColors:this.pageColors}),await this.#hu(),this.drawLayer.setParent(s);const{annotationEditorUIManager:a}=this.#Kc;a&&(this.annotationLayer||this.#$c===ya.DISABLE)&&(this.annotationEditorLayer||=new Ul({uiManager:a,pageIndex:this.id-1,l10n:e,structTreeLayer:this.structTreeLayer,accessibilityManager:this._accessibilityManager,annotationLayer:this.annotationLayer?.annotationLayer,textLayer:this.textLayer,drawLayer:this.drawLayer.getDrawLayer(),onAppend:t=>{this.#au(t,"annotationEditorLayer")}}),this.#lu())});if(i.isPureXfa){if(!this.xfaLayer){const{annotationStorage:t,linkService:e}=this.#Kc;this.xfaLayer=new mh({pdfPage:i,annotationStorage:t,linkService:e})}this.#du()}return t.setAttribute("data-loaded",!0),this.dispatchPageRender(),w}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.#iu;return t&&e&&i?this.canvas:null}}class wh{constructor(t,e){this._ready=new Promise((i,n)=>{import(t).then(t=>{i(t.QuickJSSandbox(new URL(e,location.href).href))}).catch(n)})}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 yh{#fu=null;#bu=null;#vu=null;#$d=null;#Ga=null;#wu=null;#Ct=null;#yu=null;#xu=!1;#Au=null;#Cu=null;constructor({eventBus:t,externalServices:e=null,docProperties:i=null}){this.#Ga=t,this.#wu=e,this.#vu=i}setViewer(t){this.#yu=t}async setDocument(t){if(this.#Ct&&await this.#Su(),this.#Ct=t,!t)return;const[e,i,n]=await Promise.all([t.getFieldObjects(),t.getCalculationOrderIds(),t.getJSActions()]);if(!e&&!n)return void await this.#Su();if(t!==this.#Ct)return;try{this.#Au=this.#Pu()}catch(t){return console.error("setDocument:",t),void await this.#Su()}const s=this.#Ga;this.#$d=new AbortController;const a={signal:this.#$d.signal,...Yr};s.on("updatefromsandbox",t=>{t?.source===window&&this.#_u(t.detail)},a),s.on("dispatcheventinsandbox",t=>{this.#Au?.dispatchEventInSandbox(t.detail)},a),s.on("pagechanging",({pageNumber:t,previous:e})=>{t!==e&&(this.#Eu(e),this.#Tu(t))},a),s.on("pagerendered",({pageNumber:t})=>{this._pageOpenPending.has(t)&&t===this.#yu.currentPageNumber&&this.#Tu(t)},a),s.on("pagesdestroy",async()=>{await this.#Eu(this.#yu.currentPageNumber),await(this.#Au?.dispatchEventInSandbox({id:"doc",name:"WillClose"})),this.#fu?.resolve()},a);try{const a=await this.#vu(t);if(t!==this.#Ct)return;await this.#Au.createSandbox({objects:e,calculationOrder:i,appInfo:{platform:navigator.platform,language:navigator.language},docInfo:{...a,actions:n}}),s.dispatch("sandboxcreated",{source:this})}catch(t){return console.error("setDocument:",t),void await this.#Su()}await(this.#Au?.dispatchEventInSandbox({id:"doc",name:"Open"})),await this.#Tu(this.#yu.currentPageNumber,!0),Promise.resolve().then(()=>{t===this.#Ct&&(this.#xu=!0)})}async dispatchWillSave(){return this.#Au?.dispatchEventInSandbox({id:"doc",name:"WillSave"})}async dispatchDidSave(){return this.#Au?.dispatchEventInSandbox({id:"doc",name:"DidSave"})}async dispatchWillPrint(){if(this.#Au){await(this.#Cu?.promise),this.#Cu=Promise.withResolvers();try{await this.#Au.dispatchEventInSandbox({id:"doc",name:"WillPrint"})}catch(t){throw this.#Cu.resolve(),this.#Cu=null,t}await this.#Cu.promise}}async dispatchDidPrint(){return this.#Au?.dispatchEventInSandbox({id:"doc",name:"DidPrint"})}get destroyPromise(){return this.#bu?.promise||null}get ready(){return this.#xu}get _pageOpenPending(){return lr(this,"_pageOpenPending",new Set)}get _visitedPages(){return lr(this,"_visitedPages",new Map)}async#_u(t){const e=this.#yu,i=e.isInPresentationMode||e.isChangingPresentationMode,{id:n,siblings:s,command:a,value:r}=t;if(!n){switch(a){case"clear":console.clear();break;case"error":console.error(r);break;case"layout":if(!i){const t=function(t){let e=Or.VERTICAL,i=Br.NONE;switch(t){case"SinglePage":e=Or.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=Or.PAGE;case"TwoColumnLeft":i=Br.ODD;break;case"TwoPageRight":e=Or.PAGE;case"TwoColumnRight":i=Br.EVEN}return{scrollMode:e,spreadMode:i}}(r);e.spreadMode=t.spreadMode}break;case"page-num":e.currentPageNumber=r+1;break;case"print":await e.pagesPromise,this.#Ga.dispatch("print",{source:this});break;case"println":console.log(r);break;case"zoom":i||(e.currentScaleValue=r);break;case"SaveAs":this.#Ga.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.#Cu?.resolve(),this.#Cu=null}return}if(i&&t.focus)return;delete t.id,delete t.siblings;const o=s?[n,...s]:[n];for(const e of o){const i=document.querySelector(`[data-element-id="${e}"]`);i?i.dispatchEvent(new CustomEvent("updatefromsandbox",{detail:t})):this.#Ct?.annotationStorage.setValue(e,t)}}async#Tu(t,e=!1){const i=this.#Ct,n=this._visitedPages;if(e&&(this.#fu=Promise.withResolvers()),!this.#fu)return;const s=this.#yu.getPageView(t-1);if(s?.renderingState!==eh.FINISHED)return void this._pageOpenPending.add(t);this._pageOpenPending.delete(t);const a=(async()=>{const e=await(n.has(t)?null:s.pdfPage?.getJSActions());i===this.#Ct&&await(this.#Au?.dispatchEventInSandbox({id:"page",name:"PageOpen",pageNumber:t,actions:e}))})();n.set(t,a)}async#Eu(t){const e=this.#Ct,i=this._visitedPages;if(!this.#fu)return;if(this._pageOpenPending.has(t))return;const n=i.get(t);n&&(i.set(t,null),await n,e===this.#Ct&&await(this.#Au?.dispatchEventInSandbox({id:"page",name:"PageClose",pageNumber:t})))}#Pu(){if(this.#bu=Promise.withResolvers(),this.#Au)throw new Error("#initScripting: Scripting already exists.");return this.#wu.createScripting()}async#Su(){if(!this.#Au)return this.#Ct=null,void this.#bu?.resolve();this.#fu&&(await Promise.race([this.#fu.promise,new Promise(t=>{setTimeout(t,1e3)})]).catch(()=>{}),this.#fu=null),this.#Ct=null;try{await this.#Au.destroySandbox()}catch{}this.#Cu?.reject(new Error("Scripting destroyed.")),this.#Cu=null,this.#$d?.abort(),this.#$d=null,this._pageOpenPending.clear(),this._visitedPages.clear(),this.#Au=null,this.#xu=!1,this.#bu?.resolve()}}let xh=class{#Mu=null;#ku=null;#Du=null;#yu=null;isThumbnailViewEnabled=!1;onIdle=null;printing=!1;constructor(){Object.defineProperty(this,"hasViewer",{value:()=>!!this.#yu})}setViewer(t){this.#yu=t}setThumbnailViewer(t){this.#Du=t}isHighestPriority(t){return this.#Mu===t.renderingId}renderHighestPriority(t){this.#ku&&(clearTimeout(this.#ku),this.#ku=null),this.#yu.forceRendering(t)||this.isThumbnailViewEnabled&&this.#Du?.forceRendering()||this.printing||this.onIdle&&(this.#ku=setTimeout(this.onIdle.bind(this),3e4))}getHighestPriority(t,e,i,n=!1,s=!1){const a=t.views,r=a.length;if(0===r)return null;for(let t=0;t<r;t++){const e=a[t].view;if(!this.isViewFinished(e))return e}if(!s)for(let t=0;t<r;t++){const{detailView:e}=a[t].view;if(e&&!this.isViewFinished(e))return e}const o=t.first.id,l=t.last.id;if(l-o+1>r){const n=t.ids;for(let t=1,s=l-o;t<s;t++){const s=i?o+t:l-t;if(n.has(s))continue;const a=e[s-1];if(!this.isViewFinished(a))return a}}let h=i?l:o-2,d=e[h];return d&&!this.isViewFinished(d)||n&&(h+=i?1:-1,d=e[h],d&&!this.isViewFinished(d))?d:null}isViewFinished(t){return t.renderingState===eh.FINISHED}renderView(t){switch(t.renderingState){case eh.FINISHED:return!1;case eh.PAUSED:this.#Mu=t.renderingId,t.resume();break;case eh.RUNNING:this.#Mu=t.renderingId;break;case eh.INITIAL:this.#Mu=t.renderingId,t.draw().finally(()=>{this.renderHighestPriority()}).catch(t=>{t instanceof sr||console.error("renderView:",t)})}return!0}};const Ah=1e4,Ch=5e3,Sh=250;function Ph(t){return Object.values(ba).includes(t)&&t!==ba.DISABLE}class _h{#Iu=new Set;#Lu=0;constructor(t){this.#Lu=t}push(t){const e=this.#Iu;e.has(t)&&e.delete(t),e.add(t),e.size>this.#Lu&&this.#Nu()}resize(t,e=null){this.#Lu=t;const i=this.#Iu;if(e){const t=i.size;let n=1;for(const s of i)if(e.has(s.id)&&(i.delete(s),i.add(s)),++n>t)break}for(;i.size>this.#Lu;)this.#Nu()}has(t){return this.#Iu.has(t)}[Symbol.iterator](){return this.#Iu.keys()}#Nu(){const t=this.#Iu.keys().next().value;t?.destroy(),this.#Iu.delete(t)}}class Eh{#in=null;#H=null;#Ru=null;#Fu=ba.NONE;#Ou=null;#$c=ya.ENABLE_FORMS;#W=null;#Bu=null;#ju=null;#J=!1;#Bc=!1;#tt=!1;#et=!1;#Gc=!0;#Oc=null;#$d=null;#Uu=0;#ft=null;#Hu=!0;#Vu=null;#zu=null;#$u=null;#Wu=!1;#Gu=null;#Xu=0;#Ku=new ResizeObserver(this.#qu.bind(this));#Yu=null;#Qu=null;#yt=null;#Zu=!0;#tu=Rr;#Mt=null;#Ju=null;#tp=null;#ep=null;constructor(t){const e="6.0.227";if(vr!==e)throw new Error(`The API version "${vr}" does not match the Viewer version "${e}".`);if(this.container=t.container,this.viewer=t.viewer||t.container.firstElementChild,this.#Mt=t.viewerAlert||null,"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.#Ku.observe(this.container),this.eventBus=t.eventBus,this.linkService=t.linkService||new fo,this.downloadManager=t.downloadManager||null,this.findController=t.findController||null,this.#H=t.altTextManager||null,this.#W=t.commentManager||null,this.#yt=t.signatureManager||null,this.#ju=t.editorUndoBar||null,this.findController&&(this.findController.onIsPageVisible=t=>this._getVisiblePages().ids.has(t)),this._scriptingManager=t.scriptingManager||null,this.#tu=t.textLayerMode??Rr,this.#$c=t.annotationMode??ya.ENABLE_FORMS,this.#Fu=t.annotationEditorMode??ba.NONE,this.#Ru=t.annotationEditorHighlightColors||null,this.#J=!0===t.enableHighlightFloatingButton,this.#tt=!0===t.enableUpdatedAddImage,this.#et=!0===t.enableNewAltTextWhenAddingImage,this.imageResourcesPath=t.imageResourcesPath||"",this.enablePrintAutoRotate=t.enablePrintAutoRotate||!1,this.removePageBorders=t.removePageBorders||!1,this.maxCanvasPixels=t.maxCanvasPixels,this.maxCanvasDim=t.maxCanvasDim,this.capCanvasAreaFactor=t.capCanvasAreaFactor,this.enableDetailCanvas=t.enableDetailCanvas??!0,this.enableOptimizedPartialRendering=t.enableOptimizedPartialRendering??!1,this.enableSelectionRendering=!1!==t.enableSelectionRendering,this.imagesRightClickMinSize=t.imagesRightClickMinSize??-1,this.l10n=t.l10n,this.l10n||=new Bl,this.#Bc=t.enablePermissions||!1,this.pageColors=t.pageColors||null,this.#ft=t.mlManager||null,this.#Zu=!1!==t.supportsPinchToZoom,this.#Gc=!1!==t.enableAutoLinking,this.#Uu=t.minDurationToUpdateCanvas??500,this.defaultRenderingQueue=!t.renderingQueue,this.defaultRenderingQueue?(this.renderingQueue=new xh,this.renderingQueue.setViewer(this)):this.renderingQueue=t.renderingQueue;const{abortSignal:i}=t;this.#Oc=i||null,i?.addEventListener("abort",()=>{this.#Ku.disconnect(),this.#Ku=null},{once:!0}),this.scroll=function(t,e,i){const n=function(i){a||(a=window.requestAnimationFrame(function(){a=null;const i=t.scrollLeft,n=s.lastX;i!==n&&(s.right=i>n),s.lastX=i;const r=t.scrollTop,o=s.lastY;r!==o&&(s.down=r>o),s.lastY=r,e(s)}))},s={right:!0,down:!0,lastX:t.scrollLeft,lastY:t.scrollTop,_eventHandler:n};let a=null;return t.addEventListener("scroll",n,{useCapture:!0,signal:i}),i?.addEventListener("abort",()=>window.cancelAnimationFrame(a),{once:!0}),s}(this.container,this._scrollUpdate.bind(this),i),this.presentationModeState=kr,this._resetView(),this.removePageBorders&&this.viewer.classList.add("removePageBorders"),this.#ip(),this.eventBus.on("thumbnailrendered",({pageNumber:t,pdfPage:e})=>{const i=this._pages[t-1];this.#in.has(i)||e?.cleanup()},Yr),t.l10n||this.l10n.translate(this.container)}get printingAllowed(){return this.#Hu}get pagesCount(){return this._pages.length}getPageView(t){return this._pages[t]}getCachedPageViews(){return new Set(this.#in)}get pageViewsReady(){return this._pages.every(t=>t?.pdfPage)}clearSelection(){const t=document.getSelection();if(t&&!t.isCollapsed)for(let e=0,i=t.rangeCount;e<i;e++)if(t.getRangeAt(e).intersectsNode(this.viewer))return t.removeAllRanges?.(),void t.empty?.()}get renderForms(){return this.#$c===ya.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._currentPageNumber!==t&&this.clearSelection(),this._setCurrentPageNumber(t,!0)||console.error(`currentPageNumber: "${t}" is not a valid page.`))}_setCurrentPageNumber(t,e=!1){if(this._currentPageNumber===t)return e&&this.#np(),!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.#np(),!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._currentPageNumber!==e&&this.clearSelection(),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.#sp(t,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(t){this.pdfDocument&&this.#sp(t,{noScroll:!1})}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!Wr(t))throw new Error("Invalid pages rotation angle.");if(!this.pdfDocument)return;if((t%=360)<0&&(t+=360),this._pagesRotation===t)return;this.clearSelection(),this._pagesRotation=t;const e=this._currentPageNumber;this.refresh(!0,{rotation:t}),this._currentScaleValue&&this.#sp(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 lr(this,"_layerProperties",{get annotationEditorUIManager(){return t.#Ou},get annotationStorage(){return t.pdfDocument?.annotationStorage},get downloadManager(){return t.downloadManager},get enableComment(){return!!t.#W},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}})}#ap(t){const e={annotationEditorMode:this.#Fu,annotationMode:this.#$c,textLayerMode:this.#tu};return t?(this.#Hu=t.includes(ir.PRINT_HIGH_QUALITY)||t.includes(ir.PRINT),this.eventBus.dispatch("printingallowed",{source:this,isAllowed:this.#Hu}),t.includes(ir.COPY)||this.#tu!==Rr||(e.textLayerMode=Fr),t.includes(ir.MODIFY_CONTENTS)||(e.annotationEditorMode=ba.DISABLE),t.includes(ir.MODIFY_ANNOTATIONS)||t.includes(ir.FILL_INTERACTIVE_FORMS)||this.#$c!==ya.ENABLE_FORMS||(e.annotationMode=ya.ENABLE),e):(this.#Hu=!0,this.eventBus.dispatch("printingallowed",{source:this,isAllowed:this.#Hu}),e)}async#rp(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:AbortSignal.any([t,i.signal])}),await Promise.race([this._onePageRenderedCapability.promise,e.promise]),i.abort()}async getAllText(t=null){const e=[],i=[];for(let n=1,s=this.pdfDocument.numPages;n<=s;++n){if(t?.aborted)return null;i.length=0;const s=await this.pdfDocument.getPage(n),{items:a}=await s.getTextContent();for(const t of a)t.str&&i.push(t.str),t.hasEOL&&i.push("\n");e.push(Hr(i.join("")))}return e.join("\n")}#op(t,e){const i=document.getSelection(),{focusNode:n,anchorNode:s}=i;if(s&&n&&i.containsNode(this.#Gu)){if(this.#Wu||t===Fr)return void dr(e);this.#Wu=!0;const{classList:i}=this.viewer;i.add("copyAll");const n=new AbortController,s=new AbortController;window.addEventListener("keydown",t=>{"Escape"===t.key&&s.abort()},{signal:n.signal}),this.getAllText(s.signal).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.#Wu=!1,n.abort(),i.remove("copyAll")}),dr(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.#Ou?.destroy(),this.#Ou=null,this.#Fu=ba.NONE,this.#Hu=!0),this.pdfDocument=t,!t)return;const e=t.numPages,i=t.getPage(1),n=t.getOptionalContentConfig({intent:"display"}),s=this.#Bc?t.getPermissions():Promise.resolve(),{eventBus:a,pageColors:r,viewer:o}=this;this.#$d=new AbortController;const{signal:l}=this.#$d,h={signal:l,...Yr};if(e>Ah){console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");const t=this._scrollMode=Or.PAGE;a.dispatch("scrollmodechanged",{source:this,mode:t})}this._pagesCapability.promise.then(()=>{a.dispatch("pagesloaded",{source:this,pagesCount:e})},()=>{});a.on("pagerender",t=>{const e=this._pages[t.pageNumber-1];e&&this.#in.push(e)},h);const d=t=>{t.cssTransform||t.isDetailView||(this._onePageRenderedCapability.resolve({timestamp:t.timestamp}),a.off("pagerendered",d))};a.on("pagerendered",d,h),Promise.all([i,s]).then(([i,s])=>{if(t!==this.pdfDocument)return;this._firstPageCapability.resolve(i),this._optionalContentConfigPromise=n;const{annotationEditorMode:h,annotationMode:d,textLayerMode:c}=this.#ap(s);if(c!==Nr){const t=this.#Gu=document.createElement("div");t.id="hiddenCopyElement",t.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none",o.before(t)}if(h!==ba.DISABLE){const e=h;t.isPureXfa?console.warn("Warning: XFA-editing is not implemented."):Ph(e)?(this.#Ou=new va(this.container,o,this.#Mt,this.#H,this.#W,this.#yt,a,t,r,this.#Ru,this.#J,this.#tt,this.#et,this.#ft,this.#ju,this.#Zu),a.dispatch("annotationeditoruimanager",{source:this,uiManager:this.#Ou}),e!==ba.NONE&&(this.#lp(e),this.#Ou.updateMode(e))):console.error(`Invalid AnnotationEditor mode: ${e}`)}const u=this._scrollMode===Or.PAGE?null:o,p=this.currentScale,g=i.getViewport({scale:p*nr.PDF_TO_CSS_UNITS});o.style.setProperty("--scale-factor",g.scale),r?.background&&o.style.setProperty("--page-bg-color",r.background),"CanvasText"!==r?.foreground&&"Canvas"!==r?.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 vh({container:u,eventBus:a,id:t,scale:p,defaultViewport:g.clone(),optionalContentConfigPromise:n,renderingQueue:this.renderingQueue,textLayerMode:c,annotationMode:d,imageResourcesPath:this.imageResourcesPath,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,capCanvasAreaFactor:this.capCanvasAreaFactor,enableDetailCanvas:this.enableDetailCanvas,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,enableSelectionRendering:this.enableSelectionRendering,imagesRightClickMinSize:this.imagesRightClickMinSize,pageColors:r,l10n:this.l10n,layerProperties:this._layerProperties,enableAutoLinking:this.#Gc,minDurationToUpdateCanvas:this.#Uu,commentManager:this.#W,abortSignal:this.#Oc});this._pages.push(e)}this._pages[0]?.setPdfPage(i),this._scrollMode===Or.PAGE?this.#hp():this._spreadMode!==Br.NONE&&this._updateSpreadMode(),a.on("annotationeditorlayerrendered",t=>{this.#Ou&&a.dispatch("annotationeditormodechanged",{source:this,mode:this.#Fu})},{once:!0,signal:l,...Yr}),this.#rp(l).then(async()=>{if(t!==this.pdfDocument)return;if(this.findController?.setDocument(t),this._scriptingManager?.setDocument(t),this.#Gu&&document.addEventListener("copy",this.#op.bind(this,c),{signal:l}),t.loadingParams.disableAutoFetch||e>Ch)return void this._pagesCapability.resolve();let i=e-1;if(i<=0)this._pagesCapability.resolve();else for(let n=2;n<=e;++n){const e=t.getPage(n).then(t=>{const e=this._pages[n-1];e.pdfPage||e.setPdfPage(t),0===--i&&this._pagesCapability.resolve()},t=>{console.error(`Unable to get page ${n} to initialize viewer`,t),0===--i&&this._pagesCapability.resolve()});n%Sh===0&&await e}}),a.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)})}onPagesEdited({pagesMapper:t,type:e,hasBeenCut:i,pageNumbers:n}){if("copy"===e){this.#Ju=new Map;for(const t of n)this.#Ju.set(t,this._pages[t-1]);return}if("cancelCopy"===e)return void(this.#Ju=null);if(("cut"===e||"delete"===e)&&(this.#tp=this._pages,this.#ep=n),"cancelDelete"===e){if(this.#ep=null,!this.#tp)return;const t=this._scrollMode===Or.PAGE?null:this.viewer;if(t){this.#Ou?.startUpdatePages();const e=document.createDocumentFragment();for(let t=0,i=this.#tp.length;t<i;t++){const i=this.#tp[t];i.updatePageNumber(t+1),e.append(i.div)}t.replaceChildren(e),this.#Ou?.endUpdatePages()}return this._pages=this.#tp,void(this.#tp=null)}if("cleanSavedData"===e){if(this.#ep){if(this.#tp){for(const t of this.#ep)this.#tp[t-1].deleteMe();this.#tp=null}this.#ep=null}return}this._currentPageNumber=0;const s=this._pages,a=this._pages=[];this.#Ou?.startUpdatePages();for(let e=1,n=t.pagesNumber;e<=n;e++){const n=t.getPrevPageNumber(e);if(n<0){let t=this.#Ju.get(-n);i?t.updatePageNumber(e):(this.#Ou?.clonePage(-n-1,e-1),t=t.clone(e)),a.push(t);continue}const r=s[n-1];a.push(r),r.updatePageNumber(e)}this.#Ou?.endUpdatePages(),"paste"===e&&(this.#Ju=null);const r=this._scrollMode===Or.PAGE?null:this.viewer;if(r){const t=document.createDocumentFragment();for(const{div:e}of a)t.append(e);r.replaceChildren(t)}setTimeout(()=>{this.forceRendering()})}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.#in=new _h(10),this._location=null,this._pagesRotation=0,this._optionalContentConfigPromise=null,this._firstPageCapability=Promise.withResolvers(),this._onePageRenderedCapability=Promise.withResolvers(),this._pagesCapability=Promise.withResolvers(),this._scrollMode=Or.VERTICAL,this._previousScrollMode=Or.UNKNOWN,this._spreadMode=Br.NONE,this.#Yu={previousPageNumber:1,scrollDown:!0,pages:[]},this.#$d?.abort(),this.#$d=null,this.viewer.textContent="",this._updateScrollMode(),this.viewer.removeAttribute("lang"),this.#Gu?.remove(),this.#Gu=null,this.#dp(),this.#cp()}#hp(){if(this._scrollMode!==Or.PAGE)throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");const t=this._currentPageNumber,e=this.#Yu,i=this.viewer;if(i.textContent="",e.pages.length=0,this._spreadMode!==Br.NONE||this.isInPresentationMode){const n=new Set,s=this._spreadMode-1;-1===s?n.add(t-1):t%2!==s?(n.add(t-1),n.add(t)):(n.add(t-2),n.add(t-1));const a=document.createElement("div");if(a.className="spread",this.isInPresentationMode){const t=document.createElement("div");t.className="dummyPage",a.append(t)}for(const t of n){const i=this._pages[t];i&&(a.append(i.div),e.pages.push(i))}i.append(a)}else{const n=this._pages[t-1];i.append(n.div),e.pages.push(n)}e.scrollDown=t>=e.previousPageNumber,e.previousPageNumber=t}_scrollUpdate(){0!==this.pagesCount&&(this.#Vu&&clearTimeout(this.#Vu),this.#Vu=setTimeout(()=>{this.#Vu=null,this.update()},100),this.update())}#up(t,e=null){const{div:i,id:n}=t;if(this._currentPageNumber!==n&&this._setCurrentPageNumber(n),this._scrollMode===Or.PAGE&&(this.#hp(),this.update()),!e&&!this.isInPresentationMode){const t=i.offsetLeft+i.clientLeft,n=t+i.clientWidth,{scrollLeft:s,clientWidth:a}=this.container;(this._scrollMode===Or.HORIZONTAL||t<s||n>s+a)&&(e={left:0,top:0})}!function(t,e){let i=t.offsetParent;if(!i)return void console.error("offsetParent is not set -- cannot scroll");let n=t.offsetTop+t.clientTop,s=t.offsetLeft+t.clientLeft;for(;i.clientHeight===i.scrollHeight&&i.clientWidth===i.scrollWidth;)if(n+=i.offsetTop,s+=i.offsetLeft,i=i.offsetParent,!i)return;e&&(void 0!==e.top&&(n+=e.top),void 0!==e.left&&(s+=e.left,i.scrollLeft=s)),i.scrollTop=n}(i,e),!this._currentScaleValue&&this._location&&(this._location=null)}#pp(t){return t===this._currentScale||Math.abs(t-this._currentScale)<1e-15}#gp(t,e,{noScroll:i=!1,preset:n=!1,drawingDelay:s=-1,origin:a=null}){if(this.clearSelection(),this._currentScaleValue=e.toString(),this.#pp(t))return void(n&&this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:e}));this.viewer.style.setProperty("--scale-factor",t*nr.PDF_TO_CSS_UNITS);const r=s>=0&&s<1e3;this.refresh(!0,{scale:t,drawingDelay:r?s:-1}),r&&(this.#Qu=setTimeout(()=>{this.#Qu=null,this.refresh()},s));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(a)){const e=t/o-1,[i,n]=this.containerTopLeft;this.container.scrollLeft+=(a[0]-n)*e,this.container.scrollTop+=(a[1]-i)*e}}this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:n?e:void 0}),this.defaultRenderingQueue&&this.update()}get#mp(){return this._spreadMode!==Br.NONE&&this._scrollMode!==Or.HORIZONTAL?2:1}#sp(t,e){let i=parseFloat(t);if(i>0)e.preset=!1,this.#gp(i,t,e);else{const n=this._pages[this._currentPageNumber-1];if(!n)return;let s=40,a=5;this.isInPresentationMode?(s=a=4,this._spreadMode!==Br.NONE&&(s*=2)):this.removePageBorders?s=a=0:this._scrollMode===Or.HORIZONTAL&&([s,a]=[a,s]);const r=(this.container.clientWidth-s)/n.width*n.scale/this.#mp,o=(this.container.clientHeight-a)/n.height*n.scale;switch(t){case"page-actual":i=1;break;case"page-width":i=r;break;case"page-height":i=o;break;case"page-fit":i=Math.min(r,o);break;case"auto":const e=Gr(n)?r:Math.min(o,r);i=Math.min(1.25,e);break;default:return void console.error(`#setScale: "${t}" is an unknown zoom value.`)}e.preset=!0,this.#gp(i,t,e)}}#np(){const t=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&this.#sp(this._currentScaleValue,{noScroll:!0}),this.#up(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:n=!1,center:s=null}){if(!this.pdfDocument)return;const a=Number.isInteger(t)&&this._pages[t-1];if(!a)return void console.error(`scrollPageIntoView: "${t}" is not a valid pageNumber parameter.`);if(this.isInPresentationMode||!e)return void this._setCurrentPageNumber(t,!0);let r,o,l=0,h=0,d=0,c=0;const u=a.rotation%180!=0,p=(u?a.height:a.width)/a.scale/nr.PDF_TO_CSS_UNITS,g=(u?a.width:a.height)/a.scale/nr.PDF_TO_CSS_UNITS;let m=0;switch(e[1].name){case"XYZ":l=e[2],h=e[3],m=e[4],l=null!==l?l:0,h=null!==h?h:g;break;case"Fit":case"FitB":m="page-fit";break;case"FitH":case"FitBH":h=e[2],m="page-width",null===h&&this._location?(l=this._location.left,h=this._location.top):("number"!=typeof h||h<0)&&(h=g);break;case"FitV":case"FitBV":l=e[2],d=p,c=g,m="page-height";break;case"FitR":l=e[2],h=e[3],d=e[4]-l,c=e[5]-h;let t=40,i=5;this.removePageBorders&&(t=i=0),r=(this.container.clientWidth-t)/d/nr.PDF_TO_CSS_UNITS,o=(this.container.clientHeight-i)/c/nr.PDF_TO_CSS_UNITS,m=Math.min(Math.abs(r),Math.abs(o));break;default:return void console.error(`scrollPageIntoView: "${e[1].name}" is not a valid destination type.`)}if(n||(m&&m!==this._currentScale?this.currentScaleValue=m:0===this._currentScale&&(this.currentScaleValue="auto")),"page-fit"===m&&!e[4])return void this.#up(a);const f=[a.viewport.convertToViewportPoint(l,h),a.viewport.convertToViewportPoint(l+d,h+c)];let b=Math.min(f[0][0],f[1][0]),v=Math.min(f[0][1],f[1][1]);s?("both"!==s&&"vertical"!==s||(v-=(this.container.clientHeight-Math.abs(f[1][1]-f[0][1]))/2),"both"!==s&&"horizontal"!==s||(b-=(this.container.clientWidth-Math.abs(f[1][0]-f[0][0]))/2)):i||(b=Math.max(b,0),v=Math.max(v,0)),this.#up(a,{left:b,top:v})}_updateLocation(t){const e=this._currentScale,i=this._currentScaleValue,n=parseFloat(i)===e?Math.round(1e4*e)/100:i,s=t.id,a=this._pages[s-1],r=this.container,o=a.getPagePoint(r.scrollLeft-t.x,r.scrollTop-t.y),l=Math.round(o[0]),h=Math.round(o[1]);let d=`#page=${s}`;this.isInPresentationMode||(d+=`&zoom=${n},${l},${h}`),this._location={pageNumber:s,scale:n,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 n=Math.max(10,2*i+1);this.#in.resize(n,t.ids);for(const{view:t,visibleArea:i}of e)t.updateVisibleArea(i);for(const e of this.#in)t.ids.has(e.id)||e.updateVisibleArea(null);this.renderingQueue.renderHighestPriority(t);const s=this._spreadMode===Br.NONE&&(this._scrollMode===Or.PAGE||this._scrollMode===Or.VERTICAL),a=this._currentPageNumber;let r=!1;for(const t of e){if(t.percent<100)break;if(t.id===a&&s){r=!0;break}}this._setCurrentPageNumber(r?this._currentPageNumber:e[0].id),this._updateLocation(t.first),this.eventBus.dispatch("updateviewarea",{source:this,location:this._location})}#fp(){const t=this._getVisiblePages(),e=[],{ids:i,views:n}=t;for(const t of n){const{view:n}=t;n.hasEditableAnnotations()?e.push(t):i.delete(n.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===Lr}get isChangingPresentationMode(){return this.presentationModeState===Ir}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===Or.PAGE?this.#Yu.pages:this._pages,e=this._scrollMode===Or.HORIZONTAL,i=e&&this._isContainerRtl;return function({scrollEl:t,views:e,sortByVisibility:i=!1,horizontal:n=!1,rtl:s=!1}){const a=t.scrollTop,r=a+t.clientHeight,o=t.scrollLeft,l=o+t.clientWidth,h=[],d=new Set,c=e.length;let u=Vr(e,n?function(t){const e=t.div,i=e.offsetLeft+e.clientLeft,n=i+e.clientWidth;return s?i<l:n>o}:function(t){const e=t.div;return e.offsetTop+e.clientTop+e.clientHeight>a});u>0&&u<c&&!n&&(u=function(t,e,i){if(t<2)return t;let n=e[t].div,s=n.offsetTop+n.clientTop;s>=i&&(n=e[t-1].div,s=n.offsetTop+n.clientTop);for(let i=t-2;i>=0&&(n=e[i].div,!(n.offsetTop+n.clientTop+n.clientHeight<=s));--i)t=i;return t}(u,e,a));let p=n?l:-1;for(let t=u;t<c;t++){const i=e[t],s=i.div,c=s.offsetLeft+s.clientLeft,u=s.offsetTop+s.clientTop,g=s.clientWidth,m=s.clientHeight,f=c+g,b=u+m;if(-1===p)b>=r&&(p=b);else if((n?c:u)>p)break;if(b<=a||u>=r||f<=o||c>=l)continue;const v=Math.max(0,a-u),w=Math.max(0,o-c),y=v+Math.max(0,b-r),x=(g-(w+Math.max(0,f-l)))/g,A=(m-y)/m*x*100|0;h.push({id:i.id,x:c,y:u,visibleArea:100===A?null:{minX:w,minY:v,maxX:Math.min(f,l)-c,maxY:Math.min(b,r)-u},view:i,percent:A,widthPercent:100*x|0}),d.add(i.id)}const g=h[0],m=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:m,views:h,ids:d}}({scrollEl:this.container,views:t,sortByVisibility:!0,horizontal:e,rtl:i})}cleanup(){for(const t of this._pages)t.renderingState!==eh.FINISHED&&t.reset()}_cancelRendering(){for(const t of this._pages)t.cancelRendering()}async#bp(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}}#vp(t){if(1===t.first?.id)return!0;if(t.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case Or.PAGE:return this.#Yu.scrollDown;case Or.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(t){const e=t||this._getVisiblePages(),i=this.#vp(e),n=this._spreadMode!==Br.NONE&&this._scrollMode!==Or.HORIZONTAL,s=null!==this.#Qu||null!==this.#Vu&&e.views.some(t=>t.detailView?.renderingCancelled),a=this.renderingQueue.getHighestPriority(e,this._pages,i,n,s);return!!a&&(this.#bp(a).then(()=>{this.renderingQueue.renderView(a)}),!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}),n=Gr(i);if(void 0===t)t=n;else if(this.enablePrintAutoRotate&&n!==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(Or).includes(t)&&t!==Or.UNKNOWN}(t))throw new Error(`Invalid scroll mode: ${t}`);this.pagesCount>Ah||(this._previousScrollMode=this._scrollMode,this.clearSelection(),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===Or.HORIZONTAL),i.classList.toggle("scrollWrapped",e===Or.WRAPPED),this.pdfDocument&&t&&(e===Or.PAGE?this.#hp():this._previousScrollMode===Or.PAGE&&this._updateSpreadMode(),this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#sp(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(Br).includes(t)&&t!==Br.UNKNOWN}(t))throw new Error(`Invalid spread mode: ${t}`);this.clearSelection(),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===Or.PAGE)this.#hp();else if(e.textContent="",this._spreadMode===Br.NONE)for(const t of this._pages)e.append(t.div);else{const t=this._spreadMode-1;let n=null;for(let s=0,a=i.length;s<a;++s)null===n?(n=document.createElement("div"),n.className="spread",e.append(n)):s%2===t&&(n=n.cloneNode(!1),e.append(n)),n.append(i[s].div)}t&&(this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#sp(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}#wp(t,e=!1){switch(this._scrollMode){case Or.WRAPPED:{const{views:i}=this._getVisiblePages(),n=new Map;for(const{id:t,y:e,percent:s,widthPercent:a}of i)0===s||a<100||n.getOrInsertComputed(e,$a).push(t);for(const i of n.values()){const n=i.indexOf(t);if(-1===n)continue;const s=i.length;if(1===s)break;if(e)for(let e=n-1,s=0;e>=s;e--){const n=i[e],s=i[e+1]-1;if(n<s)return t-s}else for(let e=n+1,a=s;e<a;e++){const n=i[e],s=i[e-1]+1;if(n>s)return s-t}if(e){const e=i[0];if(e<t)return t-e+1}else{const e=i[s-1];if(e>t)return e-t+1}break}break}case Or.HORIZONTAL:break;case Or.PAGE:case Or.VERTICAL:{if(this._spreadMode===Br.NONE)break;const i=this._spreadMode-1;if(e&&t%2!==i)break;if(!e&&t%2===i)break;const{views:n}=this._getVisiblePages(),s=e?t-1:t+1;for(const{id:t,percent:e,widthPercent:i}of n)if(t===s){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.#wp(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.#wp(t,!0)||1;return this.currentPageNumber=Math.max(t-e,1),!0}updateScale({drawingDelay:t,scaleFactor:e=null,steps:i=null,origin:n}){if(null===i&&null===e)throw new Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided.");if(!this.pdfDocument)return;let s=this._currentScale;if(e>0&&1!==e)s=Math.round(s*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{s=e(10*(s*t).toFixed(2))/10}while(--i>0)}s=Xa(s,.1,25),this.#sp(s,{noScroll:!1,drawingDelay:t,origin:n})}increaseScale(t={}){this.updateScale({...t,steps:t.steps??1})}decreaseScale(t={}){this.updateScale({...t,steps:-(t.steps??1)})}#ip(t=this.container.clientHeight){t!==this.#Xu&&(this.#Xu=t,Xr.setProperty("--viewer-container-height",`${t}px`))}#qu(t){for(const e of t)if(e.target===this.container){this.#ip(Math.floor(e.borderBoxSize[0].blockSize)),this.#Bu=null;break}}get containerTopLeft(){return this.#Bu||=[this.container.offsetTop,this.container.offsetLeft]}#dp(){null!==this.#Qu&&(clearTimeout(this.#Qu),this.#Qu=null),null!==this.#Vu&&(clearTimeout(this.#Vu),this.#Vu=null)}#cp(){this.#zu?.abort(),this.#zu=null,null!==this.#$u&&(clearTimeout(this.#$u),this.#$u=null)}#lp(t){switch(t){case ba.STAMP:this.#ft?.loadModel("altText");break;case ba.SIGNATURE:this.#yt?.loadSignatures()}}get annotationEditorMode(){return this.#Ou?this.#Fu:ba.DISABLE}set annotationEditorMode({mode:t,editId:e=null,isFromKeyboard:i=!1,mustEnterInEditMode:n=!1,editComment:s=!1}){if(!this.#Ou)throw new Error("The AnnotationEditor is not enabled.");if(this.#Fu===t)return;if(!Ph(t))throw new Error(`Invalid AnnotationEditor mode: ${t}`);if(!this.pdfDocument)return;this.#lp(t);const{eventBus:a,pdfDocument:r}=this,o=async()=>{this.#cp(),this.#Fu=t,await this.#Ou.updateMode(t,e,!0,i,n,s),t===this.#Fu&&r===this.pdfDocument&&a.dispatch("annotationeditormodechanged",{source:this,mode:t})};if(t===ba.NONE||this.#Fu===ba.NONE){const e=t!==ba.NONE;e||this.pdfDocument.annotationStorage.resetModifiedIds(),this.cleanup();for(const t of this._pages)t.toggleEditingMode(e);const i=this.#fp();if(e&&i){this.#cp(),this.#zu=new AbortController;const t=AbortSignal.any([this.#$d.signal,this.#zu.signal]);return void a.on("pagerendered",({pageNumber:t})=>{i.delete(t),0===i.size&&(this.#$u=setTimeout(o,0))},{signal:t,...Yr})}}o()}refresh(t=!1,e=Object.create(null)){if(this.pdfDocument){for(const t of this._pages)t.update(e);this.#dp(),t||this.update()}}}class Th extends Eh{_resetView(){super._resetView(),this._scrollMode=Or.PAGE,this._spreadMode=Br.NONE}set scrollMode(t){}_updateScrollMode(){}set spreadMode(t){}_updateSpreadMode(){}}function Mh(t,e,i,n){return new(i||(i=Promise))(function(s,a){function r(t){try{l(n.next(t))}catch(t){a(t)}}function o(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((n=n.apply(t,e||[])).next())})}function kh(t,e,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)}function Dh(t,e,i,n,s){if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s?s.value=i:e.set(t,i),i}var Ih,Lh,Nh,Rh,Fh;globalThis.pdfjsViewer={AnnotationLayerBuilder:bo,DownloadManager:wo,EventBus:Ao,FindState:Qr,GenericL10n:Bl,LinkTarget:go,parseQueryString:jr,PDFFindController:po,PDFHistory:class{#$d=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,...Yr})},Yr)}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 n=""!==this._fingerprint&&this._fingerprint!==t;this._fingerprint=t,this._updateUrl=!0===i,this._initialized=!0,this.#yp();const s=window.history.state;if(this._popStateInProgress=!1,this._blockHashChange=0,this._currentHash=jl(),this._numPositionUpdates=0,this._uid=this._maxUid=0,this._destination=null,this._position=null,!this.#xp(s,!0)||e){const{hash:t,page:i,rotation:s}=this.#Ap(!0);return!t||n||e?void this.#Cp(null,!0):void this.#Cp({hash:t,page:i,rotation:s},!0)}const a=s.destination;this.#Sp(a,s.uid,!0),void 0!==a.rotation&&(this._initialRotation=a.rotation),a.dest?(this._initialBookmark=JSON.stringify(a.dest),this._destination.page=null):a.hash?this._initialBookmark=a.hash:a.page&&(this._initialBookmark=`page=${a.page}`)}reset(){this._initialized&&(this.#Pp(),this._initialized=!1,this.#_p()),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.#Ep(i)&&(null!==i||this._destination))return void console.error(`PDFHistory.push: "${i}" is not a valid pageNumber parameter.`);const n=t||JSON.stringify(e);if(!n)return;let s=!1;if(this._destination&&(function(t,e){if("string"!=typeof t||"string"!=typeof e)return!1;if(t===e)return!0;if(jr(t).get("nameddest")===e)return!0;return!1}(this._destination.hash,n)||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 n in t)if(!i(t[n],e[n]))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 n=0,s=t.length;n<s;n++)if(!i(t[n],e[n]))return!1;return!0}(this._destination.dest,e))){if(this._destination.page)return;s=!0}this._popStateInProgress&&!s||(this.#Cp({dest:e,hash:n,page:i,rotation:this.linkService.rotation},s),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then(()=>{this._popStateInProgress=!1})))}pushPage(t){this._initialized&&(this.#Ep(t)?this._destination?.page!==t&&(this._popStateInProgress||(this.#Cp({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.#Tp()}back(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#xp(t)&&t.uid>0&&window.history.back()}forward(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#xp(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}#Cp(t,e=!1){const i=e||!this._destination,n={fingerprint:this._fingerprint,uid:i?this._uid:this._uid+1,destination:t};let s;if(this.#Sp(t,n.uid),this._updateUrl&&t?.hash){const{href:e,protocol:i}=document.location;"file:"!==i&&(s=mr(e,t.hash))}i?window.history.replaceState(n,"",s):window.history.pushState(n,"",s)}#Tp(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.#Cp(e);if(this._destination.temporary)return void this.#Cp(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.#Cp(e,i)}#Ep(t){return Number.isInteger(t)&&t>0&&t<=this.linkService.pagesCount}#xp(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)}#Sp(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}#Ap(t=!1){const e=unescape(jl()).substring(1),i=jr(e),n=i.get("nameddest")||"";let s=0|i.get("page");return(!this.#Ep(s)||t&&n.length>0)&&(s=null),{hash:e,page:s,rotation:this.linkService.rotation}}#Mp({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.#Tp(!0),this._updateViewareaTimeout=null},1e3))}#kp({state:t}){const e=jl(),i=this._currentHash!==e;if(this._currentHash=e,!t){this._uid++;const{hash:t,page:e,rotation:i}=this.#Ap();return void this.#Cp({hash:t,page:e,rotation:i},!0)}if(!this.#xp(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:n,resolve:s}=Promise.withResolvers(),a=new AbortController;function r(t){a.abort(),clearTimeout(h),s(t)}const o=t instanceof Ao?"on":"addEventListener",l=t instanceof Ao?{signal:a.signal,...Yr}:{signal:a.signal};t[o](e,r.bind(null,yo),l);const h=setTimeout(r.bind(null,xo),i);return n}({target:window,name:"hashchange",delay:1e3}).then(()=>{this._blockHashChange--}));const n=t.destination;this.#Sp(n,t.uid,!0),Wr(n.rotation)&&(this.linkService.rotation=n.rotation),n.dest?this.linkService.goToDestination(n.dest):n.hash?this.linkService.setHash(n.hash):n.page&&(this.linkService.page=n.page),Promise.resolve().then(()=>{this._popStateInProgress=!1})}#Pp(){this._destination&&!this._destination.temporary||this.#Tp()}#yp(){if(this.#$d)return;this.#$d=new AbortController;const{signal:t}=this.#$d;this.eventBus.on("updateviewarea",this.#Mp.bind(this),{signal:t,...Yr}),window.addEventListener("popstate",this.#kp.bind(this),{signal:t}),window.addEventListener("pagehide",this.#Pp.bind(this),{signal:t})}#_p(){this.#$d?.abort(),this.#$d=null}},PDFLinkService:mo,PDFPageView:vh,PDFScriptingManager:class extends yh{constructor(t){t.externalServices||window.addEventListener("updatefromsandbox",e=>{t.eventBus.dispatch("updatefromsandbox",{source:window,detail:e.detail})}),t.externalServices||={createScripting:()=>new wh(t.sandboxBundleSrc,t.wasmUrl)},t.docProperties||=t=>async function(t){const{info:e,metadata:i,contentDispositionFilename:n,contentLength:s}=await t.getMetadata();return{...e,baseURL:"",filesize:s||(await t.getDownloadInfo()).length,filename:n||Na(""),metadata:i?.getRaw(),authors:i?.get("dc:creator"),numPages:t.numPages,URL:""}}(t),super(t)}},PDFSinglePageViewer:Th,PDFViewer:Eh,ProgressBar:class{#Dp=null;#Ip=null;#Lp=0;#Np=null;#Ps=!0;constructor(t){this.#Dp=t.classList,this.#Np=t.style}get percent(){return this.#Lp}set percent(t){this.#Lp=t,isNaN(t)?this.#Dp.add("indeterminate"):(this.#Dp.remove("indeterminate"),this.#Np.setProperty("--progressBar-percent",`${this.#Lp}%`))}setWidth(t){if(!t)return;const e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&this.#Np.setProperty("--progressBar-end-offset",`${e}px`)}setDisableAutoFetch(t=5e3){100===this.#Lp||isNaN(this.#Lp)||(this.#Ip&&clearTimeout(this.#Ip),this.show(),this.#Ip=setTimeout(()=>{this.#Ip=null,this.hide()},t))}hide(){this.#Ps&&(this.#Ps=!1,this.#Dp.add("hidden"))}show(){this.#Ps||(this.#Ps=!0,this.#Dp.remove("hidden"))}},RenderingStates:eh,ScrollMode:Or,SimpleLinkService:fo,SpreadMode:Br,StructTreeLayerBuilder:ch,TextLayerBuilder:gh,XfaLayerBuilder:mh},"function"==typeof SuppressedError&&SuppressedError;const Oh={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},Bh={UNKNOWN:0,NORMAL:1,CHANGING:2,FULLSCREEN:3},jh={UNKNOWN:-1,NONE:0,THUMBS:1,OUTLINE:2,ATTACHMENTS:3,LAYERS:4},Uh={DISABLE:0,ENABLE:1,ENABLE_PERMISSIONS:2},Hh={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},Vh={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};function zh(t,e,i=!1){let n=t.offsetParent;if(!n)return void console.error("offsetParent is not set -- cannot scroll");let s=t.offsetTop+t.clientTop,a=t.offsetLeft+t.clientLeft;for(;n.clientHeight===n.scrollHeight&&n.clientWidth===n.scrollWidth||i&&(n.classList.contains("markedContent")||"hidden"===getComputedStyle(n).overflow);)if(s+=n.offsetTop,a+=n.offsetLeft,n=n.offsetParent,!n)return;if(e&&(void 0!==e.top&&(s+=e.top),void 0!==e.left)){if(i){const i=t.getBoundingClientRect().width,s=It((n.clientWidth-i)/2,20,400);a+=e.left-s}else a+=e.left;n.scrollLeft=a}n.scrollTop=s}function $h(t,e,i=void 0){const n=function(i){a||(a=window.requestAnimationFrame(function(){a=null;const i=t.scrollLeft,n=s.lastX;i!==n&&(s.right=i>n),s.lastX=i;const r=t.scrollTop,o=s.lastY;r!==o&&(s.down=r>o),s.lastY=r,e(s)}))},s={right:!0,down:!0,lastX:t.scrollLeft,lastY:t.scrollTop,_eventHandler:n};let a=null;return t.addEventListener("scroll",n,{useCapture:!0,signal:i}),null==i||i.addEventListener("abort",()=>window.cancelAnimationFrame(a),{once:!0}),s}const Wh=/[\x00-\x1F]/g;function Gh(t,e,i=0){let n=i,s=t.length-1;if(s<0||!e(t[s]))return t.length;if(e(t[n]))return n;for(;n<s;){const i=n+s>>1;e(t[i])?s=i:n=i+1}return n}function Xh({view:t,userUnit:e,rotate:i}){const[n,s,a,r]=t,o=i%180!=0,l=(a-n)/72*e,h=(r-s)/72*e;return{width:o?h:l,height:o?l:h}}function Kh(t,e,i){if(t<2)return t;let n=e[t].div,s=n.offsetTop+n.clientTop;s>=i&&(n=e[t-1].div,s=n.offsetTop+n.clientTop);for(let i=t-2;i>=0&&(n=e[i].div,!(n.offsetTop+n.clientTop+n.clientHeight<=s));--i)t=i;return t}function qh({scrollEl:t,views:e,sortByVisibility:i=!1,horizontal:n=!1,rtl:s=!1}){const a=t.scrollTop,r=a+t.clientHeight,o=t.scrollLeft,l=o+t.clientWidth;const h=[],d=new Set,c=e.length;let u=Gh(e,n?function(t){const e=t.div,i=e.offsetLeft+e.clientLeft,n=i+e.clientWidth;return s?i<l:n>o}:function(t){const e=t.div;return e.offsetTop+e.clientTop+e.clientHeight>a});u>0&&u<c&&!n&&(u=Kh(u,e,a));let p=n?l:-1;for(let t=u;t<c;t++){const i=e[t],s=i.div,c=s.offsetLeft+s.clientLeft,u=s.offsetTop+s.clientTop,g=s.clientWidth,m=s.clientHeight,f=c+g,b=u+m;if(-1===p)b>=r&&(p=b);else if((n?c:u)>p)break;if(b<=a||u>=r||f<=o||c>=l)continue;const v=Math.max(0,a-u),w=Math.max(0,o-c),y=v+Math.max(0,b-r),x=(g-(w+Math.max(0,f-l)))/g,A=(m-y)/m*x*100|0;h.push({id:i.id,x:c,y:u,visibleArea:100===A?null:{minX:w,minY:v,maxX:Math.min(f,l)-c,maxY:Math.min(b,r)-u},view:i,percent:A,widthPercent:100*x|0}),d.add(i.id)}const g=h[0],m=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:m,views:h,ids:d}}function Yh(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 Qh(t){const e=t.deltaMode;let i=Yh(t);return e===WheelEvent.DOM_DELTA_PIXEL?i/=900:e===WheelEvent.DOM_DELTA_LINE&&(i/=30),i}function Zh(t){return Number.isInteger(t)&&t%90==0}function Jh(t){return Number.isInteger(t)&&Object.values(Hh).includes(t)&&t!==Hh.UNKNOWN}function td(t){return Number.isInteger(t)&&Object.values(Vh).includes(t)&&t!==Vh.UNKNOWN}function ed(t){return t.width<=t.height}const id=new Promise(function(t){window.requestAnimationFrame(t)}),nd=document.documentElement.style;Ih=new WeakMap,Lh=new WeakMap,Nh=new WeakMap,Rh=new WeakMap,Fh=new WeakMap;const sd=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 ad{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,n=!1,s=!1){const a=t.views,r=a.length;if(0===r)return null;for(let t=0;t<r;t++){const e=a[t].view;if(!this.isViewFinished(e))return e}if(!s)for(let t=0;t<r;t++){const{detailView:e}=a[t].view;if(e&&!this.isViewFinished(e))return e}const o=t.first.id,l=t.last.id;if(l-o+1>r){const n=t.ids;for(let t=1,s=l-o;t<s;t++){const s=i?o+t:l-t;if(n.has(s))continue;const a=e[s-1];if(!this.isViewFinished(a))return a}}let h=i?l:o-2,d=e[h];return d&&!this.isViewFinished(d)||n&&(h+=i?1:-1,d=e[h],d&&!this.isViewFinished(d))?d:null}isViewFinished(t){return t.renderingState===Oh.FINISHED}renderView(t){switch(t.renderingState){case Oh.FINISHED:return!1;case Oh.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case Oh.RUNNING:this.highestPriorityPage=t.renderingId;break;case Oh.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally(()=>{this.renderHighestPriority()}).catch(t=>{t instanceof Bt||console.error("renderView:",t)})}return!0}}var rd,od,ld,hd,dd,cd,ud,pd;function gd(t){t.width=0,t.height=0}class md{static getCanvas(t,e){const i=Dh(this,rd,kh(this,rd,"f",od)||document.createElement("canvas"),0,od);i.width=t,i.height=e;const n=i.getContext("2d",{alpha:!1});return n.save(),n.fillStyle="rgb(255, 255, 255)",n.fillRect(0,0,t,e),n.restore(),[i,i.getContext("2d")]}static destroyCanvas(){kh(this,rd,"f",od)&&gd(kh(this,rd,"f",od)),Dh(this,rd,null,0,od)}}rd=md,od={value:null};class fd{constructor({container:t,eventBus:e,id:i,defaultViewport:n,optionalContentConfigPromise:s,linkService:a,renderingQueue:r,maxCanvasPixels:o,maxCanvasDim:l,pageColors:h,enableHWA:d,store:c,thumbnailWidth:u}){ld.add(this),this.id=i,this.renderingId="thumbnail"+i,this.pageLabel=null,this.pdfPage=null,this.rotation=0,this.viewport=n,this.pdfPageRotate=n.rotation,this._optionalContentConfigPromise=s||null,this.maxCanvasPixels=null!=o?o:33554432,this.maxCanvasDim=l||32767,this.pageColors=h||null,this.enableHWA=d||!1,this.eventBus=e,this.linkService=a,this.renderingQueue=r,this.renderTask=null,this.renderingState=Oh.INITIAL,this.resume=null,this.store=c,this.thumbnailWidth=u,this.loaded=!1;const p=document.createElement("div");p.className="thumbnail pdfSlickThumbHolder",p.setAttribute("data-page-number",this.id.toString()),this.div=p,kh(this,ld,"m",hd).call(this),t.append(p)}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=Oh.INITIAL,this.div.removeAttribute("data-loaded"),this.loaded=!1,kh(this,ld,"m",hd).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 Mh(this,void 0,void 0,function*(){if(this.renderingState!==Oh.INITIAL)return void console.error("Must be in new state before drawing");const{pageColors:t,pdfPage:e}=this;if(!e)throw this.renderingState=Oh.FINISHED,new Error("pdfPage is not loaded");this.renderingState=Oh.RUNNING;const{ctx:i,canvas:n,transform:s}=kh(this,ld,"m",dd).call(this,2),a={canvas:n,canvasContext:i,transform:s,viewport:this.viewport.clone({scale:2*this.scale}),optionalContentConfigPromise:this._optionalContentConfigPromise,pageColors:t},r=this.renderTask=e.render(a);r.onContinue=t=>{if(!this.renderingQueue.isHighestPriority(this))return this.renderingState=Oh.PAUSED,void(this.resume=()=>{this.renderingState=Oh.RUNNING,t()});t()};let o=null;try{yield r.promise}catch(t){if(t instanceof Bt)return void gd(n);o=t}finally{r===this.renderTask&&(this.renderTask=null)}if(this.renderingState=Oh.FINISHED,kh(this,ld,"m",cd).call(this,n),gd(n),this.eventBus.dispatch("thumbnailrendered",{source:this,pageNumber:this.id,pdfPage:e}),o)throw o})}setImage(t){if(this.renderingState!==Oh.INITIAL)return;const{thumbnailCanvas:e,pdfPage:i,scale:n}=t;e&&(this.pdfPage||this.setPdfPage(i),n<this.scale||(this.renderingState=Oh.FINISHED,kh(this,ld,"m",cd).call(this,e)))}setPageLabel(t){this.pageLabel="string"==typeof t?t:null}}var bd,vd,wd,yd,xd,Ad,Cd;ld=new WeakSet,hd=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:n}=this.div;n.setProperty("--thumbnail-width",`${this.canvasWidth}px`),n.setProperty("--thumbnail-height",`${this.canvasHeight}px`)},dd=function(t=1,e=this.enableHWA){const i=document.createElement("canvas"),n=i.getContext("2d",{alpha:!1,willReadFrequently:!e}),s=new Zt,a=t*this.canvasWidth,r=t*this.canvasHeight;s.limitCanvas(a,r,this.maxCanvasPixels,this.maxCanvasDim),i.width=a*s.sx|0,i.height=r*s.sy|0;return{ctx:n,canvas:i,transform:s.scaled?[s.sx,0,0,s.sy,0,0]:null}},cd=function(t){if(this.renderingState!==Oh.FINISHED)throw new Error("#convertCanvasToImage: Rendering has not finished.");const e=kh(this,ld,"m",pd).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},ud=function(t){const e=t.width<<3,i=t.height<<3,n=new Zt;return n.sx=n.sy=1,n.limitCanvas(e,i,this.maxCanvasPixels,this.maxCanvasDim),[e*n.sx|0,i*n.sy|0]},pd=function(t){const{ctx:e,canvas:i}=kh(this,ld,"m",dd).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[n,s]=kh(this,ld,"m",ud).call(this,i);const[a,r]=md.getCanvas(n,s);for(;n>t.width||s>t.height;)n>>=1,s>>=1;for(r.drawImage(t,0,0,t.width,t.height,0,0,n,s);n>2*i.width;)r.drawImage(a,0,0,n,s,0,0,n>>1,s>>1),n>>=1,s>>=1;return e.drawImage(a,0,0,n,s,0,0,i.width,i.height),i};const Sd="selected";class Pd{constructor({container:t,eventBus:e,linkService:i,renderingQueue:n,maxCanvasPixels:s,maxCanvasDim:a,pageColors:r,abortSignal:o,enableHWA:l,store:h,thumbnailWidth:d}){bd.add(this),this.container=t,this.eventBus=e,this.linkService=i,this.renderingQueue=n,this.maxCanvasPixels=s||33554432,this.maxCanvasDim=a||32767,this.pageColors=r||null,this.enableHWA=l||!1,this.store=h,this.thumbnailWidth=d,this.scroll=$h(this.container,kh(this,bd,"m",vd).bind(this),o),kh(this,bd,"m",yd).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(Sd),e.div.classList.add(Sd)}const{first:i,last:n,views:s}=kh(this,bd,"m",wd).call(this);if(s.length>0){let a=!1;if(t<=i.id||t>=n.id)a=!0;else for(const{id:e,percent:i}of s)if(e===t){a=i<100;break}a&&zh(e.div,{top:-19})}this._currentPageNumber=t}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!Zh(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!==Oh.FINISHED&&t.reset();md.destroyCanvas()}setDocument(t){if(this.pdfDocument&&(kh(this,bd,"m",xd).call(this),kh(this,bd,"m",yd).call(this)),this.pdfDocument=t,!t)return;const e=t.getPage(1),i=t.getOptionalContentConfig({intent:"display"});e.then(e=>{var n;const s=t.numPages,a=e.getViewport({scale:1});for(let t=1;t<=s;++t){const e=new fd({container:this.container,eventBus:this.eventBus,id:t,defaultViewport:a.clone(),optionalContentConfigPromise:i,linkService:this.linkService,renderingQueue:this.renderingQueue,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,pageColors:this.pageColors,enableHWA:this.enableHWA,store:this.store,thumbnailWidth:this.thumbnailWidth});this._thumbnails.push(e)}null===(n=this._thumbnails[0])||void 0===n||n.setPdfPage(e);this._thumbnails[this._currentPageNumber-1].div.classList.add(Sd),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,n=this._thumbnails.length;t<n;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=kh(this,bd,"m",wd).call(this),e=kh(this,bd,"m",Cd).call(this,t),i=this.renderingQueue.getHighestPriority(t,this._thumbnails,e,!1,!0);return!!i&&(kh(this,bd,"m",Ad).call(this,i).then(()=>{this.renderingQueue.renderView(i)}),!0)}}bd=new WeakSet,vd=function(){this.renderingQueue.renderHighestPriority()},wd=function(){return qh({scrollEl:this.container,views:this._thumbnails})},yd=function(){this._thumbnails=[],this._currentPageNumber=1,this._pageLabels=null,this._pagesRotation=0,this.container.textContent=""},xd=function(){for(const t of this._thumbnails)t.cancelRendering()},Ad=function(t){return Mh(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}})},Cd=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 _d=null;class Ed{constructor({pdfDocument:t,pagesOverview:e,printContainer:i,printResolution:n,printAnnotationStoragePromise:s=null}){this.pdfDocument=t,this.pagesOverview=e,this.printContainer=i,this._printResolution=n||150,this._optionalContentConfigPromise=t.getOptionalContentConfig({intent:"print"}),this._printAnnotationStoragePromise=s||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(_d!==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,_d=null}renderPages(t){if(this.pdfDocument.isPureXfa)return function(t,e){const i=e.allXfaHtml,n=new fo,s=Math.round(100*Ft.PDF_TO_CSS_UNITS)/100;for(const a of null==i?void 0:i.children){const i=document.createElement("div");i.className="xfaPrintedPage",t.append(i);const r=new mh({pdfPage:null,annotationStorage:e.annotationStorage,linkService:n,xfaHtml:a}),o=Rt.getPageViewport(a,{scale:s});r.render({viewport:o,intent:"print"}),i.append(r.div)}}(this.printContainer,this.pdfDocument),Promise.resolve();const e=this.pagesOverview.length,i=(n,s)=>{if(this.throwIfInactive(),++this.currentPage>=e)return t({index:e,total:e}),void n();const a=this.currentPage;t({index:a,total:e}),function(t,e,i,n,s,a,r){const o=t.scratchCanvas,l=s/Ft.PDF;o.width=Math.floor(n.width*l),o.height=Math.floor(n.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),r]).then(function([t,e]){const i={canvasContext:h,transform:[l,0,0,l,0,0],viewport:t.getViewport({scale:1,rotation:n.rotation}),intent:"print",annotationMode:N.ENABLE_STORAGE,optionalContentConfigPromise:a,printAnnotationStorage:e};return t.render(i).promise.catch(t=>{throw t instanceof Bt||console.error(t),t})})}(this,this.pdfDocument,a+1,this.pagesOverview[a],this._printResolution,this._optionalContentConfigPromise,this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then(function(){i(n,s)},s)};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:n,reject:s}=Promise.withResolvers();return t.onload=n,t.onerror=s,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===_d}throwIfInactive(){if(!this.active)throw new Error("This print request was cancelled or completed.")}}const Td={instance:{supportsPrinting:!0,createPrintService(t){if(_d)throw new Error("The print service is created and active.");return _d=new Ed(t)}}};var Md,kd,Dd,Id,Ld,Nd,Rd,Fd,Od,Bd,jd,Ud,Hd,Vd,zd,$d,Wd,Gd,Xd;const Kd="pdfPresentationMode",qd="pdfPresentationModeControls",Yd=Math.PI/6;class Qd{constructor({container:t,pdfViewer:e,eventBus:i}){Md.add(this),kd.set(this,Bh.UNKNOWN),Dd.set(this,null),Id.set(this,null),Ld.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 Mh(this,void 0,void 0,function*(){const{container:t,pdfViewer:e}=this;if(this.active||!e.pagesCount||!t.requestFullscreen)return!1;kh(this,Md,"m",Gd).call(this),kh(this,Md,"m",Rd).call(this,Bh.CHANGING);const i=t.requestFullscreen();Dh(this,Dd,{pageNumber:e.currentPageNumber,scaleValue:e.currentScaleValue,scrollMode:e.scrollMode,spreadMode:null,annotationEditorMode:null}),e.spreadMode===Vh.NONE||e.pageViewsReady&&e.hasEqualPageSizes||(console.warn("Ignoring Spread modes when entering PresentationMode, since the document may contain varying page sizes."),kh(this,Dd,"f").spreadMode=e.spreadMode),e.annotationEditorMode!==O.DISABLE&&(kh(this,Dd,"f").annotationEditorMode=e.annotationEditorMode);try{return yield i,e.focus(),!0}catch(t){kh(this,Md,"m",Xd).call(this),kh(this,Md,"m",Rd).call(this,Bh.NORMAL)}return!1})}get active(){return kh(this,kd,"f")===Bh.CHANGING||kh(this,kd,"f")===Bh.FULLSCREEN}}kd=new WeakMap,Dd=new WeakMap,Id=new WeakMap,Ld=new WeakMap,Md=new WeakSet,Nd=function(t){if(!this.active)return;t.preventDefault();const e=Qh(t),i=Date.now(),n=this.mouseScrollTimeStamp;if(!(i>n&&i-n<50)&&((this.mouseScrollDelta>0&&e<0||this.mouseScrollDelta<0&&e>0)&&kh(this,Md,"m",Vd).call(this),this.mouseScrollDelta+=e,Math.abs(this.mouseScrollDelta)>=.1)){const t=this.mouseScrollDelta;kh(this,Md,"m",Vd).call(this);(t>0?this.pdfViewer.previousPage():this.pdfViewer.nextPage())&&(this.mouseScrollTimeStamp=i)}},Rd=function(t){Dh(this,kd,t),this.eventBus.dispatch("presentationmodechanged",{source:this,state:t})},Fd=function(){var t;kh(this,Md,"m",Rd).call(this,Bh.FULLSCREEN),this.container.classList.add(Kd),setTimeout(()=>{this.pdfViewer.scrollMode=Hh.PAGE,null!==kh(this,Dd,"f").spreadMode&&(this.pdfViewer.spreadMode=Vh.NONE),this.pdfViewer.currentPageNumber=kh(this,Dd,"f").pageNumber,this.pdfViewer.currentScaleValue="page-fit",null!==kh(this,Dd,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:O.NONE})},0),kh(this,Md,"m",$d).call(this),kh(this,Md,"m",Ud).call(this),this.contextMenuOpen=!1,null===(t=document.getSelection())||void 0===t||t.empty()},Od=function(){const t=this.pdfViewer.currentPageNumber;this.container.classList.remove(Kd),setTimeout(()=>{kh(this,Md,"m",Xd).call(this),kh(this,Md,"m",Rd).call(this,Bh.NORMAL),this.pdfViewer.scrollMode=kh(this,Dd,"f").scrollMode,null!==kh(this,Dd,"f").spreadMode&&(this.pdfViewer.spreadMode=kh(this,Dd,"f").spreadMode),this.pdfViewer.currentScaleValue=kh(this,Dd,"f").scaleValue,this.pdfViewer.currentPageNumber=t,null!==kh(this,Dd,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:kh(this,Dd,"f").annotationEditorMode}),Dh(this,Dd,null)},0),kh(this,Md,"m",Wd).call(this),kh(this,Md,"m",Hd).call(this),kh(this,Md,"m",Vd).call(this),this.contextMenuOpen=!1},Bd=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()))},jd=function(){this.contextMenuOpen=!0},Ud=function(){this.controlsTimeout?clearTimeout(this.controlsTimeout):this.container.classList.add(qd),this.controlsTimeout=setTimeout(()=>{this.container.classList.remove(qd),delete this.controlsTimeout},3e3)},Hd=function(){this.controlsTimeout&&(clearTimeout(this.controlsTimeout),this.container.classList.remove(qd),delete this.controlsTimeout)},Vd=function(){this.mouseScrollTimeStamp=0,this.mouseScrollDelta=0},zd=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,n=this.touchSwipeState.endY-this.touchSwipeState.startY,s=Math.abs(Math.atan2(n,i));Math.abs(i)>50&&(s<=Yd||s>=Math.PI-Yd)?e=i:Math.abs(n)>50&&Math.abs(s-Math.PI/2)<=Yd&&(e=n),e>0?this.pdfViewer.previousPage():e<0&&this.pdfViewer.nextPage()}},$d=function(){if(kh(this,Ld,"f"))return;Dh(this,Ld,new AbortController);const{signal:t}=kh(this,Ld,"f"),e=kh(this,Md,"m",zd).bind(this);window.addEventListener("mousemove",kh(this,Md,"m",Ud).bind(this),{signal:t}),window.addEventListener("mousedown",kh(this,Md,"m",Bd).bind(this),{signal:t}),window.addEventListener("wheel",kh(this,Md,"m",Nd).bind(this),{passive:!1,signal:t}),window.addEventListener("keydown",kh(this,Md,"m",Vd).bind(this),{signal:t}),window.addEventListener("contextmenu",kh(this,Md,"m",jd).bind(this),{signal:t}),window.addEventListener("touchstart",e,{signal:t}),window.addEventListener("touchmove",e,{signal:t}),window.addEventListener("touchend",e,{signal:t})},Wd=function(){var t;null===(t=kh(this,Ld,"f"))||void 0===t||t.abort(),Dh(this,Ld,null)},Gd=function(){kh(this,Id,"f")||(Dh(this,Id,new AbortController),window.addEventListener("fullscreenchange",()=>{document.fullscreenElement?kh(this,Md,"m",Fd).call(this):kh(this,Md,"m",Od).call(this)},{signal:kh(this,Id,"f").signal}))},Xd=function(){var t;null===(t=kh(this,Id,"f"))||void 0===t||t.abort(),Dh(this,Id,null)};const Zd={isDocumentLoaded:!1,pagesReady:!1,url:null,numPages:0,pageNumber:0,scale:0,scaleValue:"auto",pagesRotation:0,spreadMode:Vh.UNKNOWN,scrollMode:Hh.UNKNOWN,documentOutline:null,attachments:new Map,thumbnails:new Map,thumbnailViews:new Map,annotationEditorMode:O.NONE,pdfSlick:null},Jd=()=>{return(t=(t,e)=>Object.assign(Object.assign({},Zd),{_setThumbnailView:(i,n)=>{const s=new Map(e().thumbnails),a=new Map(e().thumbnailViews),{canvasWidth:r,canvasHeight:o,scale:l,rotation:h,loaded:d,pageLabel:c,src:u=null}=n;a.set(i,n),s.set(i,{pageNumber:i,width:r,height:o,scale:l,rotation:h,loaded:d,pageLabel:c,src:u}),t({thumbnailViews:a,thumbnails:s})},_setThumbnailsViews:e=>{const i=new Map(e.map(t=>[t.id,t])),n=new Map(e.map(t=>{const{canvasWidth:e,canvasHeight:i,scale:n,rotation:s,loaded:a,pageLabel:r,src:o=null}=t;return[t.id,{pageNumber:t.id,width:e,height:i,scale:n,rotation:s,loaded:a,pageLabel:r,src:o}]}));t({thumbnailViews:i,thumbnails:n})}}))?b(t):b;var t};var tc,ec,ic,nc,sc,ac,rc,oc,lc,hc,dc,cc,uc,pc,gc,mc,fc,bc,vc,wc,yc,xc,Ac,Cc,Sc,Pc,_c;class Ec{constructor({eventBus:t,slick:e,printDialog:i}){tc.add(this),ec.set(this,null),ic.set(this,null),nc.set(this,null),this.eventBus=t,this.slick=e,this.printDialog=null!=i?i:null,this.bindEvents()}get supportsPrinting(){return Td.instance.supportsPrinting}get printing(){return!!kh(this,ec,"f")}print(){return Mh(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=kh(this,ec,"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===kh(this,ec,"f")&&this.abort()})}else console.error("Expected print service to be initialized."),null===(e=this.printDialog)||void 0===e||e.close()}}})}abort(){var t;kh(this,ec,"f")&&(kh(this,ec,"f").destroy(),null===(t=this.printDialog)||void 0===t||t.close(),this.eventBus.dispatch("afterprint",{source:this}))}bindEvents(){Dh(this,ic,new AbortController);const{signal:t}=kh(this,ic,"f"),e={signal:t};this.eventBus.on("beforeprint",kh(this,tc,"m",sc).bind(this),e),this.eventBus.on("afterprint",kh(this,tc,"m",ac).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=kh(this,ic,"f"))||void 0===t||t.abort(),Dh(this,ic,null)}}ec=new WeakMap,ic=new WeakMap,nc=new WeakMap,tc=new WeakSet,sc=function(){kh(this,ec,"f")||this.supportsPrinting&&(this.slick.viewer.pageViewsReady?(Dh(this,nc,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()}}}()),Dh(this,ec,Td.instance.createPrintService({pdfDocument:this.slick.document,pagesOverview:this.slick.viewer.getPagesOverview(),printContainer:kh(this,nc,"f").element,printResolution:this.slick.printResolution,optionalContentConfigPromise:null,printAnnotationStoragePromise:null})),this.slick.forceRendering(),kh(this,ec,"f").layout()):this.slick.l10n.get("printing_not_ready",null,"Warning: The PDF is not fully loaded for printing.").then(t=>{window.alert(t)}))},ac=function(){var t,e,i;kh(this,ec,"f")&&(kh(this,ec,"f").destroy(),Dh(this,ec,null),null===(t=this.printDialog)||void 0===t||t.close(),null===(e=kh(this,nc,"f"))||void 0===e||e.remove(),Dh(this,nc,null),null===(i=this.slick.document)||void 0===i||i.annotationStorage.resetModified()),this.slick.forceRendering()};class Tc{static create(){let t=document.querySelector("#printServiceDialog");if(!t){const e=(t,e,i)=>{const n=document.createElement(t);return Object.entries(e).forEach(([t,e])=>n.setAttribute(t,e)),n.append(...i),n};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 Tc(t)}constructor(t){this.dialog=t}open(t){return Mh(this,void 0,void 0,function*(){const e=this.dialog.querySelector("#printCancel"),i=()=>{var n;this.dialog.removeEventListener("close",i),this.dialog.removeEventListener("cancel",i),null==e||e.removeEventListener("click",i),null===(n=null==t?void 0:t.close)||void 0===n||n.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),n=this.dialog.querySelector("progress"),s=this.dialog.querySelector(".relative-progress");n.value=i,s.setAttribute("data-l10n-args",JSON.stringify({progress:i}))}}On.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:s&&"SCRIPT"===s.tagName.toUpperCase()&&s.src||new URL("index.js",document.baseURI).href).toString();const Mc={"8.5x11":"Letter","8.5x14":"Legal"},kc={"297x420":"A3","210x297":"A4"};function Dc(t,e,i){return i[`${e?t.width:t.height}x${e?t.height:t.width}`]}class Ic{constructor({container:t,viewer:e,thumbs:i,store:n=Jd(),options:s,onError:a,printDialog:r}){var o,l,h,d,c,u,p,g,m,f,b,v,w,y,x,A,C,S,P,_,E,T;rc.add(this),oc.set(this,void 0),lc.set(this,void 0),hc.set(this,void 0),dc.set(this,void 0),cc.set(this,void 0),this.downloadManager=null,this.findController=null,this.pdfPresentationMode=null,this.document=null,uc.set(this,void 0),pc.set(this,void 0),gc.set(this,void 0),mc.set(this,void 0),Dh(this,lc,t),Dh(this,hc,e),Dh(this,dc,i),Dh(this,gc,a),this.l10n=null!==(o=null==s?void 0:s.l10n)&&void 0!==o?o:new Bl(navigator.language),this.downloadManager=new wo,this.textLayerMode=null!==(l=null==s?void 0:s.textLayerMode)&&void 0!==l?l:Uh.ENABLE,Dh(this,uc,null!==(h=null==s?void 0:s.annotationMode)&&void 0!==h?h:N.ENABLE_FORMS),Dh(this,pc,null!==(d=null==s?void 0:s.annotationEditorMode)&&void 0!==d?d:O.NONE),this.annotationEditorHighlightColors=null!==(c=null==s?void 0:s.annotationEditorHighlightColors)&&void 0!==c?c:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",this.removePageBorders=null!==(u=null==s?void 0:s.removePageBorders)&&void 0!==u&&u,this.singlePageViewer=null!==(p=null==s?void 0:s.singlePageViewer)&&void 0!==p&&p,this.enablePrintAutoRotate=null!==(g=null==s?void 0:s.enablePrintAutoRotate)&&void 0!==g&&g,this.useOnlyCssZoom=null!==(m=null==s?void 0:s.useOnlyCssZoom)&&void 0!==m&&m,this.pageColors=null!==(f=null==s?void 0:s.pageColors)&&void 0!==f?f:null,this.maxCanvasPixels=null!==(b=null==s?void 0:s.maxCanvasPixels)&&void 0!==b?b:Math.pow(2,24),this.maxCanvasDim=null!==(v=null==s?void 0:s.maxCanvasDim)&&void 0!==v?v:32767,this.capCanvasAreaFactor=null!==(w=null==s?void 0:s.capCanvasAreaFactor)&&void 0!==w?w:200,this.printResolution=null!==(y=null==s?void 0:s.printResolution)&&void 0!==y?y:96,this.thumbnailWidth=null!==(x=null==s?void 0:s.thumbnailWidth)&&void 0!==x?x:125,this.enableHWA=null!==(A=null==s?void 0:s.enableHWA)&&void 0!==A&&A,this.enableDetailCanvas=null===(C=null==s?void 0:s.enableDetailCanvas)||void 0===C||C,this.enableOptimizedPartialRendering=null!==(S=null==s?void 0:s.enableOptimizedPartialRendering)&&void 0!==S&&S,this.minDurationToUpdateCanvas=null!==(P=null==s?void 0:s.minDurationToUpdateCanvas)&&void 0!==P?P:500,this.getDocumentParams=null!==(_=null==s?void 0:s.getDocumentParams)&&void 0!==_?_:{},!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=n;const M=new ad;M.onIdle=this._cleanup.bind(this),M.isThumbnailViewEnabled=!0,Dh(this,oc,M);const k=new Ao,D=new mo({eventBus:k,externalLinkTarget:2,externalLinkRel:"noopener noreferrer nofollow",ignoreDestinationZoom:!1}),I=new po({eventBus:k,linkService:D}),L=Object.assign(Object.assign({container:t},e&&{viewer:e}),{eventBus:k,linkService:D,findController:I,renderingQueue:M,textLayerMode:this.textLayerMode,annotationEditorHighlightColors:this.annotationEditorHighlightColors,l10n:this.l10n,annotationMode:kh(this,uc,"f"),annotationEditorMode:kh(this,pc,"f"),removePageBorders:this.removePageBorders,imageResourcesPath:"/images/",enableDetailCanvas:this.enableDetailCanvas,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,minDurationToUpdateCanvas:this.minDurationToUpdateCanvas,maxCanvasPixels:!0===this.useOnlyCssZoom?0:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,capCanvasAreaFactor:this.capCanvasAreaFactor}),R=this.singlePageViewer?new Th(L):new Eh(L);M.setViewer(R),i&&(this.thumbnailViewer=new Pd({container:i,eventBus:k,linkService:D,renderingQueue:M,maxCanvasPixels:!0===this.useOnlyCssZoom?0:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,pageColors:this.pageColors,enableHWA:this.enableHWA,store:n,thumbnailWidth:this.thumbnailWidth,abortSignal:null===(E=kh(this,mc,"f"))||void 0===E?void 0:E.signal}),M.setThumbnailViewer(this.thumbnailViewer)),document.fullscreenEnabled&&(this.pdfPresentationMode=new Qd({container:t,pdfViewer:R,eventBus:k})),this.eventBus=k,this.linkService=D,this.findController=I,this.viewer=R,this.linkService.setViewer(R),Dh(this,cc,new Ec({eventBus:k,slick:this,printDialog:null!=r?r:Tc.create()}));const F=null!==(T=null==s?void 0:s.scaleValue)&&void 0!==T?T:"auto";this.store.setState({scaleValue:F})}loadDocument(t,e){return Mh(this,void 0,void 0,function*(){var i,n,s,a,r;if(this.url&&"string"==typeof this.url)try{URL.revokeObjectURL(this.url)}catch(t){}try{null===(i=this.document)||void 0===i||i.loadingTask.destroy(),null===(n=this.viewer)||void 0===n||n.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!==(s=null==e?void 0:e.filename)&&void 0!==s?s:Ht(null===(a=this.url)||void 0===a?void 0:a.toString());this.filename=o;const l=Xn(Object.assign(Object.assign({},this.getDocumentParams),{url:this.url,enableHWA:this.enableHWA}));(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===(r=this.thumbnailViewer)||void 0===r||r.setDocument(h)),kh(this,rc,"m",wc).call(this),yield kh(this,rc,"m",fc).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 kh(this,rc,"m",bc).call(this),this.forceRendering()}catch(t){kh(this,gc,"f")&&kh(this,gc,"f").call(this,t)}})}forceRendering(t=!0){kh(this,oc,"f").printing=!!kh(this,cc,"f").printing,kh(this,oc,"f").isThumbnailViewEnabled=t,kh(this,oc,"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 Mh(this,void 0,void 0,function*(){var t;const e=this.url,{filename:i}=this;let n;try{n=(yield this.document.getData()).slice(0)}catch(t){}yield null===(t=this.downloadManager)||void 0===t?void 0:t.download(n,e,i)})}save(){return Mh(this,void 0,void 0,function*(){var t;const e=this.url,{filename:i}=this;try{const n=(yield this.document.saveDocument()).slice(0);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 kh(this,cc,"f").supportsPrinting}requestPresentationMode(){var t;null===(t=this.pdfPresentationMode)||void 0===t||t.request()}triggerPrinting(){kh(this,cc,"f").print()}unbindEvents(){var t;null===(t=kh(this,mc,"f"))||void 0===t||t.abort(),Dh(this,mc,null),kh(this,cc,"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(O.HIGHLIGHT),this.setAnnotationEditorParams([{type:B.HIGHLIGHT_COLOR,value:t}]),this.store.setState({highlightDefaultColor:t})}setSpreadMode(t){td(t)&&(this.viewer.spreadMode=t,this.dispatch("switchspreadmode",{mode:t}))}setScrollMode(t){Jh(t)&&(this.viewer.scrollMode=t,this.dispatch("switchscrollmode",{mode:t}))}setRotation(t){Zh(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)}}function Lc(){const[t,i]=e.useState({width:0,height:0}),n=e.useRef(null),s=e.useCallback(t=>{var e;null===(e=n.current)||void 0===e||e.disconnect(),n.current=null,t&&"undefined"!=typeof ResizeObserver&&(n.current=new ResizeObserver(t=>{const e=t[0];if(e){const{width:t,height:n}=e.contentRect;i({width:t,height:n})}}),n.current.observe(t))},[]);return e.useEffect(()=>()=>{var t;return null===(t=n.current)||void 0===t?void 0:t.disconnect()},[]),[s,t]}function Nc(t,i,n){e.useEffect(()=>{const e=setTimeout(t,i);return()=>clearTimeout(e)},n)}function Rc({usePDFSlickStore:t,viewerRef:e,className:n}){const s=t(t=>t.pdfSlick),a=t(t=>t.scaleValue),[r,{width:o}]=Lc();return Nc(()=>{o&&(!s||"auto"!==a&&"page-fit"!==a&&"page-width"!==a||(s.viewer.currentScaleValue=a),null==s||s.viewer.update())},0,[o]),i.jsx("div",{ref:t=>{e(t),r(t)},id:"viewerContainer",className:`pdfSlickContainer ${null!=n?n:""}`,style:{position:"absolute",inset:0,overflow:"auto"},children:i.jsx("div",{id:"viewer",className:"pdfSlickViewer pdfViewer"})})}function Fc({children:t,thumbsRef:e,usePDFSlickStore:s,className:a}){const r=s(t=>t.thumbnailViews),o=s(t=>t.pdfSlick),[l,{width:h}]=Lc();return Nc(()=>{h&&(null==o||o.forceRendering())},0,[h]),i.jsx("div",{ref:t=>{e(t),l(t)},className:a,style:{position:"absolute",overflow:"auto",inset:0},children:Array.from(r).map(([e,i])=>{var s;return n.createPortal(t({pageNumber:e,width:i.canvasWidth,height:i.canvasHeight,scale:i.scale,src:null!==(s=null==i?void 0:i.src)&&void 0!==s?s:null,rotation:i.rotation,pageLabel:i.pageLabel,loaded:i.loaded}),i.div)})})}function Oc(t){return function(i,n){return function(t,i=w,n){const s=v(t.subscribe,t.getState,t.getInitialState,i,n);return e.useDebugValue(s),s}(t,i,n)}}oc=new WeakMap,lc=new WeakMap,hc=new WeakMap,dc=new WeakMap,cc=new WeakMap,uc=new WeakMap,pc=new WeakMap,gc=new WeakMap,mc=new WeakMap,rc=new WeakSet,fc=function(){return Mh(this,void 0,void 0,function*(){var t;const e=this.document,i=null!==(t=yield e.getPageLabels())&&void 0!==t?t:[],n=i.length;let s=0,a=0;for(let t=0;t<n;t++){const e=i[t];if(e===(t+1).toString())s++;else{if(""!==e)break;a++}}if(s>=n||a>=n)return;const{viewer:r,thumbnailViewer:o}=this;r.setPageLabels(i),null==o||o.setPageLabels(i)})},bc=function(){return Mh(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=>kh(this,rc,"m",vc).call(this,Xh(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:Gt.toDateObject(t.CreationDate),modificationDate:Gt.toDateObject(t.ModDate),isLinearized:t.IsLinearized,pageSize:i})})},vc=function(t,e){return Mh(this,void 0,void 0,function*(){if(!t)return;e%180!=0&&(t={width:t.height,height:t.width});const i=ed(t);let n={width:Math.round(100*t.width)/100,height:Math.round(100*t.height)/100},s={width:Math.round(25.4*t.width*10)/10,height:Math.round(25.4*t.height*10)/10},a=Dc(n,i,Mc)||Dc(s,i,kc);if(!(a||Number.isInteger(s.width)&&Number.isInteger(s.height))){const e={width:25.4*t.width,height:25.4*t.height},r={width:Math.round(s.width),height:Math.round(s.height)};Math.abs(e.width-r.width)<.1&&Math.abs(e.height-r.height)<.1&&(a=Dc(r,i,kc),a&&(n={width:Math.round(r.width/25.4*100)/100,height:Math.round(r.height/25.4*100)/100},s=r))}const[{width:r,height:o},l,h,d]=yield Promise.all([n,this.l10n.get("document_properties_page_size_unit_inches",null,"in"),a&&this.l10n.get(`document_properties_page_size_name_${a.toLowerCase()}`,null,a),this.l10n.get("document_properties_page_size_orientation_"+(i?"portrait":"landscape"),null,i?"portrait":"landscape")]);return{width:r.toLocaleString(),height:o.toLocaleString(),unit:l,name:h,orientation:d}})},wc=function(){Dh(this,mc,new AbortController);const{signal:t}=kh(this,mc,"f"),e={signal:t};this.eventBus.on("pagesinit",kh(this,rc,"m",yc).bind(this),e),this.eventBus.on("scalechanging",kh(this,rc,"m",Sc).bind(this),e),this.eventBus.on("pagechanging",kh(this,rc,"m",Pc).bind(this),e),this.eventBus.on("pagerendered",kh(this,rc,"m",_c).bind(this),e),this.eventBus.on("rotationchanging",kh(this,rc,"m",xc).bind(this),e),this.eventBus.on("switchspreadmode",kh(this,rc,"m",Ac).bind(this),e),this.eventBus.on("switchscrollmode",kh(this,rc,"m",Cc).bind(this),e)},yc=function(t){return Mh(this,arguments,void 0,function*({source:t}){var e;const i=yield null===(e=this.document)||void 0===e?void 0:e.getOutline(),n=this.store.getState().scaleValue;t.currentScaleValue=null!=n?n:"auto",this.store.setState({documentOutline:i,pageNumber:1,scaleValue:n,pagesReady:!0})})},xc=function({pagesRotation:t,pageNumber:e}){this.store.setState({pagesRotation:t}),this.thumbnailViewer&&(this.thumbnailViewer.pagesRotation=t),this.forceRendering(),this.viewer.currentPageNumber=e},Ac=function({mode:t}){this.store.setState({spreadMode:t})},Cc=function({mode:t}){this.store.setState({scrollMode:t})},Sc=function({scale:t,presetValue:e}){this.store.setState({scale:t,scaleValue:e}),this.viewer.update()},Pc=function({pageNumber:t}){var e;null===(e=this.thumbnailViewer)||void 0===e||e.scrollThumbnailIntoView(t),this.store.setState({pageNumber:t})},_c=function({pageNumber:t,error:e}){var i;if(kh(this,dc,"f")){const e=this.viewer.getPageView(t-1),n=null===(i=this.thumbnailViewer)||void 0===i?void 0:i.getThumbnail(t-1);e&&n&&n.setImage(e)}};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.PDFSlick=Ic,t.PDFSlickThumbnails=Fc,t.PDFSlickViewer=Rc,t.PresentationModeState=Bh,t.ProgressBar=class{constructor(t){Ih.set(this,void 0),Lh.set(this,null),Nh.set(this,0),Rh.set(this,void 0),Fh.set(this,!0),Dh(this,Ih,t.classList),Dh(this,Rh,t.style)}get percent(){return kh(this,Nh,"f")}set percent(t){Dh(this,Nh,It(t,0,100)),isNaN(t)?kh(this,Ih,"f").add("indeterminate"):(kh(this,Ih,"f").remove("indeterminate"),kh(this,Rh,"f").setProperty("--progressBar-percent",`${kh(this,Nh,"f")}%`))}setWidth(t){if(!t)return;const e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&kh(this,Rh,"f").setProperty("--progressBar-end-offset",`${e}px`)}setDisableAutoFetch(t=5e3){100===kh(this,Nh,"f")||isNaN(kh(this,Nh,"f"))||(kh(this,Lh,"f")&&clearTimeout(kh(this,Lh,"f")),this.show(),Dh(this,Lh,setTimeout(()=>{Dh(this,Lh,null),this.hide()},t)))}hide(){kh(this,Fh,"f")&&(Dh(this,Fh,!1),kh(this,Ih,"f").add("hidden"))}show(){kh(this,Fh,"f")||(Dh(this,Fh,!0),kh(this,Ih,"f").remove("hidden"))}},t.RendererType={CANVAS:"canvas",SVG:"svg"},t.RenderingStates=Oh,t.SCROLLBAR_PADDING=40,t.ScrollMode=Hh,t.SidebarView=jh,t.SpreadMode=Vh,t.TextLayerMode=Uh,t.UNKNOWN_SCALE=0,t.VERTICAL_PADDING=5,t.animationStarted=id,t.apiPageLayoutToViewerModes=function(t){let e=Hh.VERTICAL,i=Vh.NONE;switch(t){case"SinglePage":e=Hh.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=Hh.PAGE;case"TwoColumnLeft":i=Vh.ODD;break;case"TwoPageRight":e=Hh.PAGE;case"TwoColumnRight":i=Vh.EVEN}return{scrollMode:e,spreadMode:i}},t.apiPageModeToSidebarView=function(t){switch(t){case"UseNone":return jh.NONE;case"UseThumbs":return jh.THUMBS;case"UseOutlines":return jh.OUTLINE;case"UseAttachments":return jh.ATTACHMENTS;case"UseOC":return jh.LAYERS}return jh.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 n,s=0,a=1,r=1,o=1;for(;;){const t=s+r,e=a+o;if(e>8)break;i<=t/e?(r=t,o=e):(s=t,a=e)}return n=i-s/a<r/o-i?i===t?[s,a]:[a,s]:i===t?[r,o]:[o,r],n},t.backtrackBeforeAllVisibleElements=Kh,t.binarySearchFirstItem=Gh,t.calcRound=sd,t.create=Jd,t.createStore=Oc,t.docStyle=nd,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=Xh,t.getVisibleElements=qh,t.initialState=Zd,t.isPortraitOrientation=ed,t.isValidRotation=Zh,t.isValidScrollMode=Jh,t.isValidSpreadMode=td,t.normalizeWheelEventDelta=Qh,t.normalizeWheelEventDirection=Yh,t.parseQueryString=function(t){const e=new Map;for(const[i,n]of new URLSearchParams(t))e.set(i.toLowerCase(),n);return e},t.removeNullCharacters=function(t,e=!1){return Wh.test(t)?e?t.replaceAll(Wh,t=>"\0"===t?"":" "):t.replaceAll("\0",""):t},t.scrollIntoView=zh,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[n,s]=e.useState(!1),[a,r]=e.useState(null),[o,l]=e.useState(null),[h,d]=e.useState(null),c=e.useMemo(()=>Jd(),[]),u=e.useMemo(()=>Oc(c),[]),p=e.useCallback(t=>{null!==t&&r(t)},[]),g=e.useCallback(t=>{null!==t&&l(t)},[]);return e.useEffect(()=>{if(t&&a){const e=new Ic({container:a,thumbs:o,store:c,options:i,onError:t=>d(t)});e.loadDocument(t,i).then(()=>{s(!0)}),c.setState({pdfSlick:e})}return()=>{}},[t,a]),{isDocumentLoaded:n,viewerRef:p,thumbsRef:g,usePDFSlickStore:u,store:c,PDFSlickViewer:Rc,PDFSlickThumbnails:Fc,error:h}},t.watchScroll=$h});