@zeniai/web-cockpit-ui 2.3.21-dev → 2.3.22-dev

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.
Files changed (60) hide show
  1. package/dist/assets/{CreditAgentRoutes-moJLbhEX.js → CreditAgentRoutes-BSCovuK7.js} +2 -2
  2. package/dist/assets/{Editor-CbBxvSmp-C_jDBK45.js → Editor-BJM3mxbk-BU69M__x.js} +10 -10
  3. package/dist/assets/{Preview-Bi907R7d.js → Preview-DCMYHdXQ.js} +1 -1
  4. package/dist/assets/{ScreenRoutes-DBIjAKtT.js → ScreenRoutes-DmPLNUiN.js} +33 -33
  5. package/dist/assets/SignInScreen-C_mQUaNg.js +1 -0
  6. package/dist/assets/{TaskDescriptionEditor-DyTyMxvk-CDpdNbKO.js → TaskDescriptionEditor-CfKh5nux-CYkybSv3.js} +3 -3
  7. package/dist/assets/{analytics-D6rU2phb.js → analytics-BQp5eAef.js} +36 -36
  8. package/dist/assets/{analyticsHelper-9zdI2_60.js → analyticsHelper-BmbVDhM3.js} +1 -1
  9. package/dist/assets/{apple-wallet-DMr790ZM-DUQOY6Dc.js → apple-wallet-DMr790ZM-hJUMgrL7.js} +1 -1
  10. package/dist/assets/{bank-verification-HpVi21UA-BeKlMSCu.js → bank-verification-HpVi21UA-DKO2vlVi.js} +1 -1
  11. package/dist/assets/{core-B3-F7eBr.js → core-Tp-f995F.js} +1 -1
  12. package/dist/assets/{dash.all.min-DcSmBiNR.js → dash.all.min-B--TWXqN.js} +1 -1
  13. package/dist/assets/{empty-BvT6gWa7.js → empty-8w7lnNDy.js} +1 -1
  14. package/dist/assets/{empty-CQ_4F6AL.js → empty-C8aelB8k.js} +1 -1
  15. package/dist/assets/{epic-DGxFS5aI.js → epic-B57YvH__.js} +2 -2
  16. package/dist/assets/{index-BbtpQSrw.js → index-BG2KSZUN.js} +1 -1
  17. package/dist/assets/{index-ovt9Xz6x.js → index-BGcLWwYU.js} +4847 -4810
  18. package/dist/assets/{index-DZRDjwaC.js → index-BYZPrbCg.js} +1 -1
  19. package/dist/assets/{index-D9Ex1U6B.js → index-BpRINGji.js} +1 -1
  20. package/dist/assets/{index-Bsjk-vms.js → index-BzUwg4A1.js} +2 -2
  21. package/dist/assets/{index-B_T8blia.js → index-D414nesG.js} +1 -1
  22. package/dist/assets/{index-DpXUK-2V.js → index-WQvcJj05.js} +3 -3
  23. package/dist/assets/{index-TjJI1T_l.js → index-zdSvBS0s.js} +1 -1
  24. package/dist/assets/{lexical-C9tRwoBl.js → lexical-Q_iSNeyd.js} +1 -1
  25. package/dist/assets/{liveblocks-CyhgjAmM.js → liveblocks-C_j2EWYR.js} +1 -1
  26. package/dist/assets/{lottie-CaZsq4ox.js → lottie-jwG43yRg.js} +1 -1
  27. package/dist/assets/{mcdonalds-logo-BTFuGR4i-BcsmRWp0.js → mcdonalds-logo-BTFuGR4i-CTNbDGA4.js} +1 -1
  28. package/dist/assets/{mercury-logo-Xd1WsXHh-CcGfsdFc.js → mercury-logo-Xd1WsXHh-Cf80nNAe.js} +1 -1
  29. package/dist/assets/{mercury-logo-dark-WebeUx9w-DDvE2mnq.js → mercury-logo-dark-WebeUx9w-BwS0mI_e.js} +1 -1
  30. package/dist/assets/{more-providers-avatars-Dt7HPmCt-D7fl3oXk.js → more-providers-avatars-Dt7HPmCt-C7TIBQMk.js} +1 -1
  31. package/dist/assets/{mui-DF3cXn7x.js → mui-B8_UdfTU.js} +1 -1
  32. package/dist/assets/{netsuite-logo-Dp53a_wk-DHhfSa5A.js → netsuite-logo-Dp53a_wk-BXIQRuSU.js} +1 -1
  33. package/dist/assets/{netsuite-logo-dark-C53BYo7C-slTYfQG6.js → netsuite-logo-dark-C53BYo7C-YFaW3rm9.js} +1 -1
  34. package/dist/assets/{paypal-logo-RhbjaD58-BEMjEPiS.js → paypal-logo-RhbjaD58-D_dwib76.js} +1 -1
  35. package/dist/assets/{paypal-logo-dark-_jTZA_FH-Cc9Dr3f1.js → paypal-logo-dark-_jTZA_FH-BTTOnj80.js} +1 -1
  36. package/dist/assets/{phone-otp-DI7iHM2C-DaB1jXjs.js → phone-otp-DI7iHM2C-D9pJ_Zhf.js} +1 -1
  37. package/dist/assets/{react-BL5QuQiL.js → react-13t95lOq.js} +1 -1
  38. package/dist/assets/{react-BFTgt5Nr.js → react-B1uOCHuc.js} +1 -1
  39. package/dist/assets/{react-B_2gErNA.js → react-BXXll-B8.js} +2 -2
  40. package/dist/assets/{react-DgoxEFcu.js → react-Bcj2vUCr.js} +1 -1
  41. package/dist/assets/{react-CSvt5NVX.js → react-BvNaFZi7.js} +1 -1
  42. package/dist/assets/{react-TFqk2ULt.js → react-C-_fkWly.js} +1 -1
  43. package/dist/assets/{react-CEc9o3j_.js → react-CPuPLrAm.js} +1 -1
  44. package/dist/assets/{react-XUzH62MA.js → react-NI50CDSW.js} +1 -1
  45. package/dist/assets/{recharts-mBO0sQiJ.js → recharts-BmU4Su4y.js} +1 -1
  46. package/dist/assets/{sentry-CMq56eOF.js → sentry-CsmEj6N0.js} +1 -1
  47. package/dist/assets/{subway-logo-B-Kc0fke-tO7AD_Vb.js → subway-logo-B-Kc0fke-Bfnr4OA4.js} +1 -1
  48. package/dist/assets/{underline-BNKkE4Fr-DOksg_Rq.js → underline-BZ7JVlVm-C0t97YDn.js} +1 -1
  49. package/dist/assets/url-44QIqvix.js +6 -0
  50. package/dist/assets/{url-YDIkIjen.js → url-DI-fObeY.js} +1 -1
  51. package/dist/assets/utils-C03h8lYk.js +36 -0
  52. package/dist/assets/{vendor-react-lottie-player-Qhg4gMF8-B6KA4tHZ.js → vendor-react-lottie-player-Qhg4gMF8-DXPhrNgs.js} +1 -1
  53. package/dist/assets/{zeni-card-trust-BpxZYDve-QOGaaPs2.js → zeni-card-trust-BpxZYDve-Duf5vkpY.js} +1 -1
  54. package/dist/assets/{zeni-epic-state-XxVgcdSL.js → zeni-epic-state-Djpn9hBU.js} +5 -5
  55. package/dist/assets/{zeni-thanksgiving-logo-full-BLmLHEXd-D9EXpClk.js → zeni-thanksgiving-logo-full-BLmLHEXd-ChwuYBTE.js} +1 -1
  56. package/dist/index.html +1 -1
  57. package/package.json +4 -4
  58. package/dist/assets/SignInScreen-4aU3_vW0.js +0 -1
  59. package/dist/assets/url-BGsWubiD.js +0 -6
  60. package/dist/assets/utils-DegUrf4b.js +0 -36
@@ -1,6 +1,6 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/empty-BvT6gWa7.js","assets/sentry-CMq56eOF.js","assets/empty-CQ_4F6AL.js","assets/index-DZRDjwaC.js","assets/index-BbtpQSrw.js","assets/zeni-epic-state-XxVgcdSL.js","assets/core-B3-F7eBr.js","assets/utils-DegUrf4b.js","assets/recharts-mBO0sQiJ.js","assets/url-BGsWubiD.js","assets/index-B_T8blia.js","assets/index-TjJI1T_l.js","assets/url-YDIkIjen.js"])))=>i.map(i=>d[i]);
2
- import{H as Bs,bd as Le}from"./zeni-epic-state-XxVgcdSL.js";import{p as ie,g as pn,a as C}from"./sentry-CMq56eOF.js";import{j as z}from"./liveblocks-CyhgjAmM.js";import{V as H,c as he}from"./recharts-mBO0sQiJ.js";import"./core-B3-F7eBr.js";(function(){try{var l=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new l.Error().stack;t&&(l._sentryDebugIds=l._sentryDebugIds||{},l._sentryDebugIds[t]="a6b5baa6-aba9-474c-839d-75f41d56b3c0",l._sentryDebugIdIdentifier="sentry-dbid-a6b5baa6-aba9-474c-839d-75f41d56b3c0")}catch{}})();var Ae={};Ae.d=(l,t)=>{for(var e in t)Ae.o(t,e)&&!Ae.o(l,e)&&Object.defineProperty(l,e,{enumerable:!0,get:t[e]})};Ae.o=(l,t)=>Object.prototype.hasOwnProperty.call(l,t);var M=globalThis.pdfjsLib={};Ae.d(M,{AbortException:()=>Zt,AnnotationEditorLayer:()=>Ht,AnnotationEditorParamsType:()=>D,AnnotationEditorType:()=>N,AnnotationEditorUIManager:()=>Gt,AnnotationLayer:()=>ua,AnnotationMode:()=>zt,CMapCompressionType:()=>cs,ColorPicker:()=>Mt,DOMSVGFactory:()=>Ss,DrawLayer:()=>dt,FeatureTest:()=>vt,GlobalWorkerOptions:()=>ye,ImageKind:()=>Oe,InvalidPDFException:()=>mi,MissingPDFException:()=>Jt,OPS:()=>Pt,Outliner:()=>vs,PDFDataRangeTransport:()=>Ii,PDFDateString:()=>wi,PDFWorker:()=>Tt,PasswordResponses:()=>vn,PermissionFlag:()=>bn,PixelsPerInch:()=>le,RenderingCancelledException:()=>xs,TextLayer:()=>Be,UnexpectedResponseException:()=>ze,Util:()=>R,VerbosityLevel:()=>je,XfaLayer:()=>Fi,build:()=>Wr,createValidAbsoluteUrl:()=>wn,fetchData:()=>Ye,getDocument:()=>Nr,getFilenameFromUrl:()=>Mn,getPdfFilenameFromUrl:()=>In,getXfaPageViewport:()=>Dn,isDataScheme:()=>Cs,isPdfFile:()=>Ts,noContextMenu:()=>At,normalizeUnicode:()=>Pn,renderTextLayer:()=>Pr,setLayerDimensions:()=>Yt,shadow:()=>B,updateTextLayer:()=>Rr,version:()=>Vr});const ut=typeof ie=="object"&&ie+""=="[object process]"&&!ie.versions.nw&&!(ie.versions.electron&&ie.type&&ie.type!=="browser"),gi=[1,0,0,1,0,0],hs=[.001,0,0,.001,0,0],gn=1e7,es=1.35,Ct={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256},zt={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},mn="pdfjs_internal_editor_",N={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},D={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35},bn={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},ct={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},Oe={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},st={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,WIDGET:20},pe={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},je={ERRORS:0,WARNINGS:1,INFOS:5},cs={NONE:0,BINARY:1},Pt={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91},vn={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let $e=je.WARNINGS;function An(l){Number.isInteger(l)&&($e=l)}function yn(){return $e}function Ue(l){$e>=je.INFOS&&console.log(`Info: ${l}`)}function F(l){$e>=je.WARNINGS&&console.log(`Warning: ${l}`)}function V(l){throw new Error(l)}function nt(l,t){l||V(t)}function _n(l){switch(l?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function wn(l,t=null,e=null){if(!l)return null;try{if(e&&typeof l=="string"&&(e.addDefaultProtocol&&l.startsWith("www.")&&l.match(/\./g)?.length>=2&&(l=`http://${l}`),e.tryConvertEncoding))try{l=Tn(l)}catch{}const s=t?new URL(l,t):new URL(l);if(_n(s))return s}catch{}return null}function B(l,t,e,s=!1){return Object.defineProperty(l,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Wt=(function(){function t(e,s){this.constructor===t&&V("Cannot initialize BaseException."),this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class ds extends Wt{constructor(t,e){super(t,"PasswordException"),this.code=e}}class us extends Wt{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class mi extends Wt{constructor(t){super(t,"InvalidPDFException")}}class Jt extends Wt{constructor(t){super(t,"MissingPDFException")}}class ze extends Wt{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class En extends Wt{constructor(t){super(t,"FormatError")}}class Zt extends Wt{constructor(t){super(t,"AbortException")}}function bi(l){(typeof l!="object"||l?.length===void 0)&&V("Invalid argument for bytesToString");const t=l.length,e=8192;if(t<e)return String.fromCharCode.apply(null,l);const s=[];for(let i=0;i<t;i+=e){const n=Math.min(i+e,t),r=l.subarray(i,n);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function Ge(l){typeof l!="string"&&V("Invalid argument for stringToBytes");const t=l.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=l.charCodeAt(s)&255;return e}function Sn(l){return String.fromCharCode(l>>24&255,l>>16&255,l>>8&255,l&255)}function ws(l){const t=Object.create(null);for(const[e,s]of l)t[e]=s;return t}function xn(){const l=new Uint8Array(4);return l[0]=1,new Uint32Array(l.buffer,0,1)[0]===1}function Cn(){try{return new Function(""),!0}catch{return!1}}class vt{static get isLittleEndian(){return B(this,"isLittleEndian",xn())}static get isEvalSupported(){return B(this,"isEvalSupported",Cn())}static get isOffscreenCanvasSupported(){return B(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof navigator?.platform=="string"?B(this,"platform",{isMac:navigator.platform.includes("Mac")}):B(this,"platform",{isMac:!1})}static get isCSSRoundSupported(){return B(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const ss=Array.from(Array(256).keys(),l=>l.toString(16).padStart(2,"0"));class R{static makeHexColor(t,e,s){return`#${ss[t]}${ss[e]}${ss[s]}`}static scaleMinMax(t,e){let s;t[0]?(t[0]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[3],e[3]*=t[3]):(s=e[0],e[0]=e[1],e[1]=s,s=e[2],e[2]=e[3],e[3]=s,t[1]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(s=e[0],e[0]=e[2],e[2]=s),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){const s=t[0]*e[0]+t[1]*e[2]+e[4],i=t[0]*e[1]+t[1]*e[3]+e[5];return[s,i]}static applyInverseTransform(t,e){const s=e[0]*e[3]-e[1]*e[2],i=(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/s,n=(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s;return[i,n]}static getAxialAlignedBoundingBox(t,e){const s=this.applyTransform(t,e),i=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(s[0],i[0],n[0],r[0]),Math.min(s[1],i[1],n[1],r[1]),Math.max(s[0],i[0],n[0],r[0]),Math.max(s[1],i[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]],s=t[0]*e[0]+t[1]*e[2],i=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=(s+r)/2,o=Math.sqrt((s+r)**2-4*(s*r-n*i))/2,c=a+o||1,h=a-o||1;return[Math.sqrt(c),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 s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)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:[s,n,i,r]}static#t(t,e,s,i,n,r,a,o,c,h){if(c<=0||c>=1)return;const d=1-c,u=c*c,p=u*c,f=d*(d*(d*t+3*c*e)+3*u*s)+p*i,g=d*(d*(d*n+3*c*r)+3*u*a)+p*o;h[0]=Math.min(h[0],f),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],f),h[3]=Math.max(h[3],g)}static#e(t,e,s,i,n,r,a,o,c,h,d,u){if(Math.abs(c)<1e-12){Math.abs(h)>=1e-12&&this.#t(t,e,s,i,n,r,a,o,-d/h,u);return}const p=h**2-4*d*c;if(p<0)return;const f=Math.sqrt(p),g=2*c;this.#t(t,e,s,i,n,r,a,o,(-h+f)/g,u),this.#t(t,e,s,i,n,r,a,o,(-h-f)/g,u)}static bezierBoundingBox(t,e,s,i,n,r,a,o,c){return c?(c[0]=Math.min(c[0],t,a),c[1]=Math.min(c[1],e,o),c[2]=Math.max(c[2],t,a),c[3]=Math.max(c[3],e,o)):c=[Math.min(t,a),Math.min(e,o),Math.max(t,a),Math.max(e,o)],this.#e(t,s,n,a,e,i,r,o,3*(-t+3*(s-n)+a),6*(t-2*s+n),3*(s-t),c),this.#e(t,s,n,a,e,i,r,o,3*(-e+3*(i-r)+o),6*(e-2*i+r),3*(i-e),c),c}}function Tn(l){return decodeURIComponent(escape(l))}let is=null,js=null;function Pn(l){return is||(is=/([\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,js=new Map([["ſt","ſt"]])),l.replaceAll(is,(t,e,s)=>e?e.normalize("NFKC"):js.get(s))}function Rn(){if(typeof crypto<"u"&&typeof crypto?.randomUUID=="function")return crypto.randomUUID();const l=new Uint8Array(32);if(typeof crypto<"u"&&typeof crypto?.getRandomValues=="function")crypto.getRandomValues(l);else for(let t=0;t<32;t++)l[t]=Math.floor(Math.random()*255);return bi(l)}const vi="pdfjs_internal_id_",Ft={BEZIER_CURVE_TO:0,MOVE_TO:1,LINE_TO:2,QUADRATIC_CURVE_TO:3,RESTORE:4,SAVE:5,SCALE:6,TRANSFORM:7,TRANSLATE:8};class Ve{constructor(){this.constructor===Ve&&V("Cannot initialize BaseFilterFactory.")}addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,n){return"none"}destroy(t=!1){}}class We{#t=!1;constructor({enableHWA:t=!1}={}){this.constructor===We&&V("Cannot initialize BaseCanvasFactory."),this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#t})}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}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){V("Abstract method `_createCanvas` called.")}}class qe{constructor({baseUrl:t=null,isCompressed:e=!0}){this.constructor===qe&&V("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, 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":""),s=this.isCompressed?cs.BINARY:cs.NONE;return this._fetchData(e,s).catch(i=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}_fetchData(t,e){V("Abstract method `_fetchData` called.")}}class Xe{constructor({baseUrl:t=null}){this.constructor===Xe&&V("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, 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._fetchData(e).catch(s=>{throw new Error(`Unable to load font data at: ${e}`)})}_fetchData(t){V("Abstract method `_fetchData` called.")}}class Es{constructor(){this.constructor===Es&&V("Cannot initialize BaseSVGFactory.")}create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){V("Abstract method `_createSVG` called.")}}const Nt="http://www.w3.org/2000/svg";class le{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}class Ln extends Ve{#t;#e;#s;#n;#o;#i=0;constructor({docId:t,ownerDocument:e=globalThis.document}={}){super(),this.#s=t,this.#n=e}get#r(){return this.#t||=new Map}get#l(){return this.#o||=new Map}get#c(){if(!this.#e){const t=this.#n.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 s=this.#n.createElementNS(Nt,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#e=this.#n.createElementNS(Nt,"defs"),t.append(s),s.append(this.#e),this.#n.body.append(t)}return this.#e}#d(t){if(t.length===1){const o=t[0],c=new Array(256);for(let d=0;d<256;d++)c[d]=o[d]/255;const h=c.join(",");return[h,h,h]}const[e,s,i]=t,n=new Array(256),r=new Array(256),a=new Array(256);for(let o=0;o<256;o++)n[o]=e[o]/255,r[o]=s[o]/255,a[o]=i[o]/255;return[n.join(","),r.join(","),a.join(",")]}addFilter(t){if(!t)return"none";let e=this.#r.get(t);if(e)return e;const[s,i,n]=this.#d(t),r=t.length===1?s:`${s}${i}${n}`;if(e=this.#r.get(r),e)return this.#r.set(t,e),e;const a=`g_${this.#s}_transfer_map_${this.#i++}`,o=`url(#${a})`;this.#r.set(t,o),this.#r.set(r,o);const c=this.#a(a);return this.#m(s,i,n,c),o}addHCMFilter(t,e){const s=`${t}-${e}`,i="base";let n=this.#l.get(i);if(n?.key===s||(n?(n.filter?.remove(),n.key=s,n.url="none",n.filter=null):(n={key:s,url:"none",filter:null},this.#l.set(i,n)),!t||!e))return n.url;const r=this.#v(t);t=R.makeHexColor(...r);const a=this.#v(e);if(e=R.makeHexColor(...a),this.#c.style.color="",t==="#000000"&&e==="#ffffff"||t===e)return n.url;const o=new Array(256);for(let p=0;p<=255;p++){const f=p/255;o[p]=f<=.03928?f/12.92:((f+.055)/1.055)**2.4}const c=o.join(","),h=`g_${this.#s}_hcm_filter`,d=n.filter=this.#a(h);this.#m(c,c,c,d),this.#h(d);const u=(p,f)=>{const g=r[p]/255,b=a[p]/255,m=new Array(f+1);for(let v=0;v<=f;v++)m[v]=g+v/f*(b-g);return m.join(",")};return this.#m(u(0,5),u(1,5),u(2,5),d),n.url=`url(#${h})`,n.url}addAlphaFilter(t){let e=this.#r.get(t);if(e)return e;const[s]=this.#d([t]),i=`alpha_${s}`;if(e=this.#r.get(i),e)return this.#r.set(t,e),e;const n=`g_${this.#s}_alpha_map_${this.#i++}`,r=`url(#${n})`;this.#r.set(t,r),this.#r.set(i,r);const a=this.#a(n);return this.#u(s,a),r}addLuminosityFilter(t){let e=this.#r.get(t||"luminosity");if(e)return e;let s,i;if(t?([s]=this.#d([t]),i=`luminosity_${s}`):i="luminosity",e=this.#r.get(i),e)return this.#r.set(t,e),e;const n=`g_${this.#s}_luminosity_map_${this.#i++}`,r=`url(#${n})`;this.#r.set(t,r),this.#r.set(i,r);const a=this.#a(n);return this.#f(a),t&&this.#u(s,a),r}addHighlightHCMFilter(t,e,s,i,n){const r=`${e}-${s}-${i}-${n}`;let a=this.#l.get(t);if(a?.key===r||(a?(a.filter?.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},this.#l.set(t,a)),!e||!s))return a.url;const[o,c]=[e,s].map(this.#v.bind(this));let h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[u,p]=[i,n].map(this.#v.bind(this));d<h&&([h,d,u,p]=[d,h,p,u]),this.#c.style.color="";const f=(m,v,y)=>{const A=new Array(256),_=(d-h)/y,w=m/255,E=(v-m)/(255*y);let x=0;for(let S=0;S<=y;S++){const L=Math.round(h+S*_),P=w+S*E;for(let G=x;G<=L;G++)A[G]=P;x=L+1}for(let S=x;S<256;S++)A[S]=A[x-1];return A.join(",")},g=`g_${this.#s}_hcm_${t}_filter`,b=a.filter=this.#a(g);return this.#h(b),this.#m(f(u[0],p[0],5),f(u[1],p[1],5),f(u[2],p[2],5),b),a.url=`url(#${g})`,a.url}destroy(t=!1){t&&this.#l.size!==0||(this.#e&&(this.#e.parentNode.parentNode.remove(),this.#e=null),this.#t&&(this.#t.clear(),this.#t=null),this.#i=0)}#f(t){const e=this.#n.createElementNS(Nt,"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)}#h(t){const e=this.#n.createElementNS(Nt,"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)}#a(t){const e=this.#n.createElementNS(Nt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#c.append(e),e}#p(t,e,s){const i=this.#n.createElementNS(Nt,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),t.append(i)}#m(t,e,s,i){const n=this.#n.createElementNS(Nt,"feComponentTransfer");i.append(n),this.#p(n,"feFuncR",t),this.#p(n,"feFuncG",e),this.#p(n,"feFuncB",s)}#u(t,e){const s=this.#n.createElementNS(Nt,"feComponentTransfer");e.append(s),this.#p(s,"feFuncA",t)}#v(t){return this.#c.style.color=t,Ps(getComputedStyle(this.#c).getPropertyValue("color"))}}class kn extends We{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}={}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}async function Ye(l,t="text"){if(be(l,document.baseURI)){const e=await fetch(l);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",l,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class Ai extends qe{_fetchData(t,e){return Ye(t,this.isCompressed?"arraybuffer":"text").then(s=>({cMapData:s instanceof ArrayBuffer?new Uint8Array(s):Ge(s),compressionType:e}))}}class yi extends Xe{_fetchData(t){return Ye(t,"arraybuffer").then(e=>new Uint8Array(e))}}class Ss extends Es{_createSVG(t){return document.createElementNS(Nt,t)}}class we{constructor({viewBox:t,scale:e,rotation:s,offsetX:i=0,offsetY:n=0,dontFlip:r=!1}){this.viewBox=t,this.scale=e,this.rotation=s,this.offsetX=i,this.offsetY=n;const a=(t[2]+t[0])/2,o=(t[3]+t[1])/2;let c,h,d,u;switch(s%=360,s<0&&(s+=360),s){case 180:c=-1,h=0,d=0,u=1;break;case 90:c=0,h=1,d=1,u=0;break;case 270:c=0,h=-1,d=-1,u=0;break;case 0:c=1,h=0,d=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}r&&(d=-d,u=-u);let p,f,g,b;c===0?(p=Math.abs(o-t[1])*e+i,f=Math.abs(a-t[0])*e+n,g=(t[3]-t[1])*e,b=(t[2]-t[0])*e):(p=Math.abs(a-t[0])*e+i,f=Math.abs(o-t[1])*e+n,g=(t[2]-t[0])*e,b=(t[3]-t[1])*e),this.transform=[c*e,h*e,d*e,u*e,p-c*e*a-d*e*o,f-h*e*a-u*e*o],this.width=g,this.height=b}get rawDims(){const{viewBox:t}=this;return B(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new we({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){return R.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=R.applyTransform([t[0],t[1]],this.transform),s=R.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return R.applyInverseTransform([t,e],this.transform)}}class xs extends Wt{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Cs(l){const t=l.length;let e=0;for(;e<t&&l[e].trim()==="";)e++;return l.substring(e,e+5).toLowerCase()==="data:"}function Ts(l){return typeof l=="string"&&/\.pdf$/i.test(l)}function Mn(l){return[l]=l.split(/[#?]/,1),l.substring(l.lastIndexOf("/")+1)}function In(l,t="document.pdf"){if(typeof l!="string")return t;if(Cs(l))return F('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const e=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,s=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=e.exec(l);let n=s.exec(i[1])||s.exec(i[2])||s.exec(i[3]);if(n&&(n=n[0],n.includes("%")))try{n=s.exec(decodeURIComponent(n))[0]}catch{}return n||t}class $s{started=Object.create(null);times=[];time(t){t in this.started&&F(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||F(`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:s}of this.times)e=Math.max(s.length,e);for(const{name:s,start:i,end:n}of this.times)t.push(`${s.padEnd(e)} ${n-i}ms
3
- `);return t.join("")}}function be(l,t){try{const{protocol:e}=t?new URL(l,t):new URL(l);return e==="http:"||e==="https:"}catch{return!1}}function At(l){l.preventDefault()}function _i(l){console.log("Deprecated API usage: "+l)}let Us;class wi{static toDateObject(t){if(!t||typeof t!="string")return null;Us||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=Us.exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-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 c=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,c==="-"?(r+=h,a+=d):c==="+"&&(r-=h,a-=d),new Date(Date.UTC(s,i,n,r,a,o))}}function Dn(l,{scale:t=1,rotation:e=0}){const{width:s,height:i}=l.attributes.style,n=[0,0,parseInt(s),parseInt(i)];return new we({viewBox:n,scale:t,rotation:e})}function Ps(l){if(l.startsWith("#")){const t=parseInt(l.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return l.startsWith("rgb(")?l.slice(4,-1).split(",").map(t=>parseInt(t)):l.startsWith("rgba(")?l.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(F(`Not a valid color format: "${l}"`),[0,0,0])}function Fn(l){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const e of l.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;l.set(e,Ps(s))}t.remove()}function Y(l){const{a:t,b:e,c:s,d:i,e:n,f:r}=l.getTransform();return[t,e,s,i,n,r]}function Ot(l){const{a:t,b:e,c:s,d:i,e:n,f:r}=l.getTransform().invertSelf();return[t,e,s,i,n,r]}function Yt(l,t,e=!1,s=!0){if(t instanceof we){const{pageWidth:i,pageHeight:n}=t.rawDims,{style:r}=l,a=vt.isCSSRoundSupported,o=`var(--scale-factor) * ${i}px`,c=`var(--scale-factor) * ${n}px`,h=a?`round(${o}, 1px)`:`calc(${o})`,d=a?`round(${c}, 1px)`:`calc(${c})`;!e||t.rotation%180===0?(r.width=h,r.height=d):(r.width=d,r.height=h)}s&&l.setAttribute("data-main-rotation",t.rotation)}class Rs{#t=null;#e=null;#s;#n=null;constructor(t){this.#s=t}render(){const t=this.#t=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");const e=this.#s._uiManager._signal;t.addEventListener("contextmenu",At,{signal:e}),t.addEventListener("pointerdown",Rs.#o,{signal:e});const s=this.#n=document.createElement("div");s.className="buttons",t.append(s);const i=this.#s.toolbarPosition;if(i){const{style:n}=t,r=this.#s._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=`${100*r}%`,n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return this.#c(),t}static#o(t){t.stopPropagation()}#i(t){this.#s._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()}#r(t){this.#s._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()}#l(t){const e=this.#s._uiManager._signal;t.addEventListener("focusin",this.#i.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#r.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",At,{signal:e})}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden")}#c(){const t=document.createElement("button");t.className="delete",t.tabIndex=0,t.setAttribute("data-l10n-id",`pdfjs-editor-remove-${this.#s.editorType}-button`),this.#l(t),t.addEventListener("click",e=>{this.#s._uiManager.delete()},{signal:this.#s._uiManager._signal}),this.#n.append(t)}get#d(){const t=document.createElement("div");return t.className="divider",t}addAltTextButton(t){this.#l(t),this.#n.prepend(t,this.#d)}addColorPicker(t){this.#e=t;const e=t.renderButton();this.#l(e),this.#n.prepend(e,this.#d)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class On{#t=null;#e=null;#s;constructor(t){this.#s=t}#n(){const t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",At,{signal:this.#s._signal});const e=this.#t=document.createElement("div");return e.className="buttons",t.append(e),this.#i(),t}#o(t,e){let s=0,i=0;for(const n of t){const r=n.y+n.height;if(r<s)continue;const a=n.x+(e?n.width:0);if(r>s){i=a,s=r;continue}e?a>i&&(i=a):a<i&&(i=a)}return[e?1-i:i,s]}show(t,e,s){const[i,n]=this.#o(e,s),{style:r}=this.#e||=this.#n();t.append(this.#e),r.insetInlineEnd=`${100*i}%`,r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#i(){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 s=this.#s._signal;t.addEventListener("contextmenu",At,{signal:s}),t.addEventListener("click",()=>{this.#s.highlightSelection("floating_button")},{signal:s}),this.#t.append(t)}}function Ne(l,t,e){for(const s of e)t.addEventListener(s,l[s].bind(l))}function Nn(l){return Math.round(Math.min(255,Math.max(1,255*l))).toString(16).padStart(2,"0")}class Hn{#t=0;get id(){return`${mn}${this.#t++}`}}class Ls{#t=Rn();#e=0;#s=null;static get _isSVGFittingCanvas(){const t='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>',s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;const n=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return B(this,"_isSVGFittingCanvas",n)}async#n(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{s||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let i;if(typeof e=="string"?(s.url=e,i=await Ye(e,"blob")):i=s.file=e,i.type==="image/svg+xml"){const n=Ls._isSVGFittingCanvas,r=new FileReader,a=new Image,o=new Promise((c,h)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,c()},r.onload=async()=>{const d=s.svgUrl=r.result;a.src=await n?`${d}#svgView(preserveAspectRatio(none))`:d},a.onerror=r.onerror=h});r.readAsDataURL(i),await o}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){console.error(i),s=null}return this.#s.set(t,s),s&&this.#s.set(s.id,s),s}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return this.#n(`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return this.#n(t,t)}async getFromId(t){this.#s||=new Map;const e=this.#s.get(t);return e?e.bitmap?(e.refCounter+=1,e):e.file?this.getFromFile(e.file):this.getFromUrl(e.url):null}getSvgUrl(t){const e=this.#s.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#s||=new Map;const e=this.#s.get(t);e&&(e.refCounter-=1,e.refCounter===0&&(e.bitmap=null))}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class Bn{#t=[];#e=!1;#s;#n=-1;constructor(t=128){this.#s=t}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(i&&t(),this.#e)return;const o={cmd:t,undo:e,post:s,type:n};if(this.#n===-1){this.#t.length>0&&(this.#t.length=0),this.#n=0,this.#t.push(o);return}if(r&&this.#t[this.#n].type===n){a&&(o.undo=this.#t[this.#n].undo),this.#t[this.#n]=o;return}const c=this.#n+1;c===this.#s?this.#t.splice(0,1):(this.#n=c,c<this.#t.length&&this.#t.splice(c)),this.#t.push(o)}undo(){if(this.#n===-1)return;this.#e=!0;const{undo:t,post:e}=this.#t[this.#n];t(),e?.(),this.#e=!1,this.#n-=1}redo(){if(this.#n<this.#t.length-1){this.#n+=1,this.#e=!0;const{cmd:t,post:e}=this.#t[this.#n];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#n!==-1}hasSomethingToRedo(){return this.#n<this.#t.length-1}destroy(){this.#t=null}}class Ee{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=vt.platform;for(const[s,i,n={}]of t)for(const r of s){const a=r.startsWith("mac+");e&&a?(this.callbacks.set(r.slice(4),{callback:i,options:n}),this.allKeys.add(r.split("+").at(-1))):!e&&!a&&(this.callbacks.set(r,{callback:i,options:n}),this.allKeys.add(r.split("+").at(-1)))}}#t(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(this.#t(e));if(!s)return;const{callback:i,options:{bubbles:n=!1,args:r=[],checker:a=null}}=s;a&&!a(t,e)||(i.bind(t,...r,e)(),n||(e.stopPropagation(),e.preventDefault()))}}class ks{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return Fn(t),B(this,"_colors",t)}convert(t){const e=Ps(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((n,r)=>n===e[r]))return ks._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?R.makeHexColor(...e):t}}class Gt{#t=new AbortController;#e=null;#s=new Map;#n=new Map;#o=null;#i=null;#r=null;#l=new Bn;#c=0;#d=new Set;#f=null;#h=null;#a=new Set;#p=!1;#m=null;#u=null;#v=null;#g=!1;#A=null;#_=new Hn;#E=!1;#x=!1;#C=null;#L=null;#S=null;#y=N.NONE;#b=new Set;#w=null;#T=null;#P=null;#M=this.blur.bind(this);#k=this.focus.bind(this);#F=this.copy.bind(this);#I=this.cut.bind(this);#O=this.paste.bind(this);#D=this.keydown.bind(this);#G=this.keyup.bind(this);#V=this.onEditingAction.bind(this);#U=this.onPageChanging.bind(this);#j=this.onScaleChanging.bind(this);#N=this.onRotationChanging.bind(this);#Y={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#z=[0,0];#H=null;#$=null;#K=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=Gt.prototype,e=r=>r.#$.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),s=(r,{target:a})=>{if(a instanceof HTMLInputElement){const{type:o}=a;return o!=="text"&&o!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return B(this,"_keyboardManager",new Ee([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.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"],t.delete,{checker:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#$.contains(a)&&!r.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#$.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,s,i,n,r,a,o,c){this._signal=this.#t.signal,this.#$=t,this.#K=e,this.#o=s,this._eventBus=i,this._eventBus._on("editingaction",this.#V),this._eventBus._on("pagechanging",this.#U),this._eventBus._on("scalechanging",this.#j),this._eventBus._on("rotationchanging",this.#N),this.#nt(),this.#lt(),this.#Q(),this.#i=n.annotationStorage,this.#m=n.filterFactory,this.#T=r,this.#v=a||null,this.#p=o,this.#S=c||null,this.viewParameters={realScale:le.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}destroy(){this.#t?.abort(),this.#t=null,this._signal=null,this._eventBus._off("editingaction",this.#V),this._eventBus._off("pagechanging",this.#U),this._eventBus._off("scalechanging",this.#j),this._eventBus._off("rotationchanging",this.#N);for(const t of this.#n.values())t.destroy();this.#n.clear(),this.#s.clear(),this.#a.clear(),this.#e=null,this.#b.clear(),this.#l.destroy(),this.#o?.destroy(),this.#A?.hide(),this.#A=null,this.#u&&(clearTimeout(this.#u),this.#u=null),this.#H&&(clearTimeout(this.#H),this.#H=null)}async mlGuess(t){return this.#S?.guess(t)||null}get hasMLManager(){return!!this.#S}get hcmFilter(){return B(this,"hcmFilter",this.#T?this.#m.addHCMFilter(this.#T.foreground,this.#T.background):"none")}get direction(){return B(this,"direction",getComputedStyle(this.#$).direction)}get highlightColors(){return B(this,"highlightColors",this.#v?new Map(this.#v.split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return B(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setMainHighlightColorPicker(t){this.#L=t}editAltText(t){this.#o?.editAltText(this,t)}onPageChanging({pageNumber:t}){this.#c=t-1}focusMainContainer(){this.#$.focus()}findParent(t,e){for(const s of this.#n.values()){const{x:i,y:n,width:r,height:a}=s.div.getBoundingClientRect();if(t>=i&&t<=i+r&&e>=n&&e<=n+a)return s}return null}disableUserSelect(t=!1){this.#K.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#a.add(t)}removeShouldRescale(t){this.#a.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*le.PDF_TO_CSS_UNITS;for(const e of this.#a)e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#q({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r}=e,a=e.toString(),c=this.#q(e).closest(".textLayer"),h=this.getSelectionBoxes(c);if(h){e.empty(),this.#y===N.NONE&&(this._eventBus.dispatch("showannotationeditorui",{source:this,mode:N.HIGHLIGHT}),this.showAllEditors("highlight",!0,!0));for(const d of this.#n.values())if(d.hasTextLayer(c)){d.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r,text:a});break}}}#st(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=this.#q(t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(this.#A||=new On(this),this.#A.show(s,i,this.direction==="ltr"))}addToAnnotationStorage(t){!t.isEmpty()&&this.#i&&!this.#i.has(t.id)&&this.#i.setValue(t.id,t)}#it(){const t=document.getSelection();if(!t||t.isCollapsed){this.#w&&(this.#A?.hide(),this.#w=null,this.#R({hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===this.#w)return;if(!this.#q(t).closest(".textLayer")){this.#w&&(this.#A?.hide(),this.#w=null,this.#R({hasSelectedText:!1}));return}if(this.#A?.hide(),this.#w=e,this.#R({hasSelectedText:!0}),!(this.#y!==N.HIGHLIGHT&&this.#y!==N.NONE)&&(this.#y===N.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#g=this.isShiftKeyDown,!this.isShiftKeyDown)){const n=this._signal,r=a=>{a.type==="pointerup"&&a.button!==0||(window.removeEventListener("pointerup",r),window.removeEventListener("blur",r),a.type==="pointerup"&&this.#X("main_toolbar"))};window.addEventListener("pointerup",r,{signal:n}),window.addEventListener("blur",r,{signal:n})}}#X(t=""){this.#y===N.HIGHLIGHT?this.highlightSelection(t):this.#p&&this.#st()}#nt(){document.addEventListener("selectionchange",this.#it.bind(this),{signal:this._signal})}#rt(){const t=this._signal;window.addEventListener("focus",this.#k,{signal:t}),window.addEventListener("blur",this.#M,{signal:t})}#at(){window.removeEventListener("focus",this.#k),window.removeEventListener("blur",this.#M)}blur(){if(this.isShiftKeyDown=!1,this.#g&&(this.#g=!1,this.#X("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#b)if(e.div.contains(t)){this.#C=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#C)return;const[t,e]=this.#C;this.#C=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#Q(){const t=this._signal;window.addEventListener("keydown",this.#D,{signal:t}),window.addEventListener("keyup",this.#G,{signal:t})}#ot(){window.removeEventListener("keydown",this.#D),window.removeEventListener("keyup",this.#G)}#J(){const t=this._signal;document.addEventListener("copy",this.#F,{signal:t}),document.addEventListener("cut",this.#I,{signal:t}),document.addEventListener("paste",this.#O,{signal:t})}#Z(){document.removeEventListener("copy",this.#F),document.removeEventListener("cut",this.#I),document.removeEventListener("paste",this.#O)}#lt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#Q(),this.#J()}removeEditListeners(){this.#ot(),this.#Z()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of this.#h)if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of this.#h)if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const s of this.#b){const i=s.serialize(!0);i&&e.push(i)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}paste(t){t.preventDefault();const{clipboardData:e}=t;for(const n of e.items)for(const r of this.#h)if(r.isHandlingMimeForPasting(n.type)){r.paste(n,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){F(`paste: "${n.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const n=[];for(const o of s){const c=i.deserialize(o);if(!c)return;n.push(c)}const r=()=>{for(const o of n)this.#tt(o);this.#et(n)},a=()=>{for(const o of n)o.remove()};this.addCommands({cmd:r,undo:a,mustExec:!0})}catch(n){F(`paste: "${n.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#y!==N.NONE&&!this.isEditorHandlingKeyboard&&Gt._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#g&&(this.#g=!1,this.#X("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}#R(t){Object.entries(t).some(([s,i])=>this.#Y[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#Y,t)}),this.#y===N.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#B([[D.HIGHLIGHT_FREE,!0]]))}#B(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#rt(),this.#J(),this.#R({isEditing:this.#y!==N.NONE,isEmpty:this.#W(),hasSomethingToUndo:this.#l.hasSomethingToUndo(),hasSomethingToRedo:this.#l.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#at(),this.#Z(),this.#R({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#h){this.#h=t;for(const e of this.#h)this.#B(e.defaultPropertiesToUpdate)}}getId(){return this.#_.id}get currentLayer(){return this.#n.get(this.#c)}getLayer(t){return this.#n.get(t)}get currentPageIndex(){return this.#c}addLayer(t){this.#n.set(t.pageIndex,t),this.#E?t.enable():t.disable()}removeLayer(t){this.#n.delete(t.pageIndex)}updateMode(t,e=null,s=!1){if(this.#y!==t){if(this.#y=t,t===N.NONE){this.setEditingState(!1),this.#ct();return}this.setEditingState(!0),this.#ht(),this.unselectAll();for(const i of this.#n.values())i.updateMode(t);if(!e&&s){this.addNewEditorFromKeyboard();return}if(e){for(const i of this.#s.values())if(i.annotationElementId===e){this.setSelected(i),i.enterInEditMode();break}}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#y&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#h){switch(t){case D.CREATE:this.currentLayer.addNewEditor();return;case D.HIGHLIGHT_DEFAULT_COLOR:this.#L?.updateColor(e);break;case D.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#P||=new Map).set(t,e),this.showAllEditors("highlight",e);break}for(const s of this.#b)s.updateParams(t,e);for(const s of this.#h)s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){for(const n of this.#s.values())n.editorType===t&&n.show(e);(this.#P?.get(D.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#B([[D.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#x!==t){this.#x=t;for(const e of this.#n.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}#ht(){if(!this.#E){this.#E=!0;for(const t of this.#n.values())t.enable();for(const t of this.#s.values())t.enable()}}#ct(){if(this.unselectAll(),this.#E){this.#E=!1;for(const t of this.#n.values())t.disable();for(const t of this.#s.values())t.disable()}}getEditors(t){const e=[];for(const s of this.#s.values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return this.#s.get(t)}addEditor(t){this.#s.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#u&&clearTimeout(this.#u),this.#u=setTimeout(()=>{this.focusMainContainer(),this.#u=null},0)),this.#s.delete(t.id),this.unselect(t),(!t.annotationElementId||!this.#d.has(t.annotationElementId))&&this.#i?.remove(t.id)}addDeletedAnnotationElement(t){this.#d.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#d.has(t)}removeDeletedAnnotationElement(t){this.#d.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#tt(t){const e=this.#n.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#B(t.propertiesToUpdate))}get#dt(){let t=null;for(t of this.#b);return t}updateUI(t){this.#dt===t&&this.#B(t.propertiesToUpdate)}toggleSelected(t){if(this.#b.has(t)){this.#b.delete(t),t.unselect(),this.#R({hasSelectedEditor:this.hasSelection});return}this.#b.add(t),t.select(),this.#B(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}setSelected(t){for(const e of this.#b)e!==t&&e.unselect();this.#b.clear(),this.#b.add(t),t.select(),this.#B(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}isSelected(t){return this.#b.has(t)}get firstSelectedEditor(){return this.#b.values().next().value}unselect(t){t.unselect(),this.#b.delete(t),this.#R({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#b.size!==0}get isEnterHandled(){return this.#b.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#l.undo(),this.#R({hasSomethingToUndo:this.#l.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#W()})}redo(){this.#l.redo(),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:this.#l.hasSomethingToRedo(),isEmpty:this.#W()})}addCommands(t){this.#l.add(t),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#W()})}#W(){if(this.#s.size===0)return!0;if(this.#s.size===1)for(const t of this.#s.values())return t.isEmpty();return!1}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...this.#b],e=()=>{for(const i of t)i.remove()},s=()=>{for(const i of t)this.#tt(i)};this.addCommands({cmd:e,undo:s,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#et(t){for(const e of this.#b)e.unselect();this.#b.clear();for(const e of t)e.isEmpty()||(this.#b.add(e),e.select());this.#R({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#b)t.commit();this.#et(this.#s.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#y!==N.NONE))&&this.hasSelection){for(const t of this.#b)t.unselect();this.#b.clear(),this.#R({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;this.#z[0]+=t,this.#z[1]+=e;const[i,n]=this.#z,r=[...this.#b],a=1e3;this.#H&&clearTimeout(this.#H),this.#H=setTimeout(()=>{this.#H=null,this.#z[0]=this.#z[1]=0,this.addCommands({cmd:()=>{for(const o of r)this.#s.has(o.id)&&o.translateInPage(i,n)},undo:()=>{for(const o of r)this.#s.has(o.id)&&o.translateInPage(-i,-n)},mustExec:!1})},a);for(const o of r)o.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#f=new Map;for(const t of this.#b)this.#f.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#f)return!1;this.disableUserSelect(!1);const t=this.#f;this.#f=null;let e=!1;for(const[{x:i,y:n,pageIndex:r},a]of t)a.newX=i,a.newY=n,a.newPageIndex=r,e||=i!==a.savedX||n!==a.savedY||r!==a.savedPageIndex;if(!e)return!1;const s=(i,n,r,a)=>{if(this.#s.has(i.id)){const o=this.#n.get(a);o?i._setParentAndPosition(o,n,r):(i.pageIndex=a,i.x=n,i.y=r)}};return this.addCommands({cmd:()=>{for(const[i,{newX:n,newY:r,newPageIndex:a}]of t)s(i,n,r,a)},undo:()=>{for(const[i,{savedX:n,savedY:r,savedPageIndex:a}]of t)s(i,n,r,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#f)for(const s of this.#f.keys())s.drag(t,e)}rebuild(t){if(t.parent===null){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()||this.#b.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#y}get imageManager(){return B(this,"imageManager",new Ls)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let c=0,h=e.rangeCount;c<h;c++)if(!t.contains(e.getRangeAt(c).commonAncestorContainer))return null;const{x:s,y:i,width:n,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(c,h,d,u)=>({x:(h-i)/r,y:1-(c+d-s)/n,width:u/r,height:d/n});break;case"180":a=(c,h,d,u)=>({x:1-(c+d-s)/n,y:1-(h+u-i)/r,width:d/n,height:u/r});break;case"270":a=(c,h,d,u)=>({x:1-(h+u-i)/r,y:(c-s)/n,width:u/r,height:d/n});break;default:a=(c,h,d,u)=>({x:(c-s)/n,y:(h-i)/r,width:d/n,height:u/r});break}const o=[];for(let c=0,h=e.rangeCount;c<h;c++){const d=e.getRangeAt(c);if(!d.collapsed)for(const{x:u,y:p,width:f,height:g}of d.getClientRects())f===0||g===0||o.push(a(u,p,f,g))}return o.length===0?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 s=this.#i.getRawValue(e);s&&(this.#y===N.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}}class qt{#t="";#e=!1;#s=null;#n=null;#o=null;#i=!1;#r=null;static _l10nPromise=null;constructor(t){this.#r=t}static initialize(t){qt._l10nPromise||=t}async render(){const t=this.#s=document.createElement("button");t.className="altText";const e=await qt._l10nPromise.get("pdfjs-editor-alt-text-button-label");t.textContent=e,t.setAttribute("aria-label",e),t.tabIndex="0";const s=this.#r._uiManager._signal;t.addEventListener("contextmenu",At,{signal:s}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),this.#r._uiManager.editAltText(this.#r)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(this.#i=!0,i(n))},{signal:s}),await this.#l(),t}finish(){this.#s&&(this.#s.focus({focusVisible:this.#i}),this.#i=!1)}isEmpty(){return!this.#t&&!this.#e}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e}){this.#t===t&&this.#e===e||(this.#t=t,this.#e=e,this.#l())}toggle(t=!1){this.#s&&(!t&&this.#o&&(clearTimeout(this.#o),this.#o=null),this.#s.disabled=!t)}destroy(){this.#s?.remove(),this.#s=null,this.#n=null}async#l(){const t=this.#s;if(!t)return;if(!this.#t&&!this.#e){t.classList.remove("done"),this.#n?.remove();return}t.classList.add("done"),qt._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then(i=>{t.setAttribute("aria-label",i)});let e=this.#n;if(!e){this.#n=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip");const i=e.id=`alt-text-tooltip-${this.#r.id}`;t.setAttribute("aria-describedby",i);const n=100,r=this.#r._uiManager._signal;r.addEventListener("abort",()=>{clearTimeout(this.#o),this.#o=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#o=setTimeout(()=>{this.#o=null,this.#n.classList.add("show"),this.#r._reportTelemetry({action:"alt_text_tooltip"})},n)},{signal:r}),t.addEventListener("mouseleave",()=>{this.#o&&(clearTimeout(this.#o),this.#o=null),this.#n?.classList.remove("show")},{signal:r})}e.innerText=this.#e?await qt._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):this.#t,e.parentNode||t.append(e),this.#r.getImageForAltText()?.setAttribute("aria-describedby",e.id)}}class I{#t=null;#e=null;#s=null;#n=!1;#o=!1;#i=null;#r=null;#l=this.focusin.bind(this);#c=this.focusout.bind(this);#d=null;#f="";#h=!1;#a=null;#p=!1;#m=!1;#u=!1;#v=null;#g=0;#A=0;#_=null;_initialOptions=Object.create(null);_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;_l10nPromise=null;#E=!1;#x=I._zIndex++;static _borderLineWidth=-1;static _colorManager=new ks;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=I.prototype._resizeWithKeyboard,e=Gt.TRANSLATE_SMALL,s=Gt.TRANSLATE_BIG;return B(this,"_resizerKeyboardManager",new Ee([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape","mac+Escape"],I.prototype._stopResizingWithKeyboard]]))}constructor(t){this.constructor===I&&V("Cannot initialize AnnotationEditor."),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:s,pageHeight:i,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],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 _defaultLineColor(){return B(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new jn({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,s){if(I._l10nPromise||=new Map(["pdfjs-editor-alt-text-button-label","pdfjs-editor-alt-text-edit-button-label","pdfjs-editor-alt-text-decorative-tooltip","pdfjs-editor-resizer-label-topLeft","pdfjs-editor-resizer-label-topMiddle","pdfjs-editor-resizer-label-topRight","pdfjs-editor-resizer-label-middleRight","pdfjs-editor-resizer-label-bottomRight","pdfjs-editor-resizer-label-bottomMiddle","pdfjs-editor-resizer-label-bottomLeft","pdfjs-editor-resizer-label-middleLeft"].map(n=>[n,t.get(n.replaceAll(/([A-Z])/g,r=>`-${r.toLowerCase()}`))])),s?.strings)for(const n of s.strings)I._l10nPromise.set(n,t.get(n));if(I._borderLineWidth!==-1)return;const i=getComputedStyle(document.documentElement);I._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){V("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#E}set _isDraggable(t){this.#E=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/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}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.#x}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#D(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#h?this.#h=!1:this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||t.relatedTarget?.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,s,i){const[n,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/r,this.fixAndSetPosition()}#C([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this.fixAndSetPosition()}translate(t,e){this.#C(this.parentDimensions,t,e)}translateInPage(t,e){this.#a||=[this.x,this.y],this.#C(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#a||=[this.x,this.y];const[s,i]=this.parentDimensions;if(this.x+=t/s,this.y+=e/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:c,y:h}=this.div.getBoundingClientRect();this.parent.findNewParent(this,c,h)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:r}=this;const[a,o]=this.getBaseTranslation();n+=a,r+=o,this.div.style.left=`${(100*n).toFixed(2)}%`,this.div.style.top=`${(100*r).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!this.#a&&(this.#a[0]!==this.x||this.#a[1]!==this.y)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=I,i=s/t,n=s/e;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const[e,s]=this.pageDimensions;let{x:i,y:n,width:r,height:a}=this;if(r*=e,a*=s,i*=e,n*=s,this._mustFixPosition)switch(t){case 0:i=Math.max(0,Math.min(e-r,i)),n=Math.max(0,Math.min(s-a,n));break;case 90:i=Math.max(0,Math.min(e-a,i)),n=Math.min(s,Math.max(r,n));break;case 180:i=Math.min(e,Math.max(r,i)),n=Math.min(s,Math.max(a,n));break;case 270:i=Math.min(e,Math.max(a,i)),n=Math.max(0,Math.min(s-r,n));break}this.x=i/=e,this.y=n/=s;const[o,c]=this.getBaseTranslation();i+=o,n+=c;const{style:h}=this.div;h.left=`${(100*i).toFixed(2)}%`,h.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}static#L(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return I.#L(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return I.#L(t,e,360-this.parentRotation)}#S(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,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,s]}=this,i=e*t,n=s*t;return vt.isCSSRoundSupported?[Math.round(i),Math.round(n)]:[i,n]}setDims(t,e){const[s,i]=this.parentDimensions;this.div.style.width=`${(100*t/s).toFixed(2)}%`,this.#o||(this.div.style.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),n=!this.#o&&e.endsWith("%");if(i&&n)return;const[r,a]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/r).toFixed(2)}%`),!this.#o&&!n&&(t.height=`${(100*parseFloat(e)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#y(){if(this.#i)return;this.#i=document.createElement("div"),this.#i.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 s of t){const i=document.createElement("div");this.#i.append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",this.#b.bind(this,s),{signal:e}),i.addEventListener("contextmenu",At,{signal:e}),i.tabIndex=-1}this.div.prepend(this.#i)}#b(t,e){e.preventDefault();const{isMac:s}=vt.platform;if(e.button!==0||e.ctrlKey&&s)return;this.#s?.toggle(!1);const i=this.#T.bind(this,t),n=this._isDraggable;this._isDraggable=!1;const r=this._uiManager._signal,a={passive:!0,capture:!0,signal:r};this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",i,a),window.addEventListener("contextmenu",At,{signal:r});const o=this.x,c=this.y,h=this.width,d=this.height,u=this.parent.div.style.cursor,p=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const f=()=>{this.parent.togglePointerEvents(!0),this.#s?.toggle(!0),this._isDraggable=n,window.removeEventListener("pointerup",f),window.removeEventListener("blur",f),window.removeEventListener("pointermove",i,a),window.removeEventListener("contextmenu",At),this.parent.div.style.cursor=u,this.div.style.cursor=p,this.#w(o,c,h,d)};window.addEventListener("pointerup",f,{signal:r}),window.addEventListener("blur",f,{signal:r})}#w(t,e,s,i){const n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===s&&o===i||this.addCommands({cmd:()=>{this.width=a,this.height=o,this.x=n,this.y=r;const[c,h]=this.parentDimensions;this.setDims(c*a,h*o),this.fixAndSetPosition()},undo:()=>{this.width=s,this.height=i,this.x=t,this.y=e;const[c,h]=this.parentDimensions;this.setDims(c*s,h*i),this.fixAndSetPosition()},mustExec:!0})}#T(t,e){const[s,i]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,c=I.MIN_SIZE/s,h=I.MIN_SIZE/i,d=T=>Math.round(T*1e4)/1e4,u=this.#S(this.rotation),p=(T,k)=>[u[0]*T+u[2]*k,u[1]*T+u[3]*k],f=this.#S(360-this.rotation),g=(T,k)=>[f[0]*T+f[2]*k,f[1]*T+f[3]*k];let b,m,v=!1,y=!1;switch(t){case"topLeft":v=!0,b=(T,k)=>[0,0],m=(T,k)=>[T,k];break;case"topMiddle":b=(T,k)=>[T/2,0],m=(T,k)=>[T/2,k];break;case"topRight":v=!0,b=(T,k)=>[T,0],m=(T,k)=>[0,k];break;case"middleRight":y=!0,b=(T,k)=>[T,k/2],m=(T,k)=>[0,k/2];break;case"bottomRight":v=!0,b=(T,k)=>[T,k],m=(T,k)=>[0,0];break;case"bottomMiddle":b=(T,k)=>[T/2,k],m=(T,k)=>[T/2,0];break;case"bottomLeft":v=!0,b=(T,k)=>[0,k],m=(T,k)=>[T,0];break;case"middleLeft":y=!0,b=(T,k)=>[0,k/2],m=(T,k)=>[T,k/2];break}const A=b(a,o),_=m(a,o);let w=p(..._);const E=d(n+w[0]),x=d(r+w[1]);let S=1,L=1,[P,G]=this.screenToPageTranslation(e.movementX,e.movementY);if([P,G]=g(P/s,G/i),v){const T=Math.hypot(a,o);S=L=Math.max(Math.min(Math.hypot(_[0]-A[0]-P,_[1]-A[1]-G)/T,1/a,1/o),c/a,h/o)}else y?S=Math.max(c,Math.min(1,Math.abs(_[0]-A[0]-P)))/a:L=Math.max(h,Math.min(1,Math.abs(_[1]-A[1]-G)))/o;const j=d(a*S),O=d(o*L);w=p(...m(j,O));const $=E-w[0],U=x-w[1];this.width=j,this.height=O,this.x=$,this.y=U,this.setDims(s*j,i*O),this.fixAndSetPosition()}altTextFinish(){this.#s?.finish()}async addEditToolbar(){return this.#d||this.#m?this.#d:(this.#d=new Rs(this),this.div.append(this.#d.render()),this.#s&&this.#d.addAltTextButton(await this.#s.render()),this.#d)}removeEditToolbar(){this.#d&&(this.#d.remove(),this.#d=null,this.#s?.destroy())}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#s||(qt.initialize(I._l10nPromise),this.#s=new qt(this),this.#t&&(this.#s.data=this.#t,this.#t=null),await this.addEditToolbar())}get altTextData(){return this.#s?.data}set altTextData(t){this.#s&&(this.#s.data=t)}hasAltText(){return!this.#s?.isEmpty()}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.#n?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground();const t=this._uiManager._signal;this.div.addEventListener("focusin",this.#l,{signal:t}),this.div.addEventListener("focusout",this.#c,{signal:t});const[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*s/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,n]=this.getInitialTranslation();return this.translate(i,n),Ne(this,this.div,["pointerdown"]),this.div}pointerdown(t){const{isMac:e}=vt.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#h=!0,this._isDraggable){this.#M(t);return}this.#P(t)}#P(t){const{isMac:e}=vt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#M(t){const e=this._uiManager.isSelected(this);this._uiManager.setUpDragSession();let s,i;const n=this._uiManager._signal;e&&(this.div.classList.add("moving"),s={passive:!0,capture:!0,signal:n},this.#g=t.clientX,this.#A=t.clientY,i=a=>{const{clientX:o,clientY:c}=a,[h,d]=this.screenToPageTranslation(o-this.#g,c-this.#A);this.#g=o,this.#A=c,this._uiManager.dragSelectedEditors(h,d)},window.addEventListener("pointermove",i,s));const r=()=>{window.removeEventListener("pointerup",r),window.removeEventListener("blur",r),e&&(this.div.classList.remove("moving"),window.removeEventListener("pointermove",i,s)),this.#h=!1,this._uiManager.endDragSession()||this.#P(t)};window.addEventListener("pointerup",r,{signal:n}),window.addEventListener("blur",r,{signal:n})}moveInDOM(){this.#v&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.#v=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition()}getRect(t,e,s=this.rotation){const i=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,c=t/i,h=e/i,d=this.x*n,u=this.y*r,p=this.width*n,f=this.height*r;switch(s){case 0:return[d+c+a,r-u-h-f+o,d+c+p+a,r-u-h+o];case 90:return[d+h+a,r-u+c+o,d+h+f+a,r-u+c+p+o];case 180:return[d-c-p+a,r-u+h+o,d-c+a,r-u+h+f+o];case 270:return[d-h-f+a,r-u-c-p+o,d-h+a,r-u-c+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,r]=t,a=n-s,o=r-i;switch(this.rotation){case 0:return[s,e-r,a,o];case 90:return[s,e-i,o,a];case 180:return[n,e-i,a,o];case 270:return[n,e-r,o,a];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){this.#m=!0}disableEditMode(){this.#m=!1}isInEditMode(){return this.#m}shouldGetKeyboardEvents(){return this.#u}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){const t=this._uiManager._signal;this.div?.addEventListener("focusin",this.#l,{signal:t}),this.div?.addEventListener("focusout",this.#c,{signal:t})}rotate(t){}serialize(t=!1,e=null){V("An editor must be serializable")}static deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s});i.rotation=t.rotation,i.#t=t.accessibilityData;const[n,r]=i.pageDimensions,[a,o,c,h]=i.getRectInCurrentCoords(t.rect,r);return i.x=a/n,i.y=o/r,i.width=c/n,i.height=h/r,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.div.removeEventListener("focusin",this.#l),this.div.removeEventListener("focusout",this.#c),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#v&&(clearTimeout(this.#v),this.#v=null),this.#D(),this.removeEditToolbar(),this.#_){for(const t of this.#_.values())clearTimeout(t);this.#_=null}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#y(),this.#i.classList.remove("hidden"),Ne(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#r={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#i.children;if(!this.#e){this.#e=Array.from(e);const r=this.#k.bind(this),a=this.#F.bind(this),o=this._uiManager._signal;for(const c of this.#e){const h=c.getAttribute("data-resizer-name");c.setAttribute("role","spinbutton"),c.addEventListener("keydown",r,{signal:o}),c.addEventListener("blur",a,{signal:o}),c.addEventListener("focus",this.#I.bind(this,h),{signal:o}),I._l10nPromise.get(`pdfjs-editor-resizer-label-${h}`).then(d=>c.setAttribute("aria-label",d))}}const s=this.#e[0];let i=0;for(const r of e){if(r===s)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(n!==i){if(n<i)for(let a=0;a<i-n;a++)this.#i.append(this.#i.firstChild);else if(n>i)for(let a=0;a<n-i;a++)this.#i.firstChild.before(this.#i.lastChild);let r=0;for(const a of e){const c=this.#e[r++].getAttribute("data-resizer-name");I._l10nPromise.get(`pdfjs-editor-resizer-label-${c}`).then(h=>a.setAttribute("aria-label",h))}}this.#O(0),this.#u=!0,this.#i.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#k(t){I._resizerKeyboardManager.exec(this,t)}#F(t){this.#u&&t.relatedTarget?.parentNode!==this.#i&&this.#D()}#I(t){this.#f=this.#u?t:""}#O(t){if(this.#e)for(const e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#u&&this.#T(this.#f,{movementX:t,movementY:e})}#D(){if(this.#u=!1,this.#O(-1),this.#r){const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=this.#r;this.#w(t,e,s,i),this.#r=null}}_stopResizingWithKeyboard(){this.#D(),this.div.focus()}select(){if(this.makeResizable(),this.div?.classList.add("selectedEditor"),!this.#d){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this.#d?.show()});return}this.#d?.show()}unselect(){this.#i?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this.#d?.hide()}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#p}set isEditing(t){this.#p=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#o=!0;const s=t/e,{style:i}=this.div;i.aspectRatio=s,i.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.#_||=new Map;const{action:s}=t;let i=this.#_.get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#_.delete(s),this.#_.size===0&&(this.#_=null)},I._telemetryTimeout),this.#_.set(s,i);return}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.#n=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#n=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstChild:e}=t.container;e.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class jn extends I{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}const zs=3285377520,xt=4294901760,Lt=65535;class Ei{constructor(t){this.h1=t?t&4294967295:zs,this.h2=t?t&4294967295:zs}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let g=0,b=t.length;g<b;g++){const m=t.charCodeAt(g);m<=255?e[s++]=m:(e[s++]=m>>>8,e[s++]=m&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,n=s-i*4,r=new Uint32Array(e.buffer,0,i);let a=0,o=0,c=this.h1,h=this.h2;const d=3432918353,u=461845907,p=d&Lt,f=u&Lt;for(let g=0;g<i;g++)g&1?(a=r[g],a=a*d&xt|a*p&Lt,a=a<<15|a>>>17,a=a*u&xt|a*f&Lt,c^=a,c=c<<13|c>>>19,c=c*5+3864292196):(o=r[g],o=o*d&xt|o*p&Lt,o=o<<15|o>>>17,o=o*u&xt|o*f&Lt,h^=o,h=h<<13|h>>>19,h=h*5+3864292196);switch(a=0,n){case 3:a^=e[i*4+2]<<16;case 2:a^=e[i*4+1]<<8;case 1:a^=e[i*4],a=a*d&xt|a*p&Lt,a=a<<15|a>>>17,a=a*u&xt|a*f&Lt,i&1?c^=a:h^=a}this.h1=c,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&xt|t*36045&Lt,e=e*4283543511&xt|((e<<16|t>>>16)*2950163797&xt)>>>16,t^=e>>>1,t=t*444984403&xt|t*60499&Lt,e=e*3301882366&xt|((e<<16|t>>>16)*3120437893&xt)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const fs=Object.freeze({map:null,hash:"",transfer:void 0});class Ms{#t=!1;#e=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=this.#e.get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return this.#e.get(t)}remove(t){if(this.#e.delete(t),this.#e.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of this.#e.values())if(e instanceof I)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=this.#e.get(t);let i=!1;if(s!==void 0)for(const[n,r]of Object.entries(e))s[n]!==r&&(i=!0,s[n]=r);else i=!0,this.#e.set(t,e);i&&this.#s(),e instanceof I&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#e.has(t)}getAll(){return this.#e.size>0?ws(this.#e):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return this.#e.size}#s(){this.#t||(this.#t=!0,typeof this.onSetModified=="function"&&this.onSetModified())}resetModified(){this.#t&&(this.#t=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Si(this)}get serializable(){if(this.#e.size===0)return fs;const t=new Map,e=new Ei,s=[],i=Object.create(null);let n=!1;for(const[r,a]of this.#e){const o=a instanceof I?a.serialize(!1,i):a;o&&(t.set(r,o),e.update(`${r}:${JSON.stringify(o)}`),n||=!!o.bitmap)}if(n)for(const r of t.values())r.bitmap&&s.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:fs}get editorStats(){let t=null;const e=new Map;for(const s of this.#e.values()){if(!(s instanceof I))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:n}=i;e.has(n)||e.set(n,Object.getPrototypeOf(s).constructor),t||=Object.create(null);const r=t[n]||=new Map;for(const[a,o]of Object.entries(i)){if(a==="type")continue;let c=r.get(a);c||(c=new Map,r.set(a,c));const h=c.get(o)??0;c.set(o,h+1)}}for(const[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}}class Si extends Ms{#t;constructor(t){super();const{map:e,hash:s,transfer:i}=t.serializable,n=structuredClone(e,i?{transfer:i}:null);this.#t={map:n,hash:s,transfer:i}}get print(){V("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}}class $n{#t=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.#t.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||this.#t.has(t.loadedName))){if(nt(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:i,style:n}=t,r=new FontFace(s,i,n);this.addNativeFontFace(r);try{await r.load(),this.#t.add(s),e?.(t)}catch{F(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}return}V("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){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw F(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){const t=!!this._document?.fonts;return B(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(ut||typeof navigator<"u"&&typeof navigator?.userAgent=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),B(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(nt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const n=s.shift();setTimeout(n.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return B(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(A,_){return A.charCodeAt(_)<<24|A.charCodeAt(_+1)<<16|A.charCodeAt(_+2)<<8|A.charCodeAt(_+3)&255}function i(A,_,w,E){const x=A.substring(0,_),S=A.substring(_+w);return x+E+S}let n,r;const a=this._document.createElement("canvas");a.width=1,a.height=1;const o=a.getContext("2d");let c=0;function h(A,_){if(++c>30){F("Load test font never loaded."),_();return}if(o.font="30px "+A,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0){_();return}setTimeout(h.bind(null,A,_))}const d=`lt${Date.now()}${this.loadTestFontId++}`;let u=this._loadTestFont;u=i(u,976,d.length,d);const f=16,g=1482184792;let b=s(u,f);for(n=0,r=d.length-3;n<r;n+=4)b=b-g+s(d,n)|0;n<d.length&&(b=b-g+s(d+"XXX",n)|0),u=i(u,f,4,Sn(b));const m=`url(data:font/opentype;base64,${btoa(u)});`,v=`@font-face {font-family:"${d}";src:${m}}`;this.insertRule(v);const y=this._document.createElement("div");y.style.visibility="hidden",y.style.width=y.style.height="10px",y.style.position="absolute",y.style.top=y.style.left="0px";for(const A of[t.loadedName,d]){const _=this._document.createElement("span");_.textContent="Hi",_.style.fontFamily=A,y.append(_)}this._document.body.append(y),h(d,()=>{y.remove(),e.complete()})}}class Un{constructor(t,{disableFontFace:e=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const i in t)this[i]=t[i];this.disableFontFace=e===!0,this._inspectFont=s}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{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)}return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=bi(this.data),e=`url(data:${this.mimetype};base64,${btoa(t)});`;let s;if(!this.cssFontInfo)s=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),s=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${e}}`}return this._inspectFont?.(this,e),s}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];let s;try{s=t.get(this.loadedName+"_path_"+e)}catch(n){F(`getPathGenerator - ignoring character: "${n}".`)}if(!Array.isArray(s)||s.length===0)return this.compiledGlyphs[e]=function(n,r){};const i=[];for(let n=0,r=s.length;n<r;)switch(s[n++]){case Ft.BEZIER_CURVE_TO:{const[a,o,c,h,d,u]=s.slice(n,n+6);i.push(p=>p.bezierCurveTo(a,o,c,h,d,u)),n+=6}break;case Ft.MOVE_TO:{const[a,o]=s.slice(n,n+2);i.push(c=>c.moveTo(a,o)),n+=2}break;case Ft.LINE_TO:{const[a,o]=s.slice(n,n+2);i.push(c=>c.lineTo(a,o)),n+=2}break;case Ft.QUADRATIC_CURVE_TO:{const[a,o,c,h]=s.slice(n,n+4);i.push(d=>d.quadraticCurveTo(a,o,c,h)),n+=4}break;case Ft.RESTORE:i.push(a=>a.restore());break;case Ft.SAVE:i.push(a=>a.save());break;case Ft.SCALE:nt(i.length===2,"Scale command is only valid at the third position.");break;case Ft.TRANSFORM:{const[a,o,c,h,d,u]=s.slice(n,n+6);i.push(p=>p.transform(a,o,c,h,d,u)),n+=6}break;case Ft.TRANSLATE:{const[a,o]=s.slice(n,n+2);i.push(c=>c.translate(a,o)),n+=2}break}return this.compiledGlyphs[e]=function(r,a){i[0](r),i[1](r),r.scale(a,-a);for(let o=2,c=i.length;o<c;o++)i[o](r)}}}if(ut){var ps=Promise.withResolvers(),gs=null;(async()=>{const t=await Le(()=>import("./empty-BvT6gWa7.js").then(a=>a.e),__vite__mapDeps([0,1,2])),e=await Le(()=>import("./index-DZRDjwaC.js").then(a=>a.i),__vite__mapDeps([3,1,4,5,6,7,8,9])),s=await Le(()=>import("./index-B_T8blia.js").then(a=>a.i),__vite__mapDeps([10,1,11,4,5,6,7,8,9])),i=await Le(()=>import("./url-YDIkIjen.js").then(a=>a.u),__vite__mapDeps([12,1,9,7,5,6,8]));let n,r;return new Map(Object.entries({fs:t,http:e,https:s,url:i,canvas:n,path2d:r}))})().then(t=>{gs=t,ps.resolve()},t=>{F(`loadPackages: ${t}`),gs=new Map,ps.resolve()})}class Dt{static get promise(){return ps.promise}static get(t){return gs?.get(t)}}const xi=function(l){return Dt.get("fs").promises.readFile(l).then(e=>new Uint8Array(e))};class zn extends Ve{}class Gn extends We{_createCanvas(t,e){return Dt.get("canvas").createCanvas(t,e)}}class Vn extends qe{_fetchData(t,e){return xi(t).then(s=>({cMapData:s,compressionType:e}))}}class Wn extends Xe{_fetchData(t){return xi(t)}}const pt={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function ms(l,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),l.clip(i)}class Se{constructor(){this.constructor===Se&&V("Cannot initialize BaseShadingPattern.")}getPattern(){V("Abstract method `getPattern` called.")}}class qn extends Se{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;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)e.addColorStop(s[0],s[1]);return e}getPattern(t,e,s,i){let n;if(i===pt.STROKE||i===pt.FILL){const r=e.current.getClippedPathBoundingBox(i,Y(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,c=e.cachedCanvases.getCanvas("pattern",a,o,!0),h=c.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]),s=R.transform(s,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),ms(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),n=t.createPattern(c.canvas,"no-repeat");const d=new DOMMatrix(s);n.setTransform(d)}else ms(t,this._bbox),n=this._createGradient(t);return n}}function ns(l,t,e,s,i,n,r,a){const o=t.coords,c=t.colors,h=l.data,d=l.width*4;let u;o[e+1]>o[s+1]&&(u=e,e=s,s=u,u=n,n=r,r=u),o[s+1]>o[i+1]&&(u=s,s=i,i=u,u=r,r=a,a=u),o[e+1]>o[s+1]&&(u=e,e=s,s=u,u=n,n=r,r=u);const p=(o[e]+t.offsetX)*t.scaleX,f=(o[e+1]+t.offsetY)*t.scaleY,g=(o[s]+t.offsetX)*t.scaleX,b=(o[s+1]+t.offsetY)*t.scaleY,m=(o[i]+t.offsetX)*t.scaleX,v=(o[i+1]+t.offsetY)*t.scaleY;if(f>=v)return;const y=c[n],A=c[n+1],_=c[n+2],w=c[r],E=c[r+1],x=c[r+2],S=c[a],L=c[a+1],P=c[a+2],G=Math.round(f),j=Math.round(v);let O,$,U,T,k,yt,Et,$t;for(let Q=G;Q<=j;Q++){if(Q<b){const q=Q<f?0:(f-Q)/(f-b);O=p-(p-g)*q,$=y-(y-w)*q,U=A-(A-E)*q,T=_-(_-x)*q}else{let q;Q>v?q=1:b===v?q=0:q=(b-Q)/(b-v),O=g-(g-m)*q,$=w-(w-S)*q,U=E-(E-L)*q,T=x-(x-P)*q}let X;Q<f?X=0:Q>v?X=1:X=(f-Q)/(f-v),k=p-(p-m)*X,yt=y-(y-S)*X,Et=A-(A-L)*X,$t=_-(_-P)*X;const St=Math.round(Math.min(O,k)),_t=Math.round(Math.max(O,k));let ft=d*Q+St*4;for(let q=St;q<=_t;q++)X=(O-q)/(O-k),X<0?X=0:X>1&&(X=1),h[ft++]=$-($-yt)*X|0,h[ft++]=U-(U-Et)*X|0,h[ft++]=T-(T-$t)*X|0,h[ft++]=255}}function Xn(l,t,e){const s=t.coords,i=t.colors;let n,r;switch(t.type){case"lattice":const a=t.verticesPerRow,o=Math.floor(s.length/a)-1,c=a-1;for(n=0;n<o;n++){let h=n*a;for(let d=0;d<c;d++,h++)ns(l,e,s[h],s[h+1],s[h+a],i[h],i[h+1],i[h+a]),ns(l,e,s[h+a+1],s[h+1],s[h+a],i[h+a+1],i[h+1],i[h+a])}break;case"triangles":for(n=0,r=s.length;n<r;n+=3)ns(l,e,s[n],s[n+1],s[n+2],i[n],i[n+1],i[n+2]);break;default:throw new Error("illegal figure")}}class Yn extends Se{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,s){const a=Math.floor(this._bounds[0]),o=Math.floor(this._bounds[1]),c=Math.ceil(this._bounds[2])-a,h=Math.ceil(this._bounds[3])-o,d=Math.min(Math.ceil(Math.abs(c*t[0]*1.1)),3e3),u=Math.min(Math.ceil(Math.abs(h*t[1]*1.1)),3e3),p=c/d,f=h/u,g={coords:this._coords,colors:this._colors,offsetX:-a,offsetY:-o,scaleX:1/p,scaleY:1/f},b=d+4,m=u+4,v=s.getCanvas("mesh",b,m,!1),y=v.context,A=y.createImageData(d,u);if(e){const w=A.data;for(let E=0,x=w.length;E<x;E+=4)w[E]=e[0],w[E+1]=e[1],w[E+2]=e[2],w[E+3]=255}for(const w of this._figures)Xn(A,w,g);return y.putImageData(A,2,2),{canvas:v.canvas,offsetX:a-2*p,offsetY:o-2*f,scaleX:p,scaleY:f}}getPattern(t,e,s,i){ms(t,this._bbox);let n;if(i===pt.SHADING)n=R.singularValueDecompose2dScale(Y(t));else if(n=R.singularValueDecompose2dScale(e.baseTransform),this.matrix){const a=R.singularValueDecompose2dScale(this.matrix);n=[n[0]*a[0],n[1]*a[1]]}const r=this._createMeshCanvas(n,i===pt.SHADING?null:this._background,e.cachedCanvases);return i!==pt.SHADING&&(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 Kn extends Se{getPattern(){return"hotpink"}}function Qn(l){switch(l[0]){case"RadialAxial":return new qn(l);case"Mesh":return new Yn(l);case"Dummy":return new Kn}throw new Error(`Unknown IR type: ${l[0]}`)}const Gs={COLORED:1,UNCOLORED:2};class Is{static MAX_PATTERN_SIZE=3e3;constructor(t,e,s,i,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=s,this.canvasGraphicsFactory=i,this.baseTransform=n}createPatternCanvas(t){const e=this.operatorList,s=this.bbox,i=this.xstep,n=this.ystep,r=this.paintType,a=this.tilingType,o=this.color,c=this.canvasGraphicsFactory;Ue("TilingType: "+a);const h=s[0],d=s[1],u=s[2],p=s[3],f=R.singularValueDecompose2dScale(this.matrix),g=R.singularValueDecompose2dScale(this.baseTransform),b=[f[0]*g[0],f[1]*g[1]],m=this.getSizeAndScale(i,this.ctx.canvas.width,b[0]),v=this.getSizeAndScale(n,this.ctx.canvas.height,b[1]),y=t.cachedCanvases.getCanvas("pattern",m.size,v.size,!0),A=y.context,_=c.createCanvasGraphics(A);_.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(_,r,o);let w=h,E=d,x=u,S=p;return h<0&&(w=0,x+=Math.abs(h)),d<0&&(E=0,S+=Math.abs(d)),A.translate(-(m.scale*w),-(v.scale*E)),_.transform(m.scale,0,0,v.scale,0,0),A.save(),this.clipBbox(_,w,E,x,S),_.baseTransform=Y(_.ctx),_.executeOperatorList(e),_.endDrawing(),{canvas:y.canvas,scaleX:m.scale,scaleY:v.scale,offsetX:w,offsetY:E}}getSizeAndScale(t,e,s){t=Math.abs(t);const i=Math.max(Is.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*s);return n>=i?n=i:s=n/t,{scale:s,size:n}}clipBbox(t,e,s,i,n){const r=i-e,a=n-s;t.ctx.rect(e,s,r,a),t.current.updateRectMinMax(Y(t.ctx),[e,s,i,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,n=t.current;switch(e){case Gs.COLORED:const r=this.ctx;i.fillStyle=r.fillStyle,i.strokeStyle=r.strokeStyle,n.fillColor=r.fillStyle,n.strokeColor=r.strokeStyle;break;case Gs.UNCOLORED:const a=R.makeHexColor(s[0],s[1],s[2]);i.fillStyle=a,i.strokeStyle=a,n.fillColor=a,n.strokeColor=a;break;default:throw new En(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,i){let n=s;i!==pt.SHADING&&(n=R.transform(n,e.baseTransform),this.matrix&&(n=R.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 Jn({src:l,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:r=!1}){const a=vt.isLittleEndian?4278190080:255,[o,c]=r?[n,a]:[a,n],h=s>>3,d=s&7,u=l.length;e=new Uint32Array(e.buffer);let p=0;for(let f=0;f<i;f++){for(const b=t+h;t<b;t++){const m=t<u?l[t]:255;e[p++]=m&128?c:o,e[p++]=m&64?c:o,e[p++]=m&32?c:o,e[p++]=m&16?c:o,e[p++]=m&8?c:o,e[p++]=m&4?c:o,e[p++]=m&2?c:o,e[p++]=m&1?c:o}if(d===0)continue;const g=t<u?l[t++]:255;for(let b=0;b<d;b++)e[p++]=g&1<<7-b?c:o}return{srcPos:t,destPos:p}}const Vs=16,Ws=100,Zn=15,qs=10,Xs=1e3,bt=16;function tr(l,t){if(l._removeMirroring)throw new Error("Context is already forwarding operations.");l.__originalSave=l.save,l.__originalRestore=l.restore,l.__originalRotate=l.rotate,l.__originalScale=l.scale,l.__originalTranslate=l.translate,l.__originalTransform=l.transform,l.__originalSetTransform=l.setTransform,l.__originalResetTransform=l.resetTransform,l.__originalClip=l.clip,l.__originalMoveTo=l.moveTo,l.__originalLineTo=l.lineTo,l.__originalBezierCurveTo=l.bezierCurveTo,l.__originalRect=l.rect,l.__originalClosePath=l.closePath,l.__originalBeginPath=l.beginPath,l._removeMirroring=()=>{l.save=l.__originalSave,l.restore=l.__originalRestore,l.rotate=l.__originalRotate,l.scale=l.__originalScale,l.translate=l.__originalTranslate,l.transform=l.__originalTransform,l.setTransform=l.__originalSetTransform,l.resetTransform=l.__originalResetTransform,l.clip=l.__originalClip,l.moveTo=l.__originalMoveTo,l.lineTo=l.__originalLineTo,l.bezierCurveTo=l.__originalBezierCurveTo,l.rect=l.__originalRect,l.closePath=l.__originalClosePath,l.beginPath=l.__originalBeginPath,delete l._removeMirroring},l.save=function(){t.save(),this.__originalSave()},l.restore=function(){t.restore(),this.__originalRestore()},l.translate=function(s,i){t.translate(s,i),this.__originalTranslate(s,i)},l.scale=function(s,i){t.scale(s,i),this.__originalScale(s,i)},l.transform=function(s,i,n,r,a,o){t.transform(s,i,n,r,a,o),this.__originalTransform(s,i,n,r,a,o)},l.setTransform=function(s,i,n,r,a,o){t.setTransform(s,i,n,r,a,o),this.__originalSetTransform(s,i,n,r,a,o)},l.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},l.rotate=function(s){t.rotate(s),this.__originalRotate(s)},l.clip=function(s){t.clip(s),this.__originalClip(s)},l.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},l.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},l.bezierCurveTo=function(e,s,i,n,r,a){t.bezierCurveTo(e,s,i,n,r,a),this.__originalBezierCurveTo(e,s,i,n,r,a)},l.rect=function(e,s,i,n){t.rect(e,s,i,n),this.__originalRect(e,s,i,n)},l.closePath=function(){t.closePath(),this.__originalClosePath()},l.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class er{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s){let i;return this.cache[t]!==void 0?(i=this.cache[t],this.canvasFactory.reset(i,e,s)):(i=this.canvasFactory.create(e,s),this.cache[t]=i),i}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 ke(l,t,e,s,i,n,r,a,o,c){const[h,d,u,p,f,g]=Y(l);if(d===0&&u===0){const v=r*h+f,y=Math.round(v),A=a*p+g,_=Math.round(A),w=(r+o)*h+f,E=Math.abs(Math.round(w)-y)||1,x=(a+c)*p+g,S=Math.abs(Math.round(x)-_)||1;return l.setTransform(Math.sign(h),0,0,Math.sign(p),y,_),l.drawImage(t,e,s,i,n,0,0,E,S),l.setTransform(h,d,u,p,f,g),[E,S]}if(h===0&&p===0){const v=a*u+f,y=Math.round(v),A=r*d+g,_=Math.round(A),w=(a+c)*u+f,E=Math.abs(Math.round(w)-y)||1,x=(r+o)*d+g,S=Math.abs(Math.round(x)-_)||1;return l.setTransform(0,Math.sign(d),Math.sign(u),0,y,_),l.drawImage(t,e,s,i,n,0,0,S,E),l.setTransform(h,d,u,p,f,g),[S,E]}l.drawImage(t,e,s,i,n,r,a,o,c);const b=Math.hypot(h,d),m=Math.hypot(u,p);return[b*o,m*c]}function sr(l){const{width:t,height:e}=l;if(t>Xs||e>Xs)return null;const s=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=t+1;let r=new Uint8Array(n*(e+1)),a,o,c;const h=t+7&-8;let d=new Uint8Array(h*e),u=0;for(const m of l.data){let v=128;for(;v>0;)d[u++]=m&v?0:255,v>>=1}let p=0;for(u=0,d[u]!==0&&(r[0]=1,++p),o=1;o<t;o++)d[u]!==d[u+1]&&(r[o]=d[u]?2:1,++p),u++;for(d[u]!==0&&(r[o]=2,++p),a=1;a<e;a++){u=a*h,c=a*n,d[u-h]!==d[u]&&(r[c]=d[u]?1:8,++p);let m=(d[u]?4:0)+(d[u-h]?8:0);for(o=1;o<t;o++)m=(m>>2)+(d[u+1]?4:0)+(d[u-h+1]?8:0),i[m]&&(r[c+o]=i[m],++p),u++;if(d[u-h]!==d[u]&&(r[c+o]=d[u]?2:4,++p),p>s)return null}for(u=h*(e-1),c=a*n,d[u]!==0&&(r[c]=8,++p),o=1;o<t;o++)d[u]!==d[u+1]&&(r[c+o]=d[u]?4:8,++p),u++;if(d[u]!==0&&(r[c+o]=4,++p),p>s)return null;const f=new Int32Array([0,n,-1,0,-n,0,0,0,1]),g=new Path2D;for(a=0;p&&a<=e;a++){let m=a*n;const v=m+t;for(;m<v&&!r[m];)m++;if(m===v)continue;g.moveTo(m%n,a);const y=m;let A=r[m];do{const _=f[A];do m+=_;while(!r[m]);const w=r[m];w!==5&&w!==10?(A=w,r[m]=0):(A=w&51*A>>4,r[m]&=A>>2|A<<2),g.lineTo(m%n,m/n|0),r[m]||--p}while(y!==m);--a}return d=null,r=null,function(m){m.save(),m.scale(1/t,-1/e),m.translate(0,-e),m.fill(g),m.beginPath(),m.restore()}}class Ys{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=gi,this.textMatrixScale=1,this.fontMatrix=hs,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=ct.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!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,s){[e,s]=R.applyTransform([e,s],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,s)}updateRectMinMax(t,e){const s=R.applyTransform(e,t),i=R.applyTransform(e.slice(2),t),n=R.applyTransform([e[0],e[3]],t),r=R.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,s[0],i[0],n[0],r[0]),this.minY=Math.min(this.minY,s[1],i[1],n[1],r[1]),this.maxX=Math.max(this.maxX,s[0],i[0],n[0],r[0]),this.maxY=Math.max(this.maxY,s[1],i[1],n[1],r[1])}updateScalingPathMinMax(t,e){R.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,s,i,n,r,a,o,c,h){const d=R.bezierBoundingBox(e,s,i,n,r,a,o,c,h);h||this.updateRectMinMax(t,d)}getPathBoundingBox(t=pt.FILL,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===pt.STROKE){e||V("Stroke bounding box must include transform.");const i=R.singularValueDecompose2dScale(e),n=i[0]*this.lineWidth/2,r=i[1]*this.lineWidth/2;s[0]-=n,s[1]-=r,s[2]+=n,s[3]+=r}return s}updateClipFromPath(){const t=R.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=pt.FILL,e=null){return R.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Ks(l,t){if(typeof ImageData<"u"&&t instanceof ImageData){l.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%bt,n=(e-i)/bt,r=i===0?n:n+1,a=l.createImageData(s,bt);let o=0,c;const h=t.data,d=a.data;let u,p,f,g;if(t.kind===Oe.GRAYSCALE_1BPP){const b=h.byteLength,m=new Uint32Array(d.buffer,0,d.byteLength>>2),v=m.length,y=s+7>>3,A=4294967295,_=vt.isLittleEndian?4278190080:255;for(u=0;u<r;u++){for(f=u<n?bt:i,c=0,p=0;p<f;p++){const w=b-o;let E=0;const x=w>y?s:w*8-7,S=x&-8;let L=0,P=0;for(;E<S;E+=8)P=h[o++],m[c++]=P&128?A:_,m[c++]=P&64?A:_,m[c++]=P&32?A:_,m[c++]=P&16?A:_,m[c++]=P&8?A:_,m[c++]=P&4?A:_,m[c++]=P&2?A:_,m[c++]=P&1?A:_;for(;E<x;E++)L===0&&(P=h[o++],L=128),m[c++]=P&L?A:_,L>>=1}for(;c<v;)m[c++]=0;l.putImageData(a,0,u*bt)}}else if(t.kind===Oe.RGBA_32BPP){for(p=0,g=s*bt*4,u=0;u<n;u++)d.set(h.subarray(o,o+g)),o+=g,l.putImageData(a,0,p),p+=bt;u<r&&(g=s*i*4,d.set(h.subarray(o,o+g)),l.putImageData(a,0,p))}else if(t.kind===Oe.RGB_24BPP)for(f=bt,g=s*f,u=0;u<r;u++){for(u>=n&&(f=i,g=s*f),c=0,p=g;p--;)d[c++]=h[o++],d[c++]=h[o++],d[c++]=h[o++],d[c++]=255;l.putImageData(a,0,u*bt)}else throw new Error(`bad image kind: ${t.kind}`)}function Qs(l,t){if(t.bitmap){l.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%bt,n=(e-i)/bt,r=i===0?n:n+1,a=l.createImageData(s,bt);let o=0;const c=t.data,h=a.data;for(let d=0;d<r;d++){const u=d<n?bt:i;({srcPos:o}=Jn({src:c,srcPos:o,dest:h,width:s,height:u,nonBlackColor:0})),l.putImageData(a,0,d*bt)}}function ge(l,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)l[s]!==void 0&&(t[s]=l[s]);l.setLineDash!==void 0&&(t.setLineDash(l.getLineDash()),t.lineDashOffset=l.lineDashOffset)}function Me(l){if(l.strokeStyle=l.fillStyle="#000000",l.fillRule="nonzero",l.globalAlpha=1,l.lineWidth=1,l.lineCap="butt",l.lineJoin="miter",l.miterLimit=10,l.globalCompositeOperation="source-over",l.font="10px sans-serif",l.setLineDash!==void 0&&(l.setLineDash([]),l.lineDashOffset=0),!ut){const{filter:t}=l;t!=="none"&&t!==""&&(l.filter="none")}}function Js(l,t){if(t)return!0;const e=R.singularValueDecompose2dScale(l);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*le.PDF_TO_CSS_UNITS);return e[0]<=s&&e[1]<=s}const ir=["butt","round","square"],nr=["miter","round","bevel"],rr={},Zs={};class re{constructor(t,e,s,i,n,{optionalContentConfig:r,markedContentStack:a=null},o,c){this.ctx=t,this.current=new Ys(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=s,this.canvasFactory=i,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 er(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,s){const o=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=o.canvas,this.ctx=o.context,this.ctx.save(),this.ctx.transform(...Y(this.compositeCtx))}this.ctx.save(),Me(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=Y(this.ctx)}executeOperatorList(t,e,s,i){const n=t.argsArray,r=t.fnArray;let a=e||0;const o=n.length;if(o===a)return a;const c=o-a>qs&&typeof s=="function",h=c?Date.now()+Zn:0;let d=0;const u=this.commonObjs,p=this.objs;let f;for(;;){if(i!==void 0&&a===i.nextBreakPoint)return i.breakIt(a,s),a;if(f=r[a],f!==Pt.dependency)this[f].apply(this,n[a]);else for(const g of n[a]){const b=g.startsWith("g_")?u:p;if(!b.has(g))return b.get(g,s),a}if(a++,a===o)return a;if(c&&++d>qs){if(Date.now()>h)return s(),a;d=0}}}#t(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();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.#t(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#e()}#e(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){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 s=t.width,i=t.height;let n=Math.max(Math.hypot(e[0],e[1]),1),r=Math.max(Math.hypot(e[2],e[3]),1),a=s,o=i,c="prescale1",h,d;for(;n>2&&a>1||r>2&&o>1;){let u=a,p=o;n>2&&a>1&&(u=a>=16384?Math.floor(a/2)-1||1:Math.ceil(a/2),n/=a/u),r>2&&o>1&&(p=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o)/2,r/=o/p),h=this.cachedCanvases.getCanvas(c,u,p),d=h.context,d.clearRect(0,0,u,p),d.drawImage(t,0,0,a,o,0,0,u,p),t=h.canvas,a=u,o=p,c=c==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:a,paintHeight:o}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:i}=t,n=this.current.fillColor,r=this.current.patternFill,a=Y(e);let o,c,h,d;if((t.bitmap||t.data)&&t.count>1){const x=t.bitmap||t.data.buffer;c=JSON.stringify(r?a:[a.slice(0,4),n]),o=this._cachedBitmapsMap.get(x),o||(o=new Map,this._cachedBitmapsMap.set(x,o));const S=o.get(c);if(S&&!r){const L=Math.round(Math.min(a[0],a[2])+a[4]),P=Math.round(Math.min(a[1],a[3])+a[5]);return{canvas:S,offsetX:L,offsetY:P}}h=S}h||(d=this.cachedCanvases.getCanvas("maskCanvas",s,i),Qs(d.context,t));let u=R.transform(a,[1/s,0,0,-1/i,0,0]);u=R.transform(u,[1,0,0,1,0,-i]);const[p,f,g,b]=R.getAxialAlignedBoundingBox([0,0,s,i],u),m=Math.round(g-p)||1,v=Math.round(b-f)||1,y=this.cachedCanvases.getCanvas("fillCanvas",m,v),A=y.context,_=p,w=f;A.translate(-_,-w),A.transform(...u),h||(h=this._scaleImage(d.canvas,Ot(A)),h=h.img,o&&r&&o.set(c,h)),A.imageSmoothingEnabled=Js(Y(A),t.interpolate),ke(A,h,0,0,h.width,h.height,0,0,s,i),A.globalCompositeOperation="source-in";const E=R.transform(Ot(A),[1,0,0,1,-_,-w]);return A.fillStyle=r?n.getPattern(e,this,E,pt.FILL):n,A.fillRect(0,0,s,i),o&&!r&&(this.cachedCanvases.delete("fillCanvas"),o.set(c,y.canvas)),{canvas:y.canvas,offsetX:Math.round(_),offsetY:Math.round(w)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=ir[t]}setLineJoin(t){this.ctx.lineJoin=nr[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(t),s.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,s]of t)switch(e){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s[0],s[1]);break;case"CA":this.current.strokeAlpha=s;break;case"ca":this.current.fillAlpha=s,this.ctx.globalAlpha=s;break;case"BM":this.ctx.globalCompositeOperation=s;break;case"SMask":this.current.activeSMask=s?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s);break}}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,s="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(s,t,e);this.suspendedCtx=this.ctx,this.ctx=i.context;const n=this.ctx;n.setTransform(...Y(this.suspendedCtx)),ge(this.suspendedCtx,n),tr(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(),ge(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,s=this.suspendedCtx;this.composeSMask(s,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,s,i){const n=i[0],r=i[1],a=i[2]-n,o=i[3]-r;a===0||o===0||(this.genericComposeSMask(e.context,s,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(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,n,r,a,o,c,h,d){let u=t.canvas,p=o-h,f=c-d;if(r){if(p<0||f<0||p+s>u.width||f+i>u.height){const b=this.cachedCanvases.getCanvas("maskExtension",s,i),m=b.context;m.drawImage(u,-p,-f),r.some(v=>v!==0)&&(m.globalCompositeOperation="destination-atop",m.fillStyle=R.makeHexColor(...r),m.fillRect(0,0,s,i),m.globalCompositeOperation="source-over"),u=b.canvas,p=f=0}else if(r.some(b=>b!==0)){t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const b=new Path2D;b.rect(p,f,s,i),t.clip(b),t.globalCompositeOperation="destination-atop",t.fillStyle=R.makeHexColor(...r),t.fillRect(p,f,s,i),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),n==="Alpha"&&a?e.filter=this.filterFactory.addAlphaFilter(a):n==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(a));const g=new Path2D;g.rect(o,c,s,i),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(u,p,f,s,i,o,c,s,i),e.restore()}save(){this.inSMaskMode?(ge(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),ge(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,s,i,n,r){this.ctx.transform(t,e,s,i,n,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){const i=this.ctx,n=this.current;let r=n.x,a=n.y,o,c;const h=Y(i),d=h[0]===0&&h[3]===0||h[1]===0&&h[2]===0,u=d?s.slice(0):null;for(let p=0,f=0,g=t.length;p<g;p++)switch(t[p]|0){case Pt.rectangle:r=e[f++],a=e[f++];const b=e[f++],m=e[f++],v=r+b,y=a+m;i.moveTo(r,a),b===0||m===0?i.lineTo(v,y):(i.lineTo(v,a),i.lineTo(v,y),i.lineTo(r,y)),d||n.updateRectMinMax(h,[r,a,v,y]),i.closePath();break;case Pt.moveTo:r=e[f++],a=e[f++],i.moveTo(r,a),d||n.updatePathMinMax(h,r,a);break;case Pt.lineTo:r=e[f++],a=e[f++],i.lineTo(r,a),d||n.updatePathMinMax(h,r,a);break;case Pt.curveTo:o=r,c=a,r=e[f+4],a=e[f+5],i.bezierCurveTo(e[f],e[f+1],e[f+2],e[f+3],r,a),n.updateCurvePathMinMax(h,o,c,e[f],e[f+1],e[f+2],e[f+3],r,a,u),f+=6;break;case Pt.curveTo2:o=r,c=a,i.bezierCurveTo(r,a,e[f],e[f+1],e[f+2],e[f+3]),n.updateCurvePathMinMax(h,o,c,r,a,e[f],e[f+1],e[f+2],e[f+3],u),r=e[f+2],a=e[f+3],f+=4;break;case Pt.curveTo3:o=r,c=a,r=e[f+2],a=e[f+3],i.bezierCurveTo(e[f],e[f+1],r,a,r,a),n.updateCurvePathMinMax(h,o,c,e[f],e[f+1],r,a,r,a,u),f+=4;break;case Pt.closePath:i.closePath();break}d&&n.updateScalingPathMinMax(h,u),n.setCurrentPoint(r,a)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,s=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof s=="object"&&s?.getPattern?(e.save(),e.strokeStyle=s.getPattern(e,this,Ot(e),pt.STROKE),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,s=this.current.fillColor,i=this.current.patternFill;let n=!1;i&&(e.save(),e.fillStyle=s.getPattern(e,this,Ot(e),pt.FILL),n=!0);const r=this.current.getClippedPathBoundingBox();this.contentVisible&&r!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),n&&e.restore(),t&&this.consumePath(r)}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=rr}eoClip(){this.pendingClip=Zs}beginText(){this.current.textMatrix=gi,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(t===void 0){e.beginPath();return}e.save(),e.beginPath();for(const s of t)e.setTransform(...s.transform),e.translate(s.x,s.y),s.addToPath(e,s.fontSize);e.restore(),e.clip(),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 s=this.commonObjs.get(t),i=this.current;if(!s)throw new Error(`Can't find font for ${t}`);if(i.fontMatrix=s.fontMatrix||hs,(i.fontMatrix[0]===0||i.fontMatrix[3]===0)&&F("Invalid font matrix for font "+t),e<0?(e=-e,i.fontDirection=-1):i.fontDirection=1,this.current.font=s,this.current.fontSize=e,s.isType3Font)return;const n=s.loadedName||"sans-serif",r=s.systemFontInfo?.css||`"${n}", ${s.fallbackName}`;let a="normal";s.black?a="900":s.bold&&(a="bold");const o=s.italic?"italic":"normal";let c=e;e<Vs?c=Vs:e>Ws&&(c=Ws),this.current.fontSizeScale=e/c,this.ctx.font=`${o} ${a} ${c}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,s,i,n,r){this.current.textMatrix=[t,e,s,i,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)}paintChar(t,e,s,i){const n=this.ctx,r=this.current,a=r.font,o=r.textRenderingMode,c=r.fontSize/r.fontSizeScale,h=o&ct.FILL_STROKE_MASK,d=!!(o&ct.ADD_TO_PATH_FLAG),u=r.patternFill&&!a.missingFile;let p;(a.disableFontFace||d||u)&&(p=a.getPathGenerator(this.commonObjs,t)),a.disableFontFace||u?(n.save(),n.translate(e,s),n.beginPath(),p(n,c),i&&n.setTransform(...i),(h===ct.FILL||h===ct.FILL_STROKE)&&n.fill(),(h===ct.STROKE||h===ct.FILL_STROKE)&&n.stroke(),n.restore()):((h===ct.FILL||h===ct.FILL_STROKE)&&n.fillText(t,e,s),(h===ct.STROKE||h===ct.FILL_STROKE)&&n.strokeText(t,e,s)),d&&(this.pendingTextPaths||=[]).push({transform:Y(n),x:e,y:s,fontSize:c,addToPath:p})}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 s=!1;for(let i=3;i<e.length;i+=4)if(e[i]>0&&e[i]<255){s=!0;break}return B(this,"isFontSubpixelAAEnabled",s)}showText(t){const e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);const i=e.fontSize;if(i===0)return;const n=this.ctx,r=e.fontSizeScale,a=e.charSpacing,o=e.wordSpacing,c=e.fontDirection,h=e.textHScale*c,d=t.length,u=s.vertical,p=u?1:-1,f=s.defaultVMetrics,g=i*e.fontMatrix[0],b=e.textRenderingMode===ct.FILL&&!s.disableFontFace&&!e.patternFill;n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),c>0?n.scale(h,-1):n.scale(h,1);let m;if(e.patternFill){n.save();const w=e.fillColor.getPattern(n,this,Ot(n),pt.FILL);m=Y(n),n.restore(),n.fillStyle=w}let v=e.lineWidth;const y=e.textMatrixScale;if(y===0||v===0){const w=e.textRenderingMode&ct.FILL_STROKE_MASK;(w===ct.STROKE||w===ct.FILL_STROKE)&&(v=this.getSinglePixelWidth())}else v/=y;if(r!==1&&(n.scale(r,r),v/=r),n.lineWidth=v,s.isInvalidPDFjsFont){const w=[];let E=0;for(const x of t)w.push(x.unicode),E+=x.width;n.fillText(w.join(""),0,0),e.x+=E*g*h,n.restore(),this.compose();return}let A=0,_;for(_=0;_<d;++_){const w=t[_];if(typeof w=="number"){A+=p*w*i/1e3;continue}let E=!1;const x=(w.isSpace?o:0)+a,S=w.fontChar,L=w.accent;let P,G,j=w.width;if(u){const $=w.vmetric||f,U=-(w.vmetric?$[1]:j*.5)*g,T=$[2]*g;j=$?-$[0]:j,P=U/r,G=(A+T)/r}else P=A/r,G=0;if(s.remeasure&&j>0){const $=n.measureText(S).width*1e3/i*r;if(j<$&&this.isFontSubpixelAAEnabled){const U=j/$;E=!0,n.save(),n.scale(U,1),P/=U}else j!==$&&(P+=(j-$)/2e3*i/r)}if(this.contentVisible&&(w.isInFont||s.missingFile)){if(b&&!L)n.fillText(S,P,G);else if(this.paintChar(S,P,G,m),L){const $=P+i*L.offset.x/r,U=G-i*L.offset.y/r;this.paintChar(L.fontChar,$,U,m)}}const O=u?j*g-x*c:j*g+x*c;A+=O,E&&n.restore()}u?e.y-=A:e.x+=A*h,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,s=this.current,i=s.font,n=s.fontSize,r=s.fontDirection,a=i.vertical?1:-1,o=s.charSpacing,c=s.wordSpacing,h=s.textHScale*r,d=s.fontMatrix||hs,u=t.length,p=s.textRenderingMode===ct.INVISIBLE;let f,g,b,m;if(!(p||n===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...s.textMatrix),e.translate(s.x,s.y),e.scale(h,r),f=0;f<u;++f){if(g=t[f],typeof g=="number"){m=a*g*n/1e3,this.ctx.translate(m,0),s.x+=m*h;continue}const v=(g.isSpace?c:0)+o,y=i.charProcOperatorList[g.operatorListId];if(!y){F(`Type3 character "${g.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=g,this.save(),e.scale(n,n),e.transform(...d),this.executeOperatorList(y),this.restore()),b=R.applyTransform([g.width,0],d)[0]*n+v,e.translate(b,0),s.x+=b*h}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,n,r){this.ctx.rect(s,i,n-s,r-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){const s=t[1],i=this.baseTransform||Y(this.ctx),n={createCanvasGraphics:r=>new re(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Is(t,s,this.ctx,n,i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,s){const i=R.makeHexColor(t,e,s);this.ctx.strokeStyle=i,this.current.strokeColor=i}setFillRGBColor(t,e,s){const i=R.makeHexColor(t,e,s);this.ctx.fillStyle=i,this.current.fillColor=i,this.current.patternFill=!1}_getPattern(t,e=null){let s;return this.cachedPatterns.has(t)?s=this.cachedPatterns.get(t):(s=Qn(this.getObject(t)),this.cachedPatterns.set(t,s)),e&&(s.matrix=e),s}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const s=this._getPattern(t);e.fillStyle=s.getPattern(e,this,Ot(e),pt.SHADING);const i=Ot(e);if(i){const{width:n,height:r}=e.canvas,[a,o,c,h]=R.getAxialAlignedBoundingBox([0,0,n,r],i);this.ctx.fillRect(a,o,c-a,h-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){V("Should not call beginInlineImage")}beginImageData(){V("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Y(this.ctx),e)){const s=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],s,i),this.current.updateRectMinMax(Y(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||Ue("TODO: Support non-isolated groups."),t.knockout&&F("Knockout groups not supported.");const s=Y(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=R.getAxialAlignedBoundingBox(t.bbox,Y(e));const n=[0,0,e.canvas.width,e.canvas.height];i=R.intersect(i,n)||[0,0,0,0];const r=Math.floor(i[0]),a=Math.floor(i[1]),o=Math.max(Math.ceil(i[2])-r,1),c=Math.max(Math.ceil(i[3])-a,1);this.current.startNewPathAndClipBox([0,0,o,c]);let h="groupAt"+this.groupLevel;t.smask&&(h+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(h,o,c),u=d.context;u.translate(-r,-a),u.transform(...s),t.smask?this.smaskStack.push({canvas:d.canvas,context:u,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()),ge(e,u),this.ctx=u,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,s=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const i=Y(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const n=R.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],i);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(t,e,s,i,n){if(this.#t(),Me(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const r=e[2]-e[0],a=e[3]-e[1];if(n&&this.annotationCanvasMap){s=s.slice(),s[4]-=e[0],s[5]-=e[1],e=e.slice(),e[0]=e[1]=0,e[2]=r,e[3]=a;const[o,c]=R.singularValueDecompose2dScale(Y(this.ctx)),{viewportScale:h}=this,d=Math.ceil(r*this.outputScaleX*h),u=Math.ceil(a*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(d,u);const{canvas:p,context:f}=this.annotationCanvas;this.annotationCanvasMap.set(t,p),this.annotationCanvas.savedCtx=this.ctx,this.ctx=f,this.ctx.save(),this.ctx.setTransform(o,0,0,-c,0,a*c),Me(this.ctx)}else Me(this.ctx),this.ctx.rect(e[0],e[1],r,a),this.ctx.clip(),this.endPath()}this.current=new Ys(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#e(),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),t.count=e;const s=this.ctx,i=this.processingType3;if(i&&(i.compiled===void 0&&(i.compiled=sr(t)),i.compiled)){i.compiled(s);return}const n=this._createMaskCanvas(t),r=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(r,n.offsetX,n.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,i=0,n,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);const a=this.ctx;a.save();const o=Y(a);a.transform(e,s,i,n,0,0);const c=this._createMaskCanvas(t);a.setTransform(1,0,0,1,c.offsetX-o[4],c.offsetY-o[5]);for(let h=0,d=r.length;h<d;h+=2){const u=R.transform(o,[e,s,i,n,r[h],r[h+1]]),[p,f]=R.applyTransform([0,0],u);a.drawImage(c.canvas,p,f)}a.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;for(const n of t){const{data:r,width:a,height:o,transform:c}=n,h=this.cachedCanvases.getCanvas("maskCanvas",a,o),d=h.context;d.save();const u=this.getObject(r,n);Qs(d,u),d.globalCompositeOperation="source-in",d.fillStyle=i?s.getPattern(d,this,Ot(e),pt.FILL):s,d.fillRect(0,0,a,o),d.restore(),e.save(),e.transform(...c),e.scale(1,-1),ke(e,h.canvas,0,0,a,o,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);if(!e){F("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,s,i){if(!this.contentVisible)return;const n=this.getObject(t);if(!n){F("Dependent image isn't ready yet");return}const r=n.width,a=n.height,o=[];for(let c=0,h=i.length;c<h;c+=2)o.push({transform:[e,0,0,s,i[c],i[c+1]],x:0,y:0,w:r,h:a});this.paintInlineImageXObjectGroup(n,o)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:e,width:s,height:i}=t,n=this.cachedCanvases.getCanvas("inlineImage",s,i),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,s=t.height,i=this.ctx;if(this.save(),!ut){const{filter:a}=i;a!=="none"&&a!==""&&(i.filter="none")}i.scale(1/e,-1/s);let n;if(t.bitmap)n=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)n=t;else{const o=this.cachedCanvases.getCanvas("inlineImage",e,s).context;Ks(o,t),n=this.applyTransferMapsToCanvas(o)}const r=this._scaleImage(n,Ot(i));i.imageSmoothingEnabled=Js(Y(i),t.interpolate),ke(i,r.img,0,0,r.paintWidth,r.paintHeight,0,-s,e,s),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.ctx;let i;if(t.bitmap)i=t.bitmap;else{const n=t.width,r=t.height,o=this.cachedCanvases.getCanvas("inlineImage",n,r).context;Ks(o,t),i=this.applyTransferMapsToCanvas(o)}for(const n of e)s.save(),s.transform(...n.transform),s.scale(1,-1),ke(s,i,n.x,n.y,n.w,n.h,0,-1,1,1),s.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){t==="OC"?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 s=this.ctx;this.pendingClip&&(e||(this.pendingClip===Zs?s.clip("evenodd"):s.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),s.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Y(this.ctx);if(t[1]===0&&t[2]===0)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]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:n}=this.ctx.getTransform();let r,a;if(s===0&&i===0){const o=Math.abs(e),c=Math.abs(n);if(o===c)if(t===0)r=a=1/o;else{const h=o*t;r=a=h<1?1/h:1}else if(t===0)r=1/o,a=1/c;else{const h=o*t,d=c*t;r=h<1?1/h:1,a=d<1?1/d:1}}else{const o=Math.abs(e*n-s*i),c=Math.hypot(e,s),h=Math.hypot(i,n);if(t===0)r=h/o,a=c/o;else{const d=t*o;r=h>d?h/d:1,a=c>d?c/d:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:s}=this.current,[i,n]=this.getScaleForStroking();if(e.lineWidth=s||1,i===1&&n===1){e.stroke();return}const r=e.getLineDash();if(t&&e.save(),e.scale(i,n),r.length>0){const a=Math.max(i,n);e.setLineDash(r.map(o=>o/a)),e.lineDashOffset/=a}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 l in Pt)re.prototype[l]!==void 0&&(re.prototype[Pt[l]]=re.prototype[l]);class ye{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");this.#e=t}}const Ie={DATA:1,ERROR:2},tt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function wt(l){switch(l instanceof Error||typeof l=="object"&&l!==null||V('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),l.name){case"AbortException":return new Zt(l.message);case"MissingPDFException":return new Jt(l.message);case"PasswordException":return new ds(l.message,l.code);case"UnexpectedResponseException":return new ze(l.message,l.status);case"UnknownErrorException":return new us(l.message,l.details);default:return new us(l.message,l.toString())}}class ve{constructor(t,e,s){this.sourceName=t,this.targetName=e,this.comObj=s,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),this._onComObjOnMessage=i=>{const n=i.data;if(n.targetName!==this.sourceName)return;if(n.stream){this.#e(n);return}if(n.callback){const a=n.callbackId,o=this.callbackCapabilities[a];if(!o)throw new Error(`Cannot resolve callback ${a}`);if(delete this.callbackCapabilities[a],n.callback===Ie.DATA)o.resolve(n.data);else if(n.callback===Ie.ERROR)o.reject(wt(n.reason));else throw new Error("Unexpected callback case");return}const r=this.actionHandler[n.action];if(!r)throw new Error(`Unknown action from worker: ${n.action}`);if(n.callbackId){const a=this.sourceName,o=n.sourceName;new Promise(function(c){c(r(n.data))}).then(function(c){s.postMessage({sourceName:a,targetName:o,callback:Ie.DATA,callbackId:n.callbackId,data:c})},function(c){s.postMessage({sourceName:a,targetName:o,callback:Ie.ERROR,callbackId:n.callbackId,reason:wt(c)})});return}if(n.streamId){this.#t(n);return}r(n.data)},s.addEventListener("message",this._onComObjOnMessage)}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[i]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(r){n.reject(r)}return n.promise}sendWithStream(t,e,s,i){const n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:c=>{const h=Promise.withResolvers();return this.streamControllers[n]={controller:c,startCall:h,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:c.desiredSize},i),h.promise},pull:c=>{const h=Promise.withResolvers();return this.streamControllers[n].pullCall=h,o.postMessage({sourceName:r,targetName:a,stream:tt.PULL,streamId:n,desiredSize:c.desiredSize}),h.promise},cancel:c=>{nt(c instanceof Error,"cancel must have a valid reason");const h=Promise.withResolvers();return this.streamControllers[n].cancelCall=h,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:tt.CANCEL,streamId:n,reason:wt(c)}),h.promise}},s)}#t(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(c,h=1,d){if(this.isCancelled)return;const u=this.desiredSize;this.desiredSize-=h,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:tt.ENQUEUE,streamId:e,chunk:c},d)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:tt.CLOSE,streamId:e}),delete r.streamSinks[e])},error(c){nt(c instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:tt.ERROR,streamId:e,reason:wt(c)}))},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,new Promise(function(c){c(a(t.data,o))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:tt.START_COMPLETE,streamId:e,success:!0})},function(c){n.postMessage({sourceName:s,targetName:i,stream:tt.START_COMPLETE,streamId:e,reason:wt(c)})})}#e(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case tt.START_COMPLETE:t.success?r.startCall.resolve():r.startCall.reject(wt(t.reason));break;case tt.PULL_COMPLETE:t.success?r.pullCall.resolve():r.pullCall.reject(wt(t.reason));break;case tt.PULL:if(!a){n.postMessage({sourceName:s,targetName:i,stream:tt.PULL_COMPLETE,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,new Promise(function(o){o(a.onPull?.())}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:tt.PULL_COMPLETE,streamId:e,success:!0})},function(o){n.postMessage({sourceName:s,targetName:i,stream:tt.PULL_COMPLETE,streamId:e,reason:wt(o)})});break;case tt.ENQUEUE:if(nt(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case tt.CLOSE:if(nt(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#s(r,e);break;case tt.ERROR:nt(r,"error should have stream controller"),r.controller.error(wt(t.reason)),this.#s(r,e);break;case tt.CANCEL_COMPLETE:t.success?r.cancelCall.resolve():r.cancelCall.reject(wt(t.reason)),this.#s(r,e);break;case tt.CANCEL:if(!a)break;new Promise(function(o){o(a.onCancel?.(wt(t.reason)))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:tt.CANCEL_COMPLETE,streamId:e,success:!0})},function(o){n.postMessage({sourceName:s,targetName:i,stream:tt.CANCEL_COMPLETE,streamId:e,reason:wt(o)})}),a.sinkCapability.reject(wt(t.reason)),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#s(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}class ar{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}getAll(){return ws(this.#t)}has(t){return this.#t.has(t)}}const Ut=Symbol("INTERNAL");class or{#t=!1;#e=!1;#s=!1;#n=!0;constructor(t,{name:e,intent:s,usage:i}){this.#t=!!(t&Ct.DISPLAY),this.#e=!!(t&Ct.PRINT),this.name=e,this.intent=s,this.usage=i}get visible(){if(this.#s)return this.#n;if(!this.#n)return!1;const{print:t,view:e}=this.usage;return this.#t?e?.viewState!=="OFF":this.#e?t?.printState!=="OFF":!0}_setVisible(t,e,s=!1){t!==Ut&&V("Internal method `_setVisible` called."),this.#s=s,this.#n=e}}class lr{#t=null;#e=new Map;#s=null;#n=null;constructor(t,e=Ct.DISPLAY){if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,this.#n=t.order;for(const s of t.groups)this.#e.set(s.id,new or(e,s));if(t.baseState==="OFF")for(const s of this.#e.values())s._setVisible(Ut,!1);for(const s of t.on)this.#e.get(s)._setVisible(Ut,!0);for(const s of t.off)this.#e.get(s)._setVisible(Ut,!1);this.#s=this.getHash()}}#o(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const n=t[i];let r;if(Array.isArray(n))r=this.#o(n);else if(this.#e.has(n))r=this.#e.get(n).visible;else return F(`Optional content group not found: ${n}`),!0;switch(s){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return s==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return Ue("Optional content group not defined."),!0;if(t.type==="OCG")return this.#e.has(t.id)?this.#e.get(t.id).visible:(F(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return this.#o(t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!this.#e.has(e))return F(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!this.#e.has(e))return F(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!this.#e.has(e))return F(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!this.#e.has(e))return F(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return F(`Unknown optional content policy ${t.policy}.`),!0}return F(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0){const s=this.#e.get(t);if(!s){F(`Optional content group not found: ${t}`);return}s._setVisible(Ut,!!e,!0),this.#t=null}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const n=this.#e.get(i);if(n)switch(s){case"ON":n._setVisible(Ut,!0);break;case"OFF":n._setVisible(Ut,!1);break;case"Toggle":n._setVisible(Ut,!n.visible);break}}this.#t=null}get hasInitialVisibility(){return this.#s===null||this.getHash()===this.#s}getOrder(){return this.#e.size?this.#n?this.#n.slice():[...this.#e.keys()]:null}getGroups(){return this.#e.size>0?ws(this.#e):null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;const t=new Ei;for(const[e,s]of this.#e)t.update(`${e}:${s.visible}`);return this.#t=t.hexdigest()}}class hr{constructor(t,{disableRange:e=!1,disableStream:s=!1}){nt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:n,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,n?.length>0){const o=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(o)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((o,c)=>{this._onReceiveData({begin:o,chunk:c})}),t.addProgressListener((o,c)=>{this._onProgress({loaded:o,total:c})}),t.addProgressiveReadListener(o=>{this._onReceiveData({chunk:o})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{const i=this._rangeReaders.some(function(n){return n._begin!==t?!1:(n._enqueue(s),!0)});nt(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){t.total===void 0?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(){nt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new cr(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new dr(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class cr{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=Ts(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const n of this._queuedChunks)this._loaded+=n.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):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 e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class dr{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const s of this._requests)s.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 e=this._queuedChunk;return this._queuedChunk=null,{value:e,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 e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function ur(l){let t=!0,e=s("filename\\*","i").exec(l);if(e){e=e[1];let h=a(e);return h=unescape(h),h=o(h),h=c(h),n(h)}if(e=r(l),e){const h=c(e);return n(h)}if(e=s("filename","i").exec(l),e){e=e[1];let h=a(e);return h=c(h),n(h)}function s(h,d){return new RegExp("(?:^|;)\\s*"+h+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function i(h,d){if(h){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const u=new TextDecoder(h,{fatal:!0}),p=Ge(d);d=u.decode(p),t=!1}catch{}}return d}function n(h){return t&&/[\x80-\xff]/.test(h)&&(h=i("utf-8",h),t&&(h=i("iso-8859-1",h))),h}function r(h){const d=[];let u;const p=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(u=p.exec(h))!==null;){let[,g,b,m]=u;if(g=parseInt(g,10),g in d){if(g===0)break;continue}d[g]=[b,m]}const f=[];for(let g=0;g<d.length&&g in d;++g){let[b,m]=d[g];m=a(m),b&&(m=unescape(m),g===0&&(m=o(m))),f.push(m)}return f.join("")}function a(h){if(h.startsWith('"')){const d=h.slice(1).split('\\"');for(let u=0;u<d.length;++u){const p=d[u].indexOf('"');p!==-1&&(d[u]=d[u].slice(0,p),d.length=u+1),d[u]=d[u].replaceAll(/\\(.)/g,"$1")}h=d.join('"')}return h}function o(h){const d=h.indexOf("'");if(d===-1)return h;const u=h.slice(0,d),f=h.slice(d+1).replace(/^[^']*'/,"");return i(u,f)}function c(h){return!h.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(h)?h:h.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(d,u,p,f){if(p==="q"||p==="Q")return f=f.replaceAll("_"," "),f=f.replaceAll(/=([0-9a-fA-F]{2})/g,function(g,b){return String.fromCharCode(parseInt(b,16))}),i(u,f);try{f=atob(f)}catch{}return i(u,f)})}return""}function Ds({getResponseHeader:l,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={allowRangeRequests:!1,suggestedLength:void 0},n=parseInt(l("Content-Length"),10);return!Number.isInteger(n)||(i.suggestedLength=n,n<=2*e)||s||!t||l("Accept-Ranges")!=="bytes"||(l("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function Fs(l){const t=l("Content-Disposition");if(t){let e=ur(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Ts(e))return e}return null}function Ke(l,t){return l===404||l===0&&t.startsWith("file:")?new Jt('Missing PDF "'+t+'".'):new ze(`Unexpected server response (${l}) while retrieving PDF "${t}".`,l)}function Ci(l){return l===200||l===206}function Ti(l,t,e){return{method:"GET",headers:l,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function Pi(l){const t=new Headers;for(const e in l){const s=l[e];s!==void 0&&t.append(e,s)}return t}function Ri(l){return l instanceof Uint8Array?l.buffer:l instanceof ArrayBuffer?l:(F(`getArrayBuffer - unexpected data format: ${l}`),new Uint8Array(l).buffer)}class ti{constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return nt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new fr(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new pr(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class fr{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,this._headers=Pi(this._stream.httpHeaders);const s=e.url;fetch(s,Ti(this._headers,this._withCredentials,this._abortController)).then(i=>{if(!Ci(i.status))throw Ke(i.status,s);this._reader=i.body.getReader(),this._headersCapability.resolve();const n=o=>i.headers.get(o),{allowRangeRequests:r,suggestedLength:a}=Ds({getResponseHeader:n,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=a||this._contentLength,this._filename=Fs(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Zt("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:Ri(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class pr{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;const i=t.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController,this._headers=Pi(this._stream.httpHeaders),this._headers.append("Range",`bytes=${e}-${s-1}`);const n=i.url;fetch(n,Ti(this._headers,this._withCredentials,this._abortController)).then(r=>{if(!Ci(r.status))throw Ke(r.status,n);this._readCapability.resolve(),this._reader=r.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:Ri(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}const rs=200,as=206;function gr(l){const t=l.response;return typeof t!="string"?t:Ge(t).buffer}class mr{constructor(t,e={}){this.url=t,this.isHttp=/^https?:/i.test(t),this.httpHeaders=this.isHttp&&e.httpHeaders||Object.create(null),this.withCredentials=e.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(t,e,s){const i={begin:t,end:e};for(const n in s)i[n]=s[n];return this.request(i)}requestFull(t){return this.request(t)}request(t){const e=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const n in this.httpHeaders){const r=this.httpHeaders[n];r!==void 0&&e.setRequestHeader(n,r)}return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=as):i.expectedStatus=rs,e.responseType="arraybuffer",t.onError&&(e.onerror=function(n){t.onError(e.status)}),e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){const s=this.pendingRequests[t];s&&s.onProgress?.(e)}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),i.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],i.status===0&&this.isHttp){s.onError?.(i.status);return}const n=i.status||rs;if(!(n===rs&&s.expectedStatus===as)&&n!==s.expectedStatus){s.onError?.(i.status);return}const a=gr(i);if(n===as){const o=i.getResponseHeader("Content-Range"),c=/bytes (\d+)-(\d+)\/(\d+)/.exec(o);s.onDone({begin:parseInt(c[1],10),chunk:a})}else a?s.onDone({begin:0,chunk:a}):s.onError?.(i.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 br{constructor(t){this._source=t,this._manager=new mr(t.url,{httpHeaders:t.httpHeaders,withCredentials:t.withCredentials}),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 nt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new vr(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new Ar(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class vr{constructor(t,e){this._manager=t;const s={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._fullRequestId=t.requestFull(s),this._headersReceivedCapability=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),s=r=>e.getResponseHeader(r),{allowRangeRequests:i,suggestedLength:n}=Ds({getResponseHeader:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=Fs(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersReceivedCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Ke(t,this._url),this._headersReceivedCapability.reject(this._storedError);for(const e of this._requests)e.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._headersReceivedCapability.promise}async read(){if(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._headersReceivedCapability.reject(t);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Ar{constructor(t,e,s){this._manager=t;const i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._requestId=t.requestRange(e,s,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError=Ke(t,this._url);for(const e of this._requests)e.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(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,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 e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const Li=/^file:\/\/\/[a-zA-Z]:\//;function yr(l){const t=Dt.get("url"),e=t.parse(l);return e.protocol==="file:"||e.host?e:/^[a-z]:[/\\]/i.test(l)?t.parse(`file:///${l}`):(e.host||(e.protocol="file:"),e)}class _r{constructor(t){this.source=t,this.url=yr(t.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return nt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new Sr(this):new wr(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=this.isFsUrl?new xr(this,t,e):new Er(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class ki{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}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();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(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",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Zt("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Mi{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const e=t.source;this._isStreamingSupported=!e.disableStream}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();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(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",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}function He(l,t){return{protocol:l.protocol,auth:l.auth,host:l.hostname,port:l.port,path:l.path,method:"GET",headers:t}}class wr extends ki{constructor(t){super(t);const e=s=>{if(s.statusCode===404){const a=new Jt(`Missing PDF "${this._url}".`);this._storedError=a,this._headersCapability.reject(a);return}this._headersCapability.resolve(),this._setReadableStream(s);const i=a=>this._readableStream.headers[a.toLowerCase()],{allowRangeRequests:n,suggestedLength:r}=Ds({getResponseHeader:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=r||this._contentLength,this._filename=Fs(i)};if(this._request=null,this._url.protocol==="http:"){const s=Dt.get("http");this._request=s.request(He(this._url,t.httpHeaders),e)}else{const s=Dt.get("https");this._request=s.request(He(this._url,t.httpHeaders),e)}this._request.on("error",s=>{this._storedError=s,this._headersCapability.reject(s)}),this._request.end()}}class Er extends Mi{constructor(t,e,s){super(t),this._httpHeaders={};for(const n in t.httpHeaders){const r=t.httpHeaders[n];r!==void 0&&(this._httpHeaders[n]=r)}this._httpHeaders.Range=`bytes=${e}-${s-1}`;const i=n=>{if(n.statusCode===404){const r=new Jt(`Missing PDF "${this._url}".`);this._storedError=r;return}this._setReadableStream(n)};if(this._request=null,this._url.protocol==="http:"){const n=Dt.get("http");this._request=n.request(He(this._url,this._httpHeaders),i)}else{const n=Dt.get("https");this._request=n.request(He(this._url,this._httpHeaders),i)}this._request.on("error",n=>{this._storedError=n}),this._request.end()}}class Sr extends ki{constructor(t){super(t);let e=decodeURIComponent(this._url.path);Li.test(this._url.href)&&(e=e.replace(/^\//,""));const s=Dt.get("fs");s.promises.lstat(e).then(i=>{this._contentLength=i.size,this._setReadableStream(s.createReadStream(e)),this._headersCapability.resolve()},i=>{i.code==="ENOENT"&&(i=new Jt(`Missing PDF "${e}".`)),this._storedError=i,this._headersCapability.reject(i)})}}class xr extends Mi{constructor(t,e,s){super(t);let i=decodeURIComponent(this._url.path);Li.test(this._url.href)&&(i=i.replace(/^\//,""));const n=Dt.get("fs");this._setReadableStream(n.createReadStream(i,{start:e,end:s-1}))}}const Cr=1e5,mt=30,Tr=.8;let Be=class kt{#t=Promise.withResolvers();#e=null;#s=!1;#n=!!globalThis.FontInspector?.enabled;#o=null;#i=null;#r=0;#l=0;#c=null;#d=null;#f=0;#h=0;#a=Object.create(null);#p=[];#m=null;#u=[];#v=new WeakMap;#g=null;static#A=new Map;static#_=new Map;static#E=null;static#x=new Set;constructor({textContentSource:t,container:e,viewport:s}){if(t instanceof ReadableStream)this.#m=t;else if(typeof t=="object")this.#m=new ReadableStream({start(o){o.enqueue(t),o.close()}});else throw new Error('No "textContentSource" parameter specified.');this.#e=this.#d=e,this.#h=s.scale*(globalThis.devicePixelRatio||1),this.#f=s.rotation,this.#i={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:null};const{pageWidth:i,pageHeight:n,pageX:r,pageY:a}=s.rawDims;this.#g=[1,0,0,-1,-r,a+n],this.#l=i,this.#r=n,kt.#b(),Yt(e,s),this.#t.promise.catch(()=>{}).then(()=>{kt.#x.delete(this),this.#i=null,this.#a=null})}render(){const t=()=>{this.#c.read().then(({value:e,done:s})=>{if(s){this.#t.resolve();return}this.#o??=e.lang,Object.assign(this.#a,e.styles),this.#C(e.items),t()},this.#t.reject)};return this.#c=this.#m.getReader(),kt.#x.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){const s=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==this.#f&&(e?.(),this.#f=i,Yt(this.#d,{rotation:i})),s!==this.#h){e?.(),this.#h=s;const n={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:kt.#y(this.#o)};for(const r of this.#u)n.properties=this.#v.get(r),n.div=r,this.#S(n)}}cancel(){const t=new Zt("TextLayer task cancelled.");this.#c?.cancel(t).catch(()=>{}),this.#c=null,this.#t.reject(t)}get textDivs(){return this.#u}get textContentItemsStr(){return this.#p}#C(t){if(this.#s)return;this.#i.ctx??=kt.#y(this.#o);const e=this.#u,s=this.#p;for(const i of t){if(e.length>Cr){F("Ignoring additional textDivs for performance reasons."),this.#s=!0;return}if(i.str===void 0){if(i.type==="beginMarkedContentProps"||i.type==="beginMarkedContent"){const n=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),i.id!==null&&this.#e.setAttribute("id",`${i.id}`),n.append(this.#e)}else i.type==="endMarkedContent"&&(this.#e=this.#e.parentNode);continue}s.push(i.str),this.#L(i)}}#L(t){const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#u.push(e);const i=R.transform(this.#g,t.transform);let n=Math.atan2(i[1],i[0]);const r=this.#a[t.fontName];r.vertical&&(n+=Math.PI/2);const a=this.#n&&r.fontSubstitution||r.fontFamily,o=Math.hypot(i[2],i[3]),c=o*kt.#w(a,this.#o);let h,d;n===0?(h=i[4],d=i[5]-c):(h=i[4]+c*Math.sin(n),d=i[5]-c*Math.cos(n));const u="calc(var(--scale-factor)*",p=e.style;this.#e===this.#d?(p.left=`${(100*h/this.#l).toFixed(2)}%`,p.top=`${(100*d/this.#r).toFixed(2)}%`):(p.left=`${u}${h.toFixed(2)}px)`,p.top=`${u}${d.toFixed(2)}px)`),p.fontSize=`${u}${(kt.#E*o).toFixed(2)}px)`,p.fontFamily=a,s.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#n&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),n!==0&&(s.angle=n*(180/Math.PI));let f=!1;if(t.str.length>1)f=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const g=Math.abs(t.transform[0]),b=Math.abs(t.transform[3]);g!==b&&Math.max(g,b)/Math.min(g,b)>1.5&&(f=!0)}if(f&&(s.canvasWidth=r.vertical?t.height:t.width),this.#v.set(e,s),this.#i.div=e,this.#i.properties=s,this.#S(this.#i),s.hasText&&this.#e.append(e),s.hasEOL){const g=document.createElement("br");g.setAttribute("role","presentation"),this.#e.append(g)}}#S(t){const{div:e,properties:s,ctx:i,prevFontSize:n,prevFontFamily:r}=t,{style:a}=e;let o="";if(kt.#E>1&&(o=`scale(${1/kt.#E})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:c}=a,{canvasWidth:h,fontSize:d}=s;(n!==d||r!==c)&&(i.font=`${d*this.#h}px ${c}`,t.prevFontSize=d,t.prevFontFamily=c);const{width:u}=i.measureText(e.textContent);u>0&&(o=`scaleX(${h*this.#h/u}) ${o}`)}s.angle!==0&&(o=`rotate(${s.angle}deg) ${o}`),o.length>0&&(a.transform=o)}static cleanup(){if(!(this.#x.size>0)){this.#A.clear();for(const{canvas:t}of this.#_.values())t.remove();this.#_.clear()}}static#y(t=null){let e=this.#_.get(t||="");if(!e){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#_.set(t,e)}return e}static#b(){if(this.#E!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.textContent="X",document.body.append(t),this.#E=t.getBoundingClientRect().height,t.remove()}static#w(t,e){const s=this.#A.get(t);if(s)return s;const i=this.#y(e),n=i.font;i.canvas.width=i.canvas.height=mt,i.font=`${mt}px ${t}`;const r=i.measureText("");let a=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);if(a){const d=a/(a+o);return this.#A.set(t,d),i.canvas.width=i.canvas.height=0,i.font=n,d}i.strokeStyle="red",i.clearRect(0,0,mt,mt),i.strokeText("g",0,0);let c=i.getImageData(0,0,mt,mt).data;o=0;for(let d=c.length-1-3;d>=0;d-=4)if(c[d]>0){o=Math.ceil(d/4/mt);break}i.clearRect(0,0,mt,mt),i.strokeText("A",0,mt),c=i.getImageData(0,0,mt,mt).data,a=0;for(let d=0,u=c.length;d<u;d+=4)if(c[d]>0){a=mt-Math.floor(d/4/mt);break}i.canvas.width=i.canvas.height=0,i.font=n;const h=a?a/(a+o):Tr;return this.#A.set(t,h),h}};function Pr(){_i("`renderTextLayer`, please use `TextLayer` instead.");const{textContentSource:l,container:t,viewport:e,...s}=arguments[0],i=Object.keys(s);i.length>0&&F("Ignoring `renderTextLayer` parameters: "+i.join(", "));const n=new Be({textContentSource:l,container:t,viewport:e}),{textDivs:r,textContentItemsStr:a}=n;return{promise:n.render(),textDivs:r,textContentItemsStr:a}}function Rr(){_i("`updateTextLayer`, please use `TextLayer` instead.")}class _e{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(n){if(!n)return;let r=null;const a=n.name;if(a==="#text")r=n.value;else if(_e.shouldBuildText(a))n?.attributes?.textContent?r=n.attributes.textContent:n.value&&(r=n.value);else return;if(r!==null&&e.push({str:r}),!!n.children)for(const o of n.children)i(o)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const Lr=65536,kr=100,Mr=5e3,Ir=ut?Gn:kn,Dr=ut?Vn:Ai,Fr=ut?zn:Ln,Or=ut?Wn:yi;function Nr(l={}){typeof l=="string"||l instanceof URL?l={url:l}:(l instanceof ArrayBuffer||ArrayBuffer.isView(l))&&(l={data:l});const t=new Os,{docId:e}=t,s=l.url?Hr(l.url):null,i=l.data?Br(l.data):null,n=l.httpHeaders||null,r=l.withCredentials===!0,a=l.password??null,o=l.range instanceof Ii?l.range:null,c=Number.isInteger(l.rangeChunkSize)&&l.rangeChunkSize>0?l.rangeChunkSize:Lr;let h=l.worker instanceof Tt?l.worker:null;const d=l.verbosity,u=typeof l.docBaseUrl=="string"&&!Cs(l.docBaseUrl)?l.docBaseUrl:null,p=typeof l.cMapUrl=="string"?l.cMapUrl:null,f=l.cMapPacked!==!1,g=l.CMapReaderFactory||Dr,b=typeof l.standardFontDataUrl=="string"?l.standardFontDataUrl:null,m=l.StandardFontDataFactory||Or,v=l.stopAtErrors!==!0,y=Number.isInteger(l.maxImageSize)&&l.maxImageSize>-1?l.maxImageSize:-1,A=l.isEvalSupported!==!1,_=typeof l.isOffscreenCanvasSupported=="boolean"?l.isOffscreenCanvasSupported:!ut,w=Number.isInteger(l.canvasMaxAreaInBytes)?l.canvasMaxAreaInBytes:-1,E=typeof l.disableFontFace=="boolean"?l.disableFontFace:ut,x=l.fontExtraProperties===!0,S=l.enableXfa===!0,L=l.ownerDocument||globalThis.document,P=l.disableRange===!0,G=l.disableStream===!0,j=l.disableAutoFetch===!0,O=l.pdfBug===!0,$=l.enableHWA===!0,U=o?o.length:l.length??NaN,T=typeof l.useSystemFonts=="boolean"?l.useSystemFonts:!ut&&!E,k=typeof l.useWorkerFetch=="boolean"?l.useWorkerFetch:g===Ai&&m===yi&&p&&b&&be(p,document.baseURI)&&be(b,document.baseURI),yt=l.canvasFactory||new Ir({ownerDocument:L,enableHWA:$}),Et=l.filterFactory||new Fr({docId:e,ownerDocument:L}),$t=null;An(d);const Q={canvasFactory:yt,filterFactory:Et};if(k||(Q.cMapReaderFactory=new g({baseUrl:p,isCompressed:f}),Q.standardFontDataFactory=new m({baseUrl:b})),!h){const _t={verbosity:d,port:ye.workerPort};h=_t.port?Tt.fromPort(_t):new Tt(_t),t._worker=h}const X={docId:e,apiVersion:"4.4.168",data:i,password:a,disableAutoFetch:j,rangeChunkSize:c,length:U,docBaseUrl:u,enableXfa:S,evaluatorOptions:{maxImageSize:y,disableFontFace:E,ignoreErrors:v,isEvalSupported:A,isOffscreenCanvasSupported:_,canvasMaxAreaInBytes:w,fontExtraProperties:x,useSystemFonts:T,cMapUrl:k?p:null,standardFontDataUrl:k?b:null}},St={disableFontFace:E,fontExtraProperties:x,ownerDocument:L,pdfBug:O,styleElement:$t,loadingParams:{disableAutoFetch:j,enableXfa:S}};return h.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const _t=h.messageHandler.sendWithPromise("GetDocRequest",X,i?[i.buffer]:null);let ft;if(o)ft=new hr(o,{disableRange:P,disableStream:G});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");ft=(gt=>ut?function(){return typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype}()&&be(gt.url)?new ti(gt):new _r(gt):be(gt.url)?new ti(gt):new br(gt))({url:s,length:U,httpHeaders:n,withCredentials:r,rangeChunkSize:c,disableRange:P,disableStream:G})}return _t.then(q=>{if(t.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const gt=new ve(e,q,h.port),Rt=new zr(gt,t,ft,St,Q);t._transport=Rt,gt.send("Ready",null)})}).catch(t._capability.reject),t}function Hr(l){if(l instanceof URL)return l.href;try{return new URL(l,window.location).href}catch{if(ut&&typeof l=="string")return l}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function Br(l){if(ut&&typeof Bs<"u"&&l instanceof Bs)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(l instanceof Uint8Array&&l.byteLength===l.buffer.byteLength)return l;if(typeof l=="string")return Ge(l);if(l instanceof ArrayBuffer||ArrayBuffer.isView(l)||typeof l=="object"&&!isNaN(l?.length))return new Uint8Array(l);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function ei(l){return typeof l=="object"&&Number.isInteger(l?.num)&&l.num>=0&&Number.isInteger(l?.gen)&&l.gen>=0}class Os{static#t=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${Os.#t++}`,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&&(this._worker.destroy(),this._worker=null)}}let Ii=class{constructor(t,e,s=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i,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 s of this._rangeListeners)s(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(const s of this._progressListeners)s(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){V("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class jr{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return B(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 $r{#t=null;#e=!1;constructor(t,e,s,i=!1){this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new $s:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new Di,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:s=0,offsetY:i=0,dontFlip:n=!1}={}){return new we({viewBox:this.view,scale:t,rotation:e,offsetX:s,offsetY:i,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 B(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:s="display",annotationMode:i=zt.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:a=null,annotationCanvasMap:o=null,pageColors:c=null,printAnnotationStorage:h=null}){this._stats?.time("Overall");const d=this._transport.getRenderingIntent(s,i,h),{renderingIntent:u,cacheKey:p}=d;this.#e=!1,this.#n(),a||=this._transport.getOptionalContentConfig(u);let f=this._intentStates.get(p);f||(f=Object.create(null),this._intentStates.set(p,f)),f.streamReaderCancelTimeout&&(clearTimeout(f.streamReaderCancelTimeout),f.streamReaderCancelTimeout=null);const g=!!(u&Ct.PRINT);f.displayReadyCapability||(f.displayReadyCapability=Promise.withResolvers(),f.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(d));const b=y=>{f.renderTasks.delete(m),(this._maybeCleanupAfterRender||g)&&(this.#e=!0),this.#s(!g),y?(m.capability.reject(y),this._abortOperatorList({intentState:f,reason:y instanceof Error?y:new Error(y)})):m.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},m=new ne({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:!g,pdfBug:this._pdfBug,pageColors:c});(f.renderTasks||=new Set).add(m);const v=m.task;return Promise.all([f.displayReadyCapability.promise,a]).then(([y,A])=>{if(this.destroyed){b();return}if(this._stats?.time("Rendering"),!(A.renderingIntent&u))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");m.initializeGraphics({transparency:y,optionalContentConfig:A}),m.operatorListChanged()}).catch(b),v}getOperatorList({intent:t="display",annotationMode:e=zt.ENABLE,printAnnotationStorage:s=null}={}){function i(){r.operatorList.lastChunk&&(r.opListReadCapability.resolve(r.operatorList),r.renderTasks.delete(a))}const n=this._transport.getRenderingIntent(t,e,s,!0);let r=this._intentStates.get(n.cacheKey);r||(r=Object.create(null),this._intentStates.set(n.cacheKey,r));let a;return r.opListReadCapability||(a=Object.create(null),a.operatorListChanged=i,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:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(i){return i.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>_e.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){function n(){r.read().then(function({value:o,done:c}){if(c){s(a);return}a.lang??=o.lang,Object.assign(a.styles,o.styles),a.items.push(...o.items),n()},i)}const r=e.getReader(),a={items:[],styles:Object.create(null),lang:null};n()})}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 s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),this.#e=!1,this.#n(),Promise.all(t)}cleanup(t=!1){this.#e=!0;const e=this.#s(!1);return t&&e&&(this._stats&&=new $s),e}#s(t=!1){if(this.#n(),!this.#e||this.destroyed)return!1;if(t)return this.#t=setTimeout(()=>{this.#t=null,this.#s(!1)},Mr),!1;for(const{renderTasks:e,operatorList:s}of this._intentStates.values())if(e.size>0||!s.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#e=!1,!0}#n(){this.#t&&(clearTimeout(this.#t),this.#t=null)}_startRenderPage(t,e){const s=this._intentStates.get(e);s&&(this._stats?.timeEnd("Page Request"),s.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&this.#s(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s}){const{map:i,transfer:n}=s,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:i},n).getReader(),o=this._intentStates.get(e);o.streamReader=a;const c=()=>{a.read().then(({value:h,done:d})=>{if(d){o.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(h,o),c())},h=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const d of o.renderTasks)d.operatorListChanged();this.#s(!0)}if(o.displayReadyCapability)o.displayReadyCapability.reject(h);else if(o.opListReadCapability)o.opListReadCapability.reject(h);else throw h}})};c()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof xs){let i=kr;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new Zt(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,n]of this._intentStates)if(n===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}class Ur{#t=new Set;#e=Promise.resolve();postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(const i of this.#t)i.call(this,s)})}addEventListener(t,e){this.#t.add(e)}removeEventListener(t,e){this.#t.delete(e)}terminate(){this.#t.clear()}}const Bt={isWorkerDisabled:!1,fakeWorkerId:0};ut&&(Bt.isWorkerDisabled=!0,ye.workerSrc||="./pdf.worker.mjs"),Bt.isSameOrigin=function(l,t){let e;try{if(e=new URL(l),!e.origin||e.origin==="null")return!1}catch{return!1}const s=new URL(t,e);return e.origin===s.origin},Bt.createCDNWrapper=function(l){const t=`await import("${l}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))};class Tt{static#t;constructor({name:t=null,port:e=null,verbosity:s=yn()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(Tt.#t?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(Tt.#t||=new WeakMap).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return ut?Promise.all([Dt.promise,this._readyCapability.promise]):this._readyCapability.promise}#e(){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 ve("main","worker",t),this._messageHandler.on("ready",function(){}),this.#e()}_initialize(){if(Bt.isWorkerDisabled||Tt.#s){this._setupFakeWorker();return}let{workerSrc:t}=Tt;try{Bt.isSameOrigin(window.location.href,t)||(t=Bt.createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new ve("main","worker",e),i=()=>{n.abort(),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=new AbortController;e.addEventListener("error",()=>{this._webWorker||i()},{signal:n.signal}),s.on("test",a=>{if(n.abort(),this.destroyed||!a){i();return}this._messageHandler=s,this._port=e,this._webWorker=e,this.#e()}),s.on("ready",a=>{if(n.abort(),this.destroyed){i();return}try{r()}catch{this._setupFakeWorker()}});const r=()=>{const a=new Uint8Array;s.send("test",a,[a.buffer])};r();return}catch{Ue("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){Bt.isWorkerDisabled||(F("Setting up fake worker."),Bt.isWorkerDisabled=!0),Tt._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new Ur;this._port=e;const s=`fake${Bt.fakeWorkerId++}`,i=new ve(s+"_worker",s,e);t.setup(i,e),this._messageHandler=new ve(s,s+"_worker",e),this.#e()}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),Tt.#t?.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const e=this.#t?.get(t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new Tt(t)}static get workerSrc(){if(ye.workerSrc)return ye.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#s(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return B(this,"_setupFakeWorkerGlobal",(async()=>this.#s?this.#s:(await import(this.workerSrc)).WorkerMessageHandler)())}}class zr{#t=new Map;#e=new Map;#s=new Map;#n=new Map;#o=null;constructor(t,e,s,i,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Di,this.fontLoader=new $n({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#i(t,e=null){const s=this.#t.get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return this.#t.set(t,i),i}get annotationStorage(){return B(this,"annotationStorage",new Ms)}getRenderingIntent(t,e=zt.ENABLE,s=null,i=!1){let n=Ct.DISPLAY,r=fs;switch(t){case"any":n=Ct.ANY;break;case"display":break;case"print":n=Ct.PRINT;break;default:F(`getRenderingIntent - invalid intent: ${t}`)}switch(e){case zt.DISABLE:n+=Ct.ANNOTATIONS_DISABLE;break;case zt.ENABLE:break;case zt.ENABLE_FORMS:n+=Ct.ANNOTATIONS_FORMS;break;case zt.ENABLE_STORAGE:n+=Ct.ANNOTATIONS_STORAGE,r=(n&Ct.PRINT&&s instanceof Si?s:this.annotationStorage).serializable;break;default:F(`getRenderingIntent - invalid annotationMode: ${e}`)}return i&&(n+=Ct.OPLIST),{renderingIntent:n,cacheKey:`${n}_${r.hash}`,annotationStorageSerializable:r}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#o?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const s of this.#e.values())t.push(s._destroy());this.#e.clear(),this.#s.clear(),this.#n.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.#t.clear(),this.filterFactory.destroy(),Be.cleanup(),this._networkStream?.cancelAllRequests(new Zt("Worker was terminated.")),this.messageHandler&&(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",(s,i)=>{nt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=n=>{this._lastProgress={loaded:n.loaded,total:n.total}},i.onPull=()=>{this._fullReader.read().then(function({value:n,done:r}){if(r){i.close();return}nt(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(n),1,[n])}).catch(n=>{i.error(n)})},i.onCancel=n=>{this._fullReader.cancel(n),i.ready.catch(r=>{if(!this.destroyed)throw r})}}),t.on("ReaderHeadersReady",s=>{const i=Promise.withResolvers(),n=this._fullReader;return n.headersReady.then(()=>{(!n.isStreamingSupported||!n.isRangeSupported)&&(this._lastProgress&&e.onProgress?.(this._lastProgress),n.onProgress=r=>{e.onProgress?.({loaded:r.loaded,total:r.total})}),i.resolve({isStreamingSupported:n.isStreamingSupported,isRangeSupported:n.isRangeSupported,contentLength:n.contentLength})},i.reject),i.promise}),t.on("GetRangeReader",(s,i)=>{nt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(s.begin,s.end);if(!n){i.close();return}i.onPull=()=>{n.read().then(function({value:r,done:a}){if(a){i.close();return}nt(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{n.cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new jr(s,this))}),t.on("DocException",function(s){let i;switch(s.name){case"PasswordException":i=new ds(s.message,s.code);break;case"InvalidPDFException":i=new mi(s.message);break;case"MissingPDFException":i=new Jt(s.message);break;case"UnexpectedResponseException":i=new ze(s.message,s.status);break;case"UnknownErrorException":i=new us(s.message,s.details);break;default:V("DocException - expected a valid Error.")}e._capability.reject(i)}),t.on("PasswordRequest",s=>{if(this.#o=Promise.withResolvers(),e.onPassword){const i=n=>{n instanceof Error?this.#o.reject(n):this.#o.resolve({password:n})};try{e.onPassword(i,s.code)}catch(n){this.#o.reject(n)}}else this.#o.reject(new ds(s.message,s.code));return this.#o.promise}),t.on("DataLoaded",s=>{e.onProgress?.({loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;this.#e.get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,n])=>{if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":const{disableFontFace:r,fontExtraProperties:a,pdfBug:o}=this._params;if("error"in n){const u=n.error;F(`Error during font loading: ${u}`),this.commonObjs.resolve(s,u);break}const c=o&&globalThis.FontInspector?.enabled?(u,p)=>globalThis.FontInspector.fontAdded(u,p):null,h=new Un(n,{disableFontFace:r,inspectFont:c});this.fontLoader.bind(h).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!a&&h.data&&(h.data=null),this.commonObjs.resolve(s,h)});break;case"CopyLocalImage":const{imageRef:d}=n;nt(d,"The imageRef must be defined.");for(const u of this.#e.values())for(const[,p]of u.objs)if(p?.ref===d)return p.dataLen?(this.commonObjs.resolve(s,structuredClone(p)),p.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,n);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,n,r])=>{if(this.destroyed)return;const a=this.#e.get(i);if(!a.objs.has(s)){if(a._intentStates.size===0){r?.bitmap?.close();return}switch(n){case"Image":a.objs.resolve(s,r),r?.dataLen>gn&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(s,r);break;default:throw new Error(`Got unknown object type ${n}`)}}}),t.on("DocProgress",s=>{this.destroyed||e.onProgress?.({loaded:s.loaded,total:s.total})}),t.on("FetchBuiltInCMap",s=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(s):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))),t.on("FetchStandardFontData",s=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(s):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.")))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&F("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,s=this.#s.get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&this.#n.set(n.refStr,t);const r=new $r(e,n,this,this._params.pdfBug);return this.#e.set(e,r),r});return this.#s.set(e,i),i}getPageIndex(t){return ei(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.#i("GetFieldObjects")}hasJSActions(){return this.#i("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?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.#i("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.#i("GetOptionalContentConfig").then(e=>new lr(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#t.get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(i=>({info:i[0],metadata:i[1]?new ar(i[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#t.set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of this.#e.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(!0),Be.cleanup()}}cachedPageNumber(t){if(!ei(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return this.#n.get(e)??null}}const De=Symbol("INITIAL_DATA");class Di{#t=Object.create(null);#e(t){return this.#t[t]||={...Promise.withResolvers(),data:De}}get(t,e=null){if(e){const i=this.#e(t);return i.promise.then(()=>e(i.data)),null}const s=this.#t[t];if(!s||s.data===De)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=this.#t[t];return!!e&&e.data!==De}resolve(t,e=null){const s=this.#e(t);s.data=e,s.resolve()}clear(){for(const t in this.#t){const{data:e}=this.#t[t];e?.bitmap?.close()}this.#t=Object.create(null)}*[Symbol.iterator](){for(const t in this.#t){const{data:e}=this.#t[t];e!==De&&(yield[t,e])}}}class Gr{#t=null;constructor(t){this.#t=t,this.onContinue=null}get promise(){return this.#t.capability.promise}cancel(t=0){this.#t.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#t.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#t;return t.form||t.canvas&&e?.size>0}}class ne{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:c,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:u=null}){this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=c,this._pdfBug=d,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=h===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Gr(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(ne.#e.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.");ne.#e.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:s,viewport:i,transform:n,background:r}=this.params;this.gfx=new re(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:i,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.#t&&(window.cancelAnimationFrame(this.#t),this.#t=null),ne.#e.delete(this._canvas),this.callback(t||new xs(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#t=window.requestAnimationFrame(()=>{this.#t=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(),ne.#e.delete(this._canvas),this.callback())))}}const Vr="4.4.168",Wr="19fbc8998";function si(l){return Math.floor(Math.max(0,Math.min(1,l))*255).toString(16).padStart(2,"0")}function me(l){return Math.max(0,Math.min(255,255*l))}class ii{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}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=me(t),[t,t,t]}static G_HTML([t]){const e=si(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(me)}static RGB_HTML(t){return`#${t.map(si).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[me(1-Math.min(1,t+i)),me(1-Math.min(1,s+i)),me(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,n=1-e,r=1-s,a=Math.min(i,n,r);return["CMYK",i,n,r,a]}}class Fi{static setupStorage(t,e,s,i,n){const r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",a=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(const a of s.children)a.attributes.value===r.value?a.attributes.selected=!0:a.attributes.hasOwnProperty("selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{const o=a.target.options,c=o.selectedIndex===-1?"":o[o.selectedIndex].value;i.setValue(e,{value:c})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${i}`);for(const[o,c]of Object.entries(r))if(c!=null)switch(o){case"class":c.length&&t.setAttribute(o,c.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",c);break;case"style":Object.assign(t.style,c);break;case"textContent":t.textContent=c;break;default:(!a||o!=="href"&&o!=="newWindow")&&t.setAttribute(o,c)}a&&n.addLinkAttributes(t,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(t,r.dataId,e,s)}static render(t){const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",r=document.createElement(i.name);i.attributes&&this.setAttributes({html:r,element:i,intent:n,linkService:s});const a=n!=="richText",o=t.div;if(o.append(r),t.viewport){const d=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=d}a&&o.setAttribute("class","xfaLayer xfaFont");const c=[];if(i.children.length===0){if(i.value){const d=document.createTextNode(i.value);r.append(d),a&&_e.shouldBuildText(i.name)&&c.push(d)}return{textDivs:c}}const h=[[i,-1,r]];for(;h.length>0;){const[d,u,p]=h.at(-1);if(u+1===d.children.length){h.pop();continue}const f=d.children[++h.at(-1)[1]];if(f===null)continue;const{name:g}=f;if(g==="#text"){const m=document.createTextNode(f.value);c.push(m),p.append(m);continue}const b=f?.attributes?.xmlns?document.createElementNS(f.attributes.xmlns,g):document.createElement(g);if(p.append(b),f.attributes&&this.setAttributes({html:b,element:f,storage:e,intent:n,linkService:s}),f.children?.length>0)h.push([f,-1,b]);else if(f.value){const m=document.createTextNode(f.value);a&&_e.shouldBuildText(g)&&c.push(m),b.append(m)}}for(const d of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))d.setAttribute("readOnly",!0);return{textDivs:c}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const xe=1e3,qr=9,Kt=new WeakSet;function jt(l){return{width:l[2]-l[0],height:l[3]-l[1]}}class Xr{static create(t){switch(t.data.annotationType){case st.LINK:return new Oi(t);case st.TEXT:return new Yr(t);case st.WIDGET:switch(t.data.fieldType){case"Tx":return new Kr(t);case"Btn":return t.data.radioButton?new Ni(t):t.data.checkBox?new Jr(t):new Zr(t);case"Ch":return new ta(t);case"Sig":return new Qr(t)}return new te(t);case st.POPUP:return new bs(t);case st.FREETEXT:return new Hi(t);case st.LINE:return new sa(t);case st.SQUARE:return new ia(t);case st.CIRCLE:return new na(t);case st.POLYLINE:return new Bi(t);case st.CARET:return new aa(t);case st.INK:return new ji(t);case st.POLYGON:return new ra(t);case st.HIGHLIGHT:return new oa(t);case st.UNDERLINE:return new la(t);case st.SQUIGGLY:return new ha(t);case st.STRIKEOUT:return new ca(t);case st.STAMP:return new $i(t);case st.FILEATTACHMENT:return new da(t);default:return new J(t)}}}class J{#t=null;#e=!1;#s=null;constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!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(s)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:s}){return!!(t?.str||e?.str||s?.str)}get hasPopupData(){return J._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#t||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#n(e),this.#s?.popup.updateEdited(t)}resetEdited(){this.#t&&(this.#n(this.#t.rect),this.#s?.popup.resetEdited(),this.#t=null)}#n(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;s?.splice(0,4,...t);const{width:c,height:h}=jt(t);e.left=`${100*(t[0]-a)/n}%`,e.top=`${100*(r-t[3]+o)/r}%`,i===0?(e.width=`${100*c/n}%`,e.height=`${100*h/r}%`):this.setRotation(i)}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof te||(n.tabIndex=xe);const{style:r}=n;if(r.zIndex=this.parent.zIndex++,e.popupRef&&n.setAttribute("aria-haspopup","dialog"),e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof bs){const{rotation:g}=e;return!e.hasOwnCanvas&&g!==0&&this.setRotation(g,n),n}const{width:a,height:o}=jt(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const g=e.borderStyle.horizontalCornerRadius,b=e.borderStyle.verticalCornerRadius;if(g>0||b>0){const v=`calc(${g}px * var(--scale-factor)) / calc(${b}px * var(--scale-factor))`;r.borderRadius=v}else if(this instanceof Ni){const v=`calc(${a}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;r.borderRadius=v}switch(e.borderStyle.style){case pe.SOLID:r.borderStyle="solid";break;case pe.DASHED:r.borderStyle="dashed";break;case pe.BEVELED:F("Unimplemented border style: beveled");break;case pe.INSET:F("Unimplemented border style: inset");break;case pe.UNDERLINE:r.borderBottomStyle="solid";break}const m=e.borderColor||null;m?(this.#e=!0,r.borderColor=R.makeHexColor(m[0]|0,m[1]|0,m[2]|0)):r.borderWidth=0}const c=R.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:h,pageHeight:d,pageX:u,pageY:p}=i.rawDims;r.left=`${100*(c[0]-u)/h}%`,r.top=`${100*(c[1]-p)/d}%`;const{rotation:f}=e;return e.hasOwnCanvas||f===0?(r.width=`${100*a/h}%`,r.height=`${100*o/d}%`):this.setRotation(f,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:n,height:r}=jt(this.data.rect);let a,o;t%180===0?(a=100*n/s,o=100*r/i):(a=100*r/s,o=100*n/i),e.style.width=`${a}%`,e.style.height=`${o}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const n=i.detail[e],r=n[0],a=n.slice(1);i.target.style[s]=ii[`${r}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[s]:ii[`${r}_rgb`](a)})};return B(this,"_commonActions",{display:e=>{const{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.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:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail))(t[i]||s[i])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,n]of Object.entries(e)){const r=s[i];if(r){const a={detail:{[i]:n},target:t};r(a),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,n]=this.data.rect.map(g=>Math.fround(g));if(t.length===8){const[g,b,m,v]=t.subarray(2,6);if(i===g&&n===b&&e===m&&s===v)return}const{style:r}=this.container;let a;if(this.#e){const{borderColor:g,borderWidth:b}=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="${g}" stroke-width="${b}">`],this.container.classList.add("hasBorder")}const o=i-e,c=n-s,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);const u=h.createElement("defs");d.append(u);const p=h.createElement("clipPath"),f=`clippath_${this.data.id}`;p.setAttribute("id",f),p.setAttribute("clipPathUnits","objectBoundingBox"),u.append(p);for(let g=2,b=t.length;g<b;g+=8){const m=t[g],v=t[g+1],y=t[g+2],A=t[g+3],_=h.createElement("rect"),w=(y-e)/o,E=(n-v)/c,x=(m-y)/o,S=(v-A)/c;_.setAttribute("x",w),_.setAttribute("y",E),_.setAttribute("width",x),_.setAttribute("height",S),p.append(_),a?.push(`<rect vector-effect="non-scaling-stroke" x="${w}" y="${E}" width="${x}" height="${S}"/>`)}this.#e&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${f})`}_createPopup(){const{container:t,data:e}=this;t.setAttribute("aria-haspopup","dialog");const s=this.#s=new bs({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]});this.parent.div.append(s.render())}render(){V("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:n,id:r,exportValues:a}of i){if(n===-1||r===e)continue;const o=typeof a=="string"?a:null,c=document.querySelector(`[data-element-id="${r}"]`);if(c&&!Kt.has(c)){F(`_getElementsByName - element not allowed: ${r}`);continue}s.push({id:r,exportValue:o,domElement:c})}return s}for(const i of document.getElementsByName(t)){const{exportValue:n}=i,r=i.getAttribute("data-element-id");r!==e&&Kt.has(i)&&s.push({id:r,exportValue:n,domElement:i})}return s}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")}get _isEditable(){return!1}_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 Oi extends J{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,s=document.createElement("a");s.setAttribute("data-element-id",t.id);let i=!1;return t.url?(e.addLinkAttributes(s,t.url,t.newWindow),i=!0):t.action?(this._bindNamedAction(s,t.action),i=!0):t.attachment?(this.#e(s,t.attachment,t.attachmentDest),i=!0):t.setOCGState?(this.#s(s,t.setOCGState),i=!0):t.dest?(this._bindLink(s,t.dest),i=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(s,t),i=!0),t.resetForm?(this._bindResetFormAction(s,t.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(s,""),i=!0)),this.container.classList.add("linkAnnotation"),i&&this.container.append(s),this.container}#t(){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.#t()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#t()}#e(t,e,s=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,s),!1),this.#t()}#s(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#t()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(e.actions)){const n=s.get(i);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:i}}),!1))}t.onclick||(t.onclick=()=>!1),this.#t()}_bindResetFormAction(t,e){const s=t.onclick;if(s||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects){F('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),s||(t.onclick=()=>!1);return}t.onclick=()=>{s?.();const{fields:i,refs:n,include:r}=e,a=[];if(i.length!==0||n.length!==0){const h=new Set(n);for(const d of i){const u=this._fieldObjects[d]||[];for(const{id:p}of u)h.add(p)}for(const d of Object.values(this._fieldObjects))for(const u of d)h.has(u.id)===r&&a.push(u)}else for(const h of Object.values(this._fieldObjects))a.push(...h);const o=this.annotationStorage,c=[];for(const h of a){const{id:d}=h;switch(c.push(d),h.type){case"text":{const p=h.defaultValue||"";o.setValue(d,{value:p});break}case"checkbox":case"radiobutton":{const p=h.defaultValue===h.exportValues;o.setValue(d,{value:p});break}case"combobox":case"listbox":{const p=h.defaultValue||"";o.setValue(d,{value:p});break}default:continue}const u=document.querySelector(`[data-element-id="${d}"]`);if(u){if(!Kt.has(u)){F(`_bindResetFormAction - element not allowed: ${d}`);continue}}else continue;u.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:c,name:"ResetForm"}}),!1}}}class Yr extends J{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 te extends J{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return vt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){s.includes("mouse")?t.addEventListener(s,r=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})}):t.addEventListener(s,r=>{if(s==="blur"){if(!e.focused||!r.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r)}})})}_setEventListeners(t,e,s,i){for(const[n,r]of s)(r==="Action"||this.data.actions?.[r])&&((r==="Focus"||r==="Blur")&&(e||={focused:!1}),this._setEventListener(t,e,n,r,i),r==="Focus"&&!this.data.actions?.Blur?this._setEventListener(t,e,"blur","Blur",null):r==="Blur"&&!this.data.actions?.Focus&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":R.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||qr,n=t.style;let r;const a=2,o=c=>Math.round(10*c)/10;if(this.data.multiLine){const c=Math.abs(this.data.rect[3]-this.data.rect[1]-a),h=Math.round(c/(es*i))||1,d=c/h;r=Math.min(i,o(d/es))}else{const c=Math.abs(this.data.rect[3]-this.data.rect[1]-a);r=Math.min(i,o(c/es))}n.fontSize=`calc(${r}px * var(--scale-factor))`,n.color=R.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Kr extends te{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=s),n.setValue(r.id,{[i]:s})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const i=t.getValue(e,{value:this.data.fieldValue});let n=i.value||"";const r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&n.length>r&&(n=n.slice(0,r));let a=i.formattedValue||this.data.textContent?.join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/empty-8w7lnNDy.js","assets/sentry-CsmEj6N0.js","assets/empty-C8aelB8k.js","assets/index-BYZPrbCg.js","assets/index-BG2KSZUN.js","assets/zeni-epic-state-Djpn9hBU.js","assets/core-Tp-f995F.js","assets/utils-C03h8lYk.js","assets/recharts-BmU4Su4y.js","assets/url-44QIqvix.js","assets/index-D414nesG.js","assets/index-zdSvBS0s.js","assets/url-DI-fObeY.js"])))=>i.map(i=>d[i]);
2
+ import{H as Bs,bd as Le}from"./zeni-epic-state-Djpn9hBU.js";import{p as ie,g as pn,a as C}from"./sentry-CsmEj6N0.js";import{j as z}from"./liveblocks-C_j2EWYR.js";import{V as H,c as he}from"./recharts-BmU4Su4y.js";import"./core-Tp-f995F.js";(function(){try{var l=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new l.Error().stack;t&&(l._sentryDebugIds=l._sentryDebugIds||{},l._sentryDebugIds[t]="a6b5baa6-aba9-474c-839d-75f41d56b3c0",l._sentryDebugIdIdentifier="sentry-dbid-a6b5baa6-aba9-474c-839d-75f41d56b3c0")}catch{}})();var Ae={};Ae.d=(l,t)=>{for(var e in t)Ae.o(t,e)&&!Ae.o(l,e)&&Object.defineProperty(l,e,{enumerable:!0,get:t[e]})};Ae.o=(l,t)=>Object.prototype.hasOwnProperty.call(l,t);var M=globalThis.pdfjsLib={};Ae.d(M,{AbortException:()=>Zt,AnnotationEditorLayer:()=>Ht,AnnotationEditorParamsType:()=>D,AnnotationEditorType:()=>N,AnnotationEditorUIManager:()=>Gt,AnnotationLayer:()=>ua,AnnotationMode:()=>zt,CMapCompressionType:()=>cs,ColorPicker:()=>Mt,DOMSVGFactory:()=>Ss,DrawLayer:()=>dt,FeatureTest:()=>vt,GlobalWorkerOptions:()=>ye,ImageKind:()=>Oe,InvalidPDFException:()=>mi,MissingPDFException:()=>Jt,OPS:()=>Pt,Outliner:()=>vs,PDFDataRangeTransport:()=>Ii,PDFDateString:()=>wi,PDFWorker:()=>Tt,PasswordResponses:()=>vn,PermissionFlag:()=>bn,PixelsPerInch:()=>le,RenderingCancelledException:()=>xs,TextLayer:()=>Be,UnexpectedResponseException:()=>ze,Util:()=>R,VerbosityLevel:()=>je,XfaLayer:()=>Fi,build:()=>Wr,createValidAbsoluteUrl:()=>wn,fetchData:()=>Ye,getDocument:()=>Nr,getFilenameFromUrl:()=>Mn,getPdfFilenameFromUrl:()=>In,getXfaPageViewport:()=>Dn,isDataScheme:()=>Cs,isPdfFile:()=>Ts,noContextMenu:()=>At,normalizeUnicode:()=>Pn,renderTextLayer:()=>Pr,setLayerDimensions:()=>Yt,shadow:()=>B,updateTextLayer:()=>Rr,version:()=>Vr});const ut=typeof ie=="object"&&ie+""=="[object process]"&&!ie.versions.nw&&!(ie.versions.electron&&ie.type&&ie.type!=="browser"),gi=[1,0,0,1,0,0],hs=[.001,0,0,.001,0,0],gn=1e7,es=1.35,Ct={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256},zt={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},mn="pdfjs_internal_editor_",N={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},D={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35},bn={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},ct={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},Oe={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},st={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,WIDGET:20},pe={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},je={ERRORS:0,WARNINGS:1,INFOS:5},cs={NONE:0,BINARY:1},Pt={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91},vn={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let $e=je.WARNINGS;function An(l){Number.isInteger(l)&&($e=l)}function yn(){return $e}function Ue(l){$e>=je.INFOS&&console.log(`Info: ${l}`)}function F(l){$e>=je.WARNINGS&&console.log(`Warning: ${l}`)}function V(l){throw new Error(l)}function nt(l,t){l||V(t)}function _n(l){switch(l?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function wn(l,t=null,e=null){if(!l)return null;try{if(e&&typeof l=="string"&&(e.addDefaultProtocol&&l.startsWith("www.")&&l.match(/\./g)?.length>=2&&(l=`http://${l}`),e.tryConvertEncoding))try{l=Tn(l)}catch{}const s=t?new URL(l,t):new URL(l);if(_n(s))return s}catch{}return null}function B(l,t,e,s=!1){return Object.defineProperty(l,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Wt=(function(){function t(e,s){this.constructor===t&&V("Cannot initialize BaseException."),this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class ds extends Wt{constructor(t,e){super(t,"PasswordException"),this.code=e}}class us extends Wt{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class mi extends Wt{constructor(t){super(t,"InvalidPDFException")}}class Jt extends Wt{constructor(t){super(t,"MissingPDFException")}}class ze extends Wt{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class En extends Wt{constructor(t){super(t,"FormatError")}}class Zt extends Wt{constructor(t){super(t,"AbortException")}}function bi(l){(typeof l!="object"||l?.length===void 0)&&V("Invalid argument for bytesToString");const t=l.length,e=8192;if(t<e)return String.fromCharCode.apply(null,l);const s=[];for(let i=0;i<t;i+=e){const n=Math.min(i+e,t),r=l.subarray(i,n);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function Ge(l){typeof l!="string"&&V("Invalid argument for stringToBytes");const t=l.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=l.charCodeAt(s)&255;return e}function Sn(l){return String.fromCharCode(l>>24&255,l>>16&255,l>>8&255,l&255)}function ws(l){const t=Object.create(null);for(const[e,s]of l)t[e]=s;return t}function xn(){const l=new Uint8Array(4);return l[0]=1,new Uint32Array(l.buffer,0,1)[0]===1}function Cn(){try{return new Function(""),!0}catch{return!1}}class vt{static get isLittleEndian(){return B(this,"isLittleEndian",xn())}static get isEvalSupported(){return B(this,"isEvalSupported",Cn())}static get isOffscreenCanvasSupported(){return B(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof navigator?.platform=="string"?B(this,"platform",{isMac:navigator.platform.includes("Mac")}):B(this,"platform",{isMac:!1})}static get isCSSRoundSupported(){return B(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const ss=Array.from(Array(256).keys(),l=>l.toString(16).padStart(2,"0"));class R{static makeHexColor(t,e,s){return`#${ss[t]}${ss[e]}${ss[s]}`}static scaleMinMax(t,e){let s;t[0]?(t[0]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[3],e[3]*=t[3]):(s=e[0],e[0]=e[1],e[1]=s,s=e[2],e[2]=e[3],e[3]=s,t[1]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(s=e[0],e[0]=e[2],e[2]=s),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){const s=t[0]*e[0]+t[1]*e[2]+e[4],i=t[0]*e[1]+t[1]*e[3]+e[5];return[s,i]}static applyInverseTransform(t,e){const s=e[0]*e[3]-e[1]*e[2],i=(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/s,n=(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s;return[i,n]}static getAxialAlignedBoundingBox(t,e){const s=this.applyTransform(t,e),i=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(s[0],i[0],n[0],r[0]),Math.min(s[1],i[1],n[1],r[1]),Math.max(s[0],i[0],n[0],r[0]),Math.max(s[1],i[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]],s=t[0]*e[0]+t[1]*e[2],i=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=(s+r)/2,o=Math.sqrt((s+r)**2-4*(s*r-n*i))/2,c=a+o||1,h=a-o||1;return[Math.sqrt(c),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 s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)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:[s,n,i,r]}static#t(t,e,s,i,n,r,a,o,c,h){if(c<=0||c>=1)return;const d=1-c,u=c*c,p=u*c,f=d*(d*(d*t+3*c*e)+3*u*s)+p*i,g=d*(d*(d*n+3*c*r)+3*u*a)+p*o;h[0]=Math.min(h[0],f),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],f),h[3]=Math.max(h[3],g)}static#e(t,e,s,i,n,r,a,o,c,h,d,u){if(Math.abs(c)<1e-12){Math.abs(h)>=1e-12&&this.#t(t,e,s,i,n,r,a,o,-d/h,u);return}const p=h**2-4*d*c;if(p<0)return;const f=Math.sqrt(p),g=2*c;this.#t(t,e,s,i,n,r,a,o,(-h+f)/g,u),this.#t(t,e,s,i,n,r,a,o,(-h-f)/g,u)}static bezierBoundingBox(t,e,s,i,n,r,a,o,c){return c?(c[0]=Math.min(c[0],t,a),c[1]=Math.min(c[1],e,o),c[2]=Math.max(c[2],t,a),c[3]=Math.max(c[3],e,o)):c=[Math.min(t,a),Math.min(e,o),Math.max(t,a),Math.max(e,o)],this.#e(t,s,n,a,e,i,r,o,3*(-t+3*(s-n)+a),6*(t-2*s+n),3*(s-t),c),this.#e(t,s,n,a,e,i,r,o,3*(-e+3*(i-r)+o),6*(e-2*i+r),3*(i-e),c),c}}function Tn(l){return decodeURIComponent(escape(l))}let is=null,js=null;function Pn(l){return is||(is=/([\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,js=new Map([["ſt","ſt"]])),l.replaceAll(is,(t,e,s)=>e?e.normalize("NFKC"):js.get(s))}function Rn(){if(typeof crypto<"u"&&typeof crypto?.randomUUID=="function")return crypto.randomUUID();const l=new Uint8Array(32);if(typeof crypto<"u"&&typeof crypto?.getRandomValues=="function")crypto.getRandomValues(l);else for(let t=0;t<32;t++)l[t]=Math.floor(Math.random()*255);return bi(l)}const vi="pdfjs_internal_id_",Ft={BEZIER_CURVE_TO:0,MOVE_TO:1,LINE_TO:2,QUADRATIC_CURVE_TO:3,RESTORE:4,SAVE:5,SCALE:6,TRANSFORM:7,TRANSLATE:8};class Ve{constructor(){this.constructor===Ve&&V("Cannot initialize BaseFilterFactory.")}addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,n){return"none"}destroy(t=!1){}}class We{#t=!1;constructor({enableHWA:t=!1}={}){this.constructor===We&&V("Cannot initialize BaseCanvasFactory."),this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#t})}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}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){V("Abstract method `_createCanvas` called.")}}class qe{constructor({baseUrl:t=null,isCompressed:e=!0}){this.constructor===qe&&V("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, 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":""),s=this.isCompressed?cs.BINARY:cs.NONE;return this._fetchData(e,s).catch(i=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}_fetchData(t,e){V("Abstract method `_fetchData` called.")}}class Xe{constructor({baseUrl:t=null}){this.constructor===Xe&&V("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, 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._fetchData(e).catch(s=>{throw new Error(`Unable to load font data at: ${e}`)})}_fetchData(t){V("Abstract method `_fetchData` called.")}}class Es{constructor(){this.constructor===Es&&V("Cannot initialize BaseSVGFactory.")}create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){V("Abstract method `_createSVG` called.")}}const Nt="http://www.w3.org/2000/svg";class le{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}class Ln extends Ve{#t;#e;#s;#n;#o;#i=0;constructor({docId:t,ownerDocument:e=globalThis.document}={}){super(),this.#s=t,this.#n=e}get#r(){return this.#t||=new Map}get#l(){return this.#o||=new Map}get#c(){if(!this.#e){const t=this.#n.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 s=this.#n.createElementNS(Nt,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#e=this.#n.createElementNS(Nt,"defs"),t.append(s),s.append(this.#e),this.#n.body.append(t)}return this.#e}#d(t){if(t.length===1){const o=t[0],c=new Array(256);for(let d=0;d<256;d++)c[d]=o[d]/255;const h=c.join(",");return[h,h,h]}const[e,s,i]=t,n=new Array(256),r=new Array(256),a=new Array(256);for(let o=0;o<256;o++)n[o]=e[o]/255,r[o]=s[o]/255,a[o]=i[o]/255;return[n.join(","),r.join(","),a.join(",")]}addFilter(t){if(!t)return"none";let e=this.#r.get(t);if(e)return e;const[s,i,n]=this.#d(t),r=t.length===1?s:`${s}${i}${n}`;if(e=this.#r.get(r),e)return this.#r.set(t,e),e;const a=`g_${this.#s}_transfer_map_${this.#i++}`,o=`url(#${a})`;this.#r.set(t,o),this.#r.set(r,o);const c=this.#a(a);return this.#m(s,i,n,c),o}addHCMFilter(t,e){const s=`${t}-${e}`,i="base";let n=this.#l.get(i);if(n?.key===s||(n?(n.filter?.remove(),n.key=s,n.url="none",n.filter=null):(n={key:s,url:"none",filter:null},this.#l.set(i,n)),!t||!e))return n.url;const r=this.#v(t);t=R.makeHexColor(...r);const a=this.#v(e);if(e=R.makeHexColor(...a),this.#c.style.color="",t==="#000000"&&e==="#ffffff"||t===e)return n.url;const o=new Array(256);for(let p=0;p<=255;p++){const f=p/255;o[p]=f<=.03928?f/12.92:((f+.055)/1.055)**2.4}const c=o.join(","),h=`g_${this.#s}_hcm_filter`,d=n.filter=this.#a(h);this.#m(c,c,c,d),this.#h(d);const u=(p,f)=>{const g=r[p]/255,b=a[p]/255,m=new Array(f+1);for(let v=0;v<=f;v++)m[v]=g+v/f*(b-g);return m.join(",")};return this.#m(u(0,5),u(1,5),u(2,5),d),n.url=`url(#${h})`,n.url}addAlphaFilter(t){let e=this.#r.get(t);if(e)return e;const[s]=this.#d([t]),i=`alpha_${s}`;if(e=this.#r.get(i),e)return this.#r.set(t,e),e;const n=`g_${this.#s}_alpha_map_${this.#i++}`,r=`url(#${n})`;this.#r.set(t,r),this.#r.set(i,r);const a=this.#a(n);return this.#u(s,a),r}addLuminosityFilter(t){let e=this.#r.get(t||"luminosity");if(e)return e;let s,i;if(t?([s]=this.#d([t]),i=`luminosity_${s}`):i="luminosity",e=this.#r.get(i),e)return this.#r.set(t,e),e;const n=`g_${this.#s}_luminosity_map_${this.#i++}`,r=`url(#${n})`;this.#r.set(t,r),this.#r.set(i,r);const a=this.#a(n);return this.#f(a),t&&this.#u(s,a),r}addHighlightHCMFilter(t,e,s,i,n){const r=`${e}-${s}-${i}-${n}`;let a=this.#l.get(t);if(a?.key===r||(a?(a.filter?.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},this.#l.set(t,a)),!e||!s))return a.url;const[o,c]=[e,s].map(this.#v.bind(this));let h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[u,p]=[i,n].map(this.#v.bind(this));d<h&&([h,d,u,p]=[d,h,p,u]),this.#c.style.color="";const f=(m,v,y)=>{const A=new Array(256),_=(d-h)/y,w=m/255,E=(v-m)/(255*y);let x=0;for(let S=0;S<=y;S++){const L=Math.round(h+S*_),P=w+S*E;for(let G=x;G<=L;G++)A[G]=P;x=L+1}for(let S=x;S<256;S++)A[S]=A[x-1];return A.join(",")},g=`g_${this.#s}_hcm_${t}_filter`,b=a.filter=this.#a(g);return this.#h(b),this.#m(f(u[0],p[0],5),f(u[1],p[1],5),f(u[2],p[2],5),b),a.url=`url(#${g})`,a.url}destroy(t=!1){t&&this.#l.size!==0||(this.#e&&(this.#e.parentNode.parentNode.remove(),this.#e=null),this.#t&&(this.#t.clear(),this.#t=null),this.#i=0)}#f(t){const e=this.#n.createElementNS(Nt,"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)}#h(t){const e=this.#n.createElementNS(Nt,"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)}#a(t){const e=this.#n.createElementNS(Nt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#c.append(e),e}#p(t,e,s){const i=this.#n.createElementNS(Nt,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),t.append(i)}#m(t,e,s,i){const n=this.#n.createElementNS(Nt,"feComponentTransfer");i.append(n),this.#p(n,"feFuncR",t),this.#p(n,"feFuncG",e),this.#p(n,"feFuncB",s)}#u(t,e){const s=this.#n.createElementNS(Nt,"feComponentTransfer");e.append(s),this.#p(s,"feFuncA",t)}#v(t){return this.#c.style.color=t,Ps(getComputedStyle(this.#c).getPropertyValue("color"))}}class kn extends We{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}={}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}async function Ye(l,t="text"){if(be(l,document.baseURI)){const e=await fetch(l);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",l,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class Ai extends qe{_fetchData(t,e){return Ye(t,this.isCompressed?"arraybuffer":"text").then(s=>({cMapData:s instanceof ArrayBuffer?new Uint8Array(s):Ge(s),compressionType:e}))}}class yi extends Xe{_fetchData(t){return Ye(t,"arraybuffer").then(e=>new Uint8Array(e))}}class Ss extends Es{_createSVG(t){return document.createElementNS(Nt,t)}}class we{constructor({viewBox:t,scale:e,rotation:s,offsetX:i=0,offsetY:n=0,dontFlip:r=!1}){this.viewBox=t,this.scale=e,this.rotation=s,this.offsetX=i,this.offsetY=n;const a=(t[2]+t[0])/2,o=(t[3]+t[1])/2;let c,h,d,u;switch(s%=360,s<0&&(s+=360),s){case 180:c=-1,h=0,d=0,u=1;break;case 90:c=0,h=1,d=1,u=0;break;case 270:c=0,h=-1,d=-1,u=0;break;case 0:c=1,h=0,d=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}r&&(d=-d,u=-u);let p,f,g,b;c===0?(p=Math.abs(o-t[1])*e+i,f=Math.abs(a-t[0])*e+n,g=(t[3]-t[1])*e,b=(t[2]-t[0])*e):(p=Math.abs(a-t[0])*e+i,f=Math.abs(o-t[1])*e+n,g=(t[2]-t[0])*e,b=(t[3]-t[1])*e),this.transform=[c*e,h*e,d*e,u*e,p-c*e*a-d*e*o,f-h*e*a-u*e*o],this.width=g,this.height=b}get rawDims(){const{viewBox:t}=this;return B(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new we({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){return R.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=R.applyTransform([t[0],t[1]],this.transform),s=R.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return R.applyInverseTransform([t,e],this.transform)}}class xs extends Wt{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Cs(l){const t=l.length;let e=0;for(;e<t&&l[e].trim()==="";)e++;return l.substring(e,e+5).toLowerCase()==="data:"}function Ts(l){return typeof l=="string"&&/\.pdf$/i.test(l)}function Mn(l){return[l]=l.split(/[#?]/,1),l.substring(l.lastIndexOf("/")+1)}function In(l,t="document.pdf"){if(typeof l!="string")return t;if(Cs(l))return F('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const e=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,s=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=e.exec(l);let n=s.exec(i[1])||s.exec(i[2])||s.exec(i[3]);if(n&&(n=n[0],n.includes("%")))try{n=s.exec(decodeURIComponent(n))[0]}catch{}return n||t}class $s{started=Object.create(null);times=[];time(t){t in this.started&&F(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||F(`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:s}of this.times)e=Math.max(s.length,e);for(const{name:s,start:i,end:n}of this.times)t.push(`${s.padEnd(e)} ${n-i}ms
3
+ `);return t.join("")}}function be(l,t){try{const{protocol:e}=t?new URL(l,t):new URL(l);return e==="http:"||e==="https:"}catch{return!1}}function At(l){l.preventDefault()}function _i(l){console.log("Deprecated API usage: "+l)}let Us;class wi{static toDateObject(t){if(!t||typeof t!="string")return null;Us||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=Us.exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-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 c=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,c==="-"?(r+=h,a+=d):c==="+"&&(r-=h,a-=d),new Date(Date.UTC(s,i,n,r,a,o))}}function Dn(l,{scale:t=1,rotation:e=0}){const{width:s,height:i}=l.attributes.style,n=[0,0,parseInt(s),parseInt(i)];return new we({viewBox:n,scale:t,rotation:e})}function Ps(l){if(l.startsWith("#")){const t=parseInt(l.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return l.startsWith("rgb(")?l.slice(4,-1).split(",").map(t=>parseInt(t)):l.startsWith("rgba(")?l.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(F(`Not a valid color format: "${l}"`),[0,0,0])}function Fn(l){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const e of l.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;l.set(e,Ps(s))}t.remove()}function Y(l){const{a:t,b:e,c:s,d:i,e:n,f:r}=l.getTransform();return[t,e,s,i,n,r]}function Ot(l){const{a:t,b:e,c:s,d:i,e:n,f:r}=l.getTransform().invertSelf();return[t,e,s,i,n,r]}function Yt(l,t,e=!1,s=!0){if(t instanceof we){const{pageWidth:i,pageHeight:n}=t.rawDims,{style:r}=l,a=vt.isCSSRoundSupported,o=`var(--scale-factor) * ${i}px`,c=`var(--scale-factor) * ${n}px`,h=a?`round(${o}, 1px)`:`calc(${o})`,d=a?`round(${c}, 1px)`:`calc(${c})`;!e||t.rotation%180===0?(r.width=h,r.height=d):(r.width=d,r.height=h)}s&&l.setAttribute("data-main-rotation",t.rotation)}class Rs{#t=null;#e=null;#s;#n=null;constructor(t){this.#s=t}render(){const t=this.#t=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");const e=this.#s._uiManager._signal;t.addEventListener("contextmenu",At,{signal:e}),t.addEventListener("pointerdown",Rs.#o,{signal:e});const s=this.#n=document.createElement("div");s.className="buttons",t.append(s);const i=this.#s.toolbarPosition;if(i){const{style:n}=t,r=this.#s._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=`${100*r}%`,n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return this.#c(),t}static#o(t){t.stopPropagation()}#i(t){this.#s._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()}#r(t){this.#s._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()}#l(t){const e=this.#s._uiManager._signal;t.addEventListener("focusin",this.#i.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#r.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",At,{signal:e})}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden")}#c(){const t=document.createElement("button");t.className="delete",t.tabIndex=0,t.setAttribute("data-l10n-id",`pdfjs-editor-remove-${this.#s.editorType}-button`),this.#l(t),t.addEventListener("click",e=>{this.#s._uiManager.delete()},{signal:this.#s._uiManager._signal}),this.#n.append(t)}get#d(){const t=document.createElement("div");return t.className="divider",t}addAltTextButton(t){this.#l(t),this.#n.prepend(t,this.#d)}addColorPicker(t){this.#e=t;const e=t.renderButton();this.#l(e),this.#n.prepend(e,this.#d)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class On{#t=null;#e=null;#s;constructor(t){this.#s=t}#n(){const t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",At,{signal:this.#s._signal});const e=this.#t=document.createElement("div");return e.className="buttons",t.append(e),this.#i(),t}#o(t,e){let s=0,i=0;for(const n of t){const r=n.y+n.height;if(r<s)continue;const a=n.x+(e?n.width:0);if(r>s){i=a,s=r;continue}e?a>i&&(i=a):a<i&&(i=a)}return[e?1-i:i,s]}show(t,e,s){const[i,n]=this.#o(e,s),{style:r}=this.#e||=this.#n();t.append(this.#e),r.insetInlineEnd=`${100*i}%`,r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#i(){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 s=this.#s._signal;t.addEventListener("contextmenu",At,{signal:s}),t.addEventListener("click",()=>{this.#s.highlightSelection("floating_button")},{signal:s}),this.#t.append(t)}}function Ne(l,t,e){for(const s of e)t.addEventListener(s,l[s].bind(l))}function Nn(l){return Math.round(Math.min(255,Math.max(1,255*l))).toString(16).padStart(2,"0")}class Hn{#t=0;get id(){return`${mn}${this.#t++}`}}class Ls{#t=Rn();#e=0;#s=null;static get _isSVGFittingCanvas(){const t='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>',s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;const n=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return B(this,"_isSVGFittingCanvas",n)}async#n(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{s||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let i;if(typeof e=="string"?(s.url=e,i=await Ye(e,"blob")):i=s.file=e,i.type==="image/svg+xml"){const n=Ls._isSVGFittingCanvas,r=new FileReader,a=new Image,o=new Promise((c,h)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,c()},r.onload=async()=>{const d=s.svgUrl=r.result;a.src=await n?`${d}#svgView(preserveAspectRatio(none))`:d},a.onerror=r.onerror=h});r.readAsDataURL(i),await o}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){console.error(i),s=null}return this.#s.set(t,s),s&&this.#s.set(s.id,s),s}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return this.#n(`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return this.#n(t,t)}async getFromId(t){this.#s||=new Map;const e=this.#s.get(t);return e?e.bitmap?(e.refCounter+=1,e):e.file?this.getFromFile(e.file):this.getFromUrl(e.url):null}getSvgUrl(t){const e=this.#s.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#s||=new Map;const e=this.#s.get(t);e&&(e.refCounter-=1,e.refCounter===0&&(e.bitmap=null))}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class Bn{#t=[];#e=!1;#s;#n=-1;constructor(t=128){this.#s=t}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(i&&t(),this.#e)return;const o={cmd:t,undo:e,post:s,type:n};if(this.#n===-1){this.#t.length>0&&(this.#t.length=0),this.#n=0,this.#t.push(o);return}if(r&&this.#t[this.#n].type===n){a&&(o.undo=this.#t[this.#n].undo),this.#t[this.#n]=o;return}const c=this.#n+1;c===this.#s?this.#t.splice(0,1):(this.#n=c,c<this.#t.length&&this.#t.splice(c)),this.#t.push(o)}undo(){if(this.#n===-1)return;this.#e=!0;const{undo:t,post:e}=this.#t[this.#n];t(),e?.(),this.#e=!1,this.#n-=1}redo(){if(this.#n<this.#t.length-1){this.#n+=1,this.#e=!0;const{cmd:t,post:e}=this.#t[this.#n];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#n!==-1}hasSomethingToRedo(){return this.#n<this.#t.length-1}destroy(){this.#t=null}}class Ee{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=vt.platform;for(const[s,i,n={}]of t)for(const r of s){const a=r.startsWith("mac+");e&&a?(this.callbacks.set(r.slice(4),{callback:i,options:n}),this.allKeys.add(r.split("+").at(-1))):!e&&!a&&(this.callbacks.set(r,{callback:i,options:n}),this.allKeys.add(r.split("+").at(-1)))}}#t(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(this.#t(e));if(!s)return;const{callback:i,options:{bubbles:n=!1,args:r=[],checker:a=null}}=s;a&&!a(t,e)||(i.bind(t,...r,e)(),n||(e.stopPropagation(),e.preventDefault()))}}class ks{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return Fn(t),B(this,"_colors",t)}convert(t){const e=Ps(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((n,r)=>n===e[r]))return ks._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?R.makeHexColor(...e):t}}class Gt{#t=new AbortController;#e=null;#s=new Map;#n=new Map;#o=null;#i=null;#r=null;#l=new Bn;#c=0;#d=new Set;#f=null;#h=null;#a=new Set;#p=!1;#m=null;#u=null;#v=null;#g=!1;#A=null;#_=new Hn;#E=!1;#x=!1;#C=null;#L=null;#S=null;#y=N.NONE;#b=new Set;#w=null;#T=null;#P=null;#M=this.blur.bind(this);#k=this.focus.bind(this);#F=this.copy.bind(this);#I=this.cut.bind(this);#O=this.paste.bind(this);#D=this.keydown.bind(this);#G=this.keyup.bind(this);#V=this.onEditingAction.bind(this);#U=this.onPageChanging.bind(this);#j=this.onScaleChanging.bind(this);#N=this.onRotationChanging.bind(this);#Y={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#z=[0,0];#H=null;#$=null;#K=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=Gt.prototype,e=r=>r.#$.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),s=(r,{target:a})=>{if(a instanceof HTMLInputElement){const{type:o}=a;return o!=="text"&&o!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return B(this,"_keyboardManager",new Ee([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.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"],t.delete,{checker:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#$.contains(a)&&!r.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#$.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,s,i,n,r,a,o,c){this._signal=this.#t.signal,this.#$=t,this.#K=e,this.#o=s,this._eventBus=i,this._eventBus._on("editingaction",this.#V),this._eventBus._on("pagechanging",this.#U),this._eventBus._on("scalechanging",this.#j),this._eventBus._on("rotationchanging",this.#N),this.#nt(),this.#lt(),this.#Q(),this.#i=n.annotationStorage,this.#m=n.filterFactory,this.#T=r,this.#v=a||null,this.#p=o,this.#S=c||null,this.viewParameters={realScale:le.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}destroy(){this.#t?.abort(),this.#t=null,this._signal=null,this._eventBus._off("editingaction",this.#V),this._eventBus._off("pagechanging",this.#U),this._eventBus._off("scalechanging",this.#j),this._eventBus._off("rotationchanging",this.#N);for(const t of this.#n.values())t.destroy();this.#n.clear(),this.#s.clear(),this.#a.clear(),this.#e=null,this.#b.clear(),this.#l.destroy(),this.#o?.destroy(),this.#A?.hide(),this.#A=null,this.#u&&(clearTimeout(this.#u),this.#u=null),this.#H&&(clearTimeout(this.#H),this.#H=null)}async mlGuess(t){return this.#S?.guess(t)||null}get hasMLManager(){return!!this.#S}get hcmFilter(){return B(this,"hcmFilter",this.#T?this.#m.addHCMFilter(this.#T.foreground,this.#T.background):"none")}get direction(){return B(this,"direction",getComputedStyle(this.#$).direction)}get highlightColors(){return B(this,"highlightColors",this.#v?new Map(this.#v.split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return B(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setMainHighlightColorPicker(t){this.#L=t}editAltText(t){this.#o?.editAltText(this,t)}onPageChanging({pageNumber:t}){this.#c=t-1}focusMainContainer(){this.#$.focus()}findParent(t,e){for(const s of this.#n.values()){const{x:i,y:n,width:r,height:a}=s.div.getBoundingClientRect();if(t>=i&&t<=i+r&&e>=n&&e<=n+a)return s}return null}disableUserSelect(t=!1){this.#K.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#a.add(t)}removeShouldRescale(t){this.#a.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*le.PDF_TO_CSS_UNITS;for(const e of this.#a)e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#q({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r}=e,a=e.toString(),c=this.#q(e).closest(".textLayer"),h=this.getSelectionBoxes(c);if(h){e.empty(),this.#y===N.NONE&&(this._eventBus.dispatch("showannotationeditorui",{source:this,mode:N.HIGHLIGHT}),this.showAllEditors("highlight",!0,!0));for(const d of this.#n.values())if(d.hasTextLayer(c)){d.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r,text:a});break}}}#st(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=this.#q(t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(this.#A||=new On(this),this.#A.show(s,i,this.direction==="ltr"))}addToAnnotationStorage(t){!t.isEmpty()&&this.#i&&!this.#i.has(t.id)&&this.#i.setValue(t.id,t)}#it(){const t=document.getSelection();if(!t||t.isCollapsed){this.#w&&(this.#A?.hide(),this.#w=null,this.#R({hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===this.#w)return;if(!this.#q(t).closest(".textLayer")){this.#w&&(this.#A?.hide(),this.#w=null,this.#R({hasSelectedText:!1}));return}if(this.#A?.hide(),this.#w=e,this.#R({hasSelectedText:!0}),!(this.#y!==N.HIGHLIGHT&&this.#y!==N.NONE)&&(this.#y===N.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#g=this.isShiftKeyDown,!this.isShiftKeyDown)){const n=this._signal,r=a=>{a.type==="pointerup"&&a.button!==0||(window.removeEventListener("pointerup",r),window.removeEventListener("blur",r),a.type==="pointerup"&&this.#X("main_toolbar"))};window.addEventListener("pointerup",r,{signal:n}),window.addEventListener("blur",r,{signal:n})}}#X(t=""){this.#y===N.HIGHLIGHT?this.highlightSelection(t):this.#p&&this.#st()}#nt(){document.addEventListener("selectionchange",this.#it.bind(this),{signal:this._signal})}#rt(){const t=this._signal;window.addEventListener("focus",this.#k,{signal:t}),window.addEventListener("blur",this.#M,{signal:t})}#at(){window.removeEventListener("focus",this.#k),window.removeEventListener("blur",this.#M)}blur(){if(this.isShiftKeyDown=!1,this.#g&&(this.#g=!1,this.#X("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#b)if(e.div.contains(t)){this.#C=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#C)return;const[t,e]=this.#C;this.#C=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#Q(){const t=this._signal;window.addEventListener("keydown",this.#D,{signal:t}),window.addEventListener("keyup",this.#G,{signal:t})}#ot(){window.removeEventListener("keydown",this.#D),window.removeEventListener("keyup",this.#G)}#J(){const t=this._signal;document.addEventListener("copy",this.#F,{signal:t}),document.addEventListener("cut",this.#I,{signal:t}),document.addEventListener("paste",this.#O,{signal:t})}#Z(){document.removeEventListener("copy",this.#F),document.removeEventListener("cut",this.#I),document.removeEventListener("paste",this.#O)}#lt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#Q(),this.#J()}removeEditListeners(){this.#ot(),this.#Z()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of this.#h)if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of this.#h)if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const s of this.#b){const i=s.serialize(!0);i&&e.push(i)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}paste(t){t.preventDefault();const{clipboardData:e}=t;for(const n of e.items)for(const r of this.#h)if(r.isHandlingMimeForPasting(n.type)){r.paste(n,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){F(`paste: "${n.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const n=[];for(const o of s){const c=i.deserialize(o);if(!c)return;n.push(c)}const r=()=>{for(const o of n)this.#tt(o);this.#et(n)},a=()=>{for(const o of n)o.remove()};this.addCommands({cmd:r,undo:a,mustExec:!0})}catch(n){F(`paste: "${n.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#y!==N.NONE&&!this.isEditorHandlingKeyboard&&Gt._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#g&&(this.#g=!1,this.#X("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}#R(t){Object.entries(t).some(([s,i])=>this.#Y[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#Y,t)}),this.#y===N.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#B([[D.HIGHLIGHT_FREE,!0]]))}#B(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#rt(),this.#J(),this.#R({isEditing:this.#y!==N.NONE,isEmpty:this.#W(),hasSomethingToUndo:this.#l.hasSomethingToUndo(),hasSomethingToRedo:this.#l.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#at(),this.#Z(),this.#R({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#h){this.#h=t;for(const e of this.#h)this.#B(e.defaultPropertiesToUpdate)}}getId(){return this.#_.id}get currentLayer(){return this.#n.get(this.#c)}getLayer(t){return this.#n.get(t)}get currentPageIndex(){return this.#c}addLayer(t){this.#n.set(t.pageIndex,t),this.#E?t.enable():t.disable()}removeLayer(t){this.#n.delete(t.pageIndex)}updateMode(t,e=null,s=!1){if(this.#y!==t){if(this.#y=t,t===N.NONE){this.setEditingState(!1),this.#ct();return}this.setEditingState(!0),this.#ht(),this.unselectAll();for(const i of this.#n.values())i.updateMode(t);if(!e&&s){this.addNewEditorFromKeyboard();return}if(e){for(const i of this.#s.values())if(i.annotationElementId===e){this.setSelected(i),i.enterInEditMode();break}}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#y&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#h){switch(t){case D.CREATE:this.currentLayer.addNewEditor();return;case D.HIGHLIGHT_DEFAULT_COLOR:this.#L?.updateColor(e);break;case D.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#P||=new Map).set(t,e),this.showAllEditors("highlight",e);break}for(const s of this.#b)s.updateParams(t,e);for(const s of this.#h)s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){for(const n of this.#s.values())n.editorType===t&&n.show(e);(this.#P?.get(D.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#B([[D.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#x!==t){this.#x=t;for(const e of this.#n.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}#ht(){if(!this.#E){this.#E=!0;for(const t of this.#n.values())t.enable();for(const t of this.#s.values())t.enable()}}#ct(){if(this.unselectAll(),this.#E){this.#E=!1;for(const t of this.#n.values())t.disable();for(const t of this.#s.values())t.disable()}}getEditors(t){const e=[];for(const s of this.#s.values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return this.#s.get(t)}addEditor(t){this.#s.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#u&&clearTimeout(this.#u),this.#u=setTimeout(()=>{this.focusMainContainer(),this.#u=null},0)),this.#s.delete(t.id),this.unselect(t),(!t.annotationElementId||!this.#d.has(t.annotationElementId))&&this.#i?.remove(t.id)}addDeletedAnnotationElement(t){this.#d.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#d.has(t)}removeDeletedAnnotationElement(t){this.#d.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#tt(t){const e=this.#n.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#B(t.propertiesToUpdate))}get#dt(){let t=null;for(t of this.#b);return t}updateUI(t){this.#dt===t&&this.#B(t.propertiesToUpdate)}toggleSelected(t){if(this.#b.has(t)){this.#b.delete(t),t.unselect(),this.#R({hasSelectedEditor:this.hasSelection});return}this.#b.add(t),t.select(),this.#B(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}setSelected(t){for(const e of this.#b)e!==t&&e.unselect();this.#b.clear(),this.#b.add(t),t.select(),this.#B(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}isSelected(t){return this.#b.has(t)}get firstSelectedEditor(){return this.#b.values().next().value}unselect(t){t.unselect(),this.#b.delete(t),this.#R({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#b.size!==0}get isEnterHandled(){return this.#b.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#l.undo(),this.#R({hasSomethingToUndo:this.#l.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#W()})}redo(){this.#l.redo(),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:this.#l.hasSomethingToRedo(),isEmpty:this.#W()})}addCommands(t){this.#l.add(t),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#W()})}#W(){if(this.#s.size===0)return!0;if(this.#s.size===1)for(const t of this.#s.values())return t.isEmpty();return!1}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...this.#b],e=()=>{for(const i of t)i.remove()},s=()=>{for(const i of t)this.#tt(i)};this.addCommands({cmd:e,undo:s,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#et(t){for(const e of this.#b)e.unselect();this.#b.clear();for(const e of t)e.isEmpty()||(this.#b.add(e),e.select());this.#R({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#b)t.commit();this.#et(this.#s.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#y!==N.NONE))&&this.hasSelection){for(const t of this.#b)t.unselect();this.#b.clear(),this.#R({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;this.#z[0]+=t,this.#z[1]+=e;const[i,n]=this.#z,r=[...this.#b],a=1e3;this.#H&&clearTimeout(this.#H),this.#H=setTimeout(()=>{this.#H=null,this.#z[0]=this.#z[1]=0,this.addCommands({cmd:()=>{for(const o of r)this.#s.has(o.id)&&o.translateInPage(i,n)},undo:()=>{for(const o of r)this.#s.has(o.id)&&o.translateInPage(-i,-n)},mustExec:!1})},a);for(const o of r)o.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#f=new Map;for(const t of this.#b)this.#f.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#f)return!1;this.disableUserSelect(!1);const t=this.#f;this.#f=null;let e=!1;for(const[{x:i,y:n,pageIndex:r},a]of t)a.newX=i,a.newY=n,a.newPageIndex=r,e||=i!==a.savedX||n!==a.savedY||r!==a.savedPageIndex;if(!e)return!1;const s=(i,n,r,a)=>{if(this.#s.has(i.id)){const o=this.#n.get(a);o?i._setParentAndPosition(o,n,r):(i.pageIndex=a,i.x=n,i.y=r)}};return this.addCommands({cmd:()=>{for(const[i,{newX:n,newY:r,newPageIndex:a}]of t)s(i,n,r,a)},undo:()=>{for(const[i,{savedX:n,savedY:r,savedPageIndex:a}]of t)s(i,n,r,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#f)for(const s of this.#f.keys())s.drag(t,e)}rebuild(t){if(t.parent===null){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()||this.#b.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#y}get imageManager(){return B(this,"imageManager",new Ls)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let c=0,h=e.rangeCount;c<h;c++)if(!t.contains(e.getRangeAt(c).commonAncestorContainer))return null;const{x:s,y:i,width:n,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(c,h,d,u)=>({x:(h-i)/r,y:1-(c+d-s)/n,width:u/r,height:d/n});break;case"180":a=(c,h,d,u)=>({x:1-(c+d-s)/n,y:1-(h+u-i)/r,width:d/n,height:u/r});break;case"270":a=(c,h,d,u)=>({x:1-(h+u-i)/r,y:(c-s)/n,width:u/r,height:d/n});break;default:a=(c,h,d,u)=>({x:(c-s)/n,y:(h-i)/r,width:d/n,height:u/r});break}const o=[];for(let c=0,h=e.rangeCount;c<h;c++){const d=e.getRangeAt(c);if(!d.collapsed)for(const{x:u,y:p,width:f,height:g}of d.getClientRects())f===0||g===0||o.push(a(u,p,f,g))}return o.length===0?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 s=this.#i.getRawValue(e);s&&(this.#y===N.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}}class qt{#t="";#e=!1;#s=null;#n=null;#o=null;#i=!1;#r=null;static _l10nPromise=null;constructor(t){this.#r=t}static initialize(t){qt._l10nPromise||=t}async render(){const t=this.#s=document.createElement("button");t.className="altText";const e=await qt._l10nPromise.get("pdfjs-editor-alt-text-button-label");t.textContent=e,t.setAttribute("aria-label",e),t.tabIndex="0";const s=this.#r._uiManager._signal;t.addEventListener("contextmenu",At,{signal:s}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),this.#r._uiManager.editAltText(this.#r)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(this.#i=!0,i(n))},{signal:s}),await this.#l(),t}finish(){this.#s&&(this.#s.focus({focusVisible:this.#i}),this.#i=!1)}isEmpty(){return!this.#t&&!this.#e}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e}){this.#t===t&&this.#e===e||(this.#t=t,this.#e=e,this.#l())}toggle(t=!1){this.#s&&(!t&&this.#o&&(clearTimeout(this.#o),this.#o=null),this.#s.disabled=!t)}destroy(){this.#s?.remove(),this.#s=null,this.#n=null}async#l(){const t=this.#s;if(!t)return;if(!this.#t&&!this.#e){t.classList.remove("done"),this.#n?.remove();return}t.classList.add("done"),qt._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then(i=>{t.setAttribute("aria-label",i)});let e=this.#n;if(!e){this.#n=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip");const i=e.id=`alt-text-tooltip-${this.#r.id}`;t.setAttribute("aria-describedby",i);const n=100,r=this.#r._uiManager._signal;r.addEventListener("abort",()=>{clearTimeout(this.#o),this.#o=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#o=setTimeout(()=>{this.#o=null,this.#n.classList.add("show"),this.#r._reportTelemetry({action:"alt_text_tooltip"})},n)},{signal:r}),t.addEventListener("mouseleave",()=>{this.#o&&(clearTimeout(this.#o),this.#o=null),this.#n?.classList.remove("show")},{signal:r})}e.innerText=this.#e?await qt._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):this.#t,e.parentNode||t.append(e),this.#r.getImageForAltText()?.setAttribute("aria-describedby",e.id)}}class I{#t=null;#e=null;#s=null;#n=!1;#o=!1;#i=null;#r=null;#l=this.focusin.bind(this);#c=this.focusout.bind(this);#d=null;#f="";#h=!1;#a=null;#p=!1;#m=!1;#u=!1;#v=null;#g=0;#A=0;#_=null;_initialOptions=Object.create(null);_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;_l10nPromise=null;#E=!1;#x=I._zIndex++;static _borderLineWidth=-1;static _colorManager=new ks;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=I.prototype._resizeWithKeyboard,e=Gt.TRANSLATE_SMALL,s=Gt.TRANSLATE_BIG;return B(this,"_resizerKeyboardManager",new Ee([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape","mac+Escape"],I.prototype._stopResizingWithKeyboard]]))}constructor(t){this.constructor===I&&V("Cannot initialize AnnotationEditor."),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:s,pageHeight:i,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],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 _defaultLineColor(){return B(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new jn({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,s){if(I._l10nPromise||=new Map(["pdfjs-editor-alt-text-button-label","pdfjs-editor-alt-text-edit-button-label","pdfjs-editor-alt-text-decorative-tooltip","pdfjs-editor-resizer-label-topLeft","pdfjs-editor-resizer-label-topMiddle","pdfjs-editor-resizer-label-topRight","pdfjs-editor-resizer-label-middleRight","pdfjs-editor-resizer-label-bottomRight","pdfjs-editor-resizer-label-bottomMiddle","pdfjs-editor-resizer-label-bottomLeft","pdfjs-editor-resizer-label-middleLeft"].map(n=>[n,t.get(n.replaceAll(/([A-Z])/g,r=>`-${r.toLowerCase()}`))])),s?.strings)for(const n of s.strings)I._l10nPromise.set(n,t.get(n));if(I._borderLineWidth!==-1)return;const i=getComputedStyle(document.documentElement);I._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){V("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#E}set _isDraggable(t){this.#E=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/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}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.#x}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#D(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#h?this.#h=!1:this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||t.relatedTarget?.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,s,i){const[n,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/r,this.fixAndSetPosition()}#C([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this.fixAndSetPosition()}translate(t,e){this.#C(this.parentDimensions,t,e)}translateInPage(t,e){this.#a||=[this.x,this.y],this.#C(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#a||=[this.x,this.y];const[s,i]=this.parentDimensions;if(this.x+=t/s,this.y+=e/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:c,y:h}=this.div.getBoundingClientRect();this.parent.findNewParent(this,c,h)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:r}=this;const[a,o]=this.getBaseTranslation();n+=a,r+=o,this.div.style.left=`${(100*n).toFixed(2)}%`,this.div.style.top=`${(100*r).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!this.#a&&(this.#a[0]!==this.x||this.#a[1]!==this.y)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=I,i=s/t,n=s/e;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const[e,s]=this.pageDimensions;let{x:i,y:n,width:r,height:a}=this;if(r*=e,a*=s,i*=e,n*=s,this._mustFixPosition)switch(t){case 0:i=Math.max(0,Math.min(e-r,i)),n=Math.max(0,Math.min(s-a,n));break;case 90:i=Math.max(0,Math.min(e-a,i)),n=Math.min(s,Math.max(r,n));break;case 180:i=Math.min(e,Math.max(r,i)),n=Math.min(s,Math.max(a,n));break;case 270:i=Math.min(e,Math.max(a,i)),n=Math.max(0,Math.min(s-r,n));break}this.x=i/=e,this.y=n/=s;const[o,c]=this.getBaseTranslation();i+=o,n+=c;const{style:h}=this.div;h.left=`${(100*i).toFixed(2)}%`,h.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}static#L(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return I.#L(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return I.#L(t,e,360-this.parentRotation)}#S(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,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,s]}=this,i=e*t,n=s*t;return vt.isCSSRoundSupported?[Math.round(i),Math.round(n)]:[i,n]}setDims(t,e){const[s,i]=this.parentDimensions;this.div.style.width=`${(100*t/s).toFixed(2)}%`,this.#o||(this.div.style.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),n=!this.#o&&e.endsWith("%");if(i&&n)return;const[r,a]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/r).toFixed(2)}%`),!this.#o&&!n&&(t.height=`${(100*parseFloat(e)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#y(){if(this.#i)return;this.#i=document.createElement("div"),this.#i.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 s of t){const i=document.createElement("div");this.#i.append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",this.#b.bind(this,s),{signal:e}),i.addEventListener("contextmenu",At,{signal:e}),i.tabIndex=-1}this.div.prepend(this.#i)}#b(t,e){e.preventDefault();const{isMac:s}=vt.platform;if(e.button!==0||e.ctrlKey&&s)return;this.#s?.toggle(!1);const i=this.#T.bind(this,t),n=this._isDraggable;this._isDraggable=!1;const r=this._uiManager._signal,a={passive:!0,capture:!0,signal:r};this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",i,a),window.addEventListener("contextmenu",At,{signal:r});const o=this.x,c=this.y,h=this.width,d=this.height,u=this.parent.div.style.cursor,p=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const f=()=>{this.parent.togglePointerEvents(!0),this.#s?.toggle(!0),this._isDraggable=n,window.removeEventListener("pointerup",f),window.removeEventListener("blur",f),window.removeEventListener("pointermove",i,a),window.removeEventListener("contextmenu",At),this.parent.div.style.cursor=u,this.div.style.cursor=p,this.#w(o,c,h,d)};window.addEventListener("pointerup",f,{signal:r}),window.addEventListener("blur",f,{signal:r})}#w(t,e,s,i){const n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===s&&o===i||this.addCommands({cmd:()=>{this.width=a,this.height=o,this.x=n,this.y=r;const[c,h]=this.parentDimensions;this.setDims(c*a,h*o),this.fixAndSetPosition()},undo:()=>{this.width=s,this.height=i,this.x=t,this.y=e;const[c,h]=this.parentDimensions;this.setDims(c*s,h*i),this.fixAndSetPosition()},mustExec:!0})}#T(t,e){const[s,i]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,c=I.MIN_SIZE/s,h=I.MIN_SIZE/i,d=T=>Math.round(T*1e4)/1e4,u=this.#S(this.rotation),p=(T,k)=>[u[0]*T+u[2]*k,u[1]*T+u[3]*k],f=this.#S(360-this.rotation),g=(T,k)=>[f[0]*T+f[2]*k,f[1]*T+f[3]*k];let b,m,v=!1,y=!1;switch(t){case"topLeft":v=!0,b=(T,k)=>[0,0],m=(T,k)=>[T,k];break;case"topMiddle":b=(T,k)=>[T/2,0],m=(T,k)=>[T/2,k];break;case"topRight":v=!0,b=(T,k)=>[T,0],m=(T,k)=>[0,k];break;case"middleRight":y=!0,b=(T,k)=>[T,k/2],m=(T,k)=>[0,k/2];break;case"bottomRight":v=!0,b=(T,k)=>[T,k],m=(T,k)=>[0,0];break;case"bottomMiddle":b=(T,k)=>[T/2,k],m=(T,k)=>[T/2,0];break;case"bottomLeft":v=!0,b=(T,k)=>[0,k],m=(T,k)=>[T,0];break;case"middleLeft":y=!0,b=(T,k)=>[0,k/2],m=(T,k)=>[T,k/2];break}const A=b(a,o),_=m(a,o);let w=p(..._);const E=d(n+w[0]),x=d(r+w[1]);let S=1,L=1,[P,G]=this.screenToPageTranslation(e.movementX,e.movementY);if([P,G]=g(P/s,G/i),v){const T=Math.hypot(a,o);S=L=Math.max(Math.min(Math.hypot(_[0]-A[0]-P,_[1]-A[1]-G)/T,1/a,1/o),c/a,h/o)}else y?S=Math.max(c,Math.min(1,Math.abs(_[0]-A[0]-P)))/a:L=Math.max(h,Math.min(1,Math.abs(_[1]-A[1]-G)))/o;const j=d(a*S),O=d(o*L);w=p(...m(j,O));const $=E-w[0],U=x-w[1];this.width=j,this.height=O,this.x=$,this.y=U,this.setDims(s*j,i*O),this.fixAndSetPosition()}altTextFinish(){this.#s?.finish()}async addEditToolbar(){return this.#d||this.#m?this.#d:(this.#d=new Rs(this),this.div.append(this.#d.render()),this.#s&&this.#d.addAltTextButton(await this.#s.render()),this.#d)}removeEditToolbar(){this.#d&&(this.#d.remove(),this.#d=null,this.#s?.destroy())}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#s||(qt.initialize(I._l10nPromise),this.#s=new qt(this),this.#t&&(this.#s.data=this.#t,this.#t=null),await this.addEditToolbar())}get altTextData(){return this.#s?.data}set altTextData(t){this.#s&&(this.#s.data=t)}hasAltText(){return!this.#s?.isEmpty()}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.#n?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground();const t=this._uiManager._signal;this.div.addEventListener("focusin",this.#l,{signal:t}),this.div.addEventListener("focusout",this.#c,{signal:t});const[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*s/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,n]=this.getInitialTranslation();return this.translate(i,n),Ne(this,this.div,["pointerdown"]),this.div}pointerdown(t){const{isMac:e}=vt.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#h=!0,this._isDraggable){this.#M(t);return}this.#P(t)}#P(t){const{isMac:e}=vt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#M(t){const e=this._uiManager.isSelected(this);this._uiManager.setUpDragSession();let s,i;const n=this._uiManager._signal;e&&(this.div.classList.add("moving"),s={passive:!0,capture:!0,signal:n},this.#g=t.clientX,this.#A=t.clientY,i=a=>{const{clientX:o,clientY:c}=a,[h,d]=this.screenToPageTranslation(o-this.#g,c-this.#A);this.#g=o,this.#A=c,this._uiManager.dragSelectedEditors(h,d)},window.addEventListener("pointermove",i,s));const r=()=>{window.removeEventListener("pointerup",r),window.removeEventListener("blur",r),e&&(this.div.classList.remove("moving"),window.removeEventListener("pointermove",i,s)),this.#h=!1,this._uiManager.endDragSession()||this.#P(t)};window.addEventListener("pointerup",r,{signal:n}),window.addEventListener("blur",r,{signal:n})}moveInDOM(){this.#v&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.#v=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition()}getRect(t,e,s=this.rotation){const i=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,c=t/i,h=e/i,d=this.x*n,u=this.y*r,p=this.width*n,f=this.height*r;switch(s){case 0:return[d+c+a,r-u-h-f+o,d+c+p+a,r-u-h+o];case 90:return[d+h+a,r-u+c+o,d+h+f+a,r-u+c+p+o];case 180:return[d-c-p+a,r-u+h+o,d-c+a,r-u+h+f+o];case 270:return[d-h-f+a,r-u-c-p+o,d-h+a,r-u-c+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,r]=t,a=n-s,o=r-i;switch(this.rotation){case 0:return[s,e-r,a,o];case 90:return[s,e-i,o,a];case 180:return[n,e-i,a,o];case 270:return[n,e-r,o,a];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){this.#m=!0}disableEditMode(){this.#m=!1}isInEditMode(){return this.#m}shouldGetKeyboardEvents(){return this.#u}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){const t=this._uiManager._signal;this.div?.addEventListener("focusin",this.#l,{signal:t}),this.div?.addEventListener("focusout",this.#c,{signal:t})}rotate(t){}serialize(t=!1,e=null){V("An editor must be serializable")}static deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s});i.rotation=t.rotation,i.#t=t.accessibilityData;const[n,r]=i.pageDimensions,[a,o,c,h]=i.getRectInCurrentCoords(t.rect,r);return i.x=a/n,i.y=o/r,i.width=c/n,i.height=h/r,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.div.removeEventListener("focusin",this.#l),this.div.removeEventListener("focusout",this.#c),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#v&&(clearTimeout(this.#v),this.#v=null),this.#D(),this.removeEditToolbar(),this.#_){for(const t of this.#_.values())clearTimeout(t);this.#_=null}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#y(),this.#i.classList.remove("hidden"),Ne(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#r={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#i.children;if(!this.#e){this.#e=Array.from(e);const r=this.#k.bind(this),a=this.#F.bind(this),o=this._uiManager._signal;for(const c of this.#e){const h=c.getAttribute("data-resizer-name");c.setAttribute("role","spinbutton"),c.addEventListener("keydown",r,{signal:o}),c.addEventListener("blur",a,{signal:o}),c.addEventListener("focus",this.#I.bind(this,h),{signal:o}),I._l10nPromise.get(`pdfjs-editor-resizer-label-${h}`).then(d=>c.setAttribute("aria-label",d))}}const s=this.#e[0];let i=0;for(const r of e){if(r===s)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(n!==i){if(n<i)for(let a=0;a<i-n;a++)this.#i.append(this.#i.firstChild);else if(n>i)for(let a=0;a<n-i;a++)this.#i.firstChild.before(this.#i.lastChild);let r=0;for(const a of e){const c=this.#e[r++].getAttribute("data-resizer-name");I._l10nPromise.get(`pdfjs-editor-resizer-label-${c}`).then(h=>a.setAttribute("aria-label",h))}}this.#O(0),this.#u=!0,this.#i.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#k(t){I._resizerKeyboardManager.exec(this,t)}#F(t){this.#u&&t.relatedTarget?.parentNode!==this.#i&&this.#D()}#I(t){this.#f=this.#u?t:""}#O(t){if(this.#e)for(const e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#u&&this.#T(this.#f,{movementX:t,movementY:e})}#D(){if(this.#u=!1,this.#O(-1),this.#r){const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=this.#r;this.#w(t,e,s,i),this.#r=null}}_stopResizingWithKeyboard(){this.#D(),this.div.focus()}select(){if(this.makeResizable(),this.div?.classList.add("selectedEditor"),!this.#d){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this.#d?.show()});return}this.#d?.show()}unselect(){this.#i?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this.#d?.hide()}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#p}set isEditing(t){this.#p=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#o=!0;const s=t/e,{style:i}=this.div;i.aspectRatio=s,i.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.#_||=new Map;const{action:s}=t;let i=this.#_.get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#_.delete(s),this.#_.size===0&&(this.#_=null)},I._telemetryTimeout),this.#_.set(s,i);return}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.#n=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#n=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstChild:e}=t.container;e.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class jn extends I{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}const zs=3285377520,xt=4294901760,Lt=65535;class Ei{constructor(t){this.h1=t?t&4294967295:zs,this.h2=t?t&4294967295:zs}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let g=0,b=t.length;g<b;g++){const m=t.charCodeAt(g);m<=255?e[s++]=m:(e[s++]=m>>>8,e[s++]=m&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,n=s-i*4,r=new Uint32Array(e.buffer,0,i);let a=0,o=0,c=this.h1,h=this.h2;const d=3432918353,u=461845907,p=d&Lt,f=u&Lt;for(let g=0;g<i;g++)g&1?(a=r[g],a=a*d&xt|a*p&Lt,a=a<<15|a>>>17,a=a*u&xt|a*f&Lt,c^=a,c=c<<13|c>>>19,c=c*5+3864292196):(o=r[g],o=o*d&xt|o*p&Lt,o=o<<15|o>>>17,o=o*u&xt|o*f&Lt,h^=o,h=h<<13|h>>>19,h=h*5+3864292196);switch(a=0,n){case 3:a^=e[i*4+2]<<16;case 2:a^=e[i*4+1]<<8;case 1:a^=e[i*4],a=a*d&xt|a*p&Lt,a=a<<15|a>>>17,a=a*u&xt|a*f&Lt,i&1?c^=a:h^=a}this.h1=c,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&xt|t*36045&Lt,e=e*4283543511&xt|((e<<16|t>>>16)*2950163797&xt)>>>16,t^=e>>>1,t=t*444984403&xt|t*60499&Lt,e=e*3301882366&xt|((e<<16|t>>>16)*3120437893&xt)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const fs=Object.freeze({map:null,hash:"",transfer:void 0});class Ms{#t=!1;#e=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=this.#e.get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return this.#e.get(t)}remove(t){if(this.#e.delete(t),this.#e.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of this.#e.values())if(e instanceof I)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=this.#e.get(t);let i=!1;if(s!==void 0)for(const[n,r]of Object.entries(e))s[n]!==r&&(i=!0,s[n]=r);else i=!0,this.#e.set(t,e);i&&this.#s(),e instanceof I&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#e.has(t)}getAll(){return this.#e.size>0?ws(this.#e):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return this.#e.size}#s(){this.#t||(this.#t=!0,typeof this.onSetModified=="function"&&this.onSetModified())}resetModified(){this.#t&&(this.#t=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Si(this)}get serializable(){if(this.#e.size===0)return fs;const t=new Map,e=new Ei,s=[],i=Object.create(null);let n=!1;for(const[r,a]of this.#e){const o=a instanceof I?a.serialize(!1,i):a;o&&(t.set(r,o),e.update(`${r}:${JSON.stringify(o)}`),n||=!!o.bitmap)}if(n)for(const r of t.values())r.bitmap&&s.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:fs}get editorStats(){let t=null;const e=new Map;for(const s of this.#e.values()){if(!(s instanceof I))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:n}=i;e.has(n)||e.set(n,Object.getPrototypeOf(s).constructor),t||=Object.create(null);const r=t[n]||=new Map;for(const[a,o]of Object.entries(i)){if(a==="type")continue;let c=r.get(a);c||(c=new Map,r.set(a,c));const h=c.get(o)??0;c.set(o,h+1)}}for(const[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}}class Si extends Ms{#t;constructor(t){super();const{map:e,hash:s,transfer:i}=t.serializable,n=structuredClone(e,i?{transfer:i}:null);this.#t={map:n,hash:s,transfer:i}}get print(){V("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}}class $n{#t=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.#t.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||this.#t.has(t.loadedName))){if(nt(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:i,style:n}=t,r=new FontFace(s,i,n);this.addNativeFontFace(r);try{await r.load(),this.#t.add(s),e?.(t)}catch{F(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}return}V("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){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw F(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){const t=!!this._document?.fonts;return B(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(ut||typeof navigator<"u"&&typeof navigator?.userAgent=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),B(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(nt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const n=s.shift();setTimeout(n.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return B(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(A,_){return A.charCodeAt(_)<<24|A.charCodeAt(_+1)<<16|A.charCodeAt(_+2)<<8|A.charCodeAt(_+3)&255}function i(A,_,w,E){const x=A.substring(0,_),S=A.substring(_+w);return x+E+S}let n,r;const a=this._document.createElement("canvas");a.width=1,a.height=1;const o=a.getContext("2d");let c=0;function h(A,_){if(++c>30){F("Load test font never loaded."),_();return}if(o.font="30px "+A,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0){_();return}setTimeout(h.bind(null,A,_))}const d=`lt${Date.now()}${this.loadTestFontId++}`;let u=this._loadTestFont;u=i(u,976,d.length,d);const f=16,g=1482184792;let b=s(u,f);for(n=0,r=d.length-3;n<r;n+=4)b=b-g+s(d,n)|0;n<d.length&&(b=b-g+s(d+"XXX",n)|0),u=i(u,f,4,Sn(b));const m=`url(data:font/opentype;base64,${btoa(u)});`,v=`@font-face {font-family:"${d}";src:${m}}`;this.insertRule(v);const y=this._document.createElement("div");y.style.visibility="hidden",y.style.width=y.style.height="10px",y.style.position="absolute",y.style.top=y.style.left="0px";for(const A of[t.loadedName,d]){const _=this._document.createElement("span");_.textContent="Hi",_.style.fontFamily=A,y.append(_)}this._document.body.append(y),h(d,()=>{y.remove(),e.complete()})}}class Un{constructor(t,{disableFontFace:e=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const i in t)this[i]=t[i];this.disableFontFace=e===!0,this._inspectFont=s}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{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)}return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=bi(this.data),e=`url(data:${this.mimetype};base64,${btoa(t)});`;let s;if(!this.cssFontInfo)s=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),s=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${e}}`}return this._inspectFont?.(this,e),s}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];let s;try{s=t.get(this.loadedName+"_path_"+e)}catch(n){F(`getPathGenerator - ignoring character: "${n}".`)}if(!Array.isArray(s)||s.length===0)return this.compiledGlyphs[e]=function(n,r){};const i=[];for(let n=0,r=s.length;n<r;)switch(s[n++]){case Ft.BEZIER_CURVE_TO:{const[a,o,c,h,d,u]=s.slice(n,n+6);i.push(p=>p.bezierCurveTo(a,o,c,h,d,u)),n+=6}break;case Ft.MOVE_TO:{const[a,o]=s.slice(n,n+2);i.push(c=>c.moveTo(a,o)),n+=2}break;case Ft.LINE_TO:{const[a,o]=s.slice(n,n+2);i.push(c=>c.lineTo(a,o)),n+=2}break;case Ft.QUADRATIC_CURVE_TO:{const[a,o,c,h]=s.slice(n,n+4);i.push(d=>d.quadraticCurveTo(a,o,c,h)),n+=4}break;case Ft.RESTORE:i.push(a=>a.restore());break;case Ft.SAVE:i.push(a=>a.save());break;case Ft.SCALE:nt(i.length===2,"Scale command is only valid at the third position.");break;case Ft.TRANSFORM:{const[a,o,c,h,d,u]=s.slice(n,n+6);i.push(p=>p.transform(a,o,c,h,d,u)),n+=6}break;case Ft.TRANSLATE:{const[a,o]=s.slice(n,n+2);i.push(c=>c.translate(a,o)),n+=2}break}return this.compiledGlyphs[e]=function(r,a){i[0](r),i[1](r),r.scale(a,-a);for(let o=2,c=i.length;o<c;o++)i[o](r)}}}if(ut){var ps=Promise.withResolvers(),gs=null;(async()=>{const t=await Le(()=>import("./empty-8w7lnNDy.js").then(a=>a.e),__vite__mapDeps([0,1,2])),e=await Le(()=>import("./index-BYZPrbCg.js").then(a=>a.i),__vite__mapDeps([3,1,4,5,6,7,8,9])),s=await Le(()=>import("./index-D414nesG.js").then(a=>a.i),__vite__mapDeps([10,1,11,4,5,6,7,8,9])),i=await Le(()=>import("./url-DI-fObeY.js").then(a=>a.u),__vite__mapDeps([12,1,9,7,5,6,8]));let n,r;return new Map(Object.entries({fs:t,http:e,https:s,url:i,canvas:n,path2d:r}))})().then(t=>{gs=t,ps.resolve()},t=>{F(`loadPackages: ${t}`),gs=new Map,ps.resolve()})}class Dt{static get promise(){return ps.promise}static get(t){return gs?.get(t)}}const xi=function(l){return Dt.get("fs").promises.readFile(l).then(e=>new Uint8Array(e))};class zn extends Ve{}class Gn extends We{_createCanvas(t,e){return Dt.get("canvas").createCanvas(t,e)}}class Vn extends qe{_fetchData(t,e){return xi(t).then(s=>({cMapData:s,compressionType:e}))}}class Wn extends Xe{_fetchData(t){return xi(t)}}const pt={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function ms(l,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),l.clip(i)}class Se{constructor(){this.constructor===Se&&V("Cannot initialize BaseShadingPattern.")}getPattern(){V("Abstract method `getPattern` called.")}}class qn extends Se{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;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)e.addColorStop(s[0],s[1]);return e}getPattern(t,e,s,i){let n;if(i===pt.STROKE||i===pt.FILL){const r=e.current.getClippedPathBoundingBox(i,Y(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,c=e.cachedCanvases.getCanvas("pattern",a,o,!0),h=c.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]),s=R.transform(s,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),ms(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),n=t.createPattern(c.canvas,"no-repeat");const d=new DOMMatrix(s);n.setTransform(d)}else ms(t,this._bbox),n=this._createGradient(t);return n}}function ns(l,t,e,s,i,n,r,a){const o=t.coords,c=t.colors,h=l.data,d=l.width*4;let u;o[e+1]>o[s+1]&&(u=e,e=s,s=u,u=n,n=r,r=u),o[s+1]>o[i+1]&&(u=s,s=i,i=u,u=r,r=a,a=u),o[e+1]>o[s+1]&&(u=e,e=s,s=u,u=n,n=r,r=u);const p=(o[e]+t.offsetX)*t.scaleX,f=(o[e+1]+t.offsetY)*t.scaleY,g=(o[s]+t.offsetX)*t.scaleX,b=(o[s+1]+t.offsetY)*t.scaleY,m=(o[i]+t.offsetX)*t.scaleX,v=(o[i+1]+t.offsetY)*t.scaleY;if(f>=v)return;const y=c[n],A=c[n+1],_=c[n+2],w=c[r],E=c[r+1],x=c[r+2],S=c[a],L=c[a+1],P=c[a+2],G=Math.round(f),j=Math.round(v);let O,$,U,T,k,yt,Et,$t;for(let Q=G;Q<=j;Q++){if(Q<b){const q=Q<f?0:(f-Q)/(f-b);O=p-(p-g)*q,$=y-(y-w)*q,U=A-(A-E)*q,T=_-(_-x)*q}else{let q;Q>v?q=1:b===v?q=0:q=(b-Q)/(b-v),O=g-(g-m)*q,$=w-(w-S)*q,U=E-(E-L)*q,T=x-(x-P)*q}let X;Q<f?X=0:Q>v?X=1:X=(f-Q)/(f-v),k=p-(p-m)*X,yt=y-(y-S)*X,Et=A-(A-L)*X,$t=_-(_-P)*X;const St=Math.round(Math.min(O,k)),_t=Math.round(Math.max(O,k));let ft=d*Q+St*4;for(let q=St;q<=_t;q++)X=(O-q)/(O-k),X<0?X=0:X>1&&(X=1),h[ft++]=$-($-yt)*X|0,h[ft++]=U-(U-Et)*X|0,h[ft++]=T-(T-$t)*X|0,h[ft++]=255}}function Xn(l,t,e){const s=t.coords,i=t.colors;let n,r;switch(t.type){case"lattice":const a=t.verticesPerRow,o=Math.floor(s.length/a)-1,c=a-1;for(n=0;n<o;n++){let h=n*a;for(let d=0;d<c;d++,h++)ns(l,e,s[h],s[h+1],s[h+a],i[h],i[h+1],i[h+a]),ns(l,e,s[h+a+1],s[h+1],s[h+a],i[h+a+1],i[h+1],i[h+a])}break;case"triangles":for(n=0,r=s.length;n<r;n+=3)ns(l,e,s[n],s[n+1],s[n+2],i[n],i[n+1],i[n+2]);break;default:throw new Error("illegal figure")}}class Yn extends Se{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,s){const a=Math.floor(this._bounds[0]),o=Math.floor(this._bounds[1]),c=Math.ceil(this._bounds[2])-a,h=Math.ceil(this._bounds[3])-o,d=Math.min(Math.ceil(Math.abs(c*t[0]*1.1)),3e3),u=Math.min(Math.ceil(Math.abs(h*t[1]*1.1)),3e3),p=c/d,f=h/u,g={coords:this._coords,colors:this._colors,offsetX:-a,offsetY:-o,scaleX:1/p,scaleY:1/f},b=d+4,m=u+4,v=s.getCanvas("mesh",b,m,!1),y=v.context,A=y.createImageData(d,u);if(e){const w=A.data;for(let E=0,x=w.length;E<x;E+=4)w[E]=e[0],w[E+1]=e[1],w[E+2]=e[2],w[E+3]=255}for(const w of this._figures)Xn(A,w,g);return y.putImageData(A,2,2),{canvas:v.canvas,offsetX:a-2*p,offsetY:o-2*f,scaleX:p,scaleY:f}}getPattern(t,e,s,i){ms(t,this._bbox);let n;if(i===pt.SHADING)n=R.singularValueDecompose2dScale(Y(t));else if(n=R.singularValueDecompose2dScale(e.baseTransform),this.matrix){const a=R.singularValueDecompose2dScale(this.matrix);n=[n[0]*a[0],n[1]*a[1]]}const r=this._createMeshCanvas(n,i===pt.SHADING?null:this._background,e.cachedCanvases);return i!==pt.SHADING&&(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 Kn extends Se{getPattern(){return"hotpink"}}function Qn(l){switch(l[0]){case"RadialAxial":return new qn(l);case"Mesh":return new Yn(l);case"Dummy":return new Kn}throw new Error(`Unknown IR type: ${l[0]}`)}const Gs={COLORED:1,UNCOLORED:2};class Is{static MAX_PATTERN_SIZE=3e3;constructor(t,e,s,i,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=s,this.canvasGraphicsFactory=i,this.baseTransform=n}createPatternCanvas(t){const e=this.operatorList,s=this.bbox,i=this.xstep,n=this.ystep,r=this.paintType,a=this.tilingType,o=this.color,c=this.canvasGraphicsFactory;Ue("TilingType: "+a);const h=s[0],d=s[1],u=s[2],p=s[3],f=R.singularValueDecompose2dScale(this.matrix),g=R.singularValueDecompose2dScale(this.baseTransform),b=[f[0]*g[0],f[1]*g[1]],m=this.getSizeAndScale(i,this.ctx.canvas.width,b[0]),v=this.getSizeAndScale(n,this.ctx.canvas.height,b[1]),y=t.cachedCanvases.getCanvas("pattern",m.size,v.size,!0),A=y.context,_=c.createCanvasGraphics(A);_.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(_,r,o);let w=h,E=d,x=u,S=p;return h<0&&(w=0,x+=Math.abs(h)),d<0&&(E=0,S+=Math.abs(d)),A.translate(-(m.scale*w),-(v.scale*E)),_.transform(m.scale,0,0,v.scale,0,0),A.save(),this.clipBbox(_,w,E,x,S),_.baseTransform=Y(_.ctx),_.executeOperatorList(e),_.endDrawing(),{canvas:y.canvas,scaleX:m.scale,scaleY:v.scale,offsetX:w,offsetY:E}}getSizeAndScale(t,e,s){t=Math.abs(t);const i=Math.max(Is.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*s);return n>=i?n=i:s=n/t,{scale:s,size:n}}clipBbox(t,e,s,i,n){const r=i-e,a=n-s;t.ctx.rect(e,s,r,a),t.current.updateRectMinMax(Y(t.ctx),[e,s,i,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,n=t.current;switch(e){case Gs.COLORED:const r=this.ctx;i.fillStyle=r.fillStyle,i.strokeStyle=r.strokeStyle,n.fillColor=r.fillStyle,n.strokeColor=r.strokeStyle;break;case Gs.UNCOLORED:const a=R.makeHexColor(s[0],s[1],s[2]);i.fillStyle=a,i.strokeStyle=a,n.fillColor=a,n.strokeColor=a;break;default:throw new En(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,i){let n=s;i!==pt.SHADING&&(n=R.transform(n,e.baseTransform),this.matrix&&(n=R.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 Jn({src:l,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:r=!1}){const a=vt.isLittleEndian?4278190080:255,[o,c]=r?[n,a]:[a,n],h=s>>3,d=s&7,u=l.length;e=new Uint32Array(e.buffer);let p=0;for(let f=0;f<i;f++){for(const b=t+h;t<b;t++){const m=t<u?l[t]:255;e[p++]=m&128?c:o,e[p++]=m&64?c:o,e[p++]=m&32?c:o,e[p++]=m&16?c:o,e[p++]=m&8?c:o,e[p++]=m&4?c:o,e[p++]=m&2?c:o,e[p++]=m&1?c:o}if(d===0)continue;const g=t<u?l[t++]:255;for(let b=0;b<d;b++)e[p++]=g&1<<7-b?c:o}return{srcPos:t,destPos:p}}const Vs=16,Ws=100,Zn=15,qs=10,Xs=1e3,bt=16;function tr(l,t){if(l._removeMirroring)throw new Error("Context is already forwarding operations.");l.__originalSave=l.save,l.__originalRestore=l.restore,l.__originalRotate=l.rotate,l.__originalScale=l.scale,l.__originalTranslate=l.translate,l.__originalTransform=l.transform,l.__originalSetTransform=l.setTransform,l.__originalResetTransform=l.resetTransform,l.__originalClip=l.clip,l.__originalMoveTo=l.moveTo,l.__originalLineTo=l.lineTo,l.__originalBezierCurveTo=l.bezierCurveTo,l.__originalRect=l.rect,l.__originalClosePath=l.closePath,l.__originalBeginPath=l.beginPath,l._removeMirroring=()=>{l.save=l.__originalSave,l.restore=l.__originalRestore,l.rotate=l.__originalRotate,l.scale=l.__originalScale,l.translate=l.__originalTranslate,l.transform=l.__originalTransform,l.setTransform=l.__originalSetTransform,l.resetTransform=l.__originalResetTransform,l.clip=l.__originalClip,l.moveTo=l.__originalMoveTo,l.lineTo=l.__originalLineTo,l.bezierCurveTo=l.__originalBezierCurveTo,l.rect=l.__originalRect,l.closePath=l.__originalClosePath,l.beginPath=l.__originalBeginPath,delete l._removeMirroring},l.save=function(){t.save(),this.__originalSave()},l.restore=function(){t.restore(),this.__originalRestore()},l.translate=function(s,i){t.translate(s,i),this.__originalTranslate(s,i)},l.scale=function(s,i){t.scale(s,i),this.__originalScale(s,i)},l.transform=function(s,i,n,r,a,o){t.transform(s,i,n,r,a,o),this.__originalTransform(s,i,n,r,a,o)},l.setTransform=function(s,i,n,r,a,o){t.setTransform(s,i,n,r,a,o),this.__originalSetTransform(s,i,n,r,a,o)},l.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},l.rotate=function(s){t.rotate(s),this.__originalRotate(s)},l.clip=function(s){t.clip(s),this.__originalClip(s)},l.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},l.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},l.bezierCurveTo=function(e,s,i,n,r,a){t.bezierCurveTo(e,s,i,n,r,a),this.__originalBezierCurveTo(e,s,i,n,r,a)},l.rect=function(e,s,i,n){t.rect(e,s,i,n),this.__originalRect(e,s,i,n)},l.closePath=function(){t.closePath(),this.__originalClosePath()},l.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class er{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s){let i;return this.cache[t]!==void 0?(i=this.cache[t],this.canvasFactory.reset(i,e,s)):(i=this.canvasFactory.create(e,s),this.cache[t]=i),i}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 ke(l,t,e,s,i,n,r,a,o,c){const[h,d,u,p,f,g]=Y(l);if(d===0&&u===0){const v=r*h+f,y=Math.round(v),A=a*p+g,_=Math.round(A),w=(r+o)*h+f,E=Math.abs(Math.round(w)-y)||1,x=(a+c)*p+g,S=Math.abs(Math.round(x)-_)||1;return l.setTransform(Math.sign(h),0,0,Math.sign(p),y,_),l.drawImage(t,e,s,i,n,0,0,E,S),l.setTransform(h,d,u,p,f,g),[E,S]}if(h===0&&p===0){const v=a*u+f,y=Math.round(v),A=r*d+g,_=Math.round(A),w=(a+c)*u+f,E=Math.abs(Math.round(w)-y)||1,x=(r+o)*d+g,S=Math.abs(Math.round(x)-_)||1;return l.setTransform(0,Math.sign(d),Math.sign(u),0,y,_),l.drawImage(t,e,s,i,n,0,0,S,E),l.setTransform(h,d,u,p,f,g),[S,E]}l.drawImage(t,e,s,i,n,r,a,o,c);const b=Math.hypot(h,d),m=Math.hypot(u,p);return[b*o,m*c]}function sr(l){const{width:t,height:e}=l;if(t>Xs||e>Xs)return null;const s=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=t+1;let r=new Uint8Array(n*(e+1)),a,o,c;const h=t+7&-8;let d=new Uint8Array(h*e),u=0;for(const m of l.data){let v=128;for(;v>0;)d[u++]=m&v?0:255,v>>=1}let p=0;for(u=0,d[u]!==0&&(r[0]=1,++p),o=1;o<t;o++)d[u]!==d[u+1]&&(r[o]=d[u]?2:1,++p),u++;for(d[u]!==0&&(r[o]=2,++p),a=1;a<e;a++){u=a*h,c=a*n,d[u-h]!==d[u]&&(r[c]=d[u]?1:8,++p);let m=(d[u]?4:0)+(d[u-h]?8:0);for(o=1;o<t;o++)m=(m>>2)+(d[u+1]?4:0)+(d[u-h+1]?8:0),i[m]&&(r[c+o]=i[m],++p),u++;if(d[u-h]!==d[u]&&(r[c+o]=d[u]?2:4,++p),p>s)return null}for(u=h*(e-1),c=a*n,d[u]!==0&&(r[c]=8,++p),o=1;o<t;o++)d[u]!==d[u+1]&&(r[c+o]=d[u]?4:8,++p),u++;if(d[u]!==0&&(r[c+o]=4,++p),p>s)return null;const f=new Int32Array([0,n,-1,0,-n,0,0,0,1]),g=new Path2D;for(a=0;p&&a<=e;a++){let m=a*n;const v=m+t;for(;m<v&&!r[m];)m++;if(m===v)continue;g.moveTo(m%n,a);const y=m;let A=r[m];do{const _=f[A];do m+=_;while(!r[m]);const w=r[m];w!==5&&w!==10?(A=w,r[m]=0):(A=w&51*A>>4,r[m]&=A>>2|A<<2),g.lineTo(m%n,m/n|0),r[m]||--p}while(y!==m);--a}return d=null,r=null,function(m){m.save(),m.scale(1/t,-1/e),m.translate(0,-e),m.fill(g),m.beginPath(),m.restore()}}class Ys{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=gi,this.textMatrixScale=1,this.fontMatrix=hs,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=ct.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!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,s){[e,s]=R.applyTransform([e,s],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,s)}updateRectMinMax(t,e){const s=R.applyTransform(e,t),i=R.applyTransform(e.slice(2),t),n=R.applyTransform([e[0],e[3]],t),r=R.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,s[0],i[0],n[0],r[0]),this.minY=Math.min(this.minY,s[1],i[1],n[1],r[1]),this.maxX=Math.max(this.maxX,s[0],i[0],n[0],r[0]),this.maxY=Math.max(this.maxY,s[1],i[1],n[1],r[1])}updateScalingPathMinMax(t,e){R.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,s,i,n,r,a,o,c,h){const d=R.bezierBoundingBox(e,s,i,n,r,a,o,c,h);h||this.updateRectMinMax(t,d)}getPathBoundingBox(t=pt.FILL,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===pt.STROKE){e||V("Stroke bounding box must include transform.");const i=R.singularValueDecompose2dScale(e),n=i[0]*this.lineWidth/2,r=i[1]*this.lineWidth/2;s[0]-=n,s[1]-=r,s[2]+=n,s[3]+=r}return s}updateClipFromPath(){const t=R.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=pt.FILL,e=null){return R.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Ks(l,t){if(typeof ImageData<"u"&&t instanceof ImageData){l.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%bt,n=(e-i)/bt,r=i===0?n:n+1,a=l.createImageData(s,bt);let o=0,c;const h=t.data,d=a.data;let u,p,f,g;if(t.kind===Oe.GRAYSCALE_1BPP){const b=h.byteLength,m=new Uint32Array(d.buffer,0,d.byteLength>>2),v=m.length,y=s+7>>3,A=4294967295,_=vt.isLittleEndian?4278190080:255;for(u=0;u<r;u++){for(f=u<n?bt:i,c=0,p=0;p<f;p++){const w=b-o;let E=0;const x=w>y?s:w*8-7,S=x&-8;let L=0,P=0;for(;E<S;E+=8)P=h[o++],m[c++]=P&128?A:_,m[c++]=P&64?A:_,m[c++]=P&32?A:_,m[c++]=P&16?A:_,m[c++]=P&8?A:_,m[c++]=P&4?A:_,m[c++]=P&2?A:_,m[c++]=P&1?A:_;for(;E<x;E++)L===0&&(P=h[o++],L=128),m[c++]=P&L?A:_,L>>=1}for(;c<v;)m[c++]=0;l.putImageData(a,0,u*bt)}}else if(t.kind===Oe.RGBA_32BPP){for(p=0,g=s*bt*4,u=0;u<n;u++)d.set(h.subarray(o,o+g)),o+=g,l.putImageData(a,0,p),p+=bt;u<r&&(g=s*i*4,d.set(h.subarray(o,o+g)),l.putImageData(a,0,p))}else if(t.kind===Oe.RGB_24BPP)for(f=bt,g=s*f,u=0;u<r;u++){for(u>=n&&(f=i,g=s*f),c=0,p=g;p--;)d[c++]=h[o++],d[c++]=h[o++],d[c++]=h[o++],d[c++]=255;l.putImageData(a,0,u*bt)}else throw new Error(`bad image kind: ${t.kind}`)}function Qs(l,t){if(t.bitmap){l.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%bt,n=(e-i)/bt,r=i===0?n:n+1,a=l.createImageData(s,bt);let o=0;const c=t.data,h=a.data;for(let d=0;d<r;d++){const u=d<n?bt:i;({srcPos:o}=Jn({src:c,srcPos:o,dest:h,width:s,height:u,nonBlackColor:0})),l.putImageData(a,0,d*bt)}}function ge(l,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)l[s]!==void 0&&(t[s]=l[s]);l.setLineDash!==void 0&&(t.setLineDash(l.getLineDash()),t.lineDashOffset=l.lineDashOffset)}function Me(l){if(l.strokeStyle=l.fillStyle="#000000",l.fillRule="nonzero",l.globalAlpha=1,l.lineWidth=1,l.lineCap="butt",l.lineJoin="miter",l.miterLimit=10,l.globalCompositeOperation="source-over",l.font="10px sans-serif",l.setLineDash!==void 0&&(l.setLineDash([]),l.lineDashOffset=0),!ut){const{filter:t}=l;t!=="none"&&t!==""&&(l.filter="none")}}function Js(l,t){if(t)return!0;const e=R.singularValueDecompose2dScale(l);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*le.PDF_TO_CSS_UNITS);return e[0]<=s&&e[1]<=s}const ir=["butt","round","square"],nr=["miter","round","bevel"],rr={},Zs={};class re{constructor(t,e,s,i,n,{optionalContentConfig:r,markedContentStack:a=null},o,c){this.ctx=t,this.current=new Ys(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=s,this.canvasFactory=i,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 er(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,s){const o=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=o.canvas,this.ctx=o.context,this.ctx.save(),this.ctx.transform(...Y(this.compositeCtx))}this.ctx.save(),Me(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=Y(this.ctx)}executeOperatorList(t,e,s,i){const n=t.argsArray,r=t.fnArray;let a=e||0;const o=n.length;if(o===a)return a;const c=o-a>qs&&typeof s=="function",h=c?Date.now()+Zn:0;let d=0;const u=this.commonObjs,p=this.objs;let f;for(;;){if(i!==void 0&&a===i.nextBreakPoint)return i.breakIt(a,s),a;if(f=r[a],f!==Pt.dependency)this[f].apply(this,n[a]);else for(const g of n[a]){const b=g.startsWith("g_")?u:p;if(!b.has(g))return b.get(g,s),a}if(a++,a===o)return a;if(c&&++d>qs){if(Date.now()>h)return s(),a;d=0}}}#t(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();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.#t(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#e()}#e(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){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 s=t.width,i=t.height;let n=Math.max(Math.hypot(e[0],e[1]),1),r=Math.max(Math.hypot(e[2],e[3]),1),a=s,o=i,c="prescale1",h,d;for(;n>2&&a>1||r>2&&o>1;){let u=a,p=o;n>2&&a>1&&(u=a>=16384?Math.floor(a/2)-1||1:Math.ceil(a/2),n/=a/u),r>2&&o>1&&(p=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o)/2,r/=o/p),h=this.cachedCanvases.getCanvas(c,u,p),d=h.context,d.clearRect(0,0,u,p),d.drawImage(t,0,0,a,o,0,0,u,p),t=h.canvas,a=u,o=p,c=c==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:a,paintHeight:o}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:i}=t,n=this.current.fillColor,r=this.current.patternFill,a=Y(e);let o,c,h,d;if((t.bitmap||t.data)&&t.count>1){const x=t.bitmap||t.data.buffer;c=JSON.stringify(r?a:[a.slice(0,4),n]),o=this._cachedBitmapsMap.get(x),o||(o=new Map,this._cachedBitmapsMap.set(x,o));const S=o.get(c);if(S&&!r){const L=Math.round(Math.min(a[0],a[2])+a[4]),P=Math.round(Math.min(a[1],a[3])+a[5]);return{canvas:S,offsetX:L,offsetY:P}}h=S}h||(d=this.cachedCanvases.getCanvas("maskCanvas",s,i),Qs(d.context,t));let u=R.transform(a,[1/s,0,0,-1/i,0,0]);u=R.transform(u,[1,0,0,1,0,-i]);const[p,f,g,b]=R.getAxialAlignedBoundingBox([0,0,s,i],u),m=Math.round(g-p)||1,v=Math.round(b-f)||1,y=this.cachedCanvases.getCanvas("fillCanvas",m,v),A=y.context,_=p,w=f;A.translate(-_,-w),A.transform(...u),h||(h=this._scaleImage(d.canvas,Ot(A)),h=h.img,o&&r&&o.set(c,h)),A.imageSmoothingEnabled=Js(Y(A),t.interpolate),ke(A,h,0,0,h.width,h.height,0,0,s,i),A.globalCompositeOperation="source-in";const E=R.transform(Ot(A),[1,0,0,1,-_,-w]);return A.fillStyle=r?n.getPattern(e,this,E,pt.FILL):n,A.fillRect(0,0,s,i),o&&!r&&(this.cachedCanvases.delete("fillCanvas"),o.set(c,y.canvas)),{canvas:y.canvas,offsetX:Math.round(_),offsetY:Math.round(w)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=ir[t]}setLineJoin(t){this.ctx.lineJoin=nr[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(t),s.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,s]of t)switch(e){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s[0],s[1]);break;case"CA":this.current.strokeAlpha=s;break;case"ca":this.current.fillAlpha=s,this.ctx.globalAlpha=s;break;case"BM":this.ctx.globalCompositeOperation=s;break;case"SMask":this.current.activeSMask=s?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s);break}}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,s="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(s,t,e);this.suspendedCtx=this.ctx,this.ctx=i.context;const n=this.ctx;n.setTransform(...Y(this.suspendedCtx)),ge(this.suspendedCtx,n),tr(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(),ge(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,s=this.suspendedCtx;this.composeSMask(s,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,s,i){const n=i[0],r=i[1],a=i[2]-n,o=i[3]-r;a===0||o===0||(this.genericComposeSMask(e.context,s,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(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,n,r,a,o,c,h,d){let u=t.canvas,p=o-h,f=c-d;if(r){if(p<0||f<0||p+s>u.width||f+i>u.height){const b=this.cachedCanvases.getCanvas("maskExtension",s,i),m=b.context;m.drawImage(u,-p,-f),r.some(v=>v!==0)&&(m.globalCompositeOperation="destination-atop",m.fillStyle=R.makeHexColor(...r),m.fillRect(0,0,s,i),m.globalCompositeOperation="source-over"),u=b.canvas,p=f=0}else if(r.some(b=>b!==0)){t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const b=new Path2D;b.rect(p,f,s,i),t.clip(b),t.globalCompositeOperation="destination-atop",t.fillStyle=R.makeHexColor(...r),t.fillRect(p,f,s,i),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),n==="Alpha"&&a?e.filter=this.filterFactory.addAlphaFilter(a):n==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(a));const g=new Path2D;g.rect(o,c,s,i),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(u,p,f,s,i,o,c,s,i),e.restore()}save(){this.inSMaskMode?(ge(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),ge(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,s,i,n,r){this.ctx.transform(t,e,s,i,n,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){const i=this.ctx,n=this.current;let r=n.x,a=n.y,o,c;const h=Y(i),d=h[0]===0&&h[3]===0||h[1]===0&&h[2]===0,u=d?s.slice(0):null;for(let p=0,f=0,g=t.length;p<g;p++)switch(t[p]|0){case Pt.rectangle:r=e[f++],a=e[f++];const b=e[f++],m=e[f++],v=r+b,y=a+m;i.moveTo(r,a),b===0||m===0?i.lineTo(v,y):(i.lineTo(v,a),i.lineTo(v,y),i.lineTo(r,y)),d||n.updateRectMinMax(h,[r,a,v,y]),i.closePath();break;case Pt.moveTo:r=e[f++],a=e[f++],i.moveTo(r,a),d||n.updatePathMinMax(h,r,a);break;case Pt.lineTo:r=e[f++],a=e[f++],i.lineTo(r,a),d||n.updatePathMinMax(h,r,a);break;case Pt.curveTo:o=r,c=a,r=e[f+4],a=e[f+5],i.bezierCurveTo(e[f],e[f+1],e[f+2],e[f+3],r,a),n.updateCurvePathMinMax(h,o,c,e[f],e[f+1],e[f+2],e[f+3],r,a,u),f+=6;break;case Pt.curveTo2:o=r,c=a,i.bezierCurveTo(r,a,e[f],e[f+1],e[f+2],e[f+3]),n.updateCurvePathMinMax(h,o,c,r,a,e[f],e[f+1],e[f+2],e[f+3],u),r=e[f+2],a=e[f+3],f+=4;break;case Pt.curveTo3:o=r,c=a,r=e[f+2],a=e[f+3],i.bezierCurveTo(e[f],e[f+1],r,a,r,a),n.updateCurvePathMinMax(h,o,c,e[f],e[f+1],r,a,r,a,u),f+=4;break;case Pt.closePath:i.closePath();break}d&&n.updateScalingPathMinMax(h,u),n.setCurrentPoint(r,a)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,s=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof s=="object"&&s?.getPattern?(e.save(),e.strokeStyle=s.getPattern(e,this,Ot(e),pt.STROKE),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,s=this.current.fillColor,i=this.current.patternFill;let n=!1;i&&(e.save(),e.fillStyle=s.getPattern(e,this,Ot(e),pt.FILL),n=!0);const r=this.current.getClippedPathBoundingBox();this.contentVisible&&r!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),n&&e.restore(),t&&this.consumePath(r)}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=rr}eoClip(){this.pendingClip=Zs}beginText(){this.current.textMatrix=gi,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(t===void 0){e.beginPath();return}e.save(),e.beginPath();for(const s of t)e.setTransform(...s.transform),e.translate(s.x,s.y),s.addToPath(e,s.fontSize);e.restore(),e.clip(),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 s=this.commonObjs.get(t),i=this.current;if(!s)throw new Error(`Can't find font for ${t}`);if(i.fontMatrix=s.fontMatrix||hs,(i.fontMatrix[0]===0||i.fontMatrix[3]===0)&&F("Invalid font matrix for font "+t),e<0?(e=-e,i.fontDirection=-1):i.fontDirection=1,this.current.font=s,this.current.fontSize=e,s.isType3Font)return;const n=s.loadedName||"sans-serif",r=s.systemFontInfo?.css||`"${n}", ${s.fallbackName}`;let a="normal";s.black?a="900":s.bold&&(a="bold");const o=s.italic?"italic":"normal";let c=e;e<Vs?c=Vs:e>Ws&&(c=Ws),this.current.fontSizeScale=e/c,this.ctx.font=`${o} ${a} ${c}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,s,i,n,r){this.current.textMatrix=[t,e,s,i,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)}paintChar(t,e,s,i){const n=this.ctx,r=this.current,a=r.font,o=r.textRenderingMode,c=r.fontSize/r.fontSizeScale,h=o&ct.FILL_STROKE_MASK,d=!!(o&ct.ADD_TO_PATH_FLAG),u=r.patternFill&&!a.missingFile;let p;(a.disableFontFace||d||u)&&(p=a.getPathGenerator(this.commonObjs,t)),a.disableFontFace||u?(n.save(),n.translate(e,s),n.beginPath(),p(n,c),i&&n.setTransform(...i),(h===ct.FILL||h===ct.FILL_STROKE)&&n.fill(),(h===ct.STROKE||h===ct.FILL_STROKE)&&n.stroke(),n.restore()):((h===ct.FILL||h===ct.FILL_STROKE)&&n.fillText(t,e,s),(h===ct.STROKE||h===ct.FILL_STROKE)&&n.strokeText(t,e,s)),d&&(this.pendingTextPaths||=[]).push({transform:Y(n),x:e,y:s,fontSize:c,addToPath:p})}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 s=!1;for(let i=3;i<e.length;i+=4)if(e[i]>0&&e[i]<255){s=!0;break}return B(this,"isFontSubpixelAAEnabled",s)}showText(t){const e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);const i=e.fontSize;if(i===0)return;const n=this.ctx,r=e.fontSizeScale,a=e.charSpacing,o=e.wordSpacing,c=e.fontDirection,h=e.textHScale*c,d=t.length,u=s.vertical,p=u?1:-1,f=s.defaultVMetrics,g=i*e.fontMatrix[0],b=e.textRenderingMode===ct.FILL&&!s.disableFontFace&&!e.patternFill;n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),c>0?n.scale(h,-1):n.scale(h,1);let m;if(e.patternFill){n.save();const w=e.fillColor.getPattern(n,this,Ot(n),pt.FILL);m=Y(n),n.restore(),n.fillStyle=w}let v=e.lineWidth;const y=e.textMatrixScale;if(y===0||v===0){const w=e.textRenderingMode&ct.FILL_STROKE_MASK;(w===ct.STROKE||w===ct.FILL_STROKE)&&(v=this.getSinglePixelWidth())}else v/=y;if(r!==1&&(n.scale(r,r),v/=r),n.lineWidth=v,s.isInvalidPDFjsFont){const w=[];let E=0;for(const x of t)w.push(x.unicode),E+=x.width;n.fillText(w.join(""),0,0),e.x+=E*g*h,n.restore(),this.compose();return}let A=0,_;for(_=0;_<d;++_){const w=t[_];if(typeof w=="number"){A+=p*w*i/1e3;continue}let E=!1;const x=(w.isSpace?o:0)+a,S=w.fontChar,L=w.accent;let P,G,j=w.width;if(u){const $=w.vmetric||f,U=-(w.vmetric?$[1]:j*.5)*g,T=$[2]*g;j=$?-$[0]:j,P=U/r,G=(A+T)/r}else P=A/r,G=0;if(s.remeasure&&j>0){const $=n.measureText(S).width*1e3/i*r;if(j<$&&this.isFontSubpixelAAEnabled){const U=j/$;E=!0,n.save(),n.scale(U,1),P/=U}else j!==$&&(P+=(j-$)/2e3*i/r)}if(this.contentVisible&&(w.isInFont||s.missingFile)){if(b&&!L)n.fillText(S,P,G);else if(this.paintChar(S,P,G,m),L){const $=P+i*L.offset.x/r,U=G-i*L.offset.y/r;this.paintChar(L.fontChar,$,U,m)}}const O=u?j*g-x*c:j*g+x*c;A+=O,E&&n.restore()}u?e.y-=A:e.x+=A*h,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,s=this.current,i=s.font,n=s.fontSize,r=s.fontDirection,a=i.vertical?1:-1,o=s.charSpacing,c=s.wordSpacing,h=s.textHScale*r,d=s.fontMatrix||hs,u=t.length,p=s.textRenderingMode===ct.INVISIBLE;let f,g,b,m;if(!(p||n===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...s.textMatrix),e.translate(s.x,s.y),e.scale(h,r),f=0;f<u;++f){if(g=t[f],typeof g=="number"){m=a*g*n/1e3,this.ctx.translate(m,0),s.x+=m*h;continue}const v=(g.isSpace?c:0)+o,y=i.charProcOperatorList[g.operatorListId];if(!y){F(`Type3 character "${g.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=g,this.save(),e.scale(n,n),e.transform(...d),this.executeOperatorList(y),this.restore()),b=R.applyTransform([g.width,0],d)[0]*n+v,e.translate(b,0),s.x+=b*h}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,n,r){this.ctx.rect(s,i,n-s,r-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){const s=t[1],i=this.baseTransform||Y(this.ctx),n={createCanvasGraphics:r=>new re(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Is(t,s,this.ctx,n,i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,s){const i=R.makeHexColor(t,e,s);this.ctx.strokeStyle=i,this.current.strokeColor=i}setFillRGBColor(t,e,s){const i=R.makeHexColor(t,e,s);this.ctx.fillStyle=i,this.current.fillColor=i,this.current.patternFill=!1}_getPattern(t,e=null){let s;return this.cachedPatterns.has(t)?s=this.cachedPatterns.get(t):(s=Qn(this.getObject(t)),this.cachedPatterns.set(t,s)),e&&(s.matrix=e),s}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const s=this._getPattern(t);e.fillStyle=s.getPattern(e,this,Ot(e),pt.SHADING);const i=Ot(e);if(i){const{width:n,height:r}=e.canvas,[a,o,c,h]=R.getAxialAlignedBoundingBox([0,0,n,r],i);this.ctx.fillRect(a,o,c-a,h-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){V("Should not call beginInlineImage")}beginImageData(){V("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Y(this.ctx),e)){const s=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],s,i),this.current.updateRectMinMax(Y(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||Ue("TODO: Support non-isolated groups."),t.knockout&&F("Knockout groups not supported.");const s=Y(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=R.getAxialAlignedBoundingBox(t.bbox,Y(e));const n=[0,0,e.canvas.width,e.canvas.height];i=R.intersect(i,n)||[0,0,0,0];const r=Math.floor(i[0]),a=Math.floor(i[1]),o=Math.max(Math.ceil(i[2])-r,1),c=Math.max(Math.ceil(i[3])-a,1);this.current.startNewPathAndClipBox([0,0,o,c]);let h="groupAt"+this.groupLevel;t.smask&&(h+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(h,o,c),u=d.context;u.translate(-r,-a),u.transform(...s),t.smask?this.smaskStack.push({canvas:d.canvas,context:u,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()),ge(e,u),this.ctx=u,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,s=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const i=Y(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const n=R.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],i);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(t,e,s,i,n){if(this.#t(),Me(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const r=e[2]-e[0],a=e[3]-e[1];if(n&&this.annotationCanvasMap){s=s.slice(),s[4]-=e[0],s[5]-=e[1],e=e.slice(),e[0]=e[1]=0,e[2]=r,e[3]=a;const[o,c]=R.singularValueDecompose2dScale(Y(this.ctx)),{viewportScale:h}=this,d=Math.ceil(r*this.outputScaleX*h),u=Math.ceil(a*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(d,u);const{canvas:p,context:f}=this.annotationCanvas;this.annotationCanvasMap.set(t,p),this.annotationCanvas.savedCtx=this.ctx,this.ctx=f,this.ctx.save(),this.ctx.setTransform(o,0,0,-c,0,a*c),Me(this.ctx)}else Me(this.ctx),this.ctx.rect(e[0],e[1],r,a),this.ctx.clip(),this.endPath()}this.current=new Ys(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#e(),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),t.count=e;const s=this.ctx,i=this.processingType3;if(i&&(i.compiled===void 0&&(i.compiled=sr(t)),i.compiled)){i.compiled(s);return}const n=this._createMaskCanvas(t),r=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(r,n.offsetX,n.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,i=0,n,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);const a=this.ctx;a.save();const o=Y(a);a.transform(e,s,i,n,0,0);const c=this._createMaskCanvas(t);a.setTransform(1,0,0,1,c.offsetX-o[4],c.offsetY-o[5]);for(let h=0,d=r.length;h<d;h+=2){const u=R.transform(o,[e,s,i,n,r[h],r[h+1]]),[p,f]=R.applyTransform([0,0],u);a.drawImage(c.canvas,p,f)}a.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;for(const n of t){const{data:r,width:a,height:o,transform:c}=n,h=this.cachedCanvases.getCanvas("maskCanvas",a,o),d=h.context;d.save();const u=this.getObject(r,n);Qs(d,u),d.globalCompositeOperation="source-in",d.fillStyle=i?s.getPattern(d,this,Ot(e),pt.FILL):s,d.fillRect(0,0,a,o),d.restore(),e.save(),e.transform(...c),e.scale(1,-1),ke(e,h.canvas,0,0,a,o,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);if(!e){F("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,s,i){if(!this.contentVisible)return;const n=this.getObject(t);if(!n){F("Dependent image isn't ready yet");return}const r=n.width,a=n.height,o=[];for(let c=0,h=i.length;c<h;c+=2)o.push({transform:[e,0,0,s,i[c],i[c+1]],x:0,y:0,w:r,h:a});this.paintInlineImageXObjectGroup(n,o)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:e,width:s,height:i}=t,n=this.cachedCanvases.getCanvas("inlineImage",s,i),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,s=t.height,i=this.ctx;if(this.save(),!ut){const{filter:a}=i;a!=="none"&&a!==""&&(i.filter="none")}i.scale(1/e,-1/s);let n;if(t.bitmap)n=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)n=t;else{const o=this.cachedCanvases.getCanvas("inlineImage",e,s).context;Ks(o,t),n=this.applyTransferMapsToCanvas(o)}const r=this._scaleImage(n,Ot(i));i.imageSmoothingEnabled=Js(Y(i),t.interpolate),ke(i,r.img,0,0,r.paintWidth,r.paintHeight,0,-s,e,s),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.ctx;let i;if(t.bitmap)i=t.bitmap;else{const n=t.width,r=t.height,o=this.cachedCanvases.getCanvas("inlineImage",n,r).context;Ks(o,t),i=this.applyTransferMapsToCanvas(o)}for(const n of e)s.save(),s.transform(...n.transform),s.scale(1,-1),ke(s,i,n.x,n.y,n.w,n.h,0,-1,1,1),s.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){t==="OC"?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 s=this.ctx;this.pendingClip&&(e||(this.pendingClip===Zs?s.clip("evenodd"):s.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),s.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Y(this.ctx);if(t[1]===0&&t[2]===0)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]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:n}=this.ctx.getTransform();let r,a;if(s===0&&i===0){const o=Math.abs(e),c=Math.abs(n);if(o===c)if(t===0)r=a=1/o;else{const h=o*t;r=a=h<1?1/h:1}else if(t===0)r=1/o,a=1/c;else{const h=o*t,d=c*t;r=h<1?1/h:1,a=d<1?1/d:1}}else{const o=Math.abs(e*n-s*i),c=Math.hypot(e,s),h=Math.hypot(i,n);if(t===0)r=h/o,a=c/o;else{const d=t*o;r=h>d?h/d:1,a=c>d?c/d:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:s}=this.current,[i,n]=this.getScaleForStroking();if(e.lineWidth=s||1,i===1&&n===1){e.stroke();return}const r=e.getLineDash();if(t&&e.save(),e.scale(i,n),r.length>0){const a=Math.max(i,n);e.setLineDash(r.map(o=>o/a)),e.lineDashOffset/=a}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 l in Pt)re.prototype[l]!==void 0&&(re.prototype[Pt[l]]=re.prototype[l]);class ye{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");this.#e=t}}const Ie={DATA:1,ERROR:2},tt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function wt(l){switch(l instanceof Error||typeof l=="object"&&l!==null||V('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),l.name){case"AbortException":return new Zt(l.message);case"MissingPDFException":return new Jt(l.message);case"PasswordException":return new ds(l.message,l.code);case"UnexpectedResponseException":return new ze(l.message,l.status);case"UnknownErrorException":return new us(l.message,l.details);default:return new us(l.message,l.toString())}}class ve{constructor(t,e,s){this.sourceName=t,this.targetName=e,this.comObj=s,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),this._onComObjOnMessage=i=>{const n=i.data;if(n.targetName!==this.sourceName)return;if(n.stream){this.#e(n);return}if(n.callback){const a=n.callbackId,o=this.callbackCapabilities[a];if(!o)throw new Error(`Cannot resolve callback ${a}`);if(delete this.callbackCapabilities[a],n.callback===Ie.DATA)o.resolve(n.data);else if(n.callback===Ie.ERROR)o.reject(wt(n.reason));else throw new Error("Unexpected callback case");return}const r=this.actionHandler[n.action];if(!r)throw new Error(`Unknown action from worker: ${n.action}`);if(n.callbackId){const a=this.sourceName,o=n.sourceName;new Promise(function(c){c(r(n.data))}).then(function(c){s.postMessage({sourceName:a,targetName:o,callback:Ie.DATA,callbackId:n.callbackId,data:c})},function(c){s.postMessage({sourceName:a,targetName:o,callback:Ie.ERROR,callbackId:n.callbackId,reason:wt(c)})});return}if(n.streamId){this.#t(n);return}r(n.data)},s.addEventListener("message",this._onComObjOnMessage)}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[i]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(r){n.reject(r)}return n.promise}sendWithStream(t,e,s,i){const n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:c=>{const h=Promise.withResolvers();return this.streamControllers[n]={controller:c,startCall:h,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:c.desiredSize},i),h.promise},pull:c=>{const h=Promise.withResolvers();return this.streamControllers[n].pullCall=h,o.postMessage({sourceName:r,targetName:a,stream:tt.PULL,streamId:n,desiredSize:c.desiredSize}),h.promise},cancel:c=>{nt(c instanceof Error,"cancel must have a valid reason");const h=Promise.withResolvers();return this.streamControllers[n].cancelCall=h,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:tt.CANCEL,streamId:n,reason:wt(c)}),h.promise}},s)}#t(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(c,h=1,d){if(this.isCancelled)return;const u=this.desiredSize;this.desiredSize-=h,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:tt.ENQUEUE,streamId:e,chunk:c},d)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:tt.CLOSE,streamId:e}),delete r.streamSinks[e])},error(c){nt(c instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:tt.ERROR,streamId:e,reason:wt(c)}))},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,new Promise(function(c){c(a(t.data,o))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:tt.START_COMPLETE,streamId:e,success:!0})},function(c){n.postMessage({sourceName:s,targetName:i,stream:tt.START_COMPLETE,streamId:e,reason:wt(c)})})}#e(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case tt.START_COMPLETE:t.success?r.startCall.resolve():r.startCall.reject(wt(t.reason));break;case tt.PULL_COMPLETE:t.success?r.pullCall.resolve():r.pullCall.reject(wt(t.reason));break;case tt.PULL:if(!a){n.postMessage({sourceName:s,targetName:i,stream:tt.PULL_COMPLETE,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,new Promise(function(o){o(a.onPull?.())}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:tt.PULL_COMPLETE,streamId:e,success:!0})},function(o){n.postMessage({sourceName:s,targetName:i,stream:tt.PULL_COMPLETE,streamId:e,reason:wt(o)})});break;case tt.ENQUEUE:if(nt(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case tt.CLOSE:if(nt(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#s(r,e);break;case tt.ERROR:nt(r,"error should have stream controller"),r.controller.error(wt(t.reason)),this.#s(r,e);break;case tt.CANCEL_COMPLETE:t.success?r.cancelCall.resolve():r.cancelCall.reject(wt(t.reason)),this.#s(r,e);break;case tt.CANCEL:if(!a)break;new Promise(function(o){o(a.onCancel?.(wt(t.reason)))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:tt.CANCEL_COMPLETE,streamId:e,success:!0})},function(o){n.postMessage({sourceName:s,targetName:i,stream:tt.CANCEL_COMPLETE,streamId:e,reason:wt(o)})}),a.sinkCapability.reject(wt(t.reason)),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#s(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}class ar{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}getAll(){return ws(this.#t)}has(t){return this.#t.has(t)}}const Ut=Symbol("INTERNAL");class or{#t=!1;#e=!1;#s=!1;#n=!0;constructor(t,{name:e,intent:s,usage:i}){this.#t=!!(t&Ct.DISPLAY),this.#e=!!(t&Ct.PRINT),this.name=e,this.intent=s,this.usage=i}get visible(){if(this.#s)return this.#n;if(!this.#n)return!1;const{print:t,view:e}=this.usage;return this.#t?e?.viewState!=="OFF":this.#e?t?.printState!=="OFF":!0}_setVisible(t,e,s=!1){t!==Ut&&V("Internal method `_setVisible` called."),this.#s=s,this.#n=e}}class lr{#t=null;#e=new Map;#s=null;#n=null;constructor(t,e=Ct.DISPLAY){if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,this.#n=t.order;for(const s of t.groups)this.#e.set(s.id,new or(e,s));if(t.baseState==="OFF")for(const s of this.#e.values())s._setVisible(Ut,!1);for(const s of t.on)this.#e.get(s)._setVisible(Ut,!0);for(const s of t.off)this.#e.get(s)._setVisible(Ut,!1);this.#s=this.getHash()}}#o(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const n=t[i];let r;if(Array.isArray(n))r=this.#o(n);else if(this.#e.has(n))r=this.#e.get(n).visible;else return F(`Optional content group not found: ${n}`),!0;switch(s){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return s==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return Ue("Optional content group not defined."),!0;if(t.type==="OCG")return this.#e.has(t.id)?this.#e.get(t.id).visible:(F(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return this.#o(t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!this.#e.has(e))return F(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!this.#e.has(e))return F(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!this.#e.has(e))return F(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!this.#e.has(e))return F(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return F(`Unknown optional content policy ${t.policy}.`),!0}return F(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0){const s=this.#e.get(t);if(!s){F(`Optional content group not found: ${t}`);return}s._setVisible(Ut,!!e,!0),this.#t=null}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const n=this.#e.get(i);if(n)switch(s){case"ON":n._setVisible(Ut,!0);break;case"OFF":n._setVisible(Ut,!1);break;case"Toggle":n._setVisible(Ut,!n.visible);break}}this.#t=null}get hasInitialVisibility(){return this.#s===null||this.getHash()===this.#s}getOrder(){return this.#e.size?this.#n?this.#n.slice():[...this.#e.keys()]:null}getGroups(){return this.#e.size>0?ws(this.#e):null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;const t=new Ei;for(const[e,s]of this.#e)t.update(`${e}:${s.visible}`);return this.#t=t.hexdigest()}}class hr{constructor(t,{disableRange:e=!1,disableStream:s=!1}){nt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:n,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,n?.length>0){const o=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(o)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((o,c)=>{this._onReceiveData({begin:o,chunk:c})}),t.addProgressListener((o,c)=>{this._onProgress({loaded:o,total:c})}),t.addProgressiveReadListener(o=>{this._onReceiveData({chunk:o})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{const i=this._rangeReaders.some(function(n){return n._begin!==t?!1:(n._enqueue(s),!0)});nt(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){t.total===void 0?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(){nt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new cr(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new dr(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class cr{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=Ts(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const n of this._queuedChunks)this._loaded+=n.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):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 e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class dr{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const s of this._requests)s.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 e=this._queuedChunk;return this._queuedChunk=null,{value:e,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 e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function ur(l){let t=!0,e=s("filename\\*","i").exec(l);if(e){e=e[1];let h=a(e);return h=unescape(h),h=o(h),h=c(h),n(h)}if(e=r(l),e){const h=c(e);return n(h)}if(e=s("filename","i").exec(l),e){e=e[1];let h=a(e);return h=c(h),n(h)}function s(h,d){return new RegExp("(?:^|;)\\s*"+h+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function i(h,d){if(h){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const u=new TextDecoder(h,{fatal:!0}),p=Ge(d);d=u.decode(p),t=!1}catch{}}return d}function n(h){return t&&/[\x80-\xff]/.test(h)&&(h=i("utf-8",h),t&&(h=i("iso-8859-1",h))),h}function r(h){const d=[];let u;const p=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(u=p.exec(h))!==null;){let[,g,b,m]=u;if(g=parseInt(g,10),g in d){if(g===0)break;continue}d[g]=[b,m]}const f=[];for(let g=0;g<d.length&&g in d;++g){let[b,m]=d[g];m=a(m),b&&(m=unescape(m),g===0&&(m=o(m))),f.push(m)}return f.join("")}function a(h){if(h.startsWith('"')){const d=h.slice(1).split('\\"');for(let u=0;u<d.length;++u){const p=d[u].indexOf('"');p!==-1&&(d[u]=d[u].slice(0,p),d.length=u+1),d[u]=d[u].replaceAll(/\\(.)/g,"$1")}h=d.join('"')}return h}function o(h){const d=h.indexOf("'");if(d===-1)return h;const u=h.slice(0,d),f=h.slice(d+1).replace(/^[^']*'/,"");return i(u,f)}function c(h){return!h.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(h)?h:h.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(d,u,p,f){if(p==="q"||p==="Q")return f=f.replaceAll("_"," "),f=f.replaceAll(/=([0-9a-fA-F]{2})/g,function(g,b){return String.fromCharCode(parseInt(b,16))}),i(u,f);try{f=atob(f)}catch{}return i(u,f)})}return""}function Ds({getResponseHeader:l,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={allowRangeRequests:!1,suggestedLength:void 0},n=parseInt(l("Content-Length"),10);return!Number.isInteger(n)||(i.suggestedLength=n,n<=2*e)||s||!t||l("Accept-Ranges")!=="bytes"||(l("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function Fs(l){const t=l("Content-Disposition");if(t){let e=ur(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Ts(e))return e}return null}function Ke(l,t){return l===404||l===0&&t.startsWith("file:")?new Jt('Missing PDF "'+t+'".'):new ze(`Unexpected server response (${l}) while retrieving PDF "${t}".`,l)}function Ci(l){return l===200||l===206}function Ti(l,t,e){return{method:"GET",headers:l,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function Pi(l){const t=new Headers;for(const e in l){const s=l[e];s!==void 0&&t.append(e,s)}return t}function Ri(l){return l instanceof Uint8Array?l.buffer:l instanceof ArrayBuffer?l:(F(`getArrayBuffer - unexpected data format: ${l}`),new Uint8Array(l).buffer)}class ti{constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return nt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new fr(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new pr(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class fr{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,this._headers=Pi(this._stream.httpHeaders);const s=e.url;fetch(s,Ti(this._headers,this._withCredentials,this._abortController)).then(i=>{if(!Ci(i.status))throw Ke(i.status,s);this._reader=i.body.getReader(),this._headersCapability.resolve();const n=o=>i.headers.get(o),{allowRangeRequests:r,suggestedLength:a}=Ds({getResponseHeader:n,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=a||this._contentLength,this._filename=Fs(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Zt("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:Ri(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class pr{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;const i=t.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController,this._headers=Pi(this._stream.httpHeaders),this._headers.append("Range",`bytes=${e}-${s-1}`);const n=i.url;fetch(n,Ti(this._headers,this._withCredentials,this._abortController)).then(r=>{if(!Ci(r.status))throw Ke(r.status,n);this._readCapability.resolve(),this._reader=r.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:Ri(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}const rs=200,as=206;function gr(l){const t=l.response;return typeof t!="string"?t:Ge(t).buffer}class mr{constructor(t,e={}){this.url=t,this.isHttp=/^https?:/i.test(t),this.httpHeaders=this.isHttp&&e.httpHeaders||Object.create(null),this.withCredentials=e.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(t,e,s){const i={begin:t,end:e};for(const n in s)i[n]=s[n];return this.request(i)}requestFull(t){return this.request(t)}request(t){const e=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const n in this.httpHeaders){const r=this.httpHeaders[n];r!==void 0&&e.setRequestHeader(n,r)}return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=as):i.expectedStatus=rs,e.responseType="arraybuffer",t.onError&&(e.onerror=function(n){t.onError(e.status)}),e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){const s=this.pendingRequests[t];s&&s.onProgress?.(e)}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),i.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],i.status===0&&this.isHttp){s.onError?.(i.status);return}const n=i.status||rs;if(!(n===rs&&s.expectedStatus===as)&&n!==s.expectedStatus){s.onError?.(i.status);return}const a=gr(i);if(n===as){const o=i.getResponseHeader("Content-Range"),c=/bytes (\d+)-(\d+)\/(\d+)/.exec(o);s.onDone({begin:parseInt(c[1],10),chunk:a})}else a?s.onDone({begin:0,chunk:a}):s.onError?.(i.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 br{constructor(t){this._source=t,this._manager=new mr(t.url,{httpHeaders:t.httpHeaders,withCredentials:t.withCredentials}),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 nt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new vr(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new Ar(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class vr{constructor(t,e){this._manager=t;const s={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._fullRequestId=t.requestFull(s),this._headersReceivedCapability=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),s=r=>e.getResponseHeader(r),{allowRangeRequests:i,suggestedLength:n}=Ds({getResponseHeader:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=Fs(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersReceivedCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Ke(t,this._url),this._headersReceivedCapability.reject(this._storedError);for(const e of this._requests)e.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._headersReceivedCapability.promise}async read(){if(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._headersReceivedCapability.reject(t);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Ar{constructor(t,e,s){this._manager=t;const i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._requestId=t.requestRange(e,s,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError=Ke(t,this._url);for(const e of this._requests)e.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(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,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 e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const Li=/^file:\/\/\/[a-zA-Z]:\//;function yr(l){const t=Dt.get("url"),e=t.parse(l);return e.protocol==="file:"||e.host?e:/^[a-z]:[/\\]/i.test(l)?t.parse(`file:///${l}`):(e.host||(e.protocol="file:"),e)}class _r{constructor(t){this.source=t,this.url=yr(t.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return nt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new Sr(this):new wr(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=this.isFsUrl?new xr(this,t,e):new Er(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class ki{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}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();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(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",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Zt("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Mi{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const e=t.source;this._isStreamingSupported=!e.disableStream}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();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(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",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}function He(l,t){return{protocol:l.protocol,auth:l.auth,host:l.hostname,port:l.port,path:l.path,method:"GET",headers:t}}class wr extends ki{constructor(t){super(t);const e=s=>{if(s.statusCode===404){const a=new Jt(`Missing PDF "${this._url}".`);this._storedError=a,this._headersCapability.reject(a);return}this._headersCapability.resolve(),this._setReadableStream(s);const i=a=>this._readableStream.headers[a.toLowerCase()],{allowRangeRequests:n,suggestedLength:r}=Ds({getResponseHeader:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=r||this._contentLength,this._filename=Fs(i)};if(this._request=null,this._url.protocol==="http:"){const s=Dt.get("http");this._request=s.request(He(this._url,t.httpHeaders),e)}else{const s=Dt.get("https");this._request=s.request(He(this._url,t.httpHeaders),e)}this._request.on("error",s=>{this._storedError=s,this._headersCapability.reject(s)}),this._request.end()}}class Er extends Mi{constructor(t,e,s){super(t),this._httpHeaders={};for(const n in t.httpHeaders){const r=t.httpHeaders[n];r!==void 0&&(this._httpHeaders[n]=r)}this._httpHeaders.Range=`bytes=${e}-${s-1}`;const i=n=>{if(n.statusCode===404){const r=new Jt(`Missing PDF "${this._url}".`);this._storedError=r;return}this._setReadableStream(n)};if(this._request=null,this._url.protocol==="http:"){const n=Dt.get("http");this._request=n.request(He(this._url,this._httpHeaders),i)}else{const n=Dt.get("https");this._request=n.request(He(this._url,this._httpHeaders),i)}this._request.on("error",n=>{this._storedError=n}),this._request.end()}}class Sr extends ki{constructor(t){super(t);let e=decodeURIComponent(this._url.path);Li.test(this._url.href)&&(e=e.replace(/^\//,""));const s=Dt.get("fs");s.promises.lstat(e).then(i=>{this._contentLength=i.size,this._setReadableStream(s.createReadStream(e)),this._headersCapability.resolve()},i=>{i.code==="ENOENT"&&(i=new Jt(`Missing PDF "${e}".`)),this._storedError=i,this._headersCapability.reject(i)})}}class xr extends Mi{constructor(t,e,s){super(t);let i=decodeURIComponent(this._url.path);Li.test(this._url.href)&&(i=i.replace(/^\//,""));const n=Dt.get("fs");this._setReadableStream(n.createReadStream(i,{start:e,end:s-1}))}}const Cr=1e5,mt=30,Tr=.8;let Be=class kt{#t=Promise.withResolvers();#e=null;#s=!1;#n=!!globalThis.FontInspector?.enabled;#o=null;#i=null;#r=0;#l=0;#c=null;#d=null;#f=0;#h=0;#a=Object.create(null);#p=[];#m=null;#u=[];#v=new WeakMap;#g=null;static#A=new Map;static#_=new Map;static#E=null;static#x=new Set;constructor({textContentSource:t,container:e,viewport:s}){if(t instanceof ReadableStream)this.#m=t;else if(typeof t=="object")this.#m=new ReadableStream({start(o){o.enqueue(t),o.close()}});else throw new Error('No "textContentSource" parameter specified.');this.#e=this.#d=e,this.#h=s.scale*(globalThis.devicePixelRatio||1),this.#f=s.rotation,this.#i={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:null};const{pageWidth:i,pageHeight:n,pageX:r,pageY:a}=s.rawDims;this.#g=[1,0,0,-1,-r,a+n],this.#l=i,this.#r=n,kt.#b(),Yt(e,s),this.#t.promise.catch(()=>{}).then(()=>{kt.#x.delete(this),this.#i=null,this.#a=null})}render(){const t=()=>{this.#c.read().then(({value:e,done:s})=>{if(s){this.#t.resolve();return}this.#o??=e.lang,Object.assign(this.#a,e.styles),this.#C(e.items),t()},this.#t.reject)};return this.#c=this.#m.getReader(),kt.#x.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){const s=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==this.#f&&(e?.(),this.#f=i,Yt(this.#d,{rotation:i})),s!==this.#h){e?.(),this.#h=s;const n={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:kt.#y(this.#o)};for(const r of this.#u)n.properties=this.#v.get(r),n.div=r,this.#S(n)}}cancel(){const t=new Zt("TextLayer task cancelled.");this.#c?.cancel(t).catch(()=>{}),this.#c=null,this.#t.reject(t)}get textDivs(){return this.#u}get textContentItemsStr(){return this.#p}#C(t){if(this.#s)return;this.#i.ctx??=kt.#y(this.#o);const e=this.#u,s=this.#p;for(const i of t){if(e.length>Cr){F("Ignoring additional textDivs for performance reasons."),this.#s=!0;return}if(i.str===void 0){if(i.type==="beginMarkedContentProps"||i.type==="beginMarkedContent"){const n=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),i.id!==null&&this.#e.setAttribute("id",`${i.id}`),n.append(this.#e)}else i.type==="endMarkedContent"&&(this.#e=this.#e.parentNode);continue}s.push(i.str),this.#L(i)}}#L(t){const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#u.push(e);const i=R.transform(this.#g,t.transform);let n=Math.atan2(i[1],i[0]);const r=this.#a[t.fontName];r.vertical&&(n+=Math.PI/2);const a=this.#n&&r.fontSubstitution||r.fontFamily,o=Math.hypot(i[2],i[3]),c=o*kt.#w(a,this.#o);let h,d;n===0?(h=i[4],d=i[5]-c):(h=i[4]+c*Math.sin(n),d=i[5]-c*Math.cos(n));const u="calc(var(--scale-factor)*",p=e.style;this.#e===this.#d?(p.left=`${(100*h/this.#l).toFixed(2)}%`,p.top=`${(100*d/this.#r).toFixed(2)}%`):(p.left=`${u}${h.toFixed(2)}px)`,p.top=`${u}${d.toFixed(2)}px)`),p.fontSize=`${u}${(kt.#E*o).toFixed(2)}px)`,p.fontFamily=a,s.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#n&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),n!==0&&(s.angle=n*(180/Math.PI));let f=!1;if(t.str.length>1)f=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const g=Math.abs(t.transform[0]),b=Math.abs(t.transform[3]);g!==b&&Math.max(g,b)/Math.min(g,b)>1.5&&(f=!0)}if(f&&(s.canvasWidth=r.vertical?t.height:t.width),this.#v.set(e,s),this.#i.div=e,this.#i.properties=s,this.#S(this.#i),s.hasText&&this.#e.append(e),s.hasEOL){const g=document.createElement("br");g.setAttribute("role","presentation"),this.#e.append(g)}}#S(t){const{div:e,properties:s,ctx:i,prevFontSize:n,prevFontFamily:r}=t,{style:a}=e;let o="";if(kt.#E>1&&(o=`scale(${1/kt.#E})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:c}=a,{canvasWidth:h,fontSize:d}=s;(n!==d||r!==c)&&(i.font=`${d*this.#h}px ${c}`,t.prevFontSize=d,t.prevFontFamily=c);const{width:u}=i.measureText(e.textContent);u>0&&(o=`scaleX(${h*this.#h/u}) ${o}`)}s.angle!==0&&(o=`rotate(${s.angle}deg) ${o}`),o.length>0&&(a.transform=o)}static cleanup(){if(!(this.#x.size>0)){this.#A.clear();for(const{canvas:t}of this.#_.values())t.remove();this.#_.clear()}}static#y(t=null){let e=this.#_.get(t||="");if(!e){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#_.set(t,e)}return e}static#b(){if(this.#E!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.textContent="X",document.body.append(t),this.#E=t.getBoundingClientRect().height,t.remove()}static#w(t,e){const s=this.#A.get(t);if(s)return s;const i=this.#y(e),n=i.font;i.canvas.width=i.canvas.height=mt,i.font=`${mt}px ${t}`;const r=i.measureText("");let a=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);if(a){const d=a/(a+o);return this.#A.set(t,d),i.canvas.width=i.canvas.height=0,i.font=n,d}i.strokeStyle="red",i.clearRect(0,0,mt,mt),i.strokeText("g",0,0);let c=i.getImageData(0,0,mt,mt).data;o=0;for(let d=c.length-1-3;d>=0;d-=4)if(c[d]>0){o=Math.ceil(d/4/mt);break}i.clearRect(0,0,mt,mt),i.strokeText("A",0,mt),c=i.getImageData(0,0,mt,mt).data,a=0;for(let d=0,u=c.length;d<u;d+=4)if(c[d]>0){a=mt-Math.floor(d/4/mt);break}i.canvas.width=i.canvas.height=0,i.font=n;const h=a?a/(a+o):Tr;return this.#A.set(t,h),h}};function Pr(){_i("`renderTextLayer`, please use `TextLayer` instead.");const{textContentSource:l,container:t,viewport:e,...s}=arguments[0],i=Object.keys(s);i.length>0&&F("Ignoring `renderTextLayer` parameters: "+i.join(", "));const n=new Be({textContentSource:l,container:t,viewport:e}),{textDivs:r,textContentItemsStr:a}=n;return{promise:n.render(),textDivs:r,textContentItemsStr:a}}function Rr(){_i("`updateTextLayer`, please use `TextLayer` instead.")}class _e{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(n){if(!n)return;let r=null;const a=n.name;if(a==="#text")r=n.value;else if(_e.shouldBuildText(a))n?.attributes?.textContent?r=n.attributes.textContent:n.value&&(r=n.value);else return;if(r!==null&&e.push({str:r}),!!n.children)for(const o of n.children)i(o)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const Lr=65536,kr=100,Mr=5e3,Ir=ut?Gn:kn,Dr=ut?Vn:Ai,Fr=ut?zn:Ln,Or=ut?Wn:yi;function Nr(l={}){typeof l=="string"||l instanceof URL?l={url:l}:(l instanceof ArrayBuffer||ArrayBuffer.isView(l))&&(l={data:l});const t=new Os,{docId:e}=t,s=l.url?Hr(l.url):null,i=l.data?Br(l.data):null,n=l.httpHeaders||null,r=l.withCredentials===!0,a=l.password??null,o=l.range instanceof Ii?l.range:null,c=Number.isInteger(l.rangeChunkSize)&&l.rangeChunkSize>0?l.rangeChunkSize:Lr;let h=l.worker instanceof Tt?l.worker:null;const d=l.verbosity,u=typeof l.docBaseUrl=="string"&&!Cs(l.docBaseUrl)?l.docBaseUrl:null,p=typeof l.cMapUrl=="string"?l.cMapUrl:null,f=l.cMapPacked!==!1,g=l.CMapReaderFactory||Dr,b=typeof l.standardFontDataUrl=="string"?l.standardFontDataUrl:null,m=l.StandardFontDataFactory||Or,v=l.stopAtErrors!==!0,y=Number.isInteger(l.maxImageSize)&&l.maxImageSize>-1?l.maxImageSize:-1,A=l.isEvalSupported!==!1,_=typeof l.isOffscreenCanvasSupported=="boolean"?l.isOffscreenCanvasSupported:!ut,w=Number.isInteger(l.canvasMaxAreaInBytes)?l.canvasMaxAreaInBytes:-1,E=typeof l.disableFontFace=="boolean"?l.disableFontFace:ut,x=l.fontExtraProperties===!0,S=l.enableXfa===!0,L=l.ownerDocument||globalThis.document,P=l.disableRange===!0,G=l.disableStream===!0,j=l.disableAutoFetch===!0,O=l.pdfBug===!0,$=l.enableHWA===!0,U=o?o.length:l.length??NaN,T=typeof l.useSystemFonts=="boolean"?l.useSystemFonts:!ut&&!E,k=typeof l.useWorkerFetch=="boolean"?l.useWorkerFetch:g===Ai&&m===yi&&p&&b&&be(p,document.baseURI)&&be(b,document.baseURI),yt=l.canvasFactory||new Ir({ownerDocument:L,enableHWA:$}),Et=l.filterFactory||new Fr({docId:e,ownerDocument:L}),$t=null;An(d);const Q={canvasFactory:yt,filterFactory:Et};if(k||(Q.cMapReaderFactory=new g({baseUrl:p,isCompressed:f}),Q.standardFontDataFactory=new m({baseUrl:b})),!h){const _t={verbosity:d,port:ye.workerPort};h=_t.port?Tt.fromPort(_t):new Tt(_t),t._worker=h}const X={docId:e,apiVersion:"4.4.168",data:i,password:a,disableAutoFetch:j,rangeChunkSize:c,length:U,docBaseUrl:u,enableXfa:S,evaluatorOptions:{maxImageSize:y,disableFontFace:E,ignoreErrors:v,isEvalSupported:A,isOffscreenCanvasSupported:_,canvasMaxAreaInBytes:w,fontExtraProperties:x,useSystemFonts:T,cMapUrl:k?p:null,standardFontDataUrl:k?b:null}},St={disableFontFace:E,fontExtraProperties:x,ownerDocument:L,pdfBug:O,styleElement:$t,loadingParams:{disableAutoFetch:j,enableXfa:S}};return h.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const _t=h.messageHandler.sendWithPromise("GetDocRequest",X,i?[i.buffer]:null);let ft;if(o)ft=new hr(o,{disableRange:P,disableStream:G});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");ft=(gt=>ut?function(){return typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype}()&&be(gt.url)?new ti(gt):new _r(gt):be(gt.url)?new ti(gt):new br(gt))({url:s,length:U,httpHeaders:n,withCredentials:r,rangeChunkSize:c,disableRange:P,disableStream:G})}return _t.then(q=>{if(t.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const gt=new ve(e,q,h.port),Rt=new zr(gt,t,ft,St,Q);t._transport=Rt,gt.send("Ready",null)})}).catch(t._capability.reject),t}function Hr(l){if(l instanceof URL)return l.href;try{return new URL(l,window.location).href}catch{if(ut&&typeof l=="string")return l}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function Br(l){if(ut&&typeof Bs<"u"&&l instanceof Bs)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(l instanceof Uint8Array&&l.byteLength===l.buffer.byteLength)return l;if(typeof l=="string")return Ge(l);if(l instanceof ArrayBuffer||ArrayBuffer.isView(l)||typeof l=="object"&&!isNaN(l?.length))return new Uint8Array(l);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function ei(l){return typeof l=="object"&&Number.isInteger(l?.num)&&l.num>=0&&Number.isInteger(l?.gen)&&l.gen>=0}class Os{static#t=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${Os.#t++}`,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&&(this._worker.destroy(),this._worker=null)}}let Ii=class{constructor(t,e,s=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i,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 s of this._rangeListeners)s(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(const s of this._progressListeners)s(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){V("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class jr{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return B(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 $r{#t=null;#e=!1;constructor(t,e,s,i=!1){this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new $s:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new Di,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:s=0,offsetY:i=0,dontFlip:n=!1}={}){return new we({viewBox:this.view,scale:t,rotation:e,offsetX:s,offsetY:i,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 B(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:s="display",annotationMode:i=zt.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:a=null,annotationCanvasMap:o=null,pageColors:c=null,printAnnotationStorage:h=null}){this._stats?.time("Overall");const d=this._transport.getRenderingIntent(s,i,h),{renderingIntent:u,cacheKey:p}=d;this.#e=!1,this.#n(),a||=this._transport.getOptionalContentConfig(u);let f=this._intentStates.get(p);f||(f=Object.create(null),this._intentStates.set(p,f)),f.streamReaderCancelTimeout&&(clearTimeout(f.streamReaderCancelTimeout),f.streamReaderCancelTimeout=null);const g=!!(u&Ct.PRINT);f.displayReadyCapability||(f.displayReadyCapability=Promise.withResolvers(),f.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(d));const b=y=>{f.renderTasks.delete(m),(this._maybeCleanupAfterRender||g)&&(this.#e=!0),this.#s(!g),y?(m.capability.reject(y),this._abortOperatorList({intentState:f,reason:y instanceof Error?y:new Error(y)})):m.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},m=new ne({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:!g,pdfBug:this._pdfBug,pageColors:c});(f.renderTasks||=new Set).add(m);const v=m.task;return Promise.all([f.displayReadyCapability.promise,a]).then(([y,A])=>{if(this.destroyed){b();return}if(this._stats?.time("Rendering"),!(A.renderingIntent&u))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");m.initializeGraphics({transparency:y,optionalContentConfig:A}),m.operatorListChanged()}).catch(b),v}getOperatorList({intent:t="display",annotationMode:e=zt.ENABLE,printAnnotationStorage:s=null}={}){function i(){r.operatorList.lastChunk&&(r.opListReadCapability.resolve(r.operatorList),r.renderTasks.delete(a))}const n=this._transport.getRenderingIntent(t,e,s,!0);let r=this._intentStates.get(n.cacheKey);r||(r=Object.create(null),this._intentStates.set(n.cacheKey,r));let a;return r.opListReadCapability||(a=Object.create(null),a.operatorListChanged=i,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:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(i){return i.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>_e.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){function n(){r.read().then(function({value:o,done:c}){if(c){s(a);return}a.lang??=o.lang,Object.assign(a.styles,o.styles),a.items.push(...o.items),n()},i)}const r=e.getReader(),a={items:[],styles:Object.create(null),lang:null};n()})}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 s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),this.#e=!1,this.#n(),Promise.all(t)}cleanup(t=!1){this.#e=!0;const e=this.#s(!1);return t&&e&&(this._stats&&=new $s),e}#s(t=!1){if(this.#n(),!this.#e||this.destroyed)return!1;if(t)return this.#t=setTimeout(()=>{this.#t=null,this.#s(!1)},Mr),!1;for(const{renderTasks:e,operatorList:s}of this._intentStates.values())if(e.size>0||!s.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#e=!1,!0}#n(){this.#t&&(clearTimeout(this.#t),this.#t=null)}_startRenderPage(t,e){const s=this._intentStates.get(e);s&&(this._stats?.timeEnd("Page Request"),s.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&this.#s(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s}){const{map:i,transfer:n}=s,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:i},n).getReader(),o=this._intentStates.get(e);o.streamReader=a;const c=()=>{a.read().then(({value:h,done:d})=>{if(d){o.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(h,o),c())},h=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const d of o.renderTasks)d.operatorListChanged();this.#s(!0)}if(o.displayReadyCapability)o.displayReadyCapability.reject(h);else if(o.opListReadCapability)o.opListReadCapability.reject(h);else throw h}})};c()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof xs){let i=kr;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new Zt(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,n]of this._intentStates)if(n===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}class Ur{#t=new Set;#e=Promise.resolve();postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(const i of this.#t)i.call(this,s)})}addEventListener(t,e){this.#t.add(e)}removeEventListener(t,e){this.#t.delete(e)}terminate(){this.#t.clear()}}const Bt={isWorkerDisabled:!1,fakeWorkerId:0};ut&&(Bt.isWorkerDisabled=!0,ye.workerSrc||="./pdf.worker.mjs"),Bt.isSameOrigin=function(l,t){let e;try{if(e=new URL(l),!e.origin||e.origin==="null")return!1}catch{return!1}const s=new URL(t,e);return e.origin===s.origin},Bt.createCDNWrapper=function(l){const t=`await import("${l}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))};class Tt{static#t;constructor({name:t=null,port:e=null,verbosity:s=yn()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(Tt.#t?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(Tt.#t||=new WeakMap).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return ut?Promise.all([Dt.promise,this._readyCapability.promise]):this._readyCapability.promise}#e(){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 ve("main","worker",t),this._messageHandler.on("ready",function(){}),this.#e()}_initialize(){if(Bt.isWorkerDisabled||Tt.#s){this._setupFakeWorker();return}let{workerSrc:t}=Tt;try{Bt.isSameOrigin(window.location.href,t)||(t=Bt.createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new ve("main","worker",e),i=()=>{n.abort(),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=new AbortController;e.addEventListener("error",()=>{this._webWorker||i()},{signal:n.signal}),s.on("test",a=>{if(n.abort(),this.destroyed||!a){i();return}this._messageHandler=s,this._port=e,this._webWorker=e,this.#e()}),s.on("ready",a=>{if(n.abort(),this.destroyed){i();return}try{r()}catch{this._setupFakeWorker()}});const r=()=>{const a=new Uint8Array;s.send("test",a,[a.buffer])};r();return}catch{Ue("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){Bt.isWorkerDisabled||(F("Setting up fake worker."),Bt.isWorkerDisabled=!0),Tt._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new Ur;this._port=e;const s=`fake${Bt.fakeWorkerId++}`,i=new ve(s+"_worker",s,e);t.setup(i,e),this._messageHandler=new ve(s,s+"_worker",e),this.#e()}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),Tt.#t?.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const e=this.#t?.get(t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new Tt(t)}static get workerSrc(){if(ye.workerSrc)return ye.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#s(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return B(this,"_setupFakeWorkerGlobal",(async()=>this.#s?this.#s:(await import(this.workerSrc)).WorkerMessageHandler)())}}class zr{#t=new Map;#e=new Map;#s=new Map;#n=new Map;#o=null;constructor(t,e,s,i,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Di,this.fontLoader=new $n({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#i(t,e=null){const s=this.#t.get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return this.#t.set(t,i),i}get annotationStorage(){return B(this,"annotationStorage",new Ms)}getRenderingIntent(t,e=zt.ENABLE,s=null,i=!1){let n=Ct.DISPLAY,r=fs;switch(t){case"any":n=Ct.ANY;break;case"display":break;case"print":n=Ct.PRINT;break;default:F(`getRenderingIntent - invalid intent: ${t}`)}switch(e){case zt.DISABLE:n+=Ct.ANNOTATIONS_DISABLE;break;case zt.ENABLE:break;case zt.ENABLE_FORMS:n+=Ct.ANNOTATIONS_FORMS;break;case zt.ENABLE_STORAGE:n+=Ct.ANNOTATIONS_STORAGE,r=(n&Ct.PRINT&&s instanceof Si?s:this.annotationStorage).serializable;break;default:F(`getRenderingIntent - invalid annotationMode: ${e}`)}return i&&(n+=Ct.OPLIST),{renderingIntent:n,cacheKey:`${n}_${r.hash}`,annotationStorageSerializable:r}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#o?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const s of this.#e.values())t.push(s._destroy());this.#e.clear(),this.#s.clear(),this.#n.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.#t.clear(),this.filterFactory.destroy(),Be.cleanup(),this._networkStream?.cancelAllRequests(new Zt("Worker was terminated.")),this.messageHandler&&(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",(s,i)=>{nt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=n=>{this._lastProgress={loaded:n.loaded,total:n.total}},i.onPull=()=>{this._fullReader.read().then(function({value:n,done:r}){if(r){i.close();return}nt(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(n),1,[n])}).catch(n=>{i.error(n)})},i.onCancel=n=>{this._fullReader.cancel(n),i.ready.catch(r=>{if(!this.destroyed)throw r})}}),t.on("ReaderHeadersReady",s=>{const i=Promise.withResolvers(),n=this._fullReader;return n.headersReady.then(()=>{(!n.isStreamingSupported||!n.isRangeSupported)&&(this._lastProgress&&e.onProgress?.(this._lastProgress),n.onProgress=r=>{e.onProgress?.({loaded:r.loaded,total:r.total})}),i.resolve({isStreamingSupported:n.isStreamingSupported,isRangeSupported:n.isRangeSupported,contentLength:n.contentLength})},i.reject),i.promise}),t.on("GetRangeReader",(s,i)=>{nt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(s.begin,s.end);if(!n){i.close();return}i.onPull=()=>{n.read().then(function({value:r,done:a}){if(a){i.close();return}nt(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{n.cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new jr(s,this))}),t.on("DocException",function(s){let i;switch(s.name){case"PasswordException":i=new ds(s.message,s.code);break;case"InvalidPDFException":i=new mi(s.message);break;case"MissingPDFException":i=new Jt(s.message);break;case"UnexpectedResponseException":i=new ze(s.message,s.status);break;case"UnknownErrorException":i=new us(s.message,s.details);break;default:V("DocException - expected a valid Error.")}e._capability.reject(i)}),t.on("PasswordRequest",s=>{if(this.#o=Promise.withResolvers(),e.onPassword){const i=n=>{n instanceof Error?this.#o.reject(n):this.#o.resolve({password:n})};try{e.onPassword(i,s.code)}catch(n){this.#o.reject(n)}}else this.#o.reject(new ds(s.message,s.code));return this.#o.promise}),t.on("DataLoaded",s=>{e.onProgress?.({loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;this.#e.get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,n])=>{if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":const{disableFontFace:r,fontExtraProperties:a,pdfBug:o}=this._params;if("error"in n){const u=n.error;F(`Error during font loading: ${u}`),this.commonObjs.resolve(s,u);break}const c=o&&globalThis.FontInspector?.enabled?(u,p)=>globalThis.FontInspector.fontAdded(u,p):null,h=new Un(n,{disableFontFace:r,inspectFont:c});this.fontLoader.bind(h).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!a&&h.data&&(h.data=null),this.commonObjs.resolve(s,h)});break;case"CopyLocalImage":const{imageRef:d}=n;nt(d,"The imageRef must be defined.");for(const u of this.#e.values())for(const[,p]of u.objs)if(p?.ref===d)return p.dataLen?(this.commonObjs.resolve(s,structuredClone(p)),p.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,n);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,n,r])=>{if(this.destroyed)return;const a=this.#e.get(i);if(!a.objs.has(s)){if(a._intentStates.size===0){r?.bitmap?.close();return}switch(n){case"Image":a.objs.resolve(s,r),r?.dataLen>gn&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(s,r);break;default:throw new Error(`Got unknown object type ${n}`)}}}),t.on("DocProgress",s=>{this.destroyed||e.onProgress?.({loaded:s.loaded,total:s.total})}),t.on("FetchBuiltInCMap",s=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(s):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))),t.on("FetchStandardFontData",s=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(s):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.")))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&F("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,s=this.#s.get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&this.#n.set(n.refStr,t);const r=new $r(e,n,this,this._params.pdfBug);return this.#e.set(e,r),r});return this.#s.set(e,i),i}getPageIndex(t){return ei(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.#i("GetFieldObjects")}hasJSActions(){return this.#i("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?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.#i("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.#i("GetOptionalContentConfig").then(e=>new lr(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#t.get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(i=>({info:i[0],metadata:i[1]?new ar(i[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#t.set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of this.#e.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(!0),Be.cleanup()}}cachedPageNumber(t){if(!ei(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return this.#n.get(e)??null}}const De=Symbol("INITIAL_DATA");class Di{#t=Object.create(null);#e(t){return this.#t[t]||={...Promise.withResolvers(),data:De}}get(t,e=null){if(e){const i=this.#e(t);return i.promise.then(()=>e(i.data)),null}const s=this.#t[t];if(!s||s.data===De)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=this.#t[t];return!!e&&e.data!==De}resolve(t,e=null){const s=this.#e(t);s.data=e,s.resolve()}clear(){for(const t in this.#t){const{data:e}=this.#t[t];e?.bitmap?.close()}this.#t=Object.create(null)}*[Symbol.iterator](){for(const t in this.#t){const{data:e}=this.#t[t];e!==De&&(yield[t,e])}}}class Gr{#t=null;constructor(t){this.#t=t,this.onContinue=null}get promise(){return this.#t.capability.promise}cancel(t=0){this.#t.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#t.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#t;return t.form||t.canvas&&e?.size>0}}class ne{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:c,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:u=null}){this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=c,this._pdfBug=d,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=h===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Gr(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(ne.#e.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.");ne.#e.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:s,viewport:i,transform:n,background:r}=this.params;this.gfx=new re(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:i,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.#t&&(window.cancelAnimationFrame(this.#t),this.#t=null),ne.#e.delete(this._canvas),this.callback(t||new xs(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#t=window.requestAnimationFrame(()=>{this.#t=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(),ne.#e.delete(this._canvas),this.callback())))}}const Vr="4.4.168",Wr="19fbc8998";function si(l){return Math.floor(Math.max(0,Math.min(1,l))*255).toString(16).padStart(2,"0")}function me(l){return Math.max(0,Math.min(255,255*l))}class ii{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}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=me(t),[t,t,t]}static G_HTML([t]){const e=si(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(me)}static RGB_HTML(t){return`#${t.map(si).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[me(1-Math.min(1,t+i)),me(1-Math.min(1,s+i)),me(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,n=1-e,r=1-s,a=Math.min(i,n,r);return["CMYK",i,n,r,a]}}class Fi{static setupStorage(t,e,s,i,n){const r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",a=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(const a of s.children)a.attributes.value===r.value?a.attributes.selected=!0:a.attributes.hasOwnProperty("selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{const o=a.target.options,c=o.selectedIndex===-1?"":o[o.selectedIndex].value;i.setValue(e,{value:c})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${i}`);for(const[o,c]of Object.entries(r))if(c!=null)switch(o){case"class":c.length&&t.setAttribute(o,c.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",c);break;case"style":Object.assign(t.style,c);break;case"textContent":t.textContent=c;break;default:(!a||o!=="href"&&o!=="newWindow")&&t.setAttribute(o,c)}a&&n.addLinkAttributes(t,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(t,r.dataId,e,s)}static render(t){const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",r=document.createElement(i.name);i.attributes&&this.setAttributes({html:r,element:i,intent:n,linkService:s});const a=n!=="richText",o=t.div;if(o.append(r),t.viewport){const d=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=d}a&&o.setAttribute("class","xfaLayer xfaFont");const c=[];if(i.children.length===0){if(i.value){const d=document.createTextNode(i.value);r.append(d),a&&_e.shouldBuildText(i.name)&&c.push(d)}return{textDivs:c}}const h=[[i,-1,r]];for(;h.length>0;){const[d,u,p]=h.at(-1);if(u+1===d.children.length){h.pop();continue}const f=d.children[++h.at(-1)[1]];if(f===null)continue;const{name:g}=f;if(g==="#text"){const m=document.createTextNode(f.value);c.push(m),p.append(m);continue}const b=f?.attributes?.xmlns?document.createElementNS(f.attributes.xmlns,g):document.createElement(g);if(p.append(b),f.attributes&&this.setAttributes({html:b,element:f,storage:e,intent:n,linkService:s}),f.children?.length>0)h.push([f,-1,b]);else if(f.value){const m=document.createTextNode(f.value);a&&_e.shouldBuildText(g)&&c.push(m),b.append(m)}}for(const d of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))d.setAttribute("readOnly",!0);return{textDivs:c}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const xe=1e3,qr=9,Kt=new WeakSet;function jt(l){return{width:l[2]-l[0],height:l[3]-l[1]}}class Xr{static create(t){switch(t.data.annotationType){case st.LINK:return new Oi(t);case st.TEXT:return new Yr(t);case st.WIDGET:switch(t.data.fieldType){case"Tx":return new Kr(t);case"Btn":return t.data.radioButton?new Ni(t):t.data.checkBox?new Jr(t):new Zr(t);case"Ch":return new ta(t);case"Sig":return new Qr(t)}return new te(t);case st.POPUP:return new bs(t);case st.FREETEXT:return new Hi(t);case st.LINE:return new sa(t);case st.SQUARE:return new ia(t);case st.CIRCLE:return new na(t);case st.POLYLINE:return new Bi(t);case st.CARET:return new aa(t);case st.INK:return new ji(t);case st.POLYGON:return new ra(t);case st.HIGHLIGHT:return new oa(t);case st.UNDERLINE:return new la(t);case st.SQUIGGLY:return new ha(t);case st.STRIKEOUT:return new ca(t);case st.STAMP:return new $i(t);case st.FILEATTACHMENT:return new da(t);default:return new J(t)}}}class J{#t=null;#e=!1;#s=null;constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!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(s)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:s}){return!!(t?.str||e?.str||s?.str)}get hasPopupData(){return J._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#t||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#n(e),this.#s?.popup.updateEdited(t)}resetEdited(){this.#t&&(this.#n(this.#t.rect),this.#s?.popup.resetEdited(),this.#t=null)}#n(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;s?.splice(0,4,...t);const{width:c,height:h}=jt(t);e.left=`${100*(t[0]-a)/n}%`,e.top=`${100*(r-t[3]+o)/r}%`,i===0?(e.width=`${100*c/n}%`,e.height=`${100*h/r}%`):this.setRotation(i)}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof te||(n.tabIndex=xe);const{style:r}=n;if(r.zIndex=this.parent.zIndex++,e.popupRef&&n.setAttribute("aria-haspopup","dialog"),e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof bs){const{rotation:g}=e;return!e.hasOwnCanvas&&g!==0&&this.setRotation(g,n),n}const{width:a,height:o}=jt(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const g=e.borderStyle.horizontalCornerRadius,b=e.borderStyle.verticalCornerRadius;if(g>0||b>0){const v=`calc(${g}px * var(--scale-factor)) / calc(${b}px * var(--scale-factor))`;r.borderRadius=v}else if(this instanceof Ni){const v=`calc(${a}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;r.borderRadius=v}switch(e.borderStyle.style){case pe.SOLID:r.borderStyle="solid";break;case pe.DASHED:r.borderStyle="dashed";break;case pe.BEVELED:F("Unimplemented border style: beveled");break;case pe.INSET:F("Unimplemented border style: inset");break;case pe.UNDERLINE:r.borderBottomStyle="solid";break}const m=e.borderColor||null;m?(this.#e=!0,r.borderColor=R.makeHexColor(m[0]|0,m[1]|0,m[2]|0)):r.borderWidth=0}const c=R.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:h,pageHeight:d,pageX:u,pageY:p}=i.rawDims;r.left=`${100*(c[0]-u)/h}%`,r.top=`${100*(c[1]-p)/d}%`;const{rotation:f}=e;return e.hasOwnCanvas||f===0?(r.width=`${100*a/h}%`,r.height=`${100*o/d}%`):this.setRotation(f,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:n,height:r}=jt(this.data.rect);let a,o;t%180===0?(a=100*n/s,o=100*r/i):(a=100*r/s,o=100*n/i),e.style.width=`${a}%`,e.style.height=`${o}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const n=i.detail[e],r=n[0],a=n.slice(1);i.target.style[s]=ii[`${r}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[s]:ii[`${r}_rgb`](a)})};return B(this,"_commonActions",{display:e=>{const{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.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:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail))(t[i]||s[i])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,n]of Object.entries(e)){const r=s[i];if(r){const a={detail:{[i]:n},target:t};r(a),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,n]=this.data.rect.map(g=>Math.fround(g));if(t.length===8){const[g,b,m,v]=t.subarray(2,6);if(i===g&&n===b&&e===m&&s===v)return}const{style:r}=this.container;let a;if(this.#e){const{borderColor:g,borderWidth:b}=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="${g}" stroke-width="${b}">`],this.container.classList.add("hasBorder")}const o=i-e,c=n-s,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);const u=h.createElement("defs");d.append(u);const p=h.createElement("clipPath"),f=`clippath_${this.data.id}`;p.setAttribute("id",f),p.setAttribute("clipPathUnits","objectBoundingBox"),u.append(p);for(let g=2,b=t.length;g<b;g+=8){const m=t[g],v=t[g+1],y=t[g+2],A=t[g+3],_=h.createElement("rect"),w=(y-e)/o,E=(n-v)/c,x=(m-y)/o,S=(v-A)/c;_.setAttribute("x",w),_.setAttribute("y",E),_.setAttribute("width",x),_.setAttribute("height",S),p.append(_),a?.push(`<rect vector-effect="non-scaling-stroke" x="${w}" y="${E}" width="${x}" height="${S}"/>`)}this.#e&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${f})`}_createPopup(){const{container:t,data:e}=this;t.setAttribute("aria-haspopup","dialog");const s=this.#s=new bs({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]});this.parent.div.append(s.render())}render(){V("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:n,id:r,exportValues:a}of i){if(n===-1||r===e)continue;const o=typeof a=="string"?a:null,c=document.querySelector(`[data-element-id="${r}"]`);if(c&&!Kt.has(c)){F(`_getElementsByName - element not allowed: ${r}`);continue}s.push({id:r,exportValue:o,domElement:c})}return s}for(const i of document.getElementsByName(t)){const{exportValue:n}=i,r=i.getAttribute("data-element-id");r!==e&&Kt.has(i)&&s.push({id:r,exportValue:n,domElement:i})}return s}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")}get _isEditable(){return!1}_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 Oi extends J{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,s=document.createElement("a");s.setAttribute("data-element-id",t.id);let i=!1;return t.url?(e.addLinkAttributes(s,t.url,t.newWindow),i=!0):t.action?(this._bindNamedAction(s,t.action),i=!0):t.attachment?(this.#e(s,t.attachment,t.attachmentDest),i=!0):t.setOCGState?(this.#s(s,t.setOCGState),i=!0):t.dest?(this._bindLink(s,t.dest),i=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(s,t),i=!0),t.resetForm?(this._bindResetFormAction(s,t.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(s,""),i=!0)),this.container.classList.add("linkAnnotation"),i&&this.container.append(s),this.container}#t(){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.#t()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#t()}#e(t,e,s=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,s),!1),this.#t()}#s(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#t()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(e.actions)){const n=s.get(i);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:i}}),!1))}t.onclick||(t.onclick=()=>!1),this.#t()}_bindResetFormAction(t,e){const s=t.onclick;if(s||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects){F('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),s||(t.onclick=()=>!1);return}t.onclick=()=>{s?.();const{fields:i,refs:n,include:r}=e,a=[];if(i.length!==0||n.length!==0){const h=new Set(n);for(const d of i){const u=this._fieldObjects[d]||[];for(const{id:p}of u)h.add(p)}for(const d of Object.values(this._fieldObjects))for(const u of d)h.has(u.id)===r&&a.push(u)}else for(const h of Object.values(this._fieldObjects))a.push(...h);const o=this.annotationStorage,c=[];for(const h of a){const{id:d}=h;switch(c.push(d),h.type){case"text":{const p=h.defaultValue||"";o.setValue(d,{value:p});break}case"checkbox":case"radiobutton":{const p=h.defaultValue===h.exportValues;o.setValue(d,{value:p});break}case"combobox":case"listbox":{const p=h.defaultValue||"";o.setValue(d,{value:p});break}default:continue}const u=document.querySelector(`[data-element-id="${d}"]`);if(u){if(!Kt.has(u)){F(`_bindResetFormAction - element not allowed: ${d}`);continue}}else continue;u.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:c,name:"ResetForm"}}),!1}}}class Yr extends J{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 te extends J{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return vt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){s.includes("mouse")?t.addEventListener(s,r=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})}):t.addEventListener(s,r=>{if(s==="blur"){if(!e.focused||!r.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r)}})})}_setEventListeners(t,e,s,i){for(const[n,r]of s)(r==="Action"||this.data.actions?.[r])&&((r==="Focus"||r==="Blur")&&(e||={focused:!1}),this._setEventListener(t,e,n,r,i),r==="Focus"&&!this.data.actions?.Blur?this._setEventListener(t,e,"blur","Blur",null):r==="Blur"&&!this.data.actions?.Focus&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":R.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||qr,n=t.style;let r;const a=2,o=c=>Math.round(10*c)/10;if(this.data.multiLine){const c=Math.abs(this.data.rect[3]-this.data.rect[1]-a),h=Math.round(c/(es*i))||1,d=c/h;r=Math.min(i,o(d/es))}else{const c=Math.abs(this.data.rect[3]-this.data.rect[1]-a);r=Math.min(i,o(c/es))}n.fontSize=`calc(${r}px * var(--scale-factor))`,n.color=R.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Kr extends te{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=s),n.setValue(r.id,{[i]:s})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const i=t.getValue(e,{value:this.data.fieldValue});let n=i.value||"";const r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&n.length>r&&(n=n.slice(0,r));let a=i.formattedValue||this.data.textContent?.join(`
4
4
  `)||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?(s=document.createElement("textarea"),s.textContent=a??n,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",a??n),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),Kt.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=xe,this._setRequired(s,this.data.required),r&&(s.maxLength=r),s.addEventListener("input",h=>{t.setValue(e,{value:h.target.value}),this.setPropertyOnSiblings(s,"value",h.target.value,"value"),o.formattedValue=null}),s.addEventListener("resetform",h=>{const d=this.data.defaultFieldValue??"";s.value=o.userValue=d,o.formattedValue=null});let c=h=>{const{formattedValue:d}=o;d!=null&&(h.target.value=d),h.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",d=>{if(o.focused)return;const{target:u}=d;o.userValue&&(u.value=o.userValue),o.lastCommittedValue=u.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),s.addEventListener("updatefromsandbox",d=>{this.showElementAndHideCanvas(d.target);const u={value(p){o.userValue=p.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),p.target.value=o.userValue},formattedValue(p){const{formattedValue:f}=p.detail;o.formattedValue=f,f!=null&&p.target!==document.activeElement&&(p.target.value=f),t.setValue(e,{formattedValue:f})},selRange(p){p.target.setSelectionRange(...p.detail.selRange)},charLimit:p=>{const{charLimit:f}=p.detail,{target:g}=p;if(f===0){g.removeAttribute("maxLength");return}g.setAttribute("maxLength",f);let b=o.userValue;!b||b.length<=f||(b=b.slice(0,f),g.value=o.userValue=b,t.setValue(e,{value:b}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:b,willCommit:!0,commitKey:1,selStart:g.selectionStart,selEnd:g.selectionEnd}}))}};this._dispatchEventFromSandbox(u,d)}),s.addEventListener("keydown",d=>{o.commitKey=1;let u=-1;if(d.key==="Escape"?u=0:d.key==="Enter"&&!this.data.multiLine?u=2:d.key==="Tab"&&(o.commitKey=3),u===-1)return;const{value:p}=d.target;o.lastCommittedValue!==p&&(o.lastCommittedValue=p,o.userValue=p,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:p,willCommit:!0,commitKey:u,selStart:d.target.selectionStart,selEnd:d.target.selectionEnd}}))});const h=c;c=null,s.addEventListener("blur",d=>{if(!o.focused||!d.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{value:u}=d.target;o.userValue=u,o.lastCommittedValue!==u&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:u,willCommit:!0,commitKey:o.commitKey,selStart:d.target.selectionStart,selEnd:d.target.selectionEnd}}),h(d)}),this.data.actions?.Keystroke&&s.addEventListener("beforeinput",d=>{o.lastCommittedValue=null;const{data:u,target:p}=d,{value:f,selectionStart:g,selectionEnd:b}=p;let m=g,v=b;switch(d.inputType){case"deleteWordBackward":{const y=f.substring(0,g).match(/\w*[^\w]*$/);y&&(m-=y[0].length);break}case"deleteWordForward":{const y=f.substring(g).match(/^[^\w]*\w*/);y&&(v+=y[0].length);break}case"deleteContentBackward":g===b&&(m-=1);break;case"deleteContentForward":g===b&&(v+=1);break}d.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:f,change:u||"",willCommit:!1,selStart:m,selEnd:v}})}),this._setEventListeners(s,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],d=>d.target.value)}if(c&&s.addEventListener("blur",c),this.data.comb){const d=(this.data.rect[2]-this.data.rect[0])/r;s.classList.add("comb"),s.style.letterSpacing=`calc(${d}px * var(--scale-factor) - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Qr extends te{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Jr extends te{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",t.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return Kt.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=xe,n.addEventListener("change",r=>{const{name:a,checked:o}=r.target;for(const c of this._getElementsByName(a,s)){const h=o&&c.exportValue===e.exportValue;c.domElement&&(c.domElement.checked=h),t.setValue(c.id,{value:h})}t.setValue(s,{value:o})}),n.addEventListener("resetform",r=>{const a=e.defaultFieldValue||"Off";r.target.checked=a===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",r=>{const a={value(o){o.target.checked=o.detail.value!=="Off",t.setValue(s,{value:o.target.checked})}};this._dispatchEventFromSandbox(a,r)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],r=>r.target.checked)),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Ni extends te{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.fieldValue===e.buttonValue}).value;if(typeof i=="string"&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(const r of this._getElementsByName(e.fieldName,s))t.setValue(r.id,{value:!1});const n=document.createElement("input");if(Kt.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.tabIndex=xe,n.addEventListener("change",r=>{const{name:a,checked:o}=r.target;for(const c of this._getElementsByName(a,s))t.setValue(c.id,{value:!1});t.setValue(s,{value:o})}),n.addEventListener("resetform",r=>{const a=e.defaultFieldValue;r.target.checked=a!=null&&a===e.buttonValue}),this.enableScripting&&this.hasJSActions){const r=e.buttonValue;n.addEventListener("updatefromsandbox",a=>{const o={value:c=>{const h=r===c.detail.value;for(const d of this._getElementsByName(c.target.name)){const u=h&&d.id===s;d.domElement&&(d.domElement.checked=u),t.setValue(d.id,{value:u})}}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Zr extends Oi{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",s=>{this._dispatchEventFromSandbox({},s)})),t}}class ta extends te{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");Kt.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=xe;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",h=>{const d=this.data.defaultFieldValue;for(const u of i.options)u.selected=u.value===d});for(const h of this.data.options){const d=document.createElement("option");d.textContent=h.displayValue,d.value=h.exportValue,s.value.includes(h.exportValue)&&(d.setAttribute("selected",!0),n=!1),i.append(d)}let r=null;if(n){const h=document.createElement("option");h.value=" ",h.setAttribute("hidden",!0),h.setAttribute("selected",!0),i.prepend(h),r=()=>{h.remove(),i.removeEventListener("input",r),r=null},i.addEventListener("input",r)}const a=h=>{const d=h?"value":"textContent",{options:u,multiple:p}=i;return p?Array.prototype.filter.call(u,f=>f.selected).map(f=>f[d]):u.selectedIndex===-1?null:u[u.selectedIndex][d]};let o=a(!1);const c=h=>{const d=h.target.options;return Array.prototype.map.call(d,u=>({displayValue:u.textContent,exportValue:u.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",h=>{const d={value(u){r?.();const p=u.detail.value,f=new Set(Array.isArray(p)?p:[p]);for(const g of i.options)g.selected=f.has(g.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(u){i.multiple=!0},remove(u){const p=i.options,f=u.detail.remove;p[f].selected=!1,i.remove(f),p.length>0&&Array.prototype.findIndex.call(p,b=>b.selected)===-1&&(p[0].selected=!0),t.setValue(e,{value:a(!0),items:c(u)}),o=a(!1)},clear(u){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(u){const{index:p,displayValue:f,exportValue:g}=u.detail.insert,b=i.children[p],m=document.createElement("option");m.textContent=f,m.value=g,b?b.before(m):i.append(m),t.setValue(e,{value:a(!0),items:c(u)}),o=a(!1)},items(u){const{items:p}=u.detail;for(;i.length!==0;)i.remove(0);for(const f of p){const{displayValue:g,exportValue:b}=f,m=document.createElement("option");m.textContent=g,m.value=b,i.append(m)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:a(!0),items:c(u)}),o=a(!1)},indices(u){const p=new Set(u.detail.indices);for(const f of u.target.options)f.selected=p.has(f.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(u){u.target.disabled=!u.detail.editable}};this._dispatchEventFromSandbox(d,h)}),i.addEventListener("input",h=>{const d=a(!0),u=a(!1);t.setValue(e,{value:d}),h.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:u,changeEx:d,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],h=>h.target.value)):i.addEventListener("input",function(h){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class bs extends J{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:J._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new ea({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 s of this.elements)s.popup=t,e.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(s=>`${vi}${s}`).join(",")),this.container}}class ea{#t=this.#L.bind(this);#e=this.#w.bind(this);#s=this.#b.bind(this);#n=this.#y.bind(this);#o=null;#i=null;#r=null;#l=null;#c=null;#d=null;#f=null;#h=!1;#a=null;#p=null;#m=null;#u=null;#v=null;#g=null;#A=!1;constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:r,richText:a,parent:o,rect:c,parentRect:h,open:d}){this.#i=t,this.#v=i,this.#r=r,this.#u=a,this.#d=o,this.#o=e,this.#m=c,this.#f=h,this.#c=s,this.#l=wi.toDateObject(n),this.trigger=s.flatMap(u=>u.getElementsToTriggerPopup());for(const u of this.trigger)u.addEventListener("click",this.#n),u.addEventListener("mouseenter",this.#s),u.addEventListener("mouseleave",this.#e),u.classList.add("popupTriggerArea");for(const u of s)u.container?.addEventListener("keydown",this.#t);this.#i.hidden=!0,d&&this.#y()}render(){if(this.#a)return;const t=this.#a=document.createElement("div");if(t.className="popup",this.#o){const n=t.style.outlineColor=R.makeHexColor(...this.#o);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${n} 30%, white)`:t.style.backgroundColor=R.makeHexColor(...this.#o.map(a=>Math.floor(.7*(255-a)+a)))}const e=document.createElement("span");e.className="header";const s=document.createElement("h1");if(e.append(s),{dir:s.dir,str:s.textContent}=this.#v,t.append(e),this.#l){const n=document.createElement("span");n.classList.add("popupDate"),n.setAttribute("data-l10n-id","pdfjs-annotation-date-string"),n.setAttribute("data-l10n-args",JSON.stringify({date:this.#l.toLocaleDateString(),time:this.#l.toLocaleTimeString()})),e.append(n)}const i=this.#_;if(i)Fi.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const n=this._formatContents(this.#r);t.append(n)}this.#i.append(t)}get#_(){const t=this.#u,e=this.#r;return t?.str&&(!e?.str||e.str===t.str)&&this.#u.html||null}get#E(){return this.#_?.attributes?.style?.fontSize||0}get#x(){return this.#_?.attributes?.style?.color||null}#C(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:this.#x,fontSize:this.#E?`calc(${this.#E}px * var(--scale-factor))`:""}};for(const n of t.split(`
5
5
  `))e.push({name:"span",value:n,attributes:i});return s}_formatContents({str:t,dir:e}){const s=document.createElement("p");s.classList.add("popupContent"),s.dir=e;const i=t.split(/(?:\r\n?|\n)/);for(let n=0,r=i.length;n<r;++n){const a=i[n];s.append(document.createTextNode(a)),n<r-1&&s.append(document.createElement("br"))}return s}#L(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&this.#h)&&this.#y()}updateEdited({rect:t,popupContent:e}){this.#g||={contentsObj:this.#r,richText:this.#u},t&&(this.#p=null),e&&(this.#u=this.#C(e),this.#r=null),this.#a?.remove(),this.#a=null}resetEdited(){this.#g&&({contentsObj:this.#r,richText:this.#u}=this.#g,this.#g=null,this.#a?.remove(),this.#a=null,this.#p=null)}#S(){if(this.#p!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:n}}}=this.#d;let r=!!this.#f,a=r?this.#f:this.#m;for(const f of this.#c)if(!a||R.intersect(f.data.rect,a)!==null){a=f.data.rect,r=!0;break}const o=R.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),h=r?a[2]-a[0]+5:0,d=o[0]+h,u=o[1];this.#p=[100*(d-i)/e,100*(u-n)/s];const{style:p}=this.#i;p.left=`${this.#p[0]}%`,p.top=`${this.#p[1]}%`}#y(){this.#h=!this.#h,this.#h?(this.#b(),this.#i.addEventListener("click",this.#n),this.#i.addEventListener("keydown",this.#t)):(this.#w(),this.#i.removeEventListener("click",this.#n),this.#i.removeEventListener("keydown",this.#t))}#b(){this.#a||this.render(),this.isVisible?this.#h&&this.#i.classList.add("focused"):(this.#S(),this.#i.hidden=!1,this.#i.style.zIndex=parseInt(this.#i.style.zIndex)+1e3)}#w(){this.#i.classList.remove("focused"),!(this.#h||!this.isVisible)&&(this.#i.hidden=!0,this.#i.style.zIndex=parseInt(this.#i.style.zIndex)-1e3)}forceHide(){this.#A=this.isVisible,this.#A&&(this.#i.hidden=!0)}maybeShow(){this.#A&&(this.#a||this.#b(),this.#A=!1,this.#i.hidden=!1)}get isVisible(){return this.#i.hidden===!1}}class Hi extends J{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=N.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}get _isEditable(){return this.data.hasOwnCanvas}}class sa extends J{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const t=this.data,{width:e,height:s}=jt(t.rect),i=this.svgFactory.create(e,s,!0),n=this.#t=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"),i.append(n),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class ia extends J{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const t=this.data,{width:e,height:s}=jt(t.rect),i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",s-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.append(r),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class na extends J{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const t=this.data,{width:e,height:s}=jt(t.rect),i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",s/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",s/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.append(r),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Bi extends J{#t=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:s,popupRef:i}}=this;if(!e)return this.container;const{width:n,height:r}=jt(t),a=this.svgFactory.create(n,r,!0);let o=[];for(let h=0,d=e.length;h<d;h+=2){const u=e[h]-t[0],p=t[3]-e[h+1];o.push(`${u},${p}`)}o=o.join(" ");const c=this.#t=this.svgFactory.createElement(this.svgElementName);return c.setAttribute("points",o),c.setAttribute("stroke-width",s.width||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),a.append(c),this.container.append(a),!i&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class ra extends Bi{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class aa extends J{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 ji extends J{#t=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=N.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,inkLists:e,borderStyle:s,popupRef:i}}=this,{width:n,height:r}=jt(t),a=this.svgFactory.create(n,r,!0);for(const o of e){let c=[];for(let d=0,u=o.length;d<u;d+=2){const p=o[d]-t[0],f=t[3]-o[d+1];c.push(`${p},${f}`)}c=c.join(" ");const h=this.svgFactory.createElement(this.svgElementName);this.#t.push(h),h.setAttribute("points",c),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),!i&&this.hasPopupData&&this._createPopup(),a.append(h)}return this.container.append(a),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class oa extends J{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this.container}}class la extends J{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 ha extends J{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 ca extends J{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 $i extends J{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("stampAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class da extends J{#t=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 s;e.hasAppearance||e.fillAlpha===0?s=document.createElement("div"):(s=document.createElement("img"),s.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(s.style=`filter: opacity(${Math.round(e.fillAlpha*100)}%);`)),s.addEventListener("dblclick",this.#e.bind(this)),this.#t=s;const{isMac:i}=vt.platform;return t.addEventListener("keydown",n=>{n.key==="Enter"&&(i?n.metaKey:n.ctrlKey)&&this.#e()}),!e.popupRef&&this.hasPopupData?this._createPopup():s.classList.add("popupTriggerArea"),t.append(s),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}#e(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}let ua=class{#t=null;#e=null;#s=new Map;constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:r}){this.div=t,this.#t=e,this.#e=s,this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=i}#n(t,e){const s=t.firstChild||t;s.id=`${vi}${e}`,this.div.append(t),this.#t?.moveElementInDOM(this.div,t,s,!1)}async render(t){const{annotations:e}=t,s=this.div;Yt(s,this.viewport);const i=new Map,n={data:null,layer:s,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Ss,annotationStorage:t.annotationStorage||new Ms,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const r of e){if(r.noHTML)continue;const a=r.annotationType===st.POPUP;if(a){const h=i.get(r.id);if(!h)continue;n.elements=h}else{const{width:h,height:d}=jt(r.rect);if(h<=0||d<=0)continue}n.data=r;const o=Xr.create(n);if(!o.isRenderable)continue;if(!a&&r.popupRef){const h=i.get(r.popupRef);h?h.push(o):i.set(r.popupRef,[o])}const c=o.render();r.hidden&&(c.style.visibility="hidden"),this.#n(c,r.id),o.annotationEditorType>0&&(this.#s.set(o.data.id,o),this._annotationEditorUIManager?.renderAnnotationElement(o))}this.#o()}update({viewport:t}){const e=this.div;this.viewport=t,Yt(e,{rotation:t.rotation}),this.#o(),e.hidden=!1}#o(){if(!this.#e)return;const t=this.div;for(const[e,s]of this.#e){const i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;s.className="annotationContent";const{firstChild:n}=i;n?n.nodeName==="CANVAS"?n.replaceWith(s):n.classList.contains("annotationContent")?n.after(s):n.before(s):i.append(s)}this.#e.clear()}getEditableAnnotations(){return Array.from(this.#s.values())}getEditableAnnotation(t){return this.#s.get(t)}};const Fe=/\r\n?|\n/g;class it extends I{#t=this.editorDivBlur.bind(this);#e=this.editorDivFocus.bind(this);#s=this.editorDivInput.bind(this);#n=this.editorDivKeydown.bind(this);#o=this.editorDivPaste.bind(this);#i;#r="";#l=`${this.id}-editor`;#c;#d=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=it.prototype,e=n=>n.isEmpty(),s=Gt.TRANSLATE_SMALL,i=Gt.TRANSLATE_BIG;return B(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:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}]]))}static _type="freetext";static _editorType=N.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#i=t.color||it._defaultColor||I._defaultLineColor,this.#c=t.fontSize||it._defaultFontSize}static initialize(t,e){I.initialize(t,e,{strings:["pdfjs-free-text-default-content"]});const s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case D.FREETEXT_SIZE:it._defaultFontSize=e;break;case D.FREETEXT_COLOR:it._defaultColor=e;break}}updateParams(t,e){switch(t){case D.FREETEXT_SIZE:this.#f(e);break;case D.FREETEXT_COLOR:this.#h(e);break}}static get defaultPropertiesToUpdate(){return[[D.FREETEXT_SIZE,it._defaultFontSize],[D.FREETEXT_COLOR,it._defaultColor||I._defaultLineColor]]}get propertiesToUpdate(){return[[D.FREETEXT_SIZE,this.#c],[D.FREETEXT_COLOR,this.#i]]}#f(t){const e=i=>{this.editorDiv.style.fontSize=`calc(${i}px * var(--scale-factor))`,this.translate(0,-(i-this.#c)*this.parentScale),this.#c=i,this.#p()},s=this.#c;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:D.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#h(t){const e=i=>{this.#i=this.editorDiv.style.color=i},s=this.#i;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:D.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-it._internalPadding*t,-(it._internalPadding+this.#c)*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(N.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant");const t=this._uiManager._signal;this.editorDiv.addEventListener("keydown",this.#n,{signal:t}),this.editorDiv.addEventListener("focus",this.#e,{signal:t}),this.editorDiv.addEventListener("blur",this.#t,{signal:t}),this.editorDiv.addEventListener("input",this.#s,{signal:t}),this.editorDiv.addEventListener("paste",this.#o,{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.#l),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",this.#n),this.editorDiv.removeEventListener("focus",this.#e),this.editorDiv.removeEventListener("blur",this.#t),this.editorDiv.removeEventListener("input",this.#s),this.editorDiv.removeEventListener("paste",this.#o),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(){this.width||(this.enableEditMode(),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()}#a(){const t=[];this.editorDiv.normalize();for(const e of this.editorDiv.childNodes)t.push(it.#m(e));return t.join(`
6
6
  `)}#p(){const[t,e]=this.parentDimensions;let s;if(this.isAttachedToDOM)s=this.div.getBoundingClientRect();else{const{currentLayer:i,div:n}=this,r=n.style.display,a=n.classList.contains("hidden");n.classList.remove("hidden"),n.style.display="hidden",i.div.append(this.div),s=n.getBoundingClientRect(),n.remove(),n.style.display=r,n.classList.toggle("hidden",a)}this.rotation%180===this.parentRotation%180?(this.width=s.width/t,this.height=s.height/e):(this.width=s.height/t,this.height=s.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#r,e=this.#r=this.#a().trimEnd();if(t===e)return;const s=i=>{if(this.#r=i,!i){this.remove();return}this.#u(),this._uiManager.rebuild(this),this.#p()};this.addCommands({cmd:()=>{s(e)},undo:()=>{s(t)},mustExec:!1}),this.#p()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){it._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.#l),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text"),this.enableEditing(),I._l10nPromise.get("pdfjs-free-text-default-content").then(i=>this.editorDiv?.setAttribute("default-content",i)),this.editorDiv.contentEditable=!0;const{style:s}=this.editorDiv;if(s.fontSize=`calc(${this.#c}px * var(--scale-factor))`,s.color=this.#i,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Ne(this,this.div,["dblclick","keydown"]),this.width){const[i,n]=this.parentDimensions;if(this.annotationElementId){const{position:r}=this.#d;let[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);const[c,h]=this.pageDimensions,[d,u]=this.pageTranslation;let p,f;switch(this.rotation){case 0:p=t+(r[0]-d)/c,f=e+this.height-(r[1]-u)/h;break;case 90:p=t+(r[0]-d)/c,f=e-(r[1]-u)/h,[a,o]=[o,-a];break;case 180:p=t-this.width+(r[0]-d)/c,f=e-(r[1]-u)/h,[a,o]=[-a,-o];break;case 270:p=t+(r[0]-d-this.height*h)/c,f=e+(r[1]-u-this.width*c)/h,[a,o]=[-o,a];break}this.setAt(p*i,f*n,a,o)}else this.setAt(t*i,e*n,this.width*i,this.height*n);this.#u(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#m(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Fe,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:s}=e;if(s.length===1&&s[0]==="text/plain")return;t.preventDefault();const i=it.#g(e.getData("text")||"").replaceAll(Fe,`