@pdfslick/core 2.1.3 → 2.2.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/esm/PDFSlick.d.ts +2 -4
- package/dist/esm/PDFSlick.d.ts.map +1 -1
- package/dist/esm/PDFSlickPrintDialog.d.ts +24 -0
- package/dist/esm/PDFSlickPrintDialog.d.ts.map +1 -0
- package/dist/esm/PDFSlickPrintService.d.ts +23 -0
- package/dist/esm/PDFSlickPrintService.d.ts.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +763 -773
- package/dist/esm/lib/pdf_presentation_mode.d.ts +10 -9
- package/dist/esm/lib/pdf_presentation_mode.d.ts.map +1 -1
- package/dist/esm/lib/pdf_print_service.d.ts +26 -9
- package/dist/esm/lib/pdf_print_service.d.ts.map +1 -1
- package/dist/esm/lib/pdf_rendering_queue.d.ts +4 -12
- package/dist/esm/lib/pdf_rendering_queue.d.ts.map +1 -1
- package/dist/esm/lib/pdf_thumbnail_view.d.ts +33 -41
- package/dist/esm/lib/pdf_thumbnail_view.d.ts.map +1 -1
- package/dist/esm/lib/pdf_thumbnail_viewer.d.ts +35 -72
- package/dist/esm/lib/pdf_thumbnail_viewer.d.ts.map +1 -1
- package/dist/esm/lib/ui_utils.d.ts +42 -51
- package/dist/esm/lib/ui_utils.d.ts.map +1 -1
- package/dist/esm/types.d.ts +2 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/pdf_viewer.css +110 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/umd/index.js +2 -2
- package/package.json +4 -7
- package/dist/esm/lib/overlay_manager.d.ts +0 -32
- package/dist/esm/lib/overlay_manager.d.ts.map +0 -1
package/dist/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).PDFSlickCore={})}(this,(function(t){"use strict";var e="undefined"!=typeof document?document.currentScript:null;function i(t,e,i,s){return new(i||(i=Promise))((function(n,
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).PDFSlickCore={})}(this,(function(t){"use strict";var e="undefined"!=typeof document?document.currentScript:null;function i(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 s(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 n(t,e,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");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"a"===s?n.call(t,i):n?n.value=i:e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError;
|
|
2
2
|
/**
|
|
3
3
|
* @licstart The following is the entire license notice for the
|
|
4
4
|
* JavaScript code in this page
|
|
@@ -19,4 +19,4 @@
|
|
|
19
19
|
*
|
|
20
20
|
* @licend The above is the entire license notice for the
|
|
21
21
|
* JavaScript code in this page
|
|
22
|
-
*/var r={d:(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},a=globalThis.pdfjsLib={};r.d(a,{AbortException:()=>vt,AnnotationEditorLayer:()=>hn,AnnotationEditorParamsType:()=>A,AnnotationEditorType:()=>y,AnnotationEditorUIManager:()=>se,AnnotationLayer:()=>Us,AnnotationMode:()=>w,ColorPicker:()=>Zs,DOMSVGFactory:()=>cs,DrawLayer:()=>dn,FeatureTest:()=>_t,GlobalWorkerOptions:()=>ci,ImageKind:()=>M,InvalidPDFException:()=>gt,MissingPDFException:()=>ft,OPS:()=>tt,OutputScale:()=>Xt,PDFDataRangeTransport:()=>Ki,PDFDateString:()=>zt,PDFWorker:()=>Zi,PasswordResponses:()=>et,PermissionFlag:()=>_,PixelsPerInch:()=>It,RenderingCancelledException:()=>Dt,TextLayer:()=>ji,TouchManager:()=>re,UnexpectedResponseException:()=>mt,Util:()=>St,VerbosityLevel:()=>Z,XfaLayer:()=>us,build:()=>as,createValidAbsoluteUrl:()=>ht,fetchData:()=>Lt,getDocument:()=>Gi,getFilenameFromUrl:()=>Ft,getPdfFilenameFromUrl:()=>Ot,getXfaPageViewport:()=>Ut,isDataScheme:()=>Rt,isPdfFile:()=>Nt,noContextMenu:()=>Vt,normalizeUnicode:()=>Pt,setLayerDimensions:()=>qt,shadow:()=>dt,stopEvent:()=>Ht,version:()=>rs});const o=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),l=[1,0,0,1,0,0],h=[.001,0,0,.001,0,0],d=1.35,c=1,u=2,p=4,g=16,f=32,m=64,b=128,v=256,w={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},y={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},A={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},_={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},x=0,S=1,C=2,E=3,P=3,T=4,M={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},I=1,L=2,k=3,D=4,R=5,N=6,F=7,O=8,B=9,j=10,V=11,H=12,z=13,U=14,$=15,W=16,G=17,q=20,X=1,K=2,Y=3,Q=4,J=5,Z={ERRORS:0,WARNINGS:1,INFOS:5},tt={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},et={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let it=Z.WARNINGS;function st(t){Number.isInteger(t)&&(it=t)}function nt(){return it}function rt(t){it>=Z.INFOS&&console.log(`Info: ${t}`)}function at(t){it>=Z.WARNINGS&&console.log(`Warning: ${t}`)}function ot(t){throw new Error(t)}function lt(t,e){t||ot(e)}function ht(t,e=null,i=null){if(!t)return null;try{if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch{}}const s=e?new URL(t,e):new URL(t);if(function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s))return s}catch{}return null}function dt(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}const ct=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class ut extends ct{constructor(t,e){super(t,"PasswordException"),this.code=e}}class pt extends ct{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}let gt=class extends ct{constructor(t){super(t,"InvalidPDFException")}},ft=class extends ct{constructor(t){super(t,"MissingPDFException")}},mt=class extends ct{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}};class bt extends ct{constructor(t){super(t,"FormatError")}}let vt=class extends ct{constructor(t){super(t,"AbortException")}};function wt(t){"object"==typeof t&&void 0!==t?.length||ot("Invalid argument for bytesToString");const e=t.length,i=8192;if(e<i)return String.fromCharCode.apply(null,t);const s=[];for(let n=0;n<e;n+=i){const r=Math.min(n+i,e),a=t.subarray(n,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function yt(t){"string"!=typeof t&&ot("Invalid argument for stringToBytes");const e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}function At(t){const e=Object.create(null);for(const[i,s]of t)e[i]=s;return e}class _t{static get isLittleEndian(){return dt(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return dt(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return dt(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return dt(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){return"undefined"!=typeof navigator&&"string"==typeof navigator?.platform?dt(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof navigator?.userAgent&&navigator.userAgent.includes("Firefox")}):dt(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return dt(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const xt=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));let St=class{static makeHexColor(t,e,i){return`#${xt[t]}${xt[e]}${xt[i]}`}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){const i=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/i,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/i]}static getAxialAlignedBoundingBox(t,e){const i=this.applyTransform(t,e),s=this.applyTransform(t.slice(2,4),e),n=this.applyTransform([t[0],t[3]],e),r=this.applyTransform([t[2],t[1]],e);return[Math.min(i[0],s[0],n[0],r[0]),Math.min(i[1],s[1],n[1],r[1]),Math.max(i[0],s[0],n[0],r[0]),Math.max(i[1],s[1],n[1],r[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],i=t[0]*e[0]+t[1]*e[2],s=t[0]*e[1]+t[1]*e[3],n=t[2]*e[0]+t[3]*e[2],r=t[2]*e[1]+t[3]*e[3],a=(i+r)/2,o=Math.sqrt((i+r)**2-4*(i*r-n*s))/2,l=a+o||1,h=a-o||1;return[Math.sqrt(l),Math.sqrt(h)]}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[i,n,s,r]}static#t(t,e,i,s,n,r,a,o,l,h){if(l<=0||l>=1)return;const d=1-l,c=l*l,u=c*l,p=d*(d*(d*t+3*l*e)+3*c*i)+u*s,g=d*(d*(d*n+3*l*r)+3*c*a)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static#e(t,e,i,s,n,r,a,o,l,h,d,c){if(Math.abs(l)<1e-12)return void(Math.abs(h)>=1e-12&&this.#t(t,e,i,s,n,r,a,o,-d/h,c));const u=h**2-4*d*l;if(u<0)return;const p=Math.sqrt(u),g=2*l;this.#t(t,e,i,s,n,r,a,o,(-h+p)/g,c),this.#t(t,e,i,s,n,r,a,o,(-h-p)/g,c)}static bezierBoundingBox(t,e,i,s,n,r,a,o,l){return l?(l[0]=Math.min(l[0],t,a),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,a),l[3]=Math.max(l[3],e,o)):l=[Math.min(t,a),Math.min(e,o),Math.max(t,a),Math.max(e,o)],this.#e(t,i,n,a,e,s,r,o,3*(3*(i-n)-t+a),6*(t-2*i+n),3*(i-t),l),this.#e(t,i,n,a,e,s,r,o,3*(3*(s-r)-e+o),6*(e-2*s+r),3*(s-e),l),l}};let Ct=null,Et=null;function Pt(t){return Ct||(Ct=/([\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(Ct,((t,e,i)=>e?e.normalize("NFKC"):Et.get(i)))}const Tt="pdfjs_internal_id_";"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise((i=>{i(t(...e))}))});const Mt="http://www.w3.org/2000/svg";let It=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function Lt(t,e="text"){if(jt(t,document.baseURI)){const i=await fetch(t);if(!i.ok)throw new Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise(((i,s)=>{const n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType=e,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE)if(200!==n.status&&0!==n.status)s(new Error(n.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void i(n.response)}i(n.responseText)}},n.send(null)}))}class kt{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=n,this.offsetY=r,i*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let h,d,c,u,p,g,f,m;switch((s%=360)<0&&(s+=360),s){case 180:h=-1,d=0,c=0,u=1;break;case 90:h=0,d=1,c=1,u=0;break;case 270:h=0,d=-1,c=-1,u=0;break;case 0:h=1,d=0,c=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(c=-c,u=-u),0===h?(p=Math.abs(l-t[1])*i+n,g=Math.abs(o-t[0])*i+r,f=(t[3]-t[1])*i,m=(t[2]-t[0])*i):(p=Math.abs(o-t[0])*i+n,g=Math.abs(l-t[1])*i+r,f=(t[2]-t[0])*i,m=(t[3]-t[1])*i),this.transform=[h*i,d*i,c*i,u*i,p-h*i*o-c*i*l,g-d*i*o-u*i*l],this.width=f,this.height=m}get rawDims(){const{userUnit:t,viewBox:e}=this,i=e.map((e=>e*t));return dt(this,"rawDims",{pageWidth:i[2]-i[0],pageHeight:i[3]-i[1],pageX:i[0],pageY:i[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new kt({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){return St.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=St.applyTransform([t[0],t[1]],this.transform),i=St.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){return St.applyInverseTransform([t,e],this.transform)}}let Dt=class extends ct{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};function Rt(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function Nt(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function Ft(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function Ot(t,e="document.pdf"){if("string"!=typeof t)return e;if(Rt(t))return at('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const i=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t);let n=i.exec(s[1])||i.exec(s[2])||i.exec(s[3]);if(n&&(n=n[0],n.includes("%")))try{n=i.exec(decodeURIComponent(n))[0]}catch{}return n||e}class Bt{started=Object.create(null);times=[];time(t){t in this.started&&at(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||at(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:t}of this.times)e=Math.max(t.length,e);for(const{name:i,start:s,end:n}of this.times)t.push(`${i.padEnd(e)} ${n-s}ms\n`);return t.join("")}}function jt(t,e){try{const{protocol:i}=e?new URL(t,e):new URL(t);return"http:"===i||"https:"===i}catch{return!1}}function Vt(t){t.preventDefault()}function Ht(t){t.preventDefault(),t.stopPropagation()}let zt=class{static#i;static toDateObject(t){if(!t||"string"!=typeof t)return null;this.#i||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#i.exec(t);if(!e)return null;const i=parseInt(e[1],10);let s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const l=e[7]||"Z";let h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,"-"===l?(r+=h,a+=d):"+"===l&&(r-=h,a-=d),new Date(Date.UTC(i,s,n,r,a,o))}};function Ut(t,{scale:e=1,rotation:i=0}){const{width:s,height:n}=t.attributes.style,r=[0,0,parseInt(s),parseInt(n)];return new kt({viewBox:r,userUnit:1,scale:e,rotation:i})}function $t(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map((t=>parseInt(t))):t.startsWith("rgba(")?t.slice(5,-1).split(",").map((t=>parseInt(t))).slice(0,3):(at(`Not a valid color format: "${t}"`),[0,0,0])}function Wt(t){const{a:e,b:i,c:s,d:n,e:r,f:a}=t.getTransform();return[e,i,s,n,r,a]}function Gt(t){const{a:e,b:i,c:s,d:n,e:r,f:a}=t.getTransform().invertSelf();return[e,i,s,n,r,a]}function qt(t,e,i=!1,s=!0){if(e instanceof kt){const{pageWidth:s,pageHeight:n}=e.rawDims,{style:r}=t,a=_t.isCSSRoundSupported,o=`var(--scale-factor) * ${s}px`,l=`var(--scale-factor) * ${n}px`,h=a?`round(down, ${o}, var(--scale-round-x, 1px))`:`calc(${o})`,d=a?`round(down, ${l}, var(--scale-round-y, 1px))`:`calc(${l})`;i&&e.rotation%180!=0?(r.width=d,r.height=h):(r.width=h,r.height=d)}s&&t.setAttribute("data-main-rotation",e.rotation)}let Xt=class{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}};class Kt{#s=null;#n=null;#r;#a=null;#o=null;static#l=null;constructor(t){this.#r=t,Kt.#l||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"})}render(){const t=this.#s=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#r._uiManager._signal;t.addEventListener("contextmenu",Vt,{signal:e}),t.addEventListener("pointerdown",Kt.#h,{signal:e});const i=this.#a=document.createElement("div");i.className="buttons",t.append(i);const s=this.#r.toolbarPosition;if(s){const{style:e}=t,i="ltr"===this.#r._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=100*i+"%",e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return this.#d(),t}get div(){return this.#s}static#h(t){t.stopPropagation()}#c(t){this.#r._focusEventsAllowed=!1,Ht(t)}#u(t){this.#r._focusEventsAllowed=!0,Ht(t)}#p(t){const e=this.#r._uiManager._signal;t.addEventListener("focusin",this.#c.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Vt,{signal:e})}hide(){this.#s.classList.add("hidden"),this.#n?.hideDropdown()}show(){this.#s.classList.remove("hidden"),this.#o?.shown()}#d(){const{editorType:t,_uiManager:e}=this.#r,i=document.createElement("button");i.className="delete",i.tabIndex=0,i.setAttribute("data-l10n-id",Kt.#l[t]),this.#p(i),i.addEventListener("click",(t=>{e.delete()}),{signal:e._signal}),this.#a.append(i)}get#g(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#p(e),this.#a.prepend(e,this.#g),this.#o=t}addColorPicker(t){this.#n=t;const e=t.renderButton();this.#p(e),this.#a.prepend(e,this.#g)}remove(){this.#s.remove(),this.#n?.destroy(),this.#n=null}}class Yt{#a=null;#s=null;#f;constructor(t){this.#f=t}#m(){const t=this.#s=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",Vt,{signal:this.#f._signal});const e=this.#a=document.createElement("div");return e.className="buttons",t.append(e),this.#b(),t}#v(t,e){let i=0,s=0;for(const n of t){const t=n.y+n.height;if(t<i)continue;const r=n.x+(e?n.width:0);t>i?(s=r,i=t):e?r>s&&(s=r):r<s&&(s=r)}return[e?1-s:s,i]}show(t,e,i){const[s,n]=this.#v(e,i),{style:r}=this.#s||=this.#m();t.append(this.#s),r.insetInlineEnd=100*s+"%",r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#s.remove()}#b(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const i=this.#f._signal;t.addEventListener("contextmenu",Vt,{signal:i}),t.addEventListener("click",(()=>{this.#f.highlightSelection("floating_button")}),{signal:i}),this.#a.append(t)}}function Qt(t,e,i){for(const s of i)e.addEventListener(s,t[s].bind(t))}class Jt{#w=0;get id(){return"pdfjs_internal_editor_"+this.#w++}}class Zt{#y=function(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),wt(t)}();#w=0;#A=null;static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>';return dt(this,"_isSVGFittingCanvas",e.decode().then((()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]))))}async#_(t,e){this.#A||=new Map;let i=this.#A.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#y}_${this.#w++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await Lt(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=Zt._isSVGFittingCanvas,s=new FileReader,n=new Image,r=new Promise(((t,r)=>{n.onload=()=>{i.bitmap=n,i.isSvg=!0,t()},s.onload=async()=>{const t=i.svgUrl=s.result;n.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},n.onerror=s.onerror=r}));s.readAsDataURL(t),await r}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){at(t),i=null}return this.#A.set(t,i),i&&this.#A.set(i.id,i),i}async getFromFile(t){const{lastModified:e,name:i,size:s,type:n}=t;return this.#_(`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return this.#_(t,t)}async getFromBlob(t,e){const i=await e;return this.#_(t,i)}async getFromId(t){this.#A||=new Map;const e=this.#A.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#A||=new Map;let i=this.#A.get(t);if(i?.bitmap)return i.refCounter+=1,i;const s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#y}_${this.#w++}`,refCounter:1,isSvg:!1},this.#A.set(t,i),this.#A.set(i.id,i),i}getSvgUrl(t){const e=this.#A.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#A||=new Map;const e=this.#A.get(t);if(!e)return;if(e.refCounter-=1,0!==e.refCounter)return;const{bitmap:i}=e;if(!e.url&&!e.file){const t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=t.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#y}_`)}}class te{#x=[];#S=!1;#C;#E=-1;constructor(t=128){this.#C=t}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(s&&t(),this.#S)return;const o={cmd:t,undo:e,post:i,type:n};if(-1===this.#E)return this.#x.length>0&&(this.#x.length=0),this.#E=0,void this.#x.push(o);if(r&&this.#x[this.#E].type===n)return a&&(o.undo=this.#x[this.#E].undo),void(this.#x[this.#E]=o);const l=this.#E+1;l===this.#C?this.#x.splice(0,1):(this.#E=l,l<this.#x.length&&this.#x.splice(l)),this.#x.push(o)}undo(){if(-1===this.#E)return;this.#S=!0;const{undo:t,post:e}=this.#x[this.#E];t(),e?.(),this.#S=!1,this.#E-=1}redo(){if(this.#E<this.#x.length-1){this.#E+=1,this.#S=!0;const{cmd:t,post:e}=this.#x[this.#E];t(),e?.(),this.#S=!1}}hasSomethingToUndo(){return-1!==this.#E}hasSomethingToRedo(){return this.#E<this.#x.length-1}cleanType(t){if(-1!==this.#E){for(let e=this.#E;e>=0;e--)if(this.#x[e].type!==t)return this.#x.splice(e+1,this.#E-e),void(this.#E=e);this.#x.length=0,this.#E=-1}}destroy(){this.#x=null}}class ee{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=_t.platform;for(const[i,s,n={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1)))}}#P(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const i=this.callbacks.get(this.#P(e));if(!i)return;const{callback:s,options:{bubbles:n=!1,args:r=[],checker:a=null}}=i;a&&!a(t,e)||(s.bind(t,...r,e)(),n||Ht(e))}}class ie{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",document.body.append(e);for(const i of t.keys()){e.style.color=i;const s=window.getComputedStyle(e).color;t.set(i,$t(s))}e.remove()}(t),dt(this,"_colors",t)}convert(t){const e=$t(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 ie._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?St.makeHexColor(...e):t}}let se=class t{#T=new AbortController;#M=null;#I=new Map;#L=new Map;#k=null;#D=null;#R=null;#N=new te;#F=null;#O=null;#B=0;#j=new Set;#V=null;#H=null;#z=new Set;_editorUndoBar=null;#U=!1;#$=!1;#W=!1;#G=null;#q=null;#X=null;#K=null;#Y=!1;#Q=null;#J=new Jt;#Z=!1;#tt=!1;#et=null;#it=null;#st=null;#nt=null;#rt=y.NONE;#at=new Set;#ot=null;#lt=null;#ht=null;#dt={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#ct=[0,0];#ut=null;#pt=null;#gt=null;#ft=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const e=t.prototype,i=t=>t.#pt.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),s=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},n=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return dt(this,"_keyboardManager",new ee([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],e.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:s}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#pt.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#pt.contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-n,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-r,0],checker:i}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[n,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[r,0],checker:i}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-n],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-r],checker:i}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,n],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,r],checker:i}]]))}constructor(t,e,i,s,n,r,a,o,l,h,d,c,u){const p=this._signal=this.#T.signal;this.#pt=t,this.#gt=e,this.#k=i,this._eventBus=s,s._on("editingaction",this.onEditingAction.bind(this),{signal:p}),s._on("pagechanging",this.onPageChanging.bind(this),{signal:p}),s._on("scalechanging",this.onScaleChanging.bind(this),{signal:p}),s._on("rotationchanging",this.onRotationChanging.bind(this),{signal:p}),s._on("setpreference",this.onSetPreference.bind(this),{signal:p}),s._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:p}),this.#mt(),this.#bt(),this.#vt(),this.#D=n.annotationStorage,this.#G=n.filterFactory,this.#lt=r,this.#K=a||null,this.#U=o,this.#$=l,this.#W=h,this.#nt=d||null,this.viewParameters={realScale:It.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=c||null,this._supportsPinchToZoom=!1!==u}destroy(){this.#ft?.resolve(),this.#ft=null,this.#T?.abort(),this.#T=null,this._signal=null;for(const t of this.#L.values())t.destroy();this.#L.clear(),this.#I.clear(),this.#z.clear(),this.#M=null,this.#at.clear(),this.#N.destroy(),this.#k?.destroy(),this.#Q?.hide(),this.#Q=null,this.#q&&(clearTimeout(this.#q),this.#q=null),this.#ut&&(clearTimeout(this.#ut),this.#ut=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#nt}get useNewAltTextFlow(){return this.#$}get useNewAltTextWhenAddingImage(){return this.#W}get hcmFilter(){return dt(this,"hcmFilter",this.#lt?this.#G.addHCMFilter(this.#lt.foreground,this.#lt.background):"none")}get direction(){return dt(this,"direction",getComputedStyle(this.#pt).direction)}get highlightColors(){return dt(this,"highlightColors",this.#K?new Map(this.#K.split(",").map((t=>t.split("=").map((t=>t.trim()))))):null)}get highlightColorNames(){return dt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#O=t}setMainHighlightColorPicker(t){this.#st=t}editAltText(t,e=!1){this.#k?.editAltText(this,t,e)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){if("enableNewAltTextWhenAddingImage"===t)this.#W=e}onPageChanging({pageNumber:t}){this.#B=t-1}focusMainContainer(){this.#pt.focus()}findParent(t,e){for(const i of this.#L.values()){const{x:s,y:n,width:r,height:a}=i.div.getBoundingClientRect();if(t>=s&&t<=s+r&&e>=n&&e<=n+a)return i}return null}disableUserSelect(t=!1){this.#gt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#z.add(t)}removeShouldRescale(t){this.#z.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*It.PDF_TO_CSS_UNITS;for(const t of this.#z)t.onScaleChanging();this.#O?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#wt({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#yt(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const e of this.#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:r}=e,a=e.toString(),o=this.#wt(e).closest(".textLayer"),l=this.getSelectionBoxes(o);if(!l)return;e.empty();const h=this.#yt(o),d=this.#rt===y.NONE,c=()=>{h?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:l,anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r,text:a}),d&&this.showAllEditors("highlight",!0,!0)};d?this.switchToMode(y.HIGHLIGHT,c):c()}#At(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#wt(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#Q||=new Yt(this),this.#Q.show(e,i,"ltr"===this.direction))}addToAnnotationStorage(t){t.isEmpty()||!this.#D||this.#D.has(t.id)||this.#D.setValue(t.id,t)}#_t(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#ot&&(this.#Q?.hide(),this.#ot=null,this.#xt({hasSelectedText:!1})));const{anchorNode:e}=t;if(e===this.#ot)return;const i=this.#wt(t).closest(".textLayer");if(i){if(this.#Q?.hide(),this.#ot=e,this.#xt({hasSelectedText:!0}),(this.#rt===y.HIGHLIGHT||this.#rt===y.NONE)&&(this.#rt===y.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#Y=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#rt===y.HIGHLIGHT?this.#yt(i):null;t?.toggleDrawing();const e=new AbortController,s=this.combinedSignal(e),n=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#St("main_toolbar"))};window.addEventListener("pointerup",n,{signal:s}),window.addEventListener("blur",n,{signal:s})}}else this.#ot&&(this.#Q?.hide(),this.#ot=null,this.#xt({hasSelectedText:!1}))}#St(t=""){this.#rt===y.HIGHLIGHT?this.highlightSelection(t):this.#U&&this.#At()}#mt(){document.addEventListener("selectionchange",this.#_t.bind(this),{signal:this._signal})}#Ct(){if(this.#X)return;this.#X=new AbortController;const t=this.combinedSignal(this.#X);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#Et(){this.#X?.abort(),this.#X=null}blur(){if(this.isShiftKeyDown=!1,this.#Y&&(this.#Y=!1,this.#St("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#at)if(e.div.contains(t)){this.#it=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#it)return;const[t,e]=this.#it;this.#it=null,e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}#vt(){if(this.#et)return;this.#et=new AbortController;const t=this.combinedSignal(this.#et);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#Pt(){this.#et?.abort(),this.#et=null}#Tt(){if(this.#F)return;this.#F=new AbortController;const t=this.combinedSignal(this.#F);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#Mt(){this.#F?.abort(),this.#F=null}#bt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#vt(),this.#Tt()}removeEditListeners(){this.#Pt(),this.#Mt()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of this.#H)if(i.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const i of this.#H)if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#M?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const t of this.#at){const i=t.serialize(!0);i&&e.push(i)}0!==e.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const t of e.items)for(const e of this.#H)if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){return void at(`paste: "${t.message}".`)}if(!Array.isArray(i))return;this.unselectAll();const s=this.currentLayer;try{const t=[];for(const e of i){const i=await s.deserialize(e);if(!i)return;t.push(i)}const e=()=>{for(const e of t)this.#It(e);this.#Lt(t)},n=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:n,mustExec:!0})}catch(t){at(`paste: "${t.message}".`)}}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0),this.#rt===y.NONE||this.isEditorHandlingKeyboard||t._keyboardManager.exec(this,e)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#Y&&(this.#Y=!1,this.#St("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#xt(t){Object.entries(t).some((([t,e])=>this.#dt[t]!==e))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#dt,t)}),this.#rt===y.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#kt([[A.HIGHLIGHT_FREE,!0]]))}#kt(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#Ct(),this.#Tt(),this.#xt({isEditing:this.#rt!==y.NONE,isEmpty:this.#Dt(),hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:this.#N.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Et(),this.#Mt(),this.#xt({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#H){this.#H=t;for(const t of this.#H)this.#kt(t.defaultPropertiesToUpdate)}}getId(){return this.#J.id}get currentLayer(){return this.#L.get(this.#B)}getLayer(t){return this.#L.get(t)}get currentPageIndex(){return this.#B}addLayer(t){this.#L.set(t.pageIndex,t),this.#Z?t.enable():t.disable()}removeLayer(t){this.#L.delete(t.pageIndex)}async updateMode(t,e=null,i=!1){if(this.#rt!==t&&(!this.#ft||(await this.#ft.promise,this.#ft))){if(this.#ft=Promise.withResolvers(),this.#rt=t,t===y.NONE)return this.setEditingState(!1),this.#Rt(),this._editorUndoBar?.hide(),void this.#ft.resolve();this.setEditingState(!0),await this.#Nt(),this.unselectAll();for(const e of this.#L.values())e.updateMode(t);if(!e)return i&&this.addNewEditorFromKeyboard(),void this.#ft.resolve();for(const t of this.#I.values())t.annotationElementId===e?(this.setSelected(t),t.enterInEditMode()):t.unselect();this.#ft.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#rt&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#H){switch(t){case A.CREATE:return void this.currentLayer.addNewEditor();case A.HIGHLIGHT_DEFAULT_COLOR:this.#st?.updateColor(e);break;case A.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#ht||=new Map).set(t,e),this.showAllEditors("highlight",e)}for(const i of this.#at)i.updateParams(t,e);for(const i of this.#H)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(const i of this.#I.values())i.editorType===t&&i.show(e);(this.#ht?.get(A.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#kt([[A.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#tt!==t){this.#tt=t;for(const e of this.#L.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#Nt(){if(!this.#Z){this.#Z=!0;const t=[];for(const e of this.#L.values())t.push(e.enable());await Promise.all(t);for(const t of this.#I.values())t.enable()}}#Rt(){if(this.unselectAll(),this.#Z){this.#Z=!1;for(const t of this.#L.values())t.disable();for(const t of this.#I.values())t.disable()}}getEditors(t){const e=[];for(const i of this.#I.values())i.pageIndex===t&&e.push(i);return e}getEditor(t){return this.#I.get(t)}addEditor(t){this.#I.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#q&&clearTimeout(this.#q),this.#q=setTimeout((()=>{this.focusMainContainer(),this.#q=null}),0)),this.#I.delete(t.id),this.unselect(t),t.annotationElementId&&this.#j.has(t.annotationElementId)||this.#D?.remove(t.id)}addDeletedAnnotationElement(t){this.#j.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#j.has(t)}removeDeletedAnnotationElement(t){this.#j.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#It(t){const e=this.#L.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#M!==t&&(this.#M=t,t&&this.#kt(t.propertiesToUpdate))}get#Ft(){let t=null;for(t of this.#at);return t}updateUI(t){this.#Ft===t&&this.#kt(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#kt(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#at.has(t))return this.#at.delete(t),t.unselect(),void this.#xt({hasSelectedEditor:this.hasSelection});this.#at.add(t),t.select(),this.#kt(t.propertiesToUpdate),this.#xt({hasSelectedEditor:!0})}setSelected(t){this.#O?.commitOrRemove();for(const e of this.#at)e!==t&&e.unselect();this.#at.clear(),this.#at.add(t),t.select(),this.#kt(t.propertiesToUpdate),this.#xt({hasSelectedEditor:!0})}isSelected(t){return this.#at.has(t)}get firstSelectedEditor(){return this.#at.values().next().value}unselect(t){t.unselect(),this.#at.delete(t),this.#xt({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#at.size}get isEnterHandled(){return 1===this.#at.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#N.undo(),this.#xt({hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Dt()}),this._editorUndoBar?.hide()}redo(){this.#N.redo(),this.#xt({hasSomethingToUndo:!0,hasSomethingToRedo:this.#N.hasSomethingToRedo(),isEmpty:this.#Dt()})}addCommands(t){this.#N.add(t),this.#xt({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Dt()})}cleanUndoStack(t){this.#N.cleanType(t)}#Dt(){if(0===this.#I.size)return!0;if(1===this.#I.size)for(const t of this.#I.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...this.#at],i=()=>{for(const t of e)this.#It(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.#M?.commitOrRemove()}hasSomethingToControl(){return this.#M||this.hasSelection}#Lt(t){for(const t of this.#at)t.unselect();this.#at.clear();for(const e of t)e.isEmpty()||(this.#at.add(e),e.select());this.#xt({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#at)t.commit();this.#Lt(this.#I.values())}unselectAll(){if((!this.#M||(this.#M.commitOrRemove(),this.#rt===y.NONE))&&!this.#O?.commitOrRemove()&&this.hasSelection){for(const t of this.#at)t.unselect();this.#at.clear(),this.#xt({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#ct[0]+=t,this.#ct[1]+=e;const[s,n]=this.#ct,r=[...this.#at];this.#ut&&clearTimeout(this.#ut),this.#ut=setTimeout((()=>{this.#ut=null,this.#ct[0]=this.#ct[1]=0,this.addCommands({cmd:()=>{for(const t of r)this.#I.has(t.id)&&t.translateInPage(s,n)},undo:()=>{for(const t of r)this.#I.has(t.id)&&t.translateInPage(-s,-n)},mustExec:!1})}),1e3);for(const i of r)i.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#V=new Map;for(const t of this.#at)this.#V.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#V)return!1;this.disableUserSelect(!1);const t=this.#V;this.#V=null;let e=!1;for(const[{x:i,y:s,pageIndex:n},r]of t)r.newX=i,r.newY=s,r.newPageIndex=n,e||=i!==r.savedX||s!==r.savedY||n!==r.savedPageIndex;if(!e)return!1;const i=(t,e,i,s)=>{if(this.#I.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:r}]of t)i(e,s,n,r)},undo:()=>{for(const[e,{savedX:s,savedY:n,savedPageIndex:r}]of t)i(e,s,n,r)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#V)for(const i of this.#V.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#at.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#M===t}getActive(){return this.#M}getMode(){return this.#rt}get imageManager(){return dt(this,"imageManager",new Zt)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let i=0,s=e.rangeCount;i<s;i++)if(!t.contains(e.getRangeAt(i).commonAncestorContainer))return null;const{x:i,y:s,width:n,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(t,e,a,o)=>({x:(e-s)/r,y:1-(t+a-i)/n,width:o/r,height:a/n});break;case"180":a=(t,e,a,o)=>({x:1-(t+a-i)/n,y:1-(e+o-s)/r,width:a/n,height:o/r});break;case"270":a=(t,e,a,o)=>({x:1-(e+o-s)/r,y:(t-i)/n,width:o/r,height:a/n});break;default:a=(t,e,a,o)=>({x:(t-i)/n,y:(e-s)/r,width:a/n,height:o/r})}const o=[];for(let t=0,i=e.rangeCount;t<i;t++){const i=e.getRangeAt(t);if(!i.collapsed)for(const{x:t,y:e,width:s,height:n}of i.getClientRects())0!==s&&0!==n&&o.push(a(t,e,s,n))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#R||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#R?.delete(t)}renderAnnotationElement(t){const e=this.#R?.get(t.data.id);if(!e)return;const i=this.#D.getRawValue(e);i&&(this.#rt!==y.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}};class ne{#o=null;#Ot=!1;#Bt=null;#jt=null;#Vt=null;#Ht=null;#zt=!1;#Ut=null;#r=null;#$t=null;#Wt=null;#Gt=!1;static#qt=null;static _l10n=null;constructor(t){this.#r=t,this.#Gt=t._uiManager.useNewAltTextFlow,ne.#qt||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){ne._l10n??=t}async render(){const t=this.#Bt=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#jt=document.createElement("span");t.append(e),this.#Gt?(t.classList.add("new"),t.setAttribute("data-l10n-id",ne.#qt.missing),e.setAttribute("data-l10n-id",ne.#qt["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const i=this.#r._uiManager._signal;t.addEventListener("contextmenu",Vt,{signal:i}),t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:i});const s=t=>{t.preventDefault(),this.#r._uiManager.editAltText(this.#r),this.#Gt&&this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#Xt}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",(e=>{e.target===t&&"Enter"===e.key&&(this.#zt=!0,s(e))}),{signal:i}),await this.#Kt(),t}get#Xt(){return(this.#o?"added":null===this.#o&&this.guessedText&&"review")||"missing"}finish(){this.#Bt&&(this.#Bt.focus({focusVisible:this.#zt}),this.#zt=!1)}isEmpty(){return this.#Gt?null===this.#o:!this.#o&&!this.#Ot}hasData(){return this.#Gt?null!==this.#o||!!this.#$t:this.isEmpty()}get guessedText(){return this.#$t}async setGuessedText(t){null===this.#o&&(this.#$t=t,this.#Wt=await ne._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#Kt())}toggleAltTextBadge(t=!1){if(!this.#Gt||this.#o)return this.#Ut?.remove(),void(this.#Ut=null);if(!this.#Ut){const t=this.#Ut=document.createElement("div");t.className="noAltTextBadge",this.#r.div.append(t)}this.#Ut.classList.toggle("hidden",!t)}serialize(t){let e=this.#o;return t||this.#$t!==e||(e=this.#Wt),{altText:e,decorative:this.#Ot,guessedText:this.#$t,textWithDisclaimer:this.#Wt}}get data(){return{altText:this.#o,decorative:this.#Ot}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:n=!1}){i&&(this.#$t=i,this.#Wt=s),this.#o===t&&this.#Ot===e||(n||(this.#o=t,this.#Ot=e),this.#Kt())}toggle(t=!1){this.#Bt&&(!t&&this.#Ht&&(clearTimeout(this.#Ht),this.#Ht=null),this.#Bt.disabled=!t)}shown(){this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#Xt}})}destroy(){this.#Bt?.remove(),this.#Bt=null,this.#jt=null,this.#Vt=null,this.#Ut?.remove(),this.#Ut=null}async#Kt(){const t=this.#Bt;if(!t)return;if(this.#Gt){if(t.classList.toggle("done",!!this.#o),t.setAttribute("data-l10n-id",ne.#qt[this.#Xt]),this.#jt?.setAttribute("data-l10n-id",ne.#qt[`${this.#Xt}-label`]),!this.#o)return void this.#Vt?.remove()}else{if(!this.#o&&!this.#Ot)return t.classList.remove("done"),void this.#Vt?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#Vt;if(!e){this.#Vt=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#r.id}`;const i=100,s=this.#r._uiManager._signal;s.addEventListener("abort",(()=>{clearTimeout(this.#Ht),this.#Ht=null}),{once:!0}),t.addEventListener("mouseenter",(()=>{this.#Ht=setTimeout((()=>{this.#Ht=null,this.#Vt.classList.add("show"),this.#r._reportTelemetry({action:"alt_text_tooltip"})}),i)}),{signal:s}),t.addEventListener("mouseleave",(()=>{this.#Ht&&(clearTimeout(this.#Ht),this.#Ht=null),this.#Vt?.classList.remove("show")}),{signal:s})}this.#Ot?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#o),e.parentNode||t.append(e);const i=this.#r.getImageForAltText();i?.setAttribute("aria-describedby",e.id)}}let re=class t{#pt;#Yt=!1;#Qt=null;#Jt;#Zt;#te;#ee;#ie;#se=null;#ne;#re=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:r=null,signal:a}){this.#pt=t,this.#Qt=i,this.#Jt=e,this.#Zt=s,this.#te=n,this.#ee=r,this.#ne=new AbortController,this.#ie=AbortSignal.any([a,this.#ne.signal]),t.addEventListener("touchstart",this.#ae.bind(this),{passive:!1,signal:this.#ie})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return dt(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#ae(t){if(this.#Jt?.()||t.touches.length<2)return;if(!this.#re){this.#re=new AbortController;const t=AbortSignal.any([this.#ie,this.#re.signal]),e=this.#pt,i={signal:t,passive:!1};e.addEventListener("touchmove",this.#oe.bind(this),i),e.addEventListener("touchend",this.#le.bind(this),i),e.addEventListener("touchcancel",this.#le.bind(this),i),this.#Zt?.()}if(Ht(t),2!==t.touches.length||this.#Qt?.())return void(this.#se=null);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#se={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#oe(e){if(!this.#se||2!==e.touches.length)return;let[i,s]=e.touches;i.identifier>s.identifier&&([i,s]=[s,i]);const{screenX:n,screenY:r}=i,{screenX:a,screenY:o}=s,l=this.#se,{touch0X:h,touch0Y:d,touch1X:c,touch1Y:u}=l,p=c-h,g=u-d,f=a-n,m=o-r,b=Math.hypot(f,m)||1,v=Math.hypot(p,g)||1;if(!this.#Yt&&Math.abs(v-b)<=t.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=n,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,e.preventDefault(),!this.#Yt)return void(this.#Yt=!0);const w=[(n+a)/2,(r+o)/2];this.#te?.(w,v,b)}#le(t){this.#re.abort(),this.#re=null,this.#ee?.(),this.#se&&(t.preventDefault(),this.#se=null,this.#Yt=!1)}destroy(){this.#ne?.abort(),this.#ne=null}};class ae{#he=null;#de=null;#o=null;#ce=!1;#ue=null;#pe="";#ge=!1;#fe=null;#me=null;#be=null;#ve=null;#we="";#ye=!1;#Ae=null;#_e=!1;#xe=!1;#Se=!1;#Ce=null;#Ee=0;#Pe=0;#Te=null;#Me=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#Ie=!1;#Le=ae._zIndex++;static _borderLineWidth=-1;static _colorManager=new ie;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=ae.prototype._resizeWithKeyboard,e=se.TRANSLATE_SMALL,i=se.TRANSLATE_BIG;return dt(this,"_resizerKeyboardManager",new ee([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],ae.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[n,r];const[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return dt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new oe({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(ae._l10n??=t,ae._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),-1!==ae._borderLineWidth)return;const i=getComputedStyle(document.documentElement);ae._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){ot("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#Ie}set _isDraggable(t){this.#Ie=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.#Le}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#ke(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#ye?this.#ye=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const e=t.relatedTarget;e?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){const[n,r]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/r,this.fixAndSetPosition()}#De([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#De(this.parentDimensions,t,e)}translateInPage(t,e){this.#Ae||=[this.x,this.y,this.width,this.height],this.#De(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#Ae||=[this.x,this.y,this.width,this.height];const{div:i,parentDimensions:[s,n]}=this;if(this.x+=t/s,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:a}=this;const[o,l]=this.getBaseTranslation();r+=o,a+=l;const{style:h}=i;h.left=`${(100*r).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#Ae&&(this.#Ae[0]!==this.x||this.#Ae[1]!==this.y)}get _hasBeenResized(){return!!this.#Ae&&(this.#Ae[2]!==this.width||this.#Ae[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=ae,s=i/t,n=i/e;switch(this.rotation){case 90:return[-s,n];case 180:return[s,n];case 270:return[s,-n];default:return[-s,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[i,s]}=this;let{x:n,y:r,width:a,height:o}=this;if(a*=i,o*=s,n*=i,r*=s,this._mustFixPosition)switch(t){case 0:n=Math.max(0,Math.min(i-a,n)),r=Math.max(0,Math.min(s-o,r));break;case 90:n=Math.max(0,Math.min(i-o,n)),r=Math.min(s,Math.max(a,r));break;case 180:n=Math.min(i,Math.max(a,n)),r=Math.min(s,Math.max(o,r));break;case 270:n=Math.min(i,Math.max(o,n)),r=Math.max(0,Math.min(s-a,r))}this.x=n/=i,this.y=r/=s;const[l,h]=this.getBaseTranslation();n+=l,r+=h,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#Re(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return ae.#Re(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return ae.#Re(t,e,360-this.parentRotation)}#Ne(t){switch(t){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(t,e){const[i,s]=this.parentDimensions,{style:n}=this.div;n.width=`${(100*t/i).toFixed(2)}%`,this.#ge||(n.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:i}=t,s=i.endsWith("%"),n=!this.#ge&&e.endsWith("%");if(s&&n)return;const[r,a]=this.parentDimensions;s||(t.width=`${(100*parseFloat(i)/r).toFixed(2)}%`),this.#ge||n||(t.height=`${(100*parseFloat(e)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#Fe(){if(this.#fe)return;this.#fe=document.createElement("div"),this.#fe.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const i of t){const t=document.createElement("div");this.#fe.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#Oe.bind(this,i),{signal:e}),t.addEventListener("contextmenu",Vt,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#fe)}#Oe(t,e){e.preventDefault();const{isMac:i}=_t.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#o?.toggle(!1);const s=this._isDraggable;this._isDraggable=!1,this.#me=[e.screenX,e.screenY];const n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#Be.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",Ht,{passive:!1,signal:r}),window.addEventListener("contextmenu",Vt,{signal:r}),this.#be={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const l=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#o?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#je()};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}#Ve(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e;const[n,r]=this.parentDimensions;this.setDims(n*i,r*s),this.fixAndSetPosition(),this._onResized()}_onResized(){}#je(){if(!this.#be)return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#be;this.#be=null;const n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===i&&o===s||this.addCommands({cmd:this.#Ve.bind(this,n,r,a,o),undo:this.#Ve.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#Be(t,e){const[i,s]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,l=ae.MIN_SIZE/i,h=ae.MIN_SIZE/s,d=this.#Ne(this.rotation),c=(t,e)=>[d[0]*t+d[2]*e,d[1]*t+d[3]*e],u=this.#Ne(360-this.rotation);let p,g,f=!1,m=!1;switch(t){case"topLeft":f=!0,p=(t,e)=>[0,0],g=(t,e)=>[t,e];break;case"topMiddle":p=(t,e)=>[t/2,0],g=(t,e)=>[t/2,e];break;case"topRight":f=!0,p=(t,e)=>[t,0],g=(t,e)=>[0,e];break;case"middleRight":m=!0,p=(t,e)=>[t,e/2],g=(t,e)=>[0,e/2];break;case"bottomRight":f=!0,p=(t,e)=>[t,e],g=(t,e)=>[0,0];break;case"bottomMiddle":p=(t,e)=>[t/2,e],g=(t,e)=>[t/2,0];break;case"bottomLeft":f=!0,p=(t,e)=>[0,e],g=(t,e)=>[t,0];break;case"middleLeft":m=!0,p=(t,e)=>[0,e/2],g=(t,e)=>[t,e/2]}const b=p(a,o),v=g(a,o);let w=c(...v);const y=ae._round(n+w[0]),A=ae._round(r+w[1]);let _,x,S=1,C=1;if(e.fromKeyboard)({deltaX:_,deltaY:x}=e);else{const{screenX:t,screenY:i}=e,[s,n]=this.#me;[_,x]=this.screenToPageTranslation(t-s,i-n),this.#me[0]=t,this.#me[1]=i}var E,P;if([_,x]=(E=_/i,P=x/s,[u[0]*E+u[2]*P,u[1]*E+u[3]*P]),f){const t=Math.hypot(a,o);S=C=Math.max(Math.min(Math.hypot(v[0]-b[0]-_,v[1]-b[1]-x)/t,1/a,1/o),l/a,h/o)}else m?S=Math.max(l,Math.min(1,Math.abs(v[0]-b[0]-_)))/a:C=Math.max(h,Math.min(1,Math.abs(v[1]-b[1]-x)))/o;const T=ae._round(a*S),M=ae._round(o*C);w=c(...g(T,M));const I=y-w[0],L=A-w[1];this.#Ae||=[this.x,this.y,this.width,this.height],this.width=T,this.height=M,this.x=I,this.y=L,this.setDims(i*T,s*M),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#o?.finish()}async addEditToolbar(){return this._editToolbar||this.#xe||(this._editToolbar=new Kt(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||(ne.initialize(ae._l10n),this.#o=new ne(this),this.#he&&(this.#o.data=this.#he,this.#he=null),await this.addEditToolbar())}get altTextData(){return this.#o?.data}set altTextData(t){this.#o&&(this.#o.data=t)}get guessedAltText(){return this.#o?.guessedText}async setGuessedAltText(t){await(this.#o?.setGuessedText(t))}serializeAltText(t){return this.#o?.serialize(t)}hasAltText(){return!!this.#o&&!this.#o.isEmpty()}hasAltTextData(){return this.#o?.hasData()??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#ce?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#He();const[t,e]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);const[i,s]=this.getInitialTranslation();return this.translate(i,s),Qt(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#Me||=new re({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#ze.bind(this),onPinching:this.#Ue.bind(this),onPinchEnd:this.#$e.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#ze(){this.#be={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#o?.toggle(!1),this.parent.togglePointerEvents(!1)}#Ue(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;const n=this.#Ne(this.rotation),r=(t,e)=>[n[0]*t+n[2]*e,n[1]*t+n[3]*e],[a,o]=this.parentDimensions,l=this.x,h=this.y,d=this.width,c=this.height,u=ae.MIN_SIZE/a,p=ae.MIN_SIZE/o;s=Math.max(Math.min(s,1/d,1/c),u/d,p/c);const g=ae._round(d*s),f=ae._round(c*s);if(g===d&&f===c)return;this.#Ae||=[l,h,d,c];const m=r(d/2,c/2),b=ae._round(l+m[0]),v=ae._round(h+m[1]),w=r(g/2,f/2);this.x=b-w[0],this.y=v-w[1],this.width=g,this.height=f,this.setDims(a*g,o*f),this.fixAndSetPosition(),this._onResizing()}#$e(){this.#o?.toggle(!0),this.parent.togglePointerEvents(!0),this.#je()}pointerdown(t){const{isMac:e}=_t.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#ye=!0,this._isDraggable?this.#We(t):this.#Ge(t))}get isSelected(){return this._uiManager.isSelected(this)}#Ge(t){const{isMac:e}=_t.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#We(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const s=new AbortController,n=this._uiManager.combinedSignal(s),r={capture:!0,passive:!1,signal:n},a=t=>{s.abort(),this.#ue=null,this.#ye=!1,this._uiManager.endDragSession()||this.#Ge(t),i&&this._onStopDragging()};e&&(this.#Ee=t.clientX,this.#Pe=t.clientY,this.#ue=t.pointerId,this.#pe=t.pointerType,window.addEventListener("pointermove",(t=>{i||(i=!0,this._onStartDragging());const{clientX:e,clientY:s,pointerId:n}=t;if(n!==this.#ue)return void Ht(t);const[r,a]=this.screenToPageTranslation(e-this.#Ee,s-this.#Pe);this.#Ee=e,this.#Pe=s,this._uiManager.dragSelectedEditors(r,a)}),r),window.addEventListener("touchmove",Ht,r),window.addEventListener("pointerdown",(t=>{t.pointerType===this.#pe&&(this.#Me||t.isPrimary)&&a(t),Ht(t)}),r));const o=t=>{this.#ue&&this.#ue!==t.pointerId?Ht(t):a(t)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#Ce&&clearTimeout(this.#Ce),this.#Ce=setTimeout((()=>{this.#Ce=null,this.parent?.moveEditorInDOM(this)}),0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){const s=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/s,h=e/s,d=this.x*n,c=this.y*r,u=this.width*n,p=this.height*r;switch(i){case 0:return[d+l+a,r-c-h-p+o,d+l+u+a,r-c-h+o];case 90:return[d+h+a,r-c+l+o,d+h+p+a,r-c+l+u+o];case 180:return[d-l-u+a,r-c+h+o,d-l+a,r-c+h+p+o];case 270:return[d-h-p+a,r-c-l-u+o,d-h+a,r-c-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,s,n,r]=t,a=n-i,o=r-s;switch(this.rotation){case 0:return[i,e-r,a,o];case 90:return[i,e-s,o,a];case 180:return[n,e-s,a,o];case 270:return[n,e-r,o,a];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){this.#xe=!0}disableEditMode(){this.#xe=!1}isInEditMode(){return this.#xe}shouldGetKeyboardEvents(){return this.#Se}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&s>0&&t<n&&i>0}#He(){if(this.#ve||!this.div)return;this.#ve=new AbortController;const t=this._uiManager.combinedSignal(this.#ve);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#He()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){ot("An editor must be serializable")}static async deserialize(t,e,i){const s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i});s.rotation=t.rotation,s.#he=t.accessibilityData;const[n,r]=s.pageDimensions,[a,o,l,h]=s.getRectInCurrentCoords(t.rect,r);return s.x=a/n,s.y=o/r,s.width=l/n,s.height=h/r,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#ve?.abort(),this.#ve=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#Ce&&(clearTimeout(this.#Ce),this.#Ce=null),this.#ke(),this.removeEditToolbar(),this.#Te){for(const t of this.#Te.values())clearTimeout(t);this.#Te=null}this.parent=null,this.#Me?.destroy(),this.#Me=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#Fe(),this.#fe.classList.remove("hidden"),Qt(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#be={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#fe.children;if(!this.#de){this.#de=Array.from(e);const t=this.#qe.bind(this),i=this.#Xe.bind(this),s=this._uiManager._signal;for(const e of this.#de){const n=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#Ke.bind(this,n),{signal:s}),e.setAttribute("data-l10n-id",ae._l10nResizer[n])}}const i=this.#de[0];let s=0;for(const t of e){if(t===i)break;s++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#de.length/4);if(n!==s){if(n<s)for(let t=0;t<s-n;t++)this.#fe.append(this.#fe.firstChild);else if(n>s)for(let t=0;t<n-s;t++)this.#fe.firstChild.before(this.#fe.lastChild);let t=0;for(const i of e){const e=this.#de[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",ae._l10nResizer[e])}}this.#Ye(0),this.#Se=!0,this.#fe.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#qe(t){ae._resizerKeyboardManager.exec(this,t)}#Xe(t){this.#Se&&t.relatedTarget?.parentNode!==this.#fe&&this.#ke()}#Ke(t){this.#we=this.#Se?t:""}#Ye(t){if(this.#de)for(const e of this.#de)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#Se&&this.#Be(this.#we,{deltaX:t,deltaY:e,fromKeyboard:!0})}#ke(){this.#Se=!1,this.#Ye(-1),this.#je()}_stopResizingWithKeyboard(){this.#ke(),this.div.focus()}select(){this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#o?.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()}))}unselect(){this.#fe?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#o?.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#_e}set isEditing(t){this.#_e=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#ge=!0;const i=t/e,{style:s}=this.div;s.aspectRatio=i,s.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#Te||=new Map;const{action:e}=t;let i=this.#Te.get(e);return i&&clearTimeout(i),i=setTimeout((()=>{this._reportTelemetry(t),this.#Te.delete(e),0===this.#Te.size&&(this.#Te=null)}),ae._telemetryTimeout),void this.#Te.set(e,i)}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#ce=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#ce=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===e?.nodeName&&e.classList.contains("annotationContent")&&e.remove()}}class oe extends ae{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const le=3285377520,he=4294901760,de=65535;class ce{constructor(t){this.h1=t?4294967295&t:le,this.h2=t?4294967295&t:le}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,n=t.length;s<n;s++){const n=t.charCodeAt(s);n<=255?e[i++]=n:(e[i++]=n>>>8,e[i++]=255&n)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),i=e.byteLength}const s=i>>2,n=i-4*s,r=new Uint32Array(e.buffer,0,s);let a=0,o=0,l=this.h1,h=this.h2;const d=3432918353,c=461845907,u=11601,p=13715;for(let t=0;t<s;t++)1&t?(a=r[t],a=a*d&he|a*u&de,a=a<<15|a>>>17,a=a*c&he|a*p&de,l^=a,l=l<<13|l>>>19,l=5*l+3864292196):(o=r[t],o=o*d&he|o*u&de,o=o<<15|o>>>17,o=o*c&he|o*p&de,h^=o,h=h<<13|h>>>19,h=5*h+3864292196);switch(a=0,n){case 3:a^=e[4*s+2]<<16;case 2:a^=e[4*s+1]<<8;case 1:a^=e[4*s],a=a*d&he|a*u&de,a=a<<15|a>>>17,a=a*c&he|a*p&de,1&s?l^=a:h^=a}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&he|36045*t&de,e=4283543511*e&he|(2950163797*(e<<16|t>>>16)&he)>>>16,t^=e>>>1,t=444984403*t&he|60499*t&de,e=3301882366*e&he|(3120437893*(e<<16|t>>>16)&he)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const ue=Object.freeze({map:null,hash:"",transfer:void 0});class pe{#Qe=!1;#Je=null;#Ze=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=this.#Ze.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#Ze.get(t)}remove(t){if(this.#Ze.delete(t),0===this.#Ze.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of this.#Ze.values())if(t instanceof ae)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=this.#Ze.get(t);let s=!1;if(void 0!==i)for(const[t,n]of Object.entries(e))i[t]!==n&&(s=!0,i[t]=n);else s=!0,this.#Ze.set(t,e);s&&this.#ti(),e instanceof ae&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#Ze.has(t)}getAll(){return this.#Ze.size>0?At(this.#Ze):null}setAll(t){for(const[e,i]of Object.entries(t))this.setValue(e,i)}get size(){return this.#Ze.size}#ti(){this.#Qe||(this.#Qe=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#Qe&&(this.#Qe=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new ge(this)}get serializable(){if(0===this.#Ze.size)return ue;const t=new Map,e=new ce,i=[],s=Object.create(null);let n=!1;for(const[i,r]of this.#Ze){const a=r instanceof ae?r.serialize(!1,s):r;a&&(t.set(i,a),e.update(`${i}:${JSON.stringify(a)}`),n||=!!a.bitmap)}if(n)for(const e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:ue}get editorStats(){let t=null;const e=new Map;for(const i of this.#Ze.values()){if(!(i instanceof ae))continue;const s=i.telemetryFinalData;if(!s)continue;const{type:n}=s;e.has(n)||e.set(n,Object.getPrototypeOf(i).constructor),t||=Object.create(null);const r=t[n]||=new Map;for(const[t,e]of Object.entries(s)){if("type"===t)continue;let i=r.get(t);i||(i=new Map,r.set(t,i));const s=i.get(e)??0;i.set(e,s+1)}}for(const[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#Je=null}get modifiedIds(){if(this.#Je)return this.#Je;const t=[];for(const e of this.#Ze.values())e instanceof ae&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return this.#Je={ids:new Set(t),hash:t.join(",")}}}class ge extends pe{#ei;constructor(t){super();const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);this.#ei={map:n,hash:i,transfer:s}}get print(){ot("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ei}get modifiedIds(){return dt(this,"modifiedIds",{ids:new Set,hash:""})}}class fe{#ii=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#ii.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(t&&!this.#ii.has(t.loadedName))if(lt(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:s,style:n}=t,r=new FontFace(i,s,n);this.addNativeFontFace(r);try{await r.load(),this.#ii.add(i),e?.(t)}catch{at(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}}else ot("Not implemented: loadSystemFont without the Font Loading API.")}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void await this.loadSystemFont(t);if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw at(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise((e=>{const i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)}))}}get isFontLoadingAPISupported(){return dt(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let t=!1;return(o||"undefined"!=typeof navigator&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),dt(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){const{loadingRequests:e}=this,i={done:!1,complete:function(){for(lt(!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 dt(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function i(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function s(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let n,r;const a=this._document.createElement("canvas");a.width=1,a.height=1;const o=a.getContext("2d");let l=0;const h=`lt${Date.now()}${this.loadTestFontId++}`;let d=this._loadTestFont;d=s(d,976,h.length,h);const c=1482184792;let u=i(d,16);for(n=0,r=h.length-3;n<r;n+=4)u=u-c+i(h,n)|0;var p;n<h.length&&(u=u-c+i(h+"XXX",n)|0),d=s(d,16,4,(p=u,String.fromCharCode(p>>24&255,p>>16&255,p>>8&255,255&p)));const g=`@font-face {font-family:"${h}";src:${`url(data:font/opentype;base64,${btoa(d)});`}}`;this.insertRule(g);const f=this._document.createElement("div");f.style.visibility="hidden",f.style.width=f.style.height="10px",f.style.position="absolute",f.style.top=f.style.left="0px";for(const e of[t.loadedName,h]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,f.append(t)}this._document.body.append(f),function t(e,i){if(++l>30)return at("Load test font never loaded."),void i();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?i():setTimeout(t.bind(null,e,i))}(h,(()=>{f.remove(),e.complete()}))}}class me{constructor(t,{disableFontFace:e=!1,fontExtraProperties:i=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const e in t)this[e]=t[e];this.disableFontFace=!0===e,this.fontExtraProperties=!0===i,this._inspectFont=s}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${e=this.data,Uint8Array.prototype.toBase64?e.toBase64():btoa(wt(e))});`;var e;let i;if(this.cssFontInfo){let e=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(e+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),i=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${e}src:${t}}`}else i=`@font-face {font-family:"${this.loadedName}";src:${t}}`;return this._inspectFont?.(this,t),i}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];const i=this.loadedName+"_path_"+e;let s;try{s=t.get(i)}catch(t){at(`getPathGenerator - ignoring character: "${t}".`)}const n=new Path2D(s||"");return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=n}}const be=1,ve=2,we=1,ye=2,Ae=3,_e=4,xe=5,Se=6,Ce=7,Ee=8;function Pe(){}function Te(t){if(t instanceof vt||t instanceof gt||t instanceof ft||t instanceof ut||t instanceof mt||t instanceof pt)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||ot('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new vt(t.message);case"InvalidPDFException":return new gt(t.message);case"MissingPDFException":return new ft(t.message);case"PasswordException":return new ut(t.message,t.code);case"UnexpectedResponseException":return new mt(t.message,t.status);case"UnknownErrorException":return new pt(t.message,t.details)}return new pt(t.message,t.toString())}class Me{#si=new AbortController;constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),i.addEventListener("message",this.#ni.bind(this),{signal:this.#si.signal})}#ni({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#ri(t);if(t.callback){const e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],t.callback===be)i.resolve(t.data);else{if(t.callback!==ve)throw new Error("Unexpected callback case");i.reject(Te(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:be,callbackId:t.callbackId,data:e})}),(function(e){n.postMessage({sourceName:i,targetName:s,callback:ve,callbackId:t.callbackId,reason:Te(e)})}))}else t.streamId?this.#ai(t):e(t.data)}on(t,e){const i=this.actionHandler;if(i[t])throw new Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){const s=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[s]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(t){n.reject(t)}return n.promise}sendWithStream(t,e,i,s){const n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{const l=Promise.withResolvers();return this.streamControllers[n]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:i.desiredSize},s),l.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[n].pullCall=e,o.postMessage({sourceName:r,targetName:a,stream:Se,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{lt(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[n].cancelCall=e,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:we,streamId:n,reason:Te(t)}),e.promise}},i)}#ai(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(t,r=1,a){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=r,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:i,targetName:s,stream:_e,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Ae,streamId:e}),delete r.streamSinks[e])},error(t){lt(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:xe,streamId:e,reason:Te(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(a,t.data,o).then((function(){n.postMessage({sourceName:i,targetName:s,stream:Ee,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Ee,streamId:e,reason:Te(t)})}))}#ri(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case Ee:t.success?r.startCall.resolve():r.startCall.reject(Te(t.reason));break;case Ce:t.success?r.pullCall.resolve():r.pullCall.reject(Te(t.reason));break;case Se:if(!a){n.postMessage({sourceName:i,targetName:s,stream:Ce,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||Pe).then((function(){n.postMessage({sourceName:i,targetName:s,stream:Ce,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Ce,streamId:e,reason:Te(t)})}));break;case _e:if(lt(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case Ae:if(lt(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#oi(r,e);break;case xe:lt(r,"error should have stream controller"),r.controller.error(Te(t.reason)),this.#oi(r,e);break;case ye:t.success?r.cancelCall.resolve():r.cancelCall.reject(Te(t.reason)),this.#oi(r,e);break;case we:if(!a)break;const o=Te(t.reason);Promise.try(a.onCancel||Pe,o).then((function(){n.postMessage({sourceName:i,targetName:s,stream:ye,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:ye,streamId:e,reason:Te(t)})})),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#oi(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#si?.abort(),this.#si=null}}class Ie{#li=!1;constructor({enableHWA:t=!1}){this.#li=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#li})}}reset(t,e,i){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){ot("Abstract method `_createCanvas` called.")}}class Le{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){ot("Abstract method `_fetch` called.")}}class ke extends Le{async _fetch(t){const e=await Lt(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):yt(e)}}class De{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 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){ot("Abstract method `_fetch` called.")}}class Ne extends Re{async _fetch(t){const e=await Lt(t,"arraybuffer");return new Uint8Array(e)}}async function Fe(t){const e=process.getBuiltinModule("fs"),i=await e.promises.readFile(t);return new Uint8Array(i)}o&&at("Please use the `legacy` build in Node.js environments.");const Oe="Fill",Be="Stroke",je="Shading";function Ve(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 He{getPattern(){ot("Abstract method `getPattern` called.")}}class ze extends He{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===Be||s===Oe){const r=e.current.getClippedPathBoundingBox(s,Wt(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,l=e.cachedCanvases.getCanvas("pattern",a,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-r[0],-r[1]),i=St.transform(i,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),Ve(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 Ve(t,this._bbox),n=this._createGradient(t);return n}}function Ue(t,e,i,s,n,r,a,o){const l=e.coords,h=e.colors,d=t.data,c=4*t.width;let u;l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=r,r=a,a=u),l[s+1]>l[n+1]&&(u=s,s=n,n=u,u=a,a=o,o=u),l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=r,r=a,a=u);const p=(l[i]+e.offsetX)*e.scaleX,g=(l[i+1]+e.offsetY)*e.scaleY,f=(l[s]+e.offsetX)*e.scaleX,m=(l[s+1]+e.offsetY)*e.scaleY,b=(l[n]+e.offsetX)*e.scaleX,v=(l[n+1]+e.offsetY)*e.scaleY;if(g>=v)return;const w=h[r],y=h[r+1],A=h[r+2],_=h[a],x=h[a+1],S=h[a+2],C=h[o],E=h[o+1],P=h[o+2],T=Math.round(g),M=Math.round(v);let I,L,k,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,L=w-(w-_)*e,k=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,L=_-(_-C)*e,k=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++]=L-(L-N)*e|0,d[n++]=k-(k-F)*e|0,d[n++]=D-(D-O)*e|0,d[n++]=255}}function $e(t,e,i){const s=e.coords,n=e.colors;let r,a;switch(e.type){case"lattice":const o=e.verticesPerRow,l=Math.floor(s.length/o)-1,h=o-1;for(r=0;r<l;r++){let e=r*o;for(let r=0;r<h;r++,e++)Ue(t,i,s[e],s[e+1],s[e+o],n[e],n[e+1],n[e+o]),Ue(t,i,s[e+o+1],s[e+1],s[e+o],n[e+o+1],n[e+1],n[e+o])}break;case"triangles":for(r=0,a=s.length;r<a;r+=3)Ue(t,i,s[r],s[r+1],s[r+2],n[r],n[r+1],n[r+2]);break;default:throw new Error("illegal figure")}}class We extends He{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,i){const s=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-s,a=Math.ceil(this._bounds[3])-n,o=Math.min(Math.ceil(Math.abs(r*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(a*t[1]*1.1)),3e3),h=r/o,d=a/l,c={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-n,scaleX:1/h,scaleY:1/d},u=o+4,p=l+4,g=i.getCanvas("mesh",u,p),f=g.context,m=f.createImageData(o,l);if(e){const t=m.data;for(let i=0,s=t.length;i<s;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}for(const t of this._figures)$e(m,t,c);f.putImageData(m,2,2);return{canvas:g.canvas,offsetX:s-2*h,offsetY:n-2*d,scaleX:h,scaleY:d}}getPattern(t,e,i,s){let n;if(Ve(t,this._bbox),s===je)n=St.singularValueDecompose2dScale(Wt(t));else if(n=St.singularValueDecompose2dScale(e.baseTransform),this.matrix){const t=St.singularValueDecompose2dScale(this.matrix);n=[n[0]*t[0],n[1]*t[1]]}const r=this._createMeshCanvas(n,s===je?null:this._background,e.cachedCanvases);return s!==je&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class Ge extends He{getPattern(){return"hotpink"}}const qe=1,Xe=2;class Ke{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s,n){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=i,this.canvasGraphicsFactory=s,this.baseTransform=n}createPatternCanvas(t){const{bbox:e,operatorList:i,paintType:s,tilingType:n,color:r,canvasGraphicsFactory:a}=this;let{xstep:o,ystep:l}=this;o=Math.abs(o),l=Math.abs(l),rt("TilingType: "+n);const h=e[0],d=e[1],c=e[2],u=e[3],p=c-h,g=u-d,f=St.singularValueDecompose2dScale(this.matrix),m=St.singularValueDecompose2dScale(this.baseTransform),b=f[0]*m[0],v=f[1]*m[1];let w=p,y=g,A=!1,_=!1;const x=Math.ceil(o*b),S=Math.ceil(l*v);x>=Math.ceil(p*b)?w=o:A=!0,S>=Math.ceil(g*v)?y=l:_=!0;const C=this.getSizeAndScale(w,this.ctx.canvas.width,b),E=this.getSizeAndScale(y,this.ctx.canvas.height,v),P=t.cachedCanvases.getCanvas("pattern",C.size,E.size),T=P.context,M=a.createCanvasGraphics(T);if(M.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(M,s,r),T.translate(-C.scale*h,-E.scale*d),M.transform(C.scale,0,0,E.scale,0,0),T.save(),this.clipBbox(M,h,d,c,u),M.baseTransform=Wt(M.ctx),M.executeOperatorList(i),M.endDrawing(),T.restore(),A||_){const e=P.canvas;A&&(w=o),_&&(y=l);const i=this.getSizeAndScale(w,this.ctx.canvas.width,b),s=this.getSizeAndScale(y,this.ctx.canvas.height,v),n=i.size,r=s.size,a=t.cachedCanvases.getCanvas("pattern-workaround",n,r),c=a.context,u=A?Math.floor(p/o):0,f=_?Math.floor(g/l):0;for(let t=0;t<=u;t++)for(let i=0;i<=f;i++)c.drawImage(e,n*t,r*i,n,r,0,0,n,r);return{canvas:a.canvas,scaleX:i.scale,scaleY:s.scale,offsetX:h,offsetY:d}}return{canvas:P.canvas,scaleX:C.scale,scaleY:E.scale,offsetX:h,offsetY:d}}getSizeAndScale(t,e,i){const s=Math.max(Ke.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*i);return n>=s?n=s:i=n/t,{scale:i,size:n}}clipBbox(t,e,i,s,n){const r=s-e,a=n-i;t.ctx.rect(e,i,r,a),t.current.updateRectMinMax(Wt(t.ctx),[e,i,s,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const s=t.ctx,n=t.current;switch(e){case qe:const t=this.ctx;s.fillStyle=t.fillStyle,s.strokeStyle=t.strokeStyle,n.fillColor=t.fillStyle,n.strokeColor=t.strokeStyle;break;case Xe:const r=St.makeHexColor(i[0],i[1],i[2]);s.fillStyle=r,s.strokeStyle=r,n.fillColor=r,n.strokeColor=r;break;default:throw new bt(`Unsupported paint type: ${e}`)}}getPattern(t,e,i,s){let n=i;s!==je&&(n=St.transform(n,e.baseTransform),this.matrix&&(n=St.transform(n,this.matrix)));const r=this.createPatternCanvas(e);let a=new DOMMatrix(n);a=a.translate(r.offsetX,r.offsetY),a=a.scale(1/r.scaleX,1/r.scaleY);const o=t.createPattern(r.canvas,"repeat");return o.setTransform(a),o}}function Ye({src:t,srcPos:e=0,dest:i,width:s,height:n,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=_t.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],d=s>>3,c=7&s,u=t.length;i=new Uint32Array(i.buffer);let p=0;for(let s=0;s<n;s++){for(const s=e+d;e<s;e++){const s=e<u?t[e]:255;i[p++]=128&s?h:l,i[p++]=64&s?h:l,i[p++]=32&s?h:l,i[p++]=16&s?h:l,i[p++]=8&s?h:l,i[p++]=4&s?h:l,i[p++]=2&s?h:l,i[p++]=1&s?h:l}if(0===c)continue;const s=e<u?t[e++]:255;for(let t=0;t<c;t++)i[p++]=s&1<<7-t?h:l}return{srcPos:e,destPos:p}}const Qe=16;class Je{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 Ze(t,e,i,s,n,r,a,o,l,h){const[d,c,u,p,g,f]=Wt(t);if(0===c&&0===u){const m=a*d+g,b=Math.round(m),v=o*p+f,w=Math.round(v),y=(a+l)*d+g,A=Math.abs(Math.round(y)-b)||1,_=(o+h)*p+f,x=Math.abs(Math.round(_)-w)||1;return t.setTransform(Math.sign(d),0,0,Math.sign(p),b,w),t.drawImage(e,i,s,n,r,0,0,A,x),t.setTransform(d,c,u,p,g,f),[A,x]}if(0===d&&0===p){const m=o*u+g,b=Math.round(m),v=a*c+f,w=Math.round(v),y=(o+h)*u+g,A=Math.abs(Math.round(y)-b)||1,_=(a+l)*c+f,x=Math.abs(Math.round(_)-w)||1;return t.setTransform(0,Math.sign(c),Math.sign(u),0,b,w),t.drawImage(e,i,s,n,r,0,0,x,A),t.setTransform(d,c,u,p,g,f),[x,A]}t.drawImage(e,i,s,n,r,a,o,l,h);return[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class ti{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=l,this.textMatrixScale=1,this.fontMatrix=h,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=x,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,i){[e,i]=St.applyTransform([e,i],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,i),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,i)}updateRectMinMax(t,e){const i=St.applyTransform(e,t),s=St.applyTransform(e.slice(2),t),n=St.applyTransform([e[0],e[3]],t),r=St.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,i[0],s[0],n[0],r[0]),this.minY=Math.min(this.minY,i[1],s[1],n[1],r[1]),this.maxX=Math.max(this.maxX,i[0],s[0],n[0],r[0]),this.maxY=Math.max(this.maxY,i[1],s[1],n[1],r[1])}updateScalingPathMinMax(t,e){St.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,i,s,n,r,a,o,l,h){const d=St.bezierBoundingBox(e,i,s,n,r,a,o,l,h);h||this.updateRectMinMax(t,d)}getPathBoundingBox(t=Oe,e=null){const i=[this.minX,this.minY,this.maxX,this.maxY];if(t===Be){e||ot("Stroke bounding box must include transform.");const t=St.singularValueDecompose2dScale(e),s=t[0]*this.lineWidth/2,n=t[1]*this.lineWidth/2;i[0]-=s,i[1]-=n,i[2]+=s,i[3]+=n}return i}updateClipFromPath(){const t=St.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=Oe,e=null){return St.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function ei(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,s=e.width,n=i%Qe,r=(i-n)/Qe,a=0===n?r:r+1,o=t.createImageData(s,Qe);let l,h=0;const d=e.data,c=o.data;let u,p,g,f;if(e.kind===M.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=_t.isLittleEndian?4278190080:255;for(u=0;u<a;u++){for(g=u<r?Qe:n,l=0,p=0;p<g;p++){const t=e-h;let n=0;const r=t>m?s:8*t-7,a=-8&r;let o=0,c=0;for(;n<a;n+=8)c=d[h++],i[l++]=128&c?b:v,i[l++]=64&c?b:v,i[l++]=32&c?b:v,i[l++]=16&c?b:v,i[l++]=8&c?b:v,i[l++]=4&c?b:v,i[l++]=2&c?b:v,i[l++]=1&c?b:v;for(;n<r;n++)0===o&&(c=d[h++],o=128),i[l++]=c&o?b:v,o>>=1}for(;l<f;)i[l++]=0;t.putImageData(o,0,u*Qe)}}else if(e.kind===M.RGBA_32BPP){for(p=0,f=s*Qe*4,u=0;u<r;u++)c.set(d.subarray(h,h+f)),h+=f,t.putImageData(o,0,p),p+=Qe;u<a&&(f=s*n*4,c.set(d.subarray(h,h+f)),t.putImageData(o,0,p))}else{if(e.kind!==M.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=Qe,f=s*g,u=0;u<a;u++){for(u>=r&&(g=n,f=s*g),l=0,p=f;p--;)c[l++]=d[h++],c[l++]=d[h++],c[l++]=d[h++],c[l++]=255;t.putImageData(o,0,u*Qe)}}}function ii(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,s=e.width,n=i%Qe,r=(i-n)/Qe,a=0===n?r:r+1,o=t.createImageData(s,Qe);let l=0;const h=e.data,d=o.data;for(let e=0;e<a;e++){const i=e<r?Qe:n;({srcPos:l}=Ye({src:h,srcPos:l,dest:d,width:s,height:i,nonBlackColor:0})),t.putImageData(o,0,e*Qe)}}function si(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 ni(t){if(t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0),!o){const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}}function ri(t,e){if(e)return!0;const i=St.singularValueDecompose2dScale(t);i[0]=Math.fround(i[0]),i[1]=Math.fround(i[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*It.PDF_TO_CSS_UNITS);return i[0]<=s&&i[1]<=s}const ai=["butt","round","square"],oi=["miter","round","bevel"],li={},hi={};class di{constructor(t,e,i,s,n,{optionalContentConfig:r,markedContentStack:a=null},o,l){this.ctx=t,this.current=new ti(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=n,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=r,this.cachedCanvases=new Je(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,i){const t=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...Wt(this.compositeCtx))}this.ctx.save(),ni(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=Wt(this.ctx)}executeOperatorList(t,e,i,s){const n=t.argsArray,r=t.fnArray;let a=e||0;const o=n.length;if(o===a)return a;const l=o-a>10&&"function"==typeof i,h=l?Date.now()+15:0;let d=0;const c=this.commonObjs,u=this.objs;let p;for(;;){if(void 0!==s&&a===s.nextBreakPoint)return s.breakIt(a,i),a;if(p=r[a],p!==tt.dependency)this[p].apply(this,n[a]);else for(const t of n[a]){const e=t.startsWith("g_")?c:u;if(!e.has(t))return e.get(t,i),a}if(a++,a===o)return a;if(l&&++d>10){if(Date.now()>h)return i(),a;d=0}}}#hi(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#hi(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#di()}#di(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const i=t.width??t.displayWidth,s=t.height??t.displayHeight;let n,r,a=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=i,h=s,d="prescale1";for(;a>2&&l>1||o>2&&h>1;){let e=l,i=h;a>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),a/=l/e),o>2&&h>1&&(i=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/i),n=this.cachedCanvases.getCanvas(d,e,i),r=n.context,r.clearRect(0,0,e,i),r.drawImage(t,0,0,l,h,0,0,e,i),t=n.canvas,l=e,h=i,d="prescale1"===d?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t){const e=this.ctx,{width:i,height:s}=t,n=this.current.fillColor,r=this.current.patternFill,a=Wt(e);let o,l,h,d;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;l=JSON.stringify(r?a:[a.slice(0,4),n]),o=this._cachedBitmapsMap.get(e),o||(o=new Map,this._cachedBitmapsMap.set(e,o));const i=o.get(l);if(i&&!r){return{canvas:i,offsetX:Math.round(Math.min(a[0],a[2])+a[4]),offsetY:Math.round(Math.min(a[1],a[3])+a[5])}}h=i}h||(d=this.cachedCanvases.getCanvas("maskCanvas",i,s),ii(d.context,t));let c=St.transform(a,[1/i,0,0,-1/s,0,0]);c=St.transform(c,[1,0,0,1,0,-s]);const[u,p,g,f]=St.getAxialAlignedBoundingBox([0,0,i,s],c),m=Math.round(g-u)||1,b=Math.round(f-p)||1,v=this.cachedCanvases.getCanvas("fillCanvas",m,b),w=v.context,y=u,A=p;w.translate(-y,-A),w.transform(...c),h||(h=this._scaleImage(d.canvas,Gt(w)),h=h.img,o&&r&&o.set(l,h)),w.imageSmoothingEnabled=ri(Wt(w),t.interpolate),Ze(w,h,0,0,h.width,h.height,0,0,i,s),w.globalCompositeOperation="source-in";const _=St.transform(Gt(w),[1,0,0,1,-y,-A]);return w.fillStyle=r?n.getPattern(e,this,_,Oe):n,w.fillRect(0,0,i,s),o&&!r&&(this.cachedCanvases.delete("fillCanvas"),o.set(l,v.canvas)),{canvas:v.canvas,offsetX:Math.round(y),offsetY:Math.round(A)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=ai[t]}setLineJoin(t){this.ctx.lineJoin=oi[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const i=this.ctx;void 0!==i.setLineDash&&(i.setLineDash(t),i.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,i]of t)switch(e){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i[0],i[1]);break;case"CA":this.current.strokeAlpha=i;break;case"ca":this.current.fillAlpha=i,this.ctx.globalAlpha=i;break;case"BM":this.ctx.globalCompositeOperation=i;break;case"SMask":this.current.activeSMask=i?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(i,t,e);this.suspendedCtx=this.ctx,this.ctx=s.context;const n=this.ctx;n.setTransform(...Wt(this.suspendedCtx)),si(this.suspendedCtx,n),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,i){e.translate(t,i),this.__originalTranslate(t,i)},t.scale=function(t,i){e.scale(t,i),this.__originalScale(t,i)},t.transform=function(t,i,s,n,r,a){e.transform(t,i,s,n,r,a),this.__originalTransform(t,i,s,n,r,a)},t.setTransform=function(t,i,s,n,r,a){e.setTransform(t,i,s,n,r,a),this.__originalSetTransform(t,i,s,n,r,a)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,i){e.moveTo(t,i),this.__originalMoveTo(t,i)},t.lineTo=function(t,i){e.lineTo(t,i),this.__originalLineTo(t,i)},t.bezierCurveTo=function(t,i,s,n,r,a){e.bezierCurveTo(t,i,s,n,r,a),this.__originalBezierCurveTo(t,i,s,n,r,a)},t.rect=function(t,i,s,n){e.rect(t,i,s,n),this.__originalRect(t,i,s,n)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(n,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),si(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,i,s){const n=s[0],r=s[1],a=s[2]-n,o=s[3]-r;0!==a&&0!==o&&(this.genericComposeSMask(e.context,i,a,o,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,s,n,r,a,o,l,h,d){let c=t.canvas,u=o-h,p=l-d;if(r){const e=St.makeHexColor(...r);if(u<0||p<0||u+i>c.width||p+s>c.height){const t=this.cachedCanvases.getCanvas("maskExtension",i,s),n=t.context;n.drawImage(c,-u,-p),n.globalCompositeOperation="destination-atop",n.fillStyle=e,n.fillRect(0,0,i,s),n.globalCompositeOperation="source-over",c=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const n=new Path2D;n.rect(u,p,i,s),t.clip(n),t.globalCompositeOperation="destination-atop",t.fillStyle=e,t.fillRect(u,p,i,s),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===n&&a?e.filter=this.filterFactory.addAlphaFilter(a):"Luminosity"===n&&(e.filter=this.filterFactory.addLuminosityFilter(a));const g=new Path2D;g.rect(o,l,i,s),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(c,u,p,i,s,o,l,i,s),e.restore()}save(){this.inSMaskMode?(si(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),si(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,i,s,n,r){this.ctx.transform(t,e,i,s,n,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i){const s=this.ctx,n=this.current;let r,a,o=n.x,l=n.y;const h=Wt(s),d=0===h[0]&&0===h[3]||0===h[1]&&0===h[2],c=d?i.slice(0):null;for(let i=0,u=0,p=t.length;i<p;i++)switch(0|t[i]){case tt.rectangle:o=e[u++],l=e[u++];const t=e[u++],i=e[u++],p=o+t,g=l+i;s.moveTo(o,l),0===t||0===i?s.lineTo(p,g):(s.lineTo(p,l),s.lineTo(p,g),s.lineTo(o,g)),d||n.updateRectMinMax(h,[o,l,p,g]),s.closePath();break;case tt.moveTo:o=e[u++],l=e[u++],s.moveTo(o,l),d||n.updatePathMinMax(h,o,l);break;case tt.lineTo:o=e[u++],l=e[u++],s.lineTo(o,l),d||n.updatePathMinMax(h,o,l);break;case tt.curveTo:r=o,a=l,o=e[u+4],l=e[u+5],s.bezierCurveTo(e[u],e[u+1],e[u+2],e[u+3],o,l),n.updateCurvePathMinMax(h,r,a,e[u],e[u+1],e[u+2],e[u+3],o,l,c),u+=6;break;case tt.curveTo2:r=o,a=l,s.bezierCurveTo(o,l,e[u],e[u+1],e[u+2],e[u+3]),n.updateCurvePathMinMax(h,r,a,o,l,e[u],e[u+1],e[u+2],e[u+3],c),o=e[u+2],l=e[u+3],u+=4;break;case tt.curveTo3:r=o,a=l,o=e[u+2],l=e[u+3],s.bezierCurveTo(e[u],e[u+1],o,l,o,l),n.updateCurvePathMinMax(h,r,a,e[u],e[u+1],o,l,o,l,c),u+=4;break;case tt.closePath:s.closePath()}d&&n.updateScalingPathMinMax(h,c),n.setCurrentPoint(o,l)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,i=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof i&&i?.getPattern?(e.save(),e.strokeStyle=i.getPattern(e,this,Gt(e),Be),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){const e=this.ctx,i=this.current.fillColor;let s=!1;this.current.patternFill&&(e.save(),e.fillStyle=i.getPattern(e,this,Gt(e),Oe),s=!0);const n=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==n&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),s&&e.restore(),t&&this.consumePath(n)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=li}eoClip(){this.pendingClip=hi}beginText(){this.current.textMatrix=l,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(void 0===t)return void e.beginPath();const i=new Path2D,s=e.getTransform().invertSelf();for(const{transform:e,x:n,y:r,fontSize:a,path:o}of t)i.addPath(o,new DOMMatrix(e).preMultiplySelf(s).translate(n,r).scale(a,-a));e.clip(i),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){const i=this.commonObjs.get(t),s=this.current;if(!i)throw new Error(`Can't find font for ${t}`);if(s.fontMatrix=i.fontMatrix||h,0!==s.fontMatrix[0]&&0!==s.fontMatrix[3]||at("Invalid font matrix for font "+t),e<0?(e=-e,s.fontDirection=-1):s.fontDirection=1,this.current.font=i,this.current.fontSize=e,i.isType3Font)return;const n=i.loadedName||"sans-serif",r=i.systemFontInfo?.css||`"${n}", ${i.fallbackName}`;let a="normal";i.black?a="900":i.bold&&(a="bold");const o=i.italic?"italic":"normal";let l=e;e<16?l=16:e>100&&(l=100),this.current.fontSizeScale=e/l,this.ctx.font=`${o} ${a} ${l}px ${r}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,i,s,n,r){this.current.textMatrix=[t,e,i,s,n,r],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#ci(t,e,i){const s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,n){const r=this.ctx,a=this.current,o=a.font,l=a.textRenderingMode,h=a.fontSize/a.fontSizeScale,d=l&P,c=!!(l&T),u=a.patternFill&&!o.missingFile,p=a.patternStroke&&!o.missingFile;let g;if((o.disableFontFace||c||u||p)&&(g=o.getPathGenerator(this.commonObjs,t)),o.disableFontFace||u||p){if(r.save(),r.translate(e,i),r.scale(h,-h),d===x||d===C)if(s){const t=r.getTransform();r.setTransform(...s),r.fill(this.#ci(g,t,s))}else r.fill(g);if(d===S||d===C)if(n){const t=r.getTransform();r.setTransform(...n),r.stroke(this.#ci(g,t,n))}else r.lineWidth/=h,r.stroke(g);r.restore()}else d!==x&&d!==C||r.fillText(t,e,i),d!==S&&d!==C||r.strokeText(t,e,i);if(c){(this.pendingTextPaths||=[]).push({transform:Wt(r),x:e,y:i,fontSize:h,path:g})}}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let i=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){i=!0;break}return dt(this,"isFontSubpixelAAEnabled",i)}showText(t){const e=this.current,i=e.font;if(i.isType3Font)return this.showType3Text(t);const s=e.fontSize;if(0===s)return;const n=this.ctx,r=e.fontSizeScale,a=e.charSpacing,o=e.wordSpacing,l=e.fontDirection,h=e.textHScale*l,d=t.length,c=i.vertical,u=c?1:-1,p=i.defaultVMetrics,g=s*e.fontMatrix[0],f=e.textRenderingMode===x&&!i.disableFontFace&&!e.patternFill;let m,b;if(n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),l>0?n.scale(h,-1):n.scale(h,1),e.patternFill){n.save();const t=e.fillColor.getPattern(n,this,Gt(n),Oe);m=Wt(n),n.restore(),n.fillStyle=t}if(e.patternStroke){n.save();const t=e.strokeColor.getPattern(n,this,Gt(n),Be);b=Wt(n),n.restore(),n.strokeStyle=t}let v=e.lineWidth;const w=e.textMatrixScale;if(0===w||0===v){const t=e.textRenderingMode&P;t!==S&&t!==C||(v=this.getSinglePixelWidth())}else v/=w;if(1!==r&&(n.scale(r,r),v/=r),n.lineWidth=v,i.isInvalidPDFjsFont){const i=[];let s=0;for(const e of t)i.push(e.unicode),s+=e.width;return n.fillText(i.join(""),0,0),e.x+=s*g*h,n.restore(),void this.compose()}let y,A=0;for(y=0;y<d;++y){const e=t[y];if("number"==typeof e){A+=u*e*s/1e3;continue}let h=!1;const d=(e.isSpace?o:0)+a,v=e.fontChar,w=e.accent;let _,x,S=e.width;if(c){const t=e.vmetric||p,i=-(e.vmetric?t[1]:.5*S)*g,s=t[2]*g;S=t?-t[0]:S,_=i/r,x=(A+s)/r}else _=A/r,x=0;if(i.remeasure&&S>0){const t=1e3*n.measureText(v).width/s*r;if(S<t&&this.isFontSubpixelAAEnabled){const e=S/t;h=!0,n.save(),n.scale(e,1),_/=e}else S!==t&&(_+=(S-t)/2e3*s/r)}if(this.contentVisible&&(e.isInFont||i.missingFile))if(f&&!w)n.fillText(v,_,x);else if(this.paintChar(v,_,x,m,b),w){const t=_+s*w.offset.x/r,e=x-s*w.offset.y/r;this.paintChar(w.fontChar,t,e,m,b)}A+=c?S*g-d*l:S*g+d*l,h&&n.restore()}c?e.y-=A:e.x+=A*h,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,i=this.current,s=i.font,n=i.fontSize,r=i.fontDirection,a=s.vertical?1:-1,o=i.charSpacing,l=i.wordSpacing,d=i.textHScale*r,c=i.fontMatrix||h,u=t.length;let p,g,f,m;if(!(i.textRenderingMode===E)&&0!==n){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...i.textMatrix),e.translate(i.x,i.y),e.scale(d,r),p=0;p<u;++p){if(g=t[p],"number"==typeof g){m=a*g*n/1e3,this.ctx.translate(m,0),i.x+=m*d;continue}const r=(g.isSpace?l:0)+o,h=s.charProcOperatorList[g.operatorListId];if(!h){at(`Type3 character "${g.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=g,this.save(),e.scale(n,n),e.transform(...c),this.executeOperatorList(h),this.restore());f=St.applyTransform([g.width,0],c)[0]*n+r,e.translate(f,0),i.x+=f*d}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,i,s,n,r){this.ctx.rect(i,s,n-i,r-s),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){const i=t[1],s=this.baseTransform||Wt(this.ctx),n={createCanvasGraphics:t=>new di(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Ke(t,i,this.ctx,n,s)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,i){this.ctx.strokeStyle=this.current.strokeColor=St.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=St.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 ze(t);case"Mesh":return new We(t);case"Dummy":return new Ge}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,Gt(e),je);const s=Gt(e);if(s){const{width:t,height:i}=e.canvas,[n,r,a,o]=St.getAxialAlignedBoundingBox([0,0,t,i],s);this.ctx.fillRect(n,r,a-n,o-r)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){ot("Should not call beginInlineImage")}beginImageData(){ot("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Wt(this.ctx),e)){const t=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],t,i),this.current.updateRectMinMax(Wt(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||rt("TODO: Support non-isolated groups."),t.knockout&&at("Knockout groups not supported.");const i=Wt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let s=St.getAxialAlignedBoundingBox(t.bbox,Wt(e));const n=[0,0,e.canvas.width,e.canvas.height];s=St.intersect(s,n)||[0,0,0,0];const r=Math.floor(s[0]),a=Math.floor(s[1]),o=Math.max(Math.ceil(s[2])-r,1),l=Math.max(Math.ceil(s[3])-a,1);this.current.startNewPathAndClipBox([0,0,o,l]);let h="groupAt"+this.groupLevel;t.smask&&(h+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(h,o,l),c=d.context;c.translate(-r,-a),c.transform(...i),t.smask?this.smaskStack.push({canvas:d.canvas,context:c,offsetX:r,offsetY:a,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(r,a),e.save()),si(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=Wt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const i=St.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(t,e,i,s,n){if(this.#hi(),ni(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const s=e[2]-e[0],r=e[3]-e[1];if(n&&this.annotationCanvasMap){(i=i.slice())[4]-=e[0],i[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=s,e[3]=r;const[n,a]=St.singularValueDecompose2dScale(Wt(this.ctx)),{viewportScale:o}=this,l=Math.ceil(s*this.outputScaleX*o),h=Math.ceil(r*this.outputScaleY*o);this.annotationCanvas=this.canvasFactory.create(l,h);const{canvas:d,context:c}=this.annotationCanvas;this.annotationCanvasMap.set(t,d),this.annotationCanvas.savedCtx=this.ctx,this.ctx=c,this.ctx.save(),this.ctx.setTransform(n,0,0,-a,0,r*a),ni(this.ctx)}else ni(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],s,r),this.ctx.clip(),this.ctx.beginPath()}this.current=new ti(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#di(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;(t=this.getObject(t.data,t)).count=e;const i=this.ctx,s=this.processingType3;if(s&&(void 0===s.compiled&&(s.compiled=function(t){const{width:e,height:i}=t;if(e>1e3||i>1e3)return null;const s=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=e+1;let r,a,o,l=new Uint8Array(n*(i+1));const h=e+7&-8;let d=new Uint8Array(h*i),c=0;for(const e of t.data){let t=128;for(;t>0;)d[c++]=e&t?0:255,t>>=1}let u=0;for(c=0,0!==d[c]&&(l[0]=1,++u),a=1;a<e;a++)d[c]!==d[c+1]&&(l[a]=d[c]?2:1,++u),c++;for(0!==d[c]&&(l[a]=2,++u),r=1;r<i;r++){c=r*h,o=r*n,d[c-h]!==d[c]&&(l[o]=d[c]?1:8,++u);let t=(d[c]?4:0)+(d[c-h]?8:0);for(a=1;a<e;a++)t=(t>>2)+(d[c+1]?4:0)+(d[c-h+1]?8:0),s[t]&&(l[o+a]=s[t],++u),c++;if(d[c-h]!==d[c]&&(l[o+a]=d[c]?2:4,++u),u>1e3)return null}for(c=h*(i-1),o=r*n,0!==d[c]&&(l[o]=8,++u),a=1;a<e;a++)d[c]!==d[c+1]&&(l[o+a]=d[c]?4:8,++u),c++;if(0!==d[c]&&(l[o+a]=4,++u),u>1e3)return null;const p=new Int32Array([0,n,-1,0,-n,0,0,0,1]),g=new Path2D;for(r=0;u&&r<=i;r++){let t=r*n;const i=t+e;for(;t<i&&!l[t];)t++;if(t===i)continue;g.moveTo(t%n,r);const s=t;let a=l[t];do{const e=p[a];do{t+=e}while(!l[t]);const i=l[t];5!==i&&10!==i?(a=i,l[t]=0):(a=i&51*a>>4,l[t]&=a>>2|a<<2),g.lineTo(t%n,t/n|0),l[t]||--u}while(s!==t);--r}return d=null,l=null,function(t){t.save(),t.scale(1/e,-1/i),t.translate(0,-i),t.fill(g),t.beginPath(),t.restore()}}(t)),s.compiled))return void s.compiled(i);const n=this._createMaskCanvas(t),r=n.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(r,n.offsetX,n.offsetY),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i=0,s=0,n,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);const a=this.ctx;a.save();const o=Wt(a);a.transform(e,i,s,n,0,0);const l=this._createMaskCanvas(t);a.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(let t=0,h=r.length;t<h;t+=2){const h=St.transform(o,[e,i,s,n,r[t],r[t+1]]),[d,c]=St.applyTransform([0,0],h);a.drawImage(l.canvas,d,c)}a.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,i=this.current.fillColor,s=this.current.patternFill;for(const n of t){const{data:t,width:r,height:a,transform:o}=n,l=this.cachedCanvases.getCanvas("maskCanvas",r,a),h=l.context;h.save();ii(h,this.getObject(t,n)),h.globalCompositeOperation="source-in",h.fillStyle=s?i.getPattern(h,this,Gt(e),Oe):i,h.fillRect(0,0,r,a),h.restore(),e.save(),e.transform(...o),e.scale(1,-1),Ze(e,l.canvas,0,0,r,a,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):at("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s){if(!this.contentVisible)return;const n=this.getObject(t);if(!n)return void at("Dependent image isn't ready yet");const r=n.width,a=n.height,o=[];for(let t=0,n=s.length;t<n;t+=2)o.push({transform:[e,0,0,i,s[t],s[t+1]],x:0,y:0,w:r,h:a});this.paintInlineImageXObjectGroup(n,o)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;const{bitmap:e,width:i,height:s}=t,n=this.cachedCanvases.getCanvas("inlineImage",i,s),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,i=t.height,s=this.ctx;if(this.save(),!o){const{filter:t}=s;"none"!==t&&""!==t&&(s.filter="none")}let n;if(s.scale(1/e,-1/i),t.bitmap)n=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)n=t;else{const s=this.cachedCanvases.getCanvas("inlineImage",e,i).context;ei(s,t),n=this.applyTransferMapsToCanvas(s)}const r=this._scaleImage(n,Gt(s));s.imageSmoothingEnabled=ri(Wt(s),t.interpolate),Ze(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;ei(n,t),s=this.applyTransferMapsToCanvas(n)}for(const t of e)i.save(),i.transform(...t.transform),i.scale(1,-1),Ze(i,s,t.x,t.y,t.w,t.h,0,-1,1,1),i.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const i=this.ctx;this.pendingClip&&(e||(this.pendingClip===hi?i.clip("evenodd"):i.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),i.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Wt(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:i,c:s,d:n}=this.ctx.getTransform();let r,a;if(0===i&&0===s){const i=Math.abs(e),s=Math.abs(n);if(i===s)if(0===t)r=a=1/i;else{const e=i*t;r=a=e<1?1/e:1}else if(0===t)r=1/i,a=1/s;else{const e=i*t,n=s*t;r=e<1?1/e:1,a=n<1?1/n:1}}else{const o=Math.abs(e*n-i*s),l=Math.hypot(e,i),h=Math.hypot(s,n);if(0===t)r=h/o,a=l/o;else{const e=t*o;r=h>e?h/e:1,a=l>e?l/e:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:i}=this.current,[s,n]=this.getScaleForStroking();if(e.lineWidth=i||1,1===s&&1===n)return void e.stroke();const r=e.getLineDash();if(t&&e.save(),e.scale(s,n),r.length>0){const t=Math.max(s,n);e.setLineDash(r.map((e=>e/t))),e.lineDashOffset/=t}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const t in tt)void 0!==di.prototype[t]&&(di.prototype[tt[t]]=di.prototype[t]);let ci=class{static#ui=null;static#pi="";static get workerPort(){return this.#ui}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#ui=t}static get workerSrc(){return this.#pi}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#pi=t}};class ui{#gi;#fi;constructor({parsedData:t,rawData:e}){this.#gi=t,this.#fi=e}getRaw(){return this.#fi}get(t){return this.#gi.get(t)??null}getAll(){return At(this.#gi)}has(t){return this.#gi.has(t)}}const pi=Symbol("INTERNAL");class gi{#mi=!1;#bi=!1;#vi=!1;#wi=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){this.#mi=!!(t&u),this.#bi=!!(t&p),this.name=e,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(this.#vi)return this.#wi;if(!this.#wi)return!1;const{print:t,view:e}=this.usage;return this.#mi?"OFF"!==e?.viewState:!this.#bi||"OFF"!==t?.printState}_setVisible(t,e,i=!1){t!==pi&&ot("Internal method `_setVisible` called."),this.#vi=i,this.#wi=e}}class fi{#yi=null;#Ai=new Map;#_i=null;#xi=null;constructor(t,e=u){if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#xi=t.order;for(const i of t.groups)this.#Ai.set(i.id,new gi(e,i));if("OFF"===t.baseState)for(const t of this.#Ai.values())t._setVisible(pi,!1);for(const e of t.on)this.#Ai.get(e)._setVisible(pi,!0);for(const e of t.off)this.#Ai.get(e)._setVisible(pi,!1);this.#_i=this.getHash()}}#Si(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let s=1;s<e;s++){const e=t[s];let n;if(Array.isArray(e))n=this.#Si(e);else{if(!this.#Ai.has(e))return at(`Optional content group not found: ${e}`),!0;n=this.#Ai.get(e).visible}switch(i){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return"And"===i}isVisible(t){if(0===this.#Ai.size)return!0;if(!t)return rt("Optional content group not defined."),!0;if("OCG"===t.type)return this.#Ai.has(t.id)?this.#Ai.get(t.id).visible:(at(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#Si(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return at(`Optional content group not found: ${e}`),!0;if(this.#Ai.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return at(`Optional content group not found: ${e}`),!0;if(!this.#Ai.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return at(`Optional content group not found: ${e}`),!0;if(!this.#Ai.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return at(`Optional content group not found: ${e}`),!0;if(this.#Ai.get(e).visible)return!1}return!0}return at(`Unknown optional content policy ${t.policy}.`),!0}return at(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){const s=this.#Ai.get(t);if(s){if(i&&e&&s.rbGroups.length)for(const e of s.rbGroups)for(const i of e)i!==t&&this.#Ai.get(i)?._setVisible(pi,!1,!0);s._setVisible(pi,!!e,!0),this.#yi=null}else at(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let i;for(const s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}const t=this.#Ai.get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}this.#yi=null}get hasInitialVisibility(){return null===this.#_i||this.getHash()===this.#_i}getOrder(){return this.#Ai.size?this.#xi?this.#xi.slice():[...this.#Ai.keys()]:null}getGroups(){return this.#Ai.size>0?At(this.#Ai):null}getGroup(t){return this.#Ai.get(t)||null}getHash(){if(null!==this.#yi)return this.#yi;const t=new ce;for(const[e,i]of this.#Ai)t.update(`${e}:${i.visible}`);return this.#yi=t.hexdigest()}}class mi{constructor(t,{disableRange:e=!1,disableStream:i=!1}){lt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:n,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,n?.length>0){const t=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener(((t,e)=>{this._onReceiveData({begin:t,chunk:e})})),t.addProgressListener(((t,e)=>{this._onProgress({loaded:t,total:e})})),t.addProgressiveReadListener((t=>{this._onReceiveData({chunk:t})})),t.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(void 0===t)this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i);else{lt(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(){lt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new bi(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new vi(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 bi{constructor(t,e,i=!1,s=null){this._stream=t,this._done=i||!1,this._filename=Nt(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 vi{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 wi(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 yi(t){try{return new URL(t).origin}catch{}return null}function Ai({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){const n={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(r))return n;if(n.suggestedLength=r,r<=2*i)return n;if(s||!e)return n;if("bytes"!==t.get("Accept-Ranges"))return n;return"identity"!==(t.get("Content-Encoding")||"identity")||(n.allowRangeRequests=!0),n}function _i(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){i=i[1];let t=a(i);return t=unescape(t),t=o(t),t=l(t),r(t)}if(i=function(t){const e=[];let i;const n=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=n.exec(t));){let[,t,s,n]=i;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[s,n]}const r=[];for(let t=0;t<e.length&&t in e;++t){let[i,s]=e[t];s=a(s),i&&(s=unescape(s),0===t&&(s=o(s))),r.push(s)}return r.join("")}(t),i)return r(l(i));if(i=s("filename","i").exec(t),i){i=i[1];let t=a(i);return t=l(t),r(t)}function s(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function n(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const s=new TextDecoder(t,{fatal:!0}),n=yt(i);i=s.decode(n),e=!1}catch{}}return i}function r(t){return e&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),e&&(t=n("iso-8859-1",t))),t}function a(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){const e=t.indexOf("'");return-1===e?t:n(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(t,e,i,s){if("q"===i||"Q"===i)return n(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))})));try{s=atob(s)}catch{}return n(e,s)}))}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(Nt(t))return t}return null}function xi(t,e){return 404===t||0===t&&e.startsWith("file:")?new ft('Missing PDF "'+e+'".'):new mt(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t)}function Si(t){return 200===t||206===t}function Ci(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function Ei(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(at(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class Pi{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=wi(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return lt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Ti(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Mi(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 Ti{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,Ci(i,this._withCredentials,this._abortController)).then((e=>{if(t._responseOrigin=yi(e.url),!Si(e.status))throw xi(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();const i=e.headers,{allowRangeRequests:n,suggestedLength:r}=Ai({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=r||this._contentLength,this._filename=_i(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new vt("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:Ei(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Mi{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;const n=new Headers(t.headers);n.append("Range",`bytes=${e}-${i-1}`);const r=s.url;fetch(r,Ci(n,this._withCredentials,this._abortController)).then((e=>{const i=yi(e.url);if(i!==t._responseOrigin)throw new Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!Si(e.status))throw xi(e.status,r);this._readCapability.resolve(),this._reader=e.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:Ei(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Ii{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=wi(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",lt(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){const i=this.pendingRequests[t];i&&i.onProgress?.(e)}onStateChange(t,e){const i=this.pendingRequests[t];if(!i)return;const s=i.xhr;if(s.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==s.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===s.status&&this.isHttp)return void i.onError(s.status);const n=s.status||200;if(!(200===n&&206===i.expectedStatus)&&n!==i.expectedStatus)return void i.onError(s.status);const r=function(t){const e=t.response;return"string"!=typeof e?e:yt(e).buffer}(s);if(206===n){const t=s.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?i.onDone({begin:parseInt(e[1],10),chunk:r}):(at('Missing or invalid "Content-Range" header.'),i.onError(0))}else r?i.onDone({begin:0,chunk:r}):i.onError(s.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class Li{constructor(t){this._source=t,this._manager=new Ii(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 lt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new ki(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new Di(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 ki{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=yi(e.responseURL);const i=e.getAllResponseHeaders(),s=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((t=>{const[e,...i]=t.split(": ");return[e,i.join(": ")]})):[]),{allowRangeRequests:n,suggestedLength:r}=Ai({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=_i(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=xi(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 Di{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=yi(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??=xi(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 Ri=/^[a-z][a-z0-9\-+.]+:/i;class Ni{constructor(t){this.source=t,this.url=function(t){if(Ri.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),lt("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return lt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Fi(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Oi(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 Fi{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=process.getBuiltinModule("fs");i.promises.lstat(this._url).then((t=>{this._contentLength=t.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()}),(t=>{"ENOENT"===t.code&&(t=new ft(`Missing PDF "${this._url}".`)),this._storedError=t,this._headersCapability.reject(t)}))}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new vt("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Oi{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const s=t.source;this._isStreamingSupported=!s.disableStream;const n=process.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:e,end:i-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),this._storedError&&this._readableStream.destroy(this._storedError)}}const Bi=30;let ji=class t{#Ci=Promise.withResolvers();#pt=null;#Ei=!1;#Pi=!!globalThis.FontInspector?.enabled;#Ti=null;#Mi=null;#Ii=0;#Li=0;#ki=null;#Di=null;#Ri=0;#Ni=0;#Fi=Object.create(null);#Oi=[];#Bi=null;#ji=[];#Vi=new WeakMap;#Hi=null;static#zi=new Map;static#Ui=new Map;static#$i=new WeakMap;static#Wi=null;static#Gi=new Set;constructor({textContentSource:e,container:i,viewport:s}){if(e instanceof ReadableStream)this.#Bi=e;else{if("object"!=typeof e)throw new Error('No "textContentSource" parameter specified.');this.#Bi=new ReadableStream({start(t){t.enqueue(e),t.close()}})}this.#pt=this.#Di=i,this.#Ni=s.scale*(globalThis.devicePixelRatio||1),this.#Ri=s.rotation,this.#Mi={div:null,properties:null,ctx:null};const{pageWidth:n,pageHeight:r,pageX:a,pageY:o}=s.rawDims;this.#Hi=[1,0,0,-1,-a,o+r],this.#Li=n,this.#Ii=r,t.#qi(),qt(i,s),this.#Ci.promise.finally((()=>{t.#Gi.delete(this),this.#Mi=null,this.#Fi=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=_t.platform;return dt(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const e=()=>{this.#ki.read().then((({value:t,done:i})=>{i?this.#Ci.resolve():(this.#Ti??=t.lang,Object.assign(this.#Fi,t.styles),this.#Xi(t.items),e())}),this.#Ci.reject)};return this.#ki=this.#Bi.getReader(),t.#Gi.add(this),e(),this.#Ci.promise}update({viewport:e,onBefore:i=null}){const s=e.scale*(globalThis.devicePixelRatio||1),n=e.rotation;if(n!==this.#Ri&&(i?.(),this.#Ri=n,qt(this.#Di,{rotation:n})),s!==this.#Ni){i?.(),this.#Ni=s;const e={div:null,properties:null,ctx:t.#Ki(this.#Ti)};for(const t of this.#ji)e.properties=this.#Vi.get(t),e.div=t,this.#Yi(e)}}cancel(){const t=new vt("TextLayer task cancelled.");this.#ki?.cancel(t).catch((()=>{})),this.#ki=null,this.#Ci.reject(t)}get textDivs(){return this.#ji}get textContentItemsStr(){return this.#Oi}#Xi(e){if(this.#Ei)return;this.#Mi.ctx??=t.#Ki(this.#Ti);const i=this.#ji,s=this.#Oi;for(const t of e){if(i.length>1e5)return at("Ignoring additional textDivs for performance reasons."),void(this.#Ei=!0);if(void 0!==t.str)s.push(t.str),this.#Qi(t);else if("beginMarkedContentProps"===t.type||"beginMarkedContent"===t.type){const e=this.#pt;this.#pt=document.createElement("span"),this.#pt.classList.add("markedContent"),null!==t.id&&this.#pt.setAttribute("id",`${t.id}`),e.append(this.#pt)}else"endMarkedContent"===t.type&&(this.#pt=this.#pt.parentNode)}}#Qi(e){const i=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,fontSize:0};this.#ji.push(i);const n=St.transform(this.#Hi,e.transform);let r=Math.atan2(n[1],n[0]);const a=this.#Fi[e.fontName];a.vertical&&(r+=Math.PI/2);let o=this.#Pi&&a.fontSubstitution||a.fontFamily;o=t.fontFamilyMap.get(o)||o;const l=Math.hypot(n[2],n[3]),h=l*t.#Ji(o,this.#Ti);let d,c;0===r?(d=n[4],c=n[5]-h):(d=n[4]+h*Math.sin(r),c=n[5]-h*Math.cos(r));const u="calc(var(--scale-factor)*",p=i.style;this.#pt===this.#Di?(p.left=`${(100*d/this.#Li).toFixed(2)}%`,p.top=`${(100*c/this.#Ii).toFixed(2)}%`):(p.left=`${u}${d.toFixed(2)}px)`,p.top=`${u}${c.toFixed(2)}px)`),p.fontSize=`${u}${(t.#Wi*l).toFixed(2)}px)`,p.fontFamily=o,s.fontSize=l,i.setAttribute("role","presentation"),i.textContent=e.str,i.dir=e.dir,this.#Pi&&(i.dataset.fontName=a.fontSubstitutionLoadedName||e.fontName),0!==r&&(s.angle=r*(180/Math.PI));let g=!1;if(e.str.length>1)g=!0;else if(" "!==e.str&&e.transform[0]!==e.transform[3]){const t=Math.abs(e.transform[0]),i=Math.abs(e.transform[3]);t!==i&&Math.max(t,i)/Math.min(t,i)>1.5&&(g=!0)}if(g&&(s.canvasWidth=a.vertical?e.height:e.width),this.#Vi.set(i,s),this.#Mi.div=i,this.#Mi.properties=s,this.#Yi(this.#Mi),s.hasText&&this.#pt.append(i),s.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#pt.append(t)}}#Yi(e){const{div:i,properties:s,ctx:n}=e,{style:r}=i;let a="";if(t.#Wi>1&&(a=`scale(${1/t.#Wi})`),0!==s.canvasWidth&&s.hasText){const{fontFamily:e}=r,{canvasWidth:o,fontSize:l}=s;t.#Zi(n,l*this.#Ni,e);const{width:h}=n.measureText(i.textContent);h>0&&(a=`scaleX(${o*this.#Ni/h}) ${a}`)}0!==s.angle&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(r.transform=a)}static cleanup(){if(!(this.#Gi.size>0)){this.#zi.clear();for(const{canvas:t}of this.#Ui.values())t.remove();this.#Ui.clear()}}static#Ki(t=null){let e=this.#Ui.get(t||="");if(!e){const i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#Ui.set(t,e),this.#$i.set(e,{size:0,family:""})}return e}static#Zi(t,e,i){const s=this.#$i.get(t);e===s.size&&i===s.family||(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static#qi(){if(null!==this.#Wi)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#Wi=t.getBoundingClientRect().height,t.remove()}static#Ji(t,e){const i=this.#zi.get(t);if(i)return i;const s=this.#Ki(e);s.canvas.width=s.canvas.height=Bi,this.#Zi(s,Bi,t);const n=s.measureText("");let r=n.fontBoundingBoxAscent,a=Math.abs(n.fontBoundingBoxDescent);if(r){const e=r/(r+a);return this.#zi.set(t,e),s.canvas.width=s.canvas.height=0,e}s.strokeStyle="red",s.clearRect(0,0,Bi,Bi),s.strokeText("g",0,0);let o=s.getImageData(0,0,Bi,Bi).data;a=0;for(let t=o.length-1-3;t>=0;t-=4)if(o[t]>0){a=Math.ceil(t/4/Bi);break}s.clearRect(0,0,Bi,Bi),s.strokeText("A",0,Bi),o=s.getImageData(0,0,Bi,Bi).data,r=0;for(let t=0,e=o.length;t<e;t+=4)if(o[t]>0){r=Bi-Math.floor(t/4/Bi);break}s.canvas.width=s.canvas.height=0;const l=r?r/(r+a):.8;return this.#zi.set(t,l),l}};class Vi{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(!Vi.shouldBuildText(n))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(const e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}const Hi=65536,zi=o?class extends Ie{_createCanvas(t,i){return process.getBuiltinModule("module").createRequire("undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("index.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(t,i)}}:class extends Ie{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}},Ui=o?class extends Le{async _fetch(t){return Fe(t)}}:ke,$i=o?class extends De{}:class extends De{#ts;#es;#is;#ss;#ns;#rs;#w=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#ss=t,this.#ns=e}get#A(){return this.#es||=new Map}get#as(){return this.#rs||=new Map}get#os(){if(!this.#is){const t=this.#ns.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const i=this.#ns.createElementNS(Mt,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#is=this.#ns.createElementNS(Mt,"defs"),t.append(i),i.append(this.#is),this.#ns.body.append(t)}return this.#is}#ls(t){if(1===t.length){const e=t[0],i=new Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;const s=i.join(",");return[s,s,s]}const[e,i,s]=t,n=new Array(256),r=new Array(256),a=new Array(256);for(let t=0;t<256;t++)n[t]=e[t]/255,r[t]=i[t]/255,a[t]=s[t]/255;return[n.join(","),r.join(","),a.join(",")]}#hs(t){if(void 0===this.#ts){this.#ts="";const t=this.#ns.URL;t!==this.#ns.baseURI&&(Rt(t)?at('#createUrl: ignore "data:"-URL for performance reasons.'):this.#ts=t.split("#",1)[0])}return`url(${this.#ts}#${t})`}addFilter(t){if(!t)return"none";let e=this.#A.get(t);if(e)return e;const[i,s,n]=this.#ls(t),r=1===t.length?i:`${i}${s}${n}`;if(e=this.#A.get(r),e)return this.#A.set(t,e),e;const a=`g_${this.#ss}_transfer_map_${this.#w++}`,o=this.#hs(a);this.#A.set(t,o),this.#A.set(r,o);const l=this.#ds(a);return this.#cs(i,s,n,l),o}addHCMFilter(t,e){const i=`${t}-${e}`,s="base";let n=this.#as.get(s);if(n?.key===i)return n.url;if(n?(n.filter?.remove(),n.key=i,n.url="none",n.filter=null):(n={key:i,url:"none",filter:null},this.#as.set(s,n)),!t||!e)return n.url;const r=this.#us(t);t=St.makeHexColor(...r);const a=this.#us(e);if(e=St.makeHexColor(...a),this.#os.style.color="","#000000"===t&&"#ffffff"===e||t===e)return n.url;const o=new Array(256);for(let t=0;t<=255;t++){const e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const l=o.join(","),h=`g_${this.#ss}_hcm_filter`,d=n.filter=this.#ds(h);this.#cs(l,l,l,d),this.#ps(d);const c=(t,e)=>{const i=r[t]/255,s=a[t]/255,n=new Array(e+1);for(let t=0;t<=e;t++)n[t]=i+t/e*(s-i);return n.join(",")};return this.#cs(c(0,5),c(1,5),c(2,5),d),n.url=this.#hs(h),n.url}addAlphaFilter(t){let e=this.#A.get(t);if(e)return e;const[i]=this.#ls([t]),s=`alpha_${i}`;if(e=this.#A.get(s),e)return this.#A.set(t,e),e;const n=`g_${this.#ss}_alpha_map_${this.#w++}`,r=this.#hs(n);this.#A.set(t,r),this.#A.set(s,r);const a=this.#ds(n);return this.#gs(i,a),r}addLuminosityFilter(t){let e,i,s=this.#A.get(t||"luminosity");if(s)return s;if(t?([e]=this.#ls([t]),i=`luminosity_${e}`):i="luminosity",s=this.#A.get(i),s)return this.#A.set(t,s),s;const n=`g_${this.#ss}_luminosity_map_${this.#w++}`,r=this.#hs(n);this.#A.set(t,r),this.#A.set(i,r);const a=this.#ds(n);return this.#fs(a),t&&this.#gs(e,a),r}addHighlightHCMFilter(t,e,i,s,n){const r=`${e}-${i}-${s}-${n}`;let a=this.#as.get(t);if(a?.key===r)return a.url;if(a?(a.filter?.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},this.#as.set(t,a)),!e||!i)return a.url;const[o,l]=[e,i].map(this.#us.bind(this));let h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[c,u]=[s,n].map(this.#us.bind(this));d<h&&([h,d,c,u]=[d,h,u,c]),this.#os.style.color="";const p=(t,e,i)=>{const s=new Array(256),n=(d-h)/i,r=t/255,a=(e-t)/(255*i);let o=0;for(let t=0;t<=i;t++){const e=Math.round(h+t*n),i=r+t*a;for(let t=o;t<=e;t++)s[t]=i;o=e+1}for(let t=o;t<256;t++)s[t]=s[o-1];return s.join(",")},g=`g_${this.#ss}_hcm_${t}_filter`,f=a.filter=this.#ds(g);return this.#ps(f),this.#cs(p(c[0],u[0],5),p(c[1],u[1],5),p(c[2],u[2],5),f),a.url=this.#hs(g),a.url}destroy(t=!1){t&&this.#rs?.size||(this.#is?.parentNode.parentNode.remove(),this.#is=null,this.#es?.clear(),this.#es=null,this.#rs?.clear(),this.#rs=null,this.#w=0)}#fs(t){const e=this.#ns.createElementNS(Mt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#ps(t){const e=this.#ns.createElementNS(Mt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#ds(t){const e=this.#ns.createElementNS(Mt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#os.append(e),e}#ms(t,e,i){const s=this.#ns.createElementNS(Mt,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#cs(t,e,i,s){const n=this.#ns.createElementNS(Mt,"feComponentTransfer");s.append(n),this.#ms(n,"feFuncR",t),this.#ms(n,"feFuncG",e),this.#ms(n,"feFuncB",i)}#gs(t,e){const i=this.#ns.createElementNS(Mt,"feComponentTransfer");e.append(i),this.#ms(i,"feFuncA",t)}#us(t){return this.#os.style.color=t,$t(getComputedStyle(this.#os).getPropertyValue("color"))}},Wi=o?class extends Re{async _fetch(t){return Fe(t)}}:Ne;function Gi(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new Xi,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;try{return new URL(t,window.location).href}catch{if(o&&"string"==typeof t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(o&&"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 yt(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,r=t.httpHeaders||null,a=!0===t.withCredentials,l=t.password??null,h=t.range instanceof Ki?t.range:null,d=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:Hi;let c=t.worker instanceof Zi?t.worker:null;const u=t.verbosity,p="string"!=typeof t.docBaseUrl||Rt(t.docBaseUrl)?null:t.docBaseUrl,g="string"==typeof t.cMapUrl?t.cMapUrl:null,f=!1!==t.cMapPacked,m=t.CMapReaderFactory||Ui,b="string"==typeof t.standardFontDataUrl?t.standardFontDataUrl:null,v=t.StandardFontDataFactory||Wi,w=!0!==t.stopAtErrors,y=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,A=!1!==t.isEvalSupported,_="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!o,x="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!o&&(_t.platform.isFirefox||!globalThis.chrome),S=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,C="boolean"==typeof t.disableFontFace?t.disableFontFace:o,E=!0===t.fontExtraProperties,P=!0===t.enableXfa,T=t.ownerDocument||globalThis.document,M=!0===t.disableRange,I=!0===t.disableStream,L=!0===t.disableAutoFetch,k=!0===t.pdfBug,D=t.CanvasFactory||zi,R=t.FilterFactory||$i,N=!0===t.enableHWA,F=h?h.length:t.length??NaN,O="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!o&&!C,B="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:m===ke&&v===Ne&&g&&b&&jt(g,document.baseURI)&&jt(b,document.baseURI);st(u);const j={canvasFactory:new D({ownerDocument:T,enableHWA:N}),filterFactory:new R({docId:i,ownerDocument:T}),cMapReaderFactory:B?null:new m({baseUrl:g,isCompressed:f}),standardFontDataFactory:B?null:new v({baseUrl:b})};if(!c){const t={verbosity:u,port:ci.workerPort};c=t.port?Zi.fromPort(t):new Zi(t),e._worker=c}const V={docId:i,apiVersion:"4.10.38",data:n,password:l,disableAutoFetch:L,rangeChunkSize:d,length:F,docBaseUrl:p,enableXfa:P,evaluatorOptions:{maxImageSize:y,disableFontFace:C,ignoreErrors:w,isEvalSupported:A,isOffscreenCanvasSupported:_,isImageDecoderSupported:x,canvasMaxAreaInBytes:S,fontExtraProperties:E,useSystemFonts:O,cMapUrl:B?g:null,standardFontDataUrl:B?b:null}},H={disableFontFace:C,fontExtraProperties:E,ownerDocument:T,pdfBug:k,styleElement:null,loadingParams:{disableAutoFetch:L,enableXfa:P}};return c.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const t=c.messageHandler.sendWithPromise("GetDocRequest",V,n?[n.buffer]:null);let l;if(h)l=new mi(h,{disableRange:M,disableStream:I});else if(!n){if(!s)throw new Error("getDocument - no `url` parameter provided.");let t;if(o)if(jt(s)){if("undefined"==typeof fetch||"undefined"==typeof Response||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");t=Pi}else t=Ni;else t=jt(s)?Pi:Li;l=new t({url:s,length:F,httpHeaders:r,withCredentials:a,rangeChunkSize:d,disableRange:M,disableStream:I})}return t.then((t=>{if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const s=new Me(i,t,c.port),n=new ts(s,e,l,H,j);e._transport=n,s.send("Ready",null)}))})).catch(e._capability.reject),e}function qi(t){return"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0}class Xi{static#ss=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+Xi.#ss++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await(this._transport?.destroy())}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}}let Ki=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){ot("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class Yi{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 dt(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 Qi{#bs=null;#vs=!1;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new Bt:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new is,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new kt({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 dt(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=w.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:a=null,annotationCanvasMap:o=null,pageColors:l=null,printAnnotationStorage:h=null,isEditing:d=!1}){this._stats?.time("Overall");const c=this._transport.getRenderingIntent(i,s,h,d),{renderingIntent:u,cacheKey:g}=c;this.#vs=!1,this.#ws(),a||=this._transport.getOptionalContentConfig(u);let f=this._intentStates.get(g);f||(f=Object.create(null),this._intentStates.set(g,f)),f.streamReaderCancelTimeout&&(clearTimeout(f.streamReaderCancelTimeout),f.streamReaderCancelTimeout=null);const m=!!(u&p);f.displayReadyCapability||(f.displayReadyCapability=Promise.withResolvers(),f.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(c));const b=t=>{f.renderTasks.delete(v),(this._maybeCleanupAfterRender||m)&&(this.#vs=!0),this.#ys(!m),t?(v.capability.reject(t),this._abortOperatorList({intentState:f,reason:t instanceof Error?t:new Error(t)})):v.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},v=new ns({callback:b,params:{canvasContext:t,viewport:e,transform:n,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:f.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!m,pdfBug:this._pdfBug,pageColors:l});(f.renderTasks||=new Set).add(v);const y=v.task;return Promise.all([f.displayReadyCapability.promise,a]).then((([t,e])=>{if(this.destroyed)b();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.");v.initializeGraphics({transparency:t,optionalContentConfig:e}),v.operatorListChanged()}})).catch(b),y}getOperatorList({intent:t="display",annotationMode:e=w.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){const n=this._transport.getRenderingIntent(t,e,i,s,!0);let r,a=this._intentStates.get(n.cacheKey);return a||(a=Object.create(null),this._intentStates.set(n.cacheKey,a)),a.opListReadCapability||(r=Object.create(null),r.operatorListChanged=function(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(r))},a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(r),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then((t=>Vi.textContent(t)));const e=this.streamTextContent(t);return new Promise((function(t,i){const s=e.getReader(),n={items:[],styles:Object.create(null),lang:null};!function e(){s.read().then((function({value:i,done:s}){s?t(n):(n.lang??=i.lang,Object.assign(n.styles,i.styles),n.items.push(...i.items),e())}),i)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#vs=!1,this.#ws(),Promise.all(t)}cleanup(t=!1){this.#vs=!0;const e=this.#ys(!1);return t&&e&&(this._stats&&=new Bt),e}#ys(t=!1){if(this.#ws(),!this.#vs||this.destroyed)return!1;if(t)return this.#bs=setTimeout((()=>{this.#bs=null,this.#ys(!1)}),5e3),!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#vs=!1,!0}#ws(){this.#bs&&(clearTimeout(this.#bs),this.#bs=null)}_startRenderPage(t,e){const i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const t of e.renderTasks)t.operatorListChanged();t.lastChunk&&this.#ys(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){const{map:n,transfer:r}=i,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:s},r).getReader(),o=this._intentStates.get(e);o.streamReader=a;const l=()=>{a.read().then((({value:t,done:e})=>{e?o.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,o),l())}),(t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const t of o.renderTasks)t.operatorListChanged();this.#ys(!0)}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else{if(!o.opListReadCapability)throw t;o.opListReadCapability.reject(t)}}}))};l()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof Dt){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 vt(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 Ji{#As=new Map;#_s=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#_s.then((()=>{for(const[t]of this.#As)t.call(this,i)}))}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){const{signal:n}=i;if(n.aborted)return void at("LoopbackPort - cannot use an `aborted` signal.");const r=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#As.set(e,s)}removeEventListener(t,e){const i=this.#As.get(e);i?.(),this.#As.delete(e)}terminate(){for(const[,t]of this.#As)t?.();this.#As.clear()}}let Zi=class t{static#xs=0;static#Ss=!1;static#Cs;static{o&&(this.#Ss=!0,ci.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let i;try{if(i=new URL(t),!i.origin||"null"===i.origin)return!1}catch{return!1}const s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:e=null,port:i=null,verbosity:s=nt()}={}){if(this.name=e,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,i){if(t.#Cs?.has(i))throw new Error("Cannot use more than one PDFWorker per port.");return(t.#Cs||=new WeakMap).set(i,this),void this._initializeFromPort(i)}this._initialize()}get promise(){return this._readyCapability.promise}#Es(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new Me("main","worker",t),this._messageHandler.on("ready",(function(){})),this.#Es()}_initialize(){if(t.#Ss||t.#Ps)return void this._setupFakeWorker();let{workerSrc:e}=t;try{t._isSameOrigin(window.location.href,e)||(e=t._createCDNWrapper(new URL(e,window.location).href));const i=new Worker(e,{type:"module"}),s=new Me("main","worker",i),n=()=>{r.abort(),s.destroy(),i.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},r=new AbortController;i.addEventListener("error",(()=>{this._webWorker||n()}),{signal:r.signal}),s.on("test",(t=>{r.abort(),!this.destroyed&&t?(this._messageHandler=s,this._port=i,this._webWorker=i,this.#Es()):n()})),s.on("ready",(t=>{if(r.abort(),this.destroyed)n();else try{a()}catch{this._setupFakeWorker()}}));const a=()=>{const t=new Uint8Array;s.send("test",t,[t.buffer])};return void a()}catch{rt("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){t.#Ss||(at("Setting up fake worker."),t.#Ss=!0),t._setupFakeWorkerGlobal.then((e=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const i=new Ji;this._port=i;const s="fake"+t.#xs++,n=new Me(s+"_worker",s,i);e.setup(n,i),this._messageHandler=new Me(s,s+"_worker",i),this.#Es()})).catch((t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,t.#Cs?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(e){if(!e?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const i=this.#Cs?.get(e.port);if(i){if(i._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return i}return new t(e)}static get workerSrc(){if(ci.workerSrc)return ci.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#Ps(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return dt(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#Ps)return this.#Ps;return(await import(this.workerSrc)).WorkerMessageHandler})())}};class ts{#Ts=new Map;#Ms=new Map;#Is=new Map;#Ls=new Map;#ks=null;constructor(t,e,i,s,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new is,this.fontLoader=new fe({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#Ds(t,e=null){const i=this.#Ts.get(t);if(i)return i;const s=this.messageHandler.sendWithPromise(t,e);return this.#Ts.set(t,s),s}get annotationStorage(){return dt(this,"annotationStorage",new pe)}getRenderingIntent(t,e=w.ENABLE,i=null,s=!1,n=!1){let r=u,a=ue;switch(t){case"any":r=c;break;case"display":break;case"print":r=p;break;default:at(`getRenderingIntent - invalid intent: ${t}`)}const o=r&p&&i instanceof ge?i:this.annotationStorage;switch(e){case w.DISABLE:r+=m;break;case w.ENABLE:break;case w.ENABLE_FORMS:r+=g;break;case w.ENABLE_STORAGE:r+=f,a=o.serializable;break;default:at(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(r+=b),n&&(r+=v);const{ids:l,hash:h}=o.modifiedIds;return{renderingIntent:r,cacheKey:[r,a.hash,h].join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#ks?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#Ms.values())t.push(e._destroy());this.#Ms.clear(),this.#Is.clear(),this.#Ls.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.#Ts.clear(),this.filterFactory.destroy(),ji.cleanup(),this._networkStream?.cancelAllRequests(new vt("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)=>{lt(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():(lt(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)=>{lt(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():(lt(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 Yi(t,this))})),t.on("DocException",(t=>{e._capability.reject(Te(t))})),t.on("PasswordRequest",(t=>{this.#ks=Promise.withResolvers();try{if(!e.onPassword)throw Te(t);const i=t=>{t instanceof Error?this.#ks.reject(t):this.#ks.resolve({password:t})};e.onPassword(i,t.code)}catch(t){this.#ks.reject(t)}return this.#ks.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.#Ms.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),t.on("commonobj",(([e,i,s])=>{if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(i){case"Font":const{disableFontFace:n,fontExtraProperties:r,pdfBug:a}=this._params;if("error"in s){const t=s.error;at(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const o=a&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,l=new me(s,{disableFontFace:n,fontExtraProperties:r,inspectFont:o});this.fontLoader.bind(l).catch((()=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!r&&l.data&&(l.data=null),this.commonObjs.resolve(e,l)}));break;case"CopyLocalImage":const{imageRef:h}=s;lt(h,"The imageRef must be defined.");for(const t of this.#Ms.values())for(const[,i]of t.objs)if(i?.ref===h)return i.dataLen?(this.commonObjs.resolve(e,structuredClone(i)),i.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,s);break;default:throw new Error(`Got unknown common object type ${i}`)}return null})),t.on("obj",(([t,e,i,s])=>{if(this.destroyed)return;const n=this.#Ms.get(e);if(!n.objs.has(t))if(0!==n._intentStates.size)switch(i){case"Image":n.objs.resolve(t,s),s?.dataLen>1e7&&(n._maybeCleanupAfterRender=!0);break;case"Pattern":n.objs.resolve(t,s);break;default:throw new Error(`Got unknown object type ${i}`)}else s?.bitmap?.close()})),t.on("DocProgress",(t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})})),t.on("FetchBuiltInCMap",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(t)})),t.on("FetchStandardFontData",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(t)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&at("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally((()=>{this.annotationStorage.resetModified()}))}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,i=this.#Is.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.#Ls.set(i.refStr,t);const s=new Qi(e,i,this,this._params.pdfBug);return this.#Ms.set(e,s),s}));return this.#Is.set(e,s),s}getPageIndex(t){return qi(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#Ds("GetFieldObjects")}hasJSActions(){return this.#Ds("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#Ds("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#Ds("GetOptionalContentConfig").then((e=>new fi(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#Ts.get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new ui(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#Ts.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.#Ms.values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),this.#Ts.clear(),this.filterFactory.destroy(!0),ji.cleanup()}}cachedPageNumber(t){if(!qi(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#Ls.get(e)??null}}const es=Symbol("INITIAL_DATA");class is{#Rs=Object.create(null);#Ns(t){return this.#Rs[t]||={...Promise.withResolvers(),data:es}}get(t,e=null){if(e){const i=this.#Ns(t);return i.promise.then((()=>e(i.data))),null}const i=this.#Rs[t];if(!i||i.data===es)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#Rs[t];return!!e&&e.data!==es}delete(t){const e=this.#Rs[t];return!(!e||e.data===es)&&(delete this.#Rs[t],!0)}resolve(t,e=null){const i=this.#Ns(t);i.data=e,i.resolve()}clear(){for(const t in this.#Rs){const{data:e}=this.#Rs[t];e?.bitmap?.close()}this.#Rs=Object.create(null)}*[Symbol.iterator](){for(const t in this.#Rs){const{data:e}=this.#Rs[t];e!==es&&(yield[t,e])}}}class ss{#Fs=null;constructor(t){this.#Fs=t,this.onContinue=null}get promise(){return this.#Fs.capability.promise}cancel(t=0){this.#Fs.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#Fs.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#Fs;return t.form||t.canvas&&e?.size>0}}class ns{#Os=null;static#Bs=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:c=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=d,this.pageColors=c,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new ss(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(ns.#Bs.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");ns.#Bs.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:i,viewport:s,transform:n,background:r}=this.params;this.gfx=new di(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:s,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#Os&&(window.cancelAnimationFrame(this.#Os),this.#Os=null),ns.#Bs.delete(this._canvas),this.callback(t||new Dt(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#Os=window.requestAnimationFrame((()=>{this.#Os=null,this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),ns.#Bs.delete(this._canvas),this.callback())))}}const rs="4.10.38",as="f9bea397f";function os(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function ls(t){return Math.max(0,Math.min(255,255*t))}class hs{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=ls(t),t,t]}static G_HTML([t]){const e=os(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(ls)}static RGB_HTML(t){return`#${t.map(os).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[ls(1-Math.min(1,t+s)),ls(1-Math.min(1,i+s)),ls(1-Math.min(1,e+s))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const s=1-t,n=1-e,r=1-i;return["CMYK",s,n,r,Math.min(s,n,r)]}}class ds{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){ot("Abstract method `_createSVG` called.")}}let cs=class extends ds{_createSVG(t){return document.createElementNS(Mt,t)}},us=class{static setupStorage(t,e,i,s,n){const r=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==r.value&&(t.textContent=r.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(r.value===i.attributes.xfaOn?t.setAttribute("checked",!0):r.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",(t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})}))}else{if(null!==r.value&&t.setAttribute("value",r.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==r.value){t.setAttribute("value",r.value);for(const t of i.children)t.attributes.value===r.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",(t=>{const i=t.target.options,n=-1===i.selectedIndex?"":i[i.selectedIndex].value;s.setValue(e,{value:n})}))}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;"radio"===r.type&&(r.name=`${r.name}-${s}`);for(const[e,i]of Object.entries(r))if(null!=i)switch(e){case"class":i.length&&t.setAttribute(e,i.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",i);break;case"style":Object.assign(t.style,i);break;case"textContent":t.textContent=i;break;default:(!a||"href"!==e&&"newWindow"!==e)&&t.setAttribute(e,i)}a&&n.addLinkAttributes(t,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(t,r.dataId,e,i)}static render(t){const e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,n=t.intent||"display",r=document.createElement(s.name);s.attributes&&this.setAttributes({html:r,element:s,intent:n,linkService:i});const a="richText"!==n,o=t.div;if(o.append(r),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}a&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(0===s.children.length){if(s.value){const t=document.createTextNode(s.value);r.append(t),a&&Vi.shouldBuildText(s.name)&&l.push(t)}return{textDivs:l}}const h=[[s,-1,r]];for(;h.length>0;){const[t,s,r]=h.at(-1);if(s+1===t.children.length){h.pop();continue}const o=t.children[++h.at(-1)[1]];if(null===o)continue;const{name:d}=o;if("#text"===d){const t=document.createTextNode(o.value);l.push(t),r.append(t);continue}const c=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,d):document.createElement(d);if(r.append(c),o.attributes&&this.setAttributes({html:c,element:o,storage:e,intent:n,linkService:i}),o.children?.length>0)h.push([o,-1,c]);else if(o.value){const t=document.createTextNode(o.value);a&&Vi.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 ps=1e3,gs=new WeakSet;function fs(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class ms{static create(t){switch(t.data.annotationType){case L:return new vs(t);case I:return new ws(t);case q:switch(t.data.fieldType){case"Tx":return new As(t);case"Btn":return t.data.radioButton?new Ss(t):t.data.checkBox?new xs(t):new Cs(t);case"Ch":return new Es(t);case"Sig":return new _s(t)}return new ys(t);case W:return new Ps(t);case k:return new Ms(t);case D:return new Is(t);case R:return new Ls(t);case N:return new ks(t);case O:return new Ds(t);case U:return new Ns(t);case $:return new Fs(t);case F:return new Rs(t);case B:return new Os(t);case j:return new Bs(t);case V:return new js(t);case H:return new Vs(t);case z:return new Hs(t);case G:return new zs(t);default:return new bs(t)}}}class bs{#js=null;#Vs=!1;#Hs=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:i}){return!!(t?.str||e?.str||i?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return bs._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#js||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#zs(e),this.#Hs?.popup.updateEdited(t)}resetEdited(){this.#js&&(this.#zs(this.#js.rect),this.#Hs?.popup.resetEdited(),this.#js=null)}#zs(t){const{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;i?.splice(0,4,...t);const{width:l,height:h}=fs(t);e.left=100*(t[0]-a)/n+"%",e.top=100*(r-t[3]+o)/r+"%",0===s?(e.width=100*l/n+"%",e.height=100*h/r+"%"):this.setRotation(s)}_createContainer(t){const{data:e,parent:{page:i,viewport:s}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof ys||(n.tabIndex=ps);const{style:r}=n;if(r.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Ps){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:a,height:o}=fs(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;if(t>0||i>0){const e=`calc(${t}px * var(--scale-factor)) / calc(${i}px * var(--scale-factor))`;r.borderRadius=e}else if(this instanceof Ss){const t=`calc(${a}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;r.borderRadius=t}switch(e.borderStyle.style){case X:r.borderStyle="solid";break;case K:r.borderStyle="dashed";break;case Y:at("Unimplemented border style: beveled");break;case Q:at("Unimplemented border style: inset");break;case J:r.borderBottomStyle="solid"}const s=e.borderColor||null;s?(this.#Vs=!0,r.borderColor=St.makeHexColor(0|s[0],0|s[1],0|s[2])):r.borderWidth=0}const l=St.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:h,pageHeight:d,pageX:c,pageY:u}=s.rawDims;r.left=100*(l[0]-c)/h+"%",r.top=100*(l[1]-u)/d+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(r.width=100*a/h+"%",r.height=100*o/d+"%"):this.setRotation(p,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims,{width:n,height:r}=fs(this.data.rect);let a,o;t%180==0?(a=100*n/i,o=100*r/s):(a=100*r/i,o=100*n/s),e.style.width=`${a}%`,e.style.height=`${o}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,i)=>{const s=i.detail[t],n=s[0],r=s.slice(1);i.target.style[e]=hs[`${n}_HTML`](r),this.annotationStorage.setValue(this.data.id,{[e]:hs[`${n}_rgb`](r)})};return dt(this,"_commonActions",{display:t=>{const{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const s of Object.keys(e.detail)){const n=t[s]||i[s];n?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[s,n]of Object.entries(e)){const r=i[s];if(r){r({detail:{[s]:n},target:t}),delete e[s]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,s,n]=this.data.rect.map((t=>Math.fround(t)));if(8===t.length){const[r,a,o,l]=t.subarray(2,6);if(s===r&&n===a&&e===o&&i===l)return}const{style:r}=this.container;let a;if(this.#Vs){const{borderColor:t,borderWidth:e}=r;r.borderWidth=0,a=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const o=s-e,l=n-i,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);const c=h.createElement("defs");d.append(c);const u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),c.append(u);for(let i=2,s=t.length;i<s;i+=8){const s=t[i],r=t[i+1],d=t[i+2],c=t[i+3],p=h.createElement("rect"),g=(d-e)/o,f=(n-r)/l,m=(s-d)/o,b=(r-c)/l;p.setAttribute("x",g),p.setAttribute("y",f),p.setAttribute("width",m),p.setAttribute("height",b),u.append(p),a?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${f}" width="${m}" height="${b}"/>`)}this.#Vs&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(){const{data:t}=this,e=this.#Hs=new Ps({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(){ot("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const s=this._fieldObjects[t];if(s)for(const{page:t,id:n,exportValues:r}of s){if(-1===t)continue;if(n===e)continue;const s="string"==typeof r?r:null,a=document.querySelector(`[data-element-id="${n}"]`);!a||gs.has(a)?i.push({id:n,exportValue:s,domElement:a}):at(`_getElementsByName - element not allowed: ${n}`)}return i}for(const s of document.getElementsByName(t)){const{exportValue:t}=s,n=s.getAttribute("data-element-id");n!==e&&(gs.has(s)&&i.push({id:n,exportValue:t,domElement:s}))}return i}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})}))}}class vs extends bs{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action),s=!0):t.attachment?(this.#Us(i,t.attachment,t.attachmentDest),s=!0):t.setOCGState?(this.#$s(i,t.setOCGState),s=!0):t.dest?(this._bindLink(i,t.dest),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&this.container.append(i),this.container}#Ws(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#Ws()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#Ws()}#Us(t,e,i=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,i),!1),this.#Ws()}#$s(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#Ws()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const s of Object.keys(e.actions)){const n=i.get(s);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}t.onclick||(t.onclick=()=>!1),this.#Ws()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#Ws(),!this._fieldObjects)return at('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(i||(t.onclick=()=>!1));t.onclick=()=>{i?.();const{fields:t,refs:s,include:n}=e,r=[];if(0!==t.length||0!==s.length){const e=new Set(s);for(const i of t){const t=this._fieldObjects[i]||[];for(const{id:i}of t)e.add(i)}for(const t of Object.values(this._fieldObjects))for(const i of t)e.has(i.id)===n&&r.push(i)}else for(const t of Object.values(this._fieldObjects))r.push(...t);const a=this.annotationStorage,o=[];for(const t of r){const{id:e}=t;switch(o.push(e),t.type){case"text":{const i=t.defaultValue||"";a.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{const i=t.defaultValue===t.exportValues;a.setValue(e,{value:i});break}case"combobox":case"listbox":{const i=t.defaultValue||"";a.setValue(e,{value:i});break}default:continue}const i=document.querySelector(`[data-element-id="${e}"]`);i&&(gs.has(i)?i.dispatchEvent(new Event("resetform")):at(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class ws extends bs{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 ys extends bs{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return _t.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,n){i.includes("mouse")?t.addEventListener(i,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(i,(t=>{if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t)}})}))}_setEventListeners(t,e,i,s){for(const[n,r]of i)("Action"===r||this.data.actions?.[r])&&("Focus"!==r&&"Blur"!==r||(e||={focused:!1}),this._setEventListener(t,e,n,r,s),"Focus"!==r||this.data.actions?.Blur?"Blur"!==r||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":St.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,n=t.style;let r;const a=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=t/(Math.round(t/(d*s))||1);r=Math.min(s,a(e/d))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(s,a(t/d))}n.fontSize=`calc(${r}px * var(--scale-factor))`,n.color=St.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 As extends ys{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,s){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=i),n.setValue(r.id,{[s]:i})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const s=t.getValue(e,{value:this.data.fieldValue});let n=s.value||"";const r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&n.length>r&&(n=n.slice(0,r));let a=s.formattedValue||this.data.textContent?.join("\n")||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));const o={userValue:n,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=a??n,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type="text",i.setAttribute("value",a??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),gs.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=ps,this._setRequired(i,this.data.required),r&&(i.maxLength=r),i.addEventListener("input",(s=>{t.setValue(e,{value:s.target.value}),this.setPropertyOnSiblings(i,"value",s.target.value,"value"),o.formattedValue=null})),i.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null}));let l=t=>{const{formattedValue:e}=o;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",(t=>{if(o.focused)return;const{target:e}=t;o.userValue&&(e.value=o.userValue),o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)})),i.addEventListener("updatefromsandbox",(i=>{this.showElementAndHideCanvas(i.target);const s={value(i){o.userValue=i.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),i.target.value=o.userValue},formattedValue(i){const{formattedValue:s}=i.detail;o.formattedValue=s,null!=s&&i.target!==document.activeElement&&(i.target.value=s),t.setValue(e,{formattedValue:s})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{const{charLimit:s}=i.detail,{target:n}=i;if(0===s)return void n.removeAttribute("maxLength");n.setAttribute("maxLength",s);let r=o.userValue;!r||r.length<=s||(r=r.slice(0,s),n.value=o.userValue=r,t.setValue(e,{value:r}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,willCommit:!0,commitKey:1,selStart:n.selectionStart,selEnd:n.selectionEnd}}))}};this._dispatchEventFromSandbox(s,i)})),i.addEventListener("keydown",(t=>{o.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):i=2,-1===i)return;const{value:s}=t.target;o.lastCommittedValue!==s&&(o.lastCommittedValue=s,o.userValue=s,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}));const s=l;l=null,i.addEventListener("blur",(t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{value:i}=t.target;o.userValue=i,o.lastCommittedValue!==i&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),s(t)})),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",(t=>{o.lastCommittedValue=null;const{data:i,target:s}=t,{value:n,selectionStart:r,selectionEnd:a}=s;let l=r,h=a;switch(t.inputType){case"deleteWordBackward":{const t=n.substring(0,r).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{const t=n.substring(r).match(/^[^\w]*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":r===a&&(l-=1);break;case"deleteContentForward":r===a&&(h+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,change:i||"",willCommit:!1,selStart:l,selEnd:h}})})),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(l&&i.addEventListener("blur",l),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/r;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--scale-factor) - 1ch)`}}else i=document.createElement("div"),i.textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class _s extends ys{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class xs extends ys{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 gs.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=ps,n.addEventListener("change",(s=>{const{name:n,checked:r}=s.target;for(const s of this._getElementsByName(n,i)){const i=r&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:r})})),n.addEventListener("resetform",(t=>{const i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue})),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",(e=>{const s={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}};this._dispatchEventFromSandbox(s,e)})),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Ss extends ys{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(gs.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=ps,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 Cs extends vs{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 Es extends ys{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");gs.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=ps;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue;for(const t of s.options)t.selected=t.value===e}));for(const t of this.data.options){const e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),n=!1),s.append(e)}let r=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),r=()=>{t.remove(),s.removeEventListener("input",r),r=null},s.addEventListener("input",r)}const a=t=>{const e=t?"value":"textContent",{options:i,multiple:n}=s;return n?Array.prototype.filter.call(i,(t=>t.selected)).map((t=>t[e])):-1===i.selectedIndex?null:i[i.selectedIndex][e]};let o=a(!1);const l=t=>{const e=t.target.options;return Array.prototype.map.call(e,(t=>({displayValue:t.textContent,exportValue:t.value})))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",(i=>{const n={value(i){r?.();const n=i.detail.value,l=new Set(Array.isArray(n)?n:[n]);for(const t of s.options)t.selected=l.has(t.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(t){s.multiple=!0},remove(i){const n=s.options,r=i.detail.remove;if(n[r].selected=!1,s.remove(r),n.length>0){-1===Array.prototype.findIndex.call(n,(t=>t.selected))&&(n[0].selected=!0)}t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(i){const{index:n,displayValue:r,exportValue:h}=i.detail.insert,d=s.children[n],c=document.createElement("option");c.textContent=r,c.value=h,d?d.before(c):s.append(c),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},items(i){const{items:n}=i.detail;for(;0!==s.length;)s.remove(0);for(const t of n){const{displayValue:e,exportValue:i}=t,n=document.createElement("option");n.textContent=e,n.value=i,s.append(n)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},indices(i){const s=new Set(i.detail.indices);for(const t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(n,i)})),s.addEventListener("input",(i=>{const s=a(!0),n=a(!1);t.setValue(e,{value:s}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:n,changeEx:s,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(t=>t.target.value))):s.addEventListener("input",(function(i){t.setValue(e,{value:a(!0)})})),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Ps extends bs{constructor(t){const{data:e,elements:i}=t;super(t,{isRenderable:bs._hasPopupData(e)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Ts({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=>`${Tt}${t}`)).join(",")),this.container}}class Ts{#Gs=this.#qs.bind(this);#Xs=this.#Ks.bind(this);#Ys=this.#Qs.bind(this);#Js=this.#Zs.bind(this);#tn=null;#pt=null;#en=null;#in=null;#sn=null;#nn=null;#rn=null;#an=!1;#on=null;#E=null;#ln=null;#hn=null;#dn=null;#js=null;#cn=!1;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:n,contentsObj:r,richText:a,parent:o,rect:l,parentRect:h,open:d}){this.#pt=t,this.#dn=s,this.#en=r,this.#hn=a,this.#nn=o,this.#tn=e,this.#ln=l,this.#rn=h,this.#sn=i,this.#in=zt.toDateObject(n),this.trigger=i.flatMap((t=>t.getElementsToTriggerPopup()));for(const t of this.trigger)t.addEventListener("click",this.#Js),t.addEventListener("mouseenter",this.#Ys),t.addEventListener("mouseleave",this.#Xs),t.classList.add("popupTriggerArea");for(const t of i)t.container?.addEventListener("keydown",this.#Gs);this.#pt.hidden=!0,d&&this.#Zs()}render(){if(this.#on)return;const t=this.#on=document.createElement("div");if(t.className="popup",this.#tn){const e=t.style.outlineColor=St.makeHexColor(...this.#tn);if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`;else{const e=.7;t.style.backgroundColor=St.makeHexColor(...this.#tn.map((t=>Math.floor(e*(255-t)+t))))}}const e=document.createElement("span");e.className="header";const i=document.createElement("h1");if(e.append(i),({dir:i.dir,str:i.textContent}=this.#dn),t.append(e),this.#in){const t=document.createElement("span");t.classList.add("popupDate"),t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#in.valueOf()})),e.append(t)}const s=this.#un;if(s)us.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(this.#en);t.append(e)}this.#pt.append(t)}get#un(){const t=this.#hn,e=this.#en;return!t?.str||e?.str&&e.str!==t.str?null:this.#hn.html||null}get#pn(){return this.#un?.attributes?.style?.fontSize||0}get#gn(){return this.#un?.attributes?.style?.color||null}#fn(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:this.#gn,fontSize:this.#pn?`calc(${this.#pn}px * var(--scale-factor))`:""}};for(const i of t.split("\n"))e.push({name:"span",value:i,attributes:s});return i}_formatContents({str:t,dir:e}){const i=document.createElement("p");i.classList.add("popupContent"),i.dir=e;const s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t){const n=s[t];i.append(document.createTextNode(n)),t<e-1&&i.append(document.createElement("br"))}return i}#qs(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#an)&&this.#Zs()}updateEdited({rect:t,popupContent:e}){this.#js||={contentsObj:this.#en,richText:this.#hn},t&&(this.#E=null),e&&(this.#hn=this.#fn(e),this.#en=null),this.#on?.remove(),this.#on=null}resetEdited(){this.#js&&(({contentsObj:this.#en,richText:this.#hn}=this.#js),this.#js=null,this.#on?.remove(),this.#on=null,this.#E=null)}#mn(){if(null!==this.#E)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=this.#nn;let r=!!this.#rn,a=r?this.#rn:this.#ln;for(const t of this.#sn)if(!a||null!==St.intersect(t.data.rect,a)){a=t.data.rect,r=!0;break}const o=St.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),l=r?a[2]-a[0]+5:0,h=o[0]+l,d=o[1];this.#E=[100*(h-s)/e,100*(d-n)/i];const{style:c}=this.#pt;c.left=`${this.#E[0]}%`,c.top=`${this.#E[1]}%`}#Zs(){this.#an=!this.#an,this.#an?(this.#Qs(),this.#pt.addEventListener("click",this.#Js),this.#pt.addEventListener("keydown",this.#Gs)):(this.#Ks(),this.#pt.removeEventListener("click",this.#Js),this.#pt.removeEventListener("keydown",this.#Gs))}#Qs(){this.#on||this.render(),this.isVisible?this.#an&&this.#pt.classList.add("focused"):(this.#mn(),this.#pt.hidden=!1,this.#pt.style.zIndex=parseInt(this.#pt.style.zIndex)+1e3)}#Ks(){this.#pt.classList.remove("focused"),!this.#an&&this.isVisible&&(this.#pt.hidden=!0,this.#pt.style.zIndex=parseInt(this.#pt.style.zIndex)-1e3)}forceHide(){this.#cn=this.isVisible,this.#cn&&(this.#pt.hidden=!0)}maybeShow(){this.#cn&&(this.#on||this.#Qs(),this.#cn=!1,this.#pt.hidden=!1)}get isVisible(){return!1===this.#pt.hidden}}class Ms extends bs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=y.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 Is extends bs{#bn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const t=this.data,{width:e,height:i}=fs(t.rect),s=this.svgFactory.create(e,i,!0),n=this.#bn=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#bn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ls extends bs{#vn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const t=this.data,{width:e,height:i}=fs(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#vn=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",i-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#vn}addHighlightArea(){this.container.classList.add("highlightArea")}}class ks extends bs{#wn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const t=this.data,{width:e,height:i}=fs(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#wn=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",i/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",i/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#wn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ds extends bs{#yn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:i,popupRef:s}}=this;if(!e)return this.container;const{width:n,height:r}=fs(t),a=this.svgFactory.create(n,r,!0);let o=[];for(let i=0,s=e.length;i<s;i+=2){const s=e[i]-t[0],n=t[3]-e[i+1];o.push(`${s},${n}`)}o=o.join(" ");const l=this.#yn=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),a.append(l),this.container.append(a),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#yn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Rs extends Ds{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Ns extends bs{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 Fs extends bs{#An=null;#_n=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?y.HIGHLIGHT:y.INK}#xn(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:i,borderStyle:s,popupRef:n}}=this,{transform:r,width:a,height:o}=this.#xn(e,t),l=this.svgFactory.create(a,o,!0),h=this.#An=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",r);for(let t=0,e=i.length;t<e;t++){const e=this.svgFactory.createElement(this.svgElementName);this.#_n.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!n&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:i,rect:s}=t,n=this.#An;if(e>=0&&n.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#_n.length;t<e;t++)this.#_n[t].setAttribute("points",i[t].join(","));if(s){const{transform:t,width:e,height:i}=this.#xn(this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#_n}addHighlightArea(){this.container.classList.add("highlightArea")}}class Os extends bs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=y.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Bs extends bs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class js extends bs{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 Vs extends bs{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 Hs extends bs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=y.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 zs extends bs{#Sn=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let i;e.hasAppearance||0===e.fillAlpha?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),i.addEventListener("dblclick",this.#Cn.bind(this)),this.#Sn=i;const{isMac:s}=_t.platform;return t.addEventListener("keydown",(t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#Cn()})),!e.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#Sn}addHighlightArea(){this.container.classList.add("highlightArea")}#Cn(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}let Us=class{#En=null;#Pn=null;#Tn=new Map;#Mn=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:r,structTreeLayer:a}){this.div=t,this.#En=e,this.#Pn=i,this.#Mn=a||null,this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return this.#Tn.size>0}async#In(t,e){const i=t.firstChild||t,s=i.id=`${Tt}${e}`,n=await(this.#Mn?.getAriaAttributes(s));if(n)for(const[t,e]of n)i.setAttribute(t,e);this.div.append(t),this.#En?.moveElementInDOM(this.div,t,i,!1)}async render(t){const{annotations:e}=t,i=this.div;qt(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 cs,annotationStorage:t.annotationStorage||new pe,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===W;if(e){const e=s.get(t.id);if(!e)continue;n.elements=e}else{const{width:e,height:i}=fs(t.rect);if(e<=0||i<=0)continue}n.data=t;const i=ms.create(n);if(!i.isRenderable)continue;if(!e&&t.popupRef){const e=s.get(t.popupRef);e?e.push(i):s.set(t.popupRef,[i])}const r=i.render();t.hidden&&(r.style.visibility="hidden"),await this.#In(r,t.id),i._isEditable&&(this.#Tn.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}this.#Ln()}update({viewport:t}){const e=this.div;this.viewport=t,qt(e,{rotation:t.rotation}),this.#Ln(),e.hidden=!1}#Ln(){if(!this.#Pn)return;const t=this.div;for(const[e,i]of this.#Pn){const s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent";const{firstChild:n}=s;n?"CANVAS"===n.nodeName?n.replaceWith(i):n.classList.contains("annotationContent")?n.after(i):n.before(i):s.append(i)}this.#Pn.clear()}getEditableAnnotations(){return Array.from(this.#Tn.values())}getEditableAnnotation(t){return this.#Tn.get(t)}};const $s=/\r\n?|\n/g;class Ws extends ae{#tn;#kn="";#Dn=`${this.id}-editor`;#Rn=null;#pn;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=Ws.prototype,e=t=>t.isEmpty(),i=se.TRANSLATE_SMALL,s=se.TRANSLATE_BIG;return dt(this,"_keyboardManager",new ee([[["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=y.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#tn=t.color||Ws._defaultColor||ae._defaultLineColor,this.#pn=t.fontSize||Ws._defaultFontSize}static initialize(t,e){ae.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case A.FREETEXT_SIZE:Ws._defaultFontSize=e;break;case A.FREETEXT_COLOR:Ws._defaultColor=e}}updateParams(t,e){switch(t){case A.FREETEXT_SIZE:this.#Nn(e);break;case A.FREETEXT_COLOR:this.#Fn(e)}}static get defaultPropertiesToUpdate(){return[[A.FREETEXT_SIZE,Ws._defaultFontSize],[A.FREETEXT_COLOR,Ws._defaultColor||ae._defaultLineColor]]}get propertiesToUpdate(){return[[A.FREETEXT_SIZE,this.#pn],[A.FREETEXT_COLOR,this.#tn]]}#Nn(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--scale-factor))`,this.translate(0,-(t-this.#pn)*this.parentScale),this.#pn=t,this.#On()},i=this.#pn;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:A.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#Fn(t){const e=t=>{this.#tn=this.editorDiv.style.color=t},i=this.#tn;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:A.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-Ws._internalPadding*t,-(Ws._internalPadding+this.#pn)*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(y.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#Rn=new AbortController;const t=this._uiManager.combinedSignal(this.#Rn);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#Dn),this._isDraggable=!0,this.#Rn?.abort(),this.#Rn=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#Bn(){const t=[];this.editorDiv.normalize();let e=null;for(const i of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&"BR"===i.nodeName||(t.push(Ws.#jn(i)),e=i);return t.join("\n")}#On(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,s=e.style.display,n=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),i=e.getBoundingClientRect(),e.remove(),e.style.display=s,e.classList.toggle("hidden",n)}this.rotation%180==this.parentRotation%180?(this.width=i.width/t,this.height=i.height/e):(this.width=i.height/t,this.height=i.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#kn,e=this.#kn=this.#Bn().trimEnd();if(t===e)return;const i=t=>{this.#kn=t,t?(this.#Vn(),this._uiManager.rebuild(this),this.#On()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#On()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){Ws._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#Dn),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#pn}px * var(--scale-factor))`,i.color=this.#tn,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Qt(this,this.div,["dblclick","keydown"]),this.width){const[i,s]=this.parentDimensions;if(this.annotationElementId){const{position:n}=this._initialData;let[r,a]=this.getInitialTranslation();[r,a]=this.pageTranslationToScreen(r,a);const[o,l]=this.pageDimensions,[h,d]=this.pageTranslation;let c,u;switch(this.rotation){case 0:c=t+(n[0]-h)/o,u=e+this.height-(n[1]-d)/l;break;case 90:c=t+(n[0]-h)/o,u=e-(n[1]-d)/l,[r,a]=[a,-r];break;case 180:c=t-this.width+(n[0]-h)/o,u=e-(n[1]-d)/l,[r,a]=[-r,-a];break;case 270:c=t+(n[0]-h-this.height*l)/o,u=e+(n[1]-d-this.width*o)/l,[r,a]=[-a,r]}this.setAt(c*i,u*s,r,a)}else this.setAt(t*i,e*s,this.width*i,this.height*s);this.#Vn(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#jn(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll($s,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const s=Ws.#Hn(e.getData("text")||"").replaceAll($s,"\n");if(!s)return;const n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();const r=n.getRangeAt(0);if(!s.includes("\n"))return r.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),void n.collapseToStart();const{startContainer:a,startOffset:o}=r,l=[],h=[];if(a.nodeType===Node.TEXT_NODE){const t=a.parentElement;if(h.push(a.nodeValue.slice(o).replaceAll($s,"")),t!==this.editorDiv){let e=l;for(const i of this.editorDiv.childNodes)i!==t?e.push(Ws.#jn(i)):e=h}l.push(a.nodeValue.slice(0,o).replaceAll($s,""))}else if(a===this.editorDiv){let t=l,e=0;for(const i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(Ws.#jn(i))}this.#kn=`${l.join("\n")}${s}${h.join("\n")}`,this.#Vn();const d=new Range;let c=l.reduce(((t,e)=>t+e.length),0);for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(c<=e){d.setStart(t,c),d.setEnd(t,c);break}c-=e}n.removeAllRanges(),n.addRange(d)}#Vn(){if(this.editorDiv.replaceChildren(),this.#kn)for(const t of this.#kn.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#zn(){return this.#kn.replaceAll(" "," ")}static#Hn(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,i){let s=null;if(t instanceof Ms){const{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:n,rotation:r,id:a,popupRef:o},textContent:l,textPosition:h,parent:{page:{pageNumber:d}}}=t;if(!l||0===l.length)return null;s=t={annotationType:y.FREETEXT,color:Array.from(i),fontSize:e,value:l.join("\n"),position:h,pageIndex:d-1,rect:n.slice(0),rotation:r,id:a,deleted:!1,popupRef:o}}const n=await super.deserialize(t,e,i);return n.#pn=t.fontSize,n.#tn=St.makeHexColor(...t.color),n.#kn=Ws.#Hn(t.value),n.annotationElementId=t.id||null,n._initialData=s,n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=Ws._internalPadding*this.parentScale,i=this.getRect(e,e),s=ae._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#tn),n={annotationType:y.FREETEXT,color:s,fontSize:this.#pn,value:this.#zn(),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?n:this.annotationElementId&&!this.#Un(n)?null:(n.id=this.annotationElementId,n)}#Un(t){const{value:e,fontSize:i,color:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some(((t,e)=>t!==s[e]))||t.pageIndex!==n}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:i}=e;i.fontSize=`calc(${this.#pn}px * var(--scale-factor))`,i.color=this.#tn,e.replaceChildren();for(const t of this.#kn.split("\n")){const i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}const s=Ws._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:this.#kn}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class Gs{static PRECISION=1e-4;toSVGPath(){ot("Abstract method `toSVGPath` must be implemented.")}get box(){ot("Abstract getter `box` must be implemented.")}serialize(t,e){ot("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*s,r[a+1]=i+t[a+1]*n;return r}static _rescaleAndSwap(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*s,r[a+1]=i+t[a]*n;return r}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n+=2)s[n]=e+t[n],s[n+1]=i+t[n+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,s,n){switch(n){case 90:return[1-e/i,t/s];case 180:return[1-t/i,1-e/s];case 270:return[e/i,1-t/s];default:return[t/i,e/s]}}static _normalizePagePoint(t,e,i){switch(i){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,i,s,n,r){return[(t+5*i)/6,(e+5*s)/6,(5*i+n)/6,(5*s+r)/6,(i+n)/2,(s+r)/2]}}class qs{#$n;#Wn=[];#Gn;#qn;#Xn=[];#Kn=new Float32Array(18);#Yn;#Qn;#Jn;#Zn;#tr;#er;#ir=[];static#sr=8;static#nr=2;static#rr=qs.#sr+qs.#nr;constructor({x:t,y:e},i,s,n,r,a=0){this.#$n=i,this.#er=n*s,this.#qn=r,this.#Kn.set([NaN,NaN,NaN,NaN,t,e],6),this.#Gn=a,this.#Zn=qs.#sr*s,this.#Jn=qs.#rr*s,this.#tr=s,this.#ir.push(t,e)}isEmpty(){return isNaN(this.#Kn[8])}#ar(){const t=this.#Kn.subarray(4,6),e=this.#Kn.subarray(16,18),[i,s,n,r]=this.#$n;return[(this.#Yn+(t[0]-e[0])/2-i)/n,(this.#Qn+(t[1]-e[1])/2-s)/r,(this.#Yn+(e[0]-t[0])/2-i)/n,(this.#Qn+(e[1]-t[1])/2-s)/r]}add({x:t,y:e}){this.#Yn=t,this.#Qn=e;const[i,s,n,r]=this.#$n;let[a,o,l,h]=this.#Kn.subarray(8,12);const d=t-l,c=e-h,u=Math.hypot(d,c);if(u<this.#Jn)return!1;const p=u-this.#Zn,g=p/u,f=g*d,m=g*c;let b=a,v=o;a=l,o=h,l+=f,h+=m,this.#ir?.push(t,e);const w=f/p,y=-m/p*this.#er,A=w*this.#er;if(this.#Kn.set(this.#Kn.subarray(2,8),0),this.#Kn.set([l+y,h+A],4),this.#Kn.set(this.#Kn.subarray(14,18),12),this.#Kn.set([l-y,h-A],16),isNaN(this.#Kn[6]))return 0===this.#Xn.length&&(this.#Kn.set([a+y,o+A],2),this.#Xn.push(NaN,NaN,NaN,NaN,(a+y-i)/n,(o+A-s)/r),this.#Kn.set([a-y,o-A],14),this.#Wn.push(NaN,NaN,NaN,NaN,(a-y-i)/n,(o-A-s)/r)),this.#Kn.set([b,v,a,o,l,h],6),!this.isEmpty();this.#Kn.set([b,v,a,o,l,h],6);return Math.abs(Math.atan2(v-o,b-a)-Math.atan2(m,f))<Math.PI/2?([a,o,l,h]=this.#Kn.subarray(2,6),this.#Xn.push(NaN,NaN,NaN,NaN,((a+l)/2-i)/n,((o+h)/2-s)/r),[a,o,b,v]=this.#Kn.subarray(14,18),this.#Wn.push(NaN,NaN,NaN,NaN,((b+a)/2-i)/n,((v+o)/2-s)/r),!0):([b,v,a,o,l,h]=this.#Kn.subarray(0,6),this.#Xn.push(((b+5*a)/6-i)/n,((v+5*o)/6-s)/r,((5*a+l)/6-i)/n,((5*o+h)/6-s)/r,((a+l)/2-i)/n,((o+h)/2-s)/r),[l,h,a,o,b,v]=this.#Kn.subarray(12,18),this.#Wn.push(((b+5*a)/6-i)/n,((v+5*o)/6-s)/r,((5*a+l)/6-i)/n,((5*o+h)/6-s)/r,((a+l)/2-i)/n,((o+h)/2-s)/r),!0)}toSVGPath(){if(this.isEmpty())return"";const t=this.#Xn,e=this.#Wn;if(isNaN(this.#Kn[6])&&!this.isEmpty())return this.#or();const i=[];i.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#lr(i);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#hr(i),i.join(" ")}#or(){const[t,e,i,s]=this.#$n,[n,r,a,o]=this.#ar();return`M${(this.#Kn[2]-t)/i} ${(this.#Kn[3]-e)/s} L${(this.#Kn[4]-t)/i} ${(this.#Kn[5]-e)/s} L${n} ${r} L${a} ${o} L${(this.#Kn[16]-t)/i} ${(this.#Kn[17]-e)/s} L${(this.#Kn[14]-t)/i} ${(this.#Kn[15]-e)/s} Z`}#hr(t){const e=this.#Wn;t.push(`L${e[4]} ${e[5]} Z`)}#lr(t){const[e,i,s,n]=this.#$n,r=this.#Kn.subarray(4,6),a=this.#Kn.subarray(16,18),[o,l,h,d]=this.#ar();t.push(`L${(r[0]-e)/s} ${(r[1]-i)/n} L${o} ${l} L${h} ${d} L${(a[0]-e)/s} ${(a[1]-i)/n}`)}newFreeDrawOutline(t,e,i,s,n,r){return new Xs(t,e,i,s,n,r)}getOutlines(){const t=this.#Xn,e=this.#Wn,i=this.#Kn,[s,n,r,a]=this.#$n,o=new Float32Array((this.#ir?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#ir[t]-s)/r,o[t+1]=(this.#ir[t+1]-n)/a;if(o[o.length-2]=(this.#Yn-s)/r,o[o.length-1]=(this.#Qn-n)/a,isNaN(i[6])&&!this.isEmpty())return this.#dr(o);const l=new Float32Array(this.#Xn.length+24+this.#Wn.length);let h=t.length;for(let e=0;e<h;e+=2)isNaN(t[e])?l[e]=l[e+1]=NaN:(l[e]=t[e],l[e+1]=t[e+1]);h=this.#cr(l,h);for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2)isNaN(e[t+i])?(l[h]=l[h+1]=NaN,h+=2):(l[h]=e[t+i],l[h+1]=e[t+i+1],h+=2);return this.#ur(l,h),this.newFreeDrawOutline(l,o,this.#$n,this.#tr,this.#Gn,this.#qn)}#dr(t){const e=this.#Kn,[i,s,n,r]=this.#$n,[a,o,l,h]=this.#ar(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/n,(e[3]-s)/r,NaN,NaN,NaN,NaN,(e[4]-i)/n,(e[5]-s)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/n,(e[17]-s)/r,NaN,NaN,NaN,NaN,(e[14]-i)/n,(e[15]-s)/r],0),this.newFreeDrawOutline(d,t,this.#$n,this.#tr,this.#Gn,this.#qn)}#ur(t,e){const i=this.#Wn;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#cr(t,e){const i=this.#Kn.subarray(4,6),s=this.#Kn.subarray(16,18),[n,r,a,o]=this.#$n,[l,h,d,c]=this.#ar();return t.set([NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,d,c,NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/o],e),e+24}}class Xs extends Gs{#$n;#pr=new Float32Array(4);#Gn;#qn;#ir;#tr;#gr;constructor(t,e,i,s,n,r){super(),this.#gr=t,this.#ir=e,this.#$n=i,this.#tr=s,this.#Gn=n,this.#qn=r,this.lastPoint=[NaN,NaN],this.#fr(r);const[a,o,l,h]=this.#pr;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-a)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-a)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){const t=[`M${this.#gr[4]} ${this.#gr[5]}`];for(let e=6,i=this.#gr.length;e<i;e+=6)isNaN(this.#gr[e])?t.push(`L${this.#gr[e+4]} ${this.#gr[e+5]}`):t.push(`C${this.#gr[e]} ${this.#gr[e+1]} ${this.#gr[e+2]} ${this.#gr[e+3]} ${this.#gr[e+4]} ${this.#gr[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,i,s],n){const r=i-t,a=s-e;let o,l;switch(n){case 0:o=Gs._rescale(this.#gr,t,s,r,-a),l=Gs._rescale(this.#ir,t,s,r,-a);break;case 90:o=Gs._rescaleAndSwap(this.#gr,t,e,r,a),l=Gs._rescaleAndSwap(this.#ir,t,e,r,a);break;case 180:o=Gs._rescale(this.#gr,i,e,-r,a),l=Gs._rescale(this.#ir,i,e,-r,a);break;case 270:o=Gs._rescaleAndSwap(this.#gr,i,s,-r,-a),l=Gs._rescaleAndSwap(this.#ir,i,s,-r,-a)}return{outline:Array.from(o),points:[Array.from(l)]}}#fr(t){const e=this.#gr;let i=e[4],s=e[5],n=i,r=s,a=i,o=s,l=i,h=s;const d=t?Math.max:Math.min;for(let t=6,c=e.length;t<c;t+=6){if(isNaN(e[t]))n=Math.min(n,e[t+4]),r=Math.min(r,e[t+5]),a=Math.max(a,e[t+4]),o=Math.max(o,e[t+5]),h<e[t+5]?(l=e[t+4],h=e[t+5]):h===e[t+5]&&(l=d(l,e[t+4]));else{const c=St.bezierBoundingBox(i,s,...e.slice(t,t+6));n=Math.min(n,c[0]),r=Math.min(r,c[1]),a=Math.max(a,c[2]),o=Math.max(o,c[3]),h<c[3]?(l=c[2],h=c[3]):h===c[3]&&(l=d(l,c[2]))}i=e[t+4],s=e[t+5]}const c=this.#pr;c[0]=n-this.#Gn,c[1]=r-this.#Gn,c[2]=a-n+2*this.#Gn,c[3]=o-r+2*this.#Gn,this.lastPoint=[l,h]}get box(){return this.#pr}newOutliner(t,e,i,s,n,r=0){return new qs(t,e,i,s,n,r)}getNewOutline(t,e){const[i,s,n,r]=this.#pr,[a,o,l,h]=this.#$n,d=n*l,c=r*h,u=i*l+a,p=s*h+o,g=this.newOutliner({x:this.#ir[0]*d+u,y:this.#ir[1]*c+p},this.#$n,this.#tr,t,this.#qn,e??this.#Gn);for(let t=2;t<this.#ir.length;t+=2)g.add({x:this.#ir[t]*d+u,y:this.#ir[t+1]*c+p});return g.getOutlines()}}class Ks{#$n;#mr;#br=[];#vr=[];constructor(t,e=0,i=0,s=!0){let n=1/0,r=-1/0,a=1/0,o=-1/0;const l=10**-4;for(const{x:i,y:s,width:h,height:d}of t){const t=Math.floor((i-e)/l)*l,c=Math.ceil((i+h+e)/l)*l,u=Math.floor((s-e)/l)*l,p=Math.ceil((s+d+e)/l)*l,g=[t,u,p,!0],f=[c,u,p,!1];this.#br.push(g,f),n=Math.min(n,t),r=Math.max(r,c),a=Math.min(a,u),o=Math.max(o,p)}const h=r-n+2*i,d=o-a+2*i,c=n-i,u=a-i,p=this.#br.at(s?-1:-2),g=[p[0],p[2]];for(const t of this.#br){const[e,i,s]=t;t[0]=(e-c)/h,t[1]=(i-u)/d,t[2]=(s-u)/d}this.#$n=new Float32Array([c,u,h,d]),this.#mr=g}getOutlines(){this.#br.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of this.#br)e[3]?(t.push(...this.#wr(e)),this.#yr(e)):(this.#Ar(e),t.push(...this.#wr(e)));return this.#_r(t)}#_r(t){const e=[],i=new Set;for(const i of t){const[t,s,n]=i;e.push([t,s,i],[t,n,i])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(let t=0,s=e.length;t<s;t+=2){const s=e[t][2],n=e[t+1][2];s.push(n),n.push(s),i.add(s),i.add(n)}const s=[];let n;for(;i.size>0;){const t=i.values().next().value;let[e,r,a,o,l]=t;i.delete(t);let h=e,d=r;for(n=[e,a],s.push(n);;){let t;if(i.has(o))t=o;else{if(!i.has(l))break;t=l}i.delete(t),[e,r,a,o,l]=t,h!==e&&(n.push(h,d,e,d===r?r:a),h=e),d=d===r?a:r}n.push(h,d)}return new Ys(s,this.#$n,this.#mr)}#xr(t){const e=this.#vr;let i=0,s=e.length-1;for(;i<=s;){const n=i+s>>1,r=e[n][0];if(r===t)return n;r<t?i=n+1:s=n-1}return s+1}#yr([,t,e]){const i=this.#xr(t);this.#vr.splice(i,0,[t,e])}#Ar([,t,e]){const i=this.#xr(t);for(let s=i;s<this.#vr.length;s++){const[i,n]=this.#vr[s];if(i!==t)break;if(i===t&&n===e)return void this.#vr.splice(s,1)}for(let s=i-1;s>=0;s--){const[i,n]=this.#vr[s];if(i!==t)break;if(i===t&&n===e)return void this.#vr.splice(s,1)}}#wr(t){const[e,i,s]=t,n=[[e,i,s]],r=this.#xr(s);for(let t=0;t<r;t++){const[i,s]=this.#vr[t];for(let t=0,r=n.length;t<r;t++){const[,a,o]=n[t];if(!(s<=a||o<=i))if(a>=i)if(o>s)n[t][1]=s;else{if(1===r)return[];n.splice(t,1),t--,r--}else n[t][2]=i,o>s&&n.push([e,s,o])}}return n}}class Ys extends Gs{#$n;#Sr;constructor(t,e,i){super(),this.#Sr=t,this.#$n=e,this.lastPoint=i}toSVGPath(){const t=[];for(const e of this.#Sr){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n<e.length;n+=2){const r=e[n],a=e[n+1];r===i?(t.push(`V${a}`),s=a):a===s&&(t.push(`H${r}`),i=r)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],n){const r=[],a=i-t,o=s-e;for(const e of this.#Sr){const i=new Array(e.length);for(let n=0;n<e.length;n+=2)i[n]=t+e[n]*a,i[n+1]=s-e[n+1]*o;r.push(i)}return r}get box(){return this.#$n}get classNamesForOutlining(){return["highlightOutline"]}}class Qs extends qs{newFreeDrawOutline(t,e,i,s,n,r){return new Js(t,e,i,s,n,r)}}class Js extends Xs{newOutliner(t,e,i,s,n,r=0){return new Qs(t,e,i,s,n,r)}}let Zs=class t{#Cr=null;#Er=null;#Pr;#Tr=null;#Mr=!1;#Ir=!1;#r=null;#Lr;#kr=null;#f=null;#Dr;static#Rr=null;static get _keyboardManager(){return dt(this,"_keyboardManager",new ee([[["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.#Ir=!1,this.#Dr=A.HIGHLIGHT_COLOR,this.#r=e):(this.#Ir=!0,this.#Dr=A.HIGHLIGHT_DEFAULT_COLOR),this.#f=e?._uiManager||i,this.#Lr=this.#f._eventBus,this.#Pr=e?.color||this.#f?.highlightColors.values().next().value||"#FFFF98",t.#Rr||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){const t=this.#Cr=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=this.#f._signal;t.addEventListener("click",this.#Nr.bind(this),{signal:e}),t.addEventListener("keydown",this.#qs.bind(this),{signal:e});const i=this.#Er=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#Pr,t.append(i),t}renderMainDropdown(){const t=this.#Tr=this.#Fr();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#Fr(){const e=document.createElement("div"),i=this.#f._signal;e.addEventListener("contextmenu",Vt,{signal:i}),e.className="dropdown",e.role="listbox",e.setAttribute("aria-multiselectable",!1),e.setAttribute("aria-orientation","vertical"),e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[s,n]of this.#f.highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",n),r.title=s,r.setAttribute("data-l10n-id",t.#Rr[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=n,r.setAttribute("aria-selected",n===this.#Pr),r.addEventListener("click",this.#Or.bind(this,n),{signal:i}),e.append(r)}return e.addEventListener("keydown",this.#qs.bind(this),{signal:i}),e}#Or(t,e){e.stopPropagation(),this.#Lr.dispatch("switchannotationeditorparams",{source:this,type:this.#Dr,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#Cr)return void this.#Nr(t);const e=t.target.getAttribute("data-color");e&&this.#Or(e,t)}_moveToNext(t){this.#Br?t.target!==this.#Cr?t.target.nextSibling?.focus():this.#Tr.firstChild?.focus():this.#Nr(t)}_moveToPrevious(t){t.target!==this.#Tr?.firstChild&&t.target!==this.#Cr?(this.#Br||this.#Nr(t),t.target.previousSibling?.focus()):this.#Br&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#Br?this.#Tr.firstChild?.focus():this.#Nr(t)}_moveToEnd(t){this.#Br?this.#Tr.lastChild?.focus():this.#Nr(t)}#qs(e){t._keyboardManager.exec(this,e)}#Nr(t){if(this.#Br)return void this.hideDropdown();if(this.#Mr=0===t.detail,this.#kr||(this.#kr=new AbortController,window.addEventListener("pointerdown",this.#h.bind(this),{signal:this.#f.combinedSignal(this.#kr)})),this.#Tr)return void this.#Tr.classList.remove("hidden");const e=this.#Tr=this.#Fr();this.#Cr.append(e)}#h(t){this.#Tr?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#Tr?.classList.add("hidden"),this.#kr?.abort(),this.#kr=null}get#Br(){return this.#Tr&&!this.#Tr.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#Ir||(this.#Br?(this.hideDropdown(),this.#Cr.focus({preventScroll:!0,focusVisible:this.#Mr})):this.#r?.unselect())}updateColor(t){if(this.#Er&&(this.#Er.style.backgroundColor=t),!this.#Tr)return;const e=this.#f.highlightColors.values();for(const i of this.#Tr.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#Cr?.remove(),this.#Cr=null,this.#Er=null,this.#Tr?.remove(),this.#Tr=null}};class tn extends ae{#jr=null;#Vr=0;#Hr;#zr=null;#n=null;#Ur=null;#$r=null;#Wr=0;#Gr=null;#qr=null;#w=null;#Xr=!1;#mr=null;#Kr;#Yr=null;#Qr="";#er;#Jr="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=y.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=tn.prototype;return dt(this,"_keyboardManager",new ee([[["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||tn._defaultColor,this.#er=t.thickness||tn._defaultThickness,this.#Kr=t.opacity||tn._defaultOpacity,this.#Hr=t.boxes||null,this.#Jr=t.methodOfCreation||"",this.#Qr=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#Xr=!0,this.#Zr(t),this.#ta()):this.#Hr&&(this.#jr=t.anchorNode,this.#Vr=t.anchorOffset,this.#$r=t.focusNode,this.#Wr=t.focusOffset,this.#ea(),this.#ta(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#Xr?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#er,methodOfCreation:this.#Jr}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#ea(){const t=new Ks(this.#Hr,.001);this.#qr=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#qr.box;const e=new Ks(this.#Hr,.0025,.001,"ltr"===this._uiManager.direction);this.#Ur=e.getOutlines();const{lastPoint:i}=this.#Ur;this.#mr=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#Zr({highlightOutlines:t,highlightId:e,clipPathId:i}){this.#qr=t;if(this.#Ur=t.getNewOutline(this.#er/2+1.5,.0025),e>=0)this.#w=e,this.#zr=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#Yr=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#Ur.box,path:{d:this.#Ur.toSVGPath()}},!0);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#w,{bbox:tn.#ia(this.#qr.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#Yr,{bbox:tn.#ia(this.#Ur.box,e),path:{d:this.#Ur.toSVGPath()}})}const[s,n,r,a]=t.box;switch(this.rotation){case 0:this.x=s,this.y=n,this.width=r,this.height=a;break;case 90:{const[t,e]=this.parentDimensions;this.x=n,this.y=1-s,this.width=r*e/t,this.height=a*t/e;break}case 180:this.x=1-s,this.y=1-n,this.width=r,this.height=a;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-n,this.y=s,this.width=r*e/t,this.height=a*t/e;break}}const{lastPoint:o}=this.#Ur;this.#mr=[(o[0]-s)/r,(o[1]-n)/a]}static initialize(t,e){ae.initialize(t,e),tn._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case A.HIGHLIGHT_DEFAULT_COLOR:tn._defaultColor=e;break;case A.HIGHLIGHT_THICKNESS:tn._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#mr}updateParams(t,e){switch(t){case A.HIGHLIGHT_COLOR:this.#Fn(e);break;case A.HIGHLIGHT_THICKNESS:this.#sa(e)}}static get defaultPropertiesToUpdate(){return[[A.HIGHLIGHT_DEFAULT_COLOR,tn._defaultColor],[A.HIGHLIGHT_THICKNESS,tn._defaultThickness]]}get propertiesToUpdate(){return[[A.HIGHLIGHT_COLOR,this.color||tn._defaultColor],[A.HIGHLIGHT_THICKNESS,this.#er||tn._defaultThickness],[A.HIGHLIGHT_FREE,this.#Xr]]}#Fn(t){const e=(t,e)=>{this.color=t,this.#Kr=e,this.parent?.drawLayer.updateProperties(this.#w,{root:{fill:t,"fill-opacity":e}}),this.#n?.updateColor(t)},i=this.color,s=this.#Kr;this.addCommands({cmd:e.bind(this,t,tn._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:A.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#sa(t){const e=this.#er,i=t=>{this.#er=t,this.#na(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:A.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 Zs({editor:this}),t.addColorPicker(this.#n)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#ra())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#ra())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#aa(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#ta(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#aa():t&&(this.#ta(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#na(t){if(!this.#Xr)return;this.#Zr({highlightOutlines:this.#qr.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#aa(){null!==this.#w&&this.parent&&(this.parent.drawLayer.remove(this.#w),this.#w=null,this.parent.drawLayer.remove(this.#Yr),this.#Yr=null)}#ta(t=this.parent){null===this.#w&&(({id:this.#w,clipPathId:this.#zr}=t.drawLayer.draw({bbox:this.#qr.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#Kr},rootClass:{highlight:!0,free:this.#Xr},path:{d:this.#qr.toSVGPath()}},!1,!0)),this.#Yr=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#Xr},bbox:this.#Ur.box,path:{d:this.#Ur.toSVGPath()}},this.#Xr),this.#Gr&&(this.#Gr.style.clipPath=this.#zr))}static#ia([t,e,i,s],n){switch(n){case 90:return[1-e-s,t,s,i];case 180:return[1-t-i,1-e-s,i,s];case 270:return[e,1-t-i,s,i]}return[t,e,i,s]}rotate(t){const{drawLayer:e}=this.parent;let i;this.#Xr?(t=(t-this.rotation+360)%360,i=tn.#ia(this.#qr.box,t)):i=tn.#ia([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#w,{bbox:i,root:{"data-main-rotation":t}}),e.updateProperties(this.#Yr,{bbox:tn.#ia(this.#Ur.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#Qr&&(t.setAttribute("aria-label",this.#Qr),t.setAttribute("role","mark")),this.#Xr?t.classList.add("free"):this.div.addEventListener("keydown",this.#oa.bind(this),{signal:this._uiManager._signal});const e=this.#Gr=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#zr;const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),Qt(this,this.#Gr,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Yr,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Yr,{rootClass:{hovered:!1}})}#oa(t){tn._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#la(!0);break;case 1:case 3:this.#la(!1)}}#la(t){if(!this.#jr)return;const e=window.getSelection();t?e.setPosition(this.#jr,this.#Vr):e.setPosition(this.#$r,this.#Wr)}select(){super.select(),this.#Yr&&this.parent?.drawLayer.updateProperties(this.#Yr,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#Yr&&(this.parent?.drawLayer.updateProperties(this.#Yr,{rootClass:{selected:!1}}),this.#Xr||this.#la(!1))}get _mustFixPosition(){return!this.#Xr}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#w,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#Yr,{rootClass:{hidden:!t}}))}#ra(){return this.#Xr?this.rotation:0}#ha(){if(this.#Xr)return null;const[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=this.#Hr,r=new Float32Array(8*n.length);let a=0;for(const{x:o,y:l,width:h,height:d}of n){const n=o*t+i,c=(1-l)*e+s;r[a]=r[a+4]=n,r[a+1]=r[a+3]=c,r[a+2]=r[a+6]=n+h*t,r[a+5]=r[a+7]=c-d*e,a+=8}return r}#da(t){return this.#qr.serialize(t,this.#ra())}static startHighlighting(t,e,{target:i,x:s,y:n}){const{x:r,y:a,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,d=t.combinedSignal(h),c=e=>{h.abort(),this.#ca(t,e)};window.addEventListener("blur",c,{signal:d}),window.addEventListener("pointerup",c,{signal:d}),window.addEventListener("pointerdown",Ht,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",Vt,{signal:d}),i.addEventListener("pointermove",this.#ua.bind(this,t),{signal:d}),this._freeHighlight=new Qs({x:s,y:n},[r,a,o,l],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static#ua(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#ca(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,i){let s=null;if(t instanceof Os){const{data:{quadPoints:e,rect:i,rotation:n,id:r,color:a,opacity:o,popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:y.HIGHLIGHT,color:Array.from(a),opacity:o,quadPoints:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:l}}else if(t instanceof Fs){const{data:{inkLists:e,rect:i,rotation:n,id:r,color:a,borderStyle:{rawWidth:o},popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:y.HIGHLIGHT,color:Array.from(a),thickness:o,inkLists:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:l}}const{color:n,quadPoints:r,inkLists:a,opacity:o}=t,l=await super.deserialize(t,e,i);l.color=St.makeHexColor(...n),l.#Kr=o||1,a&&(l.#er=t.thickness),l.annotationElementId=t.id||null,l._initialData=s;const[h,d]=l.pageDimensions,[c,u]=l.pageTranslation;if(r){const t=l.#Hr=[];for(let e=0;e<r.length;e+=8)t.push({x:(r[e]-c)/h,y:1-(r[e+1]-u)/d,width:(r[e+2]-r[e])/h,height:(r[e+1]-r[e+5])/d});l.#ea(),l.#ta(),l.rotate(l.rotation)}else if(a){l.#Xr=!0;const t=a[0],i={x:t[0]-c,y:d-(t[1]-u)},s=new Qs(i,[0,0,h,d],1,l.#er/2,!0,.001);for(let e=0,n=t.length;e<n;e+=2)i.x=t[e]-c,i.y=d-(t[e+1]-u),s.add(i);const{id:n,clipPathId:r}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:l.color,"fill-opacity":l._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:s.toSVGPath()}},!0,!0);l.#Zr({highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:r}),l.#ta()}return l}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),i=ae._colorManager.convert(this.color),s={annotationType:y.HIGHLIGHT,color:i,opacity:this.#Kr,thickness:this.#er,quadPoints:this.#ha(),outlines:this.#da(e),pageIndex:this.pageIndex,rect:e,rotation:this.#ra(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#Un(s)?null:(s.id=this.annotationElementId,s)}#Un(t){const{color:e}=this._initialData;return t.color.some(((t,i)=>t!==e[i]))}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class en{#pa=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,i]of Object.entries(t))this.updateProperty(e,i)}updateSVGProperty(t,e){this.#pa[t]=e}toSVGProperties(){const t=this.#pa;return this.#pa=Object.create(null),{root:t}}reset(){this.#pa=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){ot("Not implemented")}}class sn extends ae{#ga=null;#fa;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#ma=null;static#ba=null;static#va=null;static#wa=NaN;static#ya=null;static#Aa=null;static#_a=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#fa=t.mustBeCommitted||!1,t.drawOutlines&&(this.#xa(t),this.#ta())}#xa({drawOutlines:t,drawId:e,drawingOptions:i}){this.#ga=t,this._drawingOptions||=i,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#Sa(t,this.parent),this.#Ca(t.box)}#Sa(t,e){const{id:i}=e.drawLayer.draw(sn._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){ot("Not implemented")}static get typesMap(){ot("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&&(sn.#ma.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){const s=this._drawingOptions,n=s[e],r=t=>{s.updateProperty(e,t);const i=this.#ga.updateProperty(e,t);i&&this.#Ca(i),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties())};this.addCommands({cmd:r.bind(this,i),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,sn._mergeSVGProperties(this.#ga.getPathResizingSVGProperties(this.#Ea()),{bbox:this.#Pa()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,sn._mergeSVGProperties(this.#ga.getPathResizedSVGProperties(this.#Ea()),{bbox:this.#Pa()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#Pa(t,e)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,sn._mergeSVGProperties(this.#ga.getPathTranslatedSVGProperties(this.#Ea(),this.parentDimensions),{bbox:this.#Pa()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#fa&&(this.#fa=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#aa(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#ta(),this.#Ca(this.#ga.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#aa()):t&&(this._uiManager.addShouldRescale(this),this.#ta(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#aa(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#ta(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#Sa(this.#ga,t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}#Ta([t,e,i,s]){const{parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[e,1-t,i*(r/n),s*(n/r)];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,i*(r/n),s*(n/r)];default:return[t,e,i,s]}}#Ea(){const{x:t,y:e,width:i,height:s,parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[1-e,t,i*(n/r),s*(r/n)];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,i*(n/r),s*(r/n)];default:return[t,e,i,s]}}#Ca(t){if([this.x,this.y,this.width,this.height]=this.#Ta(t),this.div){this.fixAndSetPosition();const[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()}#Pa(){const{x:t,y:e,width:i,height:s,rotation:n,parentRotation:r,parentDimensions:[a,o]}=this;switch((4*n+r)/90){case 1:return[1-e-s,t,s,i];case 2:return[1-t-i,1-e-s,i,s];case 3:return[e,1-t-i,s,i];case 4:return[t,e-i*(a/o),s*(o/a),i*(a/o)];case 5:return[1-e,t,i*(a/o),s*(o/a)];case 6:return[1-t-s*(o/a),1-e,s*(o/a),i*(a/o)];case 7:return[e-i*(a/o),1-t-s*(o/a),i*(a/o),s*(o/a)];case 8:return[t-i,e-s,i,s];case 9:return[1-e,t-i,s,i];case 10:return[1-t,1-e,i,s];case 11:return[e-s,1-t,s,i];case 12:return[t-s*(o/a),e,s*(o/a),i*(a/o)];case 13:return[1-e-i*(a/o),t-s*(o/a),i*(a/o),s*(o/a)];case 14:return[1-t,1-e-i*(a/o),s*(o/a),i*(a/o)];case 15:return[e,1-t,i*(a/o),s*(o/a)];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,sn._mergeSVGProperties({bbox:this.#Pa()},this.#ga.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#Ca(this.#ga.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const t=super.render();t.classList.add("draw");const e=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal";const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,e,i,s,n){ot("Not implemented")}static startDrawing(t,e,i,s){const{target:n,offsetX:r,offsetY:a,pointerId:o,pointerType:l}=s;if(sn.#ya&&sn.#ya!==l)return;const{viewport:{rotation:h}}=t,{width:d,height:c}=n.getBoundingClientRect(),u=sn.#ba=new AbortController,p=t.combinedSignal(u);sn.#wa||=o,sn.#ya??=l,window.addEventListener("pointerup",(t=>{sn.#wa===t.pointerId?this._endDraw(t):sn.#Aa?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointercancel",(t=>{sn.#wa===t.pointerId?this._currentParent.endDrawingSession():sn.#Aa?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointerdown",(t=>{sn.#ya===t.pointerType&&((sn.#Aa||=new Set).add(t.pointerId),sn.#ma.isCancellable()&&(sn.#ma.removeLastElement(),sn.#ma.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",Vt,{signal:p}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),n.addEventListener("touchmove",(t=>{t.timeStamp===sn.#_a&&Ht(t)}),{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),sn.#ma?t.drawLayer.updateProperties(this._currentDrawId,sn.#ma.startNew(r,a,d,c,h)):(e.updateUIForDefaultProperties(this),sn.#ma=this.createDrawerInstance(r,a,d,c,h),sn.#va=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(sn.#va.toSVGProperties(),sn.#ma.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(sn.#_a=-1,!sn.#ma)return;const{offsetX:e,offsetY:i,pointerId:s}=t;sn.#wa===s&&(sn.#Aa?.size>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,sn.#ma.add(e,i)),sn.#_a=t.timeStamp,Ht(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,sn.#ma=null,sn.#va=null,sn.#ya=null,sn.#_a=NaN),sn.#ba&&(sn.#ba.abort(),sn.#ba=null,sn.#wa=NaN,sn.#Aa=null)}static _endDraw(t){const e=this._currentParent;if(e)if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,sn.#ma.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const t=sn.#ma,i=this._currentDrawId,s=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:A.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(A.DRAW_STEP),!sn.#ma.isEmpty()){const{pageDimensions:[i,s],scale:n}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:sn.#ma.getOutlines(i*n,s*n,n,this._INNER_MARGIN),drawingOptions:sn.#va,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,n,r){ot("Not implemented")}static async deserialize(t,e,i){const{rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:a}}=e.viewport,o=this.deserializeDraw(r,a,s,n,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#xa({drawOutlines:o}),l.#ta(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){const[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return this.#ga.serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class nn{#Kn=new Float64Array(6);#bn;#Ma;#Ri;#er;#ir;#Ia="";#La=0;#Sr=new rn;#ka;#Da;constructor(t,e,i,s,n,r){this.#ka=i,this.#Da=s,this.#Ri=n,this.#er=r,[t,e]=this.#Ra(t,e);const a=this.#bn=[NaN,NaN,NaN,NaN,t,e];this.#ir=[t,e],this.#Ma=[{line:a,points:this.#ir}],this.#Kn.set(a,0)}updateProperty(t,e){"stroke-width"===t&&(this.#er=e)}#Ra(t,e){return Gs._normalizePoint(t,e,this.#ka,this.#Da,this.#Ri)}isEmpty(){return!this.#Ma||0===this.#Ma.length}isCancellable(){return this.#ir.length<=10}add(t,e){[t,e]=this.#Ra(t,e);const[i,s,n,r]=this.#Kn.subarray(2,6),a=t-n,o=e-r;return Math.hypot(this.#ka*a,this.#Da*o)<=2?null:(this.#ir.push(t,e),isNaN(i)?(this.#Kn.set([n,r,t,e],2),this.#bn.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#Kn[0])&&this.#bn.splice(6,6),this.#Kn.set([i,s,n,r,t,e],0),this.#bn.push(...Gs.createBezierPoints(i,s,n,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const i=this.add(t,e);return i||(2===this.#ir.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,n){this.#ka=i,this.#Da=s,this.#Ri=n,[t,e]=this.#Ra(t,e);const r=this.#bn=[NaN,NaN,NaN,NaN,t,e];this.#ir=[t,e];const a=this.#Ma.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#Ma.push({line:r,points:this.#ir}),this.#Kn.set(r,0),this.#La=0,this.toSVGPath(),null}getLastElement(){return this.#Ma.at(-1)}setLastElement(t){return this.#Ma?(this.#Ma.push(t),this.#bn=t.line,this.#ir=t.points,this.#La=0,{path:{d:this.toSVGPath()}}):this.#Sr.setLastElement(t)}removeLastElement(){if(!this.#Ma)return this.#Sr.removeLastElement();this.#Ma.pop(),this.#Ia="";for(let t=0,e=this.#Ma.length;t<e;t++){const{line:e,points:i}=this.#Ma[t];this.#bn=e,this.#ir=i,this.#La=0,this.toSVGPath()}return{path:{d:this.#Ia}}}toSVGPath(){const t=Gs.svgRound(this.#bn[4]),e=Gs.svgRound(this.#bn[5]);if(2===this.#ir.length)return this.#Ia=`${this.#Ia} M ${t} ${e} Z`,this.#Ia;if(this.#ir.length<=6){const i=this.#Ia.lastIndexOf("M");this.#Ia=`${this.#Ia.slice(0,i)} M ${t} ${e}`,this.#La=6}if(4===this.#ir.length){const t=Gs.svgRound(this.#bn[10]),e=Gs.svgRound(this.#bn[11]);return this.#Ia=`${this.#Ia} L ${t} ${e}`,this.#La=12,this.#Ia}const i=[];0===this.#La&&(i.push(`M ${t} ${e}`),this.#La=6);for(let t=this.#La,e=this.#bn.length;t<e;t+=6){const[e,s,n,r,a,o]=this.#bn.slice(t,t+6).map(Gs.svgRound);i.push(`C${e} ${s} ${n} ${r} ${a} ${o}`)}return this.#Ia+=i.join(" "),this.#La=this.#bn.length,this.#Ia}getOutlines(t,e,i,s){const n=this.#Ma.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#Sr.build(this.#Ma,t,e,i,this.#Ri,this.#er,s),this.#Kn=null,this.#bn=null,this.#Ma=null,this.#Ia=null,this.#Sr}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class rn extends Gs{#pr;#Na=0;#Gn;#Ma;#ka;#Da;#Fa;#Ri;#er;build(t,e,i,s,n,r,a){this.#ka=e,this.#Da=i,this.#Fa=s,this.#Ri=n,this.#er=r,this.#Gn=a??0,this.#Ma=t,this.#Oa()}setLastElement(t){return this.#Ma.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#Ma.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#Ma)if(t.push(`M${Gs.svgRound(e[4])} ${Gs.svgRound(e[5])}`),6!==e.length)if(12!==e.length)for(let i=6,s=e.length;i<s;i+=6){const[s,n,r,a,o,l]=e.subarray(i,i+6).map(Gs.svgRound);t.push(`C${s} ${n} ${r} ${a} ${o} ${l}`)}else t.push(`L${Gs.svgRound(e[10])} ${Gs.svgRound(e[11])}`);else t.push("Z");return t.join("")}serialize([t,e,i,s],n){const r=[],a=[],[o,l,h,d]=this.#Ba();let c,u,p,g,f,m,b,v,w;switch(this.#Ri){case 0:w=Gs._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=Gs._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=Gs._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=Gs._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.#Ma)r.push(w(t,c,u,p,g,n?new Array(t.length):null)),a.push(w(e,c,u,p,g,n?new Array(e.length):null));return{lines:r,points:a,rect:[f,m,b,v]}}static deserialize(t,e,i,s,n,{paths:{lines:r,points:a},rotation:o,thickness:l}){const h=[];let d,c,u,p,g;switch(o){case 0:g=Gs._rescale,d=-t/i,c=e/s+1,u=1/i,p=-1/s;break;case 90:g=Gs._rescaleAndSwap,d=-e/s,c=-t/i,u=1/s,p=1/i;break;case 180:g=Gs._rescale,d=t/i+1,c=-e/s,u=-1/i,p=1/s;break;case 270:g=Gs._rescaleAndSwap,d=e/s+1,c=t/i+1,u=-1/s,p=-1/i}if(!r){r=[];for(const t of a){const e=t.length;if(2===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}const i=new Float32Array(3*(e-2));r.push(i);let[s,n,a,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,n],0);for(let r=4;r<e;r+=2){const e=t[r],l=t[r+1];i.set(Gs.createBezierPoints(s,n,a,o,e,l),3*(r-2)),[s,n,a,o]=[a,o,e,l]}}}for(let t=0,e=r.length;t<e;t++)h.push({line:g(r[t].map((t=>t??NaN)),d,c,u,p),points:g(a[t].map((t=>t??NaN)),d,c,u,p)});const f=new rn;return f.build(h,i,s,1,o,l,n),f}#ja(t=this.#er){const e=this.#Gn+t/2*this.#Fa;return this.#Ri%180==0?[e/this.#ka,e/this.#Da]:[e/this.#Da,e/this.#ka]}#Ba(){const[t,e,i,s]=this.#pr,[n,r]=this.#ja(0);return[t+n,e+r,i-2*n,s-2*r]}#Oa(){const t=this.#pr=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:e}of this.#Ma){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6){const[s,n]=e.subarray(i,i+2);t[0]=Math.min(t[0],s),t[1]=Math.min(t[1],n),t[2]=Math.max(t[2],s),t[3]=Math.max(t[3],n)}continue}let i=e[4],s=e[5];for(let n=6,r=e.length;n<r;n+=6){const[r,a,o,l,h,d]=e.subarray(n,n+6);St.bezierBoundingBox(i,s,r,a,o,l,h,d,t),i=h,s=d}}const[e,i]=this.#ja();t[0]=Math.min(1,Math.max(0,t[0]-e)),t[1]=Math.min(1,Math.max(0,t[1]-i)),t[2]=Math.min(1,Math.max(0,t[2]+e)),t[3]=Math.min(1,Math.max(0,t[3]+i)),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#pr}updateProperty(t,e){return"stroke-width"===t?this.#sa(e):null}#sa(t){const[e,i]=this.#ja();this.#er=t;const[s,n]=this.#ja(),[r,a]=[s-e,n-i],o=this.#pr;return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o}updateParentDimensions([t,e],i){const[s,n]=this.#ja();this.#ka=t,this.#Da=e,this.#Fa=i;const[r,a]=this.#ja(),o=r-s,l=a-n,h=this.#pr;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#Na=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#pr.map(Gs.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#pr;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Gs.svgRound(t)} ${Gs.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#pr;let i=0,s=0,n=0,r=0,a=0,o=0;switch(this.#Na){case 90:s=e/t,n=-t/e,a=t;break;case 180:i=-1,r=-1,a=t,o=e;break;case 270:s=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${n} ${r} ${Gs.svgRound(a)} ${Gs.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){const[n,r]=this.#ja(),[a,o,l,h]=this.#pr;if(Math.abs(l-n)<=Gs.PRECISION||Math.abs(h-r)<=Gs.PRECISION){const n=t+i/2-(a+l/2),r=e+s/2-(o+h/2);return{path:{"transform-origin":`${Gs.svgRound(t)} ${Gs.svgRound(e)}`,transform:`${this.rotationTransform} translate(${n} ${r})`}}}const d=(i-2*n)/(l-2*n),c=(s-2*r)/(h-2*r),u=l/i,p=h/s;return{path:{"transform-origin":`${Gs.svgRound(a)} ${Gs.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${p}) translate(${Gs.svgRound(n)} ${Gs.svgRound(r)}) scale(${d} ${c}) translate(${Gs.svgRound(-n)} ${Gs.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,i,s]){const[n,r]=this.#ja(),a=this.#pr,[o,l,h,d]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=s,Math.abs(h-n)<=Gs.PRECISION||Math.abs(d-r)<=Gs.PRECISION){const n=t+i/2-(o+h/2),r=e+s/2-(l+d/2);for(const{line:t,points:e}of this.#Ma)Gs._translate(t,n,r,t),Gs._translate(e,n,r,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Gs.svgRound(t)} ${Gs.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const c=(i-2*n)/(h-2*n),u=(s-2*r)/(d-2*r),p=-c*(o+n)+t+n,g=-u*(l+r)+e+r;if(1!==c||1!==u||0!==p||0!==g)for(const{line:t,points:e}of this.#Ma)Gs._rescale(t,p,g,c,u,t),Gs._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Gs.svgRound(t)} ${Gs.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[s,n]=i,r=this.#pr,a=t-r[0],o=e-r[1];if(this.#ka===s&&this.#Da===n)for(const{line:t,points:e}of this.#Ma)Gs._translate(t,a,o,t),Gs._translate(e,a,o,e);else{const t=this.#ka/s,e=this.#Da/n;this.#ka=s,this.#Da=n;for(const{line:i,points:s}of this.#Ma)Gs._rescale(i,a,o,t,e,i),Gs._rescale(s,a,o,t,e,s);r[2]*=t,r[3]*=e}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Gs.svgRound(t)} ${Gs.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#pr;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Gs.svgRound(t[0])} ${Gs.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class an extends en{#Va;constructor(t){super(),this.#Va=t,super.updateProperties({fill:"none",stroke:ae._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??=this["stroke-width"],e*=this.#Va.realScale),super.updateSVGProperty(t,e)}clone(){const t=new an(this.#Va);return t.updateAll(this),t}}class on extends sn{static _type="ink";static _editorType=y.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(t,e){ae.initialize(t,e),this._defaultDrawingOptions=new an(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return dt(this,"typesMap",new Map([[A.INK_THICKNESS,"stroke-width"],[A.INK_COLOR,"stroke"],[A.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,n){return new nn(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,r){return rn.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){let s=null;if(t instanceof Fs){const{data:{inkLists:e,rect:i,rotation:n,id:r,color:a,opacity:o,borderStyle:{rawWidth:l},popupRef:h},parent:{page:{pageNumber:d}}}=t;s=t={annotationType:y.INK,color:Array.from(a),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:d-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:h}}const n=await super.deserialize(t,e,i);return n.annotationElementId=t.id||null,n._initialData=s,n}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:i}){this._drawingOptions=on.getDefaultDrawingOptions({stroke:St.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:i,rect:s}=this.serializeDraw(t),{_drawingOptions:{stroke:n,"stroke-opacity":r,"stroke-width":a}}=this,o={annotationType:y.INK,color:ae._colorManager.convert(n),opacity:r,thickness:a,paths:{lines:e,points:i},pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?o:this.annotationElementId&&!this.#Un(o)?null:(o.id=this.annotationElementId,o)}#Un(t){const{color:e,thickness:i,opacity:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some(((t,i)=>t!==e[i]))||t.thickness!==i||t.opacity!==s||t.pageIndex!==n}renderAnnotationElement(t){const{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e}),null}}class ln extends ae{#Ha=null;#za=null;#Ua=null;#$a=null;#Wa=null;#Ga="";#qa=null;#Xa=null;#Ka=!1;#Ya=!1;static _type="stamp";static _editorType=y.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#$a=t.bitmapUrl,this.#Wa=t.bitmapFile}static initialize(t,e){ae.initialize(t,e)}static get supportedTypes(){return dt(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((t=>`image/${t}`)))}static get supportedTypesStr(){return dt(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(y.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#Qa(t,e=!1){t?(this.#Ha=t.bitmap,e||(this.#za=t.id,this.#Ka=t.isSvg),t.file&&(this.#Ga=t.file.name),this.#Ja()):this.remove()}#Za(){if(this.#Ua=null,this._uiManager.enableWaiting(!1),this.#qa){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Ha)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Ha){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:s,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:s,width:n,height:r,channels:s.length/(n*r)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");const o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#to(){if(this.#za)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#za).then((t=>this.#Qa(t,!0))).finally((()=>this.#Za()));if(this.#$a){const t=this.#$a;return this.#$a=null,this._uiManager.enableWaiting(!0),void(this.#Ua=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#Qa(t))).finally((()=>this.#Za())))}if(this.#Wa){const t=this.#Wa;return this.#Wa=null,this._uiManager.enableWaiting(!0),void(this.#Ua=this._uiManager.imageManager.getFromFile(t).then((t=>this.#Qa(t))).finally((()=>this.#Za())))}const t=document.createElement("input");t.type="file",t.accept=ln.supportedTypesStr;const e=this._uiManager._signal;this.#Ua=new Promise((i=>{t.addEventListener("change",(async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#Qa(e)}else this.remove();i()}),{signal:e}),t.addEventListener("cancel",(()=>{this.remove(),i()}),{signal:e})})).finally((()=>this.#Za())),t.click()}remove(){this.#za&&(this.#Ha=null,this._uiManager.imageManager.deleteId(this.#za),this.#qa?.remove(),this.#qa=null,this.#Xa&&(clearTimeout(this.#Xa),this.#Xa=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#za&&null===this.#qa&&this.#to(),this.isAttachedToDOM||this.parent.add(this))):this.#za&&this.#to()}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#Ua||this.#Ha||this.#$a||this.#Wa||this.#za)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#Ha?this.#Ja():this.#to(),this.width&&!this.annotationElementId){const[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==this.#Xa&&clearTimeout(this.#Xa);this.#Xa=setTimeout((()=>{this.#Xa=null,this.#eo()}),200)}#Ja(){const{div:t}=this;let{width:e,height:i}=this.#Ha;const[s,n]=this.pageDimensions,r=.75;if(this.width)e=this.width*s,i=this.height*n;else if(e>r*s||i>r*n){const t=Math.min(r*s/e,r*n/i);e*=t,i*=t}const[a,o]=this.parentDimensions;this.setDims(e*a/s,i*o/n),this._uiManager.enableWaiting(!1);const l=this.#qa=document.createElement("canvas");l.setAttribute("role","img"),this.addContainer(l),this.width=e/s,this.height=i/n,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#eo(),this.#Ya||(this.parent.addUndoableEditor(this),this.#Ya=!0),this._reportTelemetry({action:"inserted_image"}),this.#Ga&&l.setAttribute("aria-label",this.#Ga)}copyCanvas(t,e,i=!1){t||(t=224);const{width:s,height:n}=this.#Ha,r=new Xt;let a=this.#Ha,o=s,l=n,h=null;if(e){if(s>e||n>e){const t=Math.min(e/s,e/n);o=Math.floor(s*t),l=Math.floor(n*t)}h=document.createElement("canvas");const t=h.width=Math.ceil(o*r.sx),i=h.height=Math.ceil(l*r.sy);this.#Ka||(a=this.#io(t,i));const d=h.getContext("2d");d.filter=this._uiManager.hcmFilter;let c="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(c="#8f8f9d",u="#42414d");const p=15,g=p*r.sx,f=p*r.sy,m=new OffscreenCanvas(2*g,2*f),b=m.getContext("2d");b.fillStyle=c,b.fillRect(0,0,2*g,2*f),b.fillStyle=u,b.fillRect(0,0,g,f),b.fillRect(g,f,g,f),d.fillStyle=d.createPattern(m,"repeat"),d.fillRect(0,0,t,i),d.drawImage(a,0,0,a.width,a.height,0,0,t,i)}let d=null;if(i){let e,i;if(r.symmetric&&a.width<t&&a.height<t)e=a.width,i=a.height;else if(a=this.#Ha,s>t||n>t){const r=Math.min(t/s,t/n);e=Math.floor(s*r),i=Math.floor(n*r),this.#Ka||(a=this.#io(e,i))}const o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(a,0,0,a.width,a.height,0,0,e,i),d={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:d}}#io(t,e){const{width:i,height:s}=this.#Ha;let n=i,r=s,a=this.#Ha;for(;n>2*t||r>2*e;){const i=n,s=r;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));const o=new OffscreenCanvas(n,r);o.getContext("2d").drawImage(a,0,0,i,s,0,0,n,r),a=o.transferToImageBitmap()}return a}#eo(){const[t,e]=this.parentDimensions,{width:i,height:s}=this,n=new Xt,r=Math.ceil(i*t*n.sx),a=Math.ceil(s*e*n.sy),o=this.#qa;if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;const l=this.#Ka?this.#Ha:this.#io(r,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,r,a)}getImageForAltText(){return this.#qa}#so(t){if(t){if(this.#Ka){const t=this._uiManager.imageManager.getSvgUrl(this.#za);if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=this.#Ha);return t.getContext("2d").drawImage(this.#Ha,0,0),t.toDataURL()}if(this.#Ka){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*It.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*It.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(this.#Ha,0,0,this.#Ha.width,this.#Ha.height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(this.#Ha)}static async deserialize(t,e,i){let s=null;if(t instanceof Hs){const{data:{rect:n,rotation:r,id:a,structParent:o,popupRef:l},container:h,parent:{page:{pageNumber:d}}}=t,c=h.querySelector("canvas"),u=i.imageManager.getFromCanvas(h.id,c);c.remove();const p=(await e._structTree.getAriaAttributes(`${Tt}${a}`))?.get("aria-label")||"";s=t={annotationType:y.STAMP,bitmapId:u.id,bitmap:u.bitmap,pageIndex:d-1,rect:n.slice(0),rotation:r,id:a,deleted:!1,accessibilityData:{decorative:!1,altText:p},isSvg:!1,structParent:o,popupRef:l}}const n=await super.deserialize(t,e,i),{rect:r,bitmap:a,bitmapUrl:o,bitmapId:l,isSvg:h,accessibilityData:d}=t;l&&i.imageManager.isValidId(l)?(n.#za=l,a&&(n.#Ha=a)):n.#$a=o,n.#Ka=h;const[c,u]=n.pageDimensions;return n.width=(r[2]-r[0])/c,n.height=(r[3]-r[1])/u,n.annotationElementId=t.id||null,d&&(n.altTextData=d),n._initialData=s,n.#Ya=!!s,n}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:y.STAMP,bitmapId:this.#za,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#Ka,structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=this.#so(!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(i.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const t=this.#Un(i);if(t.isSame)return null;t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,null===e)return i;e.stamps||=new Map;const r=this.#Ka?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#za)){if(this.#Ka){const t=e.stamps.get(this.#za);r>t.area&&(t.area=r,t.serialized.bitmap.close(),t.serialized.bitmap=this.#so(!1))}}else e.stamps.set(this.#za,{area:r,serialized:i}),i.bitmap=this.#so(!1);return i}#Un(t){const{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&s&&n,isSameAltText:n}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}let hn=class t{#En;#no=!1;#ro=null;#ao=null;#oo=null;#lo=new Map;#ho=!1;#do=!1;#co=!1;#uo=null;#po=null;#go=null;#fo=null;#f;static _initialized=!1;static#H=new Map([Ws,on,ln,tn].map((t=>[t._editorType,t])));constructor({uiManager:e,pageIndex:i,div:s,structTreeLayer:n,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:d}){const c=[...t.#H.values()];if(!t._initialized){t._initialized=!0;for(const t of c)t.initialize(d,e)}e.registerEditorTypes(c),this.#f=e,this.pageIndex=i,this.div=s,this.#En=r,this.#ro=a,this.viewport=h,this.#go=l,this.drawLayer=o,this._structTree=n,this.#f.addLayer(this)}get isEmpty(){return 0===this.#lo.size}get isInvisible(){return this.isEmpty&&this.#f.getMode()===y.NONE}updateToolbar(t){this.#f.updateToolbar(t)}updateMode(e=this.#f.getMode()){switch(this.#mo(),e){case y.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case y.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case y.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:i}=this.div;for(const s of t.#H.values())i.toggle(`${s._type}Editing`,e===s._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#go?.div}setEditingState(t){this.#f.setEditingState(t)}addCommands(t){this.#f.addCommands(t)}cleanUndoStack(t){this.#f.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#ro?.div.classList.toggle("disabled",!t)}async enable(){this.#co=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const e of this.#lo.values())e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#f.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(!this.#ro)return void(this.#co=!1);const e=this.#ro.getEditableAnnotations();for(const i of e){if(i.hide(),this.#f.isDeletedAnnotationElement(i.data.id))continue;if(t.has(i.data.id))continue;const e=await this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}this.#co=!1}disable(){this.#do=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,i=new Map;for(const t of this.#lo.values())t.disableEditing(),t.annotationElementId&&(null===t.serialize()?(i.set(t.annotationElementId,t),this.getEditableAnnotation(t.annotationElementId)?.show(),t.remove()):e.set(t.annotationElementId,t));if(this.#ro){const t=this.#ro.getEditableAnnotations();for(const s of t){const{id:t}=s.data;if(this.#f.isDeletedAnnotationElement(t))continue;let n=i.get(t);n?(n.resetAnnotationElement(s),n.show(!1),s.show()):(n=e.get(t),n&&(this.#f.addChangedExistingAnnotation(n),n.renderAnnotationElement(s)&&n.show(!1)),s.show())}}this.#mo(),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const e of t.#H.values())s.remove(`${e._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#do=!1}getEditableAnnotation(t){return this.#ro?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#f.getActive()!==t&&this.#f.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#go?.div&&!this.#fo){this.#fo=new AbortController;const t=this.#f.combinedSignal(this.#fo);this.#go.div.addEventListener("pointerdown",this.#bo.bind(this),{signal:t}),this.#go.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#go?.div&&this.#fo&&(this.#fo.abort(),this.#fo=null,this.#go.div.classList.remove("highlighting"))}#bo(t){this.#f.unselectAll();const{target:e}=t;if(e===this.#go.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#go.div.contains(e)){const{isMac:e}=_t.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#f.showAllEditors("highlight",!0,!0),this.#go.div.classList.add("free"),this.toggleDrawing(),tn.startHighlighting(this,"ltr"===this.#f.direction,{target:this.#go.div,x:t.x,y:t.y}),this.#go.div.addEventListener("pointerup",(()=>{this.#go.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#f._signal}),t.preventDefault()}}enableClick(){if(this.#ao)return;this.#ao=new AbortController;const t=this.#f.combinedSignal(this.#ao);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#ao?.abort(),this.#ao=null}attach(t){this.#lo.set(t.id,t);const{annotationElementId:e}=t;e&&this.#f.isDeletedAnnotationElement(e)&&this.#f.removeDeletedAnnotationElement(t)}detach(t){this.#lo.delete(t.id),this.#En?.removePointerInTextLayer(t.contentDiv),!this.#do&&t.annotationElementId&&this.#f.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#f.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#f.addDeletedAnnotationElement(t.annotationElementId),ae.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),this.#f.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#co),this.#f.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#oo&&(t._focusEventsAllowed=!1,this.#oo=setTimeout((()=>{this.#oo=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this.#f._signal}),e.focus())}),0)),t._structTreeParentId=this.#En?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return this.#f.getId()}get#vo(){return t.#H.get(this.#f.getMode())}combinedSignal(t){return this.#f.combinedSignal(t)}#wo(t){const e=this.#vo;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#vo?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#f.updateToolbar(t),this.#f.updateMode(t);const{offsetX:i,offsetY:s}=this.#yo(),n=this.getNextId(),r=this.#wo({parent:this,id:n,x:i,y:s,uiManager:this.#f,isCentered:!0,...e});r&&this.add(r)}async deserialize(e){return await(t.#H.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#f))||null}createAndAddNewEditor(t,e,i={}){const s=this.getNextId(),n=this.#wo({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#f,isCentered:e,...i});return n&&this.add(n),n}#yo(){const{x:t,y:e,width:i,height:s}=this.div.getBoundingClientRect(),n=Math.max(0,t),r=Math.max(0,e),a=(n+Math.min(window.innerWidth,t+i))/2-t,o=(r+Math.min(window.innerHeight,e+s))/2-e,[l,h]=this.viewport.rotation%180==0?[a,o]:[o,a];return{offsetX:l,offsetY:h}}addNewEditor(){this.createAndAddNewEditor(this.#yo(),!0)}setSelected(t){this.#f.setSelected(t)}toggleSelected(t){this.#f.toggleSelected(t)}unselect(t){this.#f.unselect(t)}pointerup(t){const{isMac:e}=_t.platform;0!==t.button||t.ctrlKey&&e||t.target===this.div&&this.#ho&&(this.#ho=!1,this.#vo?.isDrawer&&this.#vo.supportMultipleDrawings||(this.#no?this.#f.getMode()!==y.STAMP?this.createAndAddNewEditor(t,!1):this.#f.unselectAll():this.#no=!0))}pointerdown(t){if(this.#f.getMode()===y.HIGHLIGHT&&this.enableTextSelection(),this.#ho)return void(this.#ho=!1);const{isMac:e}=_t.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#ho=!0,this.#vo?.isDrawer)return void this.startDrawingSession(t);const i=this.#f.getActive();this.#no=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus(),this.#uo)return void this.#vo.startDrawing(this,this.#f,!1,t);this.#f.setCurrentDrawingSession(this),this.#uo=new AbortController;const e=this.#f.combinedSignal(this.#uo);this.div.addEventListener("blur",(({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#po=null,this.commitOrRemove())}),{signal:e}),this.#vo.startDrawing(this,this.#f,!1,t)}pause(t){if(t){const{activeElement:t}=document;this.div.contains(t)&&(this.#po=t)}else this.#po&&setTimeout((()=>{this.#po?.focus(),this.#po=null}),0)}endDrawingSession(t=!1){return this.#uo?(this.#f.setCurrentDrawingSession(null),this.#uo.abort(),this.#uo=null,this.#po=null,this.#vo.endDrawing(t)):null}findNewParent(t,e,i){const s=this.#f.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#uo&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#uo&&this.#vo.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#f.getActive()?.parent===this&&(this.#f.commitOrRemove(),this.#f.setActiveEditor(null)),this.#oo&&(clearTimeout(this.#oo),this.#oo=null);for(const t of this.#lo.values())this.#En?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#lo.clear(),this.#f.removeLayer(this)}#mo(){for(const t of this.#lo.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,qt(this.div,t);for(const t of this.#f.getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:t}){this.#f.commitOrRemove(),this.#mo();const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,qt(this.div,{rotation:i}),e!==i)for(const t of this.#lo.values())t.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#f.viewParameters.realScale}},dn=class t{#nn=null;#w=0;#Ao=new Map;#_o=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#nn){if(this.#nn!==t){if(this.#Ao.size>0)for(const e of this.#Ao.values())e.remove(),t.append(e);this.#nn=t}}else this.#nn=t}static get _svgFactory(){return dt(this,"_svgFactory",new cs)}static#xo(t,[e,i,s,n]){const{style:r}=t;r.top=100*i+"%",r.left=100*e+"%",r.width=100*s+"%",r.height=100*n+"%"}#So(){const e=t._svgFactory.create(1,1,!0);return this.#nn.append(e),e.setAttribute("aria-hidden",!0),e}#Co(e,i){const s=t._svgFactory.createElement("clipPath");e.append(s);const n=`clip_${i}`;s.setAttribute("id",n),s.setAttribute("clipPathUnits","objectBoundingBox");const r=t._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${i}`),r.classList.add("clip"),n}#Eo(t,e){for(const[i,s]of Object.entries(e))null===s?t.removeAttribute(i):t.setAttribute(i,s)}draw(e,i=!1,s=!1){const n=this.#w++,r=this.#So(),a=t._svgFactory.createElement("defs");r.append(a);const o=t._svgFactory.createElement("path");a.append(o);const l=`path_p${this.pageIndex}_${n}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),i&&this.#_o.set(n,o);const h=s?this.#Co(a,l):null,d=t._svgFactory.createElement("use");return r.append(d),d.setAttribute("href",`#${l}`),this.updateProperties(r,e),this.#Ao.set(n,r),{id:n,clipPathId:`url(#${h})`}}drawOutline(e,i){const s=this.#w++,n=this.#So(),r=t._svgFactory.createElement("defs");n.append(r);const a=t._svgFactory.createElement("path");r.append(a);const o=`path_p${this.pageIndex}_${s}`;let l;if(a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),i){const e=t._svgFactory.createElement("mask");r.append(e),l=`mask_p${this.pageIndex}_${s}`,e.setAttribute("id",l),e.setAttribute("maskUnits","objectBoundingBox");const i=t._svgFactory.createElement("rect");e.append(i),i.setAttribute("width","1"),i.setAttribute("height","1"),i.setAttribute("fill","white");const n=t._svgFactory.createElement("use");e.append(n),n.setAttribute("href",`#${o}`),n.setAttribute("stroke","none"),n.setAttribute("fill","black"),n.setAttribute("fill-rule","nonzero"),n.classList.add("mask")}const h=t._svgFactory.createElement("use");n.append(h),h.setAttribute("href",`#${o}`),l&&h.setAttribute("mask",`url(#${l})`);const d=h.cloneNode();return n.append(d),h.classList.add("mainOutline"),d.classList.add("secondaryOutline"),this.updateProperties(n,e),this.#Ao.set(s,n),s}finalizeDraw(t,e){this.#_o.delete(t),this.updateProperties(t,e)}updateProperties(e,i){if(!i)return;const{root:s,bbox:n,rootClass:r,path:a}=i,o="number"==typeof e?this.#Ao.get(e):e;if(o){if(s&&this.#Eo(o,s),n&&t.#xo(o,n),r){const{classList:t}=o;for(const[e,i]of Object.entries(r))t.toggle(e,i)}if(a){const t=o.firstChild.firstChild;this.#Eo(t,a)}}}updateParent(t,e){if(e===this)return;const i=this.#Ao.get(t);i&&(e.#nn.append(i),this.#Ao.delete(t),e.#Ao.set(t,i))}remove(t){this.#_o.delete(t),null!==this.#nn&&(this.#Ao.get(t).remove(),this.#Ao.delete(t))}destroy(){this.#nn=null;for(const t of this.#Ao.values())t.remove();this.#Ao.clear(),this.#_o.clear()}};globalThis.pdfjsTestingUtils={HighlightOutliner:Ks};var cn=a.AnnotationEditorParamsType,un=a.AnnotationEditorType,pn=a.AnnotationMode,gn=a.GlobalWorkerOptions,fn=a.PDFDateString,mn=a.PixelsPerInch,bn=a.RenderingCancelledException,vn=a.getDocument,wn=a.getPdfFilenameFromUrl,yn=a.getXfaPageViewport,An={d:(t,e)=>{for(var i in e)An.o(e,i)&&!An.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},_n=globalThis.pdfjsViewer={};An.d(_n,{AnnotationLayerBuilder:()=>da,DownloadManager:()=>ua,EventBus:()=>fa,FindState:()=>er,GenericL10n:()=>Lo,LinkTarget:()=>mr,PDFFindController:()=>fr,PDFHistory:()=>Do,PDFLinkService:()=>br,PDFPageView:()=>el,PDFScriptingManager:()=>nl,PDFSinglePageViewer:()=>ul,PDFViewer:()=>cl,ProgressBar:()=>Un,RenderingStates:()=>xn,ScrollMode:()=>Ln,SimpleLinkService:()=>vr,SpreadMode:()=>kn,StructTreeLayerBuilder:()=>Xo,TextLayerBuilder:()=>Qo,XfaLayerBuilder:()=>Jo,parseQueryString:()=>Rn});const xn={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},Sn=0,Cn=1,En=2,Pn=3,Tn=0,Mn=1,In=2,Ln={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},kn={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};function Dn(t,e,i=!1){let s=t.offsetParent;if(!s)return void console.error("offsetParent is not set -- cannot scroll");let n=t.offsetTop+t.clientTop,r=t.offsetLeft+t.clientLeft;for(;s.clientHeight===s.scrollHeight&&s.clientWidth===s.scrollWidth||i&&(s.classList.contains("markedContent")||"hidden"===getComputedStyle(s).overflow);)if(n+=s.offsetTop,r+=s.offsetLeft,s=s.offsetParent,!s)return;e&&(void 0!==e.top&&(n+=e.top),void 0!==e.left&&(r+=e.left,s.scrollLeft=r)),s.scrollTop=n}function Rn(t){const e=new Map;for(const[i,s]of new URLSearchParams(t))e.set(i.toLowerCase(),s);return e}const Nn=/[\x00-\x1F]/g;function Fn(t,e=!1){return Nn.test(t)?e?t.replaceAll(Nn,(t=>"\0"===t?"":" ")):t.replaceAll("\0",""):t}function On(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 Bn(t){if(Math.floor(t)===t)return[t,1];const e=1/t;if(e>8)return[1,8];if(Math.floor(e)===e)return[1,e];const i=t>1?e:t;let s,n=0,r=1,a=1,o=1;for(;;){const t=n+a,e=r+o;if(e>8)break;i<=t/e?(a=t,o=e):(n=t,r=e)}return s=i-n/r<a/o-i?i===t?[n,r]:[r,n]:i===t?[a,o]:[o,a],s}function jn(t,e){return t-t%e}function Vn(t){return Number.isInteger(t)&&t%90==0}function Hn(t){return t.width<=t.height}new Promise((function(t){window.requestAnimationFrame(t)}));const zn=document.documentElement.style;let Un=class{#Po=null;#To=null;#Mo=0;#Io=null;#wi=!0;constructor(t){this.#Po=t.classList,this.#Io=t.style}get percent(){return this.#Mo}set percent(t){var e,i,s;this.#Mo=(e=t,i=0,s=100,Math.min(Math.max(e,i),s)),isNaN(t)?this.#Po.add("indeterminate"):(this.#Po.remove("indeterminate"),this.#Io.setProperty("--progressBar-percent",`${this.#Mo}%`))}setWidth(t){if(!t)return;const e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&this.#Io.setProperty("--progressBar-end-offset",`${e}px`)}setDisableAutoFetch(t=5e3){100===this.#Mo||isNaN(this.#Mo)||(this.#To&&clearTimeout(this.#To),this.show(),this.#To=setTimeout((()=>{this.#To=null,this.hide()}),t))}hide(){this.#wi&&(this.#wi=!1,this.#Po.add("hidden"))}show(){this.#wi||(this.#wi=!0,this.#Po.remove("hidden"))}};const $n=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}(),Wn=0,Gn=1,qn=2,Xn=3,Kn=4,Yn=5,Qn=6,Jn=7;function Zn(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)?Wn:function(t){return t>=97&&t<=122||t>=65&&t<=90}(t)||function(t){return t>=48&&t<=57}(t)||95===t?Gn:qn:function(t){return 3584==(65408&t)}(t)?Jn:160===t?Wn:Gn:function(t){return t>=13312&&t<=40959||t>=63744&&t<=64255}(t)?Xn:function(t){return t>=12448&&t<=12543}(t)?Kn:function(t){return t>=12352&&t<=12447}(t)?Yn:function(t){return t>=65376&&t<=65439}(t)?Qn:Gn}let tr;const er={FOUND:0,NOT_FOUND:1,WRAPPED:2,PENDING:3},ir={"‐":"-","‘":"'","’":"'","‚":"'","‛":"'","“":'"',"”":'"',"„":'"',"‟":'"',"¼":"1/4","½":"1/2","¾":"3/4"},sr=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 nr;const rr=/\p{M}+/gu,ar=/([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu,or=/([^\p{M}])\p{M}*$/u,lr=/^\p{M}*([^\p{M}])/u,hr=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,dr=new Map,cr=new Map;let ur=null,pr=null;function gr(t){const e=[];let i,s;for(;null!==(i=hr.exec(t));){let{index:t}=i;for(const s of i[0]){let i=dr.get(s);i||(i=s.normalize("NFD").length,dr.set(s,i)),e.push([i,t++])}}if(0===e.length&&ur)s=ur;else if(e.length>0&&pr)s=pr;else{const t=`([${Object.keys(ir).join("")}])|([${tr||=" ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩",tr}])|(${"(?:゙|゚)"}\\n)|(\\p{M}+(?:-\\n)?)|(${"\\p{Ll}-\\n\\p{Lu}"})|(\\S-\\n)|(${"(?:\\p{Ideographic}|[-ヿ])"}\\n)|(\\n)`;s=0===e.length?ur=new RegExp(t+"|(\\u0000)","gum"):pr=new RegExp(t+"|([\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f])","gum")}const n=[];for(;null!==(i=rr.exec(t));)n.push([i[0].length,i.index]);let r=t.normalize("NFD");const a=[0,0];let o=0,l=0,h=0,d=0,c=0,u=!1;r=r.replace(s,((t,i,s,r,p,g,f,m,b,v,w)=>{if(w-=d,i){const t=ir[i],e=t.length;for(let t=1;t<e;t++)a.push(w-h+t,h-t);return h-=e-1,t}if(s){let t=cr.get(s);t||(t=s.normalize("NFKC"),cr.set(s,t));const e=t.length;for(let t=1;t<e;t++)a.push(w-h+t,h-t);return h-=e-1,t}if(r)return u=!0,w+c===n[o]?.[1]?++o:(a.push(w-1-h+1,h-1),h-=1,d+=1),a.push(w-h+1,h),d+=1,c+=1,r.charAt(0);if(p){const t=p.endsWith("\n"),e=t?p.length-2:p.length;u=!0;let i=e;w+c===n[o]?.[1]&&(i-=n[o][0],++o);for(let t=1;t<=i;t++)a.push(w-1-h+t,h-t);return h-=i,d+=i,t?(w+=e-1,a.push(w-h+1,1+h),h+=1,d+=1,c+=1,p.slice(0,e)):p}if(g)return d+=1,c+=1,g.replace("\n","");if(f){const t=f.length-2;return a.push(w-h+t,1+h),h+=1,d+=1,c+=1,f.slice(0,-2)}if(m){const t=m.length-1;return a.push(w-h+t,h),d+=1,c+=1,m.slice(0,-1)}if(b)return a.push(w-h+1,h-1),h-=1,d+=1,c+=1," ";if(w+c===e[l]?.[1]){const t=e[l][0]-1;++l;for(let e=1;e<=t;e++)a.push(w-(h-e),h-e);h-=t,d+=t}return v})),a.push(r.length,h);const p=new Uint32Array(a.length>>1),g=new Int32Array(a.length>>1);for(let t=0,e=a.length;t<e;t+=2)p[t>>1]=a[t],g[t>>1]=a[t+1];return[r,[p,g],u]}class fr{#Lo=null;#ko=!0;#Do=0;constructor({linkService:t,eventBus:e,updateMatchesCountOnProgress:i=!0}){this._linkService=t,this._eventBus=e,this.#ko=i,this.onIsPageVisible=null,this.#Ro(),e._on("find",this.#No.bind(this)),e._on("findbarclose",this.#Fo.bind(this))}get highlightMatches(){return this._highlightMatches}get pageMatches(){return this._pageMatches}get pageMatchesLength(){return this._pageMatchesLength}get selected(){return this._selected}get state(){return this.#Lo}setDocument(t){this._pdfDocument&&this.#Ro(),t&&(this._pdfDocument=t,this._firstPageCapability.resolve())}#No(t){if(!t)return;const e=this._pdfDocument,{type:i}=t;(null===this.#Lo||this.#Oo(t))&&(this._dirtyMatch=!0),this.#Lo=t,"highlightallchange"!==i&&this.#Bo(er.PENDING),this._firstPageCapability.promise.then((()=>{if(!this._pdfDocument||e&&this._pdfDocument!==e)return;this.#Bn();const t=!this._highlightMatches,s=!!this._findTimeout;this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),i?this._dirtyMatch?this.#jo():"again"===i?(this.#jo(),t&&this.#Lo.highlightAll&&this.#Vo()):"highlightallchange"===i?(s?this.#jo():this._highlightMatches=!0,this.#Vo()):this.#jo():this._findTimeout=setTimeout((()=>{this.#jo(),this._findTimeout=null}),250)}))}scrollMatchIntoView({element:t=null,selectedLeft:e=0,pageIndex:i=-1,matchIndex:s=-1}){if(!this._scrollMatches||!t)return;if(-1===s||s!==this._selected.matchIdx)return;if(-1===i||i!==this._selected.pageIdx)return;this._scrollMatches=!1;Dn(t,{top:-50,left:e+-400},!0)}#Ro(){this._highlightMatches=!1,this._scrollMatches=!1,this._pdfDocument=null,this._pageMatches=[],this._pageMatchesLength=[],this.#Do=0,this.#Lo=null,this._selected={pageIdx:-1,matchIdx:-1},this._offset={pageIdx:null,matchIdx:null,wrapped:!1},this._extractTextPromises=[],this._pageContents=[],this._pageDiffs=[],this._hasDiacritics=[],this._matchesCountTotal=0,this._pagesToSearch=null,this._pendingFindMatches=new Set,this._resumePageIdx=null,this._dirtyMatch=!1,clearTimeout(this._findTimeout),this._findTimeout=null,this._firstPageCapability=Promise.withResolvers()}get#Ho(){const{query:t}=this.#Lo;return"string"==typeof t?(t!==this._rawQuery&&(this._rawQuery=t,[this._normalizedQuery]=gr(t)),this._normalizedQuery):(t||[]).filter((t=>!!t)).map((t=>gr(t)[0]))}#Oo(t){const e=t.query,i=this.#Lo.query,s=typeof e;if(s!==typeof i)return!0;if("string"===s){if(e!==i)return!0}else if(JSON.stringify(e)!==JSON.stringify(i))return!0;switch(t.type){case"again":const t=this._selected.pageIdx+1,e=this._linkService;return t>=1&&t<=e.pagesCount&&t!==e.page&&!(this.onIsPageVisible?.(t)??1);case"highlightallchange":return!1}return!0}#zo(t,e,i){let s=t.slice(0,e).match(or);if(s){const i=t.charCodeAt(e),n=s[1].charCodeAt(0);if(Zn(i)===Zn(n))return!1}if(s=t.slice(e+i).match(lr),s){const n=t.charCodeAt(e+i-1),r=s[1].charCodeAt(0);if(Zn(n)===Zn(r))return!1}return!0}#Uo(t,e){const{matchDiacritics:i}=this.#Lo;let s=!1;const n="[ ]*";return(t=t.replaceAll(ar,((t,n,r,a,o,l)=>n?`[ ]*\\${n}[ ]*`:r?`[ ]*${r}[ ]*`:a?"[ ]+":i?o||l:o?sr.has(o.charCodeAt(0))?o:"":e?(s=!0,`${l}\\p{M}*`):l))).endsWith(n)&&(t=t.slice(0,t.length-4)),i&&e&&(nr||=String.fromCharCode(...sr),s=!0,t=`${t}(?=[${nr}]|[^\\p{M}]|$)`),[s,t]}#$o(t){const e=this.#Ho;if(0===e.length)return;const i=this._pageContents[t],s=this.match(e,i,t),n=this._pageMatches[t]=[],r=this._pageMatchesLength[t]=[],a=this._pageDiffs[t];s?.forEach((({index:t,length:e})=>{const[i,s]=function(t,e,i){if(!t)return[e,i];const[s,n]=t,r=e,a=e+i-1;let o=On(s,(t=>t>=r));s[o]>r&&--o;let l=On(s,(t=>t>=a),o);s[l]>a&&--l;const h=r+n[o];return[h,a+n[l]+1-h]}(a,t,e);s&&(n.push(i),r.push(s))})),this.#Lo.highlightAll&&this.#Wo(t),this._resumePageIdx===t&&(this._resumePageIdx=null,this.#Go());const o=n.length;this._matchesCountTotal+=o,this.#ko?o>0&&this.#qo():++this.#Do===this._linkService.pagesCount&&this.#qo()}match(t,e,i){const s=this._hasDiacritics[i];let n=!1;if("string"==typeof t?[n,t]=this.#Uo(t,s):t=t.sort().reverse().map((t=>{const[e,i]=this.#Uo(t,s);return n||=e,`(${i})`})).join("|"),!t)return;const{caseSensitive:r,entireWord:a}=this.#Lo;t=new RegExp(t,`g${n?"u":""}${r?"":"i"}`);const o=[];let l;for(;null!==(l=t.exec(e));)a&&!this.#zo(e,l.index,l[0].length)||o.push({index:l.index,length:l[0].length});return o}#Bn(){if(this._extractTextPromises.length>0)return;let t=Promise.resolve();const e={disableNormalization:!0};for(let i=0,s=this._linkService.pagesCount;i<s;i++){const{promise:s,resolve:n}=Promise.withResolvers();this._extractTextPromises[i]=s,t=t.then((()=>this._pdfDocument.getPage(i+1).then((t=>t.getTextContent(e))).then((t=>{const e=[];for(const i of t.items)e.push(i.str),i.hasEOL&&e.push("\n");[this._pageContents[i],this._pageDiffs[i],this._hasDiacritics[i]]=gr(e.join("")),n()}),(t=>{console.error(`Unable to get text content for page ${i+1}`,t),this._pageContents[i]="",this._pageDiffs[i]=null,this._hasDiacritics[i]=!1,n()}))))}}#Wo(t){this._scrollMatches&&this._selected.pageIdx===t&&(this._linkService.page=t+1),this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:t})}#Vo(){this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:-1})}#jo(){const t=this.#Lo.findPrevious,e=this._linkService.page-1,i=this._linkService.pagesCount;if(this._highlightMatches=!0,this._dirtyMatch){this._dirtyMatch=!1,this._selected.pageIdx=this._selected.matchIdx=-1,this._offset.pageIdx=e,this._offset.matchIdx=null,this._offset.wrapped=!1,this._resumePageIdx=null,this._pageMatches.length=0,this._pageMatchesLength.length=0,this.#Do=0,this._matchesCountTotal=0,this.#Vo();for(let t=0;t<i;t++)this._pendingFindMatches.has(t)||(this._pendingFindMatches.add(t),this._extractTextPromises[t].then((()=>{this._pendingFindMatches.delete(t),this.#$o(t)})))}if(0===this.#Ho.length)return void this.#Bo(er.FOUND);if(this._resumePageIdx)return;const s=this._offset;if(this._pagesToSearch=i,null!==s.matchIdx){const e=this._pageMatches[s.pageIdx].length;if(!t&&s.matchIdx+1<e||t&&s.matchIdx>0)return s.matchIdx=t?s.matchIdx-1:s.matchIdx+1,void this.#Xo(!0);this.#Ko(t)}this.#Go()}#Yo(t){const e=this._offset,i=t.length,s=this.#Lo.findPrevious;return i?(e.matchIdx=s?i-1:0,this.#Xo(!0),!0):(this.#Ko(s),!!(e.wrapped&&(e.matchIdx=null,this._pagesToSearch<0))&&(this.#Xo(!1),!0))}#Go(){null!==this._resumePageIdx&&console.error("There can only be one pending page.");let t=null;do{const e=this._offset.pageIdx;if(t=this._pageMatches[e],!t){this._resumePageIdx=e;break}}while(!this.#Yo(t))}#Ko(t){const e=this._offset,i=this._linkService.pagesCount;e.pageIdx=t?e.pageIdx-1:e.pageIdx+1,e.matchIdx=null,this._pagesToSearch--,(e.pageIdx>=i||e.pageIdx<0)&&(e.pageIdx=t?i-1:0,e.wrapped=!0)}#Xo(t=!1){let e=er.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?er.WRAPPED:er.FOUND,-1!==t&&t!==this._selected.pageIdx&&this.#Wo(t)}this.#Bo(e,this.#Lo.findPrevious),-1!==this._selected.pageIdx&&(this._scrollMatches=!0,this.#Wo(this._selected.pageIdx))}#Fo(t){const e=this._pdfDocument;this._firstPageCapability.promise.then((()=>{!this._pdfDocument||e&&this._pdfDocument!==e||(this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),this._resumePageIdx&&(this._resumePageIdx=null,this._dirtyMatch=!0),this.#Bo(er.FOUND),this._highlightMatches=!1,this.#Vo())}))}#Qo(){const{pageIdx:t,matchIdx:e}=this._selected;let i=0,s=this._matchesCountTotal;if(-1!==e){for(let e=0;e<t;e++)i+=this._pageMatches[e]?.length||0;i+=e+1}return(i<1||i>s)&&(i=s=0),{current:i,total:s}}#qo(){this._eventBus.dispatch("updatefindmatchescount",{source:this,matchesCount:this.#Qo()})}#Bo(t,e=!1){(this.#ko||this.#Do===this._linkService.pagesCount&&t!==er.PENDING)&&this._eventBus.dispatch("updatefindcontrolstate",{source:this,state:t,previous:e,entireWord:this.#Lo?.entireWord??null,matchesCount:this.#Qo(),rawQuery:this.#Lo?.query??null})}}const mr={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};class br{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?mr.BLANK:this.externalLinkTarget,n=this.externalLinkRel;this.externalLinkEnabled?t.href=t.title=e:(t.href="",t.title=`Disabled: ${e}`,t.onclick=()=>!1);let r="";switch(s){case mr.NONE:break;case mr.SELF:r="_self";break;case mr.BLANK:r="_blank";break;case mr.PARENT:r="_parent";break;case mr.TOP:r="_top"}t.target=r,t.rel="string"==typeof n?n:"noopener noreferrer nofollow"}getDestinationHash(t){if("string"==typeof t){if(t.length>0)return this.getAnchorUrl("#"+escape(t))}else if(Array.isArray(t)){const e=JSON.stringify(t);if(e.length>0)return this.getAnchorUrl("#"+escape(e))}return this.getAnchorUrl("")}getAnchorUrl(t){return this.baseUrl?this.baseUrl+t:t}setHash(t){if(!this.pdfDocument)return;let e,i;if(t.includes("=")){const s=Rn(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||br.#Jo(i)?this.goToDestination(i):console.error(`PDFLinkService.setHash: "${unescape(t)}" is not a valid destination.`)}executeNamedAction(t){if(this.pdfDocument){switch(t){case"GoBack":this.pdfHistory?.back();break;case"GoForward":this.pdfHistory?.forward();break;case"NextPage":this.pdfViewer.nextPage();break;case"PrevPage":this.pdfViewer.previousPage();break;case"LastPage":this.page=this.pagesCount;break;case"FirstPage":this.page=1}this.eventBus.dispatch("namedaction",{source:this,action:t})}}async executeSetOCGState(t){if(!this.pdfDocument)return;const e=this.pdfDocument,i=await this.pdfViewer.optionalContentConfigPromise;e===this.pdfDocument&&(i.setOCGState(t),this.pdfViewer.optionalContentConfigPromise=Promise.resolve(i))}static#Jo(t){if(!Array.isArray(t)||t.length<2)return!1;const[e,i,...s]=t;if(!("object"==typeof e&&Number.isInteger(e?.num)&&Number.isInteger(e?.gen)||Number.isInteger(e)))return!1;if("object"!=typeof i||"string"!=typeof i?.name)return!1;const n=s.length;let r=!0;switch(i.name){case"XYZ":if(n<2||n>3)return!1;break;case"Fit":case"FitB":return 0===n;case"FitH":case"FitBH":case"FitV":case"FitBV":if(n>1)return!1;break;case"FitR":if(4!==n)return!1;r=!1;break;default:return!1}for(const t of s)if(!("number"==typeof t||r&&null===t))return!1;return!0}}class vr extends br{setDocument(t,e=null){}}const{AbortException:wr,AnnotationEditorLayer:yr,AnnotationEditorParamsType:Ar,AnnotationEditorType:_r,AnnotationEditorUIManager:xr,AnnotationLayer:Sr,AnnotationMode:Cr,build:Er,ColorPicker:Pr,createValidAbsoluteUrl:Tr,DOMSVGFactory:Mr,DrawLayer:Ir,FeatureTest:Lr,fetchData:kr,getDocument:Dr,getFilenameFromUrl:Rr,getPdfFilenameFromUrl:Nr,getXfaPageViewport:Fr,GlobalWorkerOptions:Or,ImageKind:Br,InvalidPDFException:jr,isDataScheme:Vr,isPdfFile:Hr,MissingPDFException:zr,noContextMenu:Ur,normalizeUnicode:$r,OPS:Wr,OutputScale:Gr,PasswordResponses:qr,PDFDataRangeTransport:Xr,PDFDateString:Kr,PDFWorker:Yr,PermissionFlag:Qr,PixelsPerInch:Jr,RenderingCancelledException:Zr,setLayerDimensions:ta,shadow:ea,stopEvent:ia,TextLayer:sa,TouchManager:na,UnexpectedResponseException:ra,Util:aa,VerbosityLevel:oa,version:la,XfaLayer:ha}=globalThis.pdfjsLib;class da{#Zo=null;#tl=null;constructor({pdfPage:t,linkService:e,downloadManager:i,annotationStorage:s=null,imageResourcesPath:n="",renderForms:r=!0,enableScripting:a=!1,hasJSActionsPromise:o=null,fieldObjectsPromise:l=null,annotationCanvasMap:h=null,accessibilityManager:d=null,annotationEditorUIManager:c=null,onAppend:u=null}){this.pdfPage=t,this.linkService=e,this.downloadManager=i,this.imageResourcesPath=n,this.renderForms=r,this.annotationStorage=s,this.enableScripting=a,this._hasJSActionsPromise=o||Promise.resolve(!1),this._fieldObjectsPromise=l||Promise.resolve(null),this._annotationCanvasMap=h,this._accessibilityManager=d,this._annotationEditorUIManager=c,this.#Zo=u,this.annotationLayer=null,this.div=null,this._cancelled=!1,this._eventBus=e.eventBus}async render(t,e,i="display"){if(this.div){if(this._cancelled||!this.annotationLayer)return;return void this.annotationLayer.update({viewport:t.clone({dontFlip:!0})})}const[s,n,r]=await Promise.all([this.pdfPage.getAnnotations({intent:i}),this._hasJSActionsPromise,this._fieldObjectsPromise]);if(this._cancelled)return;const a=this.div=document.createElement("div");a.className="annotationLayer",this.#Zo?.(a),0!==s.length?(this.annotationLayer=new Sr({div:a,accessibilityManager:this._accessibilityManager,annotationCanvasMap:this._annotationCanvasMap,annotationEditorUIManager:this._annotationEditorUIManager,page:this.pdfPage,viewport:t.clone({dontFlip:!0}),structTreeLayer:e?.structTreeLayer||null}),await this.annotationLayer.render({annotations:s,imageResourcesPath:this.imageResourcesPath,renderForms:this.renderForms,linkService:this.linkService,downloadManager:this.downloadManager,annotationStorage:this.annotationStorage,enableScripting:this.enableScripting,hasJSActions:n,fieldObjects:r}),this.linkService.isInPresentationMode&&this.#el(Pn),this.#tl||(this.#tl=new AbortController,this._eventBus?._on("presentationmodechanged",(t=>{this.#el(t.state)}),{signal:this.#tl.signal}))):this.hide()}cancel(){this._cancelled=!0,this.#tl?.abort(),this.#tl=null}hide(){this.div&&(this.div.hidden=!0)}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}#el(t){if(!this.div)return;let e=!1;switch(t){case Pn:e=!0;break;case Cn:break;default:return}for(const t of this.div.childNodes)t.hasAttribute("data-internal-link")||(t.inert=e)}}function ca(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 ua{#il=new WeakMap;downloadData(t,e,i){ca(URL.createObjectURL(new Blob([t],{type:i})),e)}openOrDownloadData(t,e,i=null){const s=Hr(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(!Tr(e,"http://example.com"))return void console.error(`download - not a valid URL: ${e}`);s=e+"#pdfjs.action=download"}ca(s,i)}}const pa="event",ga="timeout";class fa{#As=Object.create(null);on(t,e,i=null){this._on(t,e,{external:!0,once:i?.once,signal:i?.signal})}off(t,e,i=null){this._off(t,e)}dispatch(t,e){const i=this.#As[t];if(!i||0===i.length)return;let s;for(const{listener:n,external:r,once:a}of i.slice(0))a&&this._off(t,n),r?(s||=[]).push(n):n(e);if(s){for(const t of s)t(e);s=null}}_on(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){const{signal:n}=i;if(n.aborted)return void console.error("Cannot use an `aborted` signal.");const r=()=>this._off(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}(this.#As[t]||=[]).push({listener:e,external:!0===i?.external,once:!0===i?.once,rmAbort:s})}_off(t,e,i=null){const s=this.#As[t];if(s)for(let t=0,i=s.length;t<i;t++){const i=s[t];if(i.listener===e)return i.rmAbort?.(),void s.splice(t,1)}}}class ma{constructor(t){this.value=t}valueOf(){return this.value}}class ba extends ma{constructor(t="???"){super(t)}toString(t){return`{${this.value}}`}}class va extends ma{constructor(t,e={}){super(t),this.opts=e}toString(t){try{return t.memoizeIntlObject(Intl.NumberFormat,this.opts).format(this.value)}catch(e){return t.reportError(e),this.value.toString(10)}}}class wa extends ma{constructor(t,e={}){super(t),this.opts=e}toString(t){try{return t.memoizeIntlObject(Intl.DateTimeFormat,this.opts).format(this.value)}catch(e){return t.reportError(e),new Date(this.value).toISOString()}}}function ya(t,e,i){if(i===e)return!0;if(i instanceof va&&e instanceof va&&i.value===e.value)return!0;if(e instanceof va&&"string"==typeof i){if(i===t.memoizeIntlObject(Intl.PluralRules,e.opts).select(e.value))return!0}return!1}function Aa(t,e,i){return e[i]?Ca(t,e[i].value):(t.reportError(new RangeError("No default")),new ba)}function _a(t,e){const i=[],s=Object.create(null);for(const n of e)"narg"===n.type?s[n.name]=xa(t,n.value):i.push(xa(t,n));return{positional:i,named:s}}function xa(t,e){switch(e.type){case"str":return e.value;case"num":return new va(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 ba(`$${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 ba(`$${e}`);i=t.args[e]}if(i instanceof ma)return i;switch(typeof i){case"string":return i;case"number":return new va(i);case"object":if(i instanceof Date)return new wa(i.getTime());default:return t.reportError(new TypeError(`Variable type not supported: $${e}, ${typeof i}`)),new ba(`$${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 ba(e);if(i){const n=s.attributes[i];return n?Ca(t,n):(t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new ba(`${e}.${i}`))}if(s.value)return Ca(t,s.value);return t.reportError(new ReferenceError(`No value: ${e}`)),new ba(e)}(t,e);case"term":return function(t,{name:e,attr:i,args:s}){const n=`-${e}`,r=t.bundle._terms.get(n);if(!r)return t.reportError(new ReferenceError(`Unknown term: ${n}`)),new ba(n);if(i){const e=r.attributes[i];if(e){t.params=_a(t,s).named;const i=Ca(t,e);return t.params=null,i}return t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new ba(`${n}.${i}`)}t.params=_a(t,s).named;const a=Ca(t,r.value);return t.params=null,a}(t,e);case"func":return function(t,{name:e,args:i}){let s=t.bundle._functions[e];if(!s)return t.reportError(new ReferenceError(`Unknown function: ${e}()`)),new ba(`${e}()`);if("function"!=typeof s)return t.reportError(new TypeError(`Function ${e}() is not callable`)),new ba(`${e}()`);try{let e=_a(t,i);return s(e.positional,e.named)}catch(i){return t.reportError(i),new ba(`${e}()`)}}(t,e);case"select":return function(t,{selector:e,variants:i,star:s}){let n=xa(t,e);if(n instanceof ba)return Aa(t,i,s);for(const e of i){if(ya(t,n,xa(t,e.key)))return Ca(t,e.value)}return Aa(t,i,s)}(t,e);default:return new ba}}function Sa(t,e){if(t.dirty.has(e))return t.reportError(new RangeError("Cyclic reference")),new ba;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(xa(t,n).toString(t)),s&&i.push("")}else i.push(t.bundle._transform(n));return t.dirty.delete(e),i.join("")}function Ca(t,e){return"string"==typeof e?t.bundle._transform(e):Sa(t,e)}class Ea{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 Pa(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 Ta=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function Ma(t,e){let i=t[0];if(i instanceof ba)return new ba(`NUMBER(${i.valueOf()})`);if(i instanceof va)return new va(i.valueOf(),{...i.opts,...Pa(e,Ta)});if(i instanceof wa)return new va(i.valueOf(),{...Pa(e,Ta)});throw new TypeError("Invalid argument to NUMBER")}const Ia=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function La(t,e){let i=t[0];if(i instanceof ba)return new ba(`DATETIME(${i.valueOf()})`);if(i instanceof wa)return new wa(i.valueOf(),{...i.opts,...Pa(e,Ia)});if(i instanceof va)return new wa(i.valueOf(),{...Pa(e,Ia)});throw new TypeError("Invalid argument to DATETIME")}const ka=new Map;class Da{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:Ma,DATETIME:La,...e},this._useIsolating=i,this._transform=s,this._intls=function(t){const e=Array.isArray(t)?t.join(" "):t;let i=ka.get(e);return void 0===i&&(i=new Map,ka.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 Ea(this,i,e);try{return Sa(s,t).toString(s)}catch(t){if(s.errors&&t instanceof Error)return s.errors.push(t),(new ba).toString(s);throw t}}}const Ra=/^(-?[a-zA-Z][\w-]*) *= */gm,Na=/\.([a-zA-Z][\w-]*) *= */y,Fa=/\*?\[/y,Oa=/(-?[0-9]+(?:\.([0-9]+))?)/y,Ba=/([a-zA-Z][\w-]*)/y,ja=/([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y,Va=/^[A-Z][A-Z0-9_-]*$/,Ha=/([^{}\n\r]+)/y,za=/([^\\"\n\r]*)/y,Ua=/\\([\\"])/y,$a=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y,Wa=/^\n+/,Ga=/ +$/,qa=/ *\r?\n/g,Xa=/( *)$/,Ka=/{\s*/y,Ya=/\s*}/y,Qa=/\[\s*/y,Ja=/\s*] */y,Za=/\s*\(\s*/y,to=/\s*->\s*/y,eo=/\s*:\s*/y,io=/\s*,?\s*/y,so=/\s+/y;class no{constructor(t){this.body=[],Ra.lastIndex=0;let e=0;for(;;){let i=Ra.exec(t);if(null===i)break;e=Ra.lastIndex;try{this.body.push(o(i[1]))}catch(t){if(t instanceof SyntaxError)continue;throw t}}function i(i){return i.lastIndex=e,i.test(t)}function s(i,s){if(t[e]===i)return e++,!0;if(s)throw new s(`Expected ${i}`);return!1}function n(t,s){if(i(t))return e=t.lastIndex,!0;if(s)throw new s(`Expected ${t.toString()}`);return!1}function r(i){i.lastIndex=e;let s=i.exec(t);if(null===s)throw new SyntaxError(`Expected ${i.toString()}`);return e=i.lastIndex,s}function a(t){return r(t)[1]}function o(t){let e=l(),s=function(){let t=Object.create(null);for(;i(Na);){let e=a(Na),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(Ha)&&(s=a(Ha)),"{"===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,Wa),h([n],n.length)):s?v(s,Ga):null}function h(s=[],n){for(;;){if(i(Ha)){s.push(a(Ha));continue}if("{"===t[e]){s.push(d());continue}if("}"===t[e])throw new SyntaxError("Unbalanced closing brace");let r=b();if(!r)break;s.push(r),n=Math.min(n,r.length)}let r=s.length-1,o=s[r];"string"==typeof o&&(s[r]=v(o,Ga));let l=[];for(let t of s)t instanceof ro&&(t=t.value.slice(0,t.value.length-n)),t&&l.push(t);return l}function d(){n(Ka,SyntaxError);let t=c();if(n(Ya))return t;if(n(to)){let e=function(){let t,e=[],n=0;for(;i(Fa);){s("*")&&(t=n);let i=p(),r=l();if(null===r)throw new SyntaxError("Expected variant value");e[n++]={key:i,value:r}}if(0===n)return null;if(void 0===t)throw new SyntaxError("Expected default variant");return{variants:e,star:t}}();return n(Ya,SyntaxError),{type:"select",selector:t,...e}}throw new SyntaxError("Unclosed placeable")}function c(){if("{"===t[e])return d();if(i(ja)){let[,i,s,a=null]=r(ja);if("$"===i)return{type:"var",name:s};if(n(Za)){let r=function(){let i=[];for(;;){switch(t[e]){case")":return e++,i;case void 0:throw new SyntaxError("Unclosed argument list")}i.push(u()),n(io)}}();if("-"===i)return{type:"term",name:s,attr:a,args:r};if(Va.test(s))return{type:"func",name:s,args:r};throw new SyntaxError("Function names must be all upper-case")}return"-"===i?{type:"term",name:s,attr:a,args:[]}:{type:"mesg",name:s,attr:a}}return g()}function u(){let t=c();return"mesg"!==t.type?t:n(eo)?{type:"narg",name:t.name,value:g()}:t}function p(){let t;return n(Qa,SyntaxError),t=i(Oa)?f():{type:"str",value:a(Ba)},n(Ja,SyntaxError),t}function g(){if(i(Oa))return f();if('"'===t[e])return function(){s('"',SyntaxError);let i="";for(;;){if(i+=a(za),"\\"!==t[e]){if(s('"'))return{type:"str",value:i};throw new SyntaxError("Unclosed string literal")}i+=m()}}();throw new SyntaxError("Invalid expression")}function f(){let[,t,e=""]=r(Oa),i=e.length;return{type:"num",value:parseFloat(t),precision:i}}function m(){if(i(Ua))return a(Ua);if(i($a)){let[,t,e]=r($a),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(qa,"\n"),i=Xa.exec(t)[1].length;return new ro(e,i)}}}class ro{constructor(t,e){this.value=t,this.length=e}}const ao=/<|&#?\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-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(ao.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(),r=e.localName;if(s.global.includes(n))return!0;if(!s[r])return!1;if(s[r].includes(n))return!0;if("http://www.w3.org/1999/xhtml"===e.namespaceURI&&"input"===r&&"value"===n){const t=e.type.toLowerCase();if("submit"===t||"button"===t||"reset"===t)return!0}return!1}function 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 r=So(e,n,t,i);if(0===r.size)break;if("undefined"!=typeof console){const t=n.locales[0],e=Array.from(r).join(", ");console.warn(`[fluent] Missing translations in ${t}: ${e}`)}}return s||"undefined"==typeof console||console.warn(`[fluent] Request for keys failed because no resource bundles got generated.\n keys: ${JSON.stringify(t)}.\n resourceIds: ${JSON.stringify(this.resourceIds)}.`),i}formatMessages(t){return this.formatWithFallback(t,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 r=Object.keys(i.attributes);if(r.length>0){n.attributes=new Array(r.length);for(let[a,o]of r.entries()){let r=t.formatPattern(i.attributes[o],s,e);n.attributes[a]={name:o,value:r}}}return n}function So(t,e,i,s){const n=[],r=new Set;return i.forEach((({id:i,args:a},o)=>{if(void 0!==s[o])return;let l=e.getMessage(i);if(l){if(n.length=0,s[o]=t(e,n,l,a),n.length>0&&"undefined"!=typeof console){const t=e.locales[0],s=n.join(", ");console.warn(`[fluent][resolver] errors in ${t}/${i}: ${s}.`)}}else r.add(i)})),r}const 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{#sl;#sn;#Ti;#nl;constructor({lang:t,isRTL:e},i=null){this.#Ti=Mo.#rl(t),this.#nl=i,this.#sl=e??Mo.#al(this.#Ti)?"rtl":"ltr"}_setL10n(t){this.#nl=t}getLanguage(){return this.#Ti}getDirection(){return this.#sl}async get(t,e=null,i){if(Array.isArray(t)){t=t.map((t=>({id:t})));return(await this.#nl.formatMessages(t)).map((t=>t.value))}const s=await this.#nl.formatMessages([{id:t,args:e}]);return s[0]?.value||i}async translate(t){(this.#sn||=new Set).add(t);try{this.#nl.connectRoot(t),await this.#nl.translateRoots()}catch{}}async translateOnce(t){try{await this.#nl.translateElements([t])}catch(t){console.error("translateOnce:",t)}}async destroy(){if(this.#sn){for(const t of this.#sn)this.#nl.disconnectRoot(t);this.#sn.clear(),this.#sn=null}this.#nl.pauseObserving()}pause(){this.#nl.pauseObserving()}resume(){this.#nl.resumeObserving()}static#rl(t){return{en:"en-us",es:"es-es",fy:"fy-nl",ga:"ga-ie",gu:"gu-in",hi:"hi-in",hy:"hy-am",nb:"nb-no",ne:"ne-np",nn:"nn-no",pa:"pa-in",pt:"pt-pt",sv:"sv-se",zh:"zh-cn"}[t=t?.toLowerCase()||"en-us"]||t}static#al(t){const e=t.split("-",1)[0];return["ar","he","fa","ps","ur"].includes(e)}}function Io(t,e){const i=new no(e),s=new Da(t),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.#ol.bind(Lo,"en-us",this.getLanguage()):Lo.#ll.bind(Lo,this.getLanguage());this._setL10n(new To([],e))}static async*#ol(t,e){const{baseURL:i,paths:s}=await this.#hl(),n=[e];if(t!==e){const i=e.split("-",1)[0];i!==e&&n.push(i),n.push(t)}for(const t of n){const e=await this.#dl(t,i,s);e?yield e:"en-us"===t&&(yield this.#cl(t))}}static async#dl(t,e,i){const s=i[t];if(!s)return null;const n=new URL(s,e);return Io(t,await kr(n,"text"))}static async#hl(){try{const{href:t}=document.querySelector('link[type="application/l10n"]'),e=await kr(t,"json");return{baseURL:t.replace(/[^/]*$/,"")||"./",paths:e}}catch{}return{baseURL:"./",paths:Object.create(null)}}static async*#ll(t){yield this.#cl(t)}static async#cl(t){return Io(t,'pdfjs-previous-button =\n .title = Previous Page\npdfjs-previous-button-label = Previous\npdfjs-next-button =\n .title = Next Page\npdfjs-next-button-label = Next\npdfjs-page-input =\n .title = Page\npdfjs-of-pages = of { $pagesCount }\npdfjs-page-of-pages = ({ $pageNumber } of { $pagesCount })\npdfjs-zoom-out-button =\n .title = Zoom Out\npdfjs-zoom-out-button-label = Zoom Out\npdfjs-zoom-in-button =\n .title = Zoom In\npdfjs-zoom-in-button-label = Zoom In\npdfjs-zoom-select =\n .title = Zoom\npdfjs-presentation-mode-button =\n .title = Switch to Presentation Mode\npdfjs-presentation-mode-button-label = Presentation Mode\npdfjs-open-file-button =\n .title = Open File\npdfjs-open-file-button-label = Open\npdfjs-print-button =\n .title = Print\npdfjs-print-button-label = Print\npdfjs-save-button =\n .title = Save\npdfjs-save-button-label = Save\npdfjs-download-button =\n .title = Download\npdfjs-download-button-label = Download\npdfjs-bookmark-button =\n .title = Current Page (View URL from Current Page)\npdfjs-bookmark-button-label = Current Page\npdfjs-tools-button =\n .title = Tools\npdfjs-tools-button-label = Tools\npdfjs-first-page-button =\n .title = Go to First Page\npdfjs-first-page-button-label = Go to First Page\npdfjs-last-page-button =\n .title = Go to Last Page\npdfjs-last-page-button-label = Go to Last Page\npdfjs-page-rotate-cw-button =\n .title = Rotate Clockwise\npdfjs-page-rotate-cw-button-label = Rotate Clockwise\npdfjs-page-rotate-ccw-button =\n .title = Rotate Counterclockwise\npdfjs-page-rotate-ccw-button-label = Rotate Counterclockwise\npdfjs-cursor-text-select-tool-button =\n .title = Enable Text Selection Tool\npdfjs-cursor-text-select-tool-button-label = Text Selection Tool\npdfjs-cursor-hand-tool-button =\n .title = Enable Hand Tool\npdfjs-cursor-hand-tool-button-label = Hand Tool\npdfjs-scroll-page-button =\n .title = Use Page Scrolling\npdfjs-scroll-page-button-label = Page Scrolling\npdfjs-scroll-vertical-button =\n .title = Use Vertical Scrolling\npdfjs-scroll-vertical-button-label = Vertical Scrolling\npdfjs-scroll-horizontal-button =\n .title = Use Horizontal Scrolling\npdfjs-scroll-horizontal-button-label = Horizontal Scrolling\npdfjs-scroll-wrapped-button =\n .title = Use Wrapped Scrolling\npdfjs-scroll-wrapped-button-label = Wrapped Scrolling\npdfjs-spread-none-button =\n .title = Do not join page spreads\npdfjs-spread-none-button-label = No Spreads\npdfjs-spread-odd-button =\n .title = Join page spreads starting with odd-numbered pages\npdfjs-spread-odd-button-label = Odd Spreads\npdfjs-spread-even-button =\n .title = Join page spreads starting with even-numbered pages\npdfjs-spread-even-button-label = Even Spreads\npdfjs-document-properties-button =\n .title = Document Properties…\npdfjs-document-properties-button-label = Document Properties…\npdfjs-document-properties-file-name = File name:\npdfjs-document-properties-file-size = File size:\npdfjs-document-properties-size-kb = { NUMBER($kb, maximumSignificantDigits: 3) } KB ({ $b } bytes)\npdfjs-document-properties-size-mb = { NUMBER($mb, maximumSignificantDigits: 3) } MB ({ $b } bytes)\npdfjs-document-properties-title = Title:\npdfjs-document-properties-author = Author:\npdfjs-document-properties-subject = Subject:\npdfjs-document-properties-keywords = Keywords:\npdfjs-document-properties-creation-date = Creation Date:\npdfjs-document-properties-modification-date = Modification Date:\npdfjs-document-properties-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\npdfjs-document-properties-creator = Creator:\npdfjs-document-properties-producer = PDF Producer:\npdfjs-document-properties-version = PDF Version:\npdfjs-document-properties-page-count = Page Count:\npdfjs-document-properties-page-size = Page Size:\npdfjs-document-properties-page-size-unit-inches = in\npdfjs-document-properties-page-size-unit-millimeters = mm\npdfjs-document-properties-page-size-orientation-portrait = portrait\npdfjs-document-properties-page-size-orientation-landscape = landscape\npdfjs-document-properties-page-size-name-a-three = A3\npdfjs-document-properties-page-size-name-a-four = A4\npdfjs-document-properties-page-size-name-letter = Letter\npdfjs-document-properties-page-size-name-legal = Legal\npdfjs-document-properties-page-size-dimension-string = { $width } × { $height } { $unit } ({ $orientation })\npdfjs-document-properties-page-size-dimension-name-string = { $width } × { $height } { $unit } ({ $name }, { $orientation })\npdfjs-document-properties-linearized = Fast Web View:\npdfjs-document-properties-linearized-yes = Yes\npdfjs-document-properties-linearized-no = No\npdfjs-document-properties-close-button = Close\npdfjs-print-progress-message = Preparing document for printing…\npdfjs-print-progress-percent = { $progress }%\npdfjs-print-progress-close-button = Cancel\npdfjs-printing-not-supported = Warning: Printing is not fully supported by this browser.\npdfjs-printing-not-ready = Warning: The PDF is not fully loaded for printing.\npdfjs-toggle-sidebar-button =\n .title = Toggle Sidebar\npdfjs-toggle-sidebar-notification-button =\n .title = Toggle Sidebar (document contains outline/attachments/layers)\npdfjs-toggle-sidebar-button-label = Toggle Sidebar\npdfjs-document-outline-button =\n .title = Show Document Outline (double-click to expand/collapse all items)\npdfjs-document-outline-button-label = Document Outline\npdfjs-attachments-button =\n .title = Show Attachments\npdfjs-attachments-button-label = Attachments\npdfjs-layers-button =\n .title = Show Layers (double-click to reset all layers to the default state)\npdfjs-layers-button-label = Layers\npdfjs-thumbs-button =\n .title = Show Thumbnails\npdfjs-thumbs-button-label = Thumbnails\npdfjs-current-outline-item-button =\n .title = Find Current Outline Item\npdfjs-current-outline-item-button-label = Current Outline Item\npdfjs-findbar-button =\n .title = Find in Document\npdfjs-findbar-button-label = Find\npdfjs-additional-layers = Additional Layers\npdfjs-thumb-page-title =\n .title = Page { $page }\npdfjs-thumb-page-canvas =\n .aria-label = Thumbnail of Page { $page }\npdfjs-find-input =\n .title = Find\n .placeholder = Find in document…\npdfjs-find-previous-button =\n .title = Find the previous occurrence of the phrase\npdfjs-find-previous-button-label = Previous\npdfjs-find-next-button =\n .title = Find the next occurrence of the phrase\npdfjs-find-next-button-label = Next\npdfjs-find-highlight-checkbox = Highlight All\npdfjs-find-match-case-checkbox-label = Match Case\npdfjs-find-match-diacritics-checkbox-label = Match Diacritics\npdfjs-find-entire-word-checkbox-label = Whole Words\npdfjs-find-reached-top = Reached top of document, continued from bottom\npdfjs-find-reached-bottom = Reached end of document, continued from top\npdfjs-find-match-count =\n { $total ->\n [one] { $current } of { $total } match\n *[other] { $current } of { $total } matches\n }\npdfjs-find-match-count-limit =\n { $limit ->\n [one] More than { $limit } match\n *[other] More than { $limit } matches\n }\npdfjs-find-not-found = Phrase not found\npdfjs-page-scale-width = Page Width\npdfjs-page-scale-fit = Page Fit\npdfjs-page-scale-auto = Automatic Zoom\npdfjs-page-scale-actual = Actual Size\npdfjs-page-scale-percent = { $scale }%\npdfjs-page-landmark =\n .aria-label = Page { $page }\npdfjs-loading-error = An error occurred while loading the PDF.\npdfjs-invalid-file-error = Invalid or corrupted PDF file.\npdfjs-missing-file-error = Missing PDF file.\npdfjs-unexpected-response-error = Unexpected server response.\npdfjs-rendering-error = An error occurred while rendering the page.\npdfjs-annotation-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\npdfjs-text-annotation-type =\n .alt = [{ $type } Annotation]\npdfjs-password-label = Enter the password to open this PDF file.\npdfjs-password-invalid = Invalid password. Please try again.\npdfjs-password-ok-button = OK\npdfjs-password-cancel-button = Cancel\npdfjs-web-fonts-disabled = Web fonts are disabled: unable to use embedded PDF fonts.\npdfjs-editor-free-text-button =\n .title = Text\npdfjs-editor-free-text-button-label = Text\npdfjs-editor-ink-button =\n .title = Draw\npdfjs-editor-ink-button-label = Draw\npdfjs-editor-stamp-button =\n .title = Add or edit images\npdfjs-editor-stamp-button-label = Add or edit images\npdfjs-editor-highlight-button =\n .title = Highlight\npdfjs-editor-highlight-button-label = Highlight\npdfjs-highlight-floating-button1 =\n .title = Highlight\n .aria-label = Highlight\npdfjs-highlight-floating-button-label = Highlight\npdfjs-editor-remove-ink-button =\n .title = Remove drawing\npdfjs-editor-remove-freetext-button =\n .title = Remove text\npdfjs-editor-remove-stamp-button =\n .title = Remove image\npdfjs-editor-remove-highlight-button =\n .title = Remove highlight\npdfjs-editor-free-text-color-input = Color\npdfjs-editor-free-text-size-input = Size\npdfjs-editor-ink-color-input = Color\npdfjs-editor-ink-thickness-input = Thickness\npdfjs-editor-ink-opacity-input = Opacity\npdfjs-editor-stamp-add-image-button =\n .title = Add image\npdfjs-editor-stamp-add-image-button-label = Add image\npdfjs-editor-free-highlight-thickness-input = Thickness\npdfjs-editor-free-highlight-thickness-title =\n .title = Change thickness when highlighting items other than text\npdfjs-free-text2 =\n .aria-label = Text Editor\n .default-content = Start typing…\npdfjs-ink =\n .aria-label = Draw Editor\npdfjs-ink-canvas =\n .aria-label = User-created image\npdfjs-editor-alt-text-button =\n .aria-label = Alt text\npdfjs-editor-alt-text-button-label = Alt text\npdfjs-editor-alt-text-edit-button =\n .aria-label = Edit alt text\npdfjs-editor-alt-text-dialog-label = Choose an option\npdfjs-editor-alt-text-dialog-description = Alt text (alternative text) helps when people can’t see the image or when it doesn’t load.\npdfjs-editor-alt-text-add-description-label = Add a description\npdfjs-editor-alt-text-add-description-description = Aim for 1-2 sentences that describe the subject, setting, or actions.\npdfjs-editor-alt-text-mark-decorative-label = Mark as decorative\npdfjs-editor-alt-text-mark-decorative-description = This is used for ornamental images, like borders or watermarks.\npdfjs-editor-alt-text-cancel-button = Cancel\npdfjs-editor-alt-text-save-button = Save\npdfjs-editor-alt-text-decorative-tooltip = Marked as decorative\npdfjs-editor-alt-text-textarea =\n .placeholder = For example, “A young man sits down at a table to eat a meal”\npdfjs-editor-resizer-top-left =\n .aria-label = Top left corner — resize\npdfjs-editor-resizer-top-middle =\n .aria-label = Top middle — resize\npdfjs-editor-resizer-top-right =\n .aria-label = Top right corner — resize\npdfjs-editor-resizer-middle-right =\n .aria-label = Middle right — resize\npdfjs-editor-resizer-bottom-right =\n .aria-label = Bottom right corner — resize\npdfjs-editor-resizer-bottom-middle =\n .aria-label = Bottom middle — resize\npdfjs-editor-resizer-bottom-left =\n .aria-label = Bottom left corner — resize\npdfjs-editor-resizer-middle-left =\n .aria-label = Middle left — resize\npdfjs-editor-highlight-colorpicker-label = Highlight color\npdfjs-editor-colorpicker-button =\n .title = Change color\npdfjs-editor-colorpicker-dropdown =\n .aria-label = Color choices\npdfjs-editor-colorpicker-yellow =\n .title = Yellow\npdfjs-editor-colorpicker-green =\n .title = Green\npdfjs-editor-colorpicker-blue =\n .title = Blue\npdfjs-editor-colorpicker-pink =\n .title = Pink\npdfjs-editor-colorpicker-red =\n .title = Red\npdfjs-editor-highlight-show-all-button-label = Show all\npdfjs-editor-highlight-show-all-button =\n .title = Show all\npdfjs-editor-new-alt-text-dialog-edit-label = Edit alt text (image description)\npdfjs-editor-new-alt-text-dialog-add-label = Add alt text (image description)\npdfjs-editor-new-alt-text-textarea =\n .placeholder = Write your description here…\npdfjs-editor-new-alt-text-description = Short description for people who can’t see the image or when the image doesn’t load.\npdfjs-editor-new-alt-text-disclaimer1 = This alt text was created automatically and may be inaccurate.\npdfjs-editor-new-alt-text-disclaimer-learn-more-url = Learn more\npdfjs-editor-new-alt-text-create-automatically-button-label = Create alt text automatically\npdfjs-editor-new-alt-text-not-now-button = Not now\npdfjs-editor-new-alt-text-error-title = Couldn’t create alt text automatically\npdfjs-editor-new-alt-text-error-description = Please write your own alt text or try again later.\npdfjs-editor-new-alt-text-error-close-button = Close\npdfjs-editor-new-alt-text-ai-model-downloading-progress = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\n .aria-valuetext = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\npdfjs-editor-new-alt-text-added-button =\n .aria-label = Alt text added\npdfjs-editor-new-alt-text-added-button-label = Alt text added\npdfjs-editor-new-alt-text-missing-button =\n .aria-label = Missing alt text\npdfjs-editor-new-alt-text-missing-button-label = Missing alt text\npdfjs-editor-new-alt-text-to-review-button =\n .aria-label = Review alt text\npdfjs-editor-new-alt-text-to-review-button-label = Review alt text\npdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer = Created automatically: { $generatedAltText }\npdfjs-image-alt-text-settings-button =\n .title = Image alt text settings\npdfjs-image-alt-text-settings-button-label = Image alt text settings\npdfjs-editor-alt-text-settings-dialog-label = Image alt text settings\npdfjs-editor-alt-text-settings-automatic-title = Automatic alt text\npdfjs-editor-alt-text-settings-create-model-button-label = Create alt text automatically\npdfjs-editor-alt-text-settings-create-model-description = Suggests descriptions to help people who can’t see the image or when the image doesn’t load.\npdfjs-editor-alt-text-settings-download-model-label = Alt text AI model ({ $totalSize } MB)\npdfjs-editor-alt-text-settings-ai-model-description = Runs locally on your device so your data stays private. Required for automatic alt text.\npdfjs-editor-alt-text-settings-delete-model-button = Delete\npdfjs-editor-alt-text-settings-download-model-button = Download\npdfjs-editor-alt-text-settings-downloading-model-button = Downloading…\npdfjs-editor-alt-text-settings-editor-title = Alt text editor\npdfjs-editor-alt-text-settings-show-dialog-button-label = Show alt text editor right away when adding an image\npdfjs-editor-alt-text-settings-show-dialog-description = Helps you make sure all your images have alt text.\npdfjs-editor-alt-text-settings-close-button = Close\npdfjs-editor-undo-bar-message-highlight = Highlight removed\npdfjs-editor-undo-bar-message-freetext = Text removed\npdfjs-editor-undo-bar-message-ink = Drawing removed\npdfjs-editor-undo-bar-message-stamp = Image removed\npdfjs-editor-undo-bar-message-multiple =\n { $count ->\n [one] { $count } annotation removed\n *[other] { $count } annotations removed\n }\npdfjs-editor-undo-bar-undo-button =\n .title = Undo\npdfjs-editor-undo-bar-undo-button-label = Undo\npdfjs-editor-undo-bar-close-button =\n .title = Close\npdfjs-editor-undo-bar-close-button-label = Close')}}function ko(){return document.location.hash}class Do{#tl=null;constructor({linkService:t,eventBus:e}){this.linkService=t,this.eventBus=e,this._initialized=!1,this._fingerprint="",this.reset(),this.eventBus._on("pagesinit",(()=>{this._isPagesLoaded=!1,this.eventBus._on("pagesloaded",(t=>{this._isPagesLoaded=!!t.pagesCount}),{once:!0})}))}initialize({fingerprint:t,resetHistory:e=!1,updateUrl:i=!1}){if(!t||"string"!=typeof t)return void console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');this._initialized&&this.reset();const s=""!==this._fingerprint&&this._fingerprint!==t;this._fingerprint=t,this._updateUrl=!0===i,this._initialized=!0,this.#ul();const n=window.history.state;if(this._popStateInProgress=!1,this._blockHashChange=0,this._currentHash=ko(),this._numPositionUpdates=0,this._uid=this._maxUid=0,this._destination=null,this._position=null,!this.#pl(n,!0)||e){const{hash:t,page:i,rotation:n}=this.#gl(!0);return!t||s||e?void this.#fl(null,!0):void this.#fl({hash:t,page:i,rotation:n},!0)}const r=n.destination;this.#ml(r,n.uid,!0),void 0!==r.rotation&&(this._initialRotation=r.rotation),r.dest?(this._initialBookmark=JSON.stringify(r.dest),this._destination.page=null):r.hash?this._initialBookmark=r.hash:r.page&&(this._initialBookmark=`page=${r.page}`)}reset(){this._initialized&&(this.#bl(),this._initialized=!1,this.#vl()),this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._initialBookmark=null,this._initialRotation=null}push({namedDest:t=null,explicitDest:e,pageNumber:i}){if(!this._initialized)return;if(t&&"string"!=typeof t)return void console.error(`PDFHistory.push: "${t}" is not a valid namedDest parameter.`);if(!Array.isArray(e))return void console.error(`PDFHistory.push: "${e}" is not a valid explicitDest parameter.`);if(!this.#wl(i)&&(null!==i||this._destination))return void console.error(`PDFHistory.push: "${i}" is not a valid pageNumber parameter.`);const s=t||JSON.stringify(e);if(!s)return;let n=!1;if(this._destination&&(function(t,e){if("string"!=typeof t||"string"!=typeof e)return!1;if(t===e)return!0;if(Rn(t).get("nameddest")===e)return!0;return!1}(this._destination.hash,s)||function(t,e){function i(t,e){if(typeof t!=typeof e)return!1;if(Array.isArray(t)||Array.isArray(e))return!1;if(null!==t&&"object"==typeof t&&null!==e){if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const s in t)if(!i(t[s],e[s]))return!1;return!0}return t===e||Number.isNaN(t)&&Number.isNaN(e)}if(!Array.isArray(t)||!Array.isArray(e))return!1;if(t.length!==e.length)return!1;for(let s=0,n=t.length;s<n;s++)if(!i(t[s],e[s]))return!1;return!0}(this._destination.dest,e))){if(this._destination.page)return;n=!0}this._popStateInProgress&&!n||(this.#fl({dest:e,hash:s,page:i,rotation:this.linkService.rotation},n),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then((()=>{this._popStateInProgress=!1}))))}pushPage(t){this._initialized&&(this.#wl(t)?this._destination?.page!==t&&(this._popStateInProgress||(this.#fl({dest:null,hash:`page=${t}`,page:t,rotation:this.linkService.rotation}),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then((()=>{this._popStateInProgress=!1}))))):console.error(`PDFHistory.pushPage: "${t}" is not a valid page number.`))}pushCurrentPosition(){this._initialized&&!this._popStateInProgress&&this.#yl()}back(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#pl(t)&&t.uid>0&&window.history.back()}forward(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#pl(t)&&t.uid<this._maxUid&&window.history.forward()}get popStateInProgress(){return this._initialized&&(this._popStateInProgress||this._blockHashChange>0)}get initialBookmark(){return this._initialized?this._initialBookmark:null}get initialRotation(){return this._initialized?this._initialRotation:null}#fl(t,e=!1){const i=e||!this._destination,s={fingerprint:this._fingerprint,uid:i?this._uid:this._uid+1,destination:t};let n;if(this.#ml(t,s.uid),this._updateUrl&&t?.hash){const e=document.location.href.split("#",1)[0];e.startsWith("file://")||(n=`${e}#${t.hash}`)}i?window.history.replaceState(s,"",n):window.history.pushState(s,"",n)}#yl(t=!1){if(!this._position)return;let e=this._position;if(t&&(e=Object.assign(Object.create(null),this._position),e.temporary=!0),!this._destination)return void this.#fl(e);if(this._destination.temporary)return void this.#fl(e,!0);if(this._destination.hash===e.hash)return;if(!this._destination.page&&this._numPositionUpdates<=50)return;let i=!1;if(this._destination.page>=e.first&&this._destination.page<=e.page){if(void 0!==this._destination.dest||!this._destination.first)return;i=!0}this.#fl(e,i)}#wl(t){return Number.isInteger(t)&&t>0&&t<=this.linkService.pagesCount}#pl(t,e=!1){if(!t)return!1;if(t.fingerprint!==this._fingerprint){if(!e)return!1;{if("string"!=typeof t.fingerprint||t.fingerprint.length!==this._fingerprint.length)return!1;const[e]=performance.getEntriesByType("navigation");if("reload"!==e?.type)return!1}}return!(!Number.isInteger(t.uid)||t.uid<0)&&(null!==t.destination&&"object"==typeof t.destination)}#ml(t,e,i=!1){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),i&&t?.temporary&&delete t.temporary,this._destination=t,this._uid=e,this._maxUid=Math.max(this._maxUid,e),this._numPositionUpdates=0}#gl(t=!1){const e=unescape(ko()).substring(1),i=Rn(e),s=i.get("nameddest")||"";let n=0|i.get("page");return(!this.#wl(n)||t&&s.length>0)&&(n=null),{hash:e,page:n,rotation:this.linkService.rotation}}#Al({location:t}){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._position={hash:t.pdfOpenParams.substring(1),page:this.linkService.page,first:t.pageNumber,rotation:t.rotation},this._popStateInProgress||(this._isPagesLoaded&&this._destination&&!this._destination.page&&this._numPositionUpdates++,this._updateViewareaTimeout=setTimeout((()=>{this._popStateInProgress||this.#yl(!0),this._updateViewareaTimeout=null}),1e3))}#_l({state:t}){const e=ko(),i=this._currentHash!==e;if(this._currentHash=e,!t){this._uid++;const{hash:t,page:e,rotation:i}=this.#gl();return void this.#fl({hash:t,page:e,rotation:i},!0)}if(!this.#pl(t))return;this._popStateInProgress=!0,i&&(this._blockHashChange++,async function({target:t,name:e,delay:i=0}){if("object"!=typeof t||!(Number.isInteger(i)&&i>=0))throw new Error("waitOnEventOrTimeout - invalid parameters.");const{promise:s,resolve:n}=Promise.withResolvers(),r=new AbortController;function a(t){r.abort(),clearTimeout(o),n(t)}t[t instanceof fa?"_on":"addEventListener"](e,a.bind(null,pa),{signal:r.signal});const o=setTimeout(a.bind(null,ga),i);return s}({target:window,name:"hashchange",delay:1e3}).then((()=>{this._blockHashChange--})));const s=t.destination;this.#ml(s,t.uid,!0),Vn(s.rotation)&&(this.linkService.rotation=s.rotation),s.dest?this.linkService.goToDestination(s.dest):s.hash?this.linkService.setHash(s.hash):s.page&&(this.linkService.page=s.page),Promise.resolve().then((()=>{this._popStateInProgress=!1}))}#bl(){this._destination&&!this._destination.temporary||this.#yl()}#ul(){if(this.#tl)return;this.#tl=new AbortController;const{signal:t}=this.#tl;this.eventBus._on("updateviewarea",this.#Al.bind(this),{signal:t}),window.addEventListener("popstate",this.#_l.bind(this),{signal:t}),window.addEventListener("pagehide",this.#bl.bind(this),{signal:t})}#vl(){this.#tl?.abort(),this.#tl=null}}class Ro{#ro=null;#xl=null;#Zo=null;#Mn=null;#go=null;#f;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.#f=t.uiManager,this.#ro=t.annotationLayer||null,this.#go=t.textLayer||null,this.#xl=t.drawLayer||null,this.#Zo=t.onAppend||null,this.#Mn=t.structTreeLayer||null}async render(t,e="display"){if("display"!==e)return;if(this._cancelled)return;const i=t.clone({dontFlip:!0});if(this.div)return this.annotationEditorLayer.update({viewport:i}),void this.show();const s=this.div=document.createElement("div");s.className="annotationEditorLayer",s.hidden=!0,s.dir=this.#f.direction,this.#Zo?.(s),this.annotationEditorLayer=new yr({uiManager:this.#f,div:s,structTreeLayer:this.#Mn,accessibilityManager:this.accessibilityManager,pageIndex:this.pdfPage.pageNumber-1,l10n:this.l10n,viewport:i,annotationLayer:this.#ro,textLayer:this.#go,drawLayer:this.#xl});const n={viewport:i,div:s,annotations:null,intent:e};this.annotationEditorLayer.render(n),this.show()}cancel(){this._cancelled=!0,this.div&&this.annotationEditorLayer.destroy()}hide(){this.div&&(this.annotationEditorLayer.pause(!0),this.div.hidden=!0)}show(){this.div&&!this.annotationEditorLayer.isInvisible&&(this.div.hidden=!1,this.annotationEditorLayer.pause(!1))}}{var 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,zo={BOOLEAN:1,NUMBER:2,OBJECT:4,STRING:8,UNDEFINED:16},Uo={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},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},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},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},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},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},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:zo.BOOLEAN+zo.UNDEFINED},verbosity:{value:1,kind:Bo},workerPort:{value:null,kind:jo},workerSrc:{value:"../build/pdf.worker.mjs",kind:jo}};Uo.defaultUrl={value:"compressed.tracemonkey-pldi-09.pdf",kind:Oo},Uo.sandboxBundleSrc={value:"../build/pdf.sandbox.mjs",kind:Oo},Uo.viewerCssTheme={value:0,kind:Oo+Ho},Uo.enableFakeMLManager={value:!0,kind:Oo},Uo.disablePreferences={value:!1,kind:Oo};class $o{static eventBus;static#Sl=new Map;static{for(const t in Uo)this.#Sl.set(t,Uo[t].value);for(const[t,e]of No)this.#Sl.set(t,e);this._hasInvokedSet=!1,this._checkDisablePreferences=()=>!!this.get("disablePreferences")||(this._hasInvokedSet&&console.warn('The Preferences may override manually set AppOptions; please use the "disablePreferences"-option to prevent that.'),!1)}static get(t){return this.#Sl.get(t)}static getAll(t=null,e=!1){const i=Object.create(null);for(const s in Uo){const n=Uo[s];(!t||t&n.kind)&&(i[s]=e?n.value:this.#Sl.get(s))}return i}static set(t,e){this.setAll({[t]:e})}static setAll(t,e=!1){let i;this._hasInvokedSet||=!0;for(const s in t){const n=Uo[s],r=t[s];if(!n||!(typeof r==typeof n.value||zo[(typeof r).toUpperCase()]&n.type))continue;const{kind:a}=n;(!e||a&Fo||a&Ho)&&(this.eventBus&&a&Vo&&(i||=new Map).set(s,r),this.#Sl.set(s,r))}if(i)for(const[t,e]of i)this.eventBus.dispatch(t.toLowerCase(),{source:this,value:e})}}class Wo{#xl=null;constructor(t){this.pageIndex=t.pageIndex}async render(t="display"){"display"!==t||this.#xl||this._cancelled||(this.#xl=new Ir({pageIndex:this.pageIndex}))}cancel(){this._cancelled=!0,this.#xl&&(this.#xl.destroy(),this.#xl=null)}setParent(t){this.#xl?.setParent(t)}getDrawLayer(){return this.#xl}}const Go={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},qo=/^H(\d+)$/;class Xo{#Cl;#El=null;#Pl;#Tl=new Map;#Ml;#Il=null;constructor(t,e){this.#Cl=t.getStructTree(),this.#Ml=e}async render(){if(this.#Pl)return this.#Pl;const{promise:t,resolve:e,reject:i}=Promise.withResolvers();this.#Pl=t;try{this.#El=this.#Ll(await this.#Cl)}catch(t){i(t)}return this.#Cl=null,this.#El?.classList.add("structTree"),e(this.#El),t}async getAriaAttributes(t){try{return await this.render(),this.#Tl.get(t)}catch{}return null}hide(){this.#El&&!this.#El.hidden&&(this.#El.hidden=!0)}show(){this.#El?.hidden&&(this.#El.hidden=!1)}#kl(t,e){const{alt:i,id:s,lang:n}=t;if(void 0!==i){let s=!1;const n=Fn(i);for(const e of t.children)if("annotation"===e.type){let t=this.#Tl.get(e.id);t||(t=new Map,this.#Tl.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",Fn(n,!0))}#Dl(t,e){const{alt:i,bbox:s,children:n}=t,r=n?.[0];if(!this.#Ml||!i||!s||"content"!==r?.type)return!1;const{id:a}=r;if(!a)return!1;e.setAttribute("aria-owns",a);const o=document.createElement("span");(this.#Il||=new Map).set(a,o),o.setAttribute("role","img"),o.setAttribute("aria-label",Fn(i));const{pageHeight:l,pageX:h,pageY:d}=this.#Ml,c="calc(var(--scale-factor)*",{style:u}=o;return u.width=`${c}${s[2]-s[0]}px)`,u.height=`${c}${s[3]-s[1]}px)`,u.left=`${c}${s[0]-h}px)`,u.top=`${c}${l-s[3]+d}px)`,!0}addElementsToTextLayer(){if(this.#Il){for(const[t,e]of this.#Il)document.getElementById(t)?.append(e);this.#Il.clear(),this.#Il=null}}#Ll(t){if(!t)return null;const e=document.createElement("span");if("role"in t){const{role:i}=t,s=i.match(qo);if(s?(e.setAttribute("role","heading"),e.setAttribute("aria-level",s[1])):Go[i]&&e.setAttribute("role",Go[i]),"Figure"===i&&this.#Dl(t,e))return e}if(this.#kl(t,e),t.children)if(1===t.children.length&&"id"in t.children[0])this.#kl(t.children[0],e);else for(const i of t.children)e.append(this.#Ll(i));return e}}class Ko{#Rl=!1;#Nl=null;#Fl=new Map;#Ol=new Map;setTextMapping(t){this.#Nl=t}static#Bl(t,e){const i=t.getBoundingClientRect(),s=e.getBoundingClientRect();if(0===i.width&&0===i.height)return 1;if(0===s.width&&0===s.height)return-1;const n=i.y,r=i.y+i.height,a=i.y+i.height/2,o=s.y,l=s.y+s.height,h=s.y+s.height/2;if(a<=o&&h>=r)return-1;if(h<=n&&a>=l)return 1;return i.x+i.width/2-(s.x+s.width/2)}enable(){if(this.#Rl)throw new Error("TextAccessibilityManager is already enabled.");if(!this.#Nl)throw new Error("Text divs and strings have not been set.");if(this.#Rl=!0,this.#Nl=this.#Nl.slice(),this.#Nl.sort(Ko.#Bl),this.#Fl.size>0){const t=this.#Nl;for(const[e,i]of this.#Fl){document.getElementById(e)?this.#jl(e,t[i]):this.#Fl.delete(e)}}for(const[t,e]of this.#Ol)this.addPointerInTextLayer(t,e);this.#Ol.clear()}disable(){this.#Rl&&(this.#Ol.clear(),this.#Nl=null,this.#Rl=!1)}removePointerInTextLayer(t){if(!this.#Rl)return void this.#Ol.delete(t);const e=this.#Nl;if(!e||0===e.length)return;const{id:i}=t,s=this.#Fl.get(i);if(void 0===s)return;const n=e[s];this.#Fl.delete(i);let r=n.getAttribute("aria-owns");r?.includes(i)&&(r=r.split(" ").filter((t=>t!==i)).join(" "),r?n.setAttribute("aria-owns",r):(n.removeAttribute("aria-owns"),n.setAttribute("role","presentation")))}#jl(t,e){const i=e.getAttribute("aria-owns");i?.includes(t)||e.setAttribute("aria-owns",i?`${i} ${t}`:t),e.removeAttribute("role")}addPointerInTextLayer(t,e){const{id:i}=t;if(!i)return null;if(!this.#Rl)return this.#Ol.set(t,e),null;e&&this.removePointerInTextLayer(t);const s=this.#Nl;if(!s||0===s.length)return null;const n=On(s,(e=>Ko.#Bl(t,e)<0)),r=Math.max(0,n-1),a=s[r];this.#jl(i,a),this.#Fl.set(i,r);const o=a.parentNode;return o?.classList.contains("markedContent")?o.id:null}moveElementInDOM(t,e,i,s){const n=this.addPointerInTextLayer(i,s);if(!t.hasChildNodes())return t.append(e),n;const r=Array.from(t.childNodes).filter((t=>t!==e));if(0===r.length)return n;const a=i||e,o=On(r,(t=>Ko.#Bl(a,t)<0));return 0===o?r[0].before(e):r[o-1].after(e),n}}class Yo{#tl=null;constructor({findController:t,eventBus:e,pageIndex:i}){this.findController=t,this.matches=[],this.eventBus=e,this.pageIdx=i,this.textDivs=null,this.textContentItemsStr=null,this.enabled=!1}setTextMapping(t,e){this.textDivs=t,this.textContentItemsStr=e}enable(){if(!this.textDivs||!this.textContentItemsStr)throw new Error("Text divs and strings have not been set.");if(this.enabled)throw new Error("TextHighlighter is already enabled.");this.enabled=!0,this.#tl||(this.#tl=new AbortController,this.eventBus._on("updatetextlayermatches",(t=>{t.pageIndex!==this.pageIdx&&-1!==t.pageIndex||this._updateMatches()}),{signal:this.#tl.signal})),this._updateMatches()}disable(){this.enabled&&(this.enabled=!1,this.#tl?.abort(),this.#tl=null,this._updateMatches(!0))}_convertMatches(t,e){if(!t)return[];const{textContentItemsStr:i}=this;let s=0,n=0;const r=i.length-1,a=[];for(let o=0,l=t.length;o<l;o++){let l=t[o];for(;s!==r&&l>=n+i[s].length;)n+=i[s].length,s++;s===i.length&&console.error("Could not find a matching mapping");const h={begin:{divIdx:s,offset:l-n}};for(l+=e[o];s!==r&&l>n+i[s].length;)n+=i[s].length,s++;h.end={divIdx:s,offset:l-n},a.push(h)}return a}_renderMatches(t){if(0===t.length)return;const{findController:e,pageIdx:i}=this,{textContentItemsStr:s,textDivs:n}=this,r=i===e.selected.pageIdx,a=e.selected.matchIdx;let o=null;const l={offset:void 0};function h(t,e){const i=t.divIdx;return n[i].textContent="",d(i,0,t.offset,e)}function d(t,e,i,r){let a=n[t];if(a.nodeType===Node.TEXT_NODE){const e=document.createElement("span");a.before(e),e.append(a),n[t]=e,a=e}const o=s[t].substring(e,i),l=document.createTextNode(o);if(r){const t=document.createElement("span");if(t.className=`${r} appended`,t.append(l),a.append(t),r.includes("selected")){const{left:e}=t.getClientRects()[0];return e-a.getBoundingClientRect().left}return 0}return a.append(l),0}let c=a,u=c+1;if(e.state.highlightAll)c=0,u=t.length;else if(!r)return;let p=-1,g=-1;for(let s=c;s<u;s++){const c=t[s],u=c.begin;if(u.divIdx===p&&u.offset===g)continue;p=u.divIdx,g=u.offset;const f=c.end,m=r&&s===a,b=m?" selected":"";let v=0;if(o&&u.divIdx===o.divIdx?d(o.divIdx,o.offset,u.offset):(null!==o&&d(o.divIdx,o.offset,l.offset),h(u)),u.divIdx===f.divIdx)v=d(u.divIdx,u.offset,f.offset,"highlight"+b);else{v=d(u.divIdx,u.offset,l.offset,"highlight begin"+b);for(let t=u.divIdx+1,e=f.divIdx;t<e;t++)n[t].className="highlight middle"+b;h(f,"highlight end"+b)}o=f,m&&e.scrollMatchIntoView({element:n[u.divIdx],selectedLeft:v,pageIndex:i,matchIndex:a})}o&&d(o.divIdx,o.offset,l.offset)}_updateMatches(t=!1){if(!this.enabled&&!t)return;const{findController:e,matches:i,pageIdx:s}=this,{textContentItemsStr:n,textDivs:r}=this;let a=-1;for(const t of i){for(let e=Math.max(a,t.begin.divIdx),i=t.end.divIdx;e<=i;e++){const t=r[e];t.textContent=n[e],t.className=""}a=t.end.divIdx+1}if(!e?.highlightMatches||t)return;const o=e.pageMatches[s]||null,l=e.pageMatchesLength[s]||null;this.matches=this._convertMatches(o,l),this._renderMatches(this.matches)}}class Qo{#Vl=!1;#Zo=null;#Hl=!1;#go=null;static#zl=new Map;static#Ul=null;constructor({pdfPage:t,highlighter:e=null,accessibilityManager:i=null,enablePermissions:s=!1,onAppend:n=null}){this.pdfPage=t,this.highlighter=e,this.accessibilityManager=i,this.#Vl=!0===s,this.#Zo=n,this.div=document.createElement("div"),this.div.tabIndex=0,this.div.className="textLayer"}async render(t,e=null){if(this.#Hl&&this.#go)return this.#go.update({viewport:t,onBefore:this.hide.bind(this)}),void this.show();this.cancel(),this.#go=new sa({textContentSource:this.pdfPage.streamTextContent(e||{includeMarkedContent:!0,disableNormalization:!0}),container:this.div,viewport:t});const{textDivs:i,textContentItemsStr:s}=this.#go;this.highlighter?.setTextMapping(i,s),this.accessibilityManager?.setTextMapping(i),await this.#go.render(),this.#Hl=!0;const n=document.createElement("div");n.className="endOfContent",this.div.append(n),this.#$l(n),this.#Zo?.(this.div),this.highlighter?.enable(),this.accessibilityManager?.enable()}hide(){!this.div.hidden&&this.#Hl&&(this.highlighter?.disable(),this.div.hidden=!0)}show(){this.div.hidden&&this.#Hl&&(this.div.hidden=!1,this.highlighter?.enable())}cancel(){this.#go?.cancel(),this.#go=null,this.highlighter?.disable(),this.accessibilityManager?.disable(),Qo.#Wl(this.div)}#$l(t){const{div:e}=this;e.addEventListener("mousedown",(()=>{e.classList.add("selecting")})),e.addEventListener("copy",(t=>{if(!this.#Vl){const e=document.getSelection();t.clipboardData.setData("text/plain",Fn($r(e.toString())))}ia(t)})),Qo.#zl.set(e,t),Qo.#Gl()}static#Wl(t){this.#zl.delete(t),0===this.#zl.size&&(this.#Ul?.abort(),this.#Ul=null)}static#Gl(){if(this.#Ul)return;this.#Ul=new AbortController;const{signal:t}=this.#Ul,e=(t,e)=>{e.append(t),t.style.width="",t.style.height="",e.classList.remove("selecting")};let i=!1;var s,n;document.addEventListener("pointerdown",(()=>{i=!0}),{signal:t}),document.addEventListener("pointerup",(()=>{i=!1,this.#zl.forEach(e)}),{signal:t}),window.addEventListener("blur",(()=>{i=!1,this.#zl.forEach(e)}),{signal:t}),document.addEventListener("keyup",(()=>{i||this.#zl.forEach(e)}),{signal:t}),document.addEventListener("selectionchange",(()=>{const t=document.getSelection();if(0===t.rangeCount)return void this.#zl.forEach(e);const i=new Set;for(let e=0;e<t.rangeCount;e++){const s=t.getRangeAt(e);for(const t of this.#zl.keys())!i.has(t)&&s.intersectsNode(t)&&i.add(t)}for(const[t,s]of this.#zl)i.has(t)?t.classList.add("selecting"):e(s,t);if(s??="none"===getComputedStyle(this.#zl.values().next().value).getPropertyValue("-moz-user-select"),s)return;const r=t.getRangeAt(0),a=n&&(0===r.compareBoundaryPoints(Range.END_TO_END,n)||0===r.compareBoundaryPoints(Range.START_TO_END,n));let o=a?r.startContainer:r.endContainer;o.nodeType===Node.TEXT_NODE&&(o=o.parentNode);const l=o.parentElement?.closest(".textLayer"),h=this.#zl.get(l);h&&(h.style.width=l.style.width,h.style.height=l.style.height,o.parentElement.insertBefore(h,a?o:o.nextSibling)),n=r.cloneRange()}),{signal:t})}}class Jo{constructor({pdfPage:t,annotationStorage:e=null,linkService:i,xfaHtml:s=null}){this.pdfPage=t,this.annotationStorage=e,this.linkService=i,this.xfaHtml=s,this.div=null,this._cancelled=!1}async render(t,e="display"){if("print"===e){const i={viewport:t.clone({dontFlip:!0}),div:this.div,xfaHtml:this.xfaHtml,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:e};return this.div=document.createElement("div"),i.div=this.div,ha.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?ha.update(s):(this.div=document.createElement("div"),s.div=this.div,ha.render(s))}cancel(){this._cancelled=!0}hide(){this.div&&(this.div.hidden=!0)}}const Zo={annotationEditorUIManager:null,annotationStorage:null,downloadManager:null,enableScripting:!1,fieldObjectsPromise:null,findController:null,hasJSActionsPromise:null,get linkService(){return new vr}},tl=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);class el{#ql=Cr.ENABLE_FORMS;#Xl=null;#li=!1;#Kl=!1;#_e=!1;#Yl=null;#Ql=null;#Jl=null;#Zl=null;#th=1;#eh=1;#ih=null;#sh=xn.INITIAL;#nh=Mn;#rh={directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0};#ah=[null,null,null,null];constructor(t){const e=t.container,i=t.defaultViewport;this.id=t.id,this.renderingId="page"+this.id,this.#Yl=t.layerProperties||Zo,this.pdfPage=null,this.pageLabel=null,this.rotation=0,this.scale=t.scale||1,this.viewport=i,this.pdfPageRotate=i.rotation,this._optionalContentConfigPromise=t.optionalContentConfigPromise||null,this.#nh=t.textLayerMode??Mn,this.#ql=t.annotationMode??Cr.ENABLE_FORMS,this.imageResourcesPath=t.imageResourcesPath||"",this.maxCanvasPixels=t.maxCanvasPixels??$o.get("maxCanvasPixels"),this.pageColors=t.pageColors||null,this.#li=t.enableHWA||!1,this.eventBus=t.eventBus,this.renderingQueue=t.renderingQueue,this.l10n=t.l10n,this.l10n||=new Lo,this.renderTask=null,this.resume=null,this._isStandalone=!this.renderingQueue?.hasViewer(),this._container=e,this._annotationCanvasMap=null,this.annotationLayer=null,this.annotationEditorLayer=null,this.textLayer=null,this.xfaLayer=null,this.structTreeLayer=null,this.drawLayer=null;const s=document.createElement("div");if(s.className="page",s.setAttribute("data-page-number",this.id),s.setAttribute("role","region"),s.setAttribute("data-l10n-id","pdfjs-page-landmark"),s.setAttribute("data-l10n-args",JSON.stringify({page:this.id})),this.div=s,this.#oh(),e?.append(s),this._isStandalone){e?.style.setProperty("--scale-factor",this.scale*Jr.PDF_TO_CSS_UNITS),this.pageColors?.background&&e?.style.setProperty("--page-bg-color",this.pageColors.background);const{optionalContentConfigPromise:i}=t;i&&i.then((t=>{i===this._optionalContentConfigPromise&&(this.#rh.initialOptionalContent=t.hasInitialVisibility)})),t.l10n||this.l10n.translate(this.div)}}#lh(t,e){const i=tl.get(e),s=this.#ah[i];if(this.#ah[i]=t,s)s.replaceWith(t);else{for(let e=i-1;e>=0;e--){const i=this.#ah[e];if(i)return void i.after(t)}this.div.prepend(t)}}get renderingState(){return this.#sh}set renderingState(t){if(t!==this.#sh)switch(this.#sh=t,this.#Ql&&(clearTimeout(this.#Ql),this.#Ql=null),t){case xn.PAUSED:this.div.classList.remove("loading");break;case xn.RUNNING:this.div.classList.add("loadingIcon"),this.#Ql=setTimeout((()=>{this.div.classList.add("loading"),this.#Ql=null}),0);break;case xn.INITIAL:case xn.FINISHED:this.div.classList.remove("loadingIcon","loading")}}#oh(){const{viewport:t}=this;if(this.pdfPage){if(this.#Zl===t.rotation)return;this.#Zl=t.rotation}ta(this.div,t,!0,!1)}setPdfPage(t){!this._isStandalone||"CanvasText"!==this.pageColors?.foreground&&"Canvas"!==this.pageColors?.background||(this._container?.style.setProperty("--hcm-highlight-filter",t.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight")),this._container?.style.setProperty("--hcm-highlight-selected-filter",t.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","Highlight"))),this.pdfPage=t,this.pdfPageRotate=t.rotate;const e=(this.rotation+this.pdfPageRotate)%360;this.viewport=t.getViewport({scale:this.scale*Jr.PDF_TO_CSS_UNITS,rotation:e}),this.#oh(),this.reset()}destroy(){this.reset(),this.pdfPage?.cleanup()}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}get _textHighlighter(){return ea(this,"_textHighlighter",new Yo({pageIndex:this.id-1,eventBus:this.eventBus,findController:this.#Yl.findController}))}#hh(t,e){this.eventBus.dispatch(t,{source:this,pageNumber:this.id,error:e})}async#dh(){let t=null;try{await this.annotationLayer.render(this.viewport,{structTreeLayer:this.structTreeLayer},"display")}catch(e){console.error("#renderAnnotationLayer:",e),t=e}finally{this.#hh("annotationlayerrendered",t)}}async#ch(){let t=null;try{await this.annotationEditorLayer.render(this.viewport,"display")}catch(e){console.error("#renderAnnotationEditorLayer:",e),t=e}finally{this.#hh("annotationeditorlayerrendered",t)}}async#uh(){try{await this.drawLayer.render("display")}catch(t){console.error("#renderDrawLayer:",t)}}async#ph(){let t=null;try{const t=await this.xfaLayer.render(this.viewport,"display");t?.textDivs&&this._textHighlighter&&this.#gh(t.textDivs)}catch(e){console.error("#renderXfaLayer:",e),t=e}finally{this.xfaLayer?.div&&(this.l10n.pause(),this.#lh(this.xfaLayer.div,"xfaLayer"),this.l10n.resume()),this.#hh("xfalayerrendered",t)}}async#fh(){if(!this.textLayer)return;let t=null;try{await this.textLayer.render(this.viewport)}catch(e){if(e instanceof wr)return;console.error("#renderTextLayer:",e),t=e}this.#hh("textlayerrendered",t),this.#mh()}async#mh(){if(!this.textLayer)return;const t=await(this.structTreeLayer?.render());t&&(this.l10n.pause(),this.structTreeLayer?.addElementsToTextLayer(),this.canvas&&t.parentNode!==this.canvas&&this.canvas.append(t),this.l10n.resume()),this.structTreeLayer?.show()}async#gh(t){const e=await this.pdfPage.getTextContent(),i=[];for(const t of e.items)i.push(t.str);this._textHighlighter.setTextMapping(t,i),this._textHighlighter.enable()}#bh(){const{canvas:t}=this;t&&(t.remove(),t.width=t.height=0,this.canvas=null,this.#Jl=null)}reset({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:s=!1,keepCanvasWrapper:n=!1}={}){this.cancelRendering({keepAnnotationLayer:t,keepAnnotationEditorLayer:e,keepXfaLayer:i,keepTextLayer:s}),this.renderingState=xn.INITIAL;const r=this.div,a=r.childNodes,o=t&&this.annotationLayer?.div||null,l=e&&this.annotationEditorLayer?.div||null,h=i&&this.xfaLayer?.div||null,d=s&&this.textLayer?.div||null,c=n&&this.#Xl||null;for(let t=a.length-1;t>=0;t--){const e=a[t];switch(e){case o:case l:case h:case d:case c:continue}e.remove();const i=this.#ah.indexOf(e);i>=0&&(this.#ah[i]=null)}r.removeAttribute("data-loaded"),o&&this.annotationLayer.hide(),l&&this.annotationEditorLayer.hide(),h&&this.xfaLayer.hide(),d&&this.textLayer.hide(),this.structTreeLayer?.hide(),!n&&this.#Xl&&(this.#Xl=null,this.#bh())}toggleEditingMode(t){this.hasEditableAnnotations()&&(this.#_e=t,this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0}))}update({scale:t=0,rotation:e=null,optionalContentConfigPromise:i=null,drawingDelay:s=-1}){this.scale=t||this.scale,"number"==typeof e&&(this.rotation=e),i instanceof Promise&&(this._optionalContentConfigPromise=i,i.then((t=>{i===this._optionalContentConfigPromise&&(this.#rh.initialOptionalContent=t.hasInitialVisibility)}))),this.#rh.directDrawing=!0;const n=(this.rotation+this.pdfPageRotate)%360;if(this.viewport=this.viewport.clone({scale:this.scale*Jr.PDF_TO_CSS_UNITS,rotation:n}),this.#oh(),this._isStandalone&&this._container?.style.setProperty("--scale-factor",this.viewport.scale),this.canvas){let t=!1;if(this.#Kl)if(0===this.maxCanvasPixels)t=!0;else if(this.maxCanvasPixels>0){const{width:e,height:i}=this.viewport,{sx:s,sy:n}=this.outputScale;t=(Math.floor(e)*s|0)*(Math.floor(i)*n|0)>this.maxCanvasPixels}const e=s>=0&&s<1e3;if(e||t){if(e&&!t&&this.renderingState!==xn.FINISHED&&(this.cancelRendering({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:s}),this.renderingState=xn.FINISHED,this.#rh.directDrawing=!1),this.cssTransform({redrawAnnotationLayer:!0,redrawAnnotationEditorLayer:!0,redrawXfaLayer:!0,redrawTextLayer:!e,hideTextLayer:e}),e)return;return void this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!0,timestamp:performance.now(),error:this.#ih})}}this.cssTransform({}),this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0})}cancelRendering({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:s=!1,cancelExtraDelay:n=0}={}){this.renderTask&&(this.renderTask.cancel(n),this.renderTask=null),this.resume=null,!this.textLayer||s&&this.textLayer.div||(this.textLayer.cancel(),this.textLayer=null),!this.annotationLayer||t&&this.annotationLayer.div||(this.annotationLayer.cancel(),this.annotationLayer=null,this._annotationCanvasMap=null),this.structTreeLayer&&!this.textLayer&&(this.structTreeLayer=null),!this.annotationEditorLayer||e&&this.annotationEditorLayer.div||(this.drawLayer&&(this.drawLayer.cancel(),this.drawLayer=null),this.annotationEditorLayer.cancel(),this.annotationEditorLayer=null),!this.xfaLayer||i&&this.xfaLayer.div||(this.xfaLayer.cancel(),this.xfaLayer=null,this._textHighlighter?.disable())}cssTransform({redrawAnnotationLayer:t=!1,redrawAnnotationEditorLayer:e=!1,redrawXfaLayer:i=!1,redrawTextLayer:s=!1,hideTextLayer:n=!1}){const{canvas:r}=this;if(!r)return;const a=this.#Jl;if(this.viewport!==a){const t=(360+this.viewport.rotation-a.rotation)%360;if(90===t||270===t){const{width:e,height:i}=this.viewport,s=i/e,n=e/i;r.style.transform=`rotate(${t}deg) scale(${s},${n})`}else r.style.transform=0===t?"":`rotate(${t}deg)`}t&&this.annotationLayer&&this.#dh(),e&&this.annotationEditorLayer&&(this.drawLayer&&this.#uh(),this.#ch()),i&&this.xfaLayer&&this.#ph(),this.textLayer&&(n?(this.textLayer.hide(),this.structTreeLayer?.hide()):s&&this.#fh())}get width(){return this.viewport.width}get height(){return this.viewport.height}getPagePoint(t,e){return this.viewport.convertToPdfPoint(t,e)}async#vh(t,e=null){if(t===this.renderTask&&(this.renderTask=null),e instanceof Zr)this.#ih=null;else if(this.#ih=e,this.renderingState=xn.FINISHED,this.#rh.regularAnnotations=!t.separateAnnots,this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!1,timestamp:performance.now(),error:this.#ih}),e)throw e}async draw(){this.renderingState!==xn.INITIAL&&(console.error("Must be in new state before drawing"),this.reset());const{div:t,l10n:e,pageColors:i,pdfPage:s,viewport:n}=this;if(!s)throw this.renderingState=xn.FINISHED,new Error("pdfPage is not loaded");this.renderingState=xn.RUNNING;let r=this.#Xl;if(r||(r=this.#Xl=document.createElement("div"),r.classList.add("canvasWrapper"),this.#lh(r,"canvasWrapper")),this.textLayer||this.#nh===Tn||s.isPureXfa||(this._accessibilityManager||=new Ko,this.textLayer=new Qo({pdfPage:s,highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,enablePermissions:this.#nh===In,onAppend:t=>{this.l10n.pause(),this.#lh(t,"textLayer"),this.l10n.resume()}})),!this.annotationLayer&&this.#ql!==Cr.DISABLE){const{annotationStorage:t,annotationEditorUIManager:e,downloadManager:i,enableScripting:n,fieldObjectsPromise:r,hasJSActionsPromise:a,linkService:o}=this.#Yl;this._annotationCanvasMap||=new Map,this.annotationLayer=new da({pdfPage:s,annotationStorage:t,imageResourcesPath:this.imageResourcesPath,renderForms:this.#ql===Cr.ENABLE_FORMS,linkService:o,downloadManager:i,enableScripting:n,hasJSActionsPromise:a,fieldObjectsPromise:r,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager,annotationEditorUIManager:e,onAppend:t=>{this.#lh(t,"annotationLayer")}})}const{width:a,height:o}=n,l=document.createElement("canvas");l.setAttribute("role","presentation");const h=!(!i?.background||!i?.foreground),d=this.canvas,c=!d&&!h;this.canvas=l,this.#Jl=n;let u=t=>{if(c)return r.prepend(l),void(u=null);t&&(d?(d.replaceWith(l),d.width=d.height=0):r.prepend(l),u=null)};const p=l.getContext("2d",{alpha:!1,willReadFrequently:!this.#li}),g=this.outputScale=new Gr;if(0===this.maxCanvasPixels){const t=1/this.scale;g.sx*=t,g.sy*=t,this.#Kl=!0}else if(this.maxCanvasPixels>0){const t=a*o,e=Math.sqrt(this.maxCanvasPixels/t);g.sx>e||g.sy>e?(g.sx=e,g.sy=e,this.#Kl=!0):this.#Kl=!1}const f=Bn(g.sx),m=Bn(g.sy),b=l.width=jn($n(a*g.sx),f[0]),v=l.height=jn($n(o*g.sy),m[0]),w=jn($n(a),f[1]),y=jn($n(o),m[1]);g.sx=b/w,g.sy=v/y,this.#th!==f[1]&&(t.style.setProperty("--scale-round-x",`${f[1]}px`),this.#th=f[1]),this.#eh!==m[1]&&(t.style.setProperty("--scale-round-y",`${m[1]}px`),this.#eh=m[1]);const A={canvasContext:p,transform:g.scaled?[g.sx,0,0,g.sy,0,0]:null,viewport:n,annotationMode:this.#ql,optionalContentConfigPromise:this._optionalContentConfigPromise,annotationCanvasMap:this._annotationCanvasMap,pageColors:i,isEditing:this.#_e},_=this.renderTask=s.render(A);_.onContinue=t=>{if(u?.(!1),this.renderingQueue&&!this.renderingQueue.isHighestPriority(this))return this.renderingState=xn.PAUSED,void(this.resume=()=>{this.renderingState=xn.RUNNING,t()});t()};const x=_.promise.then((async()=>{u?.(!0),await this.#vh(_),this.structTreeLayer||=new Xo(s,n.rawDims),this.#fh(),this.annotationLayer&&await this.#dh();const{annotationEditorUIManager:t}=this.#Yl;t&&(this.drawLayer||=new Wo({pageIndex:this.id}),await this.#uh(),this.drawLayer.setParent(r),this.annotationEditorLayer||=new Ro({uiManager:t,pdfPage:s,l10n:e,structTreeLayer:this.structTreeLayer,accessibilityManager:this._accessibilityManager,annotationLayer:this.annotationLayer?.annotationLayer,textLayer:this.textLayer,drawLayer:this.drawLayer.getDrawLayer(),onAppend:t=>{this.#lh(t,"annotationEditorLayer")}}),this.#ch())}),(t=>(t instanceof Zr?(d?.remove(),this.#bh()):u?.(!0),this.#vh(_,t))));if(s.isPureXfa){if(!this.xfaLayer){const{annotationStorage:t,linkService:e}=this.#Yl;this.xfaLayer=new Jo({pdfPage:s,annotationStorage:t,linkService:e})}this.#ph()}return t.setAttribute("data-loaded",!0),this.eventBus.dispatch("pagerender",{source:this,pageNumber:this.id}),x}setPageLabel(t){this.pageLabel="string"==typeof t?t:null,this.div.setAttribute("data-l10n-args",JSON.stringify({page:this.pageLabel??this.id})),null!==this.pageLabel?this.div.setAttribute("data-page-label",this.pageLabel):this.div.removeAttribute("data-page-label")}get thumbnailCanvas(){const{directDrawing:t,initialOptionalContent:e,regularAnnotations:i}=this.#rh;return t&&e&&i?this.canvas:null}}class il{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 sl{#wh=null;#yh=null;#Ah=null;#tl=null;#Lr=null;#_h=null;#xh=null;#Sh=null;#Ch=!1;#Eh=null;#Ph=null;constructor({eventBus:t,externalServices:e=null,docProperties:i=null}){this.#Lr=t,this.#_h=e,this.#Ah=i}setViewer(t){this.#Sh=t}async setDocument(t){if(this.#xh&&await this.#Th(),this.#xh=t,!t)return;const[e,i,s]=await Promise.all([t.getFieldObjects(),t.getCalculationOrderIds(),t.getJSActions()]);if(!e&&!s)return void await this.#Th();if(t!==this.#xh)return;try{this.#Eh=this.#Mh()}catch(t){return console.error("setDocument:",t),void await this.#Th()}const n=this.#Lr;this.#tl=new AbortController;const{signal:r}=this.#tl;n._on("updatefromsandbox",(t=>{t?.source===window&&this.#Ih(t.detail)}),{signal:r}),n._on("dispatcheventinsandbox",(t=>{this.#Eh?.dispatchEventInSandbox(t.detail)}),{signal:r}),n._on("pagechanging",(({pageNumber:t,previous:e})=>{t!==e&&(this.#Lh(e),this.#kh(t))}),{signal:r}),n._on("pagerendered",(({pageNumber:t})=>{this._pageOpenPending.has(t)&&t===this.#Sh.currentPageNumber&&this.#kh(t)}),{signal:r}),n._on("pagesdestroy",(async()=>{await this.#Lh(this.#Sh.currentPageNumber),await(this.#Eh?.dispatchEventInSandbox({id:"doc",name:"WillClose"})),this.#wh?.resolve()}),{signal:r});try{const r=await this.#Ah(t);if(t!==this.#xh)return;await this.#Eh.createSandbox({objects:e,calculationOrder:i,appInfo:{platform:navigator.platform,language:navigator.language},docInfo:{...r,actions:s}}),n.dispatch("sandboxcreated",{source:this})}catch(t){return console.error("setDocument:",t),void await this.#Th()}await(this.#Eh?.dispatchEventInSandbox({id:"doc",name:"Open"})),await this.#kh(this.#Sh.currentPageNumber,!0),Promise.resolve().then((()=>{t===this.#xh&&(this.#Ch=!0)}))}async dispatchWillSave(){return this.#Eh?.dispatchEventInSandbox({id:"doc",name:"WillSave"})}async dispatchDidSave(){return this.#Eh?.dispatchEventInSandbox({id:"doc",name:"DidSave"})}async dispatchWillPrint(){if(this.#Eh){await(this.#Ph?.promise),this.#Ph=Promise.withResolvers();try{await this.#Eh.dispatchEventInSandbox({id:"doc",name:"WillPrint"})}catch(t){throw this.#Ph.resolve(),this.#Ph=null,t}await this.#Ph.promise}}async dispatchDidPrint(){return this.#Eh?.dispatchEventInSandbox({id:"doc",name:"DidPrint"})}get destroyPromise(){return this.#yh?.promise||null}get ready(){return this.#Ch}get _pageOpenPending(){return ea(this,"_pageOpenPending",new Set)}get _visitedPages(){return ea(this,"_visitedPages",new Map)}async#Ih(t){const e=this.#Sh,i=e.isInPresentationMode||e.isChangingPresentationMode,{id:s,siblings:n,command:r,value:a}=t;if(!s){switch(r){case"clear":console.clear();break;case"error":console.error(a);break;case"layout":if(!i){const t=function(t){let e=Ln.VERTICAL,i=kn.NONE;switch(t){case"SinglePage":e=Ln.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=Ln.PAGE;case"TwoColumnLeft":i=kn.ODD;break;case"TwoPageRight":e=Ln.PAGE;case"TwoColumnRight":i=kn.EVEN}return{scrollMode:e,spreadMode:i}}(a);e.spreadMode=t.spreadMode}break;case"page-num":e.currentPageNumber=a+1;break;case"print":await e.pagesPromise,this.#Lr.dispatch("print",{source:this});break;case"println":console.log(a);break;case"zoom":i||(e.currentScaleValue=a);break;case"SaveAs":this.#Lr.dispatch("download",{source:this});break;case"FirstPage":e.currentPageNumber=1;break;case"LastPage":e.currentPageNumber=e.pagesCount;break;case"NextPage":e.nextPage();break;case"PrevPage":e.previousPage();break;case"ZoomViewIn":i||e.increaseScale();break;case"ZoomViewOut":i||e.decreaseScale();break;case"WillPrintFinished":this.#Ph?.resolve(),this.#Ph=null}return}if(i&&t.focus)return;delete t.id,delete t.siblings;const o=n?[s,...n]:[s];for(const e of o){const i=document.querySelector(`[data-element-id="${e}"]`);i?i.dispatchEvent(new CustomEvent("updatefromsandbox",{detail:t})):this.#xh?.annotationStorage.setValue(e,t)}}async#kh(t,e=!1){const i=this.#xh,s=this._visitedPages;if(e&&(this.#wh=Promise.withResolvers()),!this.#wh)return;const n=this.#Sh.getPageView(t-1);if(n?.renderingState!==xn.FINISHED)return void this._pageOpenPending.add(t);this._pageOpenPending.delete(t);const r=(async()=>{const e=await(s.has(t)?null:n.pdfPage?.getJSActions());i===this.#xh&&await(this.#Eh?.dispatchEventInSandbox({id:"page",name:"PageOpen",pageNumber:t,actions:e}))})();s.set(t,r)}async#Lh(t){const e=this.#xh,i=this._visitedPages;if(!this.#wh)return;if(this._pageOpenPending.has(t))return;const s=i.get(t);s&&(i.set(t,null),await s,e===this.#xh&&await(this.#Eh?.dispatchEventInSandbox({id:"page",name:"PageClose",pageNumber:t})))}#Mh(){if(this.#yh=Promise.withResolvers(),this.#Eh)throw new Error("#initScripting: Scripting already exists.");return this.#_h.createScripting()}async#Th(){if(!this.#Eh)return this.#xh=null,void this.#yh?.resolve();this.#wh&&(await Promise.race([this.#wh.promise,new Promise((t=>{setTimeout(t,1e3)}))]).catch((()=>{})),this.#wh=null),this.#xh=null;try{await this.#Eh.destroySandbox()}catch{}this.#Ph?.reject(new Error("Scripting destroyed.")),this.#Ph=null,this.#tl?.abort(),this.#tl=null,this._pageOpenPending.clear(),this._visitedPages.clear(),this.#Eh=null,this.#Ch=!1,this.#yh?.resolve()}}class nl extends sl{constructor(t){t.externalServices||window.addEventListener("updatefromsandbox",(e=>{t.eventBus.dispatch("updatefromsandbox",{source:window,detail:e.detail})})),t.externalServices||={createScripting:()=>new il(t.sandboxBundleSrc)},t.docProperties||=t=>async function(t){const e="".split("#",1)[0];let{info:i,metadata:s,contentDispositionFilename:n,contentLength:r}=await t.getMetadata();if(!r){const{length:e}=await t.getDownloadInfo();r=e}return{...i,baseURL:e,filesize:r,filename:n||Nr(""),metadata:s?.getRaw(),authors:s?.get("dc:creator"),numPages:t.numPages,URL:""}}(t),super(t)}}let rl=class{constructor(){this.pdfViewer=null,this.pdfThumbnailViewer=null,this.onIdle=null,this.highestPriorityPage=null,this.idleTimeout=null,this.printing=!1,this.isThumbnailViewEnabled=!1,Object.defineProperty(this,"hasViewer",{value:()=>!!this.pdfViewer})}setViewer(t){this.pdfViewer=t}setThumbnailViewer(t){this.pdfThumbnailViewer=t}isHighestPriority(t){return this.highestPriorityPage===t.renderingId}renderHighestPriority(t){this.idleTimeout&&(clearTimeout(this.idleTimeout),this.idleTimeout=null),this.pdfViewer.forceRendering(t)||this.isThumbnailViewEnabled&&this.pdfThumbnailViewer?.forceRendering()||this.printing||this.onIdle&&(this.idleTimeout=setTimeout(this.onIdle.bind(this),3e4))}getHighestPriority(t,e,i,s=!1){const n=t.views,r=n.length;if(0===r)return null;for(let t=0;t<r;t++){const e=n[t].view;if(!this.isViewFinished(e))return e}const a=t.first.id,o=t.last.id;if(o-a+1>r){const s=t.ids;for(let t=1,n=o-a;t<n;t++){const n=i?a+t:o-t;if(s.has(n))continue;const r=e[n-1];if(!this.isViewFinished(r))return r}}let l=i?o:a-2,h=e[l];return h&&!this.isViewFinished(h)||s&&(l+=i?1:-1,h=e[l],h&&!this.isViewFinished(h))?h:null}isViewFinished(t){return t.renderingState===xn.FINISHED}renderView(t){switch(t.renderingState){case xn.FINISHED:return!1;case xn.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case xn.RUNNING:this.highestPriorityPage=t.renderingId;break;case xn.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally((()=>{this.renderHighestPriority()})).catch((t=>{t instanceof Zr||console.error("renderView:",t)}))}return!0}};const al=1e4,ol=5e3,ll=250;function hl(t){return Object.values(_r).includes(t)&&t!==_r.DISABLE}class dl{#Dh=new Set;#Rh=0;constructor(t){this.#Rh=t}push(t){const e=this.#Dh;e.has(t)&&e.delete(t),e.add(t),e.size>this.#Rh&&this.#Nh()}resize(t,e=null){this.#Rh=t;const i=this.#Dh;if(e){const t=i.size;let s=1;for(const n of i)if(e.has(n.id)&&(i.delete(n),i.add(n)),++s>t)break}for(;i.size>this.#Rh;)this.#Nh()}has(t){return this.#Dh.has(t)}[Symbol.iterator](){return this.#Dh.keys()}#Nh(){const t=this.#Dh.keys().next().value;t?.destroy(),this.#Dh.delete(t)}}class cl{#Fh=null;#k=null;#Oh=null;#Bh=_r.NONE;#jh=null;#ql=Cr.ENABLE_FORMS;#Vh=null;#Hh=null;#li=!1;#U=!1;#Vl=!1;#$=!1;#W=!1;#tl=null;#nt=null;#zh=null;#Uh=null;#$h=!1;#Wh=null;#Gh=!1;#qh=0;#Xh=new ResizeObserver(this.#Kh.bind(this));#Yh=null;#Qh=null;#Jh=!0;#nh=Mn;constructor(t){const e="4.10.38";if(la!==e)throw new Error(`The API version "${la}" does not match the Viewer version "${e}".`);if(this.container=t.container,this.viewer=t.viewer||t.container.firstElementChild,"DIV"!==this.container?.tagName||"DIV"!==this.viewer?.tagName)throw new Error("Invalid `container` and/or `viewer` option.");if(this.container.offsetParent&&"absolute"!==getComputedStyle(this.container).position)throw new Error("The `container` must be absolutely positioned.");this.#Xh.observe(this.container),this.eventBus=t.eventBus,this.linkService=t.linkService||new vr,this.downloadManager=t.downloadManager||null,this.findController=t.findController||null,this.#k=t.altTextManager||null,this.#Hh=t.editorUndoBar||null,this.findController&&(this.findController.onIsPageVisible=t=>this._getVisiblePages().ids.has(t)),this._scriptingManager=t.scriptingManager||null,this.#nh=t.textLayerMode??Mn,this.#ql=t.annotationMode??Cr.ENABLE_FORMS,this.#Bh=t.annotationEditorMode??_r.NONE,this.#Oh=t.annotationEditorHighlightColors||null,this.#U=!0===t.enableHighlightFloatingButton,this.#$=!0===t.enableUpdatedAddImage,this.#W=!0===t.enableNewAltTextWhenAddingImage,this.imageResourcesPath=t.imageResourcesPath||"",this.enablePrintAutoRotate=t.enablePrintAutoRotate||!1,this.removePageBorders=t.removePageBorders||!1,this.maxCanvasPixels=t.maxCanvasPixels,this.l10n=t.l10n,this.l10n||=new Lo,this.#Vl=t.enablePermissions||!1,this.pageColors=t.pageColors||null,this.#nt=t.mlManager||null,this.#li=t.enableHWA||!1,this.#Jh=!1!==t.supportsPinchToZoom,this.defaultRenderingQueue=!t.renderingQueue,this.defaultRenderingQueue?(this.renderingQueue=new rl,this.renderingQueue.setViewer(this)):this.renderingQueue=t.renderingQueue;const{abortSignal:i}=t;i?.addEventListener("abort",(()=>{this.#Xh.disconnect(),this.#Xh=null}),{once:!0}),this.scroll=function(t,e,i){const s=function(i){r||(r=window.requestAnimationFrame((function(){r=null;const i=t.scrollLeft,s=n.lastX;i!==s&&(n.right=i>s),n.lastX=i;const a=t.scrollTop,o=n.lastY;a!==o&&(n.down=a>o),n.lastY=a,e(n)})))},n={right:!0,down:!0,lastX:t.scrollLeft,lastY:t.scrollTop,_eventHandler:s};let r=null;return t.addEventListener("scroll",s,{useCapture:!0,signal:i}),i?.addEventListener("abort",(()=>window.cancelAnimationFrame(r)),{once:!0}),n}(this.container,this._scrollUpdate.bind(this),i),this.presentationModeState=Sn,this._resetView(),this.removePageBorders&&this.viewer.classList.add("removePageBorders"),this.#Zh(),this.eventBus._on("thumbnailrendered",(({pageNumber:t,pdfPage:e})=>{const i=this._pages[t-1];this.#Fh.has(i)||e?.cleanup()})),t.l10n||this.l10n.translate(this.container)}get pagesCount(){return this._pages.length}getPageView(t){return this._pages[t]}getCachedPageViews(){return new Set(this.#Fh)}get pageViewsReady(){return this._pages.every((t=>t?.pdfPage))}get renderForms(){return this.#ql===Cr.ENABLE_FORMS}get enableScripting(){return!!this._scriptingManager}get currentPageNumber(){return this._currentPageNumber}set currentPageNumber(t){if(!Number.isInteger(t))throw new Error("Invalid page number.");this.pdfDocument&&(this._setCurrentPageNumber(t,!0)||console.error(`currentPageNumber: "${t}" is not a valid page.`))}_setCurrentPageNumber(t,e=!1){if(this._currentPageNumber===t)return e&&this.#td(),!0;if(!(0<t&&t<=this.pagesCount))return!1;const i=this._currentPageNumber;return this._currentPageNumber=t,this.eventBus.dispatch("pagechanging",{source:this,pageNumber:t,pageLabel:this._pageLabels?.[t-1]??null,previous:i}),e&&this.#td(),!0}get currentPageLabel(){return this._pageLabels?.[this._currentPageNumber-1]??null}set currentPageLabel(t){if(!this.pdfDocument)return;let e=0|t;if(this._pageLabels){const i=this._pageLabels.indexOf(t);i>=0&&(e=i+1)}this._setCurrentPageNumber(e,!0)||console.error(`currentPageLabel: "${t}" is not a valid page.`)}get currentScale(){return 0!==this._currentScale?this._currentScale:1}set currentScale(t){if(isNaN(t))throw new Error("Invalid numeric scale.");this.pdfDocument&&this.#ed(t,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(t){this.pdfDocument&&this.#ed(t,{noScroll:!1})}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!Vn(t))throw new Error("Invalid pages rotation angle.");if(!this.pdfDocument)return;if((t%=360)<0&&(t+=360),this._pagesRotation===t)return;this._pagesRotation=t;const e=this._currentPageNumber;this.refresh(!0,{rotation:t}),this._currentScaleValue&&this.#ed(this._currentScaleValue,{noScroll:!0}),this.eventBus.dispatch("rotationchanging",{source:this,pagesRotation:t,pageNumber:e}),this.defaultRenderingQueue&&this.update()}get firstPagePromise(){return this.pdfDocument?this._firstPageCapability.promise:null}get onePageRendered(){return this.pdfDocument?this._onePageRenderedCapability.promise:null}get pagesPromise(){return this.pdfDocument?this._pagesCapability.promise:null}get _layerProperties(){const t=this;return ea(this,"_layerProperties",{get annotationEditorUIManager(){return t.#jh},get annotationStorage(){return t.pdfDocument?.annotationStorage},get downloadManager(){return t.downloadManager},get enableScripting(){return!!t._scriptingManager},get fieldObjectsPromise(){return t.pdfDocument?.getFieldObjects()},get findController(){return t.findController},get hasJSActionsPromise(){return t.pdfDocument?.hasJSActions()},get linkService(){return t.linkService}})}#id(t){const e={annotationEditorMode:this.#Bh,annotationMode:this.#ql,textLayerMode:this.#nh};return t?(t.includes(Qr.COPY)||this.#nh!==Mn||(e.textLayerMode=In),t.includes(Qr.MODIFY_CONTENTS)||(e.annotationEditorMode=_r.DISABLE),t.includes(Qr.MODIFY_ANNOTATIONS)||t.includes(Qr.FILL_INTERACTIVE_FORMS)||this.#ql!==Cr.ENABLE_FORMS||(e.annotationMode=Cr.ENABLE),e):e}async#sd(t){if("hidden"===document.visibilityState||!this.container.offsetParent||0===this._getVisiblePages().views.length)return;const e=Promise.withResolvers(),i=new AbortController;document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&e.resolve()}),{signal:"function"==typeof AbortSignal.any?AbortSignal.any([t,i.signal]):t}),await Promise.race([this._onePageRenderedCapability.promise,e.promise]),i.abort()}async getAllText(){const t=[],e=[];for(let i=1,s=this.pdfDocument.numPages;i<=s;++i){if(this.#Gh)return null;e.length=0;const s=await this.pdfDocument.getPage(i),{items:n}=await s.getTextContent();for(const t of n)t.str&&e.push(t.str),t.hasEOL&&e.push("\n");t.push(Fn(e.join("")))}return t.join("\n")}#nd(t,e){const i=document.getSelection(),{focusNode:s,anchorNode:n}=i;if(n&&s&&i.containsNode(this.#Wh)){if(this.#$h||t===In)return void ia(e);this.#$h=!0;const{classList:i}=this.viewer;i.add("copyAll");const s=new AbortController;window.addEventListener("keydown",(t=>this.#Gh="Escape"===t.key),{signal:s.signal}),this.getAllText().then((async t=>{null!==t&&await navigator.clipboard.writeText(t)})).catch((t=>{console.warn(`Something goes wrong when extracting the text: ${t.message}`)})).finally((()=>{this.#$h=!1,this.#Gh=!1,s.abort(),i.remove("copyAll")})),ia(e)}}setDocument(t){if(this.pdfDocument&&(this.eventBus.dispatch("pagesdestroy",{source:this}),this._cancelRendering(),this._resetView(),this.findController?.setDocument(null),this._scriptingManager?.setDocument(null),this.#jh?.destroy(),this.#jh=null),this.pdfDocument=t,!t)return;const e=t.numPages,i=t.getPage(1),s=t.getOptionalContentConfig({intent:"display"}),n=this.#Vl?t.getPermissions():Promise.resolve(),{eventBus:r,pageColors:a,viewer:o}=this;this.#tl=new AbortController;const{signal:l}=this.#tl;if(e>al){console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");const t=this._scrollMode=Ln.PAGE;r.dispatch("scrollmodechanged",{source:this,mode:t})}this._pagesCapability.promise.then((()=>{r.dispatch("pagesloaded",{source:this,pagesCount:e})}),(()=>{}));r._on("pagerender",(t=>{const e=this._pages[t.pageNumber-1];e&&this.#Fh.push(e)}),{signal:l});const h=t=>{t.cssTransform||(this._onePageRenderedCapability.resolve({timestamp:t.timestamp}),r._off("pagerendered",h))};r._on("pagerendered",h,{signal:l}),Promise.all([i,n]).then((([i,n])=>{if(t!==this.pdfDocument)return;this._firstPageCapability.resolve(i),this._optionalContentConfigPromise=s;const{annotationEditorMode:h,annotationMode:d,textLayerMode:c}=this.#id(n);if(c!==Tn){const t=this.#Wh=document.createElement("div");t.id="hiddenCopyElement",o.before(t)}if("function"==typeof AbortSignal.any&&h!==_r.DISABLE){const e=h;t.isPureXfa?console.warn("Warning: XFA-editing is not implemented."):hl(e)?(this.#jh=new xr(this.container,o,this.#k,r,t,a,this.#Oh,this.#U,this.#$,this.#W,this.#nt,this.#Hh,this.#Jh),r.dispatch("annotationeditoruimanager",{source:this,uiManager:this.#jh}),e!==_r.NONE&&(e===_r.STAMP&&this.#nt?.loadModel("altText"),this.#jh.updateMode(e))):console.error(`Invalid AnnotationEditor mode: ${e}`)}const u=this._scrollMode===Ln.PAGE?null:o,p=this.currentScale,g=i.getViewport({scale:p*Jr.PDF_TO_CSS_UNITS});o.style.setProperty("--scale-factor",g.scale),a?.background&&o.style.setProperty("--page-bg-color",a.background),"CanvasText"!==a?.foreground&&"Canvas"!==a?.background||(o.style.setProperty("--hcm-highlight-filter",t.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight")),o.style.setProperty("--hcm-highlight-selected-filter",t.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","ButtonText")));for(let t=1;t<=e;++t){const e=new el({container:u,eventBus:r,id:t,scale:p,defaultViewport:g.clone(),optionalContentConfigPromise:s,renderingQueue:this.renderingQueue,textLayerMode:c,annotationMode:d,imageResourcesPath:this.imageResourcesPath,maxCanvasPixels:this.maxCanvasPixels,pageColors:a,l10n:this.l10n,layerProperties:this._layerProperties,enableHWA:this.#li});this._pages.push(e)}this._pages[0]?.setPdfPage(i),this._scrollMode===Ln.PAGE?this.#rd():this._spreadMode!==kn.NONE&&this._updateSpreadMode(),this.#sd(l).then((async()=>{if(t!==this.pdfDocument)return;if(this.findController?.setDocument(t),this._scriptingManager?.setDocument(t),this.#Wh&&document.addEventListener("copy",this.#nd.bind(this,c),{signal:l}),this.#jh&&r.dispatch("annotationeditormodechanged",{source:this,mode:this.#Bh}),t.loadingParams.disableAutoFetch||e>ol)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%ll==0&&await e}})),r.dispatch("pagesinit",{source:this}),t.getMetadata().then((({info:e})=>{t===this.pdfDocument&&e.Language&&(o.lang=e.Language)})),this.defaultRenderingQueue&&this.update()})).catch((t=>{console.error("Unable to initialize viewer",t),this._pagesCapability.reject(t)}))}setPageLabels(t){if(this.pdfDocument){t?Array.isArray(t)&&this.pdfDocument.numPages===t.length?this._pageLabels=t:(this._pageLabels=null,console.error("setPageLabels: Invalid page labels.")):this._pageLabels=null;for(let t=0,e=this._pages.length;t<e;t++)this._pages[t].setPageLabel(this._pageLabels?.[t]??null)}}_resetView(){this._pages=[],this._currentPageNumber=1,this._currentScale=0,this._currentScaleValue=null,this._pageLabels=null,this.#Fh=new dl(10),this._location=null,this._pagesRotation=0,this._optionalContentConfigPromise=null,this._firstPageCapability=Promise.withResolvers(),this._onePageRenderedCapability=Promise.withResolvers(),this._pagesCapability=Promise.withResolvers(),this._scrollMode=Ln.VERTICAL,this._previousScrollMode=Ln.UNKNOWN,this._spreadMode=kn.NONE,this.#Yh={previousPageNumber:1,scrollDown:!0,pages:[]},this.#tl?.abort(),this.#tl=null,this.viewer.textContent="",this._updateScrollMode(),this.viewer.removeAttribute("lang"),this.#Wh?.remove(),this.#Wh=null,this.#ad()}#rd(){if(this._scrollMode!==Ln.PAGE)throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");const t=this._currentPageNumber,e=this.#Yh,i=this.viewer;if(i.textContent="",e.pages.length=0,this._spreadMode!==kn.NONE||this.isInPresentationMode){const s=new Set,n=this._spreadMode-1;-1===n?s.add(t-1):t%2!==n?(s.add(t-1),s.add(t)):(s.add(t-2),s.add(t-1));const r=document.createElement("div");if(r.className="spread",this.isInPresentationMode){const t=document.createElement("div");t.className="dummyPage",r.append(t)}for(const t of s){const i=this._pages[t];i&&(r.append(i.div),e.pages.push(i))}i.append(r)}else{const s=this._pages[t-1];i.append(s.div),e.pages.push(s)}e.scrollDown=t>=e.previousPageNumber,e.previousPageNumber=t}_scrollUpdate(){0!==this.pagesCount&&this.update()}#od(t,e=null){const{div:i,id:s}=t;if(this._currentPageNumber!==s&&this._setCurrentPageNumber(s),this._scrollMode===Ln.PAGE&&(this.#rd(),this.update()),!e&&!this.isInPresentationMode){const t=i.offsetLeft+i.clientLeft,s=t+i.clientWidth,{scrollLeft:n,clientWidth:r}=this.container;(this._scrollMode===Ln.HORIZONTAL||t<n||s>n+r)&&(e={left:0,top:0})}Dn(i,e),!this._currentScaleValue&&this._location&&(this._location=null)}#ld(t){return t===this._currentScale||Math.abs(t-this._currentScale)<1e-15}#hd(t,e,{noScroll:i=!1,preset:s=!1,drawingDelay:n=-1,origin:r=null}){if(this._currentScaleValue=e.toString(),this.#ld(t))return void(s&&this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:e}));this.viewer.style.setProperty("--scale-factor",t*Jr.PDF_TO_CSS_UNITS);const a=n>=0&&n<1e3;this.refresh(!0,{scale:t,drawingDelay:a?n:-1}),a&&(this.#Qh=setTimeout((()=>{this.#Qh=null,this.refresh()}),n));const o=this._currentScale;if(this._currentScale=t,!i){let e,i=this._currentPageNumber;if(!this._location||this.isInPresentationMode||this.isChangingPresentationMode||(i=this._location.pageNumber,e=[null,{name:"XYZ"},this._location.left,this._location.top,null]),this.scrollPageIntoView({pageNumber:i,destArray:e,allowNegativeOffset:!0}),Array.isArray(r)){const e=t/o-1,[i,s]=this.containerTopLeft;this.container.scrollLeft+=(r[0]-s)*e,this.container.scrollTop+=(r[1]-i)*e}}this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:s?e:void 0}),this.defaultRenderingQueue&&this.update()}get#dd(){return this._spreadMode!==kn.NONE&&this._scrollMode!==Ln.HORIZONTAL?2:1}#ed(t,e){let i=parseFloat(t);if(i>0)e.preset=!1,this.#hd(i,t,e);else{const s=this._pages[this._currentPageNumber-1];if(!s)return;let n=40,r=5;this.isInPresentationMode?(n=r=4,this._spreadMode!==kn.NONE&&(n*=2)):this.removePageBorders?n=r=0:this._scrollMode===Ln.HORIZONTAL&&([n,r]=[r,n]);const a=(this.container.clientWidth-n)/s.width*s.scale/this.#dd,o=(this.container.clientHeight-r)/s.height*s.scale;switch(t){case"page-actual":i=1;break;case"page-width":i=a;break;case"page-height":i=o;break;case"page-fit":i=Math.min(a,o);break;case"auto":const e=Hn(s)?a:Math.min(o,a);i=Math.min(1.25,e);break;default:return void console.error(`#setScale: "${t}" is an unknown zoom value.`)}e.preset=!0,this.#hd(i,t,e)}}#td(){const t=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&this.#ed(this._currentScaleValue,{noScroll:!0}),this.#od(t)}pageLabelToPageNumber(t){if(!this._pageLabels)return null;const e=this._pageLabels.indexOf(t);return e<0?null:e+1}scrollPageIntoView({pageNumber:t,destArray:e=null,allowNegativeOffset:i=!1,ignoreDestinationZoom:s=!1}){if(!this.pdfDocument)return;const n=Number.isInteger(t)&&this._pages[t-1];if(!n)return void console.error(`scrollPageIntoView: "${t}" is not a valid pageNumber parameter.`);if(this.isInPresentationMode||!e)return void this._setCurrentPageNumber(t,!0);let r,a,o=0,l=0,h=0,d=0;const c=n.rotation%180!=0,u=(c?n.height:n.width)/n.scale/Jr.PDF_TO_CSS_UNITS,p=(c?n.width:n.height)/n.scale/Jr.PDF_TO_CSS_UNITS;let g=0;switch(e[1].name){case"XYZ":o=e[2],l=e[3],g=e[4],o=null!==o?o:0,l=null!==l?l:p;break;case"Fit":case"FitB":g="page-fit";break;case"FitH":case"FitBH":l=e[2],g="page-width",null===l&&this._location?(o=this._location.left,l=this._location.top):("number"!=typeof l||l<0)&&(l=p);break;case"FitV":case"FitBV":o=e[2],h=u,d=p,g="page-height";break;case"FitR":o=e[2],l=e[3],h=e[4]-o,d=e[5]-l;let t=40,i=5;this.removePageBorders&&(t=i=0),r=(this.container.clientWidth-t)/h/Jr.PDF_TO_CSS_UNITS,a=(this.container.clientHeight-i)/d/Jr.PDF_TO_CSS_UNITS,g=Math.min(Math.abs(r),Math.abs(a));break;default:return void console.error(`scrollPageIntoView: "${e[1].name}" is not a valid destination type.`)}if(s||(g&&g!==this._currentScale?this.currentScaleValue=g:0===this._currentScale&&(this.currentScaleValue="auto")),"page-fit"===g&&!e[4])return void this.#od(n);const f=[n.viewport.convertToViewportPoint(o,l),n.viewport.convertToViewportPoint(o+h,l+d)];let m=Math.min(f[0][0],f[1][0]),b=Math.min(f[0][1],f[1][1]);i||(m=Math.max(m,0),b=Math.max(b,0)),this.#od(n,{left:m,top:b})}_updateLocation(t){const e=this._currentScale,i=this._currentScaleValue,s=parseFloat(i)===e?Math.round(1e4*e)/100:i,n=t.id,r=this._pages[n-1],a=this.container,o=r.getPagePoint(a.scrollLeft-t.x,a.scrollTop-t.y),l=Math.round(o[0]),h=Math.round(o[1]);let d=`#page=${n}`;this.isInPresentationMode||(d+=`&zoom=${s},${l},${h}`),this._location={pageNumber:n,scale:s,top:h,left:l,rotation:this._pagesRotation,pdfOpenParams:d}}update(){const t=this._getVisiblePages(),e=t.views,i=e.length;if(0===i)return;const s=Math.max(10,2*i+1);this.#Fh.resize(s,t.ids),this.renderingQueue.renderHighestPriority(t);const n=this._spreadMode===kn.NONE&&(this._scrollMode===Ln.PAGE||this._scrollMode===Ln.VERTICAL),r=this._currentPageNumber;let a=!1;for(const t of e){if(t.percent<100)break;if(t.id===r&&n){a=!0;break}}this._setCurrentPageNumber(a?r:e[0].id),this._updateLocation(t.first),this.eventBus.dispatch("updateviewarea",{source:this,location:this._location})}#cd(){const t=this._getVisiblePages(),e=[],{ids:i,views:s}=t;for(const t of s){const{view:s}=t;s.hasEditableAnnotations()?e.push(t):i.delete(s.id)}return 0===e.length?null:(this.renderingQueue.renderHighestPriority({first:e[0],last:e.at(-1),views:e,ids:i}),i)}containsElement(t){return this.container.contains(t)}focus(){this.container.focus()}get _isContainerRtl(){return"rtl"===getComputedStyle(this.container).direction}get isInPresentationMode(){return this.presentationModeState===Pn}get isChangingPresentationMode(){return this.presentationModeState===En}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===Ln.PAGE?this.#Yh.pages:this._pages,e=this._scrollMode===Ln.HORIZONTAL,i=e&&this._isContainerRtl;return function({scrollEl:t,views:e,sortByVisibility:i=!1,horizontal:s=!1,rtl:n=!1}){const r=t.scrollTop,a=r+t.clientHeight,o=t.scrollLeft,l=o+t.clientWidth,h=[],d=new Set,c=e.length;let u=On(e,s?function(t){const e=t.div,i=e.offsetLeft+e.clientLeft,s=i+e.clientWidth;return n?i<l:s>o}:function(t){const e=t.div;return e.offsetTop+e.clientTop+e.clientHeight>r});u>0&&u<c&&!s&&(u=function(t,e,i){if(t<2)return t;let s=e[t].div,n=s.offsetTop+s.clientTop;n>=i&&(s=e[t-1].div,n=s.offsetTop+s.clientTop);for(let i=t-2;i>=0&&(s=e[i].div,!(s.offsetTop+s.clientTop+s.clientHeight<=n));--i)t=i;return t}(u,e,r));let p=s?l:-1;for(let t=u;t<c;t++){const i=e[t],n=i.div,c=n.offsetLeft+n.clientLeft,u=n.offsetTop+n.clientTop,g=n.clientWidth,f=n.clientHeight,m=c+g,b=u+f;if(-1===p)b>=a&&(p=b);else if((s?c:u)>p)break;if(b<=r||u>=a||m<=o||c>=l)continue;const v=Math.max(0,r-u)+Math.max(0,b-a),w=(g-(Math.max(0,o-c)+Math.max(0,m-l)))/g,y=(f-v)/f*w*100|0;h.push({id:i.id,x:c,y:u,view:i,percent:y,widthPercent:100*w|0}),d.add(i.id)}const g=h[0],f=h.at(-1);return i&&h.sort((function(t,e){const i=t.percent-e.percent;return Math.abs(i)>.001?-i:t.id-e.id})),{first:g,last:f,views:h,ids:d}}({scrollEl:this.container,views:t,sortByVisibility:!0,horizontal:e,rtl:i})}cleanup(){for(const t of this._pages)t.renderingState!==xn.FINISHED&&t.reset()}_cancelRendering(){for(const t of this._pages)t.cancelRendering()}async#ud(t){if(t.pdfPage)return t.pdfPage;try{const e=await this.pdfDocument.getPage(t.id);return t.pdfPage||t.setPdfPage(e),e}catch(t){return console.error("Unable to get page for page view",t),null}}#pd(t){if(1===t.first?.id)return!0;if(t.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case Ln.PAGE:return this.#Yh.scrollDown;case Ln.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(t){const e=t||this._getVisiblePages(),i=this.#pd(e),s=this._spreadMode!==kn.NONE&&this._scrollMode!==Ln.HORIZONTAL,n=this.renderingQueue.getHighestPriority(e,this._pages,i,s);return!!n&&(this.#ud(n).then((()=>{this.renderingQueue.renderView(n)})),!0)}get hasEqualPageSizes(){const t=this._pages[0];for(let e=1,i=this._pages.length;e<i;++e){const i=this._pages[e];if(i.width!==t.width||i.height!==t.height)return!1}return!0}getPagesOverview(){let t;return this._pages.map((e=>{const i=e.pdfPage.getViewport({scale:1}),s=Hn(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(Ln).includes(t)&&t!==Ln.UNKNOWN}(t))throw new Error(`Invalid scroll mode: ${t}`);this.pagesCount>al||(this._previousScrollMode=this._scrollMode,this._scrollMode=t,this.eventBus.dispatch("scrollmodechanged",{source:this,mode:t}),this._updateScrollMode(this._currentPageNumber))}}_updateScrollMode(t=null){const e=this._scrollMode,i=this.viewer;i.classList.toggle("scrollHorizontal",e===Ln.HORIZONTAL),i.classList.toggle("scrollWrapped",e===Ln.WRAPPED),this.pdfDocument&&t&&(e===Ln.PAGE?this.#rd():this._previousScrollMode===Ln.PAGE&&this._updateSpreadMode(),this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#ed(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}get spreadMode(){return this._spreadMode}set spreadMode(t){if(this._spreadMode!==t){if(!function(t){return Number.isInteger(t)&&Object.values(kn).includes(t)&&t!==kn.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===Ln.PAGE)this.#rd();else if(e.textContent="",this._spreadMode===kn.NONE)for(const t of this._pages)e.append(t.div);else{const t=this._spreadMode-1;let s=null;for(let n=0,r=i.length;n<r;++n)null===s?(s=document.createElement("div"),s.className="spread",e.append(s)):n%2===t&&(s=s.cloneNode(!1),e.append(s)),s.append(i[n].div)}t&&(this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#ed(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}_getPageAdvance(t,e=!1){switch(this._scrollMode){case Ln.WRAPPED:{const{views:i}=this._getVisiblePages(),s=new Map;for(const{id:t,y:e,percent:n,widthPercent:r}of i){if(0===n||r<100)continue;let i=s.get(e);i||s.set(e,i||=[]),i.push(t)}for(const i of s.values()){const s=i.indexOf(t);if(-1===s)continue;const n=i.length;if(1===n)break;if(e)for(let e=s-1,n=0;e>=n;e--){const s=i[e],n=i[e+1]-1;if(s<n)return t-n}else for(let e=s+1,r=n;e<r;e++){const s=i[e],n=i[e-1]+1;if(s>n)return n-t}if(e){const e=i[0];if(e<t)return t-e+1}else{const e=i[n-1];if(e>t)return e-t+1}break}break}case Ln.HORIZONTAL:break;case Ln.PAGE:case Ln.VERTICAL:{if(this._spreadMode===kn.NONE)break;const i=this._spreadMode-1;if(e&&t%2!==i)break;if(!e&&t%2===i)break;const{views:s}=this._getVisiblePages(),n=e?t-1:t+1;for(const{id:t,percent:e,widthPercent:i}of s)if(t===n){if(e>0&&100===i)return 2;break}break}}return 1}nextPage(){const t=this._currentPageNumber,e=this.pagesCount;if(t>=e)return!1;const i=this._getPageAdvance(t,!1)||1;return this.currentPageNumber=Math.min(t+i,e),!0}previousPage(){const t=this._currentPageNumber;if(t<=1)return!1;const e=this._getPageAdvance(t,!0)||1;return this.currentPageNumber=Math.max(t-e,1),!0}updateScale({drawingDelay:t,scaleFactor:e=null,steps:i=null,origin:s}){if(null===i&&null===e)throw new Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided.");if(!this.pdfDocument)return;let n=this._currentScale;if(e>0&&1!==e)n=Math.round(n*e*100)/100;else if(i){const t=i>0?1.1:1/1.1,e=i>0?Math.ceil:Math.floor;i=Math.abs(i);do{n=e(10*(n*t).toFixed(2))/10}while(--i>0)}n=Math.max(.1,Math.min(10,n)),this.#ed(n,{noScroll:!1,drawingDelay:t,origin:s})}increaseScale(t={}){this.updateScale({...t,steps:t.steps??1})}decreaseScale(t={}){this.updateScale({...t,steps:-(t.steps??1)})}#Zh(t=this.container.clientHeight){t!==this.#qh&&(this.#qh=t,zn.setProperty("--viewer-container-height",`${t}px`))}#Kh(t){for(const e of t)if(e.target===this.container){this.#Zh(Math.floor(e.borderBoxSize[0].blockSize)),this.#Vh=null;break}}get containerTopLeft(){return this.#Vh||=[this.container.offsetTop,this.container.offsetLeft]}#ad(){this.#zh?.abort(),this.#zh=null,null!==this.#Uh&&(clearTimeout(this.#Uh),this.#Uh=null)}get annotationEditorMode(){return this.#jh?this.#Bh:_r.DISABLE}set annotationEditorMode({mode:t,editId:e=null,isFromKeyboard:i=!1}){if(!this.#jh)throw new Error("The AnnotationEditor is not enabled.");if(this.#Bh===t)return;if(!hl(t))throw new Error(`Invalid AnnotationEditor mode: ${t}`);if(!this.pdfDocument)return;t===_r.STAMP&&this.#nt?.loadModel("altText");const{eventBus:s}=this,n=()=>{this.#ad(),this.#Bh=t,this.#jh.updateMode(t,e,i),s.dispatch("annotationeditormodechanged",{source:this,mode:t})};if(t===_r.NONE||this.#Bh===_r.NONE){const e=t!==_r.NONE;e||this.pdfDocument.annotationStorage.resetModifiedIds();for(const t of this._pages)t.toggleEditingMode(e);const i=this.#cd();if(e&&i){this.#ad(),this.#zh=new AbortController;const t=AbortSignal.any([this.#tl.signal,this.#zh.signal]);return void s._on("pagerendered",(({pageNumber:t})=>{i.delete(t),0===i.size&&(this.#Uh=setTimeout(n,0))}),{signal:t})}}n()}refresh(t=!1,e=Object.create(null)){if(this.pdfDocument){for(const t of this._pages)t.update(e);null!==this.#Qh&&(clearTimeout(this.#Qh),this.#Qh=null),t||this.update()}}}class ul extends cl{_resetView(){super._resetView(),this._scrollMode=Ln.PAGE,this._spreadMode=kn.NONE}set scrollMode(t){}_updateScrollMode(){}set spreadMode(t){}_updateSpreadMode(){}}var pl,gl,fl,ml,bl,vl=_n.DownloadManager,wl=_n.EventBus,yl=_n.GenericL10n,Al=_n.PDFLinkService,_l=_n.PDFSinglePageViewer,xl=_n.PDFViewer,Sl=_n.SimpleLinkService,Cl=_n.XfaLayerBuilder;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},Il={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},Ll={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};class kl{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,r=t.offsetLeft+t.clientLeft;for(;s.clientHeight===s.scrollHeight&&s.clientWidth===s.scrollWidth||i&&(s.classList.contains("markedContent")||"hidden"===getComputedStyle(s).overflow);)if(n+=s.offsetTop,r+=s.offsetLeft,s=s.offsetParent,!s)return;e&&(void 0!==e.top&&(n+=e.top),void 0!==e.left&&(r+=e.left,s.scrollLeft=r)),s.scrollTop=n,s.scrollLeft=r}function Rl(t,e){const i=function(i){n||(n=window.requestAnimationFrame((function(){n=null;const i=t.scrollLeft,r=s.lastX;i!==r&&(s.right=i>r),s.lastX=i;const a=t.scrollTop,o=s.lastY;a!==o&&(s.down=a>o),s.lastY=a,e(s)})))},s={right:!0,down:!0,lastX:t.scrollLeft,lastY:t.scrollTop,_eventHandler:i};let n=null;return t.addEventListener("scroll",i,!0),s}const Nl=/\x00/g,Fl=/[\x01-\x1F]/g;function Ol(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 Bl({view:t,userUnit:e,rotate:i}){const[s,n,r,a]=t,o=i%180!=0,l=(r-s)/72*e,h=(a-n)/72*e;return{width:o?h:l,height:o?l:h}}function jl(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 Vl({scrollEl:t,views:e,sortByVisibility:i=!1,horizontal:s=!1,rtl:n=!1}){const r=t.scrollTop,a=r+t.clientHeight,o=t.scrollLeft,l=o+t.clientWidth;const h=[],d=new Set,c=e.length;let u=Ol(e,s?function(t){const e=t.div,i=e.offsetLeft+e.clientLeft,s=i+e.clientWidth;return n?i<l:s>o}:function(t){const e=t.div;return e.offsetTop+e.clientTop+e.clientHeight>r});u>0&&u<c&&!s&&(u=jl(u,e,r));let p=s?l:-1;for(let t=u;t<c;t++){const i=e[t],n=i.div,c=n.offsetLeft+n.clientLeft,u=n.offsetTop+n.clientTop,g=n.clientWidth,f=n.clientHeight,m=c+g,b=u+f;if(-1===p)b>=a&&(p=b);else if((s?c:u)>p)break;if(b<=r||u>=a||m<=o||c>=l)continue;const v=Math.max(0,r-u)+Math.max(0,b-a),w=(g-(Math.max(0,o-c)+Math.max(0,m-l)))/g,y=(f-v)/f*w*100|0;h.push({id:i.id,x:c,y:u,view:i,percent:y,widthPercent:100*w|0}),d.add(i.id)}const g=h[0],f=h.at(-1);return i&&h.sort((function(t,e){const i=t.percent-e.percent;return Math.abs(i)>.001?-i:t.id-e.id})),{first:g,last:f,views:h,ids:d}}function Hl(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 zl(t){const e=t.deltaMode;let i=Hl(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 $l(t){return Number.isInteger(t)&&Object.values(Il).includes(t)&&t!==Il.UNKNOWN}function Wl(t){return Number.isInteger(t)&&Object.values(Ll).includes(t)&&t!==Ll.UNKNOWN}function Gl(t){return t.width<=t.height}const ql=new Promise((function(t){window.requestAnimationFrame(t)})),Xl=document.documentElement.style;pl=new WeakMap,gl=new WeakMap,fl=new WeakMap,ml=new WeakMap,bl=new WeakMap;class Kl{constructor(){this.pdfViewer=null,this.pdfThumbnailViewer=null,this.onIdle=null,this.highestPriorityPage=null,this.idleTimeout=null,this.printing=!1,this.isThumbnailViewEnabled=!1}setViewer(t){this.pdfViewer=t}setThumbnailViewer(t){this.pdfThumbnailViewer=t}isHighestPriority(t){return this.highestPriorityPage===t.renderingId}hasViewer(){return!!this.pdfViewer}renderHighestPriority(t){var e,i;this.idleTimeout&&(clearTimeout(this.idleTimeout),this.idleTimeout=null),(null===(e=this.pdfViewer)||void 0===e?void 0:e.forceRendering(t))||this.isThumbnailViewEnabled&&(null===(i=this.pdfThumbnailViewer)||void 0===i?void 0:i.forceRendering())||this.printing||this.onIdle&&(this.idleTimeout=setTimeout(this.onIdle.bind(this),3e4))}getHighestPriority(t,e,i,s=!1){const n=t.views,r=n.length;if(0===r)return null;for(let t=0;t<r;t++){const e=n[t].view;if(!this.isViewFinished(e))return e}const a=t.first.id,o=t.last.id;if(o-a+1>r){const s=t.ids;for(let t=1,n=o-a;t<n;t++){const n=i?a+t:o-t;if(s.has(n))continue;const r=e[n-1];if(!this.isViewFinished(r))return r}}let l=i?o:a-2,h=e[l];return h&&!this.isViewFinished(h)||s&&(l+=i?1:-1,h=e[l],h&&!this.isViewFinished(h))?h:null}isViewFinished(t){return t.renderingState===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 bn||console.error(`renderView: "${t}"`)}))}return!0}}var Yl,Ql;class Jl{static getCanvas(t,e){const i=n(this,Yl,s(this,Yl,"f",Ql)||document.createElement("canvas"),"f",Ql);i.width=t,i.height=e;const r=i.getContext("2d",{alpha:!1});r.save(),r.fillStyle="rgb(255, 255, 255)",r.fillRect(0,0,t,e),r.restore();const a=i.getContext("2d");return[i,a]}static destroyCanvas(){const t=s(this,Yl,"f",Ql);t&&(t.width=0,t.height=0),n(this,Yl,null,"f",Ql)}}Yl=Jl,Ql={value:null};class Zl{constructor({container:t,eventBus:e,id:i,defaultViewport:s,optionalContentConfigPromise:n,linkService:r,renderingQueue:a,l10n:o,pageColors:l,store:h,thumbnailWidth:d}){this.container=t,this.eventBus=e,this.id=i,this.renderingId="thumbnail"+i,this.pageLabel=null,this.store=h,this.loaded=!1,this.pdfPage=null,this.rotation=0,this.viewport=s,this.pdfPageRotate=s.rotation,this._optionalContentConfigPromise=n||null,this.pageColors=l||null,this.linkService=r,this.renderingQueue=a,this.renderTask=null,this.renderingState=El.INITIAL,this.resume=null;const c=this.viewport.width,u=c/this.viewport.height;this.canvasWidth=d,this.canvasHeight=this.canvasWidth/u|0,this.scale=this.canvasWidth/c,this.l10n=o,this.canvas=null,this.src=null;const p=document.createElement("div");p.className="thumbnail pdfSlickThumbHolder",p.setAttribute("data-page-number",this.id.toString()),this.div=p,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=El.INITIAL;const t=this.viewport.width,e=t/this.viewport.height;this.canvasHeight=this.canvasWidth/e|0,this.scale=this.canvasWidth/t,this.div.removeAttribute("data-loaded"),this.loaded=!1,this.canvas&&(this.canvas.width=0,this.canvas.height=0,delete this.canvas)}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}_getPageDrawContext(t=1){const e=document.createElement("canvas"),i=e.getContext("2d",{alpha:!1}),s=new kl;e.width=t*this.canvasWidth*s.sx|0,e.height=t*this.canvasHeight*s.sy|0;return{ctx:i,canvas:e,transform:s.scaled?[s.sx,0,0,s.sy,0,0]:null}}_convertCanvasToImage(t){if(this.renderingState!==El.FINISHED)throw new Error("_convertCanvasToImage: Rendering has not finished.");const e=this._reduceImage(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}draw(){if(this.renderingState!==El.INITIAL)return console.error("Must be in new state before drawing"),Promise.resolve();const{pdfPage:t}=this;if(!t)return this.renderingState=El.FINISHED,Promise.reject(new Error("pdfPage is not loaded"));this.renderingState=El.RUNNING;const e=(...t)=>i(this,[...t],void 0,(function*(t=null){if(o===this.renderTask&&(this.renderTask=null),!(t instanceof bn)&&(this.renderingState=El.FINISHED,this._convertCanvasToImage(n),t))throw t})),{ctx:s,canvas:n,transform:r}=this._getPageDrawContext(2),a={canvasContext:s,transform:r,viewport:this.viewport.clone({scale:2*this.scale}),optionalContentConfigPromise:this._optionalContentConfigPromise,pageColors:this.pageColors},o=this.renderTask=t.render(a);o.onContinue=t=>{if(!this.renderingQueue.isHighestPriority(this))return this.renderingState=El.PAUSED,void(this.resume=()=>{this.renderingState=El.RUNNING,t()});t()};const l=o.promise.then((function(){return e(null)}),(function(t){return e(t)}));return l.finally((()=>{n.width=0,n.height=0,this.eventBus.dispatch("thumbnailrendered",{source:this,pageNumber:this.id,pdfPage:this.pdfPage})})),l}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,this._convertCanvasToImage(e)))}_reduceImage(t){const{ctx:e,canvas:i}=this._getPageDrawContext();if(t.width<=2*i.width)return e.drawImage(t,0,0,t.width,t.height,0,0,i.width,i.height),i;let s=i.width<<3,n=i.height<<3;const[r,a]=Jl.getCanvas(s,n);for(;s>t.width||n>t.height;)s>>=1,n>>=1;for(a.drawImage(t,0,0,t.width,t.height,0,0,s,n);s>2*i.width;)a.drawImage(r,0,0,s,n,0,0,s>>1,n>>1),s>>=1,n>>=1;return e.drawImage(r,0,0,s,n,0,0,i.width,i.height),i}get _thumbPageTitle(){var t;return this.l10n.get("thumb_page_title",{page:null!==(t=this.pageLabel)&&void 0!==t?t:this.id})}get _thumbPageCanvas(){var t;return this.l10n.get("thumb_page_canvas",{page:null!==(t=this.pageLabel)&&void 0!==t?t:this.id})}setPageLabel(t){this.pageLabel="string"==typeof t?t:null}}var th,eh,ih;const sh="selected";class nh{constructor({container:t,eventBus:e,linkService:i,renderingQueue:s,l10n:n,pageColors:r,store:a,thumbnailWidth:o}){th.add(this),this.container=t,this.eventBus=e,this.linkService=i,this.renderingQueue=s,this.l10n=n,this.pageColors=r||null,this._thumbnails=[],this._currentPageNumber=0,this._pagesRotation=0,this._pageLabels=[],this.pdfDocument=null,this.store=a,this.thumbnailWidth=o,!this.pageColors||CSS.supports("color",this.pageColors.background)&&CSS.supports("color",this.pageColors.foreground)||((this.pageColors.background||this.pageColors.foreground)&&console.warn("PDFThumbnailViewer: Ignoring `pageColors`-option, since the browser doesn't support the values used."),this.pageColors=null),this.scroll=Rl(this.container,this._scrollUpdated.bind(this)),this._resetView()}_scrollUpdated(){this.renderingQueue.renderHighestPriority()}getThumbnail(t){return this._thumbnails[t]}_getVisibleThumbs(){return Vl({scrollEl:this.container,views:this._thumbnails})}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(sh),e.div.classList.add(sh)}const i=this._getVisibleThumbs(),{first:s,last:n,views:r}=i;if(r.length>0){let i=!1;if(t<=s.id||t>=(null==n?void 0:n.id))i=!0;else for(const{id:e,percent:s}of r)if(e===t){i=s<100;break}i&&Dl(e.div,{top:-19})}this._currentPageNumber=t,this.forceRendering()}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();Jl.destroyCanvas()}_resetView(){this._thumbnails=[],this._currentPageNumber=1,this._pageLabels=[],this._pagesRotation=0,this.container.textContent=""}setDocument(t){if(this.pdfDocument&&(this._cancelRendering(),this._resetView()),this.pdfDocument=t,!t)return;const e=t.getPage(1),i=t.getOptionalContentConfig();e.then((e=>{var s;const n=t.numPages,r=e.getViewport({scale:1});for(let t=1;t<=n;++t){const e=new Zl({container:this.container,eventBus:this.eventBus,id:t,defaultViewport:r.clone(),optionalContentConfigPromise:i,linkService:this.linkService,renderingQueue:this.renderingQueue,l10n:this.l10n,pageColors:this.pageColors,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(sh),this.store.getState()._setThumbnailsViews(this._thumbnails)})).catch((t=>{console.error("Unable to initialize thumbnail viewer",t)}))}_cancelRendering(){for(const t of this._thumbnails)t.cancelRendering()}setPageLabels(t){var e,i;if(this.pdfDocument){t?Array.isArray(t)&&this.pdfDocument.numPages===t.length?this._pageLabels=t:(this._pageLabels=[],console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.")):this._pageLabels=[];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=this._getVisibleThumbs(),e=s(this,th,"m",ih).call(this,t),i=this.renderingQueue.getHighestPriority(t,this._thumbnails,e);return!!i&&(s(this,th,"m",eh).call(this,i).then((()=>{this.renderingQueue.renderView(i)})),!0)}}var rh,ah;th=new WeakSet,eh=function(t){return i(this,void 0,void 0,(function*(){var e;if(null==t?void 0:t.pdfPage)return t.pdfPage;try{const i=yield null===(e=this.pdfDocument)||void 0===e?void 0:e.getPage(t.id);return(null==t?void 0:t.pdfPage)||t.setPdfPage(i),i}catch(t){return console.error("Unable to get page for thumb view",t),null}}))},ih=function(t){var e,i;return 1===(null===(e=t.first)||void 0===e?void 0:e.id)||(null===(i=t.last)||void 0===i?void 0:i.id)!==this._thumbnails.length&&this.scroll.down};rh=new WeakMap,ah=new WeakMap;let oh=null,lh=null,hh=new class{constructor(){rh.set(this,new WeakMap),ah.set(this,null)}get active(){return s(this,ah,"f")}register(t){return i(this,arguments,void 0,(function*(t,e=!1){if("object"!=typeof t)throw new Error("Not enough parameters.");if(s(this,rh,"f").has(t))throw new Error("The overlay is already registered.");s(this,rh,"f").set(t,{canForceClose:e}),t.addEventListener("cancel",(()=>{n(this,ah,null,"f")}))}))}unregister(t){return i(this,void 0,void 0,(function*(){if(!s(this,rh,"f").has(t))throw new Error("The overlay does not exist.");if(s(this,ah,"f")===t)throw new Error("The overlay cannot be removed while it is active.");s(this,rh,"f").delete(t)}))}open(t){return i(this,void 0,void 0,(function*(){if(!s(this,rh,"f").has(t))throw new Error("The overlay does not exist.");if(s(this,ah,"f")){if(s(this,ah,"f")===t)throw new Error("The overlay is already active.");if(!s(this,rh,"f").get(t).canForceClose)throw new Error("Another overlay is currently active.");yield this.close()}n(this,ah,t,"f"),t.showModal()}))}close(){return i(this,arguments,void 0,(function*(t=s(this,ah,"f")){if(!t||!s(this,rh,"f").has(t))throw new Error("The overlay does not exist.");if(!s(this,ah,"f"))throw new Error("The overlay is currently not active.");if(s(this,ah,"f")!==t)throw new Error("Another overlay is currently active.");t.close(),n(this,ah,null,"f")}))}};class dh{constructor(t,e,i,s,n=null,r=null,a){this.pdfDocument=t,this.pagesOverview=e,this.printContainer=i,this._printResolution=s||150,this._optionalContentConfigPromise=n||t.getOptionalContentConfig(),this._printAnnotationStoragePromise=r||Promise.resolve(),this.l10n=a,this.currentPage=-1,this.scratchCanvas=document.createElement("canvas")}layout(){this.throwIfInactive();const t=document.querySelector("body");null==t||t.setAttribute("data-pdfjsprinting","true");this.pagesOverview.every((t=>t.width===this.pagesOverview[0].width&&t.height===this.pagesOverview[0].height),this)||console.warn("Not all pages have the same size. The printed result may be incorrect!"),this.pageStyleSheet=document.createElement("style");const e=this.pagesOverview[0];this.pageStyleSheet.textContent="@page { size: "+e.width+"pt "+e.height+"pt;}",null==t||t.append(this.pageStyleSheet)}destroy(){if(oh!==this)return;this.printContainer.textContent="";const t=document.querySelector("body");null==t||t.removeAttribute("data-pdfjsprinting"),this.pageStyleSheet&&(this.pageStyleSheet.remove(),this.pageStyleSheet=null),this.scratchCanvas.width=this.scratchCanvas.height=0,this.scratchCanvas=null,oh=null,mh().then((function(){hh.active===lh&&hh.close(lh)}))}renderPages(){if(this.pdfDocument.isPureXfa)return function(t,e){const i=e.allXfaHtml,s=new Sl,n=Math.round(100*mn.PDF_TO_CSS_UNITS)/100;for(const r of null==i?void 0:i.children){const i=document.createElement("div");i.className="xfaPrintedPage",t.append(i);const a=new Cl({pdfPage:null,annotationStorage:e.annotationStorage,linkService:s,xfaHtml:r}),o=yn(r,{scale:n});a.render(o,"print"),i.append(a.div)}}(this.printContainer,this.pdfDocument),Promise.resolve();const t=this.pagesOverview.length,e=(i,s)=>{if(this.throwIfInactive(),++this.currentPage>=t)return gh(t,t,this.l10n),void i();const n=this.currentPage;gh(n,t,this.l10n),function(t,e,i,s,n,r,a){const o=oh.scratchCanvas,l=n/mn.PDF;o.width=Math.floor(s.width*l),o.height=Math.floor(s.height*l);const h=o.getContext("2d");return h.save(),h.fillStyle="rgb(255, 255, 255)",h.fillRect(0,0,o.width,o.height),h.restore(),Promise.all([e.getPage(i),a]).then((function([t,e]){const i={canvasContext:h,transform:[l,0,0,l,0,0],viewport:t.getViewport({scale:1,rotation:s.rotation}),intent:"print",annotationMode:pn.ENABLE_STORAGE,optionalContentConfigPromise:r,printAnnotationStorage:e};return t.render(i).promise}))}(0,this.pdfDocument,n+1,this.pagesOverview[n],this._printResolution,this._optionalContentConfigPromise,this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then((function(){e(i,s)}),s)};return new Promise(e)}useRenderedPage(){this.throwIfInactive();const t=document.createElement("img"),e=this.scratchCanvas;"toBlob"in e?e.toBlob((function(e){t.src=URL.createObjectURL(e)})):t.src=e.toDataURL();const i=document.createElement("div");return i.className="printedPage",i.append(t),this.printContainer.append(i),new Promise((function(e,i){t.onload=e,t.onerror=i}))}performPrint(){return this.throwIfInactive(),new Promise((t=>{setTimeout((()=>{this.active?(ch.call(window),setTimeout(t,20)):t()}),0)}))}get active(){return this===oh}throwIfInactive(){if(!this.active)throw new Error("This print request was cancelled or completed.")}}const ch=window.print;function uh(t){const e=document.createEvent("CustomEvent");e.initCustomEvent(t,!1,!1,"custom"),window.dispatchEvent(e)}function ph(){oh&&(oh.destroy(),uh("afterprint"))}function gh(t,e,i){lh||(lh=document.getElementById("printServiceDialog"));const s=Math.round(100*t/e),n=lh.querySelector("progress"),r=lh.querySelector(".relative-progress");n.value=s,i.get("print_progress_percent",{progress:s}).then((t=>{r.textContent=t}))}if(window.print=function(){if(oh)console.warn("Ignored window.print() because of a pending print job.");else{mh().then((function(){oh&&hh.open(lh)}));try{uh("beforeprint")}finally{if(!oh)return console.error("Expected print service to be initialized."),void mh().then((function(){hh.active===lh&&hh.close(lh)}));const t=oh;oh.renderPages().then((function(){return t.performPrint()})).catch((function(){})).then((function(){t.active&&ph()}))}}},window.addEventListener("keydown",(function(t){80!==t.keyCode||!t.ctrlKey&&!t.metaKey||t.altKey||t.shiftKey||(window.print(),t.preventDefault(),t.stopImmediatePropagation())}),!0),"onbeforeprint"in window){const t=function(t){"custom"!==t.detail&&t.stopImmediatePropagation()};window.addEventListener("beforeprint",t),window.addEventListener("afterprint",t)}let fh;function mh(){if(!fh){if(!hh)throw new Error("The overlay manager has not yet been initialized.");lh||(lh=document.getElementById("printServiceDialog")),fh=hh.register(lh,!0),document.getElementById("printCancel").onclick=ph,lh.addEventListener("close",ph)}return fh}const bh={instance:{supportsPrinting:!0,createPrintService(t,e,i,s,n,r,a){if(oh)throw new Error("The print service is created and active.");return oh=new dh(t,e,i,s,n,r,a),oh}}};var vh,wh,yh,Ah,_h,xh,Sh,Ch,Eh,Ph,Th,Mh,Ih,Lh,kh,Dh,Rh,Nh;const Fh="pdfPresentationMode",Oh="pdfPresentationModeControls",Bh=Math.PI/6;class jh{constructor({container:t,pdfViewer:e,eventBus:i}){vh.add(this),wh.set(this,Pl.UNKNOWN),yh.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 i(this,void 0,void 0,(function*(){const{container:t,pdfViewer:e}=this;if(this.active||!e.pagesCount||!t.requestFullscreen)return!1;s(this,vh,"m",Rh).call(this),s(this,vh,"m",_h).call(this,Pl.CHANGING);const i=t.requestFullscreen();n(this,yh,{pageNumber:e.currentPageNumber,scaleValue:e.currentScaleValue,scrollMode:e.scrollMode,spreadMode:null,annotationEditorMode:null},"f"),e.spreadMode===Ll.NONE||e.pageViewsReady&&e.hasEqualPageSizes||(console.warn("Ignoring Spread modes when entering PresentationMode, since the document may contain varying page sizes."),s(this,yh,"f").spreadMode=e.spreadMode),e.annotationEditorMode.mode!==un.DISABLE&&(s(this,yh,"f").annotationEditorMode=e.annotationEditorMode.mode);try{return yield i,e.focus(),!0}catch(t){s(this,vh,"m",Nh).call(this),s(this,vh,"m",_h).call(this,Pl.NORMAL)}return!1}))}get active(){return s(this,wh,"f")===Pl.CHANGING||s(this,wh,"f")===Pl.FULLSCREEN}}wh=new WeakMap,yh=new WeakMap,vh=new WeakSet,Ah=function(t){if(!this.active)return;t.preventDefault();const e=zl(t),i=Date.now(),n=this.mouseScrollTimeStamp;if(!(i>n&&i-n<50)&&((this.mouseScrollDelta>0&&e<0||this.mouseScrollDelta<0&&e>0)&&s(this,vh,"m",Mh).call(this),this.mouseScrollDelta+=e,Math.abs(this.mouseScrollDelta)>=.1)){const t=this.mouseScrollDelta;s(this,vh,"m",Mh).call(this);(t>0?this.pdfViewer.previousPage():this.pdfViewer.nextPage())&&(this.mouseScrollTimeStamp=i)}},_h=function(t){n(this,wh,t,"f"),this.eventBus.dispatch("presentationmodechanged",{source:this,state:t})},xh=function(){var t;s(this,vh,"m",_h).call(this,Pl.FULLSCREEN),this.container.classList.add(Fh),setTimeout((()=>{this.pdfViewer.scrollMode=Il.PAGE,null!==s(this,yh,"f").spreadMode&&(this.pdfViewer.spreadMode=Ll.NONE),this.pdfViewer.currentPageNumber=s(this,yh,"f").pageNumber,this.pdfViewer.currentScaleValue="page-fit",null!==s(this,yh,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:un.NONE})}),0),s(this,vh,"m",Lh).call(this),s(this,vh,"m",Ph).call(this),this.contextMenuOpen=!1,null===(t=window.getSelection())||void 0===t||t.removeAllRanges()},Sh=function(){const t=this.pdfViewer.currentPageNumber;this.container.classList.remove(Fh),setTimeout((()=>{var e;s(this,vh,"m",Nh).call(this),s(this,vh,"m",_h).call(this,Pl.NORMAL),this.pdfViewer.scrollMode=s(this,yh,"f").scrollMode,null!==(null===(e=s(this,yh,"f"))||void 0===e?void 0:e.spreadMode)&&(this.pdfViewer.spreadMode=s(this,yh,"f").spreadMode),this.pdfViewer.currentScaleValue=s(this,yh,"f").scaleValue,this.pdfViewer.currentPageNumber=t,null!==s(this,yh,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:s(this,yh,"f").annotationEditorMode}),n(this,yh,null,"f")}),0),s(this,vh,"m",kh).call(this),s(this,vh,"m",Th).call(this),s(this,vh,"m",Mh).call(this),this.contextMenuOpen=!1},Ch=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()))},Eh=function(){this.contextMenuOpen=!0},Ph=function(){this.controlsTimeout?clearTimeout(this.controlsTimeout):this.container.classList.add(Oh),this.controlsTimeout=setTimeout((()=>{this.container.classList.remove(Oh),delete this.controlsTimeout}),3e3)},Th=function(){this.controlsTimeout&&(clearTimeout(this.controlsTimeout),this.container.classList.remove(Oh),delete this.controlsTimeout)},Mh=function(){this.mouseScrollTimeStamp=0,this.mouseScrollDelta=0},Ih=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<=Bh||n>=Math.PI-Bh)?e=i:Math.abs(s)>50&&Math.abs(n-Math.PI/2)<=Bh&&(e=s),e>0?this.pdfViewer.previousPage():e<0&&this.pdfViewer.nextPage()}},Lh=function(){this.showControlsBind=s(this,vh,"m",Ph).bind(this),this.mouseDownBind=s(this,vh,"m",Ch).bind(this),this.mouseWheelBind=s(this,vh,"m",Ah).bind(this),this.resetMouseScrollStateBind=s(this,vh,"m",Mh).bind(this),this.contextMenuBind=s(this,vh,"m",Eh).bind(this),this.touchSwipeBind=s(this,vh,"m",Ih).bind(this),window.addEventListener("mousemove",this.showControlsBind),window.addEventListener("mousedown",this.mouseDownBind),window.addEventListener("wheel",this.mouseWheelBind,{passive:!1}),window.addEventListener("keydown",this.resetMouseScrollStateBind),window.addEventListener("contextmenu",this.contextMenuBind),window.addEventListener("touchstart",this.touchSwipeBind),window.addEventListener("touchmove",this.touchSwipeBind),window.addEventListener("touchend",this.touchSwipeBind)},kh=function(){window.removeEventListener("mousemove",this.showControlsBind),window.removeEventListener("mousedown",this.mouseDownBind),window.removeEventListener("wheel",this.mouseWheelBind,{passive:!1}),window.removeEventListener("keydown",this.resetMouseScrollStateBind),window.removeEventListener("contextmenu",this.contextMenuBind),window.removeEventListener("touchstart",this.touchSwipeBind),window.removeEventListener("touchmove",this.touchSwipeBind),window.removeEventListener("touchend",this.touchSwipeBind),delete this.showControlsBind,delete this.mouseDownBind,delete this.mouseWheelBind,delete this.resetMouseScrollStateBind,delete this.contextMenuBind,delete this.touchSwipeBind},Dh=function(){document.fullscreenElement?s(this,vh,"m",xh).call(this):s(this,vh,"m",Sh).call(this)},Rh=function(){this.fullscreenChangeBind=s(this,vh,"m",Dh).bind(this),window.addEventListener("fullscreenchange",this.fullscreenChangeBind)},Nh=function(){window.removeEventListener("fullscreenchange",this.fullscreenChangeBind),delete this.fullscreenChangeBind};const Vh=t=>{let e;const i=new Set,s=(t,s)=>{const n="function"==typeof t?t(e):t;if(!Object.is(n,e)){const t=e;e=(null!=s?s:"object"!=typeof n||null===n)?n:Object.assign({},e,n),i.forEach((i=>i(e,t)))}},n=()=>e,r={setState:s,getState:n,getInitialState:()=>a,subscribe:t=>(i.add(t),()=>i.delete(t))},a=e=t(s,n,r);return r},Hh={isDocumentLoaded:!1,pagesReady:!1,url:null,numPages:0,pageNumber:0,scale:0,scaleValue:"auto",pagesRotation:0,spreadMode:Ll.UNKNOWN,scrollMode:Il.UNKNOWN,documentOutline:null,attachments:new Map,thumbnails:new Map,thumbnailViews:new Map,annotationEditorMode:un.NONE,pdfSlick:null},zh=()=>{return(t=(t,e)=>Object.assign(Object.assign({},Hh),{_setThumbnailView:(i,s)=>{const n=new Map(e().thumbnails),r=new Map(e().thumbnailViews),{canvasWidth:a,canvasHeight:o,scale:l,rotation:h,loaded:d,pageLabel:c,src:u=null}=s;r.set(i,s),n.set(i,{pageNumber:i,width:a,height:o,scale:l,rotation:h,loaded:d,pageLabel:c,src:u}),t({thumbnailViews:r,thumbnails:n})},_setThumbnailsViews:e=>{const i=new Map(e.map((t=>[t.id,t]))),s=new Map(e.map((t=>{const{canvasWidth:e,canvasHeight:i,scale:s,rotation:n,loaded:r,pageLabel:a,src:o=null}=t;return[t.id,{pageNumber:t.id,width:e,height:i,scale:s,rotation:n,loaded:r,pageLabel:a,src:o}]})));t({thumbnailViews:i,thumbnails:s})}}))?Vh(t):Vh;var t};var Uh,$h,Wh,Gh,qh,Xh,Kh,Yh,Qh,Jh,Zh,td,ed,id,sd,nd,rd,ad,od;gn.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:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("index.js",document.baseURI).href).toString();const ld={"8.5x11":"Letter","8.5x14":"Legal"},hd={"297x420":"A3","210x297":"A4"};function dd(t,e,i){return i[`${e?t.width:t.height}x${e?t.height:t.width}`]}$h=new WeakMap,Wh=new WeakMap,Gh=new WeakMap,qh=new WeakMap,Xh=new WeakMap,Kh=new WeakMap,Yh=new WeakMap,Uh=new WeakSet,Qh=function(){return i(this,void 0,void 0,(function*(){var t;const e=this.document,i=null!==(t=yield e.getPageLabels())&&void 0!==t?t:[],s=i.length;let n=0,r=0;for(let t=0;t<s;t++){const e=i[t];if(e===(t+1).toString())n++;else{if(""!==e)break;r++}}if(n>=s||r>=s)return;const{viewer:a,thumbnailViewer:o}=this;a.setPageLabels(i),null==o||o.setPageLabels(i)}))},Jh=function(){return i(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=>s(this,Uh,"m",Zh).call(this,Bl(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:fn.toDateObject(t.CreationDate),modificationDate:fn.toDateObject(t.ModDate),isLinearized:t.IsLinearized,pageSize:i})}))},Zh=function(t,e){return i(this,void 0,void 0,(function*(){if(!t)return;e%180!=0&&(t={width:t.height,height:t.width});const i=Gl(t);let s={width:Math.round(100*t.width)/100,height:Math.round(100*t.height)/100},n={width:Math.round(25.4*t.width*10)/10,height:Math.round(25.4*t.height*10)/10},r=dd(s,i,ld)||dd(n,i,hd);if(!(r||Number.isInteger(n.width)&&Number.isInteger(n.height))){const e={width:25.4*t.width,height:25.4*t.height},a={width:Math.round(n.width),height:Math.round(n.height)};Math.abs(e.width-a.width)<.1&&Math.abs(e.height-a.height)<.1&&(r=dd(a,i,hd),r&&(s={width:Math.round(a.width/25.4*100)/100,height:Math.round(a.height/25.4*100)/100},n=a))}const[{width:a,height:o},l,h,d]=yield Promise.all([s,this.l10n.get("document_properties_page_size_unit_inches",null),r&&this.l10n.get(`document_properties_page_size_name_${r.toLowerCase()}`,null),this.l10n.get("document_properties_page_size_orientation_"+(i?"portrait":"landscape"),null)]);return{width:a.toLocaleString(),height:o.toLocaleString(),unit:l,name:h,orientation:d}}))},td=function(){this.eventBus._on("pagesinit",s(this,Uh,"m",ed).bind(this)),this.eventBus._on("scalechanging",s(this,Uh,"m",rd).bind(this)),this.eventBus._on("pagechanging",s(this,Uh,"m",ad).bind(this)),this.eventBus._on("pagerendered",s(this,Uh,"m",od).bind(this)),this.eventBus._on("rotationchanging",s(this,Uh,"m",id).bind(this)),this.eventBus._on("switchspreadmode",s(this,Uh,"m",sd).bind(this)),this.eventBus._on("switchscrollmode",s(this,Uh,"m",nd).bind(this)),this.eventBus._on("beforeprint",this.beforePrint.bind(this)),this.eventBus._on("afterprint",this.afterPrint.bind(this)),window.onbeforeprint=t=>{this.eventBus.dispatch("beforeprint",{source:window})},window.onafterprint=t=>{this.eventBus.dispatch("afterprint",{source:window})}},ed=function(t){return i(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})}))},id=function({pagesRotation:t,pageNumber:e}){this.store.setState({pagesRotation:t}),this.thumbnailViewer&&(this.thumbnailViewer.pagesRotation=t),this.forceRendering(),this.viewer.currentPageNumber=e},sd=function({mode:t}){this.store.setState({spreadMode:t})},nd=function({mode:t}){this.store.setState({scrollMode:t})},rd=function({scale:t,presetValue:e}){this.store.setState({scale:t,scaleValue:e}),this.viewer.update()},ad=function({pageNumber:t}){var e;null===(e=this.thumbnailViewer)||void 0===e||e.scrollThumbnailIntoView(t),this.store.setState({pageNumber:t})},od=function({pageNumber:t,error:e}){var i;if(s(this,qh,"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)}},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=kl,t.PDFSlick=class{constructor({container:t,viewer:e,thumbs:i,store:r=zh(),options:a,onError:o}){var l,h,d,c,u,p,g,f,m,b,v,w,y,A,_;Uh.add(this),$h.set(this,void 0),Wh.set(this,void 0),Gh.set(this,void 0),qh.set(this,void 0),this.downloadManager=null,this.findController=null,this.pdfPresentationMode=null,this.document=null,Xh.set(this,void 0),Kh.set(this,void 0),Yh.set(this,void 0),n(this,Wh,t,"f"),n(this,Gh,e,"f"),n(this,qh,i,"f"),n(this,Yh,o,"f"),this.l10n=null!==(l=null==a?void 0:a.l10n)&&void 0!==l?l:new yl(navigator.language),this.downloadManager=new vl,this.textLayerMode=null!==(h=null==a?void 0:a.textLayerMode)&&void 0!==h?h:Ml.ENABLE,n(this,Xh,null!==(d=null==a?void 0:a.annotationMode)&&void 0!==d?d:pn.ENABLE_FORMS,"f"),n(this,Kh,null!==(c=null==a?void 0:a.annotationEditorMode)&&void 0!==c?c:un.NONE,"f"),this.annotationEditorHighlightColors=null!==(u=null==a?void 0:a.annotationEditorHighlightColors)&&void 0!==u?u:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",this.removePageBorders=null!==(p=null==a?void 0:a.removePageBorders)&&void 0!==p&&p,this.singlePageViewer=null!==(g=null==a?void 0:a.singlePageViewer)&&void 0!==g&&g,this.enablePrintAutoRotate=null!==(f=null==a?void 0:a.enablePrintAutoRotate)&&void 0!==f&&f,this.useOnlyCssZoom=null!==(m=null==a?void 0:a.useOnlyCssZoom)&&void 0!==m&&m,this.pageColors=null!==(b=null==a?void 0:a.pageColors)&&void 0!==b?b:null,this.maxCanvasPixels=null!==(v=null==a?void 0:a.maxCanvasPixels)&&void 0!==v?v:16777216,this.printResolution=null!==(w=null==a?void 0:a.printResolution)&&void 0!==w?w:96,this.thumbnailWidth=null!==(y=null==a?void 0:a.thumbnailWidth)&&void 0!==y?y:125,this.getDocumentParams=null!==(A=null==a?void 0:a.getDocumentParams)&&void 0!==A?A:{},!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=r;const x=new Kl;x.onIdle=this._cleanup.bind(this),x.isThumbnailViewEnabled=!0,n(this,$h,x,"f");const S=new wl,C=new Al({eventBus:S,externalLinkTarget:2,externalLinkRel:"noopener noreferrer nofollow",ignoreDestinationZoom:!1}),E=Object.assign(Object.assign({container:t},e&&{viewer:e}),{eventBus:S,linkService:C,renderingQueue:x,textLayerMode:this.textLayerMode,annotationEditorHighlightColors:this.annotationEditorHighlightColors,l10n:this.l10n,annotationMode:s(this,Xh,"f"),annotationEditorMode:s(this,Kh,"f"),removePageBorders:this.removePageBorders,imageResourcesPath:"/images/"}),P=this.singlePageViewer?new _l(E):new xl(E);x.setViewer(P),i&&(this.thumbnailViewer=new nh({container:i,eventBus:S,linkService:C,renderingQueue:x,l10n:this.l10n,pageColors:this.pageColors,store:r,thumbnailWidth:this.thumbnailWidth}),x.setThumbnailViewer(this.thumbnailViewer)),document.fullscreenEnabled&&(this.pdfPresentationMode=new jh({container:t,pdfViewer:P,eventBus:S})),this.eventBus=S,this.linkService=C,this.viewer=P,this.linkService.setViewer(P);const T=null!==(_=null==a?void 0:a.scaleValue)&&void 0!==_?_:"auto";this.store.setState({scaleValue:T})}loadDocument(t,e){return i(this,void 0,void 0,(function*(){var i,n,r,a,o;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===(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 l=null!==(r=null==e?void 0:e.filename)&&void 0!==r?r:wn(null===(a=this.url)||void 0===a?void 0:a.toString());this.filename=l;const h=vn(Object.assign(Object.assign({},this.getDocumentParams),{url:this.url,isEvalSupported:!1}));(null==e?void 0:e.onProgress)&&(h.onProgress=e.onProgress);const d=yield h.promise;this.document=d,this.viewer.setDocument(this.document),this.linkService.setDocument(this.document),this.thumbnailViewer&&(null===(o=this.thumbnailViewer)||void 0===o||o.setDocument(d)),s(this,Uh,"m",td).call(this),yield s(this,Uh,"m",Qh).call(this),this.store.setState({filename:l,numPages:d.numPages,pageNumber:1,isDocumentLoaded:!0,url:t.toString()});const c=yield d.getAttachments(),u=new Map(Object.keys(null!=c?c:{}).sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase()))).map((t=>[t,c[t]])));this.store.setState({attachments:u}),yield s(this,Uh,"m",Jh).call(this),this.forceRendering()}catch(t){s(this,Yh,"f")&&s(this,Yh,"f").call(this,t)}}))}forceRendering(t=!0){s(this,$h,"f").printing=!!this.printService,s(this,$h,"f").isThumbnailViewEnabled=t,s(this,$h,"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 i(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 i(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 bh.instance.supportsPrinting}beforePrint(){if(this.printService)return;if(!this.supportsPrinting)return;if(!this.viewer.pageViewsReady)return void this.l10n.get("printing_not_ready",null).then((t=>{window.alert(t)}));const t=this.viewer.getPagesOverview(),e=document.getElementById("printContainer"),i=this.printResolution,s=this.viewer.optionalContentConfigPromise,n=bh.instance.createPrintService(this.document,t,e,i,s,null,this.l10n);this.printService=n,this.forceRendering(),n.layout()}afterPrint(){var t;this.printService&&(this.printService.destroy(),this.printService=null,null===(t=this.document)||void 0===t||t.annotationStorage.resetModified()),this.forceRendering()}requestPresentationMode(){var t;null===(t=this.pdfPresentationMode)||void 0===t||t.request()}triggerPrinting(){this.supportsPrinting&&window.print()}_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(un.HIGHLIGHT),this.setAnnotationEditorParams([{type:cn.HIGHLIGHT_DEFAULT_COLOR,value:t}]),this.store.setState({highlightDefaultColor:t})}setSpreadMode(t){Wl(t)&&(this.viewer.spreadMode=t,this.dispatch("switchspreadmode",{mode:t}))}setScrollMode(t){$l(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)}},t.PresentationModeState=Pl,t.ProgressBar=class{constructor(t){pl.set(this,null),gl.set(this,null),fl.set(this,0),ml.set(this,null),bl.set(this,!0),n(this,pl,t.classList,"f"),n(this,ml,t.style,"f")}get percent(){return s(this,fl,"f")}set percent(t){var e,i,r,a,o,l;n(this,fl,(a=t,o=0,l=100,Math.min(Math.max(a,o),l)),"f"),isNaN(t)?null===(e=s(this,pl,"f"))||void 0===e||e.add("indeterminate"):(null===(i=s(this,pl,"f"))||void 0===i||i.remove("indeterminate"),null===(r=s(this,ml,"f"))||void 0===r||r.setProperty("--progressBar-percent",`${s(this,fl,"f")}%`))}setWidth(t){var e;if(!t)return;const i=t.parentNode.offsetWidth-t.offsetWidth;i>0&&(null===(e=s(this,ml,"f"))||void 0===e||e.setProperty("--progressBar-end-offset",`${i}px`))}setDisableAutoFetch(t=5e3){isNaN(s(this,fl,"f"))||(s(this,gl,"f")&&clearTimeout(s(this,gl,"f")),this.show(),n(this,gl,setTimeout((()=>{n(this,gl,null,"f"),this.hide()}),t),"f"))}hide(){var t;s(this,bl,"f")&&(n(this,bl,!1,"f"),null===(t=s(this,pl,"f"))||void 0===t||t.add("hidden"))}show(){var t;s(this,bl,"f")||(n(this,bl,!0,"f"),null===(t=s(this,pl,"f"))||void 0===t||t.remove("hidden"))}},t.RendererType={CANVAS:"canvas",SVG:"svg"},t.RenderingStates=El,t.SCROLLBAR_PADDING=40,t.ScrollMode=Il,t.SidebarView=Tl,t.SpreadMode=Ll,t.TextLayerMode=Ml,t.UNKNOWN_SCALE=0,t.VERTICAL_PADDING=5,t.animationStarted=ql,t.apiPageLayoutToViewerModes=function(t){let e=Il.VERTICAL,i=Ll.NONE;switch(t){case"SinglePage":e=Il.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=Il.PAGE;case"TwoColumnLeft":i=Ll.ODD;break;case"TwoPageRight":e=Il.PAGE;case"TwoColumnRight":i=Ll.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,r=1,a=1,o=1;for(;;){const t=n+a,e=r+o;if(e>8)break;i<=t/e?(a=t,o=e):(n=t,r=e)}return s=i-n/r<a/o-i?i===t?[n,r]:[r,n]:i===t?[a,o]:[o,a],s},t.backtrackBeforeAllVisibleElements=jl,t.binarySearchFirstItem=Ol,t.create=zh,t.docStyle=Xl,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=Bl,t.getVisibleElements=Vl,t.initialState=Hh,t.isPortraitOrientation=Gl,t.isValidRotation=Ul,t.isValidScrollMode=$l,t.isValidSpreadMode=Wl,t.noContextMenuHandler=function(t){t.preventDefault()},t.normalizeWheelEventDelta=zl,t.normalizeWheelEventDirection=Hl,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"string"!=typeof t?(console.error("The argument must be a string."),t):(e&&(t=t.replace(Fl," ")),t.replace(Nl,""))},t.roundToDivide=function(t,e){const i=t%e;return 0===i?t:Math.round(t-i+e)},t.scrollIntoView=Dl,t.watchScroll=Rl}));
|
|
22
|
+
*/var a={d:(t,e)=>{for(var i in e)a.o(e,i)&&!a.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},r=globalThis.pdfjsLib={};a.d(r,{AbortException:()=>vt,AnnotationEditorLayer:()=>hn,AnnotationEditorParamsType:()=>A,AnnotationEditorType:()=>y,AnnotationEditorUIManager:()=>se,AnnotationLayer:()=>Us,AnnotationMode:()=>w,ColorPicker:()=>Zs,DOMSVGFactory:()=>cs,DrawLayer:()=>dn,FeatureTest:()=>_t,GlobalWorkerOptions:()=>ci,ImageKind:()=>T,InvalidPDFException:()=>gt,MissingPDFException:()=>ft,OPS:()=>tt,OutputScale:()=>Xt,PDFDataRangeTransport:()=>Ki,PDFDateString:()=>zt,PDFWorker:()=>Zi,PasswordResponses:()=>et,PermissionFlag:()=>_,PixelsPerInch:()=>kt,RenderingCancelledException:()=>Dt,TextLayer:()=>ji,TouchManager:()=>ae,UnexpectedResponseException:()=>mt,Util:()=>St,VerbosityLevel:()=>Z,XfaLayer:()=>us,build:()=>rs,createValidAbsoluteUrl:()=>ht,fetchData:()=>It,getDocument:()=>Gi,getFilenameFromUrl:()=>Ft,getPdfFilenameFromUrl:()=>Ot,getXfaPageViewport:()=>Ut,isDataScheme:()=>Rt,isPdfFile:()=>Nt,noContextMenu:()=>Ht,normalizeUnicode:()=>Pt,setLayerDimensions:()=>qt,shadow:()=>dt,stopEvent:()=>Vt,version:()=>as});const o=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),l=[1,0,0,1,0,0],h=[.001,0,0,.001,0,0],d=1.35,c=1,u=2,p=4,g=16,f=32,m=64,b=128,v=256,w={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},y={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},A={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},_={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},x=0,S=1,C=2,E=3,P=3,M=4,T={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},k=1,I=2,L=3,D=4,R=5,N=6,F=7,O=8,B=9,j=10,H=11,V=12,z=13,U=14,$=15,W=16,G=17,q=20,X=1,K=2,Y=3,Q=4,J=5,Z={ERRORS:0,WARNINGS:1,INFOS:5},tt={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},et={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let it=Z.WARNINGS;function st(t){Number.isInteger(t)&&(it=t)}function nt(){return it}function at(t){it>=Z.INFOS&&console.log(`Info: ${t}`)}function rt(t){it>=Z.WARNINGS&&console.log(`Warning: ${t}`)}function ot(t){throw new Error(t)}function lt(t,e){t||ot(e)}function ht(t,e=null,i=null){if(!t)return null;try{if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch{}}const s=e?new URL(t,e):new URL(t);if(function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s))return s}catch{}return null}function dt(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}const ct=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class ut extends ct{constructor(t,e){super(t,"PasswordException"),this.code=e}}class pt extends ct{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}let gt=class extends ct{constructor(t){super(t,"InvalidPDFException")}},ft=class extends ct{constructor(t){super(t,"MissingPDFException")}},mt=class extends ct{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}};class bt extends ct{constructor(t){super(t,"FormatError")}}let vt=class extends ct{constructor(t){super(t,"AbortException")}};function wt(t){"object"==typeof t&&void 0!==t?.length||ot("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 yt(t){"string"!=typeof t&&ot("Invalid argument for stringToBytes");const e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}function At(t){const e=Object.create(null);for(const[i,s]of t)e[i]=s;return e}class _t{static get isLittleEndian(){return dt(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return dt(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return dt(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return dt(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){return"undefined"!=typeof navigator&&"string"==typeof navigator?.platform?dt(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof navigator?.userAgent&&navigator.userAgent.includes("Firefox")}):dt(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return dt(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const xt=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));let St=class{static makeHexColor(t,e,i){return`#${xt[t]}${xt[e]}${xt[i]}`}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){const i=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/i,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/i]}static getAxialAlignedBoundingBox(t,e){const i=this.applyTransform(t,e),s=this.applyTransform(t.slice(2,4),e),n=this.applyTransform([t[0],t[3]],e),a=this.applyTransform([t[2],t[1]],e);return[Math.min(i[0],s[0],n[0],a[0]),Math.min(i[1],s[1],n[1],a[1]),Math.max(i[0],s[0],n[0],a[0]),Math.max(i[1],s[1],n[1],a[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],i=t[0]*e[0]+t[1]*e[2],s=t[0]*e[1]+t[1]*e[3],n=t[2]*e[0]+t[3]*e[2],a=t[2]*e[1]+t[3]*e[3],r=(i+a)/2,o=Math.sqrt((i+a)**2-4*(i*a-n*s))/2,l=r+o||1,h=r-o||1;return[Math.sqrt(l),Math.sqrt(h)]}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>a?null:[i,n,s,a]}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){return 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)):l=[Math.min(t,r),Math.min(e,o),Math.max(t,r),Math.max(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),l}};let Ct=null,Et=null;function Pt(t){return Ct||(Ct=/([\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(Ct,((t,e,i)=>e?e.normalize("NFKC"):Et.get(i)))}const Mt="pdfjs_internal_id_";"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise((i=>{i(t(...e))}))});const Tt="http://www.w3.org/2000/svg";let kt=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function It(t,e="text"){if(jt(t,document.baseURI)){const i=await fetch(t);if(!i.ok)throw new Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise(((i,s)=>{const n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType=e,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE)if(200!==n.status&&0!==n.status)s(new Error(n.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void i(n.response)}i(n.responseText)}},n.send(null)}))}class Lt{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{userUnit:t,viewBox:e}=this,i=e.map((e=>e*t));return dt(this,"rawDims",{pageWidth:i[2]-i[0],pageHeight:i[3]-i[1],pageX:i[0],pageY:i[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new Lt({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){return St.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=St.applyTransform([t[0],t[1]],this.transform),i=St.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){return St.applyInverseTransform([t,e],this.transform)}}let Dt=class extends ct{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};function Rt(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function Nt(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function Ft(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function Ot(t,e="document.pdf"){if("string"!=typeof t)return e;if(Rt(t))return rt('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 Bt{started=Object.create(null);times=[];time(t){t in this.started&&rt(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||rt(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:t}of this.times)e=Math.max(t.length,e);for(const{name:i,start:s,end:n}of this.times)t.push(`${i.padEnd(e)} ${n-s}ms\n`);return t.join("")}}function jt(t,e){try{const{protocol:i}=e?new URL(t,e):new URL(t);return"http:"===i||"https:"===i}catch{return!1}}function Ht(t){t.preventDefault()}function Vt(t){t.preventDefault(),t.stopPropagation()}let zt=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 Ut(t,{scale:e=1,rotation:i=0}){const{width:s,height:n}=t.attributes.style,a=[0,0,parseInt(s),parseInt(n)];return new Lt({viewBox:a,userUnit:1,scale:e,rotation:i})}function $t(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):(rt(`Not a valid color format: "${t}"`),[0,0,0])}function Wt(t){const{a:e,b:i,c:s,d:n,e:a,f:r}=t.getTransform();return[e,i,s,n,a,r]}function Gt(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 qt(t,e,i=!1,s=!0){if(e instanceof Lt){const{pageWidth:s,pageHeight:n}=e.rawDims,{style:a}=t,r=_t.isCSSRoundSupported,o=`var(--scale-factor) * ${s}px`,l=`var(--scale-factor) * ${n}px`,h=r?`round(down, ${o}, var(--scale-round-x, 1px))`:`calc(${o})`,d=r?`round(down, ${l}, var(--scale-round-y, 1px))`:`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 Xt=class{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}};class Kt{#s=null;#n=null;#a;#r=null;#o=null;static#l=null;constructor(t){this.#a=t,Kt.#l||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"})}render(){const t=this.#s=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#a._uiManager._signal;t.addEventListener("contextmenu",Ht,{signal:e}),t.addEventListener("pointerdown",Kt.#h,{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.#d(),t}get div(){return this.#s}static#h(t){t.stopPropagation()}#c(t){this.#a._focusEventsAllowed=!1,Vt(t)}#u(t){this.#a._focusEventsAllowed=!0,Vt(t)}#p(t){const e=this.#a._uiManager._signal;t.addEventListener("focusin",this.#c.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Ht,{signal:e})}hide(){this.#s.classList.add("hidden"),this.#n?.hideDropdown()}show(){this.#s.classList.remove("hidden"),this.#o?.shown()}#d(){const{editorType:t,_uiManager:e}=this.#a,i=document.createElement("button");i.className="delete",i.tabIndex=0,i.setAttribute("data-l10n-id",Kt.#l[t]),this.#p(i),i.addEventListener("click",(t=>{e.delete()}),{signal:e._signal}),this.#r.append(i)}get#g(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#p(e),this.#r.prepend(e,this.#g),this.#o=t}addColorPicker(t){this.#n=t;const e=t.renderButton();this.#p(e),this.#r.prepend(e,this.#g)}remove(){this.#s.remove(),this.#n?.destroy(),this.#n=null}}class Yt{#r=null;#s=null;#f;constructor(t){this.#f=t}#m(){const t=this.#s=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",Ht,{signal:this.#f._signal});const e=this.#r=document.createElement("div");return e.className="buttons",t.append(e),this.#b(),t}#v(t,e){let i=0,s=0;for(const n of t){const t=n.y+n.height;if(t<i)continue;const 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.#v(e,i),{style:a}=this.#s||=this.#m();t.append(this.#s),a.insetInlineEnd=100*s+"%",a.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#s.remove()}#b(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const i=this.#f._signal;t.addEventListener("contextmenu",Ht,{signal:i}),t.addEventListener("click",(()=>{this.#f.highlightSelection("floating_button")}),{signal:i}),this.#r.append(t)}}function Qt(t,e,i){for(const s of i)e.addEventListener(s,t[s].bind(t))}class Jt{#w=0;get id(){return"pdfjs_internal_editor_"+this.#w++}}class Zt{#y=function(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),wt(t)}();#w=0;#A=null;static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>';return dt(this,"_isSVGFittingCanvas",e.decode().then((()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]))))}async#_(t,e){this.#A||=new Map;let i=this.#A.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#y}_${this.#w++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await It(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=Zt._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){rt(t),i=null}return this.#A.set(t,i),i&&this.#A.set(i.id,i),i}async getFromFile(t){const{lastModified:e,name:i,size:s,type:n}=t;return this.#_(`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return this.#_(t,t)}async getFromBlob(t,e){const i=await e;return this.#_(t,i)}async getFromId(t){this.#A||=new Map;const e=this.#A.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#A||=new Map;let i=this.#A.get(t);if(i?.bitmap)return i.refCounter+=1,i;const s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#y}_${this.#w++}`,refCounter:1,isSvg:!1},this.#A.set(t,i),this.#A.set(i.id,i),i}getSvgUrl(t){const e=this.#A.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#A||=new Map;const e=this.#A.get(t);if(!e)return;if(e.refCounter-=1,0!==e.refCounter)return;const{bitmap:i}=e;if(!e.url&&!e.file){const t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=t.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#y}_`)}}class te{#x=[];#S=!1;#C;#E=-1;constructor(t=128){this.#C=t}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:a=!1,keepUndo:r=!1}){if(s&&t(),this.#S)return;const o={cmd:t,undo:e,post:i,type:n};if(-1===this.#E)return this.#x.length>0&&(this.#x.length=0),this.#E=0,void this.#x.push(o);if(a&&this.#x[this.#E].type===n)return r&&(o.undo=this.#x[this.#E].undo),void(this.#x[this.#E]=o);const l=this.#E+1;l===this.#C?this.#x.splice(0,1):(this.#E=l,l<this.#x.length&&this.#x.splice(l)),this.#x.push(o)}undo(){if(-1===this.#E)return;this.#S=!0;const{undo:t,post:e}=this.#x[this.#E];t(),e?.(),this.#S=!1,this.#E-=1}redo(){if(this.#E<this.#x.length-1){this.#E+=1,this.#S=!0;const{cmd:t,post:e}=this.#x[this.#E];t(),e?.(),this.#S=!1}}hasSomethingToUndo(){return-1!==this.#E}hasSomethingToRedo(){return this.#E<this.#x.length-1}cleanType(t){if(-1!==this.#E){for(let e=this.#E;e>=0;e--)if(this.#x[e].type!==t)return this.#x.splice(e+1,this.#E-e),void(this.#E=e);this.#x.length=0,this.#E=-1}}destroy(){this.#x=null}}class ee{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=_t.platform;for(const[i,s,n={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1)))}}#P(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const i=this.callbacks.get(this.#P(e));if(!i)return;const{callback:s,options:{bubbles:n=!1,args:a=[],checker:r=null}}=i;r&&!r(t,e)||(s.bind(t,...a,e)(),n||Vt(e))}}class ie{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",document.body.append(e);for(const i of t.keys()){e.style.color=i;const s=window.getComputedStyle(e).color;t.set(i,$t(s))}e.remove()}(t),dt(this,"_colors",t)}convert(t){const e=$t(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 ie._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?St.makeHexColor(...e):t}}let se=class t{#M=new AbortController;#T=null;#k=new Map;#I=new Map;#L=null;#D=null;#R=null;#N=new te;#F=null;#O=null;#B=0;#j=new Set;#H=null;#V=null;#z=new Set;_editorUndoBar=null;#U=!1;#$=!1;#W=!1;#G=null;#q=null;#X=null;#K=null;#Y=!1;#Q=null;#J=new Jt;#Z=!1;#tt=!1;#et=null;#it=null;#st=null;#nt=null;#at=y.NONE;#rt=new Set;#ot=null;#lt=null;#ht=null;#dt={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#ct=[0,0];#ut=null;#pt=null;#gt=null;#ft=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const e=t.prototype,i=t=>t.#pt.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),s=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},n=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return dt(this,"_keyboardManager",new ee([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],e.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:s}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#pt.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#pt.contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-n,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-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){const p=this._signal=this.#M.signal;this.#pt=t,this.#gt=e,this.#L=i,this._eventBus=s,s._on("editingaction",this.onEditingAction.bind(this),{signal:p}),s._on("pagechanging",this.onPageChanging.bind(this),{signal:p}),s._on("scalechanging",this.onScaleChanging.bind(this),{signal:p}),s._on("rotationchanging",this.onRotationChanging.bind(this),{signal:p}),s._on("setpreference",this.onSetPreference.bind(this),{signal:p}),s._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:p}),this.#mt(),this.#bt(),this.#vt(),this.#D=n.annotationStorage,this.#G=n.filterFactory,this.#lt=a,this.#K=r||null,this.#U=o,this.#$=l,this.#W=h,this.#nt=d||null,this.viewParameters={realScale:kt.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=c||null,this._supportsPinchToZoom=!1!==u}destroy(){this.#ft?.resolve(),this.#ft=null,this.#M?.abort(),this.#M=null,this._signal=null;for(const t of this.#I.values())t.destroy();this.#I.clear(),this.#k.clear(),this.#z.clear(),this.#T=null,this.#rt.clear(),this.#N.destroy(),this.#L?.destroy(),this.#Q?.hide(),this.#Q=null,this.#q&&(clearTimeout(this.#q),this.#q=null),this.#ut&&(clearTimeout(this.#ut),this.#ut=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#nt}get useNewAltTextFlow(){return this.#$}get useNewAltTextWhenAddingImage(){return this.#W}get hcmFilter(){return dt(this,"hcmFilter",this.#lt?this.#G.addHCMFilter(this.#lt.foreground,this.#lt.background):"none")}get direction(){return dt(this,"direction",getComputedStyle(this.#pt).direction)}get highlightColors(){return dt(this,"highlightColors",this.#K?new Map(this.#K.split(",").map((t=>t.split("=").map((t=>t.trim()))))):null)}get highlightColorNames(){return dt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#O=t}setMainHighlightColorPicker(t){this.#st=t}editAltText(t,e=!1){this.#L?.editAltText(this,t,e)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){if("enableNewAltTextWhenAddingImage"===t)this.#W=e}onPageChanging({pageNumber:t}){this.#B=t-1}focusMainContainer(){this.#pt.focus()}findParent(t,e){for(const i of this.#I.values()){const{x:s,y:n,width: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.#gt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#z.add(t)}removeShouldRescale(t){this.#z.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*kt.PDF_TO_CSS_UNITS;for(const t of this.#z)t.onScaleChanging();this.#O?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#wt({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#yt(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const e of this.#I.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:a}=e,r=e.toString(),o=this.#wt(e).closest(".textLayer"),l=this.getSelectionBoxes(o);if(!l)return;e.empty();const h=this.#yt(o),d=this.#at===y.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(y.HIGHLIGHT,c):c()}#At(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#wt(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#Q||=new Yt(this),this.#Q.show(e,i,"ltr"===this.direction))}addToAnnotationStorage(t){t.isEmpty()||!this.#D||this.#D.has(t.id)||this.#D.setValue(t.id,t)}#_t(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#ot&&(this.#Q?.hide(),this.#ot=null,this.#xt({hasSelectedText:!1})));const{anchorNode:e}=t;if(e===this.#ot)return;const i=this.#wt(t).closest(".textLayer");if(i){if(this.#Q?.hide(),this.#ot=e,this.#xt({hasSelectedText:!0}),(this.#at===y.HIGHLIGHT||this.#at===y.NONE)&&(this.#at===y.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#Y=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#at===y.HIGHLIGHT?this.#yt(i):null;t?.toggleDrawing();const e=new AbortController,s=this.combinedSignal(e),n=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#St("main_toolbar"))};window.addEventListener("pointerup",n,{signal:s}),window.addEventListener("blur",n,{signal:s})}}else this.#ot&&(this.#Q?.hide(),this.#ot=null,this.#xt({hasSelectedText:!1}))}#St(t=""){this.#at===y.HIGHLIGHT?this.highlightSelection(t):this.#U&&this.#At()}#mt(){document.addEventListener("selectionchange",this.#_t.bind(this),{signal:this._signal})}#Ct(){if(this.#X)return;this.#X=new AbortController;const t=this.combinedSignal(this.#X);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#Et(){this.#X?.abort(),this.#X=null}blur(){if(this.isShiftKeyDown=!1,this.#Y&&(this.#Y=!1,this.#St("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#rt)if(e.div.contains(t)){this.#it=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#it)return;const[t,e]=this.#it;this.#it=null,e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}#vt(){if(this.#et)return;this.#et=new AbortController;const t=this.combinedSignal(this.#et);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#Pt(){this.#et?.abort(),this.#et=null}#Mt(){if(this.#F)return;this.#F=new AbortController;const t=this.combinedSignal(this.#F);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#Tt(){this.#F?.abort(),this.#F=null}#bt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#vt(),this.#Mt()}removeEditListeners(){this.#Pt(),this.#Tt()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of this.#V)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.#V)if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#T?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const t of this.#rt){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.#V)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 rt(`paste: "${t.message}".`)}if(!Array.isArray(i))return;this.unselectAll();const s=this.currentLayer;try{const t=[];for(const e of i){const i=await s.deserialize(e);if(!i)return;t.push(i)}const e=()=>{for(const e of t)this.#kt(e);this.#It(t)},n=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:n,mustExec:!0})}catch(t){rt(`paste: "${t.message}".`)}}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0),this.#at===y.NONE||this.isEditorHandlingKeyboard||t._keyboardManager.exec(this,e)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#Y&&(this.#Y=!1,this.#St("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#xt(t){Object.entries(t).some((([t,e])=>this.#dt[t]!==e))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#dt,t)}),this.#at===y.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#Lt([[A.HIGHLIGHT_FREE,!0]]))}#Lt(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#Ct(),this.#Mt(),this.#xt({isEditing:this.#at!==y.NONE,isEmpty:this.#Dt(),hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:this.#N.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Et(),this.#Tt(),this.#xt({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#V){this.#V=t;for(const t of this.#V)this.#Lt(t.defaultPropertiesToUpdate)}}getId(){return this.#J.id}get currentLayer(){return this.#I.get(this.#B)}getLayer(t){return this.#I.get(t)}get currentPageIndex(){return this.#B}addLayer(t){this.#I.set(t.pageIndex,t),this.#Z?t.enable():t.disable()}removeLayer(t){this.#I.delete(t.pageIndex)}async updateMode(t,e=null,i=!1){if(this.#at!==t&&(!this.#ft||(await this.#ft.promise,this.#ft))){if(this.#ft=Promise.withResolvers(),this.#at=t,t===y.NONE)return this.setEditingState(!1),this.#Rt(),this._editorUndoBar?.hide(),void this.#ft.resolve();this.setEditingState(!0),await this.#Nt(),this.unselectAll();for(const e of this.#I.values())e.updateMode(t);if(!e)return i&&this.addNewEditorFromKeyboard(),void this.#ft.resolve();for(const t of this.#k.values())t.annotationElementId===e?(this.setSelected(t),t.enterInEditMode()):t.unselect();this.#ft.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#at&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#V){switch(t){case A.CREATE:return void this.currentLayer.addNewEditor();case A.HIGHLIGHT_DEFAULT_COLOR:this.#st?.updateColor(e);break;case A.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#ht||=new Map).set(t,e),this.showAllEditors("highlight",e)}for(const i of this.#rt)i.updateParams(t,e);for(const i of this.#V)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(const i of this.#k.values())i.editorType===t&&i.show(e);(this.#ht?.get(A.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#Lt([[A.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#tt!==t){this.#tt=t;for(const e of this.#I.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#Nt(){if(!this.#Z){this.#Z=!0;const t=[];for(const e of this.#I.values())t.push(e.enable());await Promise.all(t);for(const t of this.#k.values())t.enable()}}#Rt(){if(this.unselectAll(),this.#Z){this.#Z=!1;for(const t of this.#I.values())t.disable();for(const t of this.#k.values())t.disable()}}getEditors(t){const e=[];for(const i of this.#k.values())i.pageIndex===t&&e.push(i);return e}getEditor(t){return this.#k.get(t)}addEditor(t){this.#k.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#q&&clearTimeout(this.#q),this.#q=setTimeout((()=>{this.focusMainContainer(),this.#q=null}),0)),this.#k.delete(t.id),this.unselect(t),t.annotationElementId&&this.#j.has(t.annotationElementId)||this.#D?.remove(t.id)}addDeletedAnnotationElement(t){this.#j.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#j.has(t)}removeDeletedAnnotationElement(t){this.#j.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#kt(t){const e=this.#I.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#T!==t&&(this.#T=t,t&&this.#Lt(t.propertiesToUpdate))}get#Ft(){let t=null;for(t of this.#rt);return t}updateUI(t){this.#Ft===t&&this.#Lt(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#Lt(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#rt.has(t))return this.#rt.delete(t),t.unselect(),void this.#xt({hasSelectedEditor:this.hasSelection});this.#rt.add(t),t.select(),this.#Lt(t.propertiesToUpdate),this.#xt({hasSelectedEditor:!0})}setSelected(t){this.#O?.commitOrRemove();for(const e of this.#rt)e!==t&&e.unselect();this.#rt.clear(),this.#rt.add(t),t.select(),this.#Lt(t.propertiesToUpdate),this.#xt({hasSelectedEditor:!0})}isSelected(t){return this.#rt.has(t)}get firstSelectedEditor(){return this.#rt.values().next().value}unselect(t){t.unselect(),this.#rt.delete(t),this.#xt({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#rt.size}get isEnterHandled(){return 1===this.#rt.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#N.undo(),this.#xt({hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Dt()}),this._editorUndoBar?.hide()}redo(){this.#N.redo(),this.#xt({hasSomethingToUndo:!0,hasSomethingToRedo:this.#N.hasSomethingToRedo(),isEmpty:this.#Dt()})}addCommands(t){this.#N.add(t),this.#xt({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Dt()})}cleanUndoStack(t){this.#N.cleanType(t)}#Dt(){if(0===this.#k.size)return!0;if(1===this.#k.size)for(const t of this.#k.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...this.#rt],i=()=>{for(const t of e)this.#kt(t)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(i,1===e.length?e[0].editorType:e.length);for(const t of e)t.remove()},undo:i,mustExec:!0})}commitOrRemove(){this.#T?.commitOrRemove()}hasSomethingToControl(){return this.#T||this.hasSelection}#It(t){for(const t of this.#rt)t.unselect();this.#rt.clear();for(const e of t)e.isEmpty()||(this.#rt.add(e),e.select());this.#xt({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#rt)t.commit();this.#It(this.#k.values())}unselectAll(){if((!this.#T||(this.#T.commitOrRemove(),this.#at===y.NONE))&&!this.#O?.commitOrRemove()&&this.hasSelection){for(const t of this.#rt)t.unselect();this.#rt.clear(),this.#xt({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#ct[0]+=t,this.#ct[1]+=e;const[s,n]=this.#ct,a=[...this.#rt];this.#ut&&clearTimeout(this.#ut),this.#ut=setTimeout((()=>{this.#ut=null,this.#ct[0]=this.#ct[1]=0,this.addCommands({cmd:()=>{for(const t of a)this.#k.has(t.id)&&t.translateInPage(s,n)},undo:()=>{for(const t of a)this.#k.has(t.id)&&t.translateInPage(-s,-n)},mustExec:!1})}),1e3);for(const i of a)i.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#H=new Map;for(const t of this.#rt)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.#I.get(s);n?t._setParentAndPosition(n,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(const[e,{newX:s,newY:n,newPageIndex: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.#rt.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#T===t}getActive(){return this.#T}getMode(){return this.#at}get imageManager(){return dt(this,"imageManager",new Zt)}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.#R||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#R?.delete(t)}renderAnnotationElement(t){const e=this.#R?.get(t.data.id);if(!e)return;const i=this.#D.getRawValue(e);i&&(this.#at!==y.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}};class ne{#o=null;#Ot=!1;#Bt=null;#jt=null;#Ht=null;#Vt=null;#zt=!1;#Ut=null;#a=null;#$t=null;#Wt=null;#Gt=!1;static#qt=null;static _l10n=null;constructor(t){this.#a=t,this.#Gt=t._uiManager.useNewAltTextFlow,ne.#qt||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){ne._l10n??=t}async render(){const t=this.#Bt=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#jt=document.createElement("span");t.append(e),this.#Gt?(t.classList.add("new"),t.setAttribute("data-l10n-id",ne.#qt.missing),e.setAttribute("data-l10n-id",ne.#qt["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const i=this.#a._uiManager._signal;t.addEventListener("contextmenu",Ht,{signal:i}),t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:i});const s=t=>{t.preventDefault(),this.#a._uiManager.editAltText(this.#a),this.#Gt&&this.#a._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#Xt}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",(e=>{e.target===t&&"Enter"===e.key&&(this.#zt=!0,s(e))}),{signal:i}),await this.#Kt(),t}get#Xt(){return(this.#o?"added":null===this.#o&&this.guessedText&&"review")||"missing"}finish(){this.#Bt&&(this.#Bt.focus({focusVisible:this.#zt}),this.#zt=!1)}isEmpty(){return this.#Gt?null===this.#o:!this.#o&&!this.#Ot}hasData(){return this.#Gt?null!==this.#o||!!this.#$t:this.isEmpty()}get guessedText(){return this.#$t}async setGuessedText(t){null===this.#o&&(this.#$t=t,this.#Wt=await ne._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#Kt())}toggleAltTextBadge(t=!1){if(!this.#Gt||this.#o)return this.#Ut?.remove(),void(this.#Ut=null);if(!this.#Ut){const t=this.#Ut=document.createElement("div");t.className="noAltTextBadge",this.#a.div.append(t)}this.#Ut.classList.toggle("hidden",!t)}serialize(t){let e=this.#o;return t||this.#$t!==e||(e=this.#Wt),{altText:e,decorative:this.#Ot,guessedText:this.#$t,textWithDisclaimer:this.#Wt}}get data(){return{altText:this.#o,decorative:this.#Ot}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:n=!1}){i&&(this.#$t=i,this.#Wt=s),this.#o===t&&this.#Ot===e||(n||(this.#o=t,this.#Ot=e),this.#Kt())}toggle(t=!1){this.#Bt&&(!t&&this.#Vt&&(clearTimeout(this.#Vt),this.#Vt=null),this.#Bt.disabled=!t)}shown(){this.#a._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#Xt}})}destroy(){this.#Bt?.remove(),this.#Bt=null,this.#jt=null,this.#Ht=null,this.#Ut?.remove(),this.#Ut=null}async#Kt(){const t=this.#Bt;if(!t)return;if(this.#Gt){if(t.classList.toggle("done",!!this.#o),t.setAttribute("data-l10n-id",ne.#qt[this.#Xt]),this.#jt?.setAttribute("data-l10n-id",ne.#qt[`${this.#Xt}-label`]),!this.#o)return void this.#Ht?.remove()}else{if(!this.#o&&!this.#Ot)return t.classList.remove("done"),void this.#Ht?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#Ht;if(!e){this.#Ht=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.#Vt),this.#Vt=null}),{once:!0}),t.addEventListener("mouseenter",(()=>{this.#Vt=setTimeout((()=>{this.#Vt=null,this.#Ht.classList.add("show"),this.#a._reportTelemetry({action:"alt_text_tooltip"})}),i)}),{signal:s}),t.addEventListener("mouseleave",(()=>{this.#Vt&&(clearTimeout(this.#Vt),this.#Vt=null),this.#Ht?.classList.remove("show")}),{signal:s})}this.#Ot?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#o),e.parentNode||t.append(e);const i=this.#a.getImageForAltText();i?.setAttribute("aria-describedby",e.id)}}let ae=class t{#pt;#Yt=!1;#Qt=null;#Jt;#Zt;#te;#ee;#ie;#se=null;#ne;#ae=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:a=null,signal:r}){this.#pt=t,this.#Qt=i,this.#Jt=e,this.#Zt=s,this.#te=n,this.#ee=a,this.#ne=new AbortController,this.#ie=AbortSignal.any([r,this.#ne.signal]),t.addEventListener("touchstart",this.#re.bind(this),{passive:!1,signal:this.#ie})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return dt(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#re(t){if(this.#Jt?.()||t.touches.length<2)return;if(!this.#ae){this.#ae=new AbortController;const t=AbortSignal.any([this.#ie,this.#ae.signal]),e=this.#pt,i={signal:t,passive:!1};e.addEventListener("touchmove",this.#oe.bind(this),i),e.addEventListener("touchend",this.#le.bind(this),i),e.addEventListener("touchcancel",this.#le.bind(this),i),this.#Zt?.()}if(Vt(t),2!==t.touches.length||this.#Qt?.())return void(this.#se=null);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#se={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#oe(e){if(!this.#se||2!==e.touches.length)return;let[i,s]=e.touches;i.identifier>s.identifier&&([i,s]=[s,i]);const{screenX:n,screenY:a}=i,{screenX:r,screenY:o}=s,l=this.#se,{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.#Yt&&Math.abs(v-b)<=t.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=n,l.touch0Y=a,l.touch1X=r,l.touch1Y=o,e.preventDefault(),!this.#Yt)return void(this.#Yt=!0);const w=[(n+r)/2,(a+o)/2];this.#te?.(w,v,b)}#le(t){this.#ae.abort(),this.#ae=null,this.#ee?.(),this.#se&&(t.preventDefault(),this.#se=null,this.#Yt=!1)}destroy(){this.#ne?.abort(),this.#ne=null}};class re{#he=null;#de=null;#o=null;#ce=!1;#ue=null;#pe="";#ge=!1;#fe=null;#me=null;#be=null;#ve=null;#we="";#ye=!1;#Ae=null;#_e=!1;#xe=!1;#Se=!1;#Ce=null;#Ee=0;#Pe=0;#Me=null;#Te=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#ke=!1;#Ie=re._zIndex++;static _borderLineWidth=-1;static _colorManager=new ie;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=re.prototype._resizeWithKeyboard,e=se.TRANSLATE_SMALL,i=se.TRANSLATE_BIG;return dt(this,"_resizerKeyboardManager",new ee([[["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"],re.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 dt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new oe({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(re._l10n??=t,re._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!==re._borderLineWidth)return;const i=getComputedStyle(document.documentElement);re._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){ot("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#ke}set _isDraggable(t){this.#ke=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#Ie}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#Le(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#ye?this.#ye=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const e=t.relatedTarget;e?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){const[n,a]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/a,this.fixAndSetPosition()}#De([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#De(this.parentDimensions,t,e)}translateInPage(t,e){this.#Ae||=[this.x,this.y,this.width,this.height],this.#De(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#Ae||=[this.x,this.y,this.width,this.height];const{div:i,parentDimensions:[s,n]}=this;if(this.x+=t/s,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x: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.#Ae&&(this.#Ae[0]!==this.x||this.#Ae[1]!==this.y)}get _hasBeenResized(){return!!this.#Ae&&(this.#Ae[2]!==this.width||this.#Ae[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=re,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=Math.max(0,Math.min(i-r,n)),a=Math.max(0,Math.min(s-o,a));break;case 90:n=Math.max(0,Math.min(i-o,n)),a=Math.min(s,Math.max(r,a));break;case 180:n=Math.min(i,Math.max(r,n)),a=Math.min(s,Math.max(o,a));break;case 270:n=Math.min(i,Math.max(o,n)),a=Math.max(0,Math.min(s-r,a))}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#Re(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return re.#Re(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return re.#Re(t,e,360-this.parentRotation)}#Ne(t){switch(t){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(t,e){const[i,s]=this.parentDimensions,{style:n}=this.div;n.width=`${(100*t/i).toFixed(2)}%`,this.#ge||(n.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:i}=t,s=i.endsWith("%"),n=!this.#ge&&e.endsWith("%");if(s&&n)return;const[a,r]=this.parentDimensions;s||(t.width=`${(100*parseFloat(i)/a).toFixed(2)}%`),this.#ge||n||(t.height=`${(100*parseFloat(e)/r).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#Fe(){if(this.#fe)return;this.#fe=document.createElement("div"),this.#fe.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const i of t){const t=document.createElement("div");this.#fe.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#Oe.bind(this,i),{signal:e}),t.addEventListener("contextmenu",Ht,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#fe)}#Oe(t,e){e.preventDefault();const{isMac:i}=_t.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#o?.toggle(!1);const s=this._isDraggable;this._isDraggable=!1,this.#me=[e.screenX,e.screenY];const n=new AbortController,a=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#Be.bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Vt,{passive:!1,signal:a}),window.addEventListener("contextmenu",Ht,{signal:a}),this.#be={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.#je()};window.addEventListener("pointerup",l,{signal:a}),window.addEventListener("blur",l,{signal:a})}#He(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(){}#je(){if(!this.#be)return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#be;this.#be=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.#He.bind(this,n,a,r,o),undo:this.#He.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#Be(t,e){const[i,s]=this.parentDimensions,n=this.x,a=this.y,r=this.width,o=this.height,l=re.MIN_SIZE/i,h=re.MIN_SIZE/s,d=this.#Ne(this.rotation),c=(t,e)=>[d[0]*t+d[2]*e,d[1]*t+d[3]*e],u=this.#Ne(360-this.rotation);let p,g,f=!1,m=!1;switch(t){case"topLeft":f=!0,p=(t,e)=>[0,0],g=(t,e)=>[t,e];break;case"topMiddle":p=(t,e)=>[t/2,0],g=(t,e)=>[t/2,e];break;case"topRight":f=!0,p=(t,e)=>[t,0],g=(t,e)=>[0,e];break;case"middleRight":m=!0,p=(t,e)=>[t,e/2],g=(t,e)=>[0,e/2];break;case"bottomRight":f=!0,p=(t,e)=>[t,e],g=(t,e)=>[0,0];break;case"bottomMiddle":p=(t,e)=>[t/2,e],g=(t,e)=>[t/2,0];break;case"bottomLeft":f=!0,p=(t,e)=>[0,e],g=(t,e)=>[t,0];break;case"middleLeft":m=!0,p=(t,e)=>[0,e/2],g=(t,e)=>[t,e/2]}const b=p(r,o),v=g(r,o);let w=c(...v);const y=re._round(n+w[0]),A=re._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.#me;[_,x]=this.screenToPageTranslation(t-s,i-n),this.#me[0]=t,this.#me[1]=i}var E,P;if([_,x]=(E=_/i,P=x/s,[u[0]*E+u[2]*P,u[1]*E+u[3]*P]),f){const t=Math.hypot(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=Math.max(l,Math.min(1,Math.abs(v[0]-b[0]-_)))/r:C=Math.max(h,Math.min(1,Math.abs(v[1]-b[1]-x)))/o;const M=re._round(r*S),T=re._round(o*C);w=c(...g(M,T));const k=y-w[0],I=A-w[1];this.#Ae||=[this.x,this.y,this.width,this.height],this.width=M,this.height=T,this.x=k,this.y=I,this.setDims(i*M,s*T),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#o?.finish()}async addEditToolbar(){return this._editToolbar||this.#xe||(this._editToolbar=new Kt(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||(ne.initialize(re._l10n),this.#o=new ne(this),this.#he&&(this.#o.data=this.#he,this.#he=null),await this.addEditToolbar())}get altTextData(){return this.#o?.data}set altTextData(t){this.#o&&(this.#o.data=t)}get guessedAltText(){return this.#o?.guessedText}async setGuessedAltText(t){await(this.#o?.setGuessedText(t))}serializeAltText(t){return this.#o?.serialize(t)}hasAltText(){return!!this.#o&&!this.#o.isEmpty()}hasAltTextData(){return this.#o?.hasData()??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#ce?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#Ve();const[t,e]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);const[i,s]=this.getInitialTranslation();return this.translate(i,s),Qt(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#Te||=new ae({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#ze.bind(this),onPinching:this.#Ue.bind(this),onPinchEnd:this.#$e.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#ze(){this.#be={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#o?.toggle(!1),this.parent.togglePointerEvents(!1)}#Ue(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;const n=this.#Ne(this.rotation),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=re.MIN_SIZE/r,p=re.MIN_SIZE/o;s=Math.max(Math.min(s,1/d,1/c),u/d,p/c);const g=re._round(d*s),f=re._round(c*s);if(g===d&&f===c)return;this.#Ae||=[l,h,d,c];const m=a(d/2,c/2),b=re._round(l+m[0]),v=re._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()}#$e(){this.#o?.toggle(!0),this.parent.togglePointerEvents(!0),this.#je()}pointerdown(t){const{isMac:e}=_t.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#ye=!0,this._isDraggable?this.#We(t):this.#Ge(t))}get isSelected(){return this._uiManager.isSelected(this)}#Ge(t){const{isMac:e}=_t.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#We(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const s=new AbortController,n=this._uiManager.combinedSignal(s),a={capture:!0,passive:!1,signal:n},r=t=>{s.abort(),this.#ue=null,this.#ye=!1,this._uiManager.endDragSession()||this.#Ge(t),i&&this._onStopDragging()};e&&(this.#Ee=t.clientX,this.#Pe=t.clientY,this.#ue=t.pointerId,this.#pe=t.pointerType,window.addEventListener("pointermove",(t=>{i||(i=!0,this._onStartDragging());const{clientX:e,clientY:s,pointerId:n}=t;if(n!==this.#ue)return void Vt(t);const[a,r]=this.screenToPageTranslation(e-this.#Ee,s-this.#Pe);this.#Ee=e,this.#Pe=s,this._uiManager.dragSelectedEditors(a,r)}),a),window.addEventListener("touchmove",Vt,a),window.addEventListener("pointerdown",(t=>{t.pointerType===this.#pe&&(this.#Te||t.isPrimary)&&r(t),Vt(t)}),a));const o=t=>{this.#ue&&this.#ue!==t.pointerId?Vt(t):r(t)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#Ce&&clearTimeout(this.#Ce),this.#Ce=setTimeout((()=>{this.#Ce=null,this.parent?.moveEditorInDOM(this)}),0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){const s=this.parentScale,[n,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.#xe=!0}disableEditMode(){this.#xe=!1}isInEditMode(){return this.#xe}shouldGetKeyboardEvents(){return this.#Se}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:n,innerWidth:a}=window;return e<a&&s>0&&t<n&&i>0}#Ve(){if(this.#ve||!this.div)return;this.#ve=new AbortController;const t=this._uiManager.combinedSignal(this.#ve);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#Ve()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){ot("An editor must be serializable")}static async deserialize(t,e,i){const s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i});s.rotation=t.rotation,s.#he=t.accessibilityData;const[n,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.#ve?.abort(),this.#ve=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#Ce&&(clearTimeout(this.#Ce),this.#Ce=null),this.#Le(),this.removeEditToolbar(),this.#Me){for(const t of this.#Me.values())clearTimeout(t);this.#Me=null}this.parent=null,this.#Te?.destroy(),this.#Te=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#Fe(),this.#fe.classList.remove("hidden"),Qt(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#be={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#fe.children;if(!this.#de){this.#de=Array.from(e);const t=this.#qe.bind(this),i=this.#Xe.bind(this),s=this._uiManager._signal;for(const e of this.#de){const n=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#Ke.bind(this,n),{signal:s}),e.setAttribute("data-l10n-id",re._l10nResizer[n])}}const i=this.#de[0];let s=0;for(const t of e){if(t===i)break;s++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#de.length/4);if(n!==s){if(n<s)for(let t=0;t<s-n;t++)this.#fe.append(this.#fe.firstChild);else if(n>s)for(let t=0;t<n-s;t++)this.#fe.firstChild.before(this.#fe.lastChild);let t=0;for(const i of e){const e=this.#de[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",re._l10nResizer[e])}}this.#Ye(0),this.#Se=!0,this.#fe.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#qe(t){re._resizerKeyboardManager.exec(this,t)}#Xe(t){this.#Se&&t.relatedTarget?.parentNode!==this.#fe&&this.#Le()}#Ke(t){this.#we=this.#Se?t:""}#Ye(t){if(this.#de)for(const e of this.#de)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#Se&&this.#Be(this.#we,{deltaX:t,deltaY:e,fromKeyboard:!0})}#Le(){this.#Se=!1,this.#Ye(-1),this.#je()}_stopResizingWithKeyboard(){this.#Le(),this.div.focus()}select(){this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#o?.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()}))}unselect(){this.#fe?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#o?.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#_e}set isEditing(t){this.#_e=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#ge=!0;const i=t/e,{style:s}=this.div;s.aspectRatio=i,s.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#Me||=new Map;const{action:e}=t;let i=this.#Me.get(e);return i&&clearTimeout(i),i=setTimeout((()=>{this._reportTelemetry(t),this.#Me.delete(e),0===this.#Me.size&&(this.#Me=null)}),re._telemetryTimeout),void this.#Me.set(e,i)}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#ce=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#ce=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===e?.nodeName&&e.classList.contains("annotationContent")&&e.remove()}}class oe extends re{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const le=3285377520,he=4294901760,de=65535;class ce{constructor(t){this.h1=t?4294967295&t:le,this.h2=t?4294967295&t:le}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&he|r*u&de,r=r<<15|r>>>17,r=r*c&he|r*p&de,l^=r,l=l<<13|l>>>19,l=5*l+3864292196):(o=a[t],o=o*d&he|o*u&de,o=o<<15|o>>>17,o=o*c&he|o*p&de,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&he|r*u&de,r=r<<15|r>>>17,r=r*c&he|r*p&de,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&he|36045*t&de,e=4283543511*e&he|(2950163797*(e<<16|t>>>16)&he)>>>16,t^=e>>>1,t=444984403*t&he|60499*t&de,e=3301882366*e&he|(3120437893*(e<<16|t>>>16)&he)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const ue=Object.freeze({map:null,hash:"",transfer:void 0});class pe{#Qe=!1;#Je=null;#Ze=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=this.#Ze.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#Ze.get(t)}remove(t){if(this.#Ze.delete(t),0===this.#Ze.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of this.#Ze.values())if(t instanceof re)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=this.#Ze.get(t);let s=!1;if(void 0!==i)for(const[t,n]of Object.entries(e))i[t]!==n&&(s=!0,i[t]=n);else s=!0,this.#Ze.set(t,e);s&&this.#ti(),e instanceof re&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#Ze.has(t)}getAll(){return this.#Ze.size>0?At(this.#Ze):null}setAll(t){for(const[e,i]of Object.entries(t))this.setValue(e,i)}get size(){return this.#Ze.size}#ti(){this.#Qe||(this.#Qe=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#Qe&&(this.#Qe=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new ge(this)}get serializable(){if(0===this.#Ze.size)return ue;const t=new Map,e=new ce,i=[],s=Object.create(null);let n=!1;for(const[i,a]of this.#Ze){const r=a instanceof re?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}:ue}get editorStats(){let t=null;const e=new Map;for(const i of this.#Ze.values()){if(!(i instanceof re))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.#Je=null}get modifiedIds(){if(this.#Je)return this.#Je;const t=[];for(const e of this.#Ze.values())e instanceof re&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return this.#Je={ids:new Set(t),hash:t.join(",")}}}class ge extends pe{#ei;constructor(t){super();const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);this.#ei={map:n,hash:i,transfer:s}}get print(){ot("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ei}get modifiedIds(){return dt(this,"modifiedIds",{ids:new Set,hash:""})}}class fe{#ii=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#ii.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(t&&!this.#ii.has(t.loadedName))if(lt(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:s,style:n}=t,a=new FontFace(i,s,n);this.addNativeFontFace(a);try{await a.load(),this.#ii.add(i),e?.(t)}catch{rt(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}}else ot("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 rt(`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 dt(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let t=!1;return(o||"undefined"!=typeof navigator&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),dt(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){const{loadingRequests:e}=this,i={done:!1,complete:function(){for(lt(!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 dt(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 rt("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 me{constructor(t,{disableFontFace:e=!1,fontExtraProperties:i=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const e in t)this[e]=t[e];this.disableFontFace=!0===e,this.fontExtraProperties=!0===i,this._inspectFont=s}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${e=this.data,Uint8Array.prototype.toBase64?e.toBase64():btoa(wt(e))});`;var e;let i;if(this.cssFontInfo){let e=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(e+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),i=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${e}src:${t}}`}else i=`@font-face {font-family:"${this.loadedName}";src:${t}}`;return this._inspectFont?.(this,t),i}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];const i=this.loadedName+"_path_"+e;let s;try{s=t.get(i)}catch(t){rt(`getPathGenerator - ignoring character: "${t}".`)}const n=new Path2D(s||"");return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=n}}const be=1,ve=2,we=1,ye=2,Ae=3,_e=4,xe=5,Se=6,Ce=7,Ee=8;function Pe(){}function Me(t){if(t instanceof vt||t instanceof gt||t instanceof ft||t instanceof ut||t instanceof mt||t instanceof pt)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||ot('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new vt(t.message);case"InvalidPDFException":return new gt(t.message);case"MissingPDFException":return new ft(t.message);case"PasswordException":return new ut(t.message,t.code);case"UnexpectedResponseException":return new mt(t.message,t.status);case"UnknownErrorException":return new pt(t.message,t.details)}return new pt(t.message,t.toString())}class Te{#si=new AbortController;constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),i.addEventListener("message",this.#ni.bind(this),{signal:this.#si.signal})}#ni({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#ai(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===be)i.resolve(t.data);else{if(t.callback!==ve)throw new Error("Unexpected callback case");i.reject(Me(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:be,callbackId:t.callbackId,data:e})}),(function(e){n.postMessage({sourceName:i,targetName:s,callback:ve,callbackId:t.callbackId,reason:Me(e)})}))}else t.streamId?this.#ri(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:Se,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{lt(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:we,streamId:n,reason:Me(t)}),e.promise}},i)}#ri(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:_e,streamId:e,chunk:t},r)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Ae,streamId:e}),delete a.streamSinks[e])},error(t){lt(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:xe,streamId:e,reason:Me(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:Ee,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Ee,streamId:e,reason:Me(t)})}))}#ai(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 Ee:t.success?a.startCall.resolve():a.startCall.reject(Me(t.reason));break;case Ce:t.success?a.pullCall.resolve():a.pullCall.reject(Me(t.reason));break;case Se:if(!r){n.postMessage({sourceName:i,targetName:s,stream:Ce,streamId:e,success:!0});break}r.desiredSize<=0&&t.desiredSize>0&&r.sinkCapability.resolve(),r.desiredSize=t.desiredSize,Promise.try(r.onPull||Pe).then((function(){n.postMessage({sourceName:i,targetName:s,stream:Ce,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Ce,streamId:e,reason:Me(t)})}));break;case _e:if(lt(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Ae:if(lt(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),this.#oi(a,e);break;case xe:lt(a,"error should have stream controller"),a.controller.error(Me(t.reason)),this.#oi(a,e);break;case ye:t.success?a.cancelCall.resolve():a.cancelCall.reject(Me(t.reason)),this.#oi(a,e);break;case we:if(!r)break;const o=Me(t.reason);Promise.try(r.onCancel||Pe,o).then((function(){n.postMessage({sourceName:i,targetName:s,stream:ye,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:ye,streamId:e,reason:Me(t)})})),r.sinkCapability.reject(o),r.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#oi(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#si?.abort(),this.#si=null}}class ke{#li=!1;constructor({enableHWA:t=!1}){this.#li=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#li})}}reset(t,e,i){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){ot("Abstract method `_createCanvas` called.")}}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){ot("Abstract method `_fetch` called.")}}class Le extends Ie{async _fetch(t){const e=await It(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):yt(e)}}class De{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 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){ot("Abstract method `_fetch` called.")}}class Ne extends Re{async _fetch(t){const e=await It(t,"arraybuffer");return new Uint8Array(e)}}async function Fe(t){const e=process.getBuiltinModule("fs"),i=await e.promises.readFile(t);return new Uint8Array(i)}o&&rt("Please use the `legacy` build in Node.js environments.");const Oe="Fill",Be="Stroke",je="Shading";function He(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 Ve{getPattern(){ot("Abstract method `getPattern` called.")}}class ze extends Ve{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===Be||s===Oe){const a=e.current.getClippedPathBoundingBox(s,Wt(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=St.transform(i,[1,0,0,1,a[0],a[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),He(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 He(t,this._bbox),n=this._createGradient(t);return n}}function Ue(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],M=Math.round(g),T=Math.round(v);let k,I,L,D,R,N,F,O;for(let t=M;t<=T;t++){if(t<m){const e=t<g?0:(g-t)/(g-m);k=p-(p-f)*e,I=w-(w-_)*e,L=y-(y-x)*e,D=A-(A-S)*e}else{let e;e=t>v?1:m===v?0:(m-t)/(m-v),k=f-(f-b)*e,I=_-(_-C)*e,L=x-(x-E)*e,D=S-(S-P)*e}let e;e=t<g?0:t>v?1:(g-t)/(g-v),R=p-(p-b)*e,N=w-(w-C)*e,F=y-(y-E)*e,O=A-(A-P)*e;const i=Math.round(Math.min(k,R)),s=Math.round(Math.max(k,R));let n=c*t+4*i;for(let t=i;t<=s;t++)e=(k-t)/(k-R),e<0?e=0:e>1&&(e=1),d[n++]=I-(I-N)*e|0,d[n++]=L-(L-F)*e|0,d[n++]=D-(D-O)*e|0,d[n++]=255}}function $e(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++)Ue(t,i,s[e],s[e+1],s[e+o],n[e],n[e+1],n[e+o]),Ue(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)Ue(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 We extends Ve{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,i){const s=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),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)$e(m,t,c);f.putImageData(m,2,2);return{canvas:g.canvas,offsetX:s-2*h,offsetY:n-2*d,scaleX:h,scaleY:d}}getPattern(t,e,i,s){let n;if(He(t,this._bbox),s===je)n=St.singularValueDecompose2dScale(Wt(t));else if(n=St.singularValueDecompose2dScale(e.baseTransform),this.matrix){const t=St.singularValueDecompose2dScale(this.matrix);n=[n[0]*t[0],n[1]*t[1]]}const a=this._createMeshCanvas(n,s===je?null:this._background,e.cachedCanvases);return s!==je&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY),t.createPattern(a.canvas,"no-repeat")}}class Ge extends Ve{getPattern(){return"hotpink"}}const qe=1,Xe=2;class Ke{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s,n){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=i,this.canvasGraphicsFactory=s,this.baseTransform=n}createPatternCanvas(t){const{bbox:e,operatorList:i,paintType:s,tilingType:n,color:a,canvasGraphicsFactory:r}=this;let{xstep:o,ystep:l}=this;o=Math.abs(o),l=Math.abs(l),at("TilingType: "+n);const h=e[0],d=e[1],c=e[2],u=e[3],p=c-h,g=u-d,f=St.singularValueDecompose2dScale(this.matrix),m=St.singularValueDecompose2dScale(this.baseTransform),b=f[0]*m[0],v=f[1]*m[1];let w=p,y=g,A=!1,_=!1;const x=Math.ceil(o*b),S=Math.ceil(l*v);x>=Math.ceil(p*b)?w=o:A=!0,S>=Math.ceil(g*v)?y=l:_=!0;const C=this.getSizeAndScale(w,this.ctx.canvas.width,b),E=this.getSizeAndScale(y,this.ctx.canvas.height,v),P=t.cachedCanvases.getCanvas("pattern",C.size,E.size),M=P.context,T=r.createCanvasGraphics(M);if(T.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(T,s,a),M.translate(-C.scale*h,-E.scale*d),T.transform(C.scale,0,0,E.scale,0,0),M.save(),this.clipBbox(T,h,d,c,u),T.baseTransform=Wt(T.ctx),T.executeOperatorList(i),T.endDrawing(),M.restore(),A||_){const e=P.canvas;A&&(w=o),_&&(y=l);const i=this.getSizeAndScale(w,this.ctx.canvas.width,b),s=this.getSizeAndScale(y,this.ctx.canvas.height,v),n=i.size,a=s.size,r=t.cachedCanvases.getCanvas("pattern-workaround",n,a),c=r.context,u=A?Math.floor(p/o):0,f=_?Math.floor(g/l):0;for(let t=0;t<=u;t++)for(let i=0;i<=f;i++)c.drawImage(e,n*t,a*i,n,a,0,0,n,a);return{canvas:r.canvas,scaleX:i.scale,scaleY:s.scale,offsetX:h,offsetY:d}}return{canvas:P.canvas,scaleX:C.scale,scaleY:E.scale,offsetX:h,offsetY:d}}getSizeAndScale(t,e,i){const s=Math.max(Ke.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),t.current.updateRectMinMax(Wt(t.ctx),[e,i,s,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const s=t.ctx,n=t.current;switch(e){case qe:const t=this.ctx;s.fillStyle=t.fillStyle,s.strokeStyle=t.strokeStyle,n.fillColor=t.fillStyle,n.strokeColor=t.strokeStyle;break;case Xe:const a=St.makeHexColor(i[0],i[1],i[2]);s.fillStyle=a,s.strokeStyle=a,n.fillColor=a,n.strokeColor=a;break;default:throw new bt(`Unsupported paint type: ${e}`)}}getPattern(t,e,i,s){let n=i;s!==je&&(n=St.transform(n,e.baseTransform),this.matrix&&(n=St.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 Ye({src:t,srcPos:e=0,dest:i,width:s,height:n,nonBlackColor:a=4294967295,inverseDecode:r=!1}){const o=_t.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 Qe=16;class Je{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 Ze(t,e,i,s,n,a,r,o,l,h){const[d,c,u,p,g,f]=Wt(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 ti{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=l,this.textMatrixScale=1,this.fontMatrix=h,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=x,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,i){[e,i]=St.applyTransform([e,i],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,i),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,i)}updateRectMinMax(t,e){const i=St.applyTransform(e,t),s=St.applyTransform(e.slice(2),t),n=St.applyTransform([e[0],e[3]],t),a=St.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,i[0],s[0],n[0],a[0]),this.minY=Math.min(this.minY,i[1],s[1],n[1],a[1]),this.maxX=Math.max(this.maxX,i[0],s[0],n[0],a[0]),this.maxY=Math.max(this.maxY,i[1],s[1],n[1],a[1])}updateScalingPathMinMax(t,e){St.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,i,s,n,a,r,o,l,h){const d=St.bezierBoundingBox(e,i,s,n,a,r,o,l,h);h||this.updateRectMinMax(t,d)}getPathBoundingBox(t=Oe,e=null){const i=[this.minX,this.minY,this.maxX,this.maxY];if(t===Be){e||ot("Stroke bounding box must include transform.");const t=St.singularValueDecompose2dScale(e),s=t[0]*this.lineWidth/2,n=t[1]*this.lineWidth/2;i[0]-=s,i[1]-=n,i[2]+=s,i[3]+=n}return i}updateClipFromPath(){const t=St.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=Oe,e=null){return St.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function ei(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,s=e.width,n=i%Qe,a=(i-n)/Qe,r=0===n?a:a+1,o=t.createImageData(s,Qe);let l,h=0;const d=e.data,c=o.data;let u,p,g,f;if(e.kind===T.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=_t.isLittleEndian?4278190080:255;for(u=0;u<r;u++){for(g=u<a?Qe: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*Qe)}}else if(e.kind===T.RGBA_32BPP){for(p=0,f=s*Qe*4,u=0;u<a;u++)c.set(d.subarray(h,h+f)),h+=f,t.putImageData(o,0,p),p+=Qe;u<r&&(f=s*n*4,c.set(d.subarray(h,h+f)),t.putImageData(o,0,p))}else{if(e.kind!==T.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=Qe,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*Qe)}}}function ii(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,s=e.width,n=i%Qe,a=(i-n)/Qe,r=0===n?a:a+1,o=t.createImageData(s,Qe);let l=0;const h=e.data,d=o.data;for(let e=0;e<r;e++){const i=e<a?Qe:n;({srcPos:l}=Ye({src:h,srcPos:l,dest:d,width:s,height:i,nonBlackColor:0})),t.putImageData(o,0,e*Qe)}}function si(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 ni(t){if(t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0),!o){const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}}function ai(t,e){if(e)return!0;const i=St.singularValueDecompose2dScale(t);i[0]=Math.fround(i[0]),i[1]=Math.fround(i[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*kt.PDF_TO_CSS_UNITS);return i[0]<=s&&i[1]<=s}const ri=["butt","round","square"],oi=["miter","round","bevel"],li={},hi={};class di{constructor(t,e,i,s,n,{optionalContentConfig:a,markedContentStack:r=null},o,l){this.ctx=t,this.current=new ti(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=n,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=r||[],this.optionalContentConfig=a,this.cachedCanvases=new Je(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(...Wt(this.compositeCtx))}this.ctx.save(),ni(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=Wt(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!==tt.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}}}#hi(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#hi(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#di()}#di(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const i=t.width??t.displayWidth,s=t.height??t.displayHeight;let n,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=Wt(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),ii(d.context,t));let c=St.transform(r,[1/i,0,0,-1/s,0,0]);c=St.transform(c,[1,0,0,1,0,-s]);const[u,p,g,f]=St.getAxialAlignedBoundingBox([0,0,i,s],c),m=Math.round(g-u)||1,b=Math.round(f-p)||1,v=this.cachedCanvases.getCanvas("fillCanvas",m,b),w=v.context,y=u,A=p;w.translate(-y,-A),w.transform(...c),h||(h=this._scaleImage(d.canvas,Gt(w)),h=h.img,o&&a&&o.set(l,h)),w.imageSmoothingEnabled=ai(Wt(w),t.interpolate),Ze(w,h,0,0,h.width,h.height,0,0,i,s),w.globalCompositeOperation="source-in";const _=St.transform(Gt(w),[1,0,0,1,-y,-A]);return w.fillStyle=a?n.getPattern(e,this,_,Oe):n,w.fillRect(0,0,i,s),o&&!a&&(this.cachedCanvases.delete("fillCanvas"),o.set(l,v.canvas)),{canvas:v.canvas,offsetX:Math.round(y),offsetY:Math.round(A)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=ri[t]}setLineJoin(t){this.ctx.lineJoin=oi[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const i=this.ctx;void 0!==i.setLineDash&&(i.setLineDash(t),i.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,i]of t)switch(e){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i[0],i[1]);break;case"CA":this.current.strokeAlpha=i;break;case"ca":this.current.fillAlpha=i,this.ctx.globalAlpha=i;break;case"BM":this.ctx.globalCompositeOperation=i;break;case"SMask":this.current.activeSMask=i?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(i,t,e);this.suspendedCtx=this.ctx,this.ctx=s.context;const n=this.ctx;n.setTransform(...Wt(this.suspendedCtx)),si(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"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),si(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=St.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?(si(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),si(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,i,s,n,a){this.ctx.transform(t,e,i,s,n,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i){const s=this.ctx,n=this.current;let a,r,o=n.x,l=n.y;const h=Wt(s),d=0===h[0]&&0===h[3]||0===h[1]&&0===h[2],c=d?i.slice(0):null;for(let i=0,u=0,p=t.length;i<p;i++)switch(0|t[i]){case tt.rectangle:o=e[u++],l=e[u++];const t=e[u++],i=e[u++],p=o+t,g=l+i;s.moveTo(o,l),0===t||0===i?s.lineTo(p,g):(s.lineTo(p,l),s.lineTo(p,g),s.lineTo(o,g)),d||n.updateRectMinMax(h,[o,l,p,g]),s.closePath();break;case tt.moveTo:o=e[u++],l=e[u++],s.moveTo(o,l),d||n.updatePathMinMax(h,o,l);break;case tt.lineTo:o=e[u++],l=e[u++],s.lineTo(o,l),d||n.updatePathMinMax(h,o,l);break;case tt.curveTo:a=o,r=l,o=e[u+4],l=e[u+5],s.bezierCurveTo(e[u],e[u+1],e[u+2],e[u+3],o,l),n.updateCurvePathMinMax(h,a,r,e[u],e[u+1],e[u+2],e[u+3],o,l,c),u+=6;break;case tt.curveTo2:a=o,r=l,s.bezierCurveTo(o,l,e[u],e[u+1],e[u+2],e[u+3]),n.updateCurvePathMinMax(h,a,r,o,l,e[u],e[u+1],e[u+2],e[u+3],c),o=e[u+2],l=e[u+3],u+=4;break;case tt.curveTo3:a=o,r=l,o=e[u+2],l=e[u+3],s.bezierCurveTo(e[u],e[u+1],o,l,o,l),n.updateCurvePathMinMax(h,a,r,e[u],e[u+1],o,l,o,l,c),u+=4;break;case tt.closePath:s.closePath()}d&&n.updateScalingPathMinMax(h,c),n.setCurrentPoint(o,l)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,i=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof i&&i?.getPattern?(e.save(),e.strokeStyle=i.getPattern(e,this,Gt(e),Be),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){const e=this.ctx,i=this.current.fillColor;let s=!1;this.current.patternFill&&(e.save(),e.fillStyle=i.getPattern(e,this,Gt(e),Oe),s=!0);const n=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==n&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),s&&e.restore(),t&&this.consumePath(n)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=li}eoClip(){this.pendingClip=hi}beginText(){this.current.textMatrix=l,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(void 0===t)return void e.beginPath();const i=new Path2D,s=e.getTransform().invertSelf();for(const{transform:e,x:n,y:a,fontSize:r,path:o}of t)i.addPath(o,new DOMMatrix(e).preMultiplySelf(s).translate(n,a).scale(r,-r));e.clip(i),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){const i=this.commonObjs.get(t),s=this.current;if(!i)throw new Error(`Can't find font for ${t}`);if(s.fontMatrix=i.fontMatrix||h,0!==s.fontMatrix[0]&&0!==s.fontMatrix[3]||rt("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,e,i,s,n,a){this.current.textMatrix=[t,e,i,s,n,a],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#ci(t,e,i){const s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,n){const a=this.ctx,r=this.current,o=r.font,l=r.textRenderingMode,h=r.fontSize/r.fontSizeScale,d=l&P,c=!!(l&M),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){if(a.save(),a.translate(e,i),a.scale(h,-h),d===x||d===C)if(s){const t=a.getTransform();a.setTransform(...s),a.fill(this.#ci(g,t,s))}else a.fill(g);if(d===S||d===C)if(n){const t=a.getTransform();a.setTransform(...n),a.stroke(this.#ci(g,t,n))}else a.lineWidth/=h,a.stroke(g);a.restore()}else d!==x&&d!==C||a.fillText(t,e,i),d!==S&&d!==C||a.strokeText(t,e,i);if(c){(this.pendingTextPaths||=[]).push({transform:Wt(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 dt(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===x&&!i.disableFontFace&&!e.patternFill;let m,b;if(n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),l>0?n.scale(h,-1):n.scale(h,1),e.patternFill){n.save();const t=e.fillColor.getPattern(n,this,Gt(n),Oe);m=Wt(n),n.restore(),n.fillStyle=t}if(e.patternStroke){n.save();const t=e.strokeColor.getPattern(n,this,Gt(n),Be);b=Wt(n),n.restore(),n.strokeStyle=t}let v=e.lineWidth;const w=e.textMatrixScale;if(0===w||0===v){const t=e.textRenderingMode&P;t!==S&&t!==C||(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,d=i.textHScale*a,c=i.fontMatrix||h,u=t.length;let p,g,f,m;if(!(i.textRenderingMode===E)&&0!==n){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...i.textMatrix),e.translate(i.x,i.y),e.scale(d,a),p=0;p<u;++p){if(g=t[p],"number"==typeof g){m=r*g*n/1e3,this.ctx.translate(m,0),i.x+=m*d;continue}const a=(g.isSpace?l:0)+o,h=s.charProcOperatorList[g.operatorListId];if(!h){rt(`Type3 character "${g.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=g,this.save(),e.scale(n,n),e.transform(...c),this.executeOperatorList(h),this.restore());f=St.applyTransform([g.width,0],c)[0]*n+a,e.translate(f,0),i.x+=f*d}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,i,s,n,a){this.ctx.rect(i,s,n-i,a-s),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){const i=t[1],s=this.baseTransform||Wt(this.ctx),n={createCanvasGraphics:t=>new di(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Ke(t,i,this.ctx,n,s)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,i){this.ctx.strokeStyle=this.current.strokeColor=St.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=St.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 ze(t);case"Mesh":return new We(t);case"Dummy":return new Ge}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,Gt(e),je);const s=Gt(e);if(s){const{width:t,height:i}=e.canvas,[n,a,r,o]=St.getAxialAlignedBoundingBox([0,0,t,i],s);this.ctx.fillRect(n,a,r-n,o-a)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){ot("Should not call beginInlineImage")}beginImageData(){ot("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Wt(this.ctx),e)){const t=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],t,i),this.current.updateRectMinMax(Wt(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||at("TODO: Support non-isolated groups."),t.knockout&&rt("Knockout groups not supported.");const i=Wt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let s=St.getAxialAlignedBoundingBox(t.bbox,Wt(e));const n=[0,0,e.canvas.width,e.canvas.height];s=St.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),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()),si(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=Wt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const i=St.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(t,e,i,s,n){if(this.#hi(),ni(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;const[n,r]=St.singularValueDecompose2dScale(Wt(this.ctx)),{viewportScale:o}=this,l=Math.ceil(s*this.outputScaleX*o),h=Math.ceil(a*this.outputScaleY*o);this.annotationCanvas=this.canvasFactory.create(l,h);const{canvas:d,context:c}=this.annotationCanvas;this.annotationCanvasMap.set(t,d),this.annotationCanvas.savedCtx=this.ctx,this.ctx=c,this.ctx.save(),this.ctx.setTransform(n,0,0,-r,0,a*r),ni(this.ctx)}else ni(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],s,a),this.ctx.clip(),this.ctx.beginPath()}this.current=new ti(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#di(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;(t=this.getObject(t.data,t)).count=e;const i=this.ctx,s=this.processingType3;if(s&&(void 0===s.compiled&&(s.compiled=function(t){const{width:e,height:i}=t;if(e>1e3||i>1e3)return null;const s=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=e+1;let a,r,o,l=new Uint8Array(n*(i+1));const h=e+7&-8;let d=new Uint8Array(h*i),c=0;for(const e of t.data){let t=128;for(;t>0;)d[c++]=e&t?0:255,t>>=1}let u=0;for(c=0,0!==d[c]&&(l[0]=1,++u),r=1;r<e;r++)d[c]!==d[c+1]&&(l[r]=d[c]?2:1,++u),c++;for(0!==d[c]&&(l[r]=2,++u),a=1;a<i;a++){c=a*h,o=a*n,d[c-h]!==d[c]&&(l[o]=d[c]?1:8,++u);let t=(d[c]?4:0)+(d[c-h]?8:0);for(r=1;r<e;r++)t=(t>>2)+(d[c+1]?4:0)+(d[c-h+1]?8:0),s[t]&&(l[o+r]=s[t],++u),c++;if(d[c-h]!==d[c]&&(l[o+r]=d[c]?2:4,++u),u>1e3)return null}for(c=h*(i-1),o=a*n,0!==d[c]&&(l[o]=8,++u),r=1;r<e;r++)d[c]!==d[c+1]&&(l[o+r]=d[c]?4:8,++u),c++;if(0!==d[c]&&(l[o+r]=4,++u),u>1e3)return null;const p=new Int32Array([0,n,-1,0,-n,0,0,0,1]),g=new Path2D;for(a=0;u&&a<=i;a++){let t=a*n;const i=t+e;for(;t<i&&!l[t];)t++;if(t===i)continue;g.moveTo(t%n,a);const s=t;let r=l[t];do{const e=p[r];do{t+=e}while(!l[t]);const i=l[t];5!==i&&10!==i?(r=i,l[t]=0):(r=i&51*r>>4,l[t]&=r>>2|r<<2),g.lineTo(t%n,t/n|0),l[t]||--u}while(s!==t);--a}return d=null,l=null,function(t){t.save(),t.scale(1/e,-1/i),t.translate(0,-i),t.fill(g),t.beginPath(),t.restore()}}(t)),s.compiled))return void s.compiled(i);const n=this._createMaskCanvas(t),a=n.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(a,n.offsetX,n.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=Wt(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=St.transform(o,[e,i,s,n,a[t],a[t+1]]),[d,c]=St.applyTransform([0,0],h);r.drawImage(l.canvas,d,c)}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();ii(h,this.getObject(t,n)),h.globalCompositeOperation="source-in",h.fillStyle=s?i.getPattern(h,this,Gt(e),Oe):i,h.fillRect(0,0,a,r),h.restore(),e.save(),e.transform(...o),e.scale(1,-1),Ze(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):rt("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s){if(!this.contentVisible)return;const n=this.getObject(t);if(!n)return void rt("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;if(this.save(),!o){const{filter:t}=s;"none"!==t&&""!==t&&(s.filter="none")}let n;if(s.scale(1/e,-1/i),t.bitmap)n=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)n=t;else{const s=this.cachedCanvases.getCanvas("inlineImage",e,i).context;ei(s,t),n=this.applyTransferMapsToCanvas(s)}const a=this._scaleImage(n,Gt(s));s.imageSmoothingEnabled=ai(Wt(s),t.interpolate),Ze(s,a.img,0,0,a.paintWidth,a.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;ei(n,t),s=this.applyTransferMapsToCanvas(n)}for(const t of e)i.save(),i.transform(...t.transform),i.scale(1,-1),Ze(i,s,t.x,t.y,t.w,t.h,0,-1,1,1),i.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const i=this.ctx;this.pendingClip&&(e||(this.pendingClip===hi?i.clip("evenodd"):i.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),i.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Wt(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){const{ctx:e}=this,{lineWidth:i}=this.current,[s,n]=this.getScaleForStroking();if(e.lineWidth=i||1,1===s&&1===n)return void e.stroke();const a=e.getLineDash();if(t&&e.save(),e.scale(s,n),a.length>0){const t=Math.max(s,n);e.setLineDash(a.map((e=>e/t))),e.lineDashOffset/=t}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const t in tt)void 0!==di.prototype[t]&&(di.prototype[tt[t]]=di.prototype[t]);let ci=class{static#ui=null;static#pi="";static get workerPort(){return this.#ui}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#ui=t}static get workerSrc(){return this.#pi}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#pi=t}};class ui{#gi;#fi;constructor({parsedData:t,rawData:e}){this.#gi=t,this.#fi=e}getRaw(){return this.#fi}get(t){return this.#gi.get(t)??null}getAll(){return At(this.#gi)}has(t){return this.#gi.has(t)}}const pi=Symbol("INTERNAL");class gi{#mi=!1;#bi=!1;#vi=!1;#wi=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){this.#mi=!!(t&u),this.#bi=!!(t&p),this.name=e,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(this.#vi)return this.#wi;if(!this.#wi)return!1;const{print:t,view:e}=this.usage;return this.#mi?"OFF"!==e?.viewState:!this.#bi||"OFF"!==t?.printState}_setVisible(t,e,i=!1){t!==pi&&ot("Internal method `_setVisible` called."),this.#vi=i,this.#wi=e}}class fi{#yi=null;#Ai=new Map;#_i=null;#xi=null;constructor(t,e=u){if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#xi=t.order;for(const i of t.groups)this.#Ai.set(i.id,new gi(e,i));if("OFF"===t.baseState)for(const t of this.#Ai.values())t._setVisible(pi,!1);for(const e of t.on)this.#Ai.get(e)._setVisible(pi,!0);for(const e of t.off)this.#Ai.get(e)._setVisible(pi,!1);this.#_i=this.getHash()}}#Si(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let s=1;s<e;s++){const e=t[s];let n;if(Array.isArray(e))n=this.#Si(e);else{if(!this.#Ai.has(e))return rt(`Optional content group not found: ${e}`),!0;n=this.#Ai.get(e).visible}switch(i){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return"And"===i}isVisible(t){if(0===this.#Ai.size)return!0;if(!t)return at("Optional content group not defined."),!0;if("OCG"===t.type)return this.#Ai.has(t.id)?this.#Ai.get(t.id).visible:(rt(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#Si(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return rt(`Optional content group not found: ${e}`),!0;if(this.#Ai.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return rt(`Optional content group not found: ${e}`),!0;if(!this.#Ai.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return rt(`Optional content group not found: ${e}`),!0;if(!this.#Ai.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return rt(`Optional content group not found: ${e}`),!0;if(this.#Ai.get(e).visible)return!1}return!0}return rt(`Unknown optional content policy ${t.policy}.`),!0}return rt(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){const s=this.#Ai.get(t);if(s){if(i&&e&&s.rbGroups.length)for(const e of s.rbGroups)for(const i of e)i!==t&&this.#Ai.get(i)?._setVisible(pi,!1,!0);s._setVisible(pi,!!e,!0),this.#yi=null}else rt(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let i;for(const s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}const t=this.#Ai.get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}this.#yi=null}get hasInitialVisibility(){return null===this.#_i||this.getHash()===this.#_i}getOrder(){return this.#Ai.size?this.#xi?this.#xi.slice():[...this.#Ai.keys()]:null}getGroups(){return this.#Ai.size>0?At(this.#Ai):null}getGroup(t){return this.#Ai.get(t)||null}getHash(){if(null!==this.#yi)return this.#yi;const t=new ce;for(const[e,i]of this.#Ai)t.update(`${e}:${i.visible}`);return this.#yi=t.hexdigest()}}class mi{constructor(t,{disableRange:e=!1,disableStream:i=!1}){lt(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{lt(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(){lt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new bi(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new vi(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 bi{constructor(t,e,i=!1,s=null){this._stream=t,this._done=i||!1,this._filename=Nt(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 vi{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 wi(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 yi(t){try{return new URL(t).origin}catch{}return null}function Ai({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 _i(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=yt(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(Nt(t))return t}return null}function xi(t,e){return 404===t||0===t&&e.startsWith("file:")?new ft('Missing PDF "'+e+'".'):new mt(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t)}function Si(t){return 200===t||206===t}function Ci(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function Ei(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(rt(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class Pi{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=wi(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return lt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Mi(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Ti(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 Mi{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,Ci(i,this._withCredentials,this._abortController)).then((e=>{if(t._responseOrigin=yi(e.url),!Si(e.status))throw xi(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();const i=e.headers,{allowRangeRequests:n,suggestedLength:a}=Ai({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=a||this._contentLength,this._filename=_i(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new vt("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:Ei(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Ti{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,Ci(n,this._withCredentials,this._abortController)).then((e=>{const i=yi(e.url);if(i!==t._responseOrigin)throw new Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!Si(e.status))throw xi(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:Ei(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class ki{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=wi(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",lt(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:yt(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}):(rt('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 Ii{constructor(t){this._source=t,this._manager=new ki(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 lt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Li(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new Di(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 Li{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=yi(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}=Ai({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=_i(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=xi(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 Di{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=yi(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??=xi(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 Ri=/^[a-z][a-z0-9\-+.]+:/i;class Ni{constructor(t){this.source=t,this.url=function(t){if(Ri.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),lt("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return lt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Fi(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Oi(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 Fi{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=process.getBuiltinModule("fs");i.promises.lstat(this._url).then((t=>{this._contentLength=t.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()}),(t=>{"ENOENT"===t.code&&(t=new ft(`Missing PDF "${this._url}".`)),this._storedError=t,this._headersCapability.reject(t)}))}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new vt("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Oi{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const s=t.source;this._isStreamingSupported=!s.disableStream;const n=process.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:e,end:i-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),this._storedError&&this._readableStream.destroy(this._storedError)}}const Bi=30;let ji=class t{#Ci=Promise.withResolvers();#pt=null;#Ei=!1;#Pi=!!globalThis.FontInspector?.enabled;#Mi=null;#Ti=null;#ki=0;#Ii=0;#Li=null;#Di=null;#Ri=0;#Ni=0;#Fi=Object.create(null);#Oi=[];#Bi=null;#ji=[];#Hi=new WeakMap;#Vi=null;static#zi=new Map;static#Ui=new Map;static#$i=new WeakMap;static#Wi=null;static#Gi=new Set;constructor({textContentSource:e,container:i,viewport:s}){if(e instanceof ReadableStream)this.#Bi=e;else{if("object"!=typeof e)throw new Error('No "textContentSource" parameter specified.');this.#Bi=new ReadableStream({start(t){t.enqueue(e),t.close()}})}this.#pt=this.#Di=i,this.#Ni=s.scale*(globalThis.devicePixelRatio||1),this.#Ri=s.rotation,this.#Ti={div:null,properties:null,ctx:null};const{pageWidth:n,pageHeight:a,pageX:r,pageY:o}=s.rawDims;this.#Vi=[1,0,0,-1,-r,o+a],this.#Ii=n,this.#ki=a,t.#qi(),qt(i,s),this.#Ci.promise.finally((()=>{t.#Gi.delete(this),this.#Ti=null,this.#Fi=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=_t.platform;return dt(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const e=()=>{this.#Li.read().then((({value:t,done:i})=>{i?this.#Ci.resolve():(this.#Mi??=t.lang,Object.assign(this.#Fi,t.styles),this.#Xi(t.items),e())}),this.#Ci.reject)};return this.#Li=this.#Bi.getReader(),t.#Gi.add(this),e(),this.#Ci.promise}update({viewport:e,onBefore:i=null}){const s=e.scale*(globalThis.devicePixelRatio||1),n=e.rotation;if(n!==this.#Ri&&(i?.(),this.#Ri=n,qt(this.#Di,{rotation:n})),s!==this.#Ni){i?.(),this.#Ni=s;const e={div:null,properties:null,ctx:t.#Ki(this.#Mi)};for(const t of this.#ji)e.properties=this.#Hi.get(t),e.div=t,this.#Yi(e)}}cancel(){const t=new vt("TextLayer task cancelled.");this.#Li?.cancel(t).catch((()=>{})),this.#Li=null,this.#Ci.reject(t)}get textDivs(){return this.#ji}get textContentItemsStr(){return this.#Oi}#Xi(e){if(this.#Ei)return;this.#Ti.ctx??=t.#Ki(this.#Mi);const i=this.#ji,s=this.#Oi;for(const t of e){if(i.length>1e5)return rt("Ignoring additional textDivs for performance reasons."),void(this.#Ei=!0);if(void 0!==t.str)s.push(t.str),this.#Qi(t);else if("beginMarkedContentProps"===t.type||"beginMarkedContent"===t.type){const e=this.#pt;this.#pt=document.createElement("span"),this.#pt.classList.add("markedContent"),null!==t.id&&this.#pt.setAttribute("id",`${t.id}`),e.append(this.#pt)}else"endMarkedContent"===t.type&&(this.#pt=this.#pt.parentNode)}}#Qi(e){const i=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,fontSize:0};this.#ji.push(i);const n=St.transform(this.#Vi,e.transform);let a=Math.atan2(n[1],n[0]);const r=this.#Fi[e.fontName];r.vertical&&(a+=Math.PI/2);let o=this.#Pi&&r.fontSubstitution||r.fontFamily;o=t.fontFamilyMap.get(o)||o;const l=Math.hypot(n[2],n[3]),h=l*t.#Ji(o,this.#Mi);let d,c;0===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(--scale-factor)*",p=i.style;this.#pt===this.#Di?(p.left=`${(100*d/this.#Ii).toFixed(2)}%`,p.top=`${(100*c/this.#ki).toFixed(2)}%`):(p.left=`${u}${d.toFixed(2)}px)`,p.top=`${u}${c.toFixed(2)}px)`),p.fontSize=`${u}${(t.#Wi*l).toFixed(2)}px)`,p.fontFamily=o,s.fontSize=l,i.setAttribute("role","presentation"),i.textContent=e.str,i.dir=e.dir,this.#Pi&&(i.dataset.fontName=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.#Hi.set(i,s),this.#Ti.div=i,this.#Ti.properties=s,this.#Yi(this.#Ti),s.hasText&&this.#pt.append(i),s.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#pt.append(t)}}#Yi(e){const{div:i,properties:s,ctx:n}=e,{style:a}=i;let r="";if(t.#Wi>1&&(r=`scale(${1/t.#Wi})`),0!==s.canvasWidth&&s.hasText){const{fontFamily:e}=a,{canvasWidth:o,fontSize:l}=s;t.#Zi(n,l*this.#Ni,e);const{width:h}=n.measureText(i.textContent);h>0&&(r=`scaleX(${o*this.#Ni/h}) ${r}`)}0!==s.angle&&(r=`rotate(${s.angle}deg) ${r}`),r.length>0&&(a.transform=r)}static cleanup(){if(!(this.#Gi.size>0)){this.#zi.clear();for(const{canvas:t}of this.#Ui.values())t.remove();this.#Ui.clear()}}static#Ki(t=null){let e=this.#Ui.get(t||="");if(!e){const i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#Ui.set(t,e),this.#$i.set(e,{size:0,family:""})}return e}static#Zi(t,e,i){const s=this.#$i.get(t);e===s.size&&i===s.family||(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static#qi(){if(null!==this.#Wi)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#Wi=t.getBoundingClientRect().height,t.remove()}static#Ji(t,e){const i=this.#zi.get(t);if(i)return i;const s=this.#Ki(e);s.canvas.width=s.canvas.height=Bi,this.#Zi(s,Bi,t);const n=s.measureText("");let a=n.fontBoundingBoxAscent,r=Math.abs(n.fontBoundingBoxDescent);if(a){const e=a/(a+r);return this.#zi.set(t,e),s.canvas.width=s.canvas.height=0,e}s.strokeStyle="red",s.clearRect(0,0,Bi,Bi),s.strokeText("g",0,0);let o=s.getImageData(0,0,Bi,Bi).data;r=0;for(let t=o.length-1-3;t>=0;t-=4)if(o[t]>0){r=Math.ceil(t/4/Bi);break}s.clearRect(0,0,Bi,Bi),s.strokeText("A",0,Bi),o=s.getImageData(0,0,Bi,Bi).data,a=0;for(let t=0,e=o.length;t<e;t+=4)if(o[t]>0){a=Bi-Math.floor(t/4/Bi);break}s.canvas.width=s.canvas.height=0;const l=a?a/(a+r):.8;return this.#zi.set(t,l),l}};class Hi{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(!Hi.shouldBuildText(n))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(const e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}const Vi=65536,zi=o?class extends ke{_createCanvas(t,i){return process.getBuiltinModule("module").createRequire("undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("index.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(t,i)}}:class extends ke{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}},Ui=o?class extends Ie{async _fetch(t){return Fe(t)}}:Le,$i=o?class extends De{}:class extends De{#ts;#es;#is;#ss;#ns;#as;#w=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#ss=t,this.#ns=e}get#A(){return this.#es||=new Map}get#rs(){return this.#as||=new Map}get#os(){if(!this.#is){const t=this.#ns.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const i=this.#ns.createElementNS(Tt,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#is=this.#ns.createElementNS(Tt,"defs"),t.append(i),i.append(this.#is),this.#ns.body.append(t)}return this.#is}#ls(t){if(1===t.length){const e=t[0],i=new Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;const s=i.join(",");return[s,s,s]}const[e,i,s]=t,n=new Array(256),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(",")]}#hs(t){if(void 0===this.#ts){this.#ts="";const t=this.#ns.URL;t!==this.#ns.baseURI&&(Rt(t)?rt('#createUrl: ignore "data:"-URL for performance reasons.'):this.#ts=t.split("#",1)[0])}return`url(${this.#ts}#${t})`}addFilter(t){if(!t)return"none";let e=this.#A.get(t);if(e)return e;const[i,s,n]=this.#ls(t),a=1===t.length?i:`${i}${s}${n}`;if(e=this.#A.get(a),e)return this.#A.set(t,e),e;const r=`g_${this.#ss}_transfer_map_${this.#w++}`,o=this.#hs(r);this.#A.set(t,o),this.#A.set(a,o);const l=this.#ds(r);return this.#cs(i,s,n,l),o}addHCMFilter(t,e){const i=`${t}-${e}`,s="base";let n=this.#rs.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.#rs.set(s,n)),!t||!e)return n.url;const a=this.#us(t);t=St.makeHexColor(...a);const r=this.#us(e);if(e=St.makeHexColor(...r),this.#os.style.color="","#000000"===t&&"#ffffff"===e||t===e)return n.url;const o=new Array(256);for(let t=0;t<=255;t++){const e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const l=o.join(","),h=`g_${this.#ss}_hcm_filter`,d=n.filter=this.#ds(h);this.#cs(l,l,l,d),this.#ps(d);const c=(t,e)=>{const i=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.#cs(c(0,5),c(1,5),c(2,5),d),n.url=this.#hs(h),n.url}addAlphaFilter(t){let e=this.#A.get(t);if(e)return e;const[i]=this.#ls([t]),s=`alpha_${i}`;if(e=this.#A.get(s),e)return this.#A.set(t,e),e;const n=`g_${this.#ss}_alpha_map_${this.#w++}`,a=this.#hs(n);this.#A.set(t,a),this.#A.set(s,a);const r=this.#ds(n);return this.#gs(i,r),a}addLuminosityFilter(t){let e,i,s=this.#A.get(t||"luminosity");if(s)return s;if(t?([e]=this.#ls([t]),i=`luminosity_${e}`):i="luminosity",s=this.#A.get(i),s)return this.#A.set(t,s),s;const n=`g_${this.#ss}_luminosity_map_${this.#w++}`,a=this.#hs(n);this.#A.set(t,a),this.#A.set(i,a);const r=this.#ds(n);return this.#fs(r),t&&this.#gs(e,r),a}addHighlightHCMFilter(t,e,i,s,n){const a=`${e}-${i}-${s}-${n}`;let r=this.#rs.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.#rs.set(t,r)),!e||!i)return r.url;const[o,l]=[e,i].map(this.#us.bind(this));let h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[c,u]=[s,n].map(this.#us.bind(this));d<h&&([h,d,c,u]=[d,h,u,c]),this.#os.style.color="";const p=(t,e,i)=>{const s=new Array(256),n=(d-h)/i,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.#ss}_hcm_${t}_filter`,f=r.filter=this.#ds(g);return this.#ps(f),this.#cs(p(c[0],u[0],5),p(c[1],u[1],5),p(c[2],u[2],5),f),r.url=this.#hs(g),r.url}destroy(t=!1){t&&this.#as?.size||(this.#is?.parentNode.parentNode.remove(),this.#is=null,this.#es?.clear(),this.#es=null,this.#as?.clear(),this.#as=null,this.#w=0)}#fs(t){const e=this.#ns.createElementNS(Tt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#ps(t){const e=this.#ns.createElementNS(Tt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#ds(t){const e=this.#ns.createElementNS(Tt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#os.append(e),e}#ms(t,e,i){const s=this.#ns.createElementNS(Tt,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#cs(t,e,i,s){const n=this.#ns.createElementNS(Tt,"feComponentTransfer");s.append(n),this.#ms(n,"feFuncR",t),this.#ms(n,"feFuncG",e),this.#ms(n,"feFuncB",i)}#gs(t,e){const i=this.#ns.createElementNS(Tt,"feComponentTransfer");e.append(i),this.#ms(i,"feFuncA",t)}#us(t){return this.#os.style.color=t,$t(getComputedStyle(this.#os).getPropertyValue("color"))}},Wi=o?class extends Re{async _fetch(t){return Fe(t)}}:Ne;function Gi(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new Xi,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;try{return new URL(t,window.location).href}catch{if(o&&"string"==typeof t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(o&&"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 yt(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,l=t.password??null,h=t.range instanceof Ki?t.range:null,d=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:Vi;let c=t.worker instanceof Zi?t.worker:null;const u=t.verbosity,p="string"!=typeof t.docBaseUrl||Rt(t.docBaseUrl)?null:t.docBaseUrl,g="string"==typeof t.cMapUrl?t.cMapUrl:null,f=!1!==t.cMapPacked,m=t.CMapReaderFactory||Ui,b="string"==typeof t.standardFontDataUrl?t.standardFontDataUrl:null,v=t.StandardFontDataFactory||Wi,w=!0!==t.stopAtErrors,y=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,A=!1!==t.isEvalSupported,_="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!o,x="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!o&&(_t.platform.isFirefox||!globalThis.chrome),S=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,C="boolean"==typeof t.disableFontFace?t.disableFontFace:o,E=!0===t.fontExtraProperties,P=!0===t.enableXfa,M=t.ownerDocument||globalThis.document,T=!0===t.disableRange,k=!0===t.disableStream,I=!0===t.disableAutoFetch,L=!0===t.pdfBug,D=t.CanvasFactory||zi,R=t.FilterFactory||$i,N=!0===t.enableHWA,F=h?h.length:t.length??NaN,O="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!o&&!C,B="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:m===Le&&v===Ne&&g&&b&&jt(g,document.baseURI)&&jt(b,document.baseURI);st(u);const j={canvasFactory:new D({ownerDocument:M,enableHWA:N}),filterFactory:new R({docId:i,ownerDocument:M}),cMapReaderFactory:B?null:new m({baseUrl:g,isCompressed:f}),standardFontDataFactory:B?null:new v({baseUrl:b})};if(!c){const t={verbosity:u,port:ci.workerPort};c=t.port?Zi.fromPort(t):new Zi(t),e._worker=c}const H={docId:i,apiVersion:"4.10.38",data:n,password:l,disableAutoFetch:I,rangeChunkSize:d,length:F,docBaseUrl:p,enableXfa:P,evaluatorOptions:{maxImageSize:y,disableFontFace:C,ignoreErrors:w,isEvalSupported:A,isOffscreenCanvasSupported:_,isImageDecoderSupported:x,canvasMaxAreaInBytes:S,fontExtraProperties:E,useSystemFonts:O,cMapUrl:B?g:null,standardFontDataUrl:B?b:null}},V={disableFontFace:C,fontExtraProperties:E,ownerDocument:M,pdfBug:L,styleElement:null,loadingParams:{disableAutoFetch:I,enableXfa:P}};return c.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const t=c.messageHandler.sendWithPromise("GetDocRequest",H,n?[n.buffer]:null);let l;if(h)l=new mi(h,{disableRange:T,disableStream:k});else if(!n){if(!s)throw new Error("getDocument - no `url` parameter provided.");let t;if(o)if(jt(s)){if("undefined"==typeof fetch||"undefined"==typeof Response||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");t=Pi}else t=Ni;else t=jt(s)?Pi:Ii;l=new t({url:s,length:F,httpHeaders:a,withCredentials:r,rangeChunkSize:d,disableRange:T,disableStream:k})}return t.then((t=>{if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const s=new Te(i,t,c.port),n=new ts(s,e,l,V,j);e._transport=n,s.send("Ready",null)}))})).catch(e._capability.reject),e}function qi(t){return"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0}class Xi{static#ss=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+Xi.#ss++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await(this._transport?.destroy())}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}}let Ki=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){ot("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class Yi{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 dt(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 Qi{#bs=null;#vs=!1;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new Bt:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new is,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new Lt({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 dt(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=w.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:g}=c;this.#vs=!1,this.#ws(),r||=this._transport.getOptionalContentConfig(u);let f=this._intentStates.get(g);f||(f=Object.create(null),this._intentStates.set(g,f)),f.streamReaderCancelTimeout&&(clearTimeout(f.streamReaderCancelTimeout),f.streamReaderCancelTimeout=null);const m=!!(u&p);f.displayReadyCapability||(f.displayReadyCapability=Promise.withResolvers(),f.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(c));const b=t=>{f.renderTasks.delete(v),(this._maybeCleanupAfterRender||m)&&(this.#vs=!0),this.#ys(!m),t?(v.capability.reject(t),this._abortOperatorList({intentState:f,reason:t instanceof Error?t:new Error(t)})):v.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},v=new ns({callback:b,params:{canvasContext:t,viewport:e,transform:n,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:f.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!m,pdfBug:this._pdfBug,pageColors:l});(f.renderTasks||=new Set).add(v);const y=v.task;return Promise.all([f.displayReadyCapability.promise,r]).then((([t,e])=>{if(this.destroyed)b();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.");v.initializeGraphics({transparency:t,optionalContentConfig:e}),v.operatorListChanged()}})).catch(b),y}getOperatorList({intent:t="display",annotationMode:e=w.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=>Hi.textContent(t)));const e=this.streamTextContent(t);return new Promise((function(t,i){const s=e.getReader(),n={items:[],styles:Object.create(null),lang:null};!function e(){s.read().then((function({value:i,done:s}){s?t(n):(n.lang??=i.lang,Object.assign(n.styles,i.styles),n.items.push(...i.items),e())}),i)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#vs=!1,this.#ws(),Promise.all(t)}cleanup(t=!1){this.#vs=!0;const e=this.#ys(!1);return t&&e&&(this._stats&&=new Bt),e}#ys(t=!1){if(this.#ws(),!this.#vs||this.destroyed)return!1;if(t)return this.#bs=setTimeout((()=>{this.#bs=null,this.#ys(!1)}),5e3),!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#vs=!1,!0}#ws(){this.#bs&&(clearTimeout(this.#bs),this.#bs=null)}_startRenderPage(t,e){const i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const t of e.renderTasks)t.operatorListChanged();t.lastChunk&&this.#ys(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){const{map:n,transfer: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.#ys(!0)}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else{if(!o.opListReadCapability)throw t;o.opListReadCapability.reject(t)}}}))};l()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof Dt){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 vt(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 Ji{#As=new Map;#_s=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#_s.then((()=>{for(const[t]of this.#As)t.call(this,i)}))}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){const{signal:n}=i;if(n.aborted)return void rt("LoopbackPort - cannot use an `aborted` signal.");const a=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",a),n.addEventListener("abort",a)}this.#As.set(e,s)}removeEventListener(t,e){const i=this.#As.get(e);i?.(),this.#As.delete(e)}terminate(){for(const[,t]of this.#As)t?.();this.#As.clear()}}let Zi=class t{static#xs=0;static#Ss=!1;static#Cs;static{o&&(this.#Ss=!0,ci.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let i;try{if(i=new URL(t),!i.origin||"null"===i.origin)return!1}catch{return!1}const s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:e=null,port:i=null,verbosity:s=nt()}={}){if(this.name=e,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,i){if(t.#Cs?.has(i))throw new Error("Cannot use more than one PDFWorker per port.");return(t.#Cs||=new WeakMap).set(i,this),void this._initializeFromPort(i)}this._initialize()}get promise(){return this._readyCapability.promise}#Es(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new Te("main","worker",t),this._messageHandler.on("ready",(function(){})),this.#Es()}_initialize(){if(t.#Ss||t.#Ps)return void this._setupFakeWorker();let{workerSrc:e}=t;try{t._isSameOrigin(window.location.href,e)||(e=t._createCDNWrapper(new URL(e,window.location).href));const i=new Worker(e,{type:"module"}),s=new Te("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.#Es()):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{at("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){t.#Ss||(rt("Setting up fake worker."),t.#Ss=!0),t._setupFakeWorkerGlobal.then((e=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const i=new Ji;this._port=i;const s="fake"+t.#xs++,n=new Te(s+"_worker",s,i);e.setup(n,i),this._messageHandler=new Te(s,s+"_worker",i),this.#Es()})).catch((t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,t.#Cs?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(e){if(!e?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const i=this.#Cs?.get(e.port);if(i){if(i._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return i}return new t(e)}static get workerSrc(){if(ci.workerSrc)return ci.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#Ps(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return dt(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#Ps)return this.#Ps;return(await import(this.workerSrc)).WorkerMessageHandler})())}};class ts{#Ms=new Map;#Ts=new Map;#ks=new Map;#Is=new Map;#Ls=null;constructor(t,e,i,s,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new is,this.fontLoader=new fe({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#Ds(t,e=null){const i=this.#Ms.get(t);if(i)return i;const s=this.messageHandler.sendWithPromise(t,e);return this.#Ms.set(t,s),s}get annotationStorage(){return dt(this,"annotationStorage",new pe)}getRenderingIntent(t,e=w.ENABLE,i=null,s=!1,n=!1){let a=u,r=ue;switch(t){case"any":a=c;break;case"display":break;case"print":a=p;break;default:rt(`getRenderingIntent - invalid intent: ${t}`)}const o=a&p&&i instanceof ge?i:this.annotationStorage;switch(e){case w.DISABLE:a+=m;break;case w.ENABLE:break;case w.ENABLE_FORMS:a+=g;break;case w.ENABLE_STORAGE:a+=f,r=o.serializable;break;default:rt(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(a+=b),n&&(a+=v);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.#Ls?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#Ts.values())t.push(e._destroy());this.#Ts.clear(),this.#ks.clear(),this.#Is.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#Ms.clear(),this.filterFactory.destroy(),ji.cleanup(),this._networkStream?.cancelAllRequests(new vt("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)=>{lt(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():(lt(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)=>{lt(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():(lt(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 Yi(t,this))})),t.on("DocException",(t=>{e._capability.reject(Me(t))})),t.on("PasswordRequest",(t=>{this.#Ls=Promise.withResolvers();try{if(!e.onPassword)throw Me(t);const i=t=>{t instanceof Error?this.#Ls.reject(t):this.#Ls.resolve({password:t})};e.onPassword(i,t.code)}catch(t){this.#Ls.reject(t)}return this.#Ls.promise})),t.on("DataLoaded",(t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),t.on("StartRenderPage",(t=>{if(this.destroyed)return;this.#Ts.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),t.on("commonobj",(([e,i,s])=>{if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(i){case"Font":const{disableFontFace:n,fontExtraProperties:a,pdfBug:r}=this._params;if("error"in s){const t=s.error;rt(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const o=r&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,l=new me(s,{disableFontFace:n,fontExtraProperties:a,inspectFont:o});this.fontLoader.bind(l).catch((()=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!a&&l.data&&(l.data=null),this.commonObjs.resolve(e,l)}));break;case"CopyLocalImage":const{imageRef:h}=s;lt(h,"The imageRef must be defined.");for(const t of this.#Ts.values())for(const[,i]of t.objs)if(i?.ref===h)return i.dataLen?(this.commonObjs.resolve(e,structuredClone(i)),i.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,s);break;default:throw new Error(`Got unknown common object type ${i}`)}return null})),t.on("obj",(([t,e,i,s])=>{if(this.destroyed)return;const n=this.#Ts.get(e);if(!n.objs.has(t))if(0!==n._intentStates.size)switch(i){case"Image":n.objs.resolve(t,s),s?.dataLen>1e7&&(n._maybeCleanupAfterRender=!0);break;case"Pattern":n.objs.resolve(t,s);break;default:throw new Error(`Got unknown object type ${i}`)}else s?.bitmap?.close()})),t.on("DocProgress",(t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})})),t.on("FetchBuiltInCMap",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(t)})),t.on("FetchStandardFontData",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(t)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&rt("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally((()=>{this.annotationStorage.resetModified()}))}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,i=this.#ks.get(e);if(i)return i;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((i=>{if(this.destroyed)throw new Error("Transport destroyed");i.refStr&&this.#Is.set(i.refStr,t);const s=new Qi(e,i,this,this._params.pdfBug);return this.#Ts.set(e,s),s}));return this.#ks.set(e,s),s}getPageIndex(t){return qi(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#Ds("GetFieldObjects")}hasJSActions(){return this.#Ds("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#Ds("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#Ds("GetOptionalContentConfig").then((e=>new fi(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#Ms.get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new ui(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#Ms.set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of this.#Ts.values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),this.#Ms.clear(),this.filterFactory.destroy(!0),ji.cleanup()}}cachedPageNumber(t){if(!qi(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#Is.get(e)??null}}const es=Symbol("INITIAL_DATA");class is{#Rs=Object.create(null);#Ns(t){return this.#Rs[t]||={...Promise.withResolvers(),data:es}}get(t,e=null){if(e){const i=this.#Ns(t);return i.promise.then((()=>e(i.data))),null}const i=this.#Rs[t];if(!i||i.data===es)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#Rs[t];return!!e&&e.data!==es}delete(t){const e=this.#Rs[t];return!(!e||e.data===es)&&(delete this.#Rs[t],!0)}resolve(t,e=null){const i=this.#Ns(t);i.data=e,i.resolve()}clear(){for(const t in this.#Rs){const{data:e}=this.#Rs[t];e?.bitmap?.close()}this.#Rs=Object.create(null)}*[Symbol.iterator](){for(const t in this.#Rs){const{data:e}=this.#Rs[t];e!==es&&(yield[t,e])}}}class ss{#Fs=null;constructor(t){this.#Fs=t,this.onContinue=null}get promise(){return this.#Fs.capability.promise}cancel(t=0){this.#Fs.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#Fs.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#Fs;return t.form||t.canvas&&e?.size>0}}class ns{#Os=null;static#Bs=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 ss(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(ns.#Bs.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");ns.#Bs.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:i,viewport:s,transform:n,background:a}=this.params;this.gfx=new di(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.#Os&&(window.cancelAnimationFrame(this.#Os),this.#Os=null),ns.#Bs.delete(this._canvas),this.callback(t||new Dt(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#Os=window.requestAnimationFrame((()=>{this.#Os=null,this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),ns.#Bs.delete(this._canvas),this.callback())))}}const as="4.10.38",rs="f9bea397f";function os(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function ls(t){return Math.max(0,Math.min(255,255*t))}class hs{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=ls(t),t,t]}static G_HTML([t]){const e=os(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(ls)}static RGB_HTML(t){return`#${t.map(os).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[ls(1-Math.min(1,t+s)),ls(1-Math.min(1,i+s)),ls(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 ds{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){ot("Abstract method `_createSVG` called.")}}let cs=class extends ds{_createSVG(t){return document.createElementNS(Tt,t)}},us=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&&Hi.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&&Hi.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 ps=1e3,gs=new WeakSet;function fs(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class ms{static create(t){switch(t.data.annotationType){case I:return new vs(t);case k:return new ws(t);case q:switch(t.data.fieldType){case"Tx":return new As(t);case"Btn":return t.data.radioButton?new Ss(t):t.data.checkBox?new xs(t):new Cs(t);case"Ch":return new Es(t);case"Sig":return new _s(t)}return new ys(t);case W:return new Ps(t);case L:return new Ts(t);case D:return new ks(t);case R:return new Is(t);case N:return new Ls(t);case O:return new Ds(t);case U:return new Ns(t);case $:return new Fs(t);case F:return new Rs(t);case B:return new Os(t);case j:return new Bs(t);case H:return new js(t);case V:return new Hs(t);case z:return new Vs(t);case G:return new zs(t);default:return new bs(t)}}}class bs{#js=null;#Hs=!1;#Vs=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 bs._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#js||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#zs(e),this.#Vs?.popup.updateEdited(t)}resetEdited(){this.#js&&(this.#zs(this.#js.rect),this.#Vs?.popup.resetEdited(),this.#js=null)}#zs(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);const{width:l,height:h}=fs(t);e.left=100*(t[0]-r)/n+"%",e.top=100*(a-t[3]+o)/a+"%",0===s?(e.width=100*l/n+"%",e.height=100*h/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 ys||(n.tabIndex=ps);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 Ps){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:r,height:o}=fs(e.rect);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(--scale-factor)) / calc(${i}px * var(--scale-factor))`;a.borderRadius=e}else if(this instanceof Ss){const t=`calc(${r}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;a.borderRadius=t}switch(e.borderStyle.style){case X:a.borderStyle="solid";break;case K:a.borderStyle="dashed";break;case Y:rt("Unimplemented border style: beveled");break;case Q:rt("Unimplemented border style: inset");break;case J:a.borderBottomStyle="solid"}const s=e.borderColor||null;s?(this.#Hs=!0,a.borderColor=St.makeHexColor(0|s[0],0|s[1],0|s[2])):a.borderWidth=0}const l=St.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,{width:n,height:a}=fs(this.data.rect);let r,o;t%180==0?(r=100*n/i,o=100*a/s):(r=100*a/i,o=100*n/s),e.style.width=`${r}%`,e.style.height=`${o}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,i)=>{const s=i.detail[t],n=s[0],a=s.slice(1);i.target.style[e]=hs[`${n}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[e]:hs[`${n}_rgb`](a)})};return dt(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.#Hs){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.#Hs&&(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.#Vs=new Ps({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(){ot("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||gs.has(r)?i.push({id:n,exportValue:s,domElement:r}):rt(`_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&&(gs.has(s)&&i.push({id:n,exportValue:t,domElement:s}))}return i}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})}))}}class vs extends bs{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action),s=!0):t.attachment?(this.#Us(i,t.attachment,t.attachmentDest),s=!0):t.setOCGState?(this.#$s(i,t.setOCGState),s=!0):t.dest?(this._bindLink(i,t.dest),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&this.container.append(i),this.container}#Ws(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#Ws()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#Ws()}#Us(t,e,i=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,i),!1),this.#Ws()}#$s(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#Ws()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const s of Object.keys(e.actions)){const n=i.get(s);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}t.onclick||(t.onclick=()=>!1),this.#Ws()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#Ws(),!this._fieldObjects)return rt('_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&&(gs.has(i)?i.dispatchEvent(new Event("resetform")):rt(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class ws extends bs{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 ys extends bs{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return _t.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":St.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/(d*s))||1);a=Math.min(s,r(e/d))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(s,r(t/d))}n.fontSize=`calc(${a}px * var(--scale-factor))`,n.color=St.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 As extends ys{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="text",i.setAttribute("value",r??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),gs.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=ps,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(--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 _s extends ys{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class xs extends ys{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 gs.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=ps,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 Ss extends ys{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(gs.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=ps,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 Cs extends vs{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 Es extends ys{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");gs.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=ps;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 Ps extends bs{constructor(t){const{data:e,elements:i}=t;super(t,{isRenderable:bs._hasPopupData(e)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Ms({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=>`${Mt}${t}`)).join(",")),this.container}}class Ms{#Gs=this.#qs.bind(this);#Xs=this.#Ks.bind(this);#Ys=this.#Qs.bind(this);#Js=this.#Zs.bind(this);#tn=null;#pt=null;#en=null;#in=null;#sn=null;#nn=null;#an=null;#rn=!1;#on=null;#E=null;#ln=null;#hn=null;#dn=null;#js=null;#cn=!1;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:n,contentsObj:a,richText:r,parent:o,rect:l,parentRect:h,open:d}){this.#pt=t,this.#dn=s,this.#en=a,this.#hn=r,this.#nn=o,this.#tn=e,this.#ln=l,this.#an=h,this.#sn=i,this.#in=zt.toDateObject(n),this.trigger=i.flatMap((t=>t.getElementsToTriggerPopup()));for(const t of this.trigger)t.addEventListener("click",this.#Js),t.addEventListener("mouseenter",this.#Ys),t.addEventListener("mouseleave",this.#Xs),t.classList.add("popupTriggerArea");for(const t of i)t.container?.addEventListener("keydown",this.#Gs);this.#pt.hidden=!0,d&&this.#Zs()}render(){if(this.#on)return;const t=this.#on=document.createElement("div");if(t.className="popup",this.#tn){const e=t.style.outlineColor=St.makeHexColor(...this.#tn);if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`;else{const e=.7;t.style.backgroundColor=St.makeHexColor(...this.#tn.map((t=>Math.floor(e*(255-t)+t))))}}const e=document.createElement("span");e.className="header";const i=document.createElement("h1");if(e.append(i),({dir:i.dir,str:i.textContent}=this.#dn),t.append(e),this.#in){const t=document.createElement("span");t.classList.add("popupDate"),t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#in.valueOf()})),e.append(t)}const s=this.#un;if(s)us.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(this.#en);t.append(e)}this.#pt.append(t)}get#un(){const t=this.#hn,e=this.#en;return!t?.str||e?.str&&e.str!==t.str?null:this.#hn.html||null}get#pn(){return this.#un?.attributes?.style?.fontSize||0}get#gn(){return this.#un?.attributes?.style?.color||null}#fn(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:this.#gn,fontSize:this.#pn?`calc(${this.#pn}px * var(--scale-factor))`:""}};for(const i of t.split("\n"))e.push({name:"span",value:i,attributes:s});return i}_formatContents({str:t,dir:e}){const i=document.createElement("p");i.classList.add("popupContent"),i.dir=e;const s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t){const n=s[t];i.append(document.createTextNode(n)),t<e-1&&i.append(document.createElement("br"))}return i}#qs(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#rn)&&this.#Zs()}updateEdited({rect:t,popupContent:e}){this.#js||={contentsObj:this.#en,richText:this.#hn},t&&(this.#E=null),e&&(this.#hn=this.#fn(e),this.#en=null),this.#on?.remove(),this.#on=null}resetEdited(){this.#js&&(({contentsObj:this.#en,richText:this.#hn}=this.#js),this.#js=null,this.#on?.remove(),this.#on=null,this.#E=null)}#mn(){if(null!==this.#E)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=this.#nn;let a=!!this.#an,r=a?this.#an:this.#ln;for(const t of this.#sn)if(!r||null!==St.intersect(t.data.rect,r)){r=t.data.rect,a=!0;break}const o=St.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.#E=[100*(h-s)/e,100*(d-n)/i];const{style:c}=this.#pt;c.left=`${this.#E[0]}%`,c.top=`${this.#E[1]}%`}#Zs(){this.#rn=!this.#rn,this.#rn?(this.#Qs(),this.#pt.addEventListener("click",this.#Js),this.#pt.addEventListener("keydown",this.#Gs)):(this.#Ks(),this.#pt.removeEventListener("click",this.#Js),this.#pt.removeEventListener("keydown",this.#Gs))}#Qs(){this.#on||this.render(),this.isVisible?this.#rn&&this.#pt.classList.add("focused"):(this.#mn(),this.#pt.hidden=!1,this.#pt.style.zIndex=parseInt(this.#pt.style.zIndex)+1e3)}#Ks(){this.#pt.classList.remove("focused"),!this.#rn&&this.isVisible&&(this.#pt.hidden=!0,this.#pt.style.zIndex=parseInt(this.#pt.style.zIndex)-1e3)}forceHide(){this.#cn=this.isVisible,this.#cn&&(this.#pt.hidden=!0)}maybeShow(){this.#cn&&(this.#on||this.#Qs(),this.#cn=!1,this.#pt.hidden=!1)}get isVisible(){return!1===this.#pt.hidden}}class Ts extends bs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=y.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 ks extends bs{#bn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const t=this.data,{width:e,height:i}=fs(t.rect),s=this.svgFactory.create(e,i,!0),n=this.#bn=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#bn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Is extends bs{#vn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const t=this.data,{width:e,height:i}=fs(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,a=this.#vn=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.#vn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ls extends bs{#wn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const t=this.data,{width:e,height:i}=fs(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,a=this.#wn=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.#wn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ds extends bs{#yn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:i,popupRef:s}}=this;if(!e)return this.container;const{width:n,height:a}=fs(t),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.#yn=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),r.append(l),this.container.append(r),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#yn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Rs extends Ds{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Ns extends bs{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 Fs extends bs{#An=null;#_n=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?y.HIGHLIGHT:y.INK}#xn(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:i,borderStyle:s,popupRef:n}}=this,{transform:a,width:r,height:o}=this.#xn(e,t),l=this.svgFactory.create(r,o,!0),h=this.#An=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",a);for(let t=0,e=i.length;t<e;t++){const e=this.svgFactory.createElement(this.svgElementName);this.#_n.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!n&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:i,rect:s}=t,n=this.#An;if(e>=0&&n.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#_n.length;t<e;t++)this.#_n[t].setAttribute("points",i[t].join(","));if(s){const{transform:t,width:e,height:i}=this.#xn(this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#_n}addHighlightArea(){this.container.classList.add("highlightArea")}}class Os extends bs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=y.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Bs extends bs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class js extends bs{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 Hs extends bs{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 Vs extends bs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=y.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 zs extends bs{#Sn=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let i;e.hasAppearance||0===e.fillAlpha?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),i.addEventListener("dblclick",this.#Cn.bind(this)),this.#Sn=i;const{isMac:s}=_t.platform;return t.addEventListener("keydown",(t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#Cn()})),!e.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#Sn}addHighlightArea(){this.container.classList.add("highlightArea")}#Cn(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}let Us=class{#En=null;#Pn=null;#Mn=new Map;#Tn=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:a,structTreeLayer:r}){this.div=t,this.#En=e,this.#Pn=i,this.#Tn=r||null,this.page=n,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return this.#Mn.size>0}async#kn(t,e){const i=t.firstChild||t,s=i.id=`${Mt}${e}`,n=await(this.#Tn?.getAriaAttributes(s));if(n)for(const[t,e]of n)i.setAttribute(t,e);this.div.append(t),this.#En?.moveElementInDOM(this.div,t,i,!1)}async render(t){const{annotations:e}=t,i=this.div;qt(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 cs,annotationStorage:t.annotationStorage||new pe,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===W;if(e){const e=s.get(t.id);if(!e)continue;n.elements=e}else{const{width:e,height:i}=fs(t.rect);if(e<=0||i<=0)continue}n.data=t;const i=ms.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.#kn(a,t.id),i._isEditable&&(this.#Mn.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}this.#In()}update({viewport:t}){const e=this.div;this.viewport=t,qt(e,{rotation:t.rotation}),this.#In(),e.hidden=!1}#In(){if(!this.#Pn)return;const t=this.div;for(const[e,i]of this.#Pn){const s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent";const{firstChild:n}=s;n?"CANVAS"===n.nodeName?n.replaceWith(i):n.classList.contains("annotationContent")?n.after(i):n.before(i):s.append(i)}this.#Pn.clear()}getEditableAnnotations(){return Array.from(this.#Mn.values())}getEditableAnnotation(t){return this.#Mn.get(t)}};const $s=/\r\n?|\n/g;class Ws extends re{#tn;#Ln="";#Dn=`${this.id}-editor`;#Rn=null;#pn;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=Ws.prototype,e=t=>t.isEmpty(),i=se.TRANSLATE_SMALL,s=se.TRANSLATE_BIG;return dt(this,"_keyboardManager",new ee([[["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=y.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#tn=t.color||Ws._defaultColor||re._defaultLineColor,this.#pn=t.fontSize||Ws._defaultFontSize}static initialize(t,e){re.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case A.FREETEXT_SIZE:Ws._defaultFontSize=e;break;case A.FREETEXT_COLOR:Ws._defaultColor=e}}updateParams(t,e){switch(t){case A.FREETEXT_SIZE:this.#Nn(e);break;case A.FREETEXT_COLOR:this.#Fn(e)}}static get defaultPropertiesToUpdate(){return[[A.FREETEXT_SIZE,Ws._defaultFontSize],[A.FREETEXT_COLOR,Ws._defaultColor||re._defaultLineColor]]}get propertiesToUpdate(){return[[A.FREETEXT_SIZE,this.#pn],[A.FREETEXT_COLOR,this.#tn]]}#Nn(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--scale-factor))`,this.translate(0,-(t-this.#pn)*this.parentScale),this.#pn=t,this.#On()},i=this.#pn;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:A.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#Fn(t){const e=t=>{this.#tn=this.editorDiv.style.color=t},i=this.#tn;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:A.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-Ws._internalPadding*t,-(Ws._internalPadding+this.#pn)*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(y.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#Rn=new AbortController;const t=this._uiManager.combinedSignal(this.#Rn);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#Dn),this._isDraggable=!0,this.#Rn?.abort(),this.#Rn=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#Bn(){const t=[];this.editorDiv.normalize();let e=null;for(const i of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&"BR"===i.nodeName||(t.push(Ws.#jn(i)),e=i);return t.join("\n")}#On(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,s=e.style.display,n=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),i=e.getBoundingClientRect(),e.remove(),e.style.display=s,e.classList.toggle("hidden",n)}this.rotation%180==this.parentRotation%180?(this.width=i.width/t,this.height=i.height/e):(this.width=i.height/t,this.height=i.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#Ln,e=this.#Ln=this.#Bn().trimEnd();if(t===e)return;const i=t=>{this.#Ln=t,t?(this.#Hn(),this._uiManager.rebuild(this),this.#On()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#On()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){Ws._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#Dn),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#pn}px * var(--scale-factor))`,i.color=this.#tn,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Qt(this,this.div,["dblclick","keydown"]),this.width){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.setAt(t*i,e*s,this.width*i,this.height*s);this.#Hn(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#jn(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll($s,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const s=Ws.#Vn(e.getData("text")||"").replaceAll($s,"\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($s,"")),t!==this.editorDiv){let e=l;for(const i of this.editorDiv.childNodes)i!==t?e.push(Ws.#jn(i)):e=h}l.push(r.nodeValue.slice(0,o).replaceAll($s,""))}else if(r===this.editorDiv){let t=l,e=0;for(const i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(Ws.#jn(i))}this.#Ln=`${l.join("\n")}${s}${h.join("\n")}`,this.#Hn();const d=new Range;let c=l.reduce(((t,e)=>t+e.length),0);for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(c<=e){d.setStart(t,c),d.setEnd(t,c);break}c-=e}n.removeAllRanges(),n.addRange(d)}#Hn(){if(this.editorDiv.replaceChildren(),this.#Ln)for(const t of this.#Ln.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#zn(){return this.#Ln.replaceAll(" "," ")}static#Vn(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,i){let s=null;if(t instanceof Ts){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:y.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.#pn=t.fontSize,n.#tn=St.makeHexColor(...t.color),n.#Ln=Ws.#Vn(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=Ws._internalPadding*this.parentScale,i=this.getRect(e,e),s=re._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#tn),n={annotationType:y.FREETEXT,color:s,fontSize:this.#pn,value:this.#zn(),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?n:this.annotationElementId&&!this.#Un(n)?null:(n.id=this.annotationElementId,n)}#Un(t){const{value:e,fontSize:i,color:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some(((t,e)=>t!==s[e]))||t.pageIndex!==n}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:i}=e;i.fontSize=`calc(${this.#pn}px * var(--scale-factor))`,i.color=this.#tn,e.replaceChildren();for(const t of this.#Ln.split("\n")){const i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}const s=Ws._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:this.#Ln}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class Gs{static PRECISION=1e-4;toSVGPath(){ot("Abstract method `toSVGPath` must be implemented.")}get box(){ot("Abstract getter `box` must be implemented.")}serialize(t,e){ot("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 qs{#$n;#Wn=[];#Gn;#qn;#Xn=[];#Kn=new Float32Array(18);#Yn;#Qn;#Jn;#Zn;#ta;#ea;#ia=[];static#sa=8;static#na=2;static#aa=qs.#sa+qs.#na;constructor({x:t,y:e},i,s,n,a,r=0){this.#$n=i,this.#ea=n*s,this.#qn=a,this.#Kn.set([NaN,NaN,NaN,NaN,t,e],6),this.#Gn=r,this.#Zn=qs.#sa*s,this.#Jn=qs.#aa*s,this.#ta=s,this.#ia.push(t,e)}isEmpty(){return isNaN(this.#Kn[8])}#ra(){const t=this.#Kn.subarray(4,6),e=this.#Kn.subarray(16,18),[i,s,n,a]=this.#$n;return[(this.#Yn+(t[0]-e[0])/2-i)/n,(this.#Qn+(t[1]-e[1])/2-s)/a,(this.#Yn+(e[0]-t[0])/2-i)/n,(this.#Qn+(e[1]-t[1])/2-s)/a]}add({x:t,y:e}){this.#Yn=t,this.#Qn=e;const[i,s,n,a]=this.#$n;let[r,o,l,h]=this.#Kn.subarray(8,12);const d=t-l,c=e-h,u=Math.hypot(d,c);if(u<this.#Jn)return!1;const p=u-this.#Zn,g=p/u,f=g*d,m=g*c;let b=r,v=o;r=l,o=h,l+=f,h+=m,this.#ia?.push(t,e);const w=f/p,y=-m/p*this.#ea,A=w*this.#ea;if(this.#Kn.set(this.#Kn.subarray(2,8),0),this.#Kn.set([l+y,h+A],4),this.#Kn.set(this.#Kn.subarray(14,18),12),this.#Kn.set([l-y,h-A],16),isNaN(this.#Kn[6]))return 0===this.#Xn.length&&(this.#Kn.set([r+y,o+A],2),this.#Xn.push(NaN,NaN,NaN,NaN,(r+y-i)/n,(o+A-s)/a),this.#Kn.set([r-y,o-A],14),this.#Wn.push(NaN,NaN,NaN,NaN,(r-y-i)/n,(o-A-s)/a)),this.#Kn.set([b,v,r,o,l,h],6),!this.isEmpty();this.#Kn.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.#Kn.subarray(2,6),this.#Xn.push(NaN,NaN,NaN,NaN,((r+l)/2-i)/n,((o+h)/2-s)/a),[r,o,b,v]=this.#Kn.subarray(14,18),this.#Wn.push(NaN,NaN,NaN,NaN,((b+r)/2-i)/n,((v+o)/2-s)/a),!0):([b,v,r,o,l,h]=this.#Kn.subarray(0,6),this.#Xn.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.#Kn.subarray(12,18),this.#Wn.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.#Xn,e=this.#Wn;if(isNaN(this.#Kn[6])&&!this.isEmpty())return this.#oa();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.#la(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.#ha(i),i.join(" ")}#oa(){const[t,e,i,s]=this.#$n,[n,a,r,o]=this.#ra();return`M${(this.#Kn[2]-t)/i} ${(this.#Kn[3]-e)/s} L${(this.#Kn[4]-t)/i} ${(this.#Kn[5]-e)/s} L${n} ${a} L${r} ${o} L${(this.#Kn[16]-t)/i} ${(this.#Kn[17]-e)/s} L${(this.#Kn[14]-t)/i} ${(this.#Kn[15]-e)/s} Z`}#ha(t){const e=this.#Wn;t.push(`L${e[4]} ${e[5]} Z`)}#la(t){const[e,i,s,n]=this.#$n,a=this.#Kn.subarray(4,6),r=this.#Kn.subarray(16,18),[o,l,h,d]=this.#ra();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 Xs(t,e,i,s,n,a)}getOutlines(){const t=this.#Xn,e=this.#Wn,i=this.#Kn,[s,n,a,r]=this.#$n,o=new Float32Array((this.#ia?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#ia[t]-s)/a,o[t+1]=(this.#ia[t+1]-n)/r;if(o[o.length-2]=(this.#Yn-s)/a,o[o.length-1]=(this.#Qn-n)/r,isNaN(i[6])&&!this.isEmpty())return this.#da(o);const l=new Float32Array(this.#Xn.length+24+this.#Wn.length);let h=t.length;for(let e=0;e<h;e+=2)isNaN(t[e])?l[e]=l[e+1]=NaN:(l[e]=t[e],l[e+1]=t[e+1]);h=this.#ca(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.#ua(l,h),this.newFreeDrawOutline(l,o,this.#$n,this.#ta,this.#Gn,this.#qn)}#da(t){const e=this.#Kn,[i,s,n,a]=this.#$n,[r,o,l,h]=this.#ra(),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.#$n,this.#ta,this.#Gn,this.#qn)}#ua(t,e){const i=this.#Wn;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#ca(t,e){const i=this.#Kn.subarray(4,6),s=this.#Kn.subarray(16,18),[n,a,r,o]=this.#$n,[l,h,d,c]=this.#ra();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 Xs extends Gs{#$n;#pa=new Float32Array(4);#Gn;#qn;#ia;#ta;#ga;constructor(t,e,i,s,n,a){super(),this.#ga=t,this.#ia=e,this.#$n=i,this.#ta=s,this.#Gn=n,this.#qn=a,this.lastPoint=[NaN,NaN],this.#fa(a);const[r,o,l,h]=this.#pa;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.#ga[4]} ${this.#ga[5]}`];for(let e=6,i=this.#ga.length;e<i;e+=6)isNaN(this.#ga[e])?t.push(`L${this.#ga[e+4]} ${this.#ga[e+5]}`):t.push(`C${this.#ga[e]} ${this.#ga[e+1]} ${this.#ga[e+2]} ${this.#ga[e+3]} ${this.#ga[e+4]} ${this.#ga[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=Gs._rescale(this.#ga,t,s,a,-r),l=Gs._rescale(this.#ia,t,s,a,-r);break;case 90:o=Gs._rescaleAndSwap(this.#ga,t,e,a,r),l=Gs._rescaleAndSwap(this.#ia,t,e,a,r);break;case 180:o=Gs._rescale(this.#ga,i,e,-a,r),l=Gs._rescale(this.#ia,i,e,-a,r);break;case 270:o=Gs._rescaleAndSwap(this.#ga,i,s,-a,-r),l=Gs._rescaleAndSwap(this.#ia,i,s,-a,-r)}return{outline:Array.from(o),points:[Array.from(l)]}}#fa(t){const e=this.#ga;let i=e[4],s=e[5],n=i,a=s,r=i,o=s,l=i,h=s;const d=t?Math.max:Math.min;for(let t=6,c=e.length;t<c;t+=6){if(isNaN(e[t]))n=Math.min(n,e[t+4]),a=Math.min(a,e[t+5]),r=Math.max(r,e[t+4]),o=Math.max(o,e[t+5]),h<e[t+5]?(l=e[t+4],h=e[t+5]):h===e[t+5]&&(l=d(l,e[t+4]));else{const c=St.bezierBoundingBox(i,s,...e.slice(t,t+6));n=Math.min(n,c[0]),a=Math.min(a,c[1]),r=Math.max(r,c[2]),o=Math.max(o,c[3]),h<c[3]?(l=c[2],h=c[3]):h===c[3]&&(l=d(l,c[2]))}i=e[t+4],s=e[t+5]}const c=this.#pa;c[0]=n-this.#Gn,c[1]=a-this.#Gn,c[2]=r-n+2*this.#Gn,c[3]=o-a+2*this.#Gn,this.lastPoint=[l,h]}get box(){return this.#pa}newOutliner(t,e,i,s,n,a=0){return new qs(t,e,i,s,n,a)}getNewOutline(t,e){const[i,s,n,a]=this.#pa,[r,o,l,h]=this.#$n,d=n*l,c=a*h,u=i*l+r,p=s*h+o,g=this.newOutliner({x:this.#ia[0]*d+u,y:this.#ia[1]*c+p},this.#$n,this.#ta,t,this.#qn,e??this.#Gn);for(let t=2;t<this.#ia.length;t+=2)g.add({x:this.#ia[t]*d+u,y:this.#ia[t+1]*c+p});return g.getOutlines()}}class Ks{#$n;#ma;#ba=[];#va=[];constructor(t,e=0,i=0,s=!0){let n=1/0,a=-1/0,r=1/0,o=-1/0;const l=10**-4;for(const{x:i,y:s,width:h,height:d}of t){const t=Math.floor((i-e)/l)*l,c=Math.ceil((i+h+e)/l)*l,u=Math.floor((s-e)/l)*l,p=Math.ceil((s+d+e)/l)*l,g=[t,u,p,!0],f=[c,u,p,!1];this.#ba.push(g,f),n=Math.min(n,t),a=Math.max(a,c),r=Math.min(r,u),o=Math.max(o,p)}const h=a-n+2*i,d=o-r+2*i,c=n-i,u=r-i,p=this.#ba.at(s?-1:-2),g=[p[0],p[2]];for(const t of this.#ba){const[e,i,s]=t;t[0]=(e-c)/h,t[1]=(i-u)/d,t[2]=(s-u)/d}this.#$n=new Float32Array([c,u,h,d]),this.#ma=g}getOutlines(){this.#ba.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of this.#ba)e[3]?(t.push(...this.#wa(e)),this.#ya(e)):(this.#Aa(e),t.push(...this.#wa(e)));return this.#_a(t)}#_a(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 Ys(s,this.#$n,this.#ma)}#xa(t){const e=this.#va;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}#ya([,t,e]){const i=this.#xa(t);this.#va.splice(i,0,[t,e])}#Aa([,t,e]){const i=this.#xa(t);for(let s=i;s<this.#va.length;s++){const[i,n]=this.#va[s];if(i!==t)break;if(i===t&&n===e)return void this.#va.splice(s,1)}for(let s=i-1;s>=0;s--){const[i,n]=this.#va[s];if(i!==t)break;if(i===t&&n===e)return void this.#va.splice(s,1)}}#wa(t){const[e,i,s]=t,n=[[e,i,s]],a=this.#xa(s);for(let t=0;t<a;t++){const[i,s]=this.#va[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 Ys extends Gs{#$n;#Sa;constructor(t,e,i){super(),this.#Sa=t,this.#$n=e,this.lastPoint=i}toSVGPath(){const t=[];for(const e of this.#Sa){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.#Sa){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.#$n}get classNamesForOutlining(){return["highlightOutline"]}}class Qs extends qs{newFreeDrawOutline(t,e,i,s,n,a){return new Js(t,e,i,s,n,a)}}class Js extends Xs{newOutliner(t,e,i,s,n,a=0){return new Qs(t,e,i,s,n,a)}}let Zs=class t{#Ca=null;#Ea=null;#Pa;#Ma=null;#Ta=!1;#ka=!1;#a=null;#Ia;#La=null;#f=null;#Da;static#Ra=null;static get _keyboardManager(){return dt(this,"_keyboardManager",new ee([[["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.#ka=!1,this.#Da=A.HIGHLIGHT_COLOR,this.#a=e):(this.#ka=!0,this.#Da=A.HIGHLIGHT_DEFAULT_COLOR),this.#f=e?._uiManager||i,this.#Ia=this.#f._eventBus,this.#Pa=e?.color||this.#f?.highlightColors.values().next().value||"#FFFF98",t.#Ra||=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.#Ca=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=this.#f._signal;t.addEventListener("click",this.#Na.bind(this),{signal:e}),t.addEventListener("keydown",this.#qs.bind(this),{signal:e});const i=this.#Ea=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#Pa,t.append(i),t}renderMainDropdown(){const t=this.#Ma=this.#Fa();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#Fa(){const e=document.createElement("div"),i=this.#f._signal;e.addEventListener("contextmenu",Ht,{signal:i}),e.className="dropdown",e.role="listbox",e.setAttribute("aria-multiselectable",!1),e.setAttribute("aria-orientation","vertical"),e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[s,n]of this.#f.highlightColors){const a=document.createElement("button");a.tabIndex="0",a.role="option",a.setAttribute("data-color",n),a.title=s,a.setAttribute("data-l10n-id",t.#Ra[s]);const r=document.createElement("span");a.append(r),r.className="swatch",r.style.backgroundColor=n,a.setAttribute("aria-selected",n===this.#Pa),a.addEventListener("click",this.#Oa.bind(this,n),{signal:i}),e.append(a)}return e.addEventListener("keydown",this.#qs.bind(this),{signal:i}),e}#Oa(t,e){e.stopPropagation(),this.#Ia.dispatch("switchannotationeditorparams",{source:this,type:this.#Da,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#Ca)return void this.#Na(t);const e=t.target.getAttribute("data-color");e&&this.#Oa(e,t)}_moveToNext(t){this.#Ba?t.target!==this.#Ca?t.target.nextSibling?.focus():this.#Ma.firstChild?.focus():this.#Na(t)}_moveToPrevious(t){t.target!==this.#Ma?.firstChild&&t.target!==this.#Ca?(this.#Ba||this.#Na(t),t.target.previousSibling?.focus()):this.#Ba&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#Ba?this.#Ma.firstChild?.focus():this.#Na(t)}_moveToEnd(t){this.#Ba?this.#Ma.lastChild?.focus():this.#Na(t)}#qs(e){t._keyboardManager.exec(this,e)}#Na(t){if(this.#Ba)return void this.hideDropdown();if(this.#Ta=0===t.detail,this.#La||(this.#La=new AbortController,window.addEventListener("pointerdown",this.#h.bind(this),{signal:this.#f.combinedSignal(this.#La)})),this.#Ma)return void this.#Ma.classList.remove("hidden");const e=this.#Ma=this.#Fa();this.#Ca.append(e)}#h(t){this.#Ma?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#Ma?.classList.add("hidden"),this.#La?.abort(),this.#La=null}get#Ba(){return this.#Ma&&!this.#Ma.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#ka||(this.#Ba?(this.hideDropdown(),this.#Ca.focus({preventScroll:!0,focusVisible:this.#Ta})):this.#a?.unselect())}updateColor(t){if(this.#Ea&&(this.#Ea.style.backgroundColor=t),!this.#Ma)return;const e=this.#f.highlightColors.values();for(const i of this.#Ma.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#Ca?.remove(),this.#Ca=null,this.#Ea=null,this.#Ma?.remove(),this.#Ma=null}};class tn extends re{#ja=null;#Ha=0;#Va;#za=null;#n=null;#Ua=null;#$a=null;#Wa=0;#Ga=null;#qa=null;#w=null;#Xa=!1;#ma=null;#Ka;#Ya=null;#Qa="";#ea;#Ja="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=y.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=tn.prototype;return dt(this,"_keyboardManager",new ee([[["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||tn._defaultColor,this.#ea=t.thickness||tn._defaultThickness,this.#Ka=t.opacity||tn._defaultOpacity,this.#Va=t.boxes||null,this.#Ja=t.methodOfCreation||"",this.#Qa=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#Xa=!0,this.#Za(t),this.#tr()):this.#Va&&(this.#ja=t.anchorNode,this.#Ha=t.anchorOffset,this.#$a=t.focusNode,this.#Wa=t.focusOffset,this.#er(),this.#tr(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#Xa?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#ea,methodOfCreation:this.#Ja}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#er(){const t=new Ks(this.#Va,.001);this.#qa=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#qa.box;const e=new Ks(this.#Va,.0025,.001,"ltr"===this._uiManager.direction);this.#Ua=e.getOutlines();const{lastPoint:i}=this.#Ua;this.#ma=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#Za({highlightOutlines:t,highlightId:e,clipPathId:i}){this.#qa=t;if(this.#Ua=t.getNewOutline(this.#ea/2+1.5,.0025),e>=0)this.#w=e,this.#za=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#Ya=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#Ua.box,path:{d:this.#Ua.toSVGPath()}},!0);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#w,{bbox:tn.#ir(this.#qa.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#Ya,{bbox:tn.#ir(this.#Ua.box,e),path:{d:this.#Ua.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.#Ua;this.#ma=[(o[0]-s)/a,(o[1]-n)/r]}static initialize(t,e){re.initialize(t,e),tn._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case A.HIGHLIGHT_DEFAULT_COLOR:tn._defaultColor=e;break;case A.HIGHLIGHT_THICKNESS:tn._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#ma}updateParams(t,e){switch(t){case A.HIGHLIGHT_COLOR:this.#Fn(e);break;case A.HIGHLIGHT_THICKNESS:this.#sr(e)}}static get defaultPropertiesToUpdate(){return[[A.HIGHLIGHT_DEFAULT_COLOR,tn._defaultColor],[A.HIGHLIGHT_THICKNESS,tn._defaultThickness]]}get propertiesToUpdate(){return[[A.HIGHLIGHT_COLOR,this.color||tn._defaultColor],[A.HIGHLIGHT_THICKNESS,this.#ea||tn._defaultThickness],[A.HIGHLIGHT_FREE,this.#Xa]]}#Fn(t){const e=(t,e)=>{this.color=t,this.#Ka=e,this.parent?.drawLayer.updateProperties(this.#w,{root:{fill:t,"fill-opacity":e}}),this.#n?.updateColor(t)},i=this.color,s=this.#Ka;this.addCommands({cmd:e.bind(this,t,tn._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:A.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#sr(t){const e=this.#ea,i=t=>{this.#ea=t,this.#nr(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:A.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 Zs({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.#ar())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#ar())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#rr(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#tr(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#rr():t&&(this.#tr(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#nr(t){if(!this.#Xa)return;this.#Za({highlightOutlines:this.#qa.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#rr(){null!==this.#w&&this.parent&&(this.parent.drawLayer.remove(this.#w),this.#w=null,this.parent.drawLayer.remove(this.#Ya),this.#Ya=null)}#tr(t=this.parent){null===this.#w&&(({id:this.#w,clipPathId:this.#za}=t.drawLayer.draw({bbox:this.#qa.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#Ka},rootClass:{highlight:!0,free:this.#Xa},path:{d:this.#qa.toSVGPath()}},!1,!0)),this.#Ya=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#Xa},bbox:this.#Ua.box,path:{d:this.#Ua.toSVGPath()}},this.#Xa),this.#Ga&&(this.#Ga.style.clipPath=this.#za))}static#ir([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.#Xa?(t=(t-this.rotation+360)%360,i=tn.#ir(this.#qa.box,t)):i=tn.#ir([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#w,{bbox:i,root:{"data-main-rotation":t}}),e.updateProperties(this.#Ya,{bbox:tn.#ir(this.#Ua.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.#Xa?t.classList.add("free"):this.div.addEventListener("keydown",this.#or.bind(this),{signal:this._uiManager._signal});const e=this.#Ga=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#za;const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),Qt(this,this.#Ga,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Ya,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Ya,{rootClass:{hovered:!1}})}#or(t){tn._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#lr(!0);break;case 1:case 3:this.#lr(!1)}}#lr(t){if(!this.#ja)return;const e=window.getSelection();t?e.setPosition(this.#ja,this.#Ha):e.setPosition(this.#$a,this.#Wa)}select(){super.select(),this.#Ya&&this.parent?.drawLayer.updateProperties(this.#Ya,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#Ya&&(this.parent?.drawLayer.updateProperties(this.#Ya,{rootClass:{selected:!1}}),this.#Xa||this.#lr(!1))}get _mustFixPosition(){return!this.#Xa}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#w,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#Ya,{rootClass:{hidden:!t}}))}#ar(){return this.#Xa?this.rotation:0}#hr(){if(this.#Xa)return null;const[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=this.#Va,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}#dr(t){return this.#qa.serialize(t,this.#ar())}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.#cr(t,e)};window.addEventListener("blur",c,{signal:d}),window.addEventListener("pointerup",c,{signal:d}),window.addEventListener("pointerdown",Vt,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",Ht,{signal:d}),i.addEventListener("pointermove",this.#ur.bind(this,t),{signal:d}),this._freeHighlight=new Qs({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#ur(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#cr(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 Os){const{data:{quadPoints:e,rect:i,rotation:n,id:a,color:r,opacity:o,popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:y.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 Fs){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:y.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=St.makeHexColor(...n),l.#Ka=o||1,r&&(l.#ea=t.thickness),l.annotationElementId=t.id||null,l._initialData=s;const[h,d]=l.pageDimensions,[c,u]=l.pageTranslation;if(a){const t=l.#Va=[];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.#er(),l.#tr(),l.rotate(l.rotation)}else if(r){l.#Xa=!0;const t=r[0],i={x:t[0]-c,y:d-(t[1]-u)},s=new Qs(i,[0,0,h,d],1,l.#ea/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.#Za({highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:a}),l.#tr()}return l}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),i=re._colorManager.convert(this.color),s={annotationType:y.HIGHLIGHT,color:i,opacity:this.#Ka,thickness:this.#ea,quadPoints:this.#hr(),outlines:this.#dr(e),pageIndex:this.pageIndex,rect:e,rotation:this.#ar(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#Un(s)?null:(s.id=this.annotationElementId,s)}#Un(t){const{color:e}=this._initialData;return t.color.some(((t,i)=>t!==e[i]))}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class en{#pr=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,i]of Object.entries(t))this.updateProperty(e,i)}updateSVGProperty(t,e){this.#pr[t]=e}toSVGProperties(){const t=this.#pr;return this.#pr=Object.create(null),{root:t}}reset(){this.#pr=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){ot("Not implemented")}}class sn extends re{#gr=null;#fr;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#mr=null;static#br=null;static#vr=null;static#wr=NaN;static#yr=null;static#Ar=null;static#_r=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#fr=t.mustBeCommitted||!1,t.drawOutlines&&(this.#xr(t),this.#tr())}#xr({drawOutlines:t,drawId:e,drawingOptions:i}){this.#gr=t,this._drawingOptions||=i,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#Sr(t,this.parent),this.#Cr(t.box)}#Sr(t,e){const{id:i}=e.drawLayer.draw(sn._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){ot("Not implemented")}static get typesMap(){ot("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&&(sn.#mr.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.#gr.updateProperty(e,t);i&&this.#Cr(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,sn._mergeSVGProperties(this.#gr.getPathResizingSVGProperties(this.#Er()),{bbox:this.#Pr()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,sn._mergeSVGProperties(this.#gr.getPathResizedSVGProperties(this.#Er()),{bbox:this.#Pr()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#Pr(t,e)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,sn._mergeSVGProperties(this.#gr.getPathTranslatedSVGProperties(this.#Er(),this.parentDimensions),{bbox:this.#Pr()}))}_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.#fr&&(this.#fr=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#rr(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#tr(),this.#Cr(this.#gr.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#rr()):t&&(this._uiManager.addShouldRescale(this),this.#tr(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#rr(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#tr(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#Sr(this.#gr,t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}#Mr([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]}}#Er(){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]}}#Cr(t){if([this.x,this.y,this.width,this.height]=this.#Mr(t),this.div){this.fixAndSetPosition();const[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()}#Pr(){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,sn._mergeSVGProperties({bbox:this.#Pr()},this.#gr.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#Cr(this.#gr.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const t=super.render();t.classList.add("draw");const e=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal";const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,e,i,s,n){ot("Not implemented")}static startDrawing(t,e,i,s){const{target:n,offsetX:a,offsetY:r,pointerId:o,pointerType:l}=s;if(sn.#yr&&sn.#yr!==l)return;const{viewport:{rotation:h}}=t,{width:d,height:c}=n.getBoundingClientRect(),u=sn.#br=new AbortController,p=t.combinedSignal(u);sn.#wr||=o,sn.#yr??=l,window.addEventListener("pointerup",(t=>{sn.#wr===t.pointerId?this._endDraw(t):sn.#Ar?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointercancel",(t=>{sn.#wr===t.pointerId?this._currentParent.endDrawingSession():sn.#Ar?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointerdown",(t=>{sn.#yr===t.pointerType&&((sn.#Ar||=new Set).add(t.pointerId),sn.#mr.isCancellable()&&(sn.#mr.removeLastElement(),sn.#mr.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",Ht,{signal:p}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),n.addEventListener("touchmove",(t=>{t.timeStamp===sn.#_r&&Vt(t)}),{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),sn.#mr?t.drawLayer.updateProperties(this._currentDrawId,sn.#mr.startNew(a,r,d,c,h)):(e.updateUIForDefaultProperties(this),sn.#mr=this.createDrawerInstance(a,r,d,c,h),sn.#vr=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(sn.#vr.toSVGProperties(),sn.#mr.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(sn.#_r=-1,!sn.#mr)return;const{offsetX:e,offsetY:i,pointerId:s}=t;sn.#wr===s&&(sn.#Ar?.size>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,sn.#mr.add(e,i)),sn.#_r=t.timeStamp,Vt(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,sn.#mr=null,sn.#vr=null,sn.#yr=null,sn.#_r=NaN),sn.#br&&(sn.#br.abort(),sn.#br=null,sn.#wr=NaN,sn.#Ar=null)}static _endDraw(t){const e=this._currentParent;if(e)if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,sn.#mr.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const t=sn.#mr,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:A.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(A.DRAW_STEP),!sn.#mr.isEmpty()){const{pageDimensions:[i,s],scale:n}=e,a=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:sn.#mr.getOutlines(i*n,s*n,n,this._INNER_MARGIN),drawingOptions:sn.#vr,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){ot("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.#xr({drawOutlines:o}),l.#tr(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){const[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return this.#gr.serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class nn{#Kn=new Float64Array(6);#bn;#Tr;#Ri;#ea;#ia;#kr="";#Ir=0;#Sa=new an;#Lr;#Dr;constructor(t,e,i,s,n,a){this.#Lr=i,this.#Dr=s,this.#Ri=n,this.#ea=a,[t,e]=this.#Rr(t,e);const r=this.#bn=[NaN,NaN,NaN,NaN,t,e];this.#ia=[t,e],this.#Tr=[{line:r,points:this.#ia}],this.#Kn.set(r,0)}updateProperty(t,e){"stroke-width"===t&&(this.#ea=e)}#Rr(t,e){return Gs._normalizePoint(t,e,this.#Lr,this.#Dr,this.#Ri)}isEmpty(){return!this.#Tr||0===this.#Tr.length}isCancellable(){return this.#ia.length<=10}add(t,e){[t,e]=this.#Rr(t,e);const[i,s,n,a]=this.#Kn.subarray(2,6),r=t-n,o=e-a;return Math.hypot(this.#Lr*r,this.#Dr*o)<=2?null:(this.#ia.push(t,e),isNaN(i)?(this.#Kn.set([n,a,t,e],2),this.#bn.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#Kn[0])&&this.#bn.splice(6,6),this.#Kn.set([i,s,n,a,t,e],0),this.#bn.push(...Gs.createBezierPoints(i,s,n,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const i=this.add(t,e);return i||(2===this.#ia.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,n){this.#Lr=i,this.#Dr=s,this.#Ri=n,[t,e]=this.#Rr(t,e);const a=this.#bn=[NaN,NaN,NaN,NaN,t,e];this.#ia=[t,e];const r=this.#Tr.at(-1);return r&&(r.line=new Float32Array(r.line),r.points=new Float32Array(r.points)),this.#Tr.push({line:a,points:this.#ia}),this.#Kn.set(a,0),this.#Ir=0,this.toSVGPath(),null}getLastElement(){return this.#Tr.at(-1)}setLastElement(t){return this.#Tr?(this.#Tr.push(t),this.#bn=t.line,this.#ia=t.points,this.#Ir=0,{path:{d:this.toSVGPath()}}):this.#Sa.setLastElement(t)}removeLastElement(){if(!this.#Tr)return this.#Sa.removeLastElement();this.#Tr.pop(),this.#kr="";for(let t=0,e=this.#Tr.length;t<e;t++){const{line:e,points:i}=this.#Tr[t];this.#bn=e,this.#ia=i,this.#Ir=0,this.toSVGPath()}return{path:{d:this.#kr}}}toSVGPath(){const t=Gs.svgRound(this.#bn[4]),e=Gs.svgRound(this.#bn[5]);if(2===this.#ia.length)return this.#kr=`${this.#kr} M ${t} ${e} Z`,this.#kr;if(this.#ia.length<=6){const i=this.#kr.lastIndexOf("M");this.#kr=`${this.#kr.slice(0,i)} M ${t} ${e}`,this.#Ir=6}if(4===this.#ia.length){const t=Gs.svgRound(this.#bn[10]),e=Gs.svgRound(this.#bn[11]);return this.#kr=`${this.#kr} L ${t} ${e}`,this.#Ir=12,this.#kr}const i=[];0===this.#Ir&&(i.push(`M ${t} ${e}`),this.#Ir=6);for(let t=this.#Ir,e=this.#bn.length;t<e;t+=6){const[e,s,n,a,r,o]=this.#bn.slice(t,t+6).map(Gs.svgRound);i.push(`C${e} ${s} ${n} ${a} ${r} ${o}`)}return this.#kr+=i.join(" "),this.#Ir=this.#bn.length,this.#kr}getOutlines(t,e,i,s){const n=this.#Tr.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#Sa.build(this.#Tr,t,e,i,this.#Ri,this.#ea,s),this.#Kn=null,this.#bn=null,this.#Tr=null,this.#kr=null,this.#Sa}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class an extends Gs{#pa;#Nr=0;#Gn;#Tr;#Lr;#Dr;#Fr;#Ri;#ea;build(t,e,i,s,n,a,r){this.#Lr=e,this.#Dr=i,this.#Fr=s,this.#Ri=n,this.#ea=a,this.#Gn=r??0,this.#Tr=t,this.#Or()}setLastElement(t){return this.#Tr.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#Tr.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#Tr)if(t.push(`M${Gs.svgRound(e[4])} ${Gs.svgRound(e[5])}`),6!==e.length)if(12!==e.length)for(let i=6,s=e.length;i<s;i+=6){const[s,n,a,r,o,l]=e.subarray(i,i+6).map(Gs.svgRound);t.push(`C${s} ${n} ${a} ${r} ${o} ${l}`)}else t.push(`L${Gs.svgRound(e[10])} ${Gs.svgRound(e[11])}`);else t.push("Z");return t.join("")}serialize([t,e,i,s],n){const a=[],r=[],[o,l,h,d]=this.#Br();let c,u,p,g,f,m,b,v,w;switch(this.#Ri){case 0:w=Gs._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=Gs._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=Gs._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=Gs._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.#Tr)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=Gs._rescale,d=-t/i,c=e/s+1,u=1/i,p=-1/s;break;case 90:g=Gs._rescaleAndSwap,d=-e/s,c=-t/i,u=1/s,p=1/i;break;case 180:g=Gs._rescale,d=t/i+1,c=-e/s,u=-1/i,p=1/s;break;case 270:g=Gs._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(Gs.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 an;return f.build(h,i,s,1,o,l,n),f}#jr(t=this.#ea){const e=this.#Gn+t/2*this.#Fr;return this.#Ri%180==0?[e/this.#Lr,e/this.#Dr]:[e/this.#Dr,e/this.#Lr]}#Br(){const[t,e,i,s]=this.#pa,[n,a]=this.#jr(0);return[t+n,e+a,i-2*n,s-2*a]}#Or(){const t=this.#pa=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:e}of this.#Tr){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6){const[s,n]=e.subarray(i,i+2);t[0]=Math.min(t[0],s),t[1]=Math.min(t[1],n),t[2]=Math.max(t[2],s),t[3]=Math.max(t[3],n)}continue}let i=e[4],s=e[5];for(let n=6,a=e.length;n<a;n+=6){const[a,r,o,l,h,d]=e.subarray(n,n+6);St.bezierBoundingBox(i,s,a,r,o,l,h,d,t),i=h,s=d}}const[e,i]=this.#jr();t[0]=Math.min(1,Math.max(0,t[0]-e)),t[1]=Math.min(1,Math.max(0,t[1]-i)),t[2]=Math.min(1,Math.max(0,t[2]+e)),t[3]=Math.min(1,Math.max(0,t[3]+i)),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#pa}updateProperty(t,e){return"stroke-width"===t?this.#sr(e):null}#sr(t){const[e,i]=this.#jr();this.#ea=t;const[s,n]=this.#jr(),[a,r]=[s-e,n-i],o=this.#pa;return o[0]-=a,o[1]-=r,o[2]+=2*a,o[3]+=2*r,o}updateParentDimensions([t,e],i){const[s,n]=this.#jr();this.#Lr=t,this.#Dr=e,this.#Fr=i;const[a,r]=this.#jr(),o=a-s,l=r-n,h=this.#pa;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#Nr=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#pa.map(Gs.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#pa;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Gs.svgRound(t)} ${Gs.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#pa;let i=0,s=0,n=0,a=0,r=0,o=0;switch(this.#Nr){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} ${Gs.svgRound(r)} ${Gs.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){const[n,a]=this.#jr(),[r,o,l,h]=this.#pa;if(Math.abs(l-n)<=Gs.PRECISION||Math.abs(h-a)<=Gs.PRECISION){const n=t+i/2-(r+l/2),a=e+s/2-(o+h/2);return{path:{"transform-origin":`${Gs.svgRound(t)} ${Gs.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":`${Gs.svgRound(r)} ${Gs.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${p}) translate(${Gs.svgRound(n)} ${Gs.svgRound(a)}) scale(${d} ${c}) translate(${Gs.svgRound(-n)} ${Gs.svgRound(-a)})`}}}getPathResizedSVGProperties([t,e,i,s]){const[n,a]=this.#jr(),r=this.#pa,[o,l,h,d]=r;if(r[0]=t,r[1]=e,r[2]=i,r[3]=s,Math.abs(h-n)<=Gs.PRECISION||Math.abs(d-a)<=Gs.PRECISION){const n=t+i/2-(o+h/2),a=e+s/2-(l+d/2);for(const{line:t,points:e}of this.#Tr)Gs._translate(t,n,a,t),Gs._translate(e,n,a,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Gs.svgRound(t)} ${Gs.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.#Tr)Gs._rescale(t,p,g,c,u,t),Gs._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Gs.svgRound(t)} ${Gs.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[s,n]=i,a=this.#pa,r=t-a[0],o=e-a[1];if(this.#Lr===s&&this.#Dr===n)for(const{line:t,points:e}of this.#Tr)Gs._translate(t,r,o,t),Gs._translate(e,r,o,e);else{const t=this.#Lr/s,e=this.#Dr/n;this.#Lr=s,this.#Dr=n;for(const{line:i,points:s}of this.#Tr)Gs._rescale(i,r,o,t,e,i),Gs._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":`${Gs.svgRound(t)} ${Gs.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#pa;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Gs.svgRound(t[0])} ${Gs.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class rn extends en{#Hr;constructor(t){super(),this.#Hr=t,super.updateProperties({fill:"none",stroke:re._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.#Hr.realScale),super.updateSVGProperty(t,e)}clone(){const t=new rn(this.#Hr);return t.updateAll(this),t}}class on extends sn{static _type="ink";static _editorType=y.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(t,e){re.initialize(t,e),this._defaultDrawingOptions=new rn(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return dt(this,"typesMap",new Map([[A.INK_THICKNESS,"stroke-width"],[A.INK_COLOR,"stroke"],[A.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,n){return new nn(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,a){return an.deserialize(t,e,i,s,n,a)}static async deserialize(t,e,i){let s=null;if(t instanceof Fs){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:y.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=on.getDefaultDrawingOptions({stroke:St.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:y.INK,color:re._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:this.annotationElementId&&!this.#Un(o)?null:(o.id=this.annotationElementId,o)}#Un(t){const{color:e,thickness:i,opacity:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some(((t,i)=>t!==e[i]))||t.thickness!==i||t.opacity!==s||t.pageIndex!==n}renderAnnotationElement(t){const{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e}),null}}class ln extends re{#Vr=null;#zr=null;#Ur=null;#$r=null;#Wr=null;#Gr="";#qr=null;#Xr=null;#Kr=!1;#Yr=!1;static _type="stamp";static _editorType=y.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#$r=t.bitmapUrl,this.#Wr=t.bitmapFile}static initialize(t,e){re.initialize(t,e)}static get supportedTypes(){return dt(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((t=>`image/${t}`)))}static get supportedTypesStr(){return dt(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(y.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}}#Qr(t,e=!1){t?(this.#Vr=t.bitmap,e||(this.#zr=t.id,this.#Kr=t.isSvg),t.file&&(this.#Gr=t.file.name),this.#Jr()):this.remove()}#Zr(){if(this.#Ur=null,this._uiManager.enableWaiting(!1),this.#qr){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Vr)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Vr){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}#to(){if(this.#zr)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#zr).then((t=>this.#Qr(t,!0))).finally((()=>this.#Zr()));if(this.#$r){const t=this.#$r;return this.#$r=null,this._uiManager.enableWaiting(!0),void(this.#Ur=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#Qr(t))).finally((()=>this.#Zr())))}if(this.#Wr){const t=this.#Wr;return this.#Wr=null,this._uiManager.enableWaiting(!0),void(this.#Ur=this._uiManager.imageManager.getFromFile(t).then((t=>this.#Qr(t))).finally((()=>this.#Zr())))}const t=document.createElement("input");t.type="file",t.accept=ln.supportedTypesStr;const e=this._uiManager._signal;this.#Ur=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.#Qr(e)}else this.remove();i()}),{signal:e}),t.addEventListener("cancel",(()=>{this.remove(),i()}),{signal:e})})).finally((()=>this.#Zr())),t.click()}remove(){this.#zr&&(this.#Vr=null,this._uiManager.imageManager.deleteId(this.#zr),this.#qr?.remove(),this.#qr=null,this.#Xr&&(clearTimeout(this.#Xr),this.#Xr=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#zr&&null===this.#qr&&this.#to(),this.isAttachedToDOM||this.parent.add(this))):this.#zr&&this.#to()}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#Ur||this.#Vr||this.#$r||this.#Wr||this.#zr)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#Vr?this.#Jr():this.#to(),this.width&&!this.annotationElementId){const[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==this.#Xr&&clearTimeout(this.#Xr);this.#Xr=setTimeout((()=>{this.#Xr=null,this.#eo()}),200)}#Jr(){const{div:t}=this;let{width:e,height:i}=this.#Vr;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.#qr=document.createElement("canvas");l.setAttribute("role","img"),this.addContainer(l),this.width=e/s,this.height=i/n,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#eo(),this.#Yr||(this.parent.addUndoableEditor(this),this.#Yr=!0),this._reportTelemetry({action:"inserted_image"}),this.#Gr&&l.setAttribute("aria-label",this.#Gr)}copyCanvas(t,e,i=!1){t||(t=224);const{width:s,height:n}=this.#Vr,a=new Xt;let r=this.#Vr,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.#Kr||(r=this.#io(t,i));const d=h.getContext("2d");d.filter=this._uiManager.hcmFilter;let c="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(c="#8f8f9d",u="#42414d");const p=15,g=p*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.#Vr,s>t||n>t){const a=Math.min(t/s,t/n);e=Math.floor(s*a),i=Math.floor(n*a),this.#Kr||(r=this.#io(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}}#io(t,e){const{width:i,height:s}=this.#Vr;let n=i,a=s,r=this.#Vr;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}#eo(){const[t,e]=this.parentDimensions,{width:i,height:s}=this,n=new Xt,a=Math.ceil(i*t*n.sx),r=Math.ceil(s*e*n.sy),o=this.#qr;if(!o||o.width===a&&o.height===r)return;o.width=a,o.height=r;const l=this.#Kr?this.#Vr:this.#io(a,r),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,a,r)}getImageForAltText(){return this.#qr}#so(t){if(t){if(this.#Kr){const t=this._uiManager.imageManager.getSvgUrl(this.#zr);if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=this.#Vr);return t.getContext("2d").drawImage(this.#Vr,0,0),t.toDataURL()}if(this.#Kr){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*kt.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*kt.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(this.#Vr,0,0,this.#Vr.width,this.#Vr.height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(this.#Vr)}static async deserialize(t,e,i){let s=null;if(t instanceof Vs){const{data:{rect:n,rotation:a,id:r,structParent:o,popupRef:l},container:h,parent:{page:{pageNumber:d}}}=t,c=h.querySelector("canvas"),u=i.imageManager.getFromCanvas(h.id,c);c.remove();const p=(await e._structTree.getAriaAttributes(`${Mt}${r}`))?.get("aria-label")||"";s=t={annotationType:y.STAMP,bitmapId:u.id,bitmap:u.bitmap,pageIndex:d-1,rect:n.slice(0),rotation:a,id:r,deleted:!1,accessibilityData:{decorative:!1,altText:p},isSvg:!1,structParent:o,popupRef:l}}const n=await super.deserialize(t,e,i),{rect:a,bitmap:r,bitmapUrl:o,bitmapId:l,isSvg:h,accessibilityData:d}=t;l&&i.imageManager.isValidId(l)?(n.#zr=l,r&&(n.#Vr=r)):n.#$r=o,n.#Kr=h;const[c,u]=n.pageDimensions;return n.width=(a[2]-a[0])/c,n.height=(a[3]-a[1])/u,n.annotationElementId=t.id||null,d&&(n.altTextData=d),n._initialData=s,n.#Yr=!!s,n}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:y.STAMP,bitmapId:this.#zr,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#Kr,structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=this.#so(!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(i.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const t=this.#Un(i);if(t.isSame)return null;t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,null===e)return i;e.stamps||=new Map;const a=this.#Kr?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#zr)){if(this.#Kr){const t=e.stamps.get(this.#zr);a>t.area&&(t.area=a,t.serialized.bitmap.close(),t.serialized.bitmap=this.#so(!1))}}else e.stamps.set(this.#zr,{area:a,serialized:i}),i.bitmap=this.#so(!1);return i}#Un(t){const{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&s&&n,isSameAltText:n}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}let hn=class t{#En;#no=!1;#ao=null;#ro=null;#oo=null;#lo=new Map;#ho=!1;#do=!1;#co=!1;#uo=null;#po=null;#go=null;#fo=null;#f;static _initialized=!1;static#V=new Map([Ws,on,ln,tn].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.#V.values()];if(!t._initialized){t._initialized=!0;for(const t of c)t.initialize(d,e)}e.registerEditorTypes(c),this.#f=e,this.pageIndex=i,this.div=s,this.#En=a,this.#ao=r,this.viewport=h,this.#go=l,this.drawLayer=o,this._structTree=n,this.#f.addLayer(this)}get isEmpty(){return 0===this.#lo.size}get isInvisible(){return this.isEmpty&&this.#f.getMode()===y.NONE}updateToolbar(t){this.#f.updateToolbar(t)}updateMode(e=this.#f.getMode()){switch(this.#mo(),e){case y.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case y.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case y.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.#V.values())i.toggle(`${s._type}Editing`,e===s._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#go?.div}setEditingState(t){this.#f.setEditingState(t)}addCommands(t){this.#f.addCommands(t)}cleanUndoStack(t){this.#f.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#ao?.div.classList.toggle("disabled",!t)}async enable(){this.#co=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const e of this.#lo.values())e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#f.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(!this.#ao)return void(this.#co=!1);const e=this.#ao.getEditableAnnotations();for(const i of e){if(i.hide(),this.#f.isDeletedAnnotationElement(i.data.id))continue;if(t.has(i.data.id))continue;const e=await this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}this.#co=!1}disable(){this.#do=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,i=new Map;for(const t of this.#lo.values())t.disableEditing(),t.annotationElementId&&(null===t.serialize()?(i.set(t.annotationElementId,t),this.getEditableAnnotation(t.annotationElementId)?.show(),t.remove()):e.set(t.annotationElementId,t));if(this.#ao){const t=this.#ao.getEditableAnnotations();for(const s of t){const{id:t}=s.data;if(this.#f.isDeletedAnnotationElement(t))continue;let n=i.get(t);n?(n.resetAnnotationElement(s),n.show(!1),s.show()):(n=e.get(t),n&&(this.#f.addChangedExistingAnnotation(n),n.renderAnnotationElement(s)&&n.show(!1)),s.show())}}this.#mo(),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const e of t.#V.values())s.remove(`${e._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#do=!1}getEditableAnnotation(t){return this.#ao?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#f.getActive()!==t&&this.#f.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#go?.div&&!this.#fo){this.#fo=new AbortController;const t=this.#f.combinedSignal(this.#fo);this.#go.div.addEventListener("pointerdown",this.#bo.bind(this),{signal:t}),this.#go.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#go?.div&&this.#fo&&(this.#fo.abort(),this.#fo=null,this.#go.div.classList.remove("highlighting"))}#bo(t){this.#f.unselectAll();const{target:e}=t;if(e===this.#go.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#go.div.contains(e)){const{isMac:e}=_t.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#f.showAllEditors("highlight",!0,!0),this.#go.div.classList.add("free"),this.toggleDrawing(),tn.startHighlighting(this,"ltr"===this.#f.direction,{target:this.#go.div,x:t.x,y:t.y}),this.#go.div.addEventListener("pointerup",(()=>{this.#go.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#f._signal}),t.preventDefault()}}enableClick(){if(this.#ro)return;this.#ro=new AbortController;const t=this.#f.combinedSignal(this.#ro);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.#ro?.abort(),this.#ro=null}attach(t){this.#lo.set(t.id,t);const{annotationElementId:e}=t;e&&this.#f.isDeletedAnnotationElement(e)&&this.#f.removeDeletedAnnotationElement(t)}detach(t){this.#lo.delete(t.id),this.#En?.removePointerInTextLayer(t.contentDiv),!this.#do&&t.annotationElementId&&this.#f.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#f.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#f.addDeletedAnnotationElement(t.annotationElementId),re.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),this.#f.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#co),this.#f.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#oo&&(t._focusEventsAllowed=!1,this.#oo=setTimeout((()=>{this.#oo=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this.#f._signal}),e.focus())}),0)),t._structTreeParentId=this.#En?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return this.#f.getId()}get#vo(){return t.#V.get(this.#f.getMode())}combinedSignal(t){return this.#f.combinedSignal(t)}#wo(t){const e=this.#vo;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#vo?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#f.updateToolbar(t),this.#f.updateMode(t);const{offsetX:i,offsetY:s}=this.#yo(),n=this.getNextId(),a=this.#wo({parent:this,id:n,x:i,y:s,uiManager:this.#f,isCentered:!0,...e});a&&this.add(a)}async deserialize(e){return await(t.#V.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#f))||null}createAndAddNewEditor(t,e,i={}){const s=this.getNextId(),n=this.#wo({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#f,isCentered:e,...i});return n&&this.add(n),n}#yo(){const{x:t,y:e,width:i,height:s}=this.div.getBoundingClientRect(),n=Math.max(0,t),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(){this.createAndAddNewEditor(this.#yo(),!0)}setSelected(t){this.#f.setSelected(t)}toggleSelected(t){this.#f.toggleSelected(t)}unselect(t){this.#f.unselect(t)}pointerup(t){const{isMac:e}=_t.platform;0!==t.button||t.ctrlKey&&e||t.target===this.div&&this.#ho&&(this.#ho=!1,this.#vo?.isDrawer&&this.#vo.supportMultipleDrawings||(this.#no?this.#f.getMode()!==y.STAMP?this.createAndAddNewEditor(t,!1):this.#f.unselectAll():this.#no=!0))}pointerdown(t){if(this.#f.getMode()===y.HIGHLIGHT&&this.enableTextSelection(),this.#ho)return void(this.#ho=!1);const{isMac:e}=_t.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#ho=!0,this.#vo?.isDrawer)return void this.startDrawingSession(t);const i=this.#f.getActive();this.#no=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus(),this.#uo)return void this.#vo.startDrawing(this,this.#f,!1,t);this.#f.setCurrentDrawingSession(this),this.#uo=new AbortController;const e=this.#f.combinedSignal(this.#uo);this.div.addEventListener("blur",(({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#po=null,this.commitOrRemove())}),{signal:e}),this.#vo.startDrawing(this,this.#f,!1,t)}pause(t){if(t){const{activeElement:t}=document;this.div.contains(t)&&(this.#po=t)}else this.#po&&setTimeout((()=>{this.#po?.focus(),this.#po=null}),0)}endDrawingSession(t=!1){return this.#uo?(this.#f.setCurrentDrawingSession(null),this.#uo.abort(),this.#uo=null,this.#po=null,this.#vo.endDrawing(t)):null}findNewParent(t,e,i){const s=this.#f.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#uo&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#uo&&this.#vo.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#f.getActive()?.parent===this&&(this.#f.commitOrRemove(),this.#f.setActiveEditor(null)),this.#oo&&(clearTimeout(this.#oo),this.#oo=null);for(const t of this.#lo.values())this.#En?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#lo.clear(),this.#f.removeLayer(this)}#mo(){for(const t of this.#lo.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,qt(this.div,t);for(const t of this.#f.getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:t}){this.#f.commitOrRemove(),this.#mo();const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,qt(this.div,{rotation:i}),e!==i)for(const t of this.#lo.values())t.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#f.viewParameters.realScale}},dn=class t{#nn=null;#w=0;#Ao=new Map;#_o=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#nn){if(this.#nn!==t){if(this.#Ao.size>0)for(const e of this.#Ao.values())e.remove(),t.append(e);this.#nn=t}}else this.#nn=t}static get _svgFactory(){return dt(this,"_svgFactory",new cs)}static#xo(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+"%"}#So(){const e=t._svgFactory.create(1,1,!0);return this.#nn.append(e),e.setAttribute("aria-hidden",!0),e}#Co(e,i){const s=t._svgFactory.createElement("clipPath");e.append(s);const n=`clip_${i}`;s.setAttribute("id",n),s.setAttribute("clipPathUnits","objectBoundingBox");const a=t._svgFactory.createElement("use");return s.append(a),a.setAttribute("href",`#${i}`),a.classList.add("clip"),n}#Eo(t,e){for(const[i,s]of Object.entries(e))null===s?t.removeAttribute(i):t.setAttribute(i,s)}draw(e,i=!1,s=!1){const n=this.#w++,a=this.#So(),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.#_o.set(n,o);const h=s?this.#Co(r,l):null,d=t._svgFactory.createElement("use");return a.append(d),d.setAttribute("href",`#${l}`),this.updateProperties(a,e),this.#Ao.set(n,a),{id:n,clipPathId:`url(#${h})`}}drawOutline(e,i){const s=this.#w++,n=this.#So(),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.#Ao.set(s,n),s}finalizeDraw(t,e){this.#_o.delete(t),this.updateProperties(t,e)}updateProperties(e,i){if(!i)return;const{root:s,bbox:n,rootClass:a,path:r}=i,o="number"==typeof e?this.#Ao.get(e):e;if(o){if(s&&this.#Eo(o,s),n&&t.#xo(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.#Eo(t,r)}}}updateParent(t,e){if(e===this)return;const i=this.#Ao.get(t);i&&(e.#nn.append(i),this.#Ao.delete(t),e.#Ao.set(t,i))}remove(t){this.#_o.delete(t),null!==this.#nn&&(this.#Ao.get(t).remove(),this.#Ao.delete(t))}destroy(){this.#nn=null;for(const t of this.#Ao.values())t.remove();this.#Ao.clear(),this.#_o.clear()}};globalThis.pdfjsTestingUtils={HighlightOutliner:Ks};var cn=r.AnnotationEditorParamsType,un=r.AnnotationEditorType,pn=r.AnnotationMode,gn=r.GlobalWorkerOptions,fn=r.PDFDateString,mn=r.PixelsPerInch,bn=r.RenderingCancelledException,vn=r.getDocument,wn=r.getPdfFilenameFromUrl,yn=r.getXfaPageViewport,An={d:(t,e)=>{for(var i in e)An.o(e,i)&&!An.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},_n=globalThis.pdfjsViewer={};An.d(_n,{AnnotationLayerBuilder:()=>dr,DownloadManager:()=>ur,EventBus:()=>fr,FindState:()=>ea,GenericL10n:()=>Io,LinkTarget:()=>ma,PDFFindController:()=>fa,PDFHistory:()=>Do,PDFLinkService:()=>ba,PDFPageView:()=>el,PDFScriptingManager:()=>nl,PDFSinglePageViewer:()=>ul,PDFViewer:()=>cl,ProgressBar:()=>Un,RenderingStates:()=>xn,ScrollMode:()=>In,SimpleLinkService:()=>va,SpreadMode:()=>Ln,StructTreeLayerBuilder:()=>Xo,TextLayerBuilder:()=>Qo,XfaLayerBuilder:()=>Jo,parseQueryString:()=>Rn});const xn={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},Sn=0,Cn=1,En=2,Pn=3,Mn=0,Tn=1,kn=2,In={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},Ln={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};function Dn(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 Rn(t){const e=new Map;for(const[i,s]of new URLSearchParams(t))e.set(i.toLowerCase(),s);return e}const Nn=/[\x00-\x1F]/g;function Fn(t,e=!1){return Nn.test(t)?e?t.replaceAll(Nn,(t=>"\0"===t?"":" ")):t.replaceAll("\0",""):t}function On(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 Bn(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 jn(t,e){return t-t%e}function Hn(t){return Number.isInteger(t)&&t%90==0}function Vn(t){return t.width<=t.height}new Promise((function(t){window.requestAnimationFrame(t)}));const zn=document.documentElement.style;let Un=class{#Po=null;#Mo=null;#To=0;#ko=null;#wi=!0;constructor(t){this.#Po=t.classList,this.#ko=t.style}get percent(){return this.#To}set percent(t){var e,i,s;this.#To=(e=t,i=0,s=100,Math.min(Math.max(e,i),s)),isNaN(t)?this.#Po.add("indeterminate"):(this.#Po.remove("indeterminate"),this.#ko.setProperty("--progressBar-percent",`${this.#To}%`))}setWidth(t){if(!t)return;const e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&this.#ko.setProperty("--progressBar-end-offset",`${e}px`)}setDisableAutoFetch(t=5e3){100===this.#To||isNaN(this.#To)||(this.#Mo&&clearTimeout(this.#Mo),this.show(),this.#Mo=setTimeout((()=>{this.#Mo=null,this.hide()}),t))}hide(){this.#wi&&(this.#wi=!1,this.#Po.add("hidden"))}show(){this.#wi||(this.#wi=!0,this.#Po.remove("hidden"))}};const $n=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}(),Wn=0,Gn=1,qn=2,Xn=3,Kn=4,Yn=5,Qn=6,Jn=7;function Zn(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)?Wn:function(t){return t>=97&&t<=122||t>=65&&t<=90}(t)||function(t){return t>=48&&t<=57}(t)||95===t?Gn:qn:function(t){return 3584==(65408&t)}(t)?Jn:160===t?Wn:Gn:function(t){return t>=13312&&t<=40959||t>=63744&&t<=64255}(t)?Xn:function(t){return t>=12448&&t<=12543}(t)?Kn:function(t){return t>=12352&&t<=12447}(t)?Yn:function(t){return t>=65376&&t<=65439}(t)?Qn:Gn}let ta;const ea={FOUND:0,NOT_FOUND:1,WRAPPED:2,PENDING:3},ia={"‐":"-","‘":"'","’":"'","‚":"'","‛":"'","“":'"',"”":'"',"„":'"',"‟":'"',"¼":"1/4","½":"1/2","¾":"3/4"},sa=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 na;const aa=/\p{M}+/gu,ra=/([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu,oa=/([^\p{M}])\p{M}*$/u,la=/^\p{M}*([^\p{M}])/u,ha=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,da=new Map,ca=new Map;let ua=null,pa=null;function ga(t){const e=[];let i,s;for(;null!==(i=ha.exec(t));){let{index:t}=i;for(const s of i[0]){let i=da.get(s);i||(i=s.normalize("NFD").length,da.set(s,i)),e.push([i,t++])}}if(0===e.length&&ua)s=ua;else if(e.length>0&&pa)s=pa;else{const t=`([${Object.keys(ia).join("")}])|([${ta||=" ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩",ta}])|(${"(?:゙|゚)"}\\n)|(\\p{M}+(?:-\\n)?)|(${"\\p{Ll}-\\n\\p{Lu}"})|(\\S-\\n)|(${"(?:\\p{Ideographic}|[-ヿ])"}\\n)|(\\n)`;s=0===e.length?ua=new RegExp(t+"|(\\u0000)","gum"):pa=new RegExp(t+"|([\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f])","gum")}const n=[];for(;null!==(i=aa.exec(t));)n.push([i[0].length,i.index]);let a=t.normalize("NFD");const r=[0,0];let o=0,l=0,h=0,d=0,c=0,u=!1;a=a.replace(s,((t,i,s,a,p,g,f,m,b,v,w)=>{if(w-=d,i){const t=ia[i],e=t.length;for(let t=1;t<e;t++)r.push(w-h+t,h-t);return h-=e-1,t}if(s){let t=ca.get(s);t||(t=s.normalize("NFKC"),ca.set(s,t));const e=t.length;for(let t=1;t<e;t++)r.push(w-h+t,h-t);return h-=e-1,t}if(a)return u=!0,w+c===n[o]?.[1]?++o:(r.push(w-1-h+1,h-1),h-=1,d+=1),r.push(w-h+1,h),d+=1,c+=1,a.charAt(0);if(p){const t=p.endsWith("\n"),e=t?p.length-2:p.length;u=!0;let i=e;w+c===n[o]?.[1]&&(i-=n[o][0],++o);for(let t=1;t<=i;t++)r.push(w-1-h+t,h-t);return h-=i,d+=i,t?(w+=e-1,r.push(w-h+1,1+h),h+=1,d+=1,c+=1,p.slice(0,e)):p}if(g)return d+=1,c+=1,g.replace("\n","");if(f){const t=f.length-2;return r.push(w-h+t,1+h),h+=1,d+=1,c+=1,f.slice(0,-2)}if(m){const t=m.length-1;return r.push(w-h+t,h),d+=1,c+=1,m.slice(0,-1)}if(b)return r.push(w-h+1,h-1),h-=1,d+=1,c+=1," ";if(w+c===e[l]?.[1]){const t=e[l][0]-1;++l;for(let e=1;e<=t;e++)r.push(w-(h-e),h-e);h-=t,d+=t}return v})),r.push(a.length,h);const p=new Uint32Array(r.length>>1),g=new Int32Array(r.length>>1);for(let t=0,e=r.length;t<e;t+=2)p[t>>1]=r[t],g[t>>1]=r[t+1];return[a,[p,g],u]}class fa{#Io=null;#Lo=!0;#Do=0;constructor({linkService:t,eventBus:e,updateMatchesCountOnProgress:i=!0}){this._linkService=t,this._eventBus=e,this.#Lo=i,this.onIsPageVisible=null,this.#Ro(),e._on("find",this.#No.bind(this)),e._on("findbarclose",this.#Fo.bind(this))}get highlightMatches(){return this._highlightMatches}get pageMatches(){return this._pageMatches}get pageMatchesLength(){return this._pageMatchesLength}get selected(){return this._selected}get state(){return this.#Io}setDocument(t){this._pdfDocument&&this.#Ro(),t&&(this._pdfDocument=t,this._firstPageCapability.resolve())}#No(t){if(!t)return;const e=this._pdfDocument,{type:i}=t;(null===this.#Io||this.#Oo(t))&&(this._dirtyMatch=!0),this.#Io=t,"highlightallchange"!==i&&this.#Bo(ea.PENDING),this._firstPageCapability.promise.then((()=>{if(!this._pdfDocument||e&&this._pdfDocument!==e)return;this.#Bn();const t=!this._highlightMatches,s=!!this._findTimeout;this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),i?this._dirtyMatch?this.#jo():"again"===i?(this.#jo(),t&&this.#Io.highlightAll&&this.#Ho()):"highlightallchange"===i?(s?this.#jo():this._highlightMatches=!0,this.#Ho()):this.#jo():this._findTimeout=setTimeout((()=>{this.#jo(),this._findTimeout=null}),250)}))}scrollMatchIntoView({element:t=null,selectedLeft:e=0,pageIndex:i=-1,matchIndex:s=-1}){if(!this._scrollMatches||!t)return;if(-1===s||s!==this._selected.matchIdx)return;if(-1===i||i!==this._selected.pageIdx)return;this._scrollMatches=!1;Dn(t,{top:-50,left:e+-400},!0)}#Ro(){this._highlightMatches=!1,this._scrollMatches=!1,this._pdfDocument=null,this._pageMatches=[],this._pageMatchesLength=[],this.#Do=0,this.#Io=null,this._selected={pageIdx:-1,matchIdx:-1},this._offset={pageIdx:null,matchIdx:null,wrapped:!1},this._extractTextPromises=[],this._pageContents=[],this._pageDiffs=[],this._hasDiacritics=[],this._matchesCountTotal=0,this._pagesToSearch=null,this._pendingFindMatches=new Set,this._resumePageIdx=null,this._dirtyMatch=!1,clearTimeout(this._findTimeout),this._findTimeout=null,this._firstPageCapability=Promise.withResolvers()}get#Vo(){const{query:t}=this.#Io;return"string"==typeof t?(t!==this._rawQuery&&(this._rawQuery=t,[this._normalizedQuery]=ga(t)),this._normalizedQuery):(t||[]).filter((t=>!!t)).map((t=>ga(t)[0]))}#Oo(t){const e=t.query,i=this.#Io.query,s=typeof e;if(s!==typeof i)return!0;if("string"===s){if(e!==i)return!0}else if(JSON.stringify(e)!==JSON.stringify(i))return!0;switch(t.type){case"again":const t=this._selected.pageIdx+1,e=this._linkService;return t>=1&&t<=e.pagesCount&&t!==e.page&&!(this.onIsPageVisible?.(t)??1);case"highlightallchange":return!1}return!0}#zo(t,e,i){let s=t.slice(0,e).match(oa);if(s){const i=t.charCodeAt(e),n=s[1].charCodeAt(0);if(Zn(i)===Zn(n))return!1}if(s=t.slice(e+i).match(la),s){const n=t.charCodeAt(e+i-1),a=s[1].charCodeAt(0);if(Zn(n)===Zn(a))return!1}return!0}#Uo(t,e){const{matchDiacritics:i}=this.#Io;let s=!1;const n="[ ]*";return(t=t.replaceAll(ra,((t,n,a,r,o,l)=>n?`[ ]*\\${n}[ ]*`:a?`[ ]*${a}[ ]*`:r?"[ ]+":i?o||l:o?sa.has(o.charCodeAt(0))?o:"":e?(s=!0,`${l}\\p{M}*`):l))).endsWith(n)&&(t=t.slice(0,t.length-4)),i&&e&&(na||=String.fromCharCode(...sa),s=!0,t=`${t}(?=[${na}]|[^\\p{M}]|$)`),[s,t]}#$o(t){const e=this.#Vo;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]=function(t,e,i){if(!t)return[e,i];const[s,n]=t,a=e,r=e+i-1;let o=On(s,(t=>t>=a));s[o]>a&&--o;let l=On(s,(t=>t>=r),o);s[l]>r&&--l;const h=a+n[o];return[h,r+n[l]+1-h]}(r,t,e);s&&(n.push(i),a.push(s))})),this.#Io.highlightAll&&this.#Wo(t),this._resumePageIdx===t&&(this._resumePageIdx=null,this.#Go());const o=n.length;this._matchesCountTotal+=o,this.#Lo?o>0&&this.#qo():++this.#Do===this._linkService.pagesCount&&this.#qo()}match(t,e,i){const s=this._hasDiacritics[i];let n=!1;if("string"==typeof t?[n,t]=this.#Uo(t,s):t=t.sort().reverse().map((t=>{const[e,i]=this.#Uo(t,s);return n||=e,`(${i})`})).join("|"),!t)return;const{caseSensitive:a,entireWord:r}=this.#Io;t=new RegExp(t,`g${n?"u":""}${a?"":"i"}`);const o=[];let l;for(;null!==(l=t.exec(e));)r&&!this.#zo(e,l.index,l[0].length)||o.push({index:l.index,length:l[0].length});return o}#Bn(){if(this._extractTextPromises.length>0)return;let t=Promise.resolve();const e={disableNormalization:!0};for(let i=0,s=this._linkService.pagesCount;i<s;i++){const{promise:s,resolve:n}=Promise.withResolvers();this._extractTextPromises[i]=s,t=t.then((()=>this._pdfDocument.getPage(i+1).then((t=>t.getTextContent(e))).then((t=>{const e=[];for(const i of t.items)e.push(i.str),i.hasEOL&&e.push("\n");[this._pageContents[i],this._pageDiffs[i],this._hasDiacritics[i]]=ga(e.join("")),n()}),(t=>{console.error(`Unable to get text content for page ${i+1}`,t),this._pageContents[i]="",this._pageDiffs[i]=null,this._hasDiacritics[i]=!1,n()}))))}}#Wo(t){this._scrollMatches&&this._selected.pageIdx===t&&(this._linkService.page=t+1),this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:t})}#Ho(){this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:-1})}#jo(){const t=this.#Io.findPrevious,e=this._linkService.page-1,i=this._linkService.pagesCount;if(this._highlightMatches=!0,this._dirtyMatch){this._dirtyMatch=!1,this._selected.pageIdx=this._selected.matchIdx=-1,this._offset.pageIdx=e,this._offset.matchIdx=null,this._offset.wrapped=!1,this._resumePageIdx=null,this._pageMatches.length=0,this._pageMatchesLength.length=0,this.#Do=0,this._matchesCountTotal=0,this.#Ho();for(let t=0;t<i;t++)this._pendingFindMatches.has(t)||(this._pendingFindMatches.add(t),this._extractTextPromises[t].then((()=>{this._pendingFindMatches.delete(t),this.#$o(t)})))}if(0===this.#Vo.length)return void this.#Bo(ea.FOUND);if(this._resumePageIdx)return;const s=this._offset;if(this._pagesToSearch=i,null!==s.matchIdx){const e=this._pageMatches[s.pageIdx].length;if(!t&&s.matchIdx+1<e||t&&s.matchIdx>0)return s.matchIdx=t?s.matchIdx-1:s.matchIdx+1,void this.#Xo(!0);this.#Ko(t)}this.#Go()}#Yo(t){const e=this._offset,i=t.length,s=this.#Io.findPrevious;return i?(e.matchIdx=s?i-1:0,this.#Xo(!0),!0):(this.#Ko(s),!!(e.wrapped&&(e.matchIdx=null,this._pagesToSearch<0))&&(this.#Xo(!1),!0))}#Go(){null!==this._resumePageIdx&&console.error("There can only be one pending page.");let t=null;do{const e=this._offset.pageIdx;if(t=this._pageMatches[e],!t){this._resumePageIdx=e;break}}while(!this.#Yo(t))}#Ko(t){const e=this._offset,i=this._linkService.pagesCount;e.pageIdx=t?e.pageIdx-1:e.pageIdx+1,e.matchIdx=null,this._pagesToSearch--,(e.pageIdx>=i||e.pageIdx<0)&&(e.pageIdx=t?i-1:0,e.wrapped=!0)}#Xo(t=!1){let e=ea.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?ea.WRAPPED:ea.FOUND,-1!==t&&t!==this._selected.pageIdx&&this.#Wo(t)}this.#Bo(e,this.#Io.findPrevious),-1!==this._selected.pageIdx&&(this._scrollMatches=!0,this.#Wo(this._selected.pageIdx))}#Fo(t){const e=this._pdfDocument;this._firstPageCapability.promise.then((()=>{!this._pdfDocument||e&&this._pdfDocument!==e||(this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),this._resumePageIdx&&(this._resumePageIdx=null,this._dirtyMatch=!0),this.#Bo(ea.FOUND),this._highlightMatches=!1,this.#Ho())}))}#Qo(){const{pageIdx:t,matchIdx:e}=this._selected;let i=0,s=this._matchesCountTotal;if(-1!==e){for(let e=0;e<t;e++)i+=this._pageMatches[e]?.length||0;i+=e+1}return(i<1||i>s)&&(i=s=0),{current:i,total:s}}#qo(){this._eventBus.dispatch("updatefindmatchescount",{source:this,matchesCount:this.#Qo()})}#Bo(t,e=!1){(this.#Lo||this.#Do===this._linkService.pagesCount&&t!==ea.PENDING)&&this._eventBus.dispatch("updatefindcontrolstate",{source:this,state:t,previous:e,entireWord:this.#Io?.entireWord??null,matchesCount:this.#Qo(),rawQuery:this.#Io?.query??null})}}const ma={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};class ba{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?ma.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 ma.NONE:break;case ma.SELF:a="_self";break;case ma.BLANK:a="_blank";break;case ma.PARENT:a="_parent";break;case ma.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=Rn(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||ba.#Jo(i)?this.goToDestination(i):console.error(`PDFLinkService.setHash: "${unescape(t)}" is not a valid destination.`)}executeNamedAction(t){if(this.pdfDocument){switch(t){case"GoBack":this.pdfHistory?.back();break;case"GoForward":this.pdfHistory?.forward();break;case"NextPage":this.pdfViewer.nextPage();break;case"PrevPage":this.pdfViewer.previousPage();break;case"LastPage":this.page=this.pagesCount;break;case"FirstPage":this.page=1}this.eventBus.dispatch("namedaction",{source:this,action:t})}}async executeSetOCGState(t){if(!this.pdfDocument)return;const e=this.pdfDocument,i=await this.pdfViewer.optionalContentConfigPromise;e===this.pdfDocument&&(i.setOCGState(t),this.pdfViewer.optionalContentConfigPromise=Promise.resolve(i))}static#Jo(t){if(!Array.isArray(t)||t.length<2)return!1;const[e,i,...s]=t;if(!("object"==typeof e&&Number.isInteger(e?.num)&&Number.isInteger(e?.gen)||Number.isInteger(e)))return!1;if("object"!=typeof i||"string"!=typeof i?.name)return!1;const n=s.length;let a=!0;switch(i.name){case"XYZ":if(n<2||n>3)return!1;break;case"Fit":case"FitB":return 0===n;case"FitH":case"FitBH":case"FitV":case"FitBV":if(n>1)return!1;break;case"FitR":if(4!==n)return!1;a=!1;break;default:return!1}for(const t of s)if(!("number"==typeof t||a&&null===t))return!1;return!0}}class va extends ba{setDocument(t,e=null){}}const{AbortException:wa,AnnotationEditorLayer:ya,AnnotationEditorParamsType:Aa,AnnotationEditorType:_a,AnnotationEditorUIManager:xa,AnnotationLayer:Sa,AnnotationMode:Ca,build:Ea,ColorPicker:Pa,createValidAbsoluteUrl:Ma,DOMSVGFactory:Ta,DrawLayer:ka,FeatureTest:Ia,fetchData:La,getDocument:Da,getFilenameFromUrl:Ra,getPdfFilenameFromUrl:Na,getXfaPageViewport:Fa,GlobalWorkerOptions:Oa,ImageKind:Ba,InvalidPDFException:ja,isDataScheme:Ha,isPdfFile:Va,MissingPDFException:za,noContextMenu:Ua,normalizeUnicode:$a,OPS:Wa,OutputScale:Ga,PasswordResponses:qa,PDFDataRangeTransport:Xa,PDFDateString:Ka,PDFWorker:Ya,PermissionFlag:Qa,PixelsPerInch:Ja,RenderingCancelledException:Za,setLayerDimensions:tr,shadow:er,stopEvent:ir,TextLayer:sr,TouchManager:nr,UnexpectedResponseException:ar,Util:rr,VerbosityLevel:or,version:lr,XfaLayer:hr}=globalThis.pdfjsLib;class dr{#Zo=null;#tl=null;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.#Zo=u,this.annotationLayer=null,this.div=null,this._cancelled=!1,this._eventBus=e.eventBus}async render(t,e,i="display"){if(this.div){if(this._cancelled||!this.annotationLayer)return;return void this.annotationLayer.update({viewport:t.clone({dontFlip:!0})})}const[s,n,a]=await Promise.all([this.pdfPage.getAnnotations({intent:i}),this._hasJSActionsPromise,this._fieldObjectsPromise]);if(this._cancelled)return;const r=this.div=document.createElement("div");r.className="annotationLayer",this.#Zo?.(r),0!==s.length?(this.annotationLayer=new Sa({div:r,accessibilityManager:this._accessibilityManager,annotationCanvasMap:this._annotationCanvasMap,annotationEditorUIManager:this._annotationEditorUIManager,page:this.pdfPage,viewport:t.clone({dontFlip:!0}),structTreeLayer:e?.structTreeLayer||null}),await this.annotationLayer.render({annotations:s,imageResourcesPath:this.imageResourcesPath,renderForms:this.renderForms,linkService:this.linkService,downloadManager:this.downloadManager,annotationStorage:this.annotationStorage,enableScripting:this.enableScripting,hasJSActions:n,fieldObjects:a}),this.linkService.isInPresentationMode&&this.#el(Pn),this.#tl||(this.#tl=new AbortController,this._eventBus?._on("presentationmodechanged",(t=>{this.#el(t.state)}),{signal:this.#tl.signal}))):this.hide()}cancel(){this._cancelled=!0,this.#tl?.abort(),this.#tl=null}hide(){this.div&&(this.div.hidden=!0)}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}#el(t){if(!this.div)return;let e=!1;switch(t){case Pn:e=!0;break;case Cn:break;default:return}for(const t of this.div.childNodes)t.hasAttribute("data-internal-link")||(t.inert=e)}}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{#il=new WeakMap;downloadData(t,e,i){cr(URL.createObjectURL(new Blob([t],{type:i})),e)}openOrDownloadData(t,e,i=null){const s=Va(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(!Ma(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{#As=Object.create(null);on(t,e,i=null){this._on(t,e,{external:!0,once:i?.once,signal:i?.signal})}off(t,e,i=null){this._off(t,e)}dispatch(t,e){const i=this.#As[t];if(!i||0===i.length)return;let s;for(const{listener:n,external: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.#As[t]||=[]).push({listener:e,external:!0===i?.external,once:!0===i?.once,rmAbort:s})}_off(t,e,i=null){const s=this.#As[t];if(s)for(let t=0,i=s.length;t<i;t++){const i=s[t];if(i.listener===e)return i.rmAbort?.(),void s.splice(t,1)}}}class 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){try{return t.memoizeIntlObject(Intl.NumberFormat,this.opts).format(this.value)}catch(e){return t.reportError(e),this.value.toString(10)}}}class wr extends mr{constructor(t,e={}){super(t),this.opts=e}toString(t){try{return t.memoizeIntlObject(Intl.DateTimeFormat,this.opts).format(this.value)}catch(e){return t.reportError(e),new Date(this.value).toISOString()}}}function 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(i instanceof Date)return new wr(i.getTime());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 Mr=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function Tr(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,Mr)});if(i instanceof wr)return new vr(i.valueOf(),{...Pr(e,Mr)});throw new TypeError("Invalid argument to NUMBER")}const kr=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function Ir(t,e){let i=t[0];if(i instanceof br)return new br(`DATETIME(${i.valueOf()})`);if(i instanceof wr)return new wr(i.valueOf(),{...i.opts,...Pr(e,kr)});if(i instanceof vr)return new wr(i.valueOf(),{...Pr(e,kr)});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:Tr,DATETIME:Ir,...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,Hr=/^[A-Z][A-Z0-9_-]*$/,Vr=/([^{}\n\r]+)/y,zr=/([^\\"\n\r]*)/y,Ur=/\\([\\"])/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,Jr=/\s*] */y,Zr=/\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(Vr)&&(s=r(Vr)),"{"===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(Vr)){s.push(r(Vr));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(Zr)){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(Hr.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(Jr,SyntaxError),t}function g(){if(i(Or))return f();if('"'===t[e])return function(){s('"',SyntaxError);let i="";for(;;){if(i+=r(zr),"\\"!==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(Ur))return r(Ur);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-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 Mo 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 To{#sl;#sn;#Mi;#nl;constructor({lang:t,isRTL:e},i=null){this.#Mi=To.#al(t),this.#nl=i,this.#sl=e??To.#rl(this.#Mi)?"rtl":"ltr"}_setL10n(t){this.#nl=t}getLanguage(){return this.#Mi}getDirection(){return this.#sl}async get(t,e=null,i){if(Array.isArray(t)){t=t.map((t=>({id:t})));return(await this.#nl.formatMessages(t)).map((t=>t.value))}const s=await this.#nl.formatMessages([{id:t,args:e}]);return s[0]?.value||i}async translate(t){(this.#sn||=new Set).add(t);try{this.#nl.connectRoot(t),await this.#nl.translateRoots()}catch{}}async translateOnce(t){try{await this.#nl.translateElements([t])}catch(t){console.error("translateOnce:",t)}}async destroy(){if(this.#sn){for(const t of this.#sn)this.#nl.disconnectRoot(t);this.#sn.clear(),this.#sn=null}this.#nl.pauseObserving()}pause(){this.#nl.pauseObserving()}resume(){this.#nl.resumeObserving()}static#al(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#rl(t){const e=t.split("-",1)[0];return["ar","he","fa","ps","ur"].includes(e)}}function ko(t,e){const i=new no(e),s=new Dr(t),n=s.addResource(i);return n.length&&console.error("L10n errors",n),s}class Io extends To{constructor(t){super({lang:t});const e=t?Io.#ol.bind(Io,"en-us",this.getLanguage()):Io.#ll.bind(Io,this.getLanguage());this._setL10n(new Mo([],e))}static async*#ol(t,e){const{baseURL:i,paths:s}=await this.#hl(),n=[e];if(t!==e){const i=e.split("-",1)[0];i!==e&&n.push(i),n.push(t)}for(const t of n){const e=await this.#dl(t,i,s);e?yield e:"en-us"===t&&(yield this.#cl(t))}}static async#dl(t,e,i){const s=i[t];if(!s)return null;const n=new URL(s,e);return ko(t,await La(n,"text"))}static async#hl(){try{const{href:t}=document.querySelector('link[type="application/l10n"]'),e=await La(t,"json");return{baseURL:t.replace(/[^/]*$/,"")||"./",paths:e}}catch{}return{baseURL:"./",paths:Object.create(null)}}static async*#ll(t){yield this.#cl(t)}static async#cl(t){return 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-remove-ink-button =\n .title = Remove drawing\npdfjs-editor-remove-freetext-button =\n .title = Remove text\npdfjs-editor-remove-stamp-button =\n .title = Remove image\npdfjs-editor-remove-highlight-button =\n .title = Remove highlight\npdfjs-editor-free-text-color-input = Color\npdfjs-editor-free-text-size-input = Size\npdfjs-editor-ink-color-input = Color\npdfjs-editor-ink-thickness-input = Thickness\npdfjs-editor-ink-opacity-input = Opacity\npdfjs-editor-stamp-add-image-button =\n .title = Add image\npdfjs-editor-stamp-add-image-button-label = Add image\npdfjs-editor-free-highlight-thickness-input = Thickness\npdfjs-editor-free-highlight-thickness-title =\n .title = Change thickness when highlighting items other than text\npdfjs-free-text2 =\n .aria-label = Text Editor\n .default-content = Start typing…\npdfjs-ink =\n .aria-label = Draw Editor\npdfjs-ink-canvas =\n .aria-label = User-created image\npdfjs-editor-alt-text-button =\n .aria-label = Alt text\npdfjs-editor-alt-text-button-label = Alt text\npdfjs-editor-alt-text-edit-button =\n .aria-label = Edit alt text\npdfjs-editor-alt-text-dialog-label = Choose an option\npdfjs-editor-alt-text-dialog-description = Alt text (alternative text) helps when people can’t see the image or when it doesn’t load.\npdfjs-editor-alt-text-add-description-label = Add a description\npdfjs-editor-alt-text-add-description-description = Aim for 1-2 sentences that describe the subject, setting, or actions.\npdfjs-editor-alt-text-mark-decorative-label = Mark as decorative\npdfjs-editor-alt-text-mark-decorative-description = This is used for ornamental images, like borders or watermarks.\npdfjs-editor-alt-text-cancel-button = Cancel\npdfjs-editor-alt-text-save-button = Save\npdfjs-editor-alt-text-decorative-tooltip = Marked as decorative\npdfjs-editor-alt-text-textarea =\n .placeholder = For example, “A young man sits down at a table to eat a meal”\npdfjs-editor-resizer-top-left =\n .aria-label = Top left corner — resize\npdfjs-editor-resizer-top-middle =\n .aria-label = Top middle — resize\npdfjs-editor-resizer-top-right =\n .aria-label = Top right corner — resize\npdfjs-editor-resizer-middle-right =\n .aria-label = Middle right — resize\npdfjs-editor-resizer-bottom-right =\n .aria-label = Bottom right corner — resize\npdfjs-editor-resizer-bottom-middle =\n .aria-label = Bottom middle — resize\npdfjs-editor-resizer-bottom-left =\n .aria-label = Bottom left corner — resize\npdfjs-editor-resizer-middle-left =\n .aria-label = Middle left — resize\npdfjs-editor-highlight-colorpicker-label = Highlight color\npdfjs-editor-colorpicker-button =\n .title = Change color\npdfjs-editor-colorpicker-dropdown =\n .aria-label = Color choices\npdfjs-editor-colorpicker-yellow =\n .title = Yellow\npdfjs-editor-colorpicker-green =\n .title = Green\npdfjs-editor-colorpicker-blue =\n .title = Blue\npdfjs-editor-colorpicker-pink =\n .title = Pink\npdfjs-editor-colorpicker-red =\n .title = Red\npdfjs-editor-highlight-show-all-button-label = Show all\npdfjs-editor-highlight-show-all-button =\n .title = Show all\npdfjs-editor-new-alt-text-dialog-edit-label = Edit alt text (image description)\npdfjs-editor-new-alt-text-dialog-add-label = Add alt text (image description)\npdfjs-editor-new-alt-text-textarea =\n .placeholder = Write your description here…\npdfjs-editor-new-alt-text-description = Short description for people who can’t see the image or when the image doesn’t load.\npdfjs-editor-new-alt-text-disclaimer1 = This alt text was created automatically and may be inaccurate.\npdfjs-editor-new-alt-text-disclaimer-learn-more-url = Learn more\npdfjs-editor-new-alt-text-create-automatically-button-label = Create alt text automatically\npdfjs-editor-new-alt-text-not-now-button = Not now\npdfjs-editor-new-alt-text-error-title = Couldn’t create alt text automatically\npdfjs-editor-new-alt-text-error-description = Please write your own alt text or try again later.\npdfjs-editor-new-alt-text-error-close-button = Close\npdfjs-editor-new-alt-text-ai-model-downloading-progress = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\n .aria-valuetext = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\npdfjs-editor-new-alt-text-added-button =\n .aria-label = Alt text added\npdfjs-editor-new-alt-text-added-button-label = Alt text added\npdfjs-editor-new-alt-text-missing-button =\n .aria-label = Missing alt text\npdfjs-editor-new-alt-text-missing-button-label = Missing alt text\npdfjs-editor-new-alt-text-to-review-button =\n .aria-label = Review alt text\npdfjs-editor-new-alt-text-to-review-button-label = Review alt text\npdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer = Created automatically: { $generatedAltText }\npdfjs-image-alt-text-settings-button =\n .title = Image alt text settings\npdfjs-image-alt-text-settings-button-label = Image alt text settings\npdfjs-editor-alt-text-settings-dialog-label = Image alt text settings\npdfjs-editor-alt-text-settings-automatic-title = Automatic alt text\npdfjs-editor-alt-text-settings-create-model-button-label = Create alt text automatically\npdfjs-editor-alt-text-settings-create-model-description = Suggests descriptions to help people who can’t see the image or when the image doesn’t load.\npdfjs-editor-alt-text-settings-download-model-label = Alt text AI model ({ $totalSize } MB)\npdfjs-editor-alt-text-settings-ai-model-description = Runs locally on your device so your data stays private. Required for automatic alt text.\npdfjs-editor-alt-text-settings-delete-model-button = Delete\npdfjs-editor-alt-text-settings-download-model-button = Download\npdfjs-editor-alt-text-settings-downloading-model-button = Downloading…\npdfjs-editor-alt-text-settings-editor-title = Alt text editor\npdfjs-editor-alt-text-settings-show-dialog-button-label = Show alt text editor right away when adding an image\npdfjs-editor-alt-text-settings-show-dialog-description = Helps you make sure all your images have alt text.\npdfjs-editor-alt-text-settings-close-button = Close\npdfjs-editor-undo-bar-message-highlight = Highlight removed\npdfjs-editor-undo-bar-message-freetext = Text removed\npdfjs-editor-undo-bar-message-ink = Drawing removed\npdfjs-editor-undo-bar-message-stamp = Image removed\npdfjs-editor-undo-bar-message-multiple =\n { $count ->\n [one] { $count } annotation removed\n *[other] { $count } annotations removed\n }\npdfjs-editor-undo-bar-undo-button =\n .title = Undo\npdfjs-editor-undo-bar-undo-button-label = Undo\npdfjs-editor-undo-bar-close-button =\n .title = Close\npdfjs-editor-undo-bar-close-button-label = Close')}}function Lo(){return document.location.hash}class Do{#tl=null;constructor({linkService:t,eventBus:e}){this.linkService=t,this.eventBus=e,this._initialized=!1,this._fingerprint="",this.reset(),this.eventBus._on("pagesinit",(()=>{this._isPagesLoaded=!1,this.eventBus._on("pagesloaded",(t=>{this._isPagesLoaded=!!t.pagesCount}),{once:!0})}))}initialize({fingerprint:t,resetHistory:e=!1,updateUrl:i=!1}){if(!t||"string"!=typeof t)return void console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');this._initialized&&this.reset();const s=""!==this._fingerprint&&this._fingerprint!==t;this._fingerprint=t,this._updateUrl=!0===i,this._initialized=!0,this.#ul();const n=window.history.state;if(this._popStateInProgress=!1,this._blockHashChange=0,this._currentHash=Lo(),this._numPositionUpdates=0,this._uid=this._maxUid=0,this._destination=null,this._position=null,!this.#pl(n,!0)||e){const{hash:t,page:i,rotation:n}=this.#gl(!0);return!t||s||e?void this.#fl(null,!0):void this.#fl({hash:t,page:i,rotation:n},!0)}const a=n.destination;this.#ml(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.#bl(),this._initialized=!1,this.#vl()),this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._initialBookmark=null,this._initialRotation=null}push({namedDest:t=null,explicitDest:e,pageNumber:i}){if(!this._initialized)return;if(t&&"string"!=typeof t)return void console.error(`PDFHistory.push: "${t}" is not a valid namedDest parameter.`);if(!Array.isArray(e))return void console.error(`PDFHistory.push: "${e}" is not a valid explicitDest parameter.`);if(!this.#wl(i)&&(null!==i||this._destination))return void console.error(`PDFHistory.push: "${i}" is not a valid pageNumber parameter.`);const s=t||JSON.stringify(e);if(!s)return;let n=!1;if(this._destination&&(function(t,e){if("string"!=typeof t||"string"!=typeof e)return!1;if(t===e)return!0;if(Rn(t).get("nameddest")===e)return!0;return!1}(this._destination.hash,s)||function(t,e){function i(t,e){if(typeof t!=typeof e)return!1;if(Array.isArray(t)||Array.isArray(e))return!1;if(null!==t&&"object"==typeof t&&null!==e){if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const s in t)if(!i(t[s],e[s]))return!1;return!0}return t===e||Number.isNaN(t)&&Number.isNaN(e)}if(!Array.isArray(t)||!Array.isArray(e))return!1;if(t.length!==e.length)return!1;for(let s=0,n=t.length;s<n;s++)if(!i(t[s],e[s]))return!1;return!0}(this._destination.dest,e))){if(this._destination.page)return;n=!0}this._popStateInProgress&&!n||(this.#fl({dest:e,hash:s,page:i,rotation:this.linkService.rotation},n),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then((()=>{this._popStateInProgress=!1}))))}pushPage(t){this._initialized&&(this.#wl(t)?this._destination?.page!==t&&(this._popStateInProgress||(this.#fl({dest:null,hash:`page=${t}`,page:t,rotation:this.linkService.rotation}),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then((()=>{this._popStateInProgress=!1}))))):console.error(`PDFHistory.pushPage: "${t}" is not a valid page number.`))}pushCurrentPosition(){this._initialized&&!this._popStateInProgress&&this.#yl()}back(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#pl(t)&&t.uid>0&&window.history.back()}forward(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#pl(t)&&t.uid<this._maxUid&&window.history.forward()}get popStateInProgress(){return this._initialized&&(this._popStateInProgress||this._blockHashChange>0)}get initialBookmark(){return this._initialized?this._initialBookmark:null}get initialRotation(){return this._initialized?this._initialRotation:null}#fl(t,e=!1){const i=e||!this._destination,s={fingerprint:this._fingerprint,uid:i?this._uid:this._uid+1,destination:t};let n;if(this.#ml(t,s.uid),this._updateUrl&&t?.hash){const e=document.location.href.split("#",1)[0];e.startsWith("file://")||(n=`${e}#${t.hash}`)}i?window.history.replaceState(s,"",n):window.history.pushState(s,"",n)}#yl(t=!1){if(!this._position)return;let e=this._position;if(t&&(e=Object.assign(Object.create(null),this._position),e.temporary=!0),!this._destination)return void this.#fl(e);if(this._destination.temporary)return void this.#fl(e,!0);if(this._destination.hash===e.hash)return;if(!this._destination.page&&this._numPositionUpdates<=50)return;let i=!1;if(this._destination.page>=e.first&&this._destination.page<=e.page){if(void 0!==this._destination.dest||!this._destination.first)return;i=!0}this.#fl(e,i)}#wl(t){return Number.isInteger(t)&&t>0&&t<=this.linkService.pagesCount}#pl(t,e=!1){if(!t)return!1;if(t.fingerprint!==this._fingerprint){if(!e)return!1;{if("string"!=typeof t.fingerprint||t.fingerprint.length!==this._fingerprint.length)return!1;const[e]=performance.getEntriesByType("navigation");if("reload"!==e?.type)return!1}}return!(!Number.isInteger(t.uid)||t.uid<0)&&(null!==t.destination&&"object"==typeof t.destination)}#ml(t,e,i=!1){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),i&&t?.temporary&&delete t.temporary,this._destination=t,this._uid=e,this._maxUid=Math.max(this._maxUid,e),this._numPositionUpdates=0}#gl(t=!1){const e=unescape(Lo()).substring(1),i=Rn(e),s=i.get("nameddest")||"";let n=0|i.get("page");return(!this.#wl(n)||t&&s.length>0)&&(n=null),{hash:e,page:n,rotation:this.linkService.rotation}}#Al({location:t}){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._position={hash:t.pdfOpenParams.substring(1),page:this.linkService.page,first:t.pageNumber,rotation:t.rotation},this._popStateInProgress||(this._isPagesLoaded&&this._destination&&!this._destination.page&&this._numPositionUpdates++,this._updateViewareaTimeout=setTimeout((()=>{this._popStateInProgress||this.#yl(!0),this._updateViewareaTimeout=null}),1e3))}#_l({state:t}){const e=Lo(),i=this._currentHash!==e;if(this._currentHash=e,!t){this._uid++;const{hash:t,page:e,rotation:i}=this.#gl();return void this.#fl({hash:t,page:e,rotation:i},!0)}if(!this.#pl(t))return;this._popStateInProgress=!0,i&&(this._blockHashChange++,async function({target:t,name:e,delay:i=0}){if("object"!=typeof t||!(Number.isInteger(i)&&i>=0))throw new Error("waitOnEventOrTimeout - invalid parameters.");const{promise:s,resolve:n}=Promise.withResolvers(),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.#ml(s,t.uid,!0),Hn(s.rotation)&&(this.linkService.rotation=s.rotation),s.dest?this.linkService.goToDestination(s.dest):s.hash?this.linkService.setHash(s.hash):s.page&&(this.linkService.page=s.page),Promise.resolve().then((()=>{this._popStateInProgress=!1}))}#bl(){this._destination&&!this._destination.temporary||this.#yl()}#ul(){if(this.#tl)return;this.#tl=new AbortController;const{signal:t}=this.#tl;this.eventBus._on("updateviewarea",this.#Al.bind(this),{signal:t}),window.addEventListener("popstate",this.#_l.bind(this),{signal:t}),window.addEventListener("pagehide",this.#bl.bind(this),{signal:t})}#vl(){this.#tl?.abort(),this.#tl=null}}class Ro{#ao=null;#xl=null;#Zo=null;#Tn=null;#go=null;#f;constructor(t){this.pdfPage=t.pdfPage,this.accessibilityManager=t.accessibilityManager,this.l10n=t.l10n,this.l10n||=new Io,this.annotationEditorLayer=null,this.div=null,this._cancelled=!1,this.#f=t.uiManager,this.#ao=t.annotationLayer||null,this.#go=t.textLayer||null,this.#xl=t.drawLayer||null,this.#Zo=t.onAppend||null,this.#Tn=t.structTreeLayer||null}async render(t,e="display"){if("display"!==e)return;if(this._cancelled)return;const i=t.clone({dontFlip:!0});if(this.div)return this.annotationEditorLayer.update({viewport:i}),void this.show();const s=this.div=document.createElement("div");s.className="annotationEditorLayer",s.hidden=!0,s.dir=this.#f.direction,this.#Zo?.(s),this.annotationEditorLayer=new ya({uiManager:this.#f,div:s,structTreeLayer:this.#Tn,accessibilityManager:this.accessibilityManager,pageIndex:this.pdfPage.pageNumber-1,l10n:this.l10n,viewport:i,annotationLayer:this.#ao,textLayer:this.#go,drawLayer:this.#xl});const n={viewport:i,div:s,annotations:null,intent:e};this.annotationEditorLayer.render(n),this.show()}cancel(){this._cancelled=!0,this.div&&this.annotationEditorLayer.destroy()}hide(){this.div&&(this.annotationEditorLayer.pause(!0),this.div.hidden=!0)}show(){this.div&&!this.annotationEditorLayer.isInvisible&&(this.div.hidden=!1,this.annotationEditorLayer.pause(!1))}}{var 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,Ho=16,Vo=128,zo={BOOLEAN:1,NUMBER:2,OBJECT:4,STRING:8,UNDEFINED:16},Uo={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},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},toolbarDensity:{value:0,kind:Fo+Ho},altTextLearnMoreUrl:{value:"",kind:Oo+Vo},annotationEditorMode:{value:0,kind:Oo+Vo},annotationMode:{value:2,kind:Oo+Vo},cursorToolOnLoad:{value:0,kind:Oo+Vo},debuggerSrc:{value:"./debugger.mjs",kind:Oo},defaultZoomDelay:{value:400,kind:Oo+Vo},defaultZoomValue:{value:"",kind:Oo+Vo},disableHistory:{value:!1,kind:Oo},disablePageLabels:{value:!1,kind:Oo+Vo},enableAltText:{value:!1,kind:Oo+Vo},enableAltTextModelDownload:{value:!0,kind:Oo+Vo+Ho},enableGuessAltText:{value:!0,kind:Oo+Vo+Ho},enableHighlightFloatingButton:{value:!1,kind:Oo+Vo},enableNewAltTextWhenAddingImage:{value:!0,kind:Oo+Vo},enablePermissions:{value:!1,kind:Oo+Vo},enablePrintAutoRotate:{value:!0,kind:Oo+Vo},enableScripting:{value:!0,kind:Oo+Vo},enableUpdatedAddImage:{value:!1,kind:Oo+Vo},externalLinkRel:{value:"noopener noreferrer nofollow",kind:Oo},externalLinkTarget:{value:0,kind:Oo+Vo},highlightEditorColors:{value:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",kind:Oo+Vo},historyUpdateUrl:{value:!1,kind:Oo+Vo},ignoreDestinationZoom:{value:!1,kind:Oo+Vo},imageResourcesPath:{value:"./images/",kind:Oo},maxCanvasPixels:{value:2**25,kind:Oo},forcePageColors:{value:!1,kind:Oo+Vo},pageColorsBackground:{value:"Canvas",kind:Oo+Vo},pageColorsForeground:{value:"CanvasText",kind:Oo+Vo},pdfBugEnabled:{value:!1,kind:Oo+Vo},printResolution:{value:150,kind:Oo},sidebarViewOnLoad:{value:-1,kind:Oo+Vo},scrollModeOnLoad:{value:-1,kind:Oo+Vo},spreadModeOnLoad:{value:-1,kind:Oo+Vo},textLayerMode:{value:1,kind:Oo+Vo},viewOnLoad:{value:0,kind:Oo+Vo},cMapPacked:{value:!0,kind:Bo},cMapUrl:{value:"../web/cmaps/",kind:Bo},disableAutoFetch:{value:!1,kind:Bo+Vo},disableFontFace:{value:!1,kind:Bo+Vo},disableRange:{value:!1,kind:Bo+Vo},disableStream:{value:!1,kind:Bo+Vo},docBaseUrl:{value:"",kind:Bo},enableHWA:{value:!0,kind:Bo+Oo+Vo},enableXfa:{value:!0,kind:Bo+Vo},fontExtraProperties:{value:!1,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:zo.BOOLEAN+zo.UNDEFINED},verbosity:{value:1,kind:Bo},workerPort:{value:null,kind:jo},workerSrc:{value:"../build/pdf.worker.mjs",kind:jo}};Uo.defaultUrl={value:"compressed.tracemonkey-pldi-09.pdf",kind:Oo},Uo.sandboxBundleSrc={value:"../build/pdf.sandbox.mjs",kind:Oo},Uo.viewerCssTheme={value:0,kind:Oo+Vo},Uo.enableFakeMLManager={value:!0,kind:Oo},Uo.disablePreferences={value:!1,kind:Oo};class $o{static eventBus;static#Sl=new Map;static{for(const t in Uo)this.#Sl.set(t,Uo[t].value);for(const[t,e]of No)this.#Sl.set(t,e);this._hasInvokedSet=!1,this._checkDisablePreferences=()=>!!this.get("disablePreferences")||(this._hasInvokedSet&&console.warn('The Preferences may override manually set AppOptions; please use the "disablePreferences"-option to prevent that.'),!1)}static get(t){return this.#Sl.get(t)}static getAll(t=null,e=!1){const i=Object.create(null);for(const s in Uo){const n=Uo[s];(!t||t&n.kind)&&(i[s]=e?n.value:this.#Sl.get(s))}return i}static set(t,e){this.setAll({[t]:e})}static setAll(t,e=!1){let i;this._hasInvokedSet||=!0;for(const s in t){const n=Uo[s],a=t[s];if(!n||!(typeof a==typeof n.value||zo[(typeof a).toUpperCase()]&n.type))continue;const{kind:r}=n;(!e||r&Fo||r&Vo)&&(this.eventBus&&r&Ho&&(i||=new Map).set(s,a),this.#Sl.set(s,a))}if(i)for(const[t,e]of i)this.eventBus.dispatch(t.toLowerCase(),{source:this,value:e})}}class Wo{#xl=null;constructor(t){this.pageIndex=t.pageIndex}async render(t="display"){"display"!==t||this.#xl||this._cancelled||(this.#xl=new ka({pageIndex:this.pageIndex}))}cancel(){this._cancelled=!0,this.#xl&&(this.#xl.destroy(),this.#xl=null)}setParent(t){this.#xl?.setParent(t)}getDrawLayer(){return this.#xl}}const Go={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},qo=/^H(\d+)$/;class Xo{#Cl;#El=null;#Pl;#Ml=new Map;#Tl;#kl=null;constructor(t,e){this.#Cl=t.getStructTree(),this.#Tl=e}async render(){if(this.#Pl)return this.#Pl;const{promise:t,resolve:e,reject:i}=Promise.withResolvers();this.#Pl=t;try{this.#El=this.#Il(await this.#Cl)}catch(t){i(t)}return this.#Cl=null,this.#El?.classList.add("structTree"),e(this.#El),t}async getAriaAttributes(t){try{return await this.render(),this.#Ml.get(t)}catch{}return null}hide(){this.#El&&!this.#El.hidden&&(this.#El.hidden=!0)}show(){this.#El?.hidden&&(this.#El.hidden=!1)}#Ll(t,e){const{alt:i,id:s,lang:n}=t;if(void 0!==i){let s=!1;const n=Fn(i);for(const e of t.children)if("annotation"===e.type){let t=this.#Ml.get(e.id);t||(t=new Map,this.#Ml.set(e.id,t)),t.set("aria-label",n),s=!0}s||e.setAttribute("aria-label",n)}void 0!==s&&e.setAttribute("aria-owns",s),void 0!==n&&e.setAttribute("lang",Fn(n,!0))}#Dl(t,e){const{alt:i,bbox:s,children:n}=t,a=n?.[0];if(!this.#Tl||!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.#kl||=new Map).set(r,o),o.setAttribute("role","img"),o.setAttribute("aria-label",Fn(i));const{pageHeight:l,pageX:h,pageY:d}=this.#Tl,c="calc(var(--scale-factor)*",{style:u}=o;return u.width=`${c}${s[2]-s[0]}px)`,u.height=`${c}${s[3]-s[1]}px)`,u.left=`${c}${s[0]-h}px)`,u.top=`${c}${l-s[3]+d}px)`,!0}addElementsToTextLayer(){if(this.#kl){for(const[t,e]of this.#kl)document.getElementById(t)?.append(e);this.#kl.clear(),this.#kl=null}}#Il(t){if(!t)return null;const e=document.createElement("span");if("role"in t){const{role:i}=t,s=i.match(qo);if(s?(e.setAttribute("role","heading"),e.setAttribute("aria-level",s[1])):Go[i]&&e.setAttribute("role",Go[i]),"Figure"===i&&this.#Dl(t,e))return e}if(this.#Ll(t,e),t.children)if(1===t.children.length&&"id"in t.children[0])this.#Ll(t.children[0],e);else for(const i of t.children)e.append(this.#Il(i));return e}}class Ko{#Rl=!1;#Nl=null;#Fl=new Map;#Ol=new Map;setTextMapping(t){this.#Nl=t}static#Bl(t,e){const i=t.getBoundingClientRect(),s=e.getBoundingClientRect();if(0===i.width&&0===i.height)return 1;if(0===s.width&&0===s.height)return-1;const n=i.y,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.#Rl)throw new Error("TextAccessibilityManager is already enabled.");if(!this.#Nl)throw new Error("Text divs and strings have not been set.");if(this.#Rl=!0,this.#Nl=this.#Nl.slice(),this.#Nl.sort(Ko.#Bl),this.#Fl.size>0){const t=this.#Nl;for(const[e,i]of this.#Fl){document.getElementById(e)?this.#jl(e,t[i]):this.#Fl.delete(e)}}for(const[t,e]of this.#Ol)this.addPointerInTextLayer(t,e);this.#Ol.clear()}disable(){this.#Rl&&(this.#Ol.clear(),this.#Nl=null,this.#Rl=!1)}removePointerInTextLayer(t){if(!this.#Rl)return void this.#Ol.delete(t);const e=this.#Nl;if(!e||0===e.length)return;const{id:i}=t,s=this.#Fl.get(i);if(void 0===s)return;const n=e[s];this.#Fl.delete(i);let 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")))}#jl(t,e){const i=e.getAttribute("aria-owns");i?.includes(t)||e.setAttribute("aria-owns",i?`${i} ${t}`:t),e.removeAttribute("role")}addPointerInTextLayer(t,e){const{id:i}=t;if(!i)return null;if(!this.#Rl)return this.#Ol.set(t,e),null;e&&this.removePointerInTextLayer(t);const s=this.#Nl;if(!s||0===s.length)return null;const n=On(s,(e=>Ko.#Bl(t,e)<0)),a=Math.max(0,n-1),r=s[a];this.#jl(i,r),this.#Fl.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=On(a,(t=>Ko.#Bl(r,t)<0));return 0===o?a[0].before(e):a[o-1].after(e),n}}class Yo{#tl=null;constructor({findController:t,eventBus:e,pageIndex:i}){this.findController=t,this.matches=[],this.eventBus=e,this.pageIdx=i,this.textDivs=null,this.textContentItemsStr=null,this.enabled=!1}setTextMapping(t,e){this.textDivs=t,this.textContentItemsStr=e}enable(){if(!this.textDivs||!this.textContentItemsStr)throw new Error("Text divs and strings have not been set.");if(this.enabled)throw new Error("TextHighlighter is already enabled.");this.enabled=!0,this.#tl||(this.#tl=new AbortController,this.eventBus._on("updatetextlayermatches",(t=>{t.pageIndex!==this.pageIdx&&-1!==t.pageIndex||this._updateMatches()}),{signal:this.#tl.signal})),this._updateMatches()}disable(){this.enabled&&(this.enabled=!1,this.#tl?.abort(),this.#tl=null,this._updateMatches(!0))}_convertMatches(t,e){if(!t)return[];const{textContentItemsStr:i}=this;let s=0,n=0;const 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 Qo{#Hl=!1;#Zo=null;#Vl=!1;#go=null;static#zl=new Map;static#Ul=null;constructor({pdfPage:t,highlighter:e=null,accessibilityManager:i=null,enablePermissions:s=!1,onAppend:n=null}){this.pdfPage=t,this.highlighter=e,this.accessibilityManager=i,this.#Hl=!0===s,this.#Zo=n,this.div=document.createElement("div"),this.div.tabIndex=0,this.div.className="textLayer"}async render(t,e=null){if(this.#Vl&&this.#go)return this.#go.update({viewport:t,onBefore:this.hide.bind(this)}),void this.show();this.cancel(),this.#go=new sr({textContentSource:this.pdfPage.streamTextContent(e||{includeMarkedContent:!0,disableNormalization:!0}),container:this.div,viewport:t});const{textDivs:i,textContentItemsStr:s}=this.#go;this.highlighter?.setTextMapping(i,s),this.accessibilityManager?.setTextMapping(i),await this.#go.render(),this.#Vl=!0;const n=document.createElement("div");n.className="endOfContent",this.div.append(n),this.#$l(n),this.#Zo?.(this.div),this.highlighter?.enable(),this.accessibilityManager?.enable()}hide(){!this.div.hidden&&this.#Vl&&(this.highlighter?.disable(),this.div.hidden=!0)}show(){this.div.hidden&&this.#Vl&&(this.div.hidden=!1,this.highlighter?.enable())}cancel(){this.#go?.cancel(),this.#go=null,this.highlighter?.disable(),this.accessibilityManager?.disable(),Qo.#Wl(this.div)}#$l(t){const{div:e}=this;e.addEventListener("mousedown",(()=>{e.classList.add("selecting")})),e.addEventListener("copy",(t=>{if(!this.#Hl){const e=document.getSelection();t.clipboardData.setData("text/plain",Fn($a(e.toString())))}ir(t)})),Qo.#zl.set(e,t),Qo.#Gl()}static#Wl(t){this.#zl.delete(t),0===this.#zl.size&&(this.#Ul?.abort(),this.#Ul=null)}static#Gl(){if(this.#Ul)return;this.#Ul=new AbortController;const{signal:t}=this.#Ul,e=(t,e)=>{e.append(t),t.style.width="",t.style.height="",e.classList.remove("selecting")};let i=!1;var s,n;document.addEventListener("pointerdown",(()=>{i=!0}),{signal:t}),document.addEventListener("pointerup",(()=>{i=!1,this.#zl.forEach(e)}),{signal:t}),window.addEventListener("blur",(()=>{i=!1,this.#zl.forEach(e)}),{signal:t}),document.addEventListener("keyup",(()=>{i||this.#zl.forEach(e)}),{signal:t}),document.addEventListener("selectionchange",(()=>{const t=document.getSelection();if(0===t.rangeCount)return void this.#zl.forEach(e);const i=new Set;for(let e=0;e<t.rangeCount;e++){const s=t.getRangeAt(e);for(const t of this.#zl.keys())!i.has(t)&&s.intersectsNode(t)&&i.add(t)}for(const[t,s]of this.#zl)i.has(t)?t.classList.add("selecting"):e(s,t);if(s??="none"===getComputedStyle(this.#zl.values().next().value).getPropertyValue("-moz-user-select"),s)return;const 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;o.nodeType===Node.TEXT_NODE&&(o=o.parentNode);const l=o.parentElement?.closest(".textLayer"),h=this.#zl.get(l);h&&(h.style.width=l.style.width,h.style.height=l.style.height,o.parentElement.insertBefore(h,r?o:o.nextSibling)),n=a.cloneRange()}),{signal:t})}}class Jo{constructor({pdfPage:t,annotationStorage:e=null,linkService:i,xfaHtml:s=null}){this.pdfPage=t,this.annotationStorage=e,this.linkService=i,this.xfaHtml=s,this.div=null,this._cancelled=!1}async render(t,e="display"){if("print"===e){const i={viewport:t.clone({dontFlip:!0}),div:this.div,xfaHtml:this.xfaHtml,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:e};return this.div=document.createElement("div"),i.div=this.div,hr.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?hr.update(s):(this.div=document.createElement("div"),s.div=this.div,hr.render(s))}cancel(){this._cancelled=!0}hide(){this.div&&(this.div.hidden=!0)}}const Zo={annotationEditorUIManager:null,annotationStorage:null,downloadManager:null,enableScripting:!1,fieldObjectsPromise:null,findController:null,hasJSActionsPromise:null,get linkService(){return new va}},tl=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);class el{#ql=Ca.ENABLE_FORMS;#Xl=null;#li=!1;#Kl=!1;#_e=!1;#Yl=null;#Ql=null;#Jl=null;#Zl=null;#th=1;#eh=1;#ih=null;#sh=xn.INITIAL;#nh=Tn;#ah={directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0};#rh=[null,null,null,null];constructor(t){const e=t.container,i=t.defaultViewport;this.id=t.id,this.renderingId="page"+this.id,this.#Yl=t.layerProperties||Zo,this.pdfPage=null,this.pageLabel=null,this.rotation=0,this.scale=t.scale||1,this.viewport=i,this.pdfPageRotate=i.rotation,this._optionalContentConfigPromise=t.optionalContentConfigPromise||null,this.#nh=t.textLayerMode??Tn,this.#ql=t.annotationMode??Ca.ENABLE_FORMS,this.imageResourcesPath=t.imageResourcesPath||"",this.maxCanvasPixels=t.maxCanvasPixels??$o.get("maxCanvasPixels"),this.pageColors=t.pageColors||null,this.#li=t.enableHWA||!1,this.eventBus=t.eventBus,this.renderingQueue=t.renderingQueue,this.l10n=t.l10n,this.l10n||=new Io,this.renderTask=null,this.resume=null,this._isStandalone=!this.renderingQueue?.hasViewer(),this._container=e,this._annotationCanvasMap=null,this.annotationLayer=null,this.annotationEditorLayer=null,this.textLayer=null,this.xfaLayer=null,this.structTreeLayer=null,this.drawLayer=null;const s=document.createElement("div");if(s.className="page",s.setAttribute("data-page-number",this.id),s.setAttribute("role","region"),s.setAttribute("data-l10n-id","pdfjs-page-landmark"),s.setAttribute("data-l10n-args",JSON.stringify({page:this.id})),this.div=s,this.#oh(),e?.append(s),this._isStandalone){e?.style.setProperty("--scale-factor",this.scale*Ja.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)}}#lh(t,e){const i=tl.get(e),s=this.#rh[i];if(this.#rh[i]=t,s)s.replaceWith(t);else{for(let e=i-1;e>=0;e--){const i=this.#rh[e];if(i)return void i.after(t)}this.div.prepend(t)}}get renderingState(){return this.#sh}set renderingState(t){if(t!==this.#sh)switch(this.#sh=t,this.#Ql&&(clearTimeout(this.#Ql),this.#Ql=null),t){case xn.PAUSED:this.div.classList.remove("loading");break;case xn.RUNNING:this.div.classList.add("loadingIcon"),this.#Ql=setTimeout((()=>{this.div.classList.add("loading"),this.#Ql=null}),0);break;case xn.INITIAL:case xn.FINISHED:this.div.classList.remove("loadingIcon","loading")}}#oh(){const{viewport:t}=this;if(this.pdfPage){if(this.#Zl===t.rotation)return;this.#Zl=t.rotation}tr(this.div,t,!0,!1)}setPdfPage(t){!this._isStandalone||"CanvasText"!==this.pageColors?.foreground&&"Canvas"!==this.pageColors?.background||(this._container?.style.setProperty("--hcm-highlight-filter",t.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight")),this._container?.style.setProperty("--hcm-highlight-selected-filter",t.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","Highlight"))),this.pdfPage=t,this.pdfPageRotate=t.rotate;const e=(this.rotation+this.pdfPageRotate)%360;this.viewport=t.getViewport({scale:this.scale*Ja.PDF_TO_CSS_UNITS,rotation:e}),this.#oh(),this.reset()}destroy(){this.reset(),this.pdfPage?.cleanup()}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}get _textHighlighter(){return er(this,"_textHighlighter",new Yo({pageIndex:this.id-1,eventBus:this.eventBus,findController:this.#Yl.findController}))}#hh(t,e){this.eventBus.dispatch(t,{source:this,pageNumber:this.id,error:e})}async#dh(){let t=null;try{await this.annotationLayer.render(this.viewport,{structTreeLayer:this.structTreeLayer},"display")}catch(e){console.error("#renderAnnotationLayer:",e),t=e}finally{this.#hh("annotationlayerrendered",t)}}async#ch(){let t=null;try{await this.annotationEditorLayer.render(this.viewport,"display")}catch(e){console.error("#renderAnnotationEditorLayer:",e),t=e}finally{this.#hh("annotationeditorlayerrendered",t)}}async#uh(){try{await this.drawLayer.render("display")}catch(t){console.error("#renderDrawLayer:",t)}}async#ph(){let t=null;try{const t=await this.xfaLayer.render(this.viewport,"display");t?.textDivs&&this._textHighlighter&&this.#gh(t.textDivs)}catch(e){console.error("#renderXfaLayer:",e),t=e}finally{this.xfaLayer?.div&&(this.l10n.pause(),this.#lh(this.xfaLayer.div,"xfaLayer"),this.l10n.resume()),this.#hh("xfalayerrendered",t)}}async#fh(){if(!this.textLayer)return;let t=null;try{await this.textLayer.render(this.viewport)}catch(e){if(e instanceof wa)return;console.error("#renderTextLayer:",e),t=e}this.#hh("textlayerrendered",t),this.#mh()}async#mh(){if(!this.textLayer)return;const t=await(this.structTreeLayer?.render());t&&(this.l10n.pause(),this.structTreeLayer?.addElementsToTextLayer(),this.canvas&&t.parentNode!==this.canvas&&this.canvas.append(t),this.l10n.resume()),this.structTreeLayer?.show()}async#gh(t){const e=await this.pdfPage.getTextContent(),i=[];for(const t of e.items)i.push(t.str);this._textHighlighter.setTextMapping(t,i),this._textHighlighter.enable()}#bh(){const{canvas:t}=this;t&&(t.remove(),t.width=t.height=0,this.canvas=null,this.#Jl=null)}reset({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:s=!1,keepCanvasWrapper:n=!1}={}){this.cancelRendering({keepAnnotationLayer:t,keepAnnotationEditorLayer:e,keepXfaLayer:i,keepTextLayer:s}),this.renderingState=xn.INITIAL;const a=this.div,r=a.childNodes,o=t&&this.annotationLayer?.div||null,l=e&&this.annotationEditorLayer?.div||null,h=i&&this.xfaLayer?.div||null,d=s&&this.textLayer?.div||null,c=n&&this.#Xl||null;for(let t=r.length-1;t>=0;t--){const e=r[t];switch(e){case o:case l:case h:case d:case c:continue}e.remove();const i=this.#rh.indexOf(e);i>=0&&(this.#rh[i]=null)}a.removeAttribute("data-loaded"),o&&this.annotationLayer.hide(),l&&this.annotationEditorLayer.hide(),h&&this.xfaLayer.hide(),d&&this.textLayer.hide(),this.structTreeLayer?.hide(),!n&&this.#Xl&&(this.#Xl=null,this.#bh())}toggleEditingMode(t){this.hasEditableAnnotations()&&(this.#_e=t,this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0}))}update({scale:t=0,rotation:e=null,optionalContentConfigPromise:i=null,drawingDelay:s=-1}){this.scale=t||this.scale,"number"==typeof e&&(this.rotation=e),i instanceof Promise&&(this._optionalContentConfigPromise=i,i.then((t=>{i===this._optionalContentConfigPromise&&(this.#ah.initialOptionalContent=t.hasInitialVisibility)}))),this.#ah.directDrawing=!0;const n=(this.rotation+this.pdfPageRotate)%360;if(this.viewport=this.viewport.clone({scale:this.scale*Ja.PDF_TO_CSS_UNITS,rotation:n}),this.#oh(),this._isStandalone&&this._container?.style.setProperty("--scale-factor",this.viewport.scale),this.canvas){let t=!1;if(this.#Kl)if(0===this.maxCanvasPixels)t=!0;else if(this.maxCanvasPixels>0){const{width:e,height:i}=this.viewport,{sx:s,sy:n}=this.outputScale;t=(Math.floor(e)*s|0)*(Math.floor(i)*n|0)>this.maxCanvasPixels}const e=s>=0&&s<1e3;if(e||t){if(e&&!t&&this.renderingState!==xn.FINISHED&&(this.cancelRendering({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:s}),this.renderingState=xn.FINISHED,this.#ah.directDrawing=!1),this.cssTransform({redrawAnnotationLayer:!0,redrawAnnotationEditorLayer:!0,redrawXfaLayer:!0,redrawTextLayer:!e,hideTextLayer:e}),e)return;return void this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!0,timestamp:performance.now(),error:this.#ih})}}this.cssTransform({}),this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0})}cancelRendering({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:s=!1,cancelExtraDelay:n=0}={}){this.renderTask&&(this.renderTask.cancel(n),this.renderTask=null),this.resume=null,!this.textLayer||s&&this.textLayer.div||(this.textLayer.cancel(),this.textLayer=null),!this.annotationLayer||t&&this.annotationLayer.div||(this.annotationLayer.cancel(),this.annotationLayer=null,this._annotationCanvasMap=null),this.structTreeLayer&&!this.textLayer&&(this.structTreeLayer=null),!this.annotationEditorLayer||e&&this.annotationEditorLayer.div||(this.drawLayer&&(this.drawLayer.cancel(),this.drawLayer=null),this.annotationEditorLayer.cancel(),this.annotationEditorLayer=null),!this.xfaLayer||i&&this.xfaLayer.div||(this.xfaLayer.cancel(),this.xfaLayer=null,this._textHighlighter?.disable())}cssTransform({redrawAnnotationLayer:t=!1,redrawAnnotationEditorLayer:e=!1,redrawXfaLayer:i=!1,redrawTextLayer:s=!1,hideTextLayer:n=!1}){const{canvas:a}=this;if(!a)return;const r=this.#Jl;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.#dh(),e&&this.annotationEditorLayer&&(this.drawLayer&&this.#uh(),this.#ch()),i&&this.xfaLayer&&this.#ph(),this.textLayer&&(n?(this.textLayer.hide(),this.structTreeLayer?.hide()):s&&this.#fh())}get width(){return this.viewport.width}get height(){return this.viewport.height}getPagePoint(t,e){return this.viewport.convertToPdfPoint(t,e)}async#vh(t,e=null){if(t===this.renderTask&&(this.renderTask=null),e instanceof Za)this.#ih=null;else if(this.#ih=e,this.renderingState=xn.FINISHED,this.#ah.regularAnnotations=!t.separateAnnots,this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!1,timestamp:performance.now(),error:this.#ih}),e)throw e}async draw(){this.renderingState!==xn.INITIAL&&(console.error("Must be in new state before drawing"),this.reset());const{div:t,l10n:e,pageColors:i,pdfPage:s,viewport:n}=this;if(!s)throw this.renderingState=xn.FINISHED,new Error("pdfPage is not loaded");this.renderingState=xn.RUNNING;let a=this.#Xl;if(a||(a=this.#Xl=document.createElement("div"),a.classList.add("canvasWrapper"),this.#lh(a,"canvasWrapper")),this.textLayer||this.#nh===Mn||s.isPureXfa||(this._accessibilityManager||=new Ko,this.textLayer=new Qo({pdfPage:s,highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,enablePermissions:this.#nh===kn,onAppend:t=>{this.l10n.pause(),this.#lh(t,"textLayer"),this.l10n.resume()}})),!this.annotationLayer&&this.#ql!==Ca.DISABLE){const{annotationStorage:t,annotationEditorUIManager:e,downloadManager:i,enableScripting:n,fieldObjectsPromise:a,hasJSActionsPromise:r,linkService:o}=this.#Yl;this._annotationCanvasMap||=new Map,this.annotationLayer=new dr({pdfPage:s,annotationStorage:t,imageResourcesPath:this.imageResourcesPath,renderForms:this.#ql===Ca.ENABLE_FORMS,linkService:o,downloadManager:i,enableScripting:n,hasJSActionsPromise:r,fieldObjectsPromise:a,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager,annotationEditorUIManager:e,onAppend:t=>{this.#lh(t,"annotationLayer")}})}const{width:r,height:o}=n,l=document.createElement("canvas");l.setAttribute("role","presentation");const h=!(!i?.background||!i?.foreground),d=this.canvas,c=!d&&!h;this.canvas=l,this.#Jl=n;let u=t=>{if(c)return a.prepend(l),void(u=null);t&&(d?(d.replaceWith(l),d.width=d.height=0):a.prepend(l),u=null)};const p=l.getContext("2d",{alpha:!1,willReadFrequently:!this.#li}),g=this.outputScale=new Ga;if(0===this.maxCanvasPixels){const t=1/this.scale;g.sx*=t,g.sy*=t,this.#Kl=!0}else if(this.maxCanvasPixels>0){const t=r*o,e=Math.sqrt(this.maxCanvasPixels/t);g.sx>e||g.sy>e?(g.sx=e,g.sy=e,this.#Kl=!0):this.#Kl=!1}const f=Bn(g.sx),m=Bn(g.sy),b=l.width=jn($n(r*g.sx),f[0]),v=l.height=jn($n(o*g.sy),m[0]),w=jn($n(r),f[1]),y=jn($n(o),m[1]);g.sx=b/w,g.sy=v/y,this.#th!==f[1]&&(t.style.setProperty("--scale-round-x",`${f[1]}px`),this.#th=f[1]),this.#eh!==m[1]&&(t.style.setProperty("--scale-round-y",`${m[1]}px`),this.#eh=m[1]);const A={canvasContext:p,transform:g.scaled?[g.sx,0,0,g.sy,0,0]:null,viewport:n,annotationMode:this.#ql,optionalContentConfigPromise:this._optionalContentConfigPromise,annotationCanvasMap:this._annotationCanvasMap,pageColors:i,isEditing:this.#_e},_=this.renderTask=s.render(A);_.onContinue=t=>{if(u?.(!1),this.renderingQueue&&!this.renderingQueue.isHighestPriority(this))return this.renderingState=xn.PAUSED,void(this.resume=()=>{this.renderingState=xn.RUNNING,t()});t()};const x=_.promise.then((async()=>{u?.(!0),await this.#vh(_),this.structTreeLayer||=new Xo(s,n.rawDims),this.#fh(),this.annotationLayer&&await this.#dh();const{annotationEditorUIManager:t}=this.#Yl;t&&(this.drawLayer||=new Wo({pageIndex:this.id}),await this.#uh(),this.drawLayer.setParent(a),this.annotationEditorLayer||=new Ro({uiManager:t,pdfPage:s,l10n:e,structTreeLayer:this.structTreeLayer,accessibilityManager:this._accessibilityManager,annotationLayer:this.annotationLayer?.annotationLayer,textLayer:this.textLayer,drawLayer:this.drawLayer.getDrawLayer(),onAppend:t=>{this.#lh(t,"annotationEditorLayer")}}),this.#ch())}),(t=>(t instanceof Za?(d?.remove(),this.#bh()):u?.(!0),this.#vh(_,t))));if(s.isPureXfa){if(!this.xfaLayer){const{annotationStorage:t,linkService:e}=this.#Yl;this.xfaLayer=new Jo({pdfPage:s,annotationStorage:t,linkService:e})}this.#ph()}return t.setAttribute("data-loaded",!0),this.eventBus.dispatch("pagerender",{source:this,pageNumber:this.id}),x}setPageLabel(t){this.pageLabel="string"==typeof t?t:null,this.div.setAttribute("data-l10n-args",JSON.stringify({page:this.pageLabel??this.id})),null!==this.pageLabel?this.div.setAttribute("data-page-label",this.pageLabel):this.div.removeAttribute("data-page-label")}get thumbnailCanvas(){const{directDrawing:t,initialOptionalContent:e,regularAnnotations:i}=this.#ah;return t&&e&&i?this.canvas:null}}class il{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 sl{#wh=null;#yh=null;#Ah=null;#tl=null;#Ia=null;#_h=null;#xh=null;#Sh=null;#Ch=!1;#Eh=null;#Ph=null;constructor({eventBus:t,externalServices:e=null,docProperties:i=null}){this.#Ia=t,this.#_h=e,this.#Ah=i}setViewer(t){this.#Sh=t}async setDocument(t){if(this.#xh&&await this.#Mh(),this.#xh=t,!t)return;const[e,i,s]=await Promise.all([t.getFieldObjects(),t.getCalculationOrderIds(),t.getJSActions()]);if(!e&&!s)return void await this.#Mh();if(t!==this.#xh)return;try{this.#Eh=this.#Th()}catch(t){return console.error("setDocument:",t),void await this.#Mh()}const n=this.#Ia;this.#tl=new AbortController;const{signal:a}=this.#tl;n._on("updatefromsandbox",(t=>{t?.source===window&&this.#kh(t.detail)}),{signal:a}),n._on("dispatcheventinsandbox",(t=>{this.#Eh?.dispatchEventInSandbox(t.detail)}),{signal:a}),n._on("pagechanging",(({pageNumber:t,previous:e})=>{t!==e&&(this.#Ih(e),this.#Lh(t))}),{signal:a}),n._on("pagerendered",(({pageNumber:t})=>{this._pageOpenPending.has(t)&&t===this.#Sh.currentPageNumber&&this.#Lh(t)}),{signal:a}),n._on("pagesdestroy",(async()=>{await this.#Ih(this.#Sh.currentPageNumber),await(this.#Eh?.dispatchEventInSandbox({id:"doc",name:"WillClose"})),this.#wh?.resolve()}),{signal:a});try{const a=await this.#Ah(t);if(t!==this.#xh)return;await this.#Eh.createSandbox({objects:e,calculationOrder:i,appInfo:{platform:navigator.platform,language:navigator.language},docInfo:{...a,actions:s}}),n.dispatch("sandboxcreated",{source:this})}catch(t){return console.error("setDocument:",t),void await this.#Mh()}await(this.#Eh?.dispatchEventInSandbox({id:"doc",name:"Open"})),await this.#Lh(this.#Sh.currentPageNumber,!0),Promise.resolve().then((()=>{t===this.#xh&&(this.#Ch=!0)}))}async dispatchWillSave(){return this.#Eh?.dispatchEventInSandbox({id:"doc",name:"WillSave"})}async dispatchDidSave(){return this.#Eh?.dispatchEventInSandbox({id:"doc",name:"DidSave"})}async dispatchWillPrint(){if(this.#Eh){await(this.#Ph?.promise),this.#Ph=Promise.withResolvers();try{await this.#Eh.dispatchEventInSandbox({id:"doc",name:"WillPrint"})}catch(t){throw this.#Ph.resolve(),this.#Ph=null,t}await this.#Ph.promise}}async dispatchDidPrint(){return this.#Eh?.dispatchEventInSandbox({id:"doc",name:"DidPrint"})}get destroyPromise(){return this.#yh?.promise||null}get ready(){return this.#Ch}get _pageOpenPending(){return er(this,"_pageOpenPending",new Set)}get _visitedPages(){return er(this,"_visitedPages",new Map)}async#kh(t){const e=this.#Sh,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=In.VERTICAL,i=Ln.NONE;switch(t){case"SinglePage":e=In.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=In.PAGE;case"TwoColumnLeft":i=Ln.ODD;break;case"TwoPageRight":e=In.PAGE;case"TwoColumnRight":i=Ln.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.#Ia.dispatch("print",{source:this});break;case"println":console.log(r);break;case"zoom":i||(e.currentScaleValue=r);break;case"SaveAs":this.#Ia.dispatch("download",{source:this});break;case"FirstPage":e.currentPageNumber=1;break;case"LastPage":e.currentPageNumber=e.pagesCount;break;case"NextPage":e.nextPage();break;case"PrevPage":e.previousPage();break;case"ZoomViewIn":i||e.increaseScale();break;case"ZoomViewOut":i||e.decreaseScale();break;case"WillPrintFinished":this.#Ph?.resolve(),this.#Ph=null}return}if(i&&t.focus)return;delete t.id,delete t.siblings;const o=n?[s,...n]:[s];for(const e of o){const i=document.querySelector(`[data-element-id="${e}"]`);i?i.dispatchEvent(new CustomEvent("updatefromsandbox",{detail:t})):this.#xh?.annotationStorage.setValue(e,t)}}async#Lh(t,e=!1){const i=this.#xh,s=this._visitedPages;if(e&&(this.#wh=Promise.withResolvers()),!this.#wh)return;const n=this.#Sh.getPageView(t-1);if(n?.renderingState!==xn.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.#xh&&await(this.#Eh?.dispatchEventInSandbox({id:"page",name:"PageOpen",pageNumber:t,actions:e}))})();s.set(t,a)}async#Ih(t){const e=this.#xh,i=this._visitedPages;if(!this.#wh)return;if(this._pageOpenPending.has(t))return;const s=i.get(t);s&&(i.set(t,null),await s,e===this.#xh&&await(this.#Eh?.dispatchEventInSandbox({id:"page",name:"PageClose",pageNumber:t})))}#Th(){if(this.#yh=Promise.withResolvers(),this.#Eh)throw new Error("#initScripting: Scripting already exists.");return this.#_h.createScripting()}async#Mh(){if(!this.#Eh)return this.#xh=null,void this.#yh?.resolve();this.#wh&&(await Promise.race([this.#wh.promise,new Promise((t=>{setTimeout(t,1e3)}))]).catch((()=>{})),this.#wh=null),this.#xh=null;try{await this.#Eh.destroySandbox()}catch{}this.#Ph?.reject(new Error("Scripting destroyed.")),this.#Ph=null,this.#tl?.abort(),this.#tl=null,this._pageOpenPending.clear(),this._visitedPages.clear(),this.#Eh=null,this.#Ch=!1,this.#yh?.resolve()}}class nl extends sl{constructor(t){t.externalServices||window.addEventListener("updatefromsandbox",(e=>{t.eventBus.dispatch("updatefromsandbox",{source:window,detail:e.detail})})),t.externalServices||={createScripting:()=>new il(t.sandboxBundleSrc)},t.docProperties||=t=>async function(t){const e="".split("#",1)[0];let{info:i,metadata:s,contentDispositionFilename:n,contentLength:a}=await t.getMetadata();if(!a){const{length:e}=await t.getDownloadInfo();a=e}return{...i,baseURL:e,filesize:a,filename:n||Na(""),metadata:s?.getRaw(),authors:s?.get("dc:creator"),numPages:t.numPages,URL:""}}(t),super(t)}}let al=class{constructor(){this.pdfViewer=null,this.pdfThumbnailViewer=null,this.onIdle=null,this.highestPriorityPage=null,this.idleTimeout=null,this.printing=!1,this.isThumbnailViewEnabled=!1,Object.defineProperty(this,"hasViewer",{value:()=>!!this.pdfViewer})}setViewer(t){this.pdfViewer=t}setThumbnailViewer(t){this.pdfThumbnailViewer=t}isHighestPriority(t){return this.highestPriorityPage===t.renderingId}renderHighestPriority(t){this.idleTimeout&&(clearTimeout(this.idleTimeout),this.idleTimeout=null),this.pdfViewer.forceRendering(t)||this.isThumbnailViewEnabled&&this.pdfThumbnailViewer?.forceRendering()||this.printing||this.onIdle&&(this.idleTimeout=setTimeout(this.onIdle.bind(this),3e4))}getHighestPriority(t,e,i,s=!1){const n=t.views,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===xn.FINISHED}renderView(t){switch(t.renderingState){case xn.FINISHED:return!1;case xn.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case xn.RUNNING:this.highestPriorityPage=t.renderingId;break;case xn.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally((()=>{this.renderHighestPriority()})).catch((t=>{t instanceof Za||console.error("renderView:",t)}))}return!0}};const rl=1e4,ol=5e3,ll=250;function hl(t){return Object.values(_a).includes(t)&&t!==_a.DISABLE}class dl{#Dh=new Set;#Rh=0;constructor(t){this.#Rh=t}push(t){const e=this.#Dh;e.has(t)&&e.delete(t),e.add(t),e.size>this.#Rh&&this.#Nh()}resize(t,e=null){this.#Rh=t;const i=this.#Dh;if(e){const t=i.size;let s=1;for(const n of i)if(e.has(n.id)&&(i.delete(n),i.add(n)),++s>t)break}for(;i.size>this.#Rh;)this.#Nh()}has(t){return this.#Dh.has(t)}[Symbol.iterator](){return this.#Dh.keys()}#Nh(){const t=this.#Dh.keys().next().value;t?.destroy(),this.#Dh.delete(t)}}class cl{#Fh=null;#L=null;#Oh=null;#Bh=_a.NONE;#jh=null;#ql=Ca.ENABLE_FORMS;#Hh=null;#Vh=null;#li=!1;#U=!1;#Hl=!1;#$=!1;#W=!1;#tl=null;#nt=null;#zh=null;#Uh=null;#$h=!1;#Wh=null;#Gh=!1;#qh=0;#Xh=new ResizeObserver(this.#Kh.bind(this));#Yh=null;#Qh=null;#Jh=!0;#nh=Tn;constructor(t){const e="4.10.38";if(lr!==e)throw new Error(`The API version "${lr}" does not match the Viewer version "${e}".`);if(this.container=t.container,this.viewer=t.viewer||t.container.firstElementChild,"DIV"!==this.container?.tagName||"DIV"!==this.viewer?.tagName)throw new Error("Invalid `container` and/or `viewer` option.");if(this.container.offsetParent&&"absolute"!==getComputedStyle(this.container).position)throw new Error("The `container` must be absolutely positioned.");this.#Xh.observe(this.container),this.eventBus=t.eventBus,this.linkService=t.linkService||new va,this.downloadManager=t.downloadManager||null,this.findController=t.findController||null,this.#L=t.altTextManager||null,this.#Vh=t.editorUndoBar||null,this.findController&&(this.findController.onIsPageVisible=t=>this._getVisiblePages().ids.has(t)),this._scriptingManager=t.scriptingManager||null,this.#nh=t.textLayerMode??Tn,this.#ql=t.annotationMode??Ca.ENABLE_FORMS,this.#Bh=t.annotationEditorMode??_a.NONE,this.#Oh=t.annotationEditorHighlightColors||null,this.#U=!0===t.enableHighlightFloatingButton,this.#$=!0===t.enableUpdatedAddImage,this.#W=!0===t.enableNewAltTextWhenAddingImage,this.imageResourcesPath=t.imageResourcesPath||"",this.enablePrintAutoRotate=t.enablePrintAutoRotate||!1,this.removePageBorders=t.removePageBorders||!1,this.maxCanvasPixels=t.maxCanvasPixels,this.l10n=t.l10n,this.l10n||=new Io,this.#Hl=t.enablePermissions||!1,this.pageColors=t.pageColors||null,this.#nt=t.mlManager||null,this.#li=t.enableHWA||!1,this.#Jh=!1!==t.supportsPinchToZoom,this.defaultRenderingQueue=!t.renderingQueue,this.defaultRenderingQueue?(this.renderingQueue=new al,this.renderingQueue.setViewer(this)):this.renderingQueue=t.renderingQueue;const{abortSignal:i}=t;i?.addEventListener("abort",(()=>{this.#Xh.disconnect(),this.#Xh=null}),{once:!0}),this.scroll=function(t,e,i){const s=function(i){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=Sn,this._resetView(),this.removePageBorders&&this.viewer.classList.add("removePageBorders"),this.#Zh(),this.eventBus._on("thumbnailrendered",(({pageNumber:t,pdfPage:e})=>{const i=this._pages[t-1];this.#Fh.has(i)||e?.cleanup()})),t.l10n||this.l10n.translate(this.container)}get pagesCount(){return this._pages.length}getPageView(t){return this._pages[t]}getCachedPageViews(){return new Set(this.#Fh)}get pageViewsReady(){return this._pages.every((t=>t?.pdfPage))}get renderForms(){return this.#ql===Ca.ENABLE_FORMS}get enableScripting(){return!!this._scriptingManager}get currentPageNumber(){return this._currentPageNumber}set currentPageNumber(t){if(!Number.isInteger(t))throw new Error("Invalid page number.");this.pdfDocument&&(this._setCurrentPageNumber(t,!0)||console.error(`currentPageNumber: "${t}" is not a valid page.`))}_setCurrentPageNumber(t,e=!1){if(this._currentPageNumber===t)return e&&this.#td(),!0;if(!(0<t&&t<=this.pagesCount))return!1;const i=this._currentPageNumber;return this._currentPageNumber=t,this.eventBus.dispatch("pagechanging",{source:this,pageNumber:t,pageLabel:this._pageLabels?.[t-1]??null,previous:i}),e&&this.#td(),!0}get currentPageLabel(){return this._pageLabels?.[this._currentPageNumber-1]??null}set currentPageLabel(t){if(!this.pdfDocument)return;let e=0|t;if(this._pageLabels){const i=this._pageLabels.indexOf(t);i>=0&&(e=i+1)}this._setCurrentPageNumber(e,!0)||console.error(`currentPageLabel: "${t}" is not a valid page.`)}get currentScale(){return 0!==this._currentScale?this._currentScale:1}set currentScale(t){if(isNaN(t))throw new Error("Invalid numeric scale.");this.pdfDocument&&this.#ed(t,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(t){this.pdfDocument&&this.#ed(t,{noScroll:!1})}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!Hn(t))throw new Error("Invalid pages rotation angle.");if(!this.pdfDocument)return;if((t%=360)<0&&(t+=360),this._pagesRotation===t)return;this._pagesRotation=t;const e=this._currentPageNumber;this.refresh(!0,{rotation:t}),this._currentScaleValue&&this.#ed(this._currentScaleValue,{noScroll:!0}),this.eventBus.dispatch("rotationchanging",{source:this,pagesRotation:t,pageNumber:e}),this.defaultRenderingQueue&&this.update()}get firstPagePromise(){return this.pdfDocument?this._firstPageCapability.promise:null}get onePageRendered(){return this.pdfDocument?this._onePageRenderedCapability.promise:null}get pagesPromise(){return this.pdfDocument?this._pagesCapability.promise:null}get _layerProperties(){const t=this;return er(this,"_layerProperties",{get annotationEditorUIManager(){return t.#jh},get annotationStorage(){return t.pdfDocument?.annotationStorage},get downloadManager(){return t.downloadManager},get enableScripting(){return!!t._scriptingManager},get fieldObjectsPromise(){return t.pdfDocument?.getFieldObjects()},get findController(){return t.findController},get hasJSActionsPromise(){return t.pdfDocument?.hasJSActions()},get linkService(){return t.linkService}})}#id(t){const e={annotationEditorMode:this.#Bh,annotationMode:this.#ql,textLayerMode:this.#nh};return t?(t.includes(Qa.COPY)||this.#nh!==Tn||(e.textLayerMode=kn),t.includes(Qa.MODIFY_CONTENTS)||(e.annotationEditorMode=_a.DISABLE),t.includes(Qa.MODIFY_ANNOTATIONS)||t.includes(Qa.FILL_INTERACTIVE_FORMS)||this.#ql!==Ca.ENABLE_FORMS||(e.annotationMode=Ca.ENABLE),e):e}async#sd(t){if("hidden"===document.visibilityState||!this.container.offsetParent||0===this._getVisiblePages().views.length)return;const e=Promise.withResolvers(),i=new AbortController;document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&e.resolve()}),{signal:"function"==typeof AbortSignal.any?AbortSignal.any([t,i.signal]):t}),await Promise.race([this._onePageRenderedCapability.promise,e.promise]),i.abort()}async getAllText(){const t=[],e=[];for(let i=1,s=this.pdfDocument.numPages;i<=s;++i){if(this.#Gh)return null;e.length=0;const s=await this.pdfDocument.getPage(i),{items:n}=await s.getTextContent();for(const t of n)t.str&&e.push(t.str),t.hasEOL&&e.push("\n");t.push(Fn(e.join("")))}return t.join("\n")}#nd(t,e){const i=document.getSelection(),{focusNode:s,anchorNode:n}=i;if(n&&s&&i.containsNode(this.#Wh)){if(this.#$h||t===kn)return void ir(e);this.#$h=!0;const{classList:i}=this.viewer;i.add("copyAll");const s=new AbortController;window.addEventListener("keydown",(t=>this.#Gh="Escape"===t.key),{signal:s.signal}),this.getAllText().then((async t=>{null!==t&&await navigator.clipboard.writeText(t)})).catch((t=>{console.warn(`Something goes wrong when extracting the text: ${t.message}`)})).finally((()=>{this.#$h=!1,this.#Gh=!1,s.abort(),i.remove("copyAll")})),ir(e)}}setDocument(t){if(this.pdfDocument&&(this.eventBus.dispatch("pagesdestroy",{source:this}),this._cancelRendering(),this._resetView(),this.findController?.setDocument(null),this._scriptingManager?.setDocument(null),this.#jh?.destroy(),this.#jh=null),this.pdfDocument=t,!t)return;const e=t.numPages,i=t.getPage(1),s=t.getOptionalContentConfig({intent:"display"}),n=this.#Hl?t.getPermissions():Promise.resolve(),{eventBus:a,pageColors:r,viewer:o}=this;this.#tl=new AbortController;const{signal:l}=this.#tl;if(e>rl){console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");const t=this._scrollMode=In.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.#Fh.push(e)}),{signal:l});const h=t=>{t.cssTransform||(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.#id(n);if(c!==Mn){const t=this.#Wh=document.createElement("div");t.id="hiddenCopyElement",o.before(t)}if("function"==typeof AbortSignal.any&&h!==_a.DISABLE){const e=h;t.isPureXfa?console.warn("Warning: XFA-editing is not implemented."):hl(e)?(this.#jh=new xa(this.container,o,this.#L,a,t,r,this.#Oh,this.#U,this.#$,this.#W,this.#nt,this.#Vh,this.#Jh),a.dispatch("annotationeditoruimanager",{source:this,uiManager:this.#jh}),e!==_a.NONE&&(e===_a.STAMP&&this.#nt?.loadModel("altText"),this.#jh.updateMode(e))):console.error(`Invalid AnnotationEditor mode: ${e}`)}const u=this._scrollMode===In.PAGE?null:o,p=this.currentScale,g=i.getViewport({scale:p*Ja.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 el({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,pageColors:r,l10n:this.l10n,layerProperties:this._layerProperties,enableHWA:this.#li});this._pages.push(e)}this._pages[0]?.setPdfPage(i),this._scrollMode===In.PAGE?this.#ad():this._spreadMode!==Ln.NONE&&this._updateSpreadMode(),this.#sd(l).then((async()=>{if(t!==this.pdfDocument)return;if(this.findController?.setDocument(t),this._scriptingManager?.setDocument(t),this.#Wh&&document.addEventListener("copy",this.#nd.bind(this,c),{signal:l}),this.#jh&&a.dispatch("annotationeditormodechanged",{source:this,mode:this.#Bh}),t.loadingParams.disableAutoFetch||e>ol)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%ll==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.#Fh=new dl(10),this._location=null,this._pagesRotation=0,this._optionalContentConfigPromise=null,this._firstPageCapability=Promise.withResolvers(),this._onePageRenderedCapability=Promise.withResolvers(),this._pagesCapability=Promise.withResolvers(),this._scrollMode=In.VERTICAL,this._previousScrollMode=In.UNKNOWN,this._spreadMode=Ln.NONE,this.#Yh={previousPageNumber:1,scrollDown:!0,pages:[]},this.#tl?.abort(),this.#tl=null,this.viewer.textContent="",this._updateScrollMode(),this.viewer.removeAttribute("lang"),this.#Wh?.remove(),this.#Wh=null,this.#rd()}#ad(){if(this._scrollMode!==In.PAGE)throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");const t=this._currentPageNumber,e=this.#Yh,i=this.viewer;if(i.textContent="",e.pages.length=0,this._spreadMode!==Ln.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.update()}#od(t,e=null){const{div:i,id:s}=t;if(this._currentPageNumber!==s&&this._setCurrentPageNumber(s),this._scrollMode===In.PAGE&&(this.#ad(),this.update()),!e&&!this.isInPresentationMode){const t=i.offsetLeft+i.clientLeft,s=t+i.clientWidth,{scrollLeft:n,clientWidth:a}=this.container;(this._scrollMode===In.HORIZONTAL||t<n||s>n+a)&&(e={left:0,top:0})}Dn(i,e),!this._currentScaleValue&&this._location&&(this._location=null)}#ld(t){return t===this._currentScale||Math.abs(t-this._currentScale)<1e-15}#hd(t,e,{noScroll:i=!1,preset:s=!1,drawingDelay:n=-1,origin:a=null}){if(this._currentScaleValue=e.toString(),this.#ld(t))return void(s&&this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:e}));this.viewer.style.setProperty("--scale-factor",t*Ja.PDF_TO_CSS_UNITS);const r=n>=0&&n<1e3;this.refresh(!0,{scale:t,drawingDelay:r?n:-1}),r&&(this.#Qh=setTimeout((()=>{this.#Qh=null,this.refresh()}),n));const o=this._currentScale;if(this._currentScale=t,!i){let e,i=this._currentPageNumber;if(!this._location||this.isInPresentationMode||this.isChangingPresentationMode||(i=this._location.pageNumber,e=[null,{name:"XYZ"},this._location.left,this._location.top,null]),this.scrollPageIntoView({pageNumber:i,destArray:e,allowNegativeOffset:!0}),Array.isArray(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#dd(){return this._spreadMode!==Ln.NONE&&this._scrollMode!==In.HORIZONTAL?2:1}#ed(t,e){let i=parseFloat(t);if(i>0)e.preset=!1,this.#hd(i,t,e);else{const s=this._pages[this._currentPageNumber-1];if(!s)return;let n=40,a=5;this.isInPresentationMode?(n=a=4,this._spreadMode!==Ln.NONE&&(n*=2)):this.removePageBorders?n=a=0:this._scrollMode===In.HORIZONTAL&&([n,a]=[a,n]);const r=(this.container.clientWidth-n)/s.width*s.scale/this.#dd,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=Vn(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.#hd(i,t,e)}}#td(){const t=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&this.#ed(this._currentScaleValue,{noScroll:!0}),this.#od(t)}pageLabelToPageNumber(t){if(!this._pageLabels)return null;const e=this._pageLabels.indexOf(t);return e<0?null:e+1}scrollPageIntoView({pageNumber:t,destArray:e=null,allowNegativeOffset:i=!1,ignoreDestinationZoom:s=!1}){if(!this.pdfDocument)return;const n=Number.isInteger(t)&&this._pages[t-1];if(!n)return void console.error(`scrollPageIntoView: "${t}" is not a valid pageNumber parameter.`);if(this.isInPresentationMode||!e)return void this._setCurrentPageNumber(t,!0);let a,r,o=0,l=0,h=0,d=0;const c=n.rotation%180!=0,u=(c?n.height:n.width)/n.scale/Ja.PDF_TO_CSS_UNITS,p=(c?n.width:n.height)/n.scale/Ja.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/Ja.PDF_TO_CSS_UNITS,r=(this.container.clientHeight-i)/d/Ja.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.#od(n);const f=[n.viewport.convertToViewportPoint(o,l),n.viewport.convertToViewportPoint(o+h,l+d)];let m=Math.min(f[0][0],f[1][0]),b=Math.min(f[0][1],f[1][1]);i||(m=Math.max(m,0),b=Math.max(b,0)),this.#od(n,{left:m,top:b})}_updateLocation(t){const e=this._currentScale,i=this._currentScaleValue,s=parseFloat(i)===e?Math.round(1e4*e)/100:i,n=t.id,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.#Fh.resize(s,t.ids),this.renderingQueue.renderHighestPriority(t);const n=this._spreadMode===Ln.NONE&&(this._scrollMode===In.PAGE||this._scrollMode===In.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})}#cd(){const t=this._getVisiblePages(),e=[],{ids:i,views:s}=t;for(const t of s){const{view:s}=t;s.hasEditableAnnotations()?e.push(t):i.delete(s.id)}return 0===e.length?null:(this.renderingQueue.renderHighestPriority({first:e[0],last:e.at(-1),views:e,ids:i}),i)}containsElement(t){return this.container.contains(t)}focus(){this.container.focus()}get _isContainerRtl(){return"rtl"===getComputedStyle(this.container).direction}get isInPresentationMode(){return this.presentationModeState===Pn}get isChangingPresentationMode(){return this.presentationModeState===En}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===In.PAGE?this.#Yh.pages:this._pages,e=this._scrollMode===In.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=On(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)+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}}({scrollEl:this.container,views:t,sortByVisibility:!0,horizontal:e,rtl:i})}cleanup(){for(const t of this._pages)t.renderingState!==xn.FINISHED&&t.reset()}_cancelRendering(){for(const t of this._pages)t.cancelRendering()}async#ud(t){if(t.pdfPage)return t.pdfPage;try{const e=await this.pdfDocument.getPage(t.id);return t.pdfPage||t.setPdfPage(e),e}catch(t){return console.error("Unable to get page for page view",t),null}}#pd(t){if(1===t.first?.id)return!0;if(t.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case In.PAGE:return this.#Yh.scrollDown;case In.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(t){const e=t||this._getVisiblePages(),i=this.#pd(e),s=this._spreadMode!==Ln.NONE&&this._scrollMode!==In.HORIZONTAL,n=this.renderingQueue.getHighestPriority(e,this._pages,i,s);return!!n&&(this.#ud(n).then((()=>{this.renderingQueue.renderView(n)})),!0)}get hasEqualPageSizes(){const t=this._pages[0];for(let e=1,i=this._pages.length;e<i;++e){const i=this._pages[e];if(i.width!==t.width||i.height!==t.height)return!1}return!0}getPagesOverview(){let t;return this._pages.map((e=>{const i=e.pdfPage.getViewport({scale:1}),s=Vn(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(In).includes(t)&&t!==In.UNKNOWN}(t))throw new Error(`Invalid scroll mode: ${t}`);this.pagesCount>rl||(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===In.HORIZONTAL),i.classList.toggle("scrollWrapped",e===In.WRAPPED),this.pdfDocument&&t&&(e===In.PAGE?this.#ad():this._previousScrollMode===In.PAGE&&this._updateSpreadMode(),this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#ed(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}get spreadMode(){return this._spreadMode}set spreadMode(t){if(this._spreadMode!==t){if(!function(t){return Number.isInteger(t)&&Object.values(Ln).includes(t)&&t!==Ln.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===In.PAGE)this.#ad();else if(e.textContent="",this._spreadMode===Ln.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.#ed(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}_getPageAdvance(t,e=!1){switch(this._scrollMode){case In.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 In.HORIZONTAL:break;case In.PAGE:case In.VERTICAL:{if(this._spreadMode===Ln.NONE)break;const i=this._spreadMode-1;if(e&&t%2!==i)break;if(!e&&t%2===i)break;const{views:s}=this._getVisiblePages(),n=e?t-1:t+1;for(const{id:t,percent:e,widthPercent:i}of s)if(t===n){if(e>0&&100===i)return 2;break}break}}return 1}nextPage(){const t=this._currentPageNumber,e=this.pagesCount;if(t>=e)return!1;const i=this._getPageAdvance(t,!1)||1;return this.currentPageNumber=Math.min(t+i,e),!0}previousPage(){const t=this._currentPageNumber;if(t<=1)return!1;const e=this._getPageAdvance(t,!0)||1;return this.currentPageNumber=Math.max(t-e,1),!0}updateScale({drawingDelay:t,scaleFactor:e=null,steps:i=null,origin:s}){if(null===i&&null===e)throw new Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided.");if(!this.pdfDocument)return;let n=this._currentScale;if(e>0&&1!==e)n=Math.round(n*e*100)/100;else if(i){const t=i>0?1.1:1/1.1,e=i>0?Math.ceil:Math.floor;i=Math.abs(i);do{n=e(10*(n*t).toFixed(2))/10}while(--i>0)}n=Math.max(.1,Math.min(10,n)),this.#ed(n,{noScroll:!1,drawingDelay:t,origin:s})}increaseScale(t={}){this.updateScale({...t,steps:t.steps??1})}decreaseScale(t={}){this.updateScale({...t,steps:-(t.steps??1)})}#Zh(t=this.container.clientHeight){t!==this.#qh&&(this.#qh=t,zn.setProperty("--viewer-container-height",`${t}px`))}#Kh(t){for(const e of t)if(e.target===this.container){this.#Zh(Math.floor(e.borderBoxSize[0].blockSize)),this.#Hh=null;break}}get containerTopLeft(){return this.#Hh||=[this.container.offsetTop,this.container.offsetLeft]}#rd(){this.#zh?.abort(),this.#zh=null,null!==this.#Uh&&(clearTimeout(this.#Uh),this.#Uh=null)}get annotationEditorMode(){return this.#jh?this.#Bh:_a.DISABLE}set annotationEditorMode({mode:t,editId:e=null,isFromKeyboard:i=!1}){if(!this.#jh)throw new Error("The AnnotationEditor is not enabled.");if(this.#Bh===t)return;if(!hl(t))throw new Error(`Invalid AnnotationEditor mode: ${t}`);if(!this.pdfDocument)return;t===_a.STAMP&&this.#nt?.loadModel("altText");const{eventBus:s}=this,n=()=>{this.#rd(),this.#Bh=t,this.#jh.updateMode(t,e,i),s.dispatch("annotationeditormodechanged",{source:this,mode:t})};if(t===_a.NONE||this.#Bh===_a.NONE){const e=t!==_a.NONE;e||this.pdfDocument.annotationStorage.resetModifiedIds();for(const t of this._pages)t.toggleEditingMode(e);const i=this.#cd();if(e&&i){this.#rd(),this.#zh=new AbortController;const t=AbortSignal.any([this.#tl.signal,this.#zh.signal]);return void s._on("pagerendered",(({pageNumber:t})=>{i.delete(t),0===i.size&&(this.#Uh=setTimeout(n,0))}),{signal:t})}}n()}refresh(t=!1,e=Object.create(null)){if(this.pdfDocument){for(const t of this._pages)t.update(e);null!==this.#Qh&&(clearTimeout(this.#Qh),this.#Qh=null),t||this.update()}}}class ul extends cl{_resetView(){super._resetView(),this._scrollMode=In.PAGE,this._spreadMode=Ln.NONE}set scrollMode(t){}_updateScrollMode(){}set spreadMode(t){}_updateSpreadMode(){}}var pl,gl,fl,ml,bl,vl=_n.DownloadManager,wl=_n.EventBus,yl=_n.GenericL10n,Al=_n.PDFLinkService,_l=_n.PDFSinglePageViewer,xl=_n.PDFViewer,Sl=_n.SimpleLinkService,Cl=_n.XfaLayerBuilder;const El={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},Pl={UNKNOWN:0,NORMAL:1,CHANGING:2,FULLSCREEN:3},Ml={UNKNOWN:-1,NONE:0,THUMBS:1,OUTLINE:2,ATTACHMENTS:3,LAYERS:4},Tl={DISABLE:0,ENABLE:1,ENABLE_PERMISSIONS:2},kl={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},Il={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 Hl(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 Vl(t){const e=t.deltaMode;let i=Hl(t);return e===WheelEvent.DOM_DELTA_PIXEL?i/=900:e===WheelEvent.DOM_DELTA_LINE&&(i/=30),i}function zl(t){return Number.isInteger(t)&&t%90==0}function Ul(t){return Number.isInteger(t)&&Object.values(kl).includes(t)&&t!==kl.UNKNOWN}function $l(t){return Number.isInteger(t)&&Object.values(Il).includes(t)&&t!==Il.UNKNOWN}function Wl(t){return t.width<=t.height}const Gl=new Promise((function(t){window.requestAnimationFrame(t)})),ql=document.documentElement.style;pl=new WeakMap,gl=new WeakMap,fl=new WeakMap,ml=new WeakMap,bl=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 bn||console.error("renderView:",t)}))}return!0}}var Yl,Ql,Jl,Zl,th,eh,ih,sh;class nh{static getCanvas(t,e){const i=n(this,Yl,s(this,Yl,"f",Ql)||document.createElement("canvas"),"f",Ql);i.width=t,i.height=e;const a=i.getContext("2d",{alpha:!1});return a.save(),a.fillStyle="rgb(255, 255, 255)",a.fillRect(0,0,t,e),a.restore(),[i,i.getContext("2d")]}static destroyCanvas(){const t=s(this,Yl,"f",Ql);t&&(t.width=0,t.height=0),n(this,Yl,null,"f",Ql)}}Yl=nh,Ql={value:null};class ah{constructor({container:t,eventBus:e,id:i,defaultViewport:n,optionalContentConfigPromise:a,linkService:r,renderingQueue:o,pageColors:l,enableHWA:h,store:d,thumbnailWidth:c}){Jl.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=a||null,this.pageColors=l||null,this.enableHWA=h||!1,this.eventBus=e,this.linkService=r,this.renderingQueue=o,this.renderTask=null,this.renderingState=El.INITIAL,this.resume=null,this.store=d,this.thumbnailWidth=c,this.loaded=!1;const u=document.createElement("div");u.className="thumbnail pdfSlickThumbHolder",u.setAttribute("data-page-number",this.id.toString()),this.div=u,s(this,Jl,"m",Zl).call(this),t.append(u)}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,s(this,Jl,"m",Zl).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 i(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:n}=s(this,Jl,"m",th).call(this,2),a={canvasContext:e,transform:n,viewport:this.viewport.clone({scale:2*this.scale}),optionalContentConfigPromise:this._optionalContentConfigPromise,pageColors:this.pageColors},r=this.renderTask=t.render(a);r.onContinue=t=>{if(!this.renderingQueue.isHighestPriority(this))return this.renderingState=El.PAUSED,void(this.resume=()=>{this.renderingState=El.RUNNING,t()});t()};const o=r.promise.then((()=>s(this,Jl,"m",ih).call(this,r,i)),(t=>s(this,Jl,"m",ih).call(this,r,i,t)));return o.finally((()=>{i.width=0,i.height=0,this.eventBus.dispatch("thumbnailrendered",{source:this,pageNumber:this.id,pdfPage:this.pdfPage})})),o}))}setImage(t){if(this.renderingState!==El.INITIAL)return;const{thumbnailCanvas:e,pdfPage:i,scale:n}=t;e&&(this.pdfPage||this.setPdfPage(i),n<this.scale||(this.renderingState=El.FINISHED,s(this,Jl,"m",eh).call(this,e)))}setPageLabel(t){this.pageLabel="string"==typeof t?t:null}}var rh,oh,lh,hh,dh,ch,uh;Jl=new WeakSet,Zl=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=s(this,Jl,"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 i(this,arguments,void 0,(function*(t,e,i=null){if(t===this.renderTask&&(this.renderTask=null),!(i instanceof bn)&&(this.renderingState=El.FINISHED,s(this,Jl,"m",eh).call(this,e),i))throw i}))},sh=function(t){const{ctx:e,canvas:i}=s(this,Jl,"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 n=i.width<<3,a=i.height<<3;const[r,o]=nh.getCanvas(n,a);for(;n>t.width||a>t.height;)n>>=1,a>>=1;for(o.drawImage(t,0,0,t.width,t.height,0,0,n,a);n>2*i.width;)o.drawImage(r,0,0,n,a,0,0,n>>1,a>>1),n>>=1,a>>=1;return e.drawImage(r,0,0,n,a,0,0,i.width,i.height),i};const ph="selected";class gh{constructor({container:t,eventBus:e,linkService:i,renderingQueue:n,pageColors:a,abortSignal:r,enableHWA:o,store:l,thumbnailWidth:h}){rh.add(this),this.container=t,this.eventBus=e,this.linkService=i,this.renderingQueue=n,this.pageColors=a||null,this.enableHWA=o||!1,this.store=l,this.thumbnailWidth=h,this.scroll=Rl(this.container,s(this,rh,"m",oh).bind(this),r),s(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:n,views:a}=s(this,rh,"m",lh).call(this);if(a.length>0){let s=!1;if(t<=i.id||t>=n.id)s=!0;else for(const{id:e,percent:i}of a)if(e===t){s=i<100;break}s&&Dl(e.div,{top:-19})}this._currentPageNumber=t}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!zl(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&&(s(this,rh,"m",dh).call(this),s(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=s(this,rh,"m",lh).call(this),e=s(this,rh,"m",uh).call(this,t),i=this.renderingQueue.getHighestPriority(t,this._thumbnails,e);return!!i&&(s(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 i(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 Sl,n=Math.round(100*mn.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 Cl({pdfPage:null,annotationStorage:e.annotationStorage,linkService:s,xfaHtml:a}),o=yn(a,{scale:n});r.render(o,"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/mn.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:pn.ENABLE_STORAGE,optionalContentConfigPromise:a,printAnnotationStorage:e};return t.render(i).promise.catch((t=>{throw t instanceof bn||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,Mh,Th,kh,Ih,Lh,Dh,Rh,Nh,Fh;const Oh="pdfPresentationMode",Bh="pdfPresentationModeControls",jh=Math.PI/6;class Hh{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 i(this,void 0,void 0,(function*(){const{container:t,pdfViewer:e}=this;if(this.active||!e.pagesCount||!t.requestFullscreen)return!1;s(this,vh,"m",Nh).call(this),s(this,vh,"m",Sh).call(this,Pl.CHANGING);const i=t.requestFullscreen();n(this,yh,{pageNumber:e.currentPageNumber,scaleValue:e.currentScaleValue,scrollMode:e.scrollMode,spreadMode:null,annotationEditorMode:null},"f"),e.spreadMode===Il.NONE||e.pageViewsReady&&e.hasEqualPageSizes||(console.warn("Ignoring Spread modes when entering PresentationMode, since the document may contain varying page sizes."),s(this,yh,"f").spreadMode=e.spreadMode),e.annotationEditorMode!==un.DISABLE&&(s(this,yh,"f").annotationEditorMode=e.annotationEditorMode);try{return yield i,e.focus(),!0}catch(t){s(this,vh,"m",Fh).call(this),s(this,vh,"m",Sh).call(this,Pl.NORMAL)}return!1}))}get active(){return s(this,wh,"f")===Pl.CHANGING||s(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=Vl(t),i=Date.now(),n=this.mouseScrollTimeStamp;if(!(i>n&&i-n<50)&&((this.mouseScrollDelta>0&&e<0||this.mouseScrollDelta<0&&e>0)&&s(this,vh,"m",Ih).call(this),this.mouseScrollDelta+=e,Math.abs(this.mouseScrollDelta)>=.1)){const t=this.mouseScrollDelta;s(this,vh,"m",Ih).call(this);(t>0?this.pdfViewer.previousPage():this.pdfViewer.nextPage())&&(this.mouseScrollTimeStamp=i)}},Sh=function(t){n(this,wh,t,"f"),this.eventBus.dispatch("presentationmodechanged",{source:this,state:t})},Ch=function(){var t;s(this,vh,"m",Sh).call(this,Pl.FULLSCREEN),this.container.classList.add(Oh),setTimeout((()=>{this.pdfViewer.scrollMode=kl.PAGE,null!==s(this,yh,"f").spreadMode&&(this.pdfViewer.spreadMode=Il.NONE),this.pdfViewer.currentPageNumber=s(this,yh,"f").pageNumber,this.pdfViewer.currentScaleValue="page-fit",null!==s(this,yh,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:un.NONE})}),0),s(this,vh,"m",Dh).call(this),s(this,vh,"m",Th).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((()=>{s(this,vh,"m",Fh).call(this),s(this,vh,"m",Sh).call(this,Pl.NORMAL),this.pdfViewer.scrollMode=s(this,yh,"f").scrollMode,null!==s(this,yh,"f").spreadMode&&(this.pdfViewer.spreadMode=s(this,yh,"f").spreadMode),this.pdfViewer.currentScaleValue=s(this,yh,"f").scaleValue,this.pdfViewer.currentPageNumber=t,null!==s(this,yh,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:s(this,yh,"f").annotationEditorMode}),n(this,yh,null,"f")}),0),s(this,vh,"m",Rh).call(this),s(this,vh,"m",kh).call(this),s(this,vh,"m",Ih).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()))},Mh=function(){this.contextMenuOpen=!0},Th=function(){this.controlsTimeout?clearTimeout(this.controlsTimeout):this.container.classList.add(Bh),this.controlsTimeout=setTimeout((()=>{this.container.classList.remove(Bh),delete this.controlsTimeout}),3e3)},kh=function(){this.controlsTimeout&&(clearTimeout(this.controlsTimeout),this.container.classList.remove(Bh),delete this.controlsTimeout)},Ih=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(s(this,_h,"f"))return;n(this,_h,new AbortController,"f");const{signal:t}=s(this,_h,"f"),e=s(this,vh,"m",Lh).bind(this);window.addEventListener("mousemove",s(this,vh,"m",Th).bind(this),{signal:t}),window.addEventListener("mousedown",s(this,vh,"m",Ph).bind(this),{signal:t}),window.addEventListener("wheel",s(this,vh,"m",xh).bind(this),{passive:!1,signal:t}),window.addEventListener("keydown",s(this,vh,"m",Ih).bind(this),{signal:t}),window.addEventListener("contextmenu",s(this,vh,"m",Mh).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=s(this,_h,"f"))||void 0===t||t.abort(),n(this,_h,null,"f")},Nh=function(){s(this,Ah,"f")||(n(this,Ah,new AbortController,"f"),window.addEventListener("fullscreenchange",(()=>{document.fullscreenElement?s(this,vh,"m",Ch).call(this):s(this,vh,"m",Eh).call(this)}),{signal:s(this,Ah,"f").signal}))},Fh=function(){var t;null===(t=s(this,Ah,"f"))||void 0===t||t.abort(),n(this,Ah,null,"f")};const Vh=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},zh={isDocumentLoaded:!1,pagesReady:!1,url:null,numPages:0,pageNumber:0,scale:0,scaleValue:"auto",pagesRotation:0,spreadMode:Il.UNKNOWN,scrollMode:kl.UNKNOWN,documentOutline:null,attachments:new Map,thumbnails:new Map,thumbnailViews:new Map,annotationEditorMode:un.NONE,pdfSlick:null},Uh=()=>{return(t=(t,e)=>Object.assign(Object.assign({},zh),{_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})}}))?Vh(t):Vh;var t};var $h,Wh,Gh,qh,Xh,Kh,Yh,Qh,Jh,Zh,td,ed,id,sd,nd,ad,rd,od,ld,hd,dd,cd,ud,pd,gd,fd,md;class bd{constructor({eventBus:t,slick:e,printDialog:i}){$h.add(this),Wh.set(this,null),Gh.set(this,null),qh.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!!s(this,Wh,"f")}print(){return i(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=s(this,Wh,"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===s(this,Wh,"f")&&this.abort()}))}else console.error("Expected print service to be initialized."),null===(e=this.printDialog)||void 0===e||e.close()}}}))}abort(){var t;s(this,Wh,"f")&&(s(this,Wh,"f").destroy(),null===(t=this.printDialog)||void 0===t||t.close(),this.eventBus.dispatch("afterprint",{source:this}))}bindEvents(){n(this,Gh,new AbortController,"f");const{signal:t}=s(this,Gh,"f"),e={signal:t};this.eventBus._on("beforeprint",s(this,$h,"m",Xh).bind(this),e),this.eventBus._on("afterprint",s(this,$h,"m",Kh).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=s(this,Gh,"f"))||void 0===t||t.abort(),n(this,Gh,null,"f")}}Wh=new WeakMap,Gh=new WeakMap,qh=new WeakMap,$h=new WeakSet,Xh=function(){s(this,Wh,"f")||this.supportsPrinting&&(this.slick.viewer.pageViewsReady?(n(this,qh,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()}}}(),"f"),n(this,Wh,bh.instance.createPrintService({pdfDocument:this.slick.document,pagesOverview:this.slick.viewer.getPagesOverview(),printContainer:s(this,qh,"f").element,printResolution:this.slick.printResolution,optionalContentConfigPromise:null,printAnnotationStoragePromise:null}),"f"),this.slick.forceRendering(),s(this,Wh,"f").layout()):this.slick.l10n.get("printing_not_ready",null).then((t=>{window.alert(t)})))},Kh=function(){var t,e,i;s(this,Wh,"f")&&(s(this,Wh,"f").destroy(),n(this,Wh,null,"f"),null===(t=this.printDialog)||void 0===t||t.close(),null===(e=s(this,qh,"f"))||void 0===e||e.remove(),n(this,qh,null,"f"),null===(i=this.slick.document)||void 0===i||i.annotationStorage.resetModified()),this.slick.forceRendering()};class vd{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 vd(t)}constructor(t){this.dialog=t}open(t){return i(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}))}}gn.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:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("index.js",document.baseURI).href).toString();const wd={"8.5x11":"Letter","8.5x14":"Legal"},yd={"297x420":"A3","210x297":"A4"};function Ad(t,e,i){return i[`${e?t.width:t.height}x${e?t.height:t.width}`]}Qh=new WeakMap,Jh=new WeakMap,Zh=new WeakMap,td=new WeakMap,ed=new WeakMap,id=new WeakMap,sd=new WeakMap,nd=new WeakMap,ad=new WeakMap,Yh=new WeakSet,rd=function(){return i(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)}))},od=function(){return i(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=>s(this,Yh,"m",ld).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:fn.toDateObject(t.CreationDate),modificationDate:fn.toDateObject(t.ModDate),isLinearized:t.IsLinearized,pageSize:i})}))},ld=function(t,e){return i(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=Ad(s,i,wd)||Ad(n,i,yd);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=Ad(r,i,yd),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}}))},hd=function(){n(this,ad,new AbortController,"f");const{signal:t}=s(this,ad,"f"),e={signal:t};this.eventBus._on("pagesinit",s(this,Yh,"m",dd).bind(this),e),this.eventBus._on("scalechanging",s(this,Yh,"m",gd).bind(this),e),this.eventBus._on("pagechanging",s(this,Yh,"m",fd).bind(this),e),this.eventBus._on("pagerendered",s(this,Yh,"m",md).bind(this),e),this.eventBus._on("rotationchanging",s(this,Yh,"m",cd).bind(this),e),this.eventBus._on("switchspreadmode",s(this,Yh,"m",ud).bind(this),e),this.eventBus._on("switchscrollmode",s(this,Yh,"m",pd).bind(this),e)},dd=function(t){return i(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})}))},cd=function({pagesRotation:t,pageNumber:e}){this.store.setState({pagesRotation:t}),this.thumbnailViewer&&(this.thumbnailViewer.pagesRotation=t),this.forceRendering(),this.viewer.currentPageNumber=e},ud=function({mode:t}){this.store.setState({spreadMode:t})},pd=function({mode:t}){this.store.setState({scrollMode:t})},gd=function({scale:t,presetValue:e}){this.store.setState({scale:t,scaleValue:e}),this.viewer.update()},fd=function({pageNumber:t}){var e;null===(e=this.thumbnailViewer)||void 0===e||e.scrollThumbnailIntoView(t),this.store.setState({pageNumber:t})},md=function({pageNumber:t,error:e}){var i;if(s(this,td,"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)}},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=class{constructor({container:t,viewer:e,thumbs:i,store:a=Uh(),options:r,onError:o,printDialog:l}){var h,d,c,u,p,g,f,m,b,v,w,y,A,_,x;Yh.add(this),Qh.set(this,void 0),Jh.set(this,void 0),Zh.set(this,void 0),td.set(this,void 0),ed.set(this,void 0),this.downloadManager=null,this.findController=null,this.pdfPresentationMode=null,this.document=null,id.set(this,void 0),sd.set(this,void 0),nd.set(this,void 0),ad.set(this,void 0),n(this,Jh,t,"f"),n(this,Zh,e,"f"),n(this,td,i,"f"),n(this,nd,o,"f"),this.l10n=null!==(h=null==r?void 0:r.l10n)&&void 0!==h?h:new yl(navigator.language),this.downloadManager=new vl,this.textLayerMode=null!==(d=null==r?void 0:r.textLayerMode)&&void 0!==d?d:Tl.ENABLE,n(this,id,null!==(c=null==r?void 0:r.annotationMode)&&void 0!==c?c:pn.ENABLE_FORMS,"f"),n(this,sd,null!==(u=null==r?void 0:r.annotationEditorMode)&&void 0!==u?u:un.NONE,"f"),this.annotationEditorHighlightColors=null!==(p=null==r?void 0:r.annotationEditorHighlightColors)&&void 0!==p?p:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",this.removePageBorders=null!==(g=null==r?void 0:r.removePageBorders)&&void 0!==g&&g,this.singlePageViewer=null!==(f=null==r?void 0:r.singlePageViewer)&&void 0!==f&&f,this.enablePrintAutoRotate=null!==(m=null==r?void 0:r.enablePrintAutoRotate)&&void 0!==m&&m,this.useOnlyCssZoom=null!==(b=null==r?void 0:r.useOnlyCssZoom)&&void 0!==b&&b,this.pageColors=null!==(v=null==r?void 0:r.pageColors)&&void 0!==v?v:null,this.maxCanvasPixels=null!==(w=null==r?void 0:r.maxCanvasPixels)&&void 0!==w?w:16777216,this.printResolution=null!==(y=null==r?void 0:r.printResolution)&&void 0!==y?y:96,this.thumbnailWidth=null!==(A=null==r?void 0:r.thumbnailWidth)&&void 0!==A?A:125,this.getDocumentParams=null!==(_=null==r?void 0:r.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=a;const S=new Kl;S.onIdle=this._cleanup.bind(this),S.isThumbnailViewEnabled=!0,n(this,Qh,S,"f");const C=new wl,E=new Al({eventBus:C,externalLinkTarget:2,externalLinkRel:"noopener noreferrer nofollow",ignoreDestinationZoom:!1}),P=Object.assign(Object.assign({container:t},e&&{viewer:e}),{eventBus:C,linkService:E,renderingQueue:S,textLayerMode:this.textLayerMode,annotationEditorHighlightColors:this.annotationEditorHighlightColors,l10n:this.l10n,annotationMode:s(this,id,"f"),annotationEditorMode:s(this,sd,"f"),removePageBorders:this.removePageBorders,imageResourcesPath:"/images/"}),M=this.singlePageViewer?new _l(P):new xl(P);S.setViewer(M),i&&(this.thumbnailViewer=new gh({container:i,eventBus:C,linkService:E,renderingQueue:S,pageColors:this.pageColors,enableHWA:void 0,store:a,thumbnailWidth:this.thumbnailWidth}),S.setThumbnailViewer(this.thumbnailViewer)),document.fullscreenEnabled&&(this.pdfPresentationMode=new Hh({container:t,pdfViewer:M,eventBus:C})),this.eventBus=C,this.linkService=E,this.viewer=M,this.linkService.setViewer(M),n(this,ed,new bd({eventBus:C,slick:this,printDialog:null!=l?l:vd.create()}),"f");const T=null!==(x=null==r?void 0:r.scaleValue)&&void 0!==x?x:"auto";this.store.setState({scaleValue:T})}loadDocument(t,e){return i(this,void 0,void 0,(function*(){var i,n,a,r,o;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===(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 l=null!==(a=null==e?void 0:e.filename)&&void 0!==a?a:wn(null===(r=this.url)||void 0===r?void 0:r.toString());this.filename=l;const h=vn(Object.assign(Object.assign({},this.getDocumentParams),{url:this.url,isEvalSupported:!1}));(null==e?void 0:e.onProgress)&&(h.onProgress=e.onProgress);const d=yield h.promise;this.document=d,this.viewer.setDocument(this.document),this.linkService.setDocument(this.document),this.thumbnailViewer&&(null===(o=this.thumbnailViewer)||void 0===o||o.setDocument(d)),s(this,Yh,"m",hd).call(this),yield s(this,Yh,"m",rd).call(this),this.store.setState({filename:l,numPages:d.numPages,pageNumber:1,isDocumentLoaded:!0,url:t.toString()});const c=yield d.getAttachments(),u=new Map(Object.keys(null!=c?c:{}).sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase()))).map((t=>[t,c[t]])));this.store.setState({attachments:u}),yield s(this,Yh,"m",od).call(this),this.forceRendering()}catch(t){s(this,nd,"f")&&s(this,nd,"f").call(this,t)}}))}forceRendering(t=!0){s(this,Qh,"f").printing=!!s(this,ed,"f").printing,s(this,Qh,"f").isThumbnailViewEnabled=t,s(this,Qh,"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 i(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 i(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 s(this,ed,"f").supportsPrinting}requestPresentationMode(){var t;null===(t=this.pdfPresentationMode)||void 0===t||t.request()}triggerPrinting(){s(this,ed,"f").print()}unbindEvents(){var t;null===(t=s(this,ad,"f"))||void 0===t||t.abort(),n(this,ad,null,"f"),s(this,ed,"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(un.HIGHLIGHT),this.setAnnotationEditorParams([{type:cn.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){Ul(t)&&(this.viewer.scrollMode=t,this.dispatch("switchscrollmode",{mode:t}))}setRotation(t){zl(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)}},t.PresentationModeState=Pl,t.ProgressBar=class{constructor(t){pl.set(this,void 0),gl.set(this,null),fl.set(this,0),ml.set(this,void 0),bl.set(this,!0),n(this,pl,t.classList,"f"),n(this,ml,t.style,"f")}get percent(){return s(this,fl,"f")}set percent(t){var e,i,a;n(this,fl,(e=t,i=0,a=100,Math.min(Math.max(e,i),a)),"f"),isNaN(t)?s(this,pl,"f").add("indeterminate"):(s(this,pl,"f").remove("indeterminate"),s(this,ml,"f").setProperty("--progressBar-percent",`${s(this,fl,"f")}%`))}setWidth(t){if(!t)return;const e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&s(this,ml,"f").setProperty("--progressBar-end-offset",`${e}px`)}setDisableAutoFetch(t=5e3){100===s(this,fl,"f")||isNaN(s(this,fl,"f"))||(s(this,gl,"f")&&clearTimeout(s(this,gl,"f")),this.show(),n(this,gl,setTimeout((()=>{n(this,gl,null,"f"),this.hide()}),t),"f"))}hide(){s(this,bl,"f")&&(n(this,bl,!1,"f"),s(this,pl,"f").add("hidden"))}show(){s(this,bl,"f")||(n(this,bl,!0,"f"),s(this,pl,"f").remove("hidden"))}},t.RendererType={CANVAS:"canvas",SVG:"svg"},t.RenderingStates=El,t.SCROLLBAR_PADDING=40,t.ScrollMode=kl,t.SidebarView=Ml,t.SpreadMode=Il,t.TextLayerMode=Tl,t.UNKNOWN_SCALE=0,t.VERTICAL_PADDING=5,t.animationStarted=Gl,t.apiPageLayoutToViewerModes=function(t){let e=kl.VERTICAL,i=Il.NONE;switch(t){case"SinglePage":e=kl.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=kl.PAGE;case"TwoColumnLeft":i=Il.ODD;break;case"TwoPageRight":e=kl.PAGE;case"TwoColumnRight":i=Il.EVEN}return{scrollMode:e,spreadMode:i}},t.apiPageModeToSidebarView=function(t){switch(t){case"UseNone":return Ml.NONE;case"UseThumbs":return Ml.THUMBS;case"UseOutlines":return Ml.OUTLINE;case"UseAttachments":return Ml.ATTACHMENTS;case"UseOC":return Ml.LAYERS}return Ml.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.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=zh,t.isPortraitOrientation=Wl,t.isValidRotation=zl,t.isValidScrollMode=Ul,t.isValidSpreadMode=$l,t.normalizeWheelEventDelta=Vl,t.normalizeWheelEventDirection=Hl,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.watchScroll=Rl}));
|