@tom2012/cc-web 2026.5.6-a → 2026.5.8-a

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 (26) hide show
  1. package/backend/dist/memory-watcher.d.ts +4 -0
  2. package/backend/dist/memory-watcher.d.ts.map +1 -0
  3. package/backend/dist/memory-watcher.js +168 -0
  4. package/backend/dist/memory-watcher.js.map +1 -0
  5. package/backend/dist/terminal-manager.d.ts.map +1 -1
  6. package/backend/dist/terminal-manager.js +8 -0
  7. package/backend/dist/terminal-manager.js.map +1 -1
  8. package/frontend/dist/assets/{ChatOverlay-Cn2UDvPJ.js → ChatOverlay-Dewml63P.js} +1 -1
  9. package/frontend/dist/assets/{GraphPreview-ClFllaES.js → GraphPreview-DKqon8iY.js} +1 -1
  10. package/frontend/dist/assets/{MobilePage-C4plFLQR.js → MobilePage-0yihNWS5.js} +3 -3
  11. package/frontend/dist/assets/{OfficePreview-BUPUjmJy.js → OfficePreview-CLoz-Kzs.js} +2 -2
  12. package/frontend/dist/assets/{PdfPreview-qolp4W3P.js → PdfPreview-ceFK86bz.js} +1 -1
  13. package/frontend/dist/assets/{ProjectPage-UKMecARF.js → ProjectPage-Dx8ti9Xg.js} +3 -3
  14. package/frontend/dist/assets/{SettingsPage-BtaPOVzv.js → SettingsPage-DqXMFZN7.js} +1 -1
  15. package/frontend/dist/assets/{SkillHubPage-D27a49yH.js → SkillHubPage-0i_Vbges.js} +1 -1
  16. package/frontend/dist/assets/{chevron-down-Cft5PBzF.js → chevron-down-CabXIthZ.js} +1 -1
  17. package/frontend/dist/assets/{index-CgTG_5WK.js → index-DFmoROkt.js} +1 -1
  18. package/frontend/dist/assets/{index-0MbCUjQg.js → index-DKiLzICV.js} +1 -1
  19. package/frontend/dist/assets/{index-CihceaVm.js → index-PkEuCOb6.js} +2 -2
  20. package/frontend/dist/assets/{index-xa0BN4Wr.js → index-QPAdq047.js} +1 -1
  21. package/frontend/dist/assets/{jszip.min-DOkAo0GA.js → jszip.min-C5eqdtGO.js} +1 -1
  22. package/frontend/dist/assets/pdf.worker.min-qwK7q_zL.mjs +28 -0
  23. package/frontend/dist/assets/{search-5tU7yM2g.js → search-CO9hGSbE.js} +1 -1
  24. package/frontend/dist/index.html +1 -1
  25. package/package.json +1 -1
  26. package/frontend/dist/assets/pdf.worker.min-iDqQPrd3.mjs +0 -31
@@ -1 +1 @@
1
- var t,e,i,s,n,r,a,o,l,h,c,d,u,p,g,f,m,v,w,b,y,A,_,x,k,S,M,E,C,T,P,D,R,I,L,F,N,W,B,O,U,H,$,j,z,V,G,q,X,Y,K,Q,J,Z,tt,et,it,st,nt,rt,at,ot,lt,ht,ct,dt,ut,pt,gt,ft,mt,vt,wt,bt,yt,At,_t,xt,kt,St,Mt,Et,Ct,Tt,Pt,Dt,Rt,It,Lt,Ft,Nt,Wt,Bt,Ot,Ut,Ht,$t,jt,zt,Vt,Gt,qt,Xt,Yt,Kt,Qt,Jt,Zt,te,ee,ie,se,ne,re,ae,oe,le,he,ce,de,ue,pe,ge,fe,me,ve,we,be,ye,Ae,_e,xe,ke,Se,Me,Ee,Ce,Te,Pe,De,Re,Ie,Le,Fe,Ne,We,Be,Oe,Ue,He,$e,je,ze,Ve,Ge,qe,Xe,Ye,Ke,Qe,Je,Ze,ti,ei,ii,si,ni,ri,ai,oi,li,hi,ci,di,ui,pi,gi,fi,mi,vi,wi,bi,yi,Ai,_i,xi,ki,Si,Mi,Ei,Ci,Ti,Pi,Di,Ri,Ii,Li,Fi,Ni,Wi,Bi,Oi,Ui,Hi,$i,ji,zi,Vi,Gi,qi,Xi,Yi,Ki,Qi,Ji,Zi,ts,es,is,ss,ns,rs,as,os,ls,hs,cs,ds,us,ps,gs,fs,ms,vs,ws,bs,ys,As,_s,xs,ks,Ss,Ms,Es,Cs,Ts,Ps,Ds,Rs,Is,Ls,Fs,Ns,Ws,Bs,Os,Us,Hs,$s,js,zs,Vs,Gs,qs,Xs,Ys,Ks,Qs,Js,Zs,tn,en,sn,nn,rn,an,on,ln,hn,cn,dn,un,pn,gn,fn,mn,vn,wn,bn,yn,An,_n,xn,kn,Sn,Mn,En,Cn,Tn,Pn,Dn,Rn,In,Ln,Fn,Nn,Wn,Bn,On,Un,Hn,$n,jn,zn,Vn,Gn,qn,Xn,Yn,Kn,Qn,Jn,Zn,tr,er,ir,sr,nr,rr,ar,or,lr,hr,cr,dr,ur,pr,gr,fr,mr,vr,wr,br,yr,Ar,_r,xr,kr,Sr,Mr,Er,Cr,Tr,Pr,Dr,Rr,Ir,Lr,Fr,Nr,Wr,Br,Or,Ur,Hr,$r,jr,zr,Vr,Gr,qr,Xr,Yr,Kr,Qr,Jr,Zr,ta,ea,ia,sa,na,ra,aa,oa,la,ha,ca,da,ua,pa,ga,fa,ma,va,wa,ba,ya,Aa,_a,xa,ka,Sa,Ma,Ea,Ca,Ta,Pa,Da,Ra,Ia,La,Fa,Na,Wa,Ba,Oa,Ua,Ha,$a,ja,za,Va,Ga,qa,Xa,Ya,Ka,Qa,Ja,Za,to,eo,io,so,no,ro,ao,oo,lo,ho,co,uo,po,go,fo,mo,vo,wo,bo,yo,Ao,_o,xo,ko,So,Mo,Eo,Co,To,Po,Do,Ro,Io,Lo,Fo,No,Wo,Bo,Oo,Uo,Ho,$o,jo,zo,Vo,Go,qo,Xo,Yo,Ko,Qo,Jo,Zo,tl,el,il,sl,nl,rl,al,ol,ll,hl,cl,dl,ul,pl,gl,fl,ml,vl,wl,bl,yl,Al,_l,xl,kl,Sl,Ml,El,Cl,Tl,Pl,Dl,Rl,Il,Ll,Fl,Nl,Wl,Bl,Ol,Ul,Hl,$l,jl,zl,Vl,Gl,ql,Xl,Yl,Kl,Ql,Jl,Zl,th,eh,ih,sh,nh,rh,ah,oh,lh,hh,ch,dh,uh,ph,gh,fh,mh,vh,wh,bh,yh,Ah,_h,xh,kh,Sh,Mh,Eh,Ch,Th,Ph,Dh,Rh,Ih,Lh,Fh,Nh,Wh,Bh,Oh,Uh,Hh,$h,jh,zh,Vh,Gh,qh,Xh,Yh,Kh,Qh,Jh,Zh,tc,ec,ic,sc,nc,rc,ac,oc,lc,hc,cc,dc,uc,pc,gc,fc,mc,vc,wc,bc,yc,Ac,_c,xc,kc,Sc,Mc,Ec,Cc,Tc,Pc,Dc,Rc,Ic,Lc,Fc,Nc,Wc,Bc,Oc,Uc,Hc,$c,jc,zc,Vc,Gc,qc,Xc,Yc,Kc,Qc,Jc,Zc,td,ed,id,sd,nd,rd,ad,od,ld,hd,cd,dd,ud,pd,gd,fd,md,vd,wd,bd,yd,Ad,_d,xd,kd,Sd,Md,Ed,Cd,Td,Pd,Dd,Rd,Id,Ld,Fd,Nd,Wd,Bd,Od,Ud,Hd=Object.defineProperty,$d=t=>{throw TypeError(t)},jd=(t,e,i)=>((t,e,i)=>e in t?Hd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i),zd=(t,e,i)=>e.has(t)||$d("Cannot "+i),Vd=(t,e,i)=>(zd(t,e,"read from private field"),i?i.call(t):e.get(t)),Gd=(t,e,i)=>e.has(t)?$d("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),qd=(t,e,i,s)=>(zd(t,e,"write to private field"),s?s.call(t,i):e.set(t,i),i),Xd=(t,e,i)=>(zd(t,e,"access private method"),i),Yd=(t,e,i,s)=>({set _(s){qd(t,e,s,i)},get _(){return Vd(t,e,s)}});import{bD as Kd,r as Qd,j as Jd,bL as Zd,g as tu,f as eu}from"./index-CihceaVm.js";const iu=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),su=[.001,0,0,.001,0,0],nu=1.35,ru=1,au=2,ou=4,lu=16,hu=32,cu=64,du=128,uu=256,pu={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},gu="pdfjs_internal_editor_",fu={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},mu={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_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},vu={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},wu=0,bu=1,yu=2,Au=3,_u=3,xu=4,ku={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Su={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},Mu=1,Eu=2,Cu=3,Tu=4,Pu=5,Du={ERRORS:0,WARNINGS:1,INFOS:5},Ru={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},Iu=0,Lu=1,Fu=2,Nu=3,Wu={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Bu=Du.WARNINGS;function Ou(){return Bu}function Uu(t){Bu>=Du.INFOS&&console.info(`Info: ${t}`)}function Hu(t){Bu>=Du.WARNINGS&&console.warn(`Warning: ${t}`)}function $u(t){throw new Error(t)}function ju(t,e){t||$u(e)}function zu(t,e=null,i=null){if(!t)return null;if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);(null==e?void 0:e.length)>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch{}}const s=e?URL.parse(t,e):URL.parse(t);return function(t){switch(null==t?void 0:t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s)?s:null}function Vu(t,e,i=!1){const s=URL.parse(t);return s?(s.hash=e,s.href):i&&zu(t,"http://example.com")?t.split("#",1)[0]+""+(e?`#${e}`:""):""}function Gu(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}const qu=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class Xu extends qu{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Yu extends qu{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Ku extends qu{constructor(t){super(t,"InvalidPDFException")}}class Qu extends qu{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}}class Ju extends qu{constructor(t){super(t,"FormatError")}}class Zu extends qu{constructor(t){super(t,"AbortException")}}function tp(t){"object"==typeof t&&void 0!==(null==t?void 0:t.length)||$u("Invalid argument for bytesToString");const e=t.length,i=8192;if(e<i)return String.fromCharCode.apply(null,t);const s=[];for(let n=0;n<e;n+=i){const r=Math.min(n+i,e),a=t.subarray(n,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function ep(t){"string"!=typeof t&&$u("Invalid argument for stringToBytes");const e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}class ip{static get isLittleEndian(){return Gu(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return Gu(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return Gu(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return Gu(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){const{platform:t,userAgent:e}=navigator;return Gu(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){var t,e;return Gu(this,"isCSSRoundSupported",null==(e=null==(t=globalThis.CSS)?void 0:t.supports)?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const sp=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));class np{static makeHexColor(t,e,i){return`#${sp[t]}${sp[e]}${sp[i]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,i=0){const s=t[i],n=t[i+1];t[i]=s*e[0]+n*e[2]+e[4],t[i+1]=s*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){const s=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5];for(let h=0;h<6;h+=2){const e=t[i+h],c=t[i+h+1];t[i+h]=e*s+c*r+o,t[i+h+1]=e*n+c*a+l}}static applyInverseTransform(t,e){const i=t[0],s=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-s*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-i*e[1]+s*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,i){const s=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5],h=t[0],c=t[1],d=t[2],u=t[3];let p=s*h+o,g=p,f=s*d+o,m=f,v=a*c+l,w=v,b=a*u+l,y=b;if(0!==n||0!==r){const t=n*h,e=n*d,i=r*c,s=r*u;p+=i,m+=i,f+=s,g+=s,v+=t,y+=t,b+=e,w+=e}i[0]=Math.min(i[0],p,f,g,m),i[1]=Math.min(i[1],v,b,w,y),i[2]=Math.max(i[2],p,f,g,m),i[3]=Math.max(i[3],v,b,w,y)}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){const i=t[0],s=t[1],n=t[2],r=t[3],a=i**2+s**2,o=i*n+s*r,l=n**2+r**2,h=(a+l)/2,c=Math.sqrt(h**2-(a*l-o**2));e[0]=Math.sqrt(h+c||1),e[1]=Math.sqrt(h-c||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[i,n,s,r]}static pointBoundingBox(t,e,i){i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],t),i[3]=Math.max(i[3],e)}static rectBoundingBox(t,e,i,s,n){n[0]=Math.min(n[0],t,i),n[1]=Math.min(n[1],e,s),n[2]=Math.max(n[2],t,i),n[3]=Math.max(n[3],e,s)}static bezierBoundingBox(e,s,n,r,a,o,l,h,c){c[0]=Math.min(c[0],e,l),c[1]=Math.min(c[1],s,h),c[2]=Math.max(c[2],e,l),c[3]=Math.max(c[3],s,h),Xd(this,t,i).call(this,e,n,a,l,s,r,o,h,3*(3*(n-a)-e+l),6*(e-2*n+a),3*(n-e),c),Xd(this,t,i).call(this,e,n,a,l,s,r,o,h,3*(3*(r-o)-s+h),6*(s-2*r+o),3*(r-s),c)}}t=new WeakSet,e=function(t,e,i,s,n,r,a,o,l,h){if(l<=0||l>=1)return;const c=1-l,d=l*l,u=d*l,p=c*(c*(c*t+3*l*e)+3*d*i)+u*s,g=c*(c*(c*n+3*l*r)+3*d*a)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)},i=function(i,s,n,r,a,o,l,h,c,d,u,p){if(Math.abs(c)<1e-12)return void(Math.abs(d)>=1e-12&&Xd(this,t,e).call(this,i,s,n,r,a,o,l,h,-u/d,p));const g=d**2-4*u*c;if(g<0)return;const f=Math.sqrt(g),m=2*c;Xd(this,t,e).call(this,i,s,n,r,a,o,l,h,(-d+f)/m,p),Xd(this,t,e).call(this,i,s,n,r,a,o,l,h,(-d-f)/m,p)},Gd(np,t);let rp=null,ap=null;function op(t){return rp||(rp=/([\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,ap=new Map([["ſt","ſt"]])),t.replaceAll(rp,(t,e,i)=>e?e.normalize("NFKC"):ap.get(i))}function lp(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),tp(t)}const hp="pdfjs_internal_id_";function cp(t,e,i){return Math.min(Math.max(t,e),i)}function dp(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(tp(t))}"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise(i=>{i(t(...e))})}),"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(t){return t.reduce((t,e)=>t+e,0)});class up{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};return function t(i){var s;if(!i)return;let n=null;const r=i.name;if("#text"===r)n=i.value;else{if(!up.shouldBuildText(r))return;(null==(s=null==i?void 0:i.attributes)?void 0:s.textContent)?n=i.attributes.textContent:i.value&&(n=i.value)}if(null!==n&&e.push({str:n}),i.children)for(const e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}class pp{static setupStorage(t,e,i,s,n){const r=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==r.value&&(t.textContent=r.value),"print"===n)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})});break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(r.value===i.attributes.xfaOn?t.setAttribute("checked",!0):r.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})})}else{if(null!==r.value&&t.setAttribute("value",r.value),"print"===n)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})})}break;case"select":if(null!==r.value){t.setAttribute("value",r.value);for(const t of i.children)t.attributes.value===r.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",t=>{const i=t.target.options,n=-1===i.selectedIndex?"":i[i.selectedIndex].value;s.setValue(e,{value:n})})}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;"radio"===r.type&&(r.name=`${r.name}-${s}`);for(const[o,l]of Object.entries(r))if(null!=l)switch(o){case"class":l.length&&t.setAttribute(o,l.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",l);break;case"style":Object.assign(t.style,l);break;case"textContent":t.textContent=l;break;default:(!a||"href"!==o&&"newWindow"!==o)&&t.setAttribute(o,l)}a&&n.addLinkAttributes(t,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(t,r.dataId,e,i)}static render(t){var e,i;const s=t.annotationStorage,n=t.linkService,r=t.xfaHtml,a=t.intent||"display",o=document.createElement(r.name);r.attributes&&this.setAttributes({html:o,element:r,intent:a,linkService:n});const l="richText"!==a,h=t.div;if(h.append(o),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;h.style.transform=e}l&&h.setAttribute("class","xfaLayer xfaFont");const c=[];if(0===r.children.length){if(r.value){const t=document.createTextNode(r.value);o.append(t),l&&up.shouldBuildText(r.name)&&c.push(t)}return{textDivs:c}}const d=[[r,-1,o]];for(;d.length>0;){const[t,r,o]=d.at(-1);if(r+1===t.children.length){d.pop();continue}const h=t.children[++d.at(-1)[1]];if(null===h)continue;const{name:u}=h;if("#text"===u){const t=document.createTextNode(h.value);c.push(t),o.append(t);continue}const p=(null==(e=null==h?void 0:h.attributes)?void 0:e.xmlns)?document.createElementNS(h.attributes.xmlns,u):document.createElement(u);if(o.append(p),h.attributes&&this.setAttributes({html:p,element:h,storage:s,intent:a,linkService:n}),(null==(i=h.children)?void 0:i.length)>0)d.push([h,-1,p]);else if(h.value){const t=document.createTextNode(h.value);l&&up.shouldBuildText(u)&&c.push(t),p.append(t)}}for(const u of h.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))u.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 gp="http://www.w3.org/2000/svg",fp=class{};jd(fp,"CSS",96),jd(fp,"PDF",72),jd(fp,"PDF_TO_CSS_UNITS",fp.CSS/fp.PDF);let mp=fp;async function vp(t,e="text"){if(Sp(t,document.baseURI)){const i=await fetch(t);if(!i.ok)throw new Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise((i,s)=>{const n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType=e,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE)if(200!==n.status&&0!==n.status)s(new Error(n.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void i(n.response)}i(n.responseText)}},n.send(null)})}class wp{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=n,this.offsetY=r,i*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let h,c,d,u,p,g,f,m;switch((s%=360)<0&&(s+=360),s){case 180:h=-1,c=0,d=0,u=1;break;case 90:h=0,c=1,d=1,u=0;break;case 270:h=0,c=-1,d=-1,u=0;break;case 0:h=1,c=0,d=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(d=-d,u=-u),0===h?(p=Math.abs(l-t[1])*i+n,g=Math.abs(o-t[0])*i+r,f=(t[3]-t[1])*i,m=(t[2]-t[0])*i):(p=Math.abs(o-t[0])*i+n,g=Math.abs(l-t[1])*i+r,f=(t[2]-t[0])*i,m=(t[3]-t[1])*i),this.transform=[h*i,c*i,d*i,u*i,p-h*i*o-d*i*l,g-c*i*o-u*i*l],this.width=f,this.height=m}get rawDims(){const t=this.viewBox;return Gu(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new wp({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){const i=[t,e];return np.applyTransform(i,this.transform),i}convertToViewportRectangle(t){const e=[t[0],t[1]];np.applyTransform(e,this.transform);const i=[t[2],t[3]];return np.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){const i=[t,e];return np.applyInverseTransform(i,this.transform),i}}class bp extends qu{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function yp(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function Ap(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function _p(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function xp(t,e="document.pdf"){if("string"!=typeof t)return e;if(yp(t))return Hu('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const i=(t=>{try{return new URL(t)}catch{try{return new URL(decodeURIComponent(t))}catch{try{return new URL(t,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(t),"https://foo.bar")}catch{return null}}}}})(t);if(!i)return e;const s=t=>{try{let e=decodeURIComponent(t);return e.includes("/")?(e=e.split("/").at(-1),e.test(/^\.pdf$/i)?e:t):e}catch{return t}},n=/\.pdf$/i,r=i.pathname.split("/").at(-1);if(n.test(r))return s(r);if(i.searchParams.size>0){const t=Array.from(i.searchParams.values()).reverse();for(const i of t)if(n.test(i))return s(i);const e=Array.from(i.searchParams.keys()).reverse();for(const i of e)if(n.test(i))return s(i)}if(i.hash){const t=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(i.hash);if(t)return s(t[0])}return e}class kp{constructor(){jd(this,"started",Object.create(null)),jd(this,"times",[])}time(t){t in this.started&&Hu(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||Hu(`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:i}of this.times)e=Math.max(i.length,e);for(const{name:i,start:s,end:n}of this.times)t.push(`${i.padEnd(e)} ${n-s}ms\n`);return t.join("")}}function Sp(t,e){const i=e?URL.parse(t,e):URL.parse(t);return"http:"===(null==i?void 0:i.protocol)||"https:"===(null==i?void 0:i.protocol)}function Mp(t){t.preventDefault()}function Ep(t){t.preventDefault(),t.stopPropagation()}class Cp{static toDateObject(t){if(t instanceof Date)return t;if(!t||"string"!=typeof t)return null;Vd(this,s)||qd(this,s,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=Vd(this,s).exec(t);if(!e)return null;const i=parseInt(e[1],10);let n=parseInt(e[2],10);n=n>=1&&n<=12?n-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(e[6],10);l=l>=0&&l<=59?l:0;const h=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,"-"===h?(a+=c,o+=d):"+"===h&&(a-=c,o-=d),new Date(Date.UTC(i,n,r,a,o,l))}}function Tp(t,{scale:e=1,rotation:i=0}){const{width:s,height:n}=t.attributes.style,r=[0,0,parseInt(s),parseInt(n)];return new wp({viewBox:r,userUnit:1,scale:e,rotation:i})}function Pp(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(t=>parseInt(t)):t.startsWith("rgba(")?t.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(Hu(`Not a valid color format: "${t}"`),[0,0,0])}function Dp(t){const{a:e,b:i,c:s,d:n,e:r,f:a}=t.getTransform();return[e,i,s,n,r,a]}function Rp(t){const{a:e,b:i,c:s,d:n,e:r,f:a}=t.getTransform().invertSelf();return[e,i,s,n,r,a]}function Ip(t,e,i=!1,s=!0){if(e instanceof wp){const{pageWidth:s,pageHeight:n}=e.rawDims,{style:r}=t,a=ip.isCSSRoundSupported,o=`var(--total-scale-factor) * ${s}px`,l=`var(--total-scale-factor) * ${n}px`,h=a?`round(down, ${o}, var(--scale-round-x))`:`calc(${o})`,c=a?`round(down, ${l}, var(--scale-round-y))`:`calc(${l})`;i&&e.rotation%180!=0?(r.width=c,r.height=h):(r.width=h,r.height=c)}s&&t.setAttribute("data-main-rotation",e.rotation)}s=new WeakMap,Gd(Cp,s);class Lp{constructor(){const{pixelRatio:t}=Lp;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,i,s,n=-1){let r=1/0,a=1/0,o=1/0;(i=Lp.capPixels(i,n))>0&&(r=Math.sqrt(i/(t*e))),-1!==s&&(a=s/t,o=s/e);const l=Math.min(r,a,o);return(this.sx>l||this.sy>l)&&(this.sx=l,this.sy=l,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,i):i}return t}}const Fp=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class Np{static get isDarkMode(){var t;return Gu(this,"isDarkMode",!!(null==(t=null==window?void 0:window.matchMedia)?void 0:t.call(window,"(prefers-color-scheme: dark)").matches))}}class Wp{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);const{color:i}=window.getComputedStyle(t);return t.remove(),Gu(this,"commentForegroundColor",Pp(i))}}function Bp(t,e,i,s){const n=255*(1-(s=Math.min(Math.max(s??1,0),1)));return[t=Math.round(t*s+n),e=Math.round(e*s+n),i=Math.round(i*s+n)]}function Op(t,e){const i=t[0]/255,s=t[1]/255,n=t[2]/255,r=Math.max(i,s,n),a=Math.min(i,s,n),o=(r+a)/2;if(r===a)e[0]=e[1]=0;else{const t=r-a;switch(e[1]=o<.5?t/(r+a):t/(2-r-a),r){case i:e[0]=60*((s-n)/t+(s<n?6:0));break;case s:e[0]=60*((n-i)/t+2);break;case n:e[0]=60*((i-s)/t+4)}}e[2]=o}function Up(t,e){const i=t[0],s=t[1],n=t[2],r=(1-Math.abs(2*n-1))*s,a=r*(1-Math.abs(i/60%2-1)),o=n-r/2;switch(Math.floor(i/60)){case 0:e[0]=r+o,e[1]=a+o,e[2]=o;break;case 1:e[0]=a+o,e[1]=r+o,e[2]=o;break;case 2:e[0]=o,e[1]=r+o,e[2]=a+o;break;case 3:e[0]=o,e[1]=a+o,e[2]=r+o;break;case 4:e[0]=a+o,e[1]=o,e[2]=r+o;break;case 5:case 6:e[0]=r+o,e[1]=o,e[2]=a+o}}function Hp(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function $p(t,e,i){Up(t,i),i.map(Hp);const s=.2126*i[0]+.7152*i[1]+.0722*i[2];Up(e,i),i.map(Hp);const n=.2126*i[0]+.7152*i[1]+.0722*i[2];return s>n?(s+.05)/(n+.05):(n+.05)/(s+.05)}const jp=new Map;function zp(t,e){const i=t[0]+256*t[1]+65536*t[2]+16777216*e[0]+4294967296*e[1]+1099511627776*e[2];let s=jp.get(i);if(s)return s;const n=new Float32Array(9),r=n.subarray(0,3),a=n.subarray(3,6);Op(t,a);const o=n.subarray(6,9);Op(e,o);const l=o[2]<.5,h=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),$p(a,o,r)<h){let t,e;l?(t=a[2],e=1):(t=0,e=a[2]);const i=.005;for(;e-t>i;){const i=a[2]=(t+e)/2;l===$p(a,o,r)<h?t=i:e=i}a[2]=l?e:t}return Up(a,r),s=np.makeHexColor(Math.round(255*r[0]),Math.round(255*r[1]),Math.round(255*r[2])),jp.set(i,s),s}function Vp({html:t,dir:e,className:i},s){const n=document.createDocumentFragment();if("string"==typeof t){const i=document.createElement("p");i.dir=e||"auto";const s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t){const n=s[t];i.append(document.createTextNode(n)),t<e-1&&i.append(document.createElement("br"))}n.append(i)}else pp.render({xfaHtml:t,div:n,intent:"richText"});n.firstChild.classList.add("richText",i),s.append(n)}const Gp=class t{constructor(e){Gd(this,f),Gd(this,n,null),Gd(this,r,null),Gd(this,a),Gd(this,o,null),Gd(this,l,null),Gd(this,h,null),Gd(this,c,null),Gd(this,d,null),qd(this,a,e),Vd(t,u)||qd(t,u,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const e=qd(this,n,document.createElement("div"));e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const i=Vd(this,a)._uiManager._signal;i instanceof AbortSignal&&!i.aborted&&(e.addEventListener("contextmenu",Mp,{signal:i}),e.addEventListener("pointerdown",Xd(t,p,g),{signal:i}));const s=qd(this,o,document.createElement("div"));s.className="buttons",e.append(s);const r=Vd(this,a).toolbarPosition;if(r){const{style:t}=e,i="ltr"===Vd(this,a)._uiManager.direction?1-r[0]:r[0];t.insetInlineEnd=100*i+"%",t.top=`calc(${100*r[1]}% + var(--editor-toolbar-vert-offset))`}return e}get div(){return Vd(this,n)}hide(){var t;Vd(this,n).classList.add("hidden"),null==(t=Vd(this,r))||t.hideDropdown()}show(){var t,e;Vd(this,n).classList.remove("hidden"),null==(t=Vd(this,l))||t.shown(),null==(e=Vd(this,h))||e.shown()}addDeleteButton(){const{editorType:e,_uiManager:i}=Vd(this,a),s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",Vd(t,u)[e]),Xd(this,f,w).call(this,s)&&s.addEventListener("click",t=>{i.delete()},{signal:i._signal}),Vd(this,o).append(s)}async addAltText(t){const e=await t.render();Xd(this,f,w).call(this,e),Vd(this,o).append(e,Vd(this,f,b)),qd(this,l,t)}addComment(t,e=null){if(Vd(this,h))return;const i=t.renderForToolbar();if(!i)return;Xd(this,f,w).call(this,i);const s=qd(this,c,Vd(this,f,b));e?(Vd(this,o).insertBefore(i,e),Vd(this,o).insertBefore(s,e)):Vd(this,o).append(i,s),qd(this,h,t),t.toolbar=this}addColorPicker(t){if(Vd(this,r))return;qd(this,r,t);const e=t.renderButton();Xd(this,f,w).call(this,e),Vd(this,o).append(e,Vd(this,f,b))}async addEditSignatureButton(t){const e=qd(this,d,await t.renderEditButton(Vd(this,a)));Xd(this,f,w).call(this,e),Vd(this,o).append(e,Vd(this,f,b))}removeButton(t){var e,i;if("comment"===t)null==(e=Vd(this,h))||e.removeToolbarCommentButton(),qd(this,h,null),null==(i=Vd(this,c))||i.remove(),qd(this,c,null)}async addButton(t,e){switch(t){case"colorPicker":this.addColorPicker(e);break;case"altText":await this.addAltText(e);break;case"editSignature":await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":this.addComment(e)}}async addButtonBefore(t,e,i){const s=Vd(this,o).querySelector(i);s&&"comment"===t&&this.addComment(e,s)}updateEditSignatureButton(t){Vd(this,d)&&(Vd(this,d).title=t)}remove(){var t;Vd(this,n).remove(),null==(t=Vd(this,r))||t.destroy(),qd(this,r,null)}};n=new WeakMap,r=new WeakMap,a=new WeakMap,o=new WeakMap,l=new WeakMap,h=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakMap,p=new WeakSet,g=function(t){t.stopPropagation()},f=new WeakSet,m=function(t){Vd(this,a)._focusEventsAllowed=!1,Ep(t)},v=function(t){Vd(this,a)._focusEventsAllowed=!0,Ep(t)},w=function(t){const e=Vd(this,a)._uiManager._signal;return e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("focusin",Xd(this,f,m).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",Xd(this,f,v).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Mp,{signal:e}),!0)},b=function(){const t=document.createElement("div");return t.className="divider",t},Gd(Gp,p),Gd(Gp,u,null);let qp=Gp;class Xp{constructor(t){Gd(this,x),Gd(this,y,null),Gd(this,A,null),Gd(this,_),qd(this,_,t)}show(t,e,i){const[s,n]=Xd(this,x,S).call(this,e,i),{style:r}=Vd(this,A)||qd(this,A,Xd(this,x,k).call(this));t.append(Vd(this,A)),r.insetInlineEnd=100*s+"%",r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){Vd(this,A).remove()}}function Yp(t,e,i){for(const s of i)e.addEventListener(s,t[s].bind(t))}y=new WeakMap,A=new WeakMap,_=new WeakMap,x=new WeakSet,k=function(){const t=qd(this,A,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar");const e=Vd(this,_)._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",Mp,{signal:e});const i=qd(this,y,document.createElement("div"));return i.className="buttons",t.append(i),Vd(this,_).hasCommentManager()&&Xd(this,x,M).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{Vd(this,_).commentSelection("floating_button")}),Xd(this,x,M).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{Vd(this,_).highlightSelection("floating_button")}),t},S=function(t,e){let i=0,s=0;for(const n of t){const t=n.y+n.height;if(t<i)continue;const r=n.x+(e?n.width:0);t>i?(s=r,i=t):e?r>s&&(s=r):r<s&&(s=r)}return[e?1-s:s,i]},M=function(t,e,i,s){const n=document.createElement("button");n.classList.add("basic",t),n.tabIndex=0,n.setAttribute("data-l10n-id",e);const r=document.createElement("span");n.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id",i);const a=Vd(this,_)._signal;a instanceof AbortSignal&&!a.aborted&&(n.addEventListener("contextmenu",Mp,{signal:a}),n.addEventListener("click",s,{signal:a})),Vd(this,y).append(n)};class Kp{constructor(){Gd(this,E,0)}get id(){return`${gu}${Yd(this,E)._++}`}}E=new WeakMap;const Qp=class{constructor(){Gd(this,D),Gd(this,C,lp()),Gd(this,T,0),Gd(this,P,null)}static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>';return Gu(this,"_isSVGFittingCanvas",e.decode().then(()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0])))}async getFromFile(t){const{lastModified:e,name:i,size:s,type:n}=t;return Xd(this,D,R).call(this,`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return Xd(this,D,R).call(this,t,t)}async getFromBlob(t,e){const i=await e;return Xd(this,D,R).call(this,t,i)}async getFromId(t){Vd(this,P)||qd(this,P,new Map);const e=Vd(this,P).get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){Vd(this,P)||qd(this,P,new Map);let i=Vd(this,P).get(t);if(null==i?void 0:i.bitmap)return i.refCounter+=1,i;const s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${Vd(this,C)}_${Yd(this,T)._++}`,refCounter:1,isSvg:!1},Vd(this,P).set(t,i),Vd(this,P).set(i.id,i),i}getSvgUrl(t){const e=Vd(this,P).get(t);return(null==e?void 0:e.isSvg)?e.svgUrl:null}deleteId(t){var e;Vd(this,P)||qd(this,P,new Map);const i=Vd(this,P).get(t);if(!i)return;if(i.refCounter-=1,0!==i.refCounter)return;const{bitmap:s}=i;if(!i.url&&!i.file){const t=new OffscreenCanvas(s.width,s.height);t.getContext("bitmaprenderer").transferFromImageBitmap(s),i.blobPromise=t.convertToBlob()}null==(e=s.close)||e.call(s),i.bitmap=null}isValidId(t){return t.startsWith(`image_${Vd(this,C)}_`)}};C=new WeakMap,T=new WeakMap,P=new WeakMap,D=new WeakSet,R=async function(t,e){Vd(this,P)||qd(this,P,new Map);let i=Vd(this,P).get(t);if(null===i)return null;if(null==i?void 0:i.bitmap)return i.refCounter+=1,i;try{let t;if(i||(i={bitmap:null,id:`image_${Vd(this,C)}_${Yd(this,T)._++}`,refCounter:0,isSvg:!1}),"string"==typeof e?(i.url=e,t=await vp(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=Qp._isSVGFittingCanvas,s=new FileReader,n=new Image,r=new Promise((t,r)=>{n.onload=()=>{i.bitmap=n,i.isSvg=!0,t()},s.onload=async()=>{const t=i.svgUrl=s.result;n.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},n.onerror=s.onerror=r});s.readAsDataURL(t),await r}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(s){Hu(s),i=null}return Vd(this,P).set(t,i),i&&Vd(this,P).set(i.id,i),i};let Jp=Qp;class Zp{constructor(t=128){Gd(this,I,[]),Gd(this,L,!1),Gd(this,F),Gd(this,N,-1),qd(this,F,t)}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(s&&t(),Vd(this,L))return;const o={cmd:t,undo:e,post:i,type:n};if(-1===Vd(this,N))return Vd(this,I).length>0&&(Vd(this,I).length=0),qd(this,N,0),void Vd(this,I).push(o);if(r&&Vd(this,I)[Vd(this,N)].type===n)return a&&(o.undo=Vd(this,I)[Vd(this,N)].undo),void(Vd(this,I)[Vd(this,N)]=o);const l=Vd(this,N)+1;l===Vd(this,F)?Vd(this,I).splice(0,1):(qd(this,N,l),l<Vd(this,I).length&&Vd(this,I).splice(l)),Vd(this,I).push(o)}undo(){if(-1===Vd(this,N))return;qd(this,L,!0);const{undo:t,post:e}=Vd(this,I)[Vd(this,N)];t(),null==e||e(),qd(this,L,!1),qd(this,N,Vd(this,N)-1)}redo(){if(Vd(this,N)<Vd(this,I).length-1){qd(this,N,Vd(this,N)+1),qd(this,L,!0);const{cmd:t,post:e}=Vd(this,I)[Vd(this,N)];t(),null==e||e(),qd(this,L,!1)}}hasSomethingToUndo(){return-1!==Vd(this,N)}hasSomethingToRedo(){return Vd(this,N)<Vd(this,I).length-1}cleanType(t){if(-1!==Vd(this,N)){for(let e=Vd(this,N);e>=0;e--)if(Vd(this,I)[e].type!==t)return Vd(this,I).splice(e+1,Vd(this,N)-e),void qd(this,N,e);Vd(this,I).length=0,qd(this,N,-1)}}destroy(){qd(this,I,null)}}I=new WeakMap,L=new WeakMap,F=new WeakMap,N=new WeakMap;class tg{constructor(t){Gd(this,W),this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=ip.platform;for(const[i,s,n={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const i=this.callbacks.get(Xd(this,W,B).call(this,e));if(!i)return;const{callback:s,options:{bubbles:n=!1,args:r=[],checker:a=null}}=i;a&&!a(t,e)||(s.bind(t,...r,e)(),n||Ep(e))}}W=new WeakSet,B=function(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};const eg=class t{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(const i of t.keys()){e.style.color=i;const s=window.getComputedStyle(e).color;t.set(i,Pp(s))}e.remove()}(t),Gu(this,"_colors",t)}convert(e){const i=Pp(e);if(!window.matchMedia("(forced-colors: active)").matches)return i;for(const[s,n]of this._colors)if(n.every((t,e)=>t===i[e]))return t._colorsMapping.get(s);return i}getHexCode(t){const e=this._colors.get(t);return e?np.makeHexColor(...e):t}};jd(eg,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let ig=eg;const sg=class t{constructor(t,e,i,s,n,r,a,o,l,h,c,d,u,p,g,f){Gd(this,Lt),Gd(this,O,new AbortController),Gd(this,U,null),Gd(this,H,null),Gd(this,$,new Map),Gd(this,j,new Map),Gd(this,z,null),Gd(this,V,null),Gd(this,G,null),Gd(this,q,new Zp),Gd(this,X,null),Gd(this,Y,null),Gd(this,K,null),Gd(this,Q,0),Gd(this,J,new Set),Gd(this,Z,null),Gd(this,tt,null),Gd(this,et,new Set),jd(this,"_editorUndoBar",null),Gd(this,it,!1),Gd(this,st,!1),Gd(this,nt,!1),Gd(this,rt,null),Gd(this,at,null),Gd(this,ot,null),Gd(this,lt,null),Gd(this,ht,!1),Gd(this,ct,null),Gd(this,dt,new Kp),Gd(this,ut,!1),Gd(this,pt,!1),Gd(this,gt,!1),Gd(this,ft,null),Gd(this,mt,null),Gd(this,vt,null),Gd(this,wt,null),Gd(this,bt,null),Gd(this,yt,fu.NONE),Gd(this,At,new Set),Gd(this,_t,null),Gd(this,xt,null),Gd(this,kt,null),Gd(this,St,null),Gd(this,Mt,null),Gd(this,Et,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),Gd(this,Ct,[0,0]),Gd(this,Tt,null),Gd(this,Pt,null),Gd(this,Dt,null),Gd(this,Rt,null),Gd(this,It,null);const m=this._signal=Vd(this,O).signal;qd(this,Pt,t),qd(this,Dt,e),qd(this,Rt,i),qd(this,z,s),qd(this,X,n),qd(this,xt,r),qd(this,Mt,o),this._eventBus=a,a._on("editingaction",this.onEditingAction.bind(this),{signal:m}),a._on("pagechanging",this.onPageChanging.bind(this),{signal:m}),a._on("scalechanging",this.onScaleChanging.bind(this),{signal:m}),a._on("rotationchanging",this.onRotationChanging.bind(this),{signal:m}),a._on("setpreference",this.onSetPreference.bind(this),{signal:m}),a._on("switchannotationeditorparams",t=>this.updateParams(t.type,t.value),{signal:m}),window.addEventListener("pointerdown",()=>{qd(this,pt,!0)},{capture:!0,signal:m}),window.addEventListener("pointerup",()=>{qd(this,pt,!1)},{capture:!0,signal:m}),Xd(this,Lt,Ut).call(this),Xd(this,Lt,qt).call(this),Xd(this,Lt,jt).call(this),qd(this,V,o.annotationStorage),qd(this,rt,o.filterFactory),qd(this,kt,l),qd(this,lt,h||null),qd(this,it,c),qd(this,st,d),qd(this,nt,u),qd(this,bt,p||null),this.viewParameters={realScale:mp.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=!1!==f,null==n||n.setSidebarUiManager(this)}static get _keyboardManager(){const e=t.prototype,i=t=>Vd(t,Pt).contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),s=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},n=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return Gu(this,"_keyboardManager",new tg([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],e.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:s}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&Vd(t,Pt).contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&Vd(t,Pt).contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-n,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-r,0],checker:i}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[n,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[r,0],checker:i}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-n],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-r],checker:i}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,n],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,r],checker:i}]]))}destroy(){var t,e,i,s,n,r,a,o,l;null==(t=Vd(this,It))||t.resolve(),qd(this,It,null),null==(e=Vd(this,O))||e.abort(),qd(this,O,null),this._signal=null;for(const h of Vd(this,j).values())h.destroy();Vd(this,j).clear(),Vd(this,$).clear(),Vd(this,et).clear(),null==(i=Vd(this,wt))||i.clear(),qd(this,U,null),Vd(this,At).clear(),Vd(this,q).destroy(),null==(s=Vd(this,z))||s.destroy(),null==(n=Vd(this,X))||n.destroy(),null==(r=Vd(this,xt))||r.destroy(),null==(a=Vd(this,ct))||a.hide(),qd(this,ct,null),null==(o=Vd(this,vt))||o.destroy(),qd(this,vt,null),qd(this,H,null),Vd(this,at)&&(clearTimeout(Vd(this,at)),qd(this,at,null)),Vd(this,Tt)&&(clearTimeout(Vd(this,Tt)),qd(this,Tt,null)),null==(l=this._editorUndoBar)||l.destroy(),qd(this,Mt,null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return Vd(this,bt)}get useNewAltTextFlow(){return Vd(this,st)}get useNewAltTextWhenAddingImage(){return Vd(this,nt)}get hcmFilter(){return Gu(this,"hcmFilter",Vd(this,kt)?Vd(this,rt).addHCMFilter(Vd(this,kt).foreground,Vd(this,kt).background):"none")}get direction(){return Gu(this,"direction",getComputedStyle(Vd(this,Pt)).direction)}get _highlightColors(){return Gu(this,"_highlightColors",Vd(this,lt)?new Map(Vd(this,lt).split(",").map(t=>((t=t.split("=").map(t=>t.trim()))[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return Gu(this,"highlightColors",null);const e=new Map,i=!!Vd(this,kt);for(const[s,n]of t){const t=s.endsWith("_HCM");i&&t?e.set(s.replace("_HCM",""),n):i||t||e.set(s,n)}return Gu(this,"highlightColors",e)}get highlightColorNames(){return Gu(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),qd(this,K,t)}setMainHighlightColorPicker(t){qd(this,vt,t)}editAltText(t,e=!1){var i;null==(i=Vd(this,z))||i.editAltText(this,t,e)}hasCommentManager(){return!!Vd(this,X)}editComment(t,e,i,s){var n;null==(n=Vd(this,X))||n.showDialog(this,t,e,i,s)}selectComment(t,e){const i=Vd(this,j).get(t),s=null==i?void 0:i.getEditorByUID(e);null==s||s.toggleComment(!0,!0)}updateComment(t){var e;null==(e=Vd(this,X))||e.updateComment(t.getData())}updatePopupColor(t){var e;null==(e=Vd(this,X))||e.updatePopupColor(t)}removeComment(t){var e;null==(e=Vd(this,X))||e.removeComments([t.uid])}toggleComment(t,e,i=void 0){var s;null==(s=Vd(this,X))||s.toggleCommentPopup(t,e,i)}makeCommentColor(t,e){var i;return t&&(null==(i=Vd(this,X))?void 0:i.makeCommentColor(t,e))||null}getCommentDialogElement(){var t;return(null==(t=Vd(this,X))?void 0:t.dialogElement)||null}async waitForEditorsRendered(t){if(Vd(this,j).has(t-1))return;const{resolve:e,promise:i}=Promise.withResolvers(),s=i=>{i.pageNumber===t&&(this._eventBus._off("editorsrendered",s),e())};this._eventBus.on("editorsrendered",s),await i}getSignature(t){var e;null==(e=Vd(this,xt))||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return Vd(this,xt)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){if("enableNewAltTextWhenAddingImage"===t)qd(this,nt,e)}onPageChanging({pageNumber:t}){qd(this,Q,t-1)}focusMainContainer(){Vd(this,Pt).focus()}findParent(t,e){for(const i of Vd(this,j).values()){const{x:s,y:n,width:r,height:a}=i.div.getBoundingClientRect();if(t>=s&&t<=s+r&&e>=n&&e<=n+a)return i}return null}disableUserSelect(t=!1){Vd(this,Dt).classList.toggle("noUserSelect",t)}addShouldRescale(t){Vd(this,et).add(t)}removeShouldRescale(t){Vd(this,et).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*mp.PDF_TO_CSS_UNITS;for(const i of Vd(this,et))i.onScaleChanging();null==(e=Vd(this,K))||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t="",e=!1){const i=document.getSelection();if(!i||i.isCollapsed)return;const{anchorNode:s,anchorOffset:n,focusNode:r,focusOffset:a}=i,o=i.toString(),l=Xd(this,Lt,Ft).call(this,i).closest(".textLayer"),h=this.getSelectionBoxes(l);if(!h)return;i.empty();const c=Xd(this,Lt,Nt).call(this,l),d=Vd(this,yt)===fu.NONE,u=()=>{const i=null==c?void 0:c.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:s,anchorOffset:n,focusNode:r,focusOffset:a,text:o});d&&this.showAllEditors("highlight",!0,!0),e&&(null==i||i.editComment())};d?this.switchToMode(fu.HIGHLIGHT,u):u()}commentSelection(t=""){this.highlightSelection(t,!0)}getAndRemoveDataFromAnnotationStorage(t){if(!Vd(this,V))return null;const e=`${gu}${t}`,i=Vd(this,V).getRawValue(e);return i&&Vd(this,V).remove(e),i}addToAnnotationStorage(t){t.isEmpty()||!Vd(this,V)||Vd(this,V).has(t.id)||Vd(this,V).setValue(t.id,t)}a11yAlert(t,e=null){const i=Vd(this,Rt);i&&(i.setAttribute("data-l10n-id",t),e?i.setAttribute("data-l10n-args",JSON.stringify(e)):i.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,Vd(this,ht)&&(qd(this,ht,!1),Xd(this,Lt,Ot).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of Vd(this,At))if(e.div.contains(t)){qd(this,mt,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!Vd(this,mt))return;const[t,e]=Vd(this,mt);qd(this,mt,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){Xd(this,Lt,jt).call(this),Xd(this,Lt,Vt).call(this)}removeEditListeners(){Xd(this,Lt,zt).call(this),Xd(this,Lt,Gt).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of Vd(this,tt))if(i.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const i of Vd(this,tt))if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){var e;if(t.preventDefault(),null==(e=Vd(this,U))||e.commitOrRemove(),!this.hasSelection)return;const i=[];for(const s of Vd(this,At)){const t=s.serialize(!0);t&&i.push(t)}0!==i.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(i))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const r of e.items)for(const t of Vd(this,tt))if(t.isHandlingMimeForPasting(r.type))return void t.paste(r,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(n){return void Hu(`paste: "${n.message}".`)}if(!Array.isArray(i))return;this.unselectAll();const s=this.currentLayer;try{const t=[];for(const r of i){const e=await s.deserialize(r);if(!e)return;t.push(e)}const e=()=>{for(const e of t)Xd(this,Lt,Jt).call(this,e);Xd(this,Lt,ee).call(this,t)},n=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:n,mustExec:!0})}catch(n){Hu(`paste: "${n.message}".`)}}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0),Vd(this,yt)===fu.NONE||this.isEditorHandlingKeyboard||t._keyboardManager.exec(this,e)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,Vd(this,ht)&&(qd(this,ht,!1),Xd(this,Lt,Ot).call(this,"main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu")}}setEditingState(t){t?(Xd(this,Lt,Ht).call(this),Xd(this,Lt,Vt).call(this),Xd(this,Lt,Xt).call(this,{isEditing:Vd(this,yt)!==fu.NONE,isEmpty:Xd(this,Lt,te).call(this),hasSomethingToUndo:Vd(this,q).hasSomethingToUndo(),hasSomethingToRedo:Vd(this,q).hasSomethingToRedo(),hasSelectedEditor:!1})):(Xd(this,Lt,$t).call(this),Xd(this,Lt,Gt).call(this),Xd(this,Lt,Xt).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!Vd(this,tt)){qd(this,tt,t);for(const t of Vd(this,tt))Xd(this,Lt,Yt).call(this,t.defaultPropertiesToUpdate)}}getId(){return Vd(this,dt).id}get currentLayer(){return Vd(this,j).get(Vd(this,Q))}getLayer(t){return Vd(this,j).get(t)}get currentPageIndex(){return Vd(this,Q)}addLayer(t){Vd(this,j).set(t.pageIndex,t),Vd(this,ut)?t.enable():t.disable()}removeLayer(t){Vd(this,j).delete(t.pageIndex)}async updateMode(t,e=null,i=!1,s=!1,n=!1){var r,a,o,l,h,c;if(Vd(this,yt)!==t&&(!Vd(this,It)||(await Vd(this,It).promise,Vd(this,It)))){if(qd(this,It,Promise.withResolvers()),null==(r=Vd(this,K))||r.commitOrRemove(),Vd(this,yt)===fu.POPUP&&(null==(a=Vd(this,X))||a.hideSidebar()),null==(o=Vd(this,X))||o.destroyPopup(),qd(this,yt,t),t===fu.NONE){this.setEditingState(!1),Xd(this,Lt,Qt).call(this);for(const t of Vd(this,$).values())t.hideStandaloneCommentButton();return null==(l=this._editorUndoBar)||l.hide(),this.toggleComment(null),void Vd(this,It).resolve()}for(const t of Vd(this,$).values())t.addStandaloneCommentButton();t===fu.SIGNATURE&&await(null==(h=Vd(this,xt))?void 0:h.loadSignatures()),this.setEditingState(!0),await Xd(this,Lt,Kt).call(this),this.unselectAll();for(const e of Vd(this,j).values())e.updateMode(t);if(t===fu.POPUP){Vd(this,H)||qd(this,H,await Vd(this,Mt).getAnnotationsByType(new Set(Vd(this,tt).map(t=>t._editorType))));const t=new Set,e=[];for(const i of Vd(this,$).values()){const{annotationElementId:s,hasComment:n,deleted:r}=i;s&&t.add(s),n&&!r&&e.push(i.getData())}for(const i of Vd(this,H)){const{id:s,popupRef:n,contentsObj:r}=i;n&&(null==r?void 0:r.str)&&!t.has(s)&&!Vd(this,J).has(s)&&e.push(i)}null==(c=Vd(this,X))||c.showSidebar(e)}if(!e)return i&&this.addNewEditorFromKeyboard(),void Vd(this,It).resolve();for(const t of Vd(this,$).values())t.uid===e?(this.setSelected(t),n?t.editComment():s?t.enterInEditMode():t.focus()):t.unselect();Vd(this,It).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==Vd(this,yt)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(Vd(this,tt)){switch(t){case mu.CREATE:return void this.currentLayer.addNewEditor(e);case mu.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(Vd(this,St)||qd(this,St,new Map)).set(t,e),this.showAllEditors("highlight",e)}if(this.hasSelection)for(const i of Vd(this,At))i.updateParams(t,e);else for(const i of Vd(this,tt))i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){var s;for(const n of Vd(this,$).values())n.editorType===t&&n.show(e);((null==(s=Vd(this,St))?void 0:s.get(mu.HIGHLIGHT_SHOW_ALL))??!0)!==e&&Xd(this,Lt,Yt).call(this,[[mu.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(Vd(this,gt)!==t){qd(this,gt,t);for(const e of Vd(this,j).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}*getEditors(t){for(const e of Vd(this,$).values())e.pageIndex===t&&(yield e)}getEditor(t){return Vd(this,$).get(t)}addEditor(t){Vd(this,$).set(t.id,t)}removeEditor(t){var e,i;t.div.contains(document.activeElement)&&(Vd(this,at)&&clearTimeout(Vd(this,at)),qd(this,at,setTimeout(()=>{this.focusMainContainer(),qd(this,at,null)},0))),Vd(this,$).delete(t.id),t.annotationElementId&&(null==(e=Vd(this,wt))||e.delete(t.annotationElementId)),this.unselect(t),t.annotationElementId&&Vd(this,J).has(t.annotationElementId)||null==(i=Vd(this,V))||i.remove(t.id)}addDeletedAnnotationElement(t){Vd(this,J).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return Vd(this,J).has(t)}removeDeletedAnnotationElement(t){Vd(this,J).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){Vd(this,U)!==t&&(qd(this,U,t),t&&Xd(this,Lt,Yt).call(this,t.propertiesToUpdate))}updateUI(t){Vd(this,Lt,Zt)===t&&Xd(this,Lt,Yt).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){Xd(this,Lt,Yt).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(Vd(this,At).has(t))return Vd(this,At).delete(t),t.unselect(),void Xd(this,Lt,Xt).call(this,{hasSelectedEditor:this.hasSelection});Vd(this,At).add(t),t.select(),Xd(this,Lt,Yt).call(this,t.propertiesToUpdate),Xd(this,Lt,Xt).call(this,{hasSelectedEditor:!0})}setSelected(t){var e;this.updateToolbar({mode:t.mode,editId:t.id}),null==(e=Vd(this,K))||e.commitOrRemove();for(const i of Vd(this,At))i!==t&&i.unselect();Vd(this,At).clear(),Vd(this,At).add(t),t.select(),Xd(this,Lt,Yt).call(this,t.propertiesToUpdate),Xd(this,Lt,Xt).call(this,{hasSelectedEditor:!0})}isSelected(t){return Vd(this,At).has(t)}get firstSelectedEditor(){return Vd(this,At).values().next().value}unselect(t){t.unselect(),Vd(this,At).delete(t),Xd(this,Lt,Xt).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==Vd(this,At).size}get isEnterHandled(){return 1===Vd(this,At).size&&this.firstSelectedEditor.isEnterHandled}undo(){var t;Vd(this,q).undo(),Xd(this,Lt,Xt).call(this,{hasSomethingToUndo:Vd(this,q).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:Xd(this,Lt,te).call(this)}),null==(t=this._editorUndoBar)||t.hide()}redo(){Vd(this,q).redo(),Xd(this,Lt,Xt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:Vd(this,q).hasSomethingToRedo(),isEmpty:Xd(this,Lt,te).call(this)})}addCommands(t){Vd(this,q).add(t),Xd(this,Lt,Xt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:Xd(this,Lt,te).call(this)})}cleanUndoStack(t){Vd(this,q).cleanType(t)}delete(){var t;this.commitOrRemove();const e=null==(t=this.currentLayer)?void 0:t.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const i=e?[e]:[...Vd(this,At)],s=()=>{for(const t of i)Xd(this,Lt,Jt).call(this,t)};this.addCommands({cmd:()=>{var t;null==(t=this._editorUndoBar)||t.show(s,1===i.length?i[0].editorType:i.length);for(const e of i)e.remove()},undo:s,mustExec:!0})}commitOrRemove(){var t;null==(t=Vd(this,U))||t.commitOrRemove()}hasSomethingToControl(){return Vd(this,U)||this.hasSelection}selectAll(){for(const t of Vd(this,At))t.commit();Xd(this,Lt,ee).call(this,Vd(this,$).values())}unselectAll(){var t;if((!Vd(this,U)||(Vd(this,U).commitOrRemove(),Vd(this,yt)===fu.NONE))&&!(null==(t=Vd(this,K))?void 0:t.commitOrRemove())&&this.hasSelection){for(const t of Vd(this,At))t.unselect();Vd(this,At).clear(),Xd(this,Lt,Xt).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;Vd(this,Ct)[0]+=t,Vd(this,Ct)[1]+=e;const[s,n]=Vd(this,Ct),r=[...Vd(this,At)];Vd(this,Tt)&&clearTimeout(Vd(this,Tt)),qd(this,Tt,setTimeout(()=>{qd(this,Tt,null),Vd(this,Ct)[0]=Vd(this,Ct)[1]=0,this.addCommands({cmd:()=>{for(const t of r)Vd(this,$).has(t.id)&&(t.translateInPage(s,n),t.translationDone())},undo:()=>{for(const t of r)Vd(this,$).has(t.id)&&(t.translateInPage(-s,-n),t.translationDone())},mustExec:!1})},1e3));for(const a of r)a.translateInPage(t,e),a.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),qd(this,Z,new Map);for(const t of Vd(this,At))Vd(this,Z).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!Vd(this,Z))return!1;this.disableUserSelect(!1);const t=Vd(this,Z);qd(this,Z,null);let e=!1;for(const[{x:s,y:n,pageIndex:r},a]of t)a.newX=s,a.newY=n,a.newPageIndex=r,e||(e=s!==a.savedX||n!==a.savedY||r!==a.savedPageIndex);if(!e)return!1;const i=(t,e,i,s)=>{if(Vd(this,$).has(t.id)){const n=Vd(this,j).get(s);n?t._setParentAndPosition(n,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(const[e,{newX:s,newY:n,newPageIndex:r}]of t)i(e,s,n,r)},undo:()=>{for(const[e,{savedX:s,savedY:n,savedPageIndex:r}]of t)i(e,s,n,r)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(Vd(this,Z))for(const i of Vd(this,Z).keys())i.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return(null==(t=this.getActive())?void 0:t.shouldGetKeyboardEvents())||1===Vd(this,At).size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return Vd(this,U)===t}getActive(){return Vd(this,U)}getMode(){return Vd(this,yt)}isEditingMode(){return Vd(this,yt)!==fu.NONE}get imageManager(){return Gu(this,"imageManager",new Jp)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let l=0,h=e.rangeCount;l<h;l++)if(!t.contains(e.getRangeAt(l).commonAncestorContainer))return null;const{x:i,y:s,width:n,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(t,e,a,o)=>({x:(e-s)/r,y:1-(t+a-i)/n,width:o/r,height:a/n});break;case"180":a=(t,e,a,o)=>({x:1-(t+a-i)/n,y:1-(e+o-s)/r,width:a/n,height:o/r});break;case"270":a=(t,e,a,o)=>({x:1-(e+o-s)/r,y:(t-i)/n,width:o/r,height:a/n});break;default:a=(t,e,a,o)=>({x:(t-i)/n,y:(e-s)/r,width:a/n,height:o/r})}const o=[];for(let l=0,h=e.rangeCount;l<h;l++){const t=e.getRangeAt(l);if(!t.collapsed)for(const{x:e,y:i,width:s,height:n}of t.getClientRects())0!==s&&0!==n&&o.push(a(e,i,s,n))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(Vd(this,G)||qd(this,G,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;null==(e=Vd(this,G))||e.delete(t)}renderAnnotationElement(t){var e;const i=null==(e=Vd(this,G))?void 0:e.get(t.data.id);if(!i)return;const s=Vd(this,V).getRawValue(i);s&&(Vd(this,yt)!==fu.NONE||s.hasBeenModified)&&s.renderAnnotationElement(t)}setMissingCanvas(t,e,i){var s;const n=null==(s=Vd(this,wt))?void 0:s.get(t);n&&(n.setCanvas(e,i),Vd(this,wt).delete(t))}addMissingCanvas(t,e){(Vd(this,wt)||qd(this,wt,new Map)).set(t,e)}};O=new WeakMap,U=new WeakMap,H=new WeakMap,$=new WeakMap,j=new WeakMap,z=new WeakMap,V=new WeakMap,G=new WeakMap,q=new WeakMap,X=new WeakMap,Y=new WeakMap,K=new WeakMap,Q=new WeakMap,J=new WeakMap,Z=new WeakMap,tt=new WeakMap,et=new WeakMap,it=new WeakMap,st=new WeakMap,nt=new WeakMap,rt=new WeakMap,at=new WeakMap,ot=new WeakMap,lt=new WeakMap,ht=new WeakMap,ct=new WeakMap,dt=new WeakMap,ut=new WeakMap,pt=new WeakMap,gt=new WeakMap,ft=new WeakMap,mt=new WeakMap,vt=new WeakMap,wt=new WeakMap,bt=new WeakMap,yt=new WeakMap,At=new WeakMap,_t=new WeakMap,xt=new WeakMap,kt=new WeakMap,St=new WeakMap,Mt=new WeakMap,Et=new WeakMap,Ct=new WeakMap,Tt=new WeakMap,Pt=new WeakMap,Dt=new WeakMap,Rt=new WeakMap,It=new WeakMap,Lt=new WeakSet,Ft=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},Nt=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const i of Vd(this,j).values())if(i.hasTextLayer(t))return i;return null},Wt=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=Xd(this,Lt,Ft).call(this,t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(Vd(this,ct)||qd(this,ct,new Xp(this)),Vd(this,ct).show(e,i,"ltr"===this.direction))},Bt=function(){var t,e,i;const s=document.getSelection();if(!s||s.isCollapsed)return void(Vd(this,_t)&&(null==(t=Vd(this,ct))||t.hide(),qd(this,_t,null),Xd(this,Lt,Xt).call(this,{hasSelectedText:!1})));const{anchorNode:n}=s;if(n===Vd(this,_t))return;const r=Xd(this,Lt,Ft).call(this,s).closest(".textLayer");if(r){if(null==(i=Vd(this,ct))||i.hide(),qd(this,_t,n),Xd(this,Lt,Xt).call(this,{hasSelectedText:!0}),(Vd(this,yt)===fu.HIGHLIGHT||Vd(this,yt)===fu.NONE)&&(Vd(this,yt)===fu.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),qd(this,ht,this.isShiftKeyDown),!this.isShiftKeyDown)){const t=Vd(this,yt)===fu.HIGHLIGHT?Xd(this,Lt,Nt).call(this,r):null;if(null==t||t.toggleDrawing(),Vd(this,pt)){const e=new AbortController,i=this.combinedSignal(e),s=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),null==t||t.toggleDrawing(!0),"pointerup"===i.type&&Xd(this,Lt,Ot).call(this,"main_toolbar"))};window.addEventListener("pointerup",s,{signal:i}),window.addEventListener("blur",s,{signal:i})}else null==t||t.toggleDrawing(!0),Xd(this,Lt,Ot).call(this,"main_toolbar")}}else Vd(this,_t)&&(null==(e=Vd(this,ct))||e.hide(),qd(this,_t,null),Xd(this,Lt,Xt).call(this,{hasSelectedText:!1}))},Ot=function(t=""){Vd(this,yt)===fu.HIGHLIGHT?this.highlightSelection(t):Vd(this,it)&&Xd(this,Lt,Wt).call(this)},Ut=function(){document.addEventListener("selectionchange",Xd(this,Lt,Bt).bind(this),{signal:this._signal})},Ht=function(){if(Vd(this,ot))return;qd(this,ot,new AbortController);const t=this.combinedSignal(Vd(this,ot));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},$t=function(){var t;null==(t=Vd(this,ot))||t.abort(),qd(this,ot,null)},jt=function(){if(Vd(this,ft))return;qd(this,ft,new AbortController);const t=this.combinedSignal(Vd(this,ft));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},zt=function(){var t;null==(t=Vd(this,ft))||t.abort(),qd(this,ft,null)},Vt=function(){if(Vd(this,Y))return;qd(this,Y,new AbortController);const t=this.combinedSignal(Vd(this,Y));document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})},Gt=function(){var t;null==(t=Vd(this,Y))||t.abort(),qd(this,Y,null)},qt=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},Xt=function(t){Object.entries(t).some(([t,e])=>Vd(this,Et)[t]!==e)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(Vd(this,Et),t)}),Vd(this,yt)===fu.HIGHLIGHT&&!1===t.hasSelectedEditor&&Xd(this,Lt,Yt).call(this,[[mu.HIGHLIGHT_FREE,!0]]))},Yt=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},Kt=async function(){if(!Vd(this,ut)){qd(this,ut,!0);const t=[];for(const e of Vd(this,j).values())t.push(e.enable());await Promise.all(t);for(const e of Vd(this,$).values())e.enable()}},Qt=function(){if(this.unselectAll(),Vd(this,ut)){qd(this,ut,!1);for(const t of Vd(this,j).values())t.disable();for(const t of Vd(this,$).values())t.disable()}},Jt=function(t){const e=Vd(this,j).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Zt=function(){let t=null;for(t of Vd(this,At));return t},te=function(){if(0===Vd(this,$).size)return!0;if(1===Vd(this,$).size)for(const t of Vd(this,$).values())return t.isEmpty();return!1},ee=function(t){for(const e of Vd(this,At))e.unselect();Vd(this,At).clear();for(const e of t)e.isEmpty()||(Vd(this,At).add(e),e.select());Xd(this,Lt,Xt).call(this,{hasSelectedEditor:this.hasSelection})},jd(sg,"TRANSLATE_SMALL",1),jd(sg,"TRANSLATE_BIG",10);let ng=sg;const rg=class t{constructor(e){Gd(this,fe),Gd(this,ie,null),Gd(this,se,!1),Gd(this,ne,null),Gd(this,re,null),Gd(this,ae,null),Gd(this,oe,null),Gd(this,le,!1),Gd(this,he,null),Gd(this,ce,null),Gd(this,de,null),Gd(this,ue,null),Gd(this,pe,!1),qd(this,ce,e),qd(this,pe,e._uiManager.useNewAltTextFlow),Vd(t,ge)||qd(t,ge,Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(e){t._l10n??(t._l10n=e)}async render(){const e=qd(this,ne,document.createElement("button"));e.className="altText",e.tabIndex="0";const i=qd(this,re,document.createElement("span"));e.append(i),Vd(this,pe)?(e.classList.add("new"),e.setAttribute("data-l10n-id",Vd(t,ge).missing),i.setAttribute("data-l10n-id",Vd(t,ge)["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),i.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=Vd(this,ce)._uiManager._signal;e.addEventListener("contextmenu",Mp,{signal:s}),e.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:s});const n=t=>{t.preventDefault(),Vd(this,ce)._uiManager.editAltText(Vd(this,ce)),Vd(this,pe)&&Vd(this,ce)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:Vd(this,fe,me)}})};return e.addEventListener("click",n,{capture:!0,signal:s}),e.addEventListener("keydown",t=>{t.target===e&&"Enter"===t.key&&(qd(this,le,!0),n(t))},{signal:s}),await Xd(this,fe,ve).call(this),e}finish(){Vd(this,ne)&&(Vd(this,ne).focus({focusVisible:Vd(this,le)}),qd(this,le,!1))}isEmpty(){return Vd(this,pe)?null===Vd(this,ie):!Vd(this,ie)&&!Vd(this,se)}hasData(){return Vd(this,pe)?null!==Vd(this,ie)||!!Vd(this,de):this.isEmpty()}get guessedText(){return Vd(this,de)}async setGuessedText(e){null===Vd(this,ie)&&(qd(this,de,e),qd(this,ue,await t._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e})),Xd(this,fe,ve).call(this))}toggleAltTextBadge(t=!1){var e;if(!Vd(this,pe)||Vd(this,ie))return null==(e=Vd(this,he))||e.remove(),void qd(this,he,null);if(!Vd(this,he)){const t=qd(this,he,document.createElement("div"));t.className="noAltTextBadge",Vd(this,ce).div.append(t)}Vd(this,he).classList.toggle("hidden",!t)}serialize(t){let e=Vd(this,ie);return t||Vd(this,de)!==e||(e=Vd(this,ue)),{altText:e,decorative:Vd(this,se),guessedText:Vd(this,de),textWithDisclaimer:Vd(this,ue)}}get data(){return{altText:Vd(this,ie),decorative:Vd(this,se)}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:n=!1}){i&&(qd(this,de,i),qd(this,ue,s)),Vd(this,ie)===t&&Vd(this,se)===e||(n||(qd(this,ie,t),qd(this,se,e)),Xd(this,fe,ve).call(this))}toggle(t=!1){Vd(this,ne)&&(!t&&Vd(this,oe)&&(clearTimeout(Vd(this,oe)),qd(this,oe,null)),Vd(this,ne).disabled=!t)}shown(){Vd(this,ce)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:Vd(this,fe,me)}})}destroy(){var t,e;null==(t=Vd(this,ne))||t.remove(),qd(this,ne,null),qd(this,re,null),qd(this,ae,null),null==(e=Vd(this,he))||e.remove(),qd(this,he,null)}};ie=new WeakMap,se=new WeakMap,ne=new WeakMap,re=new WeakMap,ae=new WeakMap,oe=new WeakMap,le=new WeakMap,he=new WeakMap,ce=new WeakMap,de=new WeakMap,ue=new WeakMap,pe=new WeakMap,ge=new WeakMap,fe=new WeakSet,me=function(){return(Vd(this,ie)?"added":null===Vd(this,ie)&&this.guessedText&&"review")||"missing"},ve=async function(){var t,e,i;const s=Vd(this,ne);if(!s)return;if(Vd(this,pe)){if(s.classList.toggle("done",!!Vd(this,ie)),s.setAttribute("data-l10n-id",Vd(rg,ge)[Vd(this,fe,me)]),null==(t=Vd(this,re))||t.setAttribute("data-l10n-id",Vd(rg,ge)[`${Vd(this,fe,me)}-label`]),!Vd(this,ie))return void(null==(e=Vd(this,ae))||e.remove())}else{if(!Vd(this,ie)&&!Vd(this,se))return s.classList.remove("done"),void(null==(i=Vd(this,ae))||i.remove());s.classList.add("done"),s.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let n=Vd(this,ae);if(!n){qd(this,ae,n=document.createElement("span")),n.className="tooltip",n.setAttribute("role","tooltip"),n.id=`alt-text-tooltip-${Vd(this,ce).id}`;const t=100,e=Vd(this,ce)._uiManager._signal;e.addEventListener("abort",()=>{clearTimeout(Vd(this,oe)),qd(this,oe,null)},{once:!0}),s.addEventListener("mouseenter",()=>{qd(this,oe,setTimeout(()=>{qd(this,oe,null),Vd(this,ae).classList.add("show"),Vd(this,ce)._reportTelemetry({action:"alt_text_tooltip"})},t))},{signal:e}),s.addEventListener("mouseleave",()=>{var t;Vd(this,oe)&&(clearTimeout(Vd(this,oe)),qd(this,oe,null)),null==(t=Vd(this,ae))||t.classList.remove("show")},{signal:e})}Vd(this,se)?n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(n.removeAttribute("data-l10n-id"),n.textContent=Vd(this,ie)),n.parentNode||s.append(n);const r=Vd(this,ce).getElementForAltText();null==r||r.setAttribute("aria-describedby",n.id)},Gd(rg,ge,null),jd(rg,"_l10n",null);let ag=rg;class og{constructor(t){Gd(this,Ce),Gd(this,we,null),Gd(this,be,null),Gd(this,ye,!1),Gd(this,Ae,null),Gd(this,_e,null),Gd(this,xe,null),Gd(this,ke,null),Gd(this,Se,null),Gd(this,Me,!1),Gd(this,Ee,null),qd(this,Ae,t)}renderForToolbar(){const t=qd(this,be,document.createElement("button"));return t.className="comment",Xd(this,Ce,Te).call(this,t,!1)}renderForStandalone(){const t=qd(this,we,document.createElement("button"));t.className="annotationCommentButton";const e=Vd(this,Ae).commentButtonPosition;if(e){const{style:i}=t;i.insetInlineEnd=`calc(${100*("ltr"===Vd(this,Ae)._uiManager.direction?1-e[0]:e[0])}% - var(--comment-button-dim))`,i.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const s=Vd(this,Ae).commentButtonColor;s&&(i.backgroundColor=s)}return Xd(this,Ce,Te).call(this,t,!0)}focusButton(){setTimeout(()=>{var t;null==(t=Vd(this,we)??Vd(this,be))||t.focus()},0)}onUpdatedColor(){if(!Vd(this,we))return;const t=Vd(this,Ae).commentButtonColor;t&&(Vd(this,we).style.backgroundColor=t),Vd(this,Ae)._uiManager.updatePopupColor(Vd(this,Ae))}get commentButtonWidth(){var t;return((null==(t=Vd(this,we))?void 0:t.getBoundingClientRect().width)??0)/Vd(this,Ae).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(Vd(this,Ee))return Vd(this,Ee);if(!Vd(this,we))return null;const{x:t,y:e,height:i}=Vd(this,we).getBoundingClientRect(),{x:s,y:n,width:r,height:a}=Vd(this,Ae).parent.boundingClientRect;return[(t-s)/r,(e+i-n)/a]}set commentPopupPositionInLayer(t){qd(this,Ee,t)}hasDefaultPopupPosition(){return null===Vd(this,Ee)}removeStandaloneCommentButton(){var t;null==(t=Vd(this,we))||t.remove(),qd(this,we,null)}removeToolbarCommentButton(){var t;null==(t=Vd(this,be))||t.remove(),qd(this,be,null)}setCommentButtonStates({selected:t,hasPopup:e}){Vd(this,we)&&(Vd(this,we).classList.toggle("selected",t),Vd(this,we).ariaExpanded=e)}edit(t){const e=this.commentPopupPositionInLayer;let i,s;if(e)[i,s]=e;else{[i,s]=Vd(this,Ae).commentButtonPosition;const{width:t,height:e,x:n,y:r}=Vd(this,Ae);i=n+i*t,s=r+s*e}const n=Vd(this,Ae).parent.boundingClientRect,{x:r,y:a,width:o,height:l}=n;Vd(this,Ae)._uiManager.editComment(Vd(this,Ae),r+i*o,a+s*l,{...t,parentDimensions:n})}finish(){Vd(this,be)&&(Vd(this,be).focus({focusVisible:Vd(this,ye)}),qd(this,ye,!1))}isDeleted(){return Vd(this,Me)||""===Vd(this,ke)}isEmpty(){return null===Vd(this,ke)}hasBeenEdited(){return this.isDeleted()||Vd(this,ke)!==Vd(this,_e)}serialize(){return this.data}get data(){return{text:Vd(this,ke),richText:Vd(this,xe),date:Vd(this,Se),deleted:this.isDeleted()}}set data(t){if(t!==Vd(this,ke)&&qd(this,xe,null),null===t)return qd(this,ke,""),void qd(this,Me,!0);qd(this,ke,t),qd(this,Se,new Date),qd(this,Me,!1)}setInitialText(t,e=null){qd(this,_e,t),this.data=t,qd(this,Se,null),qd(this,xe,e)}shown(){}destroy(){var t,e;null==(t=Vd(this,be))||t.remove(),qd(this,be,null),null==(e=Vd(this,we))||e.remove(),qd(this,we,null),qd(this,ke,""),qd(this,xe,null),qd(this,Se,null),qd(this,Ae,null),qd(this,ye,!1),qd(this,Me,!1)}}we=new WeakMap,be=new WeakMap,ye=new WeakMap,Ae=new WeakMap,_e=new WeakMap,xe=new WeakMap,ke=new WeakMap,Se=new WeakMap,Me=new WeakMap,Ee=new WeakMap,Ce=new WeakSet,Te=function(t,e){if(!Vd(this,Ae)._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[Vd(this,Ae)._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button"));const i=Vd(this,Ae)._uiManager._signal;if(!(i instanceof AbortSignal)||i.aborted)return t;t.addEventListener("contextmenu",Mp,{signal:i}),e&&(t.addEventListener("focusin",t=>{Vd(this,Ae)._focusEventsAllowed=!1,Ep(t)},{capture:!0,signal:i}),t.addEventListener("focusout",t=>{Vd(this,Ae)._focusEventsAllowed=!0,Ep(t)},{capture:!0,signal:i})),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});const s=e=>{e.preventDefault(),t===Vd(this,be)?this.edit():Vd(this,Ae).toggleComment(!0)};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(qd(this,ye,!0),s(e))},{signal:i}),t.addEventListener("pointerenter",()=>{Vd(this,Ae).toggleComment(!1,!0)},{signal:i}),t.addEventListener("pointerleave",()=>{Vd(this,Ae).toggleComment(!1,!1)},{signal:i}),t};const lg=class{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:r=null,signal:a}){Gd(this,$e),Gd(this,Pe),Gd(this,De,!1),Gd(this,Re,null),Gd(this,Ie),Gd(this,Le),Gd(this,Fe),Gd(this,Ne),Gd(this,We,null),Gd(this,Be),Gd(this,Oe,null),Gd(this,Ue),Gd(this,He,null),qd(this,Pe,t),qd(this,Re,i),qd(this,Ie,e),qd(this,Le,s),qd(this,Fe,n),qd(this,Ne,r),qd(this,Ue,new AbortController),qd(this,Be,AbortSignal.any([a,Vd(this,Ue).signal])),t.addEventListener("touchstart",Xd(this,$e,je).bind(this),{passive:!1,signal:Vd(this,Be)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Lp.pixelRatio}destroy(){var t,e;null==(t=Vd(this,Ue))||t.abort(),qd(this,Ue,null),null==(e=Vd(this,We))||e.abort(),qd(this,We,null)}};Pe=new WeakMap,De=new WeakMap,Re=new WeakMap,Ie=new WeakMap,Le=new WeakMap,Fe=new WeakMap,Ne=new WeakMap,We=new WeakMap,Be=new WeakMap,Oe=new WeakMap,Ue=new WeakMap,He=new WeakMap,$e=new WeakSet,je=function(t){var e,i,s;if(null==(e=Vd(this,Ie))?void 0:e.call(this))return;if(1===t.touches.length){if(Vd(this,We))return;const t=qd(this,We,new AbortController),e=AbortSignal.any([Vd(this,Be),t.signal]),i=Vd(this,Pe),s={capture:!0,signal:e,passive:!1},n=t=>{var e;"touch"===t.pointerType&&(null==(e=Vd(this,We))||e.abort(),qd(this,We,null))};return i.addEventListener("pointerdown",t=>{"touch"===t.pointerType&&(Ep(t),n(t))},s),i.addEventListener("pointerup",n,s),void i.addEventListener("pointercancel",n,s)}if(!Vd(this,He)){qd(this,He,new AbortController);const t=AbortSignal.any([Vd(this,Be),Vd(this,He).signal]),e=Vd(this,Pe),s={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",Xd(this,$e,ze).bind(this),s);const n=Xd(this,$e,Ve).bind(this);e.addEventListener("touchend",n,s),e.addEventListener("touchcancel",n,s),s.capture=!0,e.addEventListener("pointerdown",Ep,s),e.addEventListener("pointermove",Ep,s),e.addEventListener("pointercancel",Ep,s),e.addEventListener("pointerup",Ep,s),null==(i=Vd(this,Le))||i.call(this)}if(Ep(t),2!==t.touches.length||(null==(s=Vd(this,Re))?void 0:s.call(this)))return void qd(this,Oe,null);let[n,r]=t.touches;n.identifier>r.identifier&&([n,r]=[r,n]),qd(this,Oe,{touch0X:n.screenX,touch0Y:n.screenY,touch1X:r.screenX,touch1Y:r.screenY})},ze=function(t){var e;if(!Vd(this,Oe)||2!==t.touches.length)return;Ep(t);let[i,s]=t.touches;i.identifier>s.identifier&&([i,s]=[s,i]);const{screenX:n,screenY:r}=i,{screenX:a,screenY:o}=s,l=Vd(this,Oe),{touch0X:h,touch0Y:c,touch1X:d,touch1Y:u}=l,p=d-h,g=u-c,f=a-n,m=o-r,v=Math.hypot(f,m)||1,w=Math.hypot(p,g)||1;if(!Vd(this,De)&&Math.abs(w-v)<=lg.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=n,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,!Vd(this,De))return void qd(this,De,!0);const b=[(n+a)/2,(r+o)/2];null==(e=Vd(this,Fe))||e.call(this,b,w,v)},Ve=function(t){var e;t.touches.length>=2||(Vd(this,He)&&(Vd(this,He).abort(),qd(this,He,null),null==(e=Vd(this,Ne))||e.call(this)),Vd(this,Oe)&&(Ep(t),qd(this,Oe,null),qd(this,De,!1)))};let hg=lg;const cg=class t{constructor(e){Gd(this,wi),Gd(this,Ge,null),Gd(this,qe,null),Gd(this,Xe,null),Gd(this,Ye,null),Gd(this,Ke,null),Gd(this,Qe,!1),Gd(this,Je,null),Gd(this,Ze,""),Gd(this,ti,null),Gd(this,ei,null),Gd(this,ii,null),Gd(this,si,null),Gd(this,ni,null),Gd(this,ri,""),Gd(this,ai,!1),Gd(this,oi,null),Gd(this,li,!1),Gd(this,hi,!1),Gd(this,ci,!1),Gd(this,di,null),Gd(this,ui,0),Gd(this,pi,0),Gd(this,gi,null),Gd(this,fi,null),jd(this,"isSelected",!1),jd(this,"_isCopy",!1),jd(this,"_editToolbar",null),jd(this,"_initialOptions",Object.create(null)),jd(this,"_initialData",null),jd(this,"_isVisible",!0),jd(this,"_uiManager",null),jd(this,"_focusEventsAllowed",!0),Gd(this,mi,!1),Gd(this,vi,t._zIndex++),this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null,this.annotationElementId=e.annotationElementId||null,this.creationDate=e.creationDate||new Date,this.modificationDate=e.modificationDate||null;const{rotation:i,rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:a}}=this.parent.viewport;this.rotation=i,this.pageRotation=(360+i-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,n],this.pageTranslation=[r,a];const[o,l]=this.parentDimensions;this.x=e.x/o,this.y=e.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const e=t.prototype._resizeWithKeyboard,i=ng.TRANSLATE_SMALL,s=ng.TRANSLATE_BIG;return Gu(this,"_resizerKeyboardManager",new tg([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-i,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[i,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-i]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,i]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,s]}],[["Escape","mac+Escape"],t.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return Gu(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new ug({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(e,i){if(t._l10n??(t._l10n=e),t._l10nResizer||(t._l10nResizer=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"})),-1!==t._borderLineWidth)return;const s=getComputedStyle(document.documentElement);t._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){$u("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return Vd(this,mi)}set _isDraggable(t){var e;qd(this,mi,t),null==(e=this.div)||e.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=Vd(this,vi)}setParent(t){var e;null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(Xd(this,wi,Bi).call(this),null==(e=Vd(this,si))||e.remove(),qd(this,si,null)),this.parent=t}focusin(t){this._focusEventsAllowed&&(Vd(this,ai)?qd(this,ai,!1):this.parent.setSelected(this))}focusout(t){var e;if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const i=t.relatedTarget;(null==i?void 0:i.closest(`#${this.id}`))||(t.preventDefault(),(null==(e=this.parent)?void 0:e.isMultipleSelection)||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){const[n,r]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/r,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s),this._onTranslated()}translate(t,e){Xd(this,wi,bi).call(this,this.parentDimensions,t,e)}translateInPage(t,e){Vd(this,oi)||qd(this,oi,[this.x,this.y,this.width,this.height]),Xd(this,wi,bi).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){Vd(this,oi)||qd(this,oi,[this.x,this.y,this.width,this.height]);const{div:i,parentDimensions:[s,n]}=this;if(this.x+=t/s,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:a}=this;const[o,l]=this.getBaseTranslation();r+=o,a+=l;const{style:h}=i;h.left=`${(100*r).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!Vd(this,oi)&&(Vd(this,oi)[0]!==this.x||Vd(this,oi)[1]!==this.y)}get _hasBeenResized(){return!!Vd(this,oi)&&(Vd(this,oi)[2]!==this.width||Vd(this,oi)[3]!==this.height)}getBaseTranslation(){const[e,i]=this.parentDimensions,{_borderLineWidth:s}=t,n=s/e,r=s/i;switch(this.rotation){case 90:return[-n,r];case 180:return[n,r];case 270:return[n,-r];default:return[-n,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[i,s]}=this;let{x:n,y:r,width:a,height:o}=this;if(a*=i,o*=s,n*=i,r*=s,this._mustFixPosition)switch(t){case 0:n=cp(n,0,i-a),r=cp(r,0,s-o);break;case 90:n=cp(n,0,i-o),r=cp(r,a,s);break;case 180:n=cp(n,a,i),r=cp(r,o,s);break;case 270:n=cp(n,o,i),r=cp(r,0,s-a)}this.x=n/=i,this.y=r/=s;const[l,h]=this.getBaseTranslation();n+=l,r+=h,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(e,i){var s;return Xd(s=t,yi,Ai).call(s,e,i,this.parentRotation)}pageTranslationToScreen(e,i){var s;return Xd(s=t,yi,Ai).call(s,e,i,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(){const{div:{style:t},width:e,height:i}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*i).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(1e4*t)/1e4}_onResizing(){}altTextFinish(){var t;null==(t=Vd(this,Xe))||t.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||Vd(this,hi))return this._editToolbar;this._editToolbar=new qp(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,i]of t)await this._editToolbar.addButton(e,i);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){var t;null==(t=this._editToolbar)||t.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){var t;null==(t=this._editToolbar)||t.removeButton("comment")}removeEditToolbar(){var t,e;null==(t=this._editToolbar)||t.remove(),this._editToolbar=null,null==(e=Vd(this,Xe))||e.destroy()}addContainer(t){var e;const i=null==(e=this._editToolbar)?void 0:e.div;i?i.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return Vd(this,Xe)||(ag.initialize(t._l10n),qd(this,Xe,new ag(this)),Vd(this,Ge)&&(Vd(this,Xe).data=Vd(this,Ge),qd(this,Ge,null))),Vd(this,Xe)}get altTextData(){var t;return null==(t=Vd(this,Xe))?void 0:t.data}set altTextData(t){Vd(this,Xe)&&(Vd(this,Xe).data=t)}get guessedAltText(){var t;return null==(t=Vd(this,Xe))?void 0:t.guessedText}async setGuessedAltText(t){var e;await(null==(e=Vd(this,Xe))?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return null==(e=Vd(this,Xe))?void 0:e.serialize(t)}hasAltText(){return!!Vd(this,Xe)&&!Vd(this,Xe).isEmpty()}hasAltTextData(){var t;return(null==(t=Vd(this,Xe))?void 0:t.hasData())??!1}focusCommentButton(){var t;null==(t=Vd(this,Ye))||t.focusButton()}addCommentButton(){return Vd(this,Ye)||qd(this,Ye,new og(this))}addStandaloneCommentButton(){Vd(this,Ke)?this._uiManager.isEditingMode()&&Vd(this,Ke).classList.remove("hidden"):this.hasComment&&(qd(this,Ke,Vd(this,Ye).renderForStandalone()),this.div.append(Vd(this,Ke)))}removeStandaloneCommentButton(){Vd(this,Ye).removeStandaloneCommentButton(),qd(this,Ke,null)}hideStandaloneCommentButton(){var t;null==(t=Vd(this,Ke))||t.classList.add("hidden")}get comment(){const{data:{richText:t,text:e,date:i,deleted:s}}=Vd(this,Ye);return{text:e,richText:t,date:i,deleted:s,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){Vd(this,Ye)||qd(this,Ye,new og(this)),Vd(this,Ye).data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:i}){if(!e)return;if(Vd(this,Ye)||qd(this,Ye,new og(this)),Vd(this,Ye).setInitialText(t,i),!this.annotationElementId)return;const s=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);s&&this.updateFromAnnotationLayer(s)}get hasEditedComment(){var t;return null==(t=Vd(this,Ye))?void 0:t.hasBeenEdited()}get hasDeletedComment(){var t;return null==(t=Vd(this,Ye))?void 0:t.isDeleted()}get hasComment(){return!!Vd(this,Ye)&&!Vd(this,Ye).isEmpty()&&!Vd(this,Ye).isDeleted()}async editComment(t){Vd(this,Ye)||qd(this,Ye,new og(this)),Vd(this,Ye).edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){Vd(this,Ye).setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const e=180,i=100,[,,,s]=t.rect,[n]=this.pageDimensions,[r]=this.pageTranslation,a=r+n+1,o=s-i,l=a+e;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[a,o,l,s]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){Vd(this,Ye).data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){var t;const e=this.div=document.createElement("div");e.setAttribute("data-editor-rotation",(360-this.rotation)%360),e.className=this.name,e.setAttribute("id",this.id),e.tabIndex=Vd(this,Qe)?-1:0,e.setAttribute("role","application"),this.defaultL10nId&&e.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||e.classList.add("hidden"),this.setInForeground(),Xd(this,wi,Ii).call(this);const[i,s]=this.parentDimensions;this.parentRotation%180!=0&&(e.style.maxWidth=`${(100*s/i).toFixed(2)}%`,e.style.maxHeight=`${(100*i/s).toFixed(2)}%`);const[n,r]=this.getInitialTranslation();return this.translate(n,r),Yp(this,e,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(Vd(this,fi)||qd(this,fi,new hg({container:e,isPinchingDisabled:()=>!this.isSelected,onPinchStart:Xd(this,wi,Ci).bind(this),onPinching:Xd(this,wi,Ti).bind(this),onPinchEnd:Xd(this,wi,Pi).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),null==(t=this._uiManager._editorUndoBar)||t.hide(),e}pointerdown(t){const{isMac:e}=ip.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(qd(this,ai,!0),this._isDraggable?Xd(this,wi,Ri).call(this,t):Xd(this,wi,Di).call(this,t))}_onStartDragging(){}_onStopDragging(){}moveInDOM(){Vd(this,di)&&clearTimeout(Vd(this,di)),qd(this,di,setTimeout(()=>{var t;qd(this,di,null),null==(t=this.parent)||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){const s=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/s,h=e/s,c=this.x*n,d=this.y*r,u=this.width*n,p=this.height*r;switch(i){case 0:return[c+l+a,r-d-h-p+o,c+l+u+a,r-d-h+o];case 90:return[c+h+a,r-d+l+o,c+h+p+a,r-d+l+u+o];case 180:return[c-l-u+a,r-d+h+o,c-l+a,r-d+h+p+o];case 270:return[c-h-p+a,r-d-l-u+o,c-h+a,r-d-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,s,n,r]=t,a=n-i,o=r-s;switch(this.rotation){case 0:return[i,e-r,a,o];case 90:return[i,e-s,o,a];case 180:return[n,e-s,a,o];case 270:return[n,e-r,o,a];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&t._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var t;null==(t=Vd(this,Ye))||t.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:i,opacity:s,deleted:n,richText:r},uid:a,pageIndex:o,creationDate:l,modificationDate:h}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:r,contentsObj:{str:t},creationDate:l,modificationDate:i||h,popupRef:!n,color:e,opacity:s}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),qd(this,hi,!0),!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),qd(this,hi,!1),!0)}isInEditMode(){return Vd(this,hi)}shouldGetKeyboardEvents(){return Vd(this,ci)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&s>0&&t<n&&i>0}rebuild(){Xd(this,wi,Ii).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:(null==(t=this._initialData)?void 0:t.popupRef)||""}}serialize(t=!1,e=null){var i;return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:(null==(i=this._initialData)?void 0:i.popupRef)||""}}static async deserialize(t,e,i){const s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});s.rotation=t.rotation,qd(s,Ge,t.accessibilityData),s._isCopy=t.isCopy||!1;const[n,r]=s.pageDimensions,[a,o,l,h]=s.getRectInCurrentCoords(t.rect,r);return s.x=a/n,s.y=o/r,s.width=l/n,s.height=h/r,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){var t,e;if(null==(t=Vd(this,ni))||t.abort(),qd(this,ni,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),Vd(this,di)&&(clearTimeout(Vd(this,di)),qd(this,di,null)),Xd(this,wi,Bi).call(this),this.removeEditToolbar(),Vd(this,gi)){for(const t of Vd(this,gi).values())clearTimeout(t);qd(this,gi,null)}this.parent=null,null==(e=Vd(this,fi))||e.destroy(),qd(this,fi,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(Xd(this,wi,xi).call(this),Vd(this,ti).classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return"ltr"===this._uiManager.direction?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[e,i]}=this,[s,n,r,a]=this.getPDFRect();return[t._round(s+(r-s)*e),t._round(n+(a-n)*(1-i))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return Vd(this,Ye).commentPopupPositionInLayer}set commentPopupPosition(t){Vd(this,Ye).commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return Vd(this,Ye).hasDefaultPopupPosition()}get commentButtonWidth(){return Vd(this,Ye).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){Vd(this,Ye).setCommentButtonStates(t)}keydown(e){if(!this.isResizable||e.target!==this.div||"Enter"!==e.key)return;this._uiManager.setSelected(this),qd(this,ii,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const i=Vd(this,ti).children;if(!Vd(this,qe)){qd(this,qe,Array.from(i));const e=Xd(this,wi,Li).bind(this),s=Xd(this,wi,Fi).bind(this),n=this._uiManager._signal;for(const i of Vd(this,qe)){const r=i.getAttribute("data-resizer-name");i.setAttribute("role","spinbutton"),i.addEventListener("keydown",e,{signal:n}),i.addEventListener("blur",s,{signal:n}),i.addEventListener("focus",Xd(this,wi,Ni).bind(this,r),{signal:n}),i.setAttribute("data-l10n-id",t._l10nResizer[r])}}const s=Vd(this,qe)[0];let n=0;for(const t of i){if(t===s)break;n++}const r=(360-this.rotation+this.parentRotation)%360/90*(Vd(this,qe).length/4);if(r!==n){if(r<n)for(let t=0;t<n-r;t++)Vd(this,ti).append(Vd(this,ti).firstChild);else if(r>n)for(let t=0;t<r-n;t++)Vd(this,ti).firstChild.before(Vd(this,ti).lastChild);let e=0;for(const s of i){const i=Vd(this,qe)[e++].getAttribute("data-resizer-name");s.setAttribute("data-l10n-id",t._l10nResizer[i])}}Xd(this,wi,Wi).call(this,0),qd(this,ci,!0),Vd(this,ti).firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}_resizeWithKeyboard(t,e){Vd(this,ci)&&Xd(this,wi,Ei).call(this,Vd(this,ri),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){Xd(this,wi,Bi).call(this),this.div.focus()}select(){var t,e,i;this.isSelected&&this._editToolbar?this._editToolbar.show():(this.isSelected=!0,this.makeResizable(),null==(t=this.div)||t.classList.add("selectedEditor"),this._editToolbar?(null==(e=this._editToolbar)||e.show(),null==(i=Vd(this,Xe))||i.toggleAltTextBadge(!1)):this.addEditToolbar().then(()=>{var t,e;(null==(t=this.div)?void 0:t.classList.contains("selectedEditor"))&&(null==(e=this._editToolbar)||e.show())}))}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>{var t;return null==(t=this.div)?void 0:t.focus({preventScroll:!0})},0)}unselect(){var t,e,i,s,n;this.isSelected&&(this.isSelected=!1,null==(t=Vd(this,ti))||t.classList.add("hidden"),null==(e=this.div)||e.classList.remove("selectedEditor"),(null==(i=this.div)?void 0:i.contains(document.activeElement))&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),null==(s=this._editToolbar)||s.hide(),null==(n=Vd(this,Xe))||n.toggleAltTextBadge(!0),this.hasComment&&this._uiManager.toggleComment(this,!1,!1))}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){"BUTTON"!==t.target.nodeName&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return Vd(this,li)}set isEditing(t){qd(this,li,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,i=!1){if(i){Vd(this,gi)||qd(this,gi,new Map);const{action:i}=e;let s=Vd(this,gi).get(i);return s&&clearTimeout(s),s=setTimeout(()=>{this._reportTelemetry(e),Vd(this,gi).delete(i),0===Vd(this,gi).size&&qd(this,gi,null)},t._telemetryTimeout),void Vd(this,gi).set(i,s)}e.type||(e.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),qd(this,Qe,!1)}disable(){this.div&&(this.div.tabIndex=-1),qd(this,Qe,!0)}updateFakeAnnotationElement(t){if(Vd(this,si)||this.deleted)return this.deleted?(Vd(this,si).remove(),void qd(this,si,null)):void((this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&Vd(this,si).updateEdited({rect:this.getPDFRect(),popup:this.comment}));qd(this,si,t.addFakeAnnotation(this))}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===(null==e?void 0:e.nodeName)&&e.classList.contains("annotationContent")&&e.remove()}};Ge=new WeakMap,qe=new WeakMap,Xe=new WeakMap,Ye=new WeakMap,Ke=new WeakMap,Qe=new WeakMap,Je=new WeakMap,Ze=new WeakMap,ti=new WeakMap,ei=new WeakMap,ii=new WeakMap,si=new WeakMap,ni=new WeakMap,ri=new WeakMap,ai=new WeakMap,oi=new WeakMap,li=new WeakMap,hi=new WeakMap,ci=new WeakMap,di=new WeakMap,ui=new WeakMap,pi=new WeakMap,gi=new WeakMap,fi=new WeakMap,mi=new WeakMap,vi=new WeakMap,wi=new WeakSet,bi=function([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},yi=new WeakSet,Ai=function(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},_i=function(t){switch(t){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}},xi=function(){if(Vd(this,ti))return;qd(this,ti,document.createElement("div")),Vd(this,ti).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const i of t){const t=document.createElement("div");Vd(this,ti).append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",Xd(this,wi,ki).bind(this,i),{signal:e}),t.addEventListener("contextmenu",Mp,{signal:e}),t.tabIndex=-1}this.div.prepend(Vd(this,ti))},ki=function(t,e){var i;e.preventDefault();const{isMac:s}=ip.platform;if(0!==e.button||e.ctrlKey&&s)return;null==(i=Vd(this,Xe))||i.toggle(!1);const n=this._isDraggable;this._isDraggable=!1,qd(this,ei,[e.screenX,e.screenY]);const r=new AbortController,a=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",Xd(this,wi,Ei).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Ep,{passive:!1,signal:a}),window.addEventListener("contextmenu",Mp,{signal:a}),qd(this,ii,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const h=()=>{var t;r.abort(),this.parent.togglePointerEvents(!0),null==(t=Vd(this,Xe))||t.toggle(!0),this._isDraggable=n,this.parent.div.style.cursor=o,this.div.style.cursor=l,Xd(this,wi,Mi).call(this)};window.addEventListener("pointerup",h,{signal:a}),window.addEventListener("blur",h,{signal:a})},Si=function(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()},Mi=function(){if(!Vd(this,ii))return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=Vd(this,ii);qd(this,ii,null);const n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===i&&o===s||this.addCommands({cmd:Xd(this,wi,Si).bind(this,n,r,a,o),undo:Xd(this,wi,Si).bind(this,t,e,i,s),mustExec:!0})},Ei=function(t,e){const[i,s]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,l=cg.MIN_SIZE/i,h=cg.MIN_SIZE/s,c=Xd(this,wi,_i).call(this,this.rotation),d=(t,e)=>[c[0]*t+c[2]*e,c[1]*t+c[3]*e],u=Xd(this,wi,_i).call(this,360-this.rotation);let p,g,f=!1,m=!1;switch(t){case"topLeft":f=!0,p=(t,e)=>[0,0],g=(t,e)=>[t,e];break;case"topMiddle":p=(t,e)=>[t/2,0],g=(t,e)=>[t/2,e];break;case"topRight":f=!0,p=(t,e)=>[t,0],g=(t,e)=>[0,e];break;case"middleRight":m=!0,p=(t,e)=>[t,e/2],g=(t,e)=>[0,e/2];break;case"bottomRight":f=!0,p=(t,e)=>[t,e],g=(t,e)=>[0,0];break;case"bottomMiddle":p=(t,e)=>[t/2,e],g=(t,e)=>[t/2,0];break;case"bottomLeft":f=!0,p=(t,e)=>[0,e],g=(t,e)=>[t,0];break;case"middleLeft":m=!0,p=(t,e)=>[0,e/2],g=(t,e)=>[t,e/2]}const v=p(a,o),w=g(a,o);let b=d(...w);const y=cg._round(n+b[0]),A=cg._round(r+b[1]);let _,x,k=1,S=1;if(e.fromKeyboard)({deltaX:_,deltaY:x}=e);else{const{screenX:t,screenY:i}=e,[s,n]=Vd(this,ei);[_,x]=this.screenToPageTranslation(t-s,i-n),Vd(this,ei)[0]=t,Vd(this,ei)[1]=i}var M,E;if([_,x]=(M=_/i,E=x/s,[u[0]*M+u[2]*E,u[1]*M+u[3]*E]),f){const t=Math.hypot(a,o);k=S=Math.max(Math.min(Math.hypot(w[0]-v[0]-_,w[1]-v[1]-x)/t,1/a,1/o),l/a,h/o)}else m?k=cp(Math.abs(w[0]-v[0]-_),l,1)/a:S=cp(Math.abs(w[1]-v[1]-x),h,1)/o;const C=cg._round(a*k),T=cg._round(o*S);b=d(...g(C,T));const P=y-b[0],D=A-b[1];Vd(this,oi)||qd(this,oi,[this.x,this.y,this.width,this.height]),this.width=C,this.height=T,this.x=P,this.y=D,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Ci=function(){var t;qd(this,ii,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),null==(t=Vd(this,Xe))||t.toggle(!1),this.parent.togglePointerEvents(!1)},Ti=function(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;const n=Xd(this,wi,_i).call(this,this.rotation),r=(t,e)=>[n[0]*t+n[2]*e,n[1]*t+n[3]*e],[a,o]=this.parentDimensions,l=this.x,h=this.y,c=this.width,d=this.height,u=cg.MIN_SIZE/a,p=cg.MIN_SIZE/o;s=Math.max(Math.min(s,1/c,1/d),u/c,p/d);const g=cg._round(c*s),f=cg._round(d*s);if(g===c&&f===d)return;Vd(this,oi)||qd(this,oi,[l,h,c,d]);const m=r(c/2,d/2),v=cg._round(l+m[0]),w=cg._round(h+m[1]),b=r(g/2,f/2);this.x=v-b[0],this.y=w-b[1],this.width=g,this.height=f,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Pi=function(){var t;null==(t=Vd(this,Xe))||t.toggle(!0),this.parent.togglePointerEvents(!0),Xd(this,wi,Mi).call(this)},Di=function(t){const{isMac:e}=ip.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Ri=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const s=new AbortController,n=this._uiManager.combinedSignal(s),r={capture:!0,passive:!1,signal:n},a=t=>{s.abort(),qd(this,Je,null),qd(this,ai,!1),this._uiManager.endDragSession()||Xd(this,wi,Di).call(this,t),i&&this._onStopDragging()};e&&(qd(this,ui,t.clientX),qd(this,pi,t.clientY),qd(this,Je,t.pointerId),qd(this,Ze,t.pointerType),window.addEventListener("pointermove",t=>{i||(i=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:e,clientY:s,pointerId:n}=t;if(n!==Vd(this,Je))return void Ep(t);const[r,a]=this.screenToPageTranslation(e-Vd(this,ui),s-Vd(this,pi));qd(this,ui,e),qd(this,pi,s),this._uiManager.dragSelectedEditors(r,a)},r),window.addEventListener("touchmove",Ep,r),window.addEventListener("pointerdown",t=>{t.pointerType===Vd(this,Ze)&&(Vd(this,fi)||t.isPrimary)&&a(t),Ep(t)},r));const o=t=>{Vd(this,Je)&&Vd(this,Je)!==t.pointerId?Ep(t):a(t)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})},Ii=function(){if(Vd(this,ni)||!this.div)return;qd(this,ni,new AbortController);const t=this._uiManager.combinedSignal(Vd(this,ni));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Li=function(t){cg._resizerKeyboardManager.exec(this,t)},Fi=function(t){var e;Vd(this,ci)&&(null==(e=t.relatedTarget)?void 0:e.parentNode)!==Vd(this,ti)&&Xd(this,wi,Bi).call(this)},Ni=function(t){qd(this,ri,Vd(this,ci)?t:"")},Wi=function(t){if(Vd(this,qe))for(const e of Vd(this,qe))e.tabIndex=t},Bi=function(){qd(this,ci,!1),Xd(this,wi,Wi).call(this,-1),Xd(this,wi,Mi).call(this)},Gd(cg,yi),jd(cg,"_l10n",null),jd(cg,"_l10nResizer",null),jd(cg,"_borderLineWidth",-1),jd(cg,"_colorManager",new ig),jd(cg,"_zIndex",1),jd(cg,"_telemetryTimeout",1e3);let dg=cg;class ug extends dg{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const pg=3285377520,gg=4294901760,fg=65535;class mg{constructor(t){this.h1=t?4294967295&t:pg,this.h2=t?4294967295&t:pg}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,n=t.length;s<n;s++){const n=t.charCodeAt(s);n<=255?e[i++]=n:(e[i++]=n>>>8,e[i++]=255&n)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),i=e.byteLength}const s=i>>2,n=i-4*s,r=new Uint32Array(e.buffer,0,s);let a=0,o=0,l=this.h1,h=this.h2;const c=3432918353,d=461845907,u=11601,p=13715;for(let g=0;g<s;g++)1&g?(a=r[g],a=a*c&gg|a*u&fg,a=a<<15|a>>>17,a=a*d&gg|a*p&fg,l^=a,l=l<<13|l>>>19,l=5*l+3864292196):(o=r[g],o=o*c&gg|o*u&fg,o=o<<15|o>>>17,o=o*d&gg|o*p&fg,h^=o,h=h<<13|h>>>19,h=5*h+3864292196);switch(a=0,n){case 3:a^=e[4*s+2]<<16;case 2:a^=e[4*s+1]<<8;case 1:a^=e[4*s],a=a*c&gg|a*u&fg,a=a<<15|a>>>17,a=a*d&gg|a*p&fg,1&s?l^=a:h^=a}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&gg|36045*t&fg,e=4283543511*e&gg|(2950163797*(e<<16|t>>>16)&gg)>>>16,t^=e>>>1,t=444984403*t&gg|60499*t&fg,e=3301882366*e&gg|(3120437893*(e<<16|t>>>16)&gg)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const vg=Object.freeze({map:null,hash:"",transfer:void 0});class wg{constructor(){Gd(this,ji),Gd(this,Oi,!1),Gd(this,Ui,null),Gd(this,Hi,null),Gd(this,$i,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=Vd(this,$i).get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return Vd(this,$i).get(t)}remove(t){const e=Vd(this,$i).get(t);if(void 0!==e&&(e instanceof dg&&Vd(this,Hi).delete(e.annotationElementId),Vd(this,$i).delete(t),0===Vd(this,$i).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor)){for(const t of Vd(this,$i).values())if(t instanceof dg)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=Vd(this,$i).get(t);let s=!1;if(void 0!==i)for(const[n,r]of Object.entries(e))i[n]!==r&&(s=!0,i[n]=r);else s=!0,Vd(this,$i).set(t,e);s&&Xd(this,ji,zi).call(this),e instanceof dg&&((Vd(this,Hi)||qd(this,Hi,new Map)).set(e.annotationElementId,e),"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type))}has(t){return Vd(this,$i).has(t)}get size(){return Vd(this,$i).size}resetModified(){Vd(this,Oi)&&(qd(this,Oi,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new bg(this)}get serializable(){if(0===Vd(this,$i).size)return vg;const t=new Map,e=new mg,i=[],s=Object.create(null);let n=!1;for(const[r,a]of Vd(this,$i)){const i=a instanceof dg?a.serialize(!1,s):a;i&&(t.set(r,i),e.update(`${r}:${JSON.stringify(i)}`),n||(n=!!i.bitmap))}if(n)for(const r of t.values())r.bitmap&&i.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:vg}get editorStats(){let t=null;const e=new Map;let i=0,s=0;for(const n of Vd(this,$i).values()){if(!(n instanceof dg)){n.popup&&(n.popup.deleted?s+=1:i+=1);continue}n.isCommentDeleted?s+=1:n.hasEditedComment&&(i+=1);const r=n.telemetryFinalData;if(!r)continue;const{type:a}=r;e.has(a)||e.set(a,Object.getPrototypeOf(n).constructor),t||(t=Object.create(null));const o=t[a]||(t[a]=new Map);for(const[t,e]of Object.entries(r)){if("type"===t)continue;let i=o.get(t);i||(i=new Map,o.set(t,i));const s=i.get(e)??0;i.set(e,s+1)}}if((s>0||i>0)&&(t||(t=Object.create(null)),t.comments={deleted:s,edited:i}),!t)return null;for(const[n,r]of e)t[n]=r.computeTelemetryFinalData(t[n]);return t}resetModifiedIds(){qd(this,Ui,null)}updateEditor(t,e){var i;const s=null==(i=Vd(this,Hi))?void 0:i.get(t);return!!s&&(s.updateFromAnnotationLayer(e),!0)}getEditor(t){var e;return(null==(e=Vd(this,Hi))?void 0:e.get(t))||null}get modifiedIds(){if(Vd(this,Ui))return Vd(this,Ui);const t=[];if(Vd(this,Hi))for(const e of Vd(this,Hi).values())e.serialize()&&t.push(e.annotationElementId);return qd(this,Ui,{ids:new Set(t),hash:t.join(",")})}[Symbol.iterator](){return Vd(this,$i).entries()}}Oi=new WeakMap,Ui=new WeakMap,Hi=new WeakMap,$i=new WeakMap,ji=new WeakSet,zi=function(){Vd(this,Oi)||(qd(this,Oi,!0),"function"==typeof this.onSetModified&&this.onSetModified())};class bg extends wg{constructor(t){super(),Gd(this,Vi);const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);qd(this,Vi,{map:n,hash:i,transfer:s})}get print(){$u("Should not call PrintAnnotationStorage.print")}get serializable(){return Vd(this,Vi)}get modifiedIds(){return Gu(this,"modifiedIds",{ids:new Set,hash:""})}}Vi=new WeakMap;class yg{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){Gd(this,Gi,new Set),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(),Vd(this,Gi).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}){if(t&&!Vd(this,Gi).has(t.loadedName)){if(ju(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:e,src:s,style:n}=t,r=new FontFace(e,s,n);this.addNativeFontFace(r);try{await r.load(),Vd(this,Gi).add(e),null==i||i(t)}catch{Hu(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}return}$u("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void(await this.loadSystemFont(t));if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw Hu(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(e=>{const i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){var t;return Gu(this,"isFontLoadingAPISupported",!!(null==(t=this._document)?void 0:t.fonts))}get isSyncFontLoadingSupported(){return Gu(this,"isSyncFontLoadingSupported",iu||ip.platform.isFirefox)}_queueLoadingCallback(t){const{loadingRequests:e}=this,i={done:!1,complete:function(){for(ju(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;){const t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(i),i}get _loadTestFont(){return Gu(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function i(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function s(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let n,r;const a=this._document.createElement("canvas");a.width=1,a.height=1;const o=a.getContext("2d");let l=0;const h=`lt${Date.now()}${this.loadTestFontId++}`;let c=this._loadTestFont;c=s(c,976,h.length,h);const d=1482184792;let u=i(c,16);for(n=0,r=h.length-3;n<r;n+=4)u=u-d+i(h,n)|0;var p;n<h.length&&(u=u-d+i(h+"XXX",n)|0),c=s(c,16,4,(p=u,String.fromCharCode(p>>24&255,p>>16&255,p>>8&255,255&p)));const g=`@font-face {font-family:"${h}";src:${`url(data:font/opentype;base64,${btoa(c)});`}}`;this.insertRule(g);const f=this._document.createElement("div");f.style.visibility="hidden",f.style.width=f.style.height="10px",f.style.position="absolute",f.style.top=f.style.left="0px";for(const m of[t.loadedName,h]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=m,f.append(t)}this._document.body.append(f),function t(e,i){if(++l>30)return Hu("Load test font never loaded."),void i();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?i():setTimeout(t.bind(null,e,i))}(h,()=>{f.remove(),e.complete()})}}Gi=new WeakMap;class Ag{constructor(t,e=null,i,s){Gd(this,qi),this.compiledGlyphs=Object.create(null),qd(this,qi,t),this._inspectFont=e,i&&Object.assign(this,i),s&&(this.charProcOperatorList=s)}createNativeFontFace(){var t;if(!this.data||this.disableFontFace)return null;let e;if(this.cssFontInfo){const t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}else e=new FontFace(this.loadedName,this.data,{});return null==(t=this._inspectFont)||t.call(this,this),e}createFontFaceRule(){var t;if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${dp(this.data)});`;let i;if(this.cssFontInfo){let t=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(t+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),i=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${t}src:${e}}`}else i=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return null==(t=this._inspectFont)||t.call(this,this,e),i}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];const i=this.loadedName+"_path_"+e;let s;try{s=t.get(i)}catch(r){Hu(`getPathGenerator - ignoring character: "${r}".`)}const n=new Path2D(s||"");return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=n}get black(){return Vd(this,qi).black}get bold(){return Vd(this,qi).bold}get disableFontFace(){return Vd(this,qi).disableFontFace??!1}get fontExtraProperties(){return Vd(this,qi).fontExtraProperties??!1}get isInvalidPDFjsFont(){return Vd(this,qi).isInvalidPDFjsFont}get isType3Font(){return Vd(this,qi).isType3Font}get italic(){return Vd(this,qi).italic}get missingFile(){return Vd(this,qi).missingFile}get remeasure(){return Vd(this,qi).remeasure}get vertical(){return Vd(this,qi).vertical}get ascent(){return Vd(this,qi).ascent}get defaultWidth(){return Vd(this,qi).defaultWidth}get descent(){return Vd(this,qi).descent}get bbox(){return Vd(this,qi).bbox}get fontMatrix(){return Vd(this,qi).fontMatrix}get fallbackName(){return Vd(this,qi).fallbackName}get loadedName(){return Vd(this,qi).loadedName}get mimetype(){return Vd(this,qi).mimetype}get name(){return Vd(this,qi).name}get data(){return Vd(this,qi).data}clearData(){Vd(this,qi).clearData()}get cssFontInfo(){return Vd(this,qi).cssFontInfo}get systemFontInfo(){return Vd(this,qi).systemFontInfo}get defaultVMetrics(){return Vd(this,qi).defaultVMetrics}}function _g(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}qi=new WeakMap;const xg=t=>"object"==typeof t&&Number.isInteger(null==t?void 0:t.num)&&t.num>=0&&Number.isInteger(null==t?void 0:t.gen)&&t.gen>=0,kg=function(t,e,i){if(!Array.isArray(i)||i.length<2)return!1;const[s,n,...r]=i;if(!t(s)&&!Number.isInteger(s))return!1;if(!e(n))return!1;const a=r.length;let o=!0;switch(n.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return 0===a;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(4!==a)return!1;o=!1;break;default:return!1}for(const l of r)if(!("number"==typeof l||o&&null===l))return!1;return!0}.bind(null,xg,t=>"object"==typeof t&&"string"==typeof(null==t?void 0:t.name));class Sg{constructor(){Gd(this,Xi,new Map),Gd(this,Yi,Promise.resolve())}postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};Vd(this,Yi).then(()=>{for(const[t]of Vd(this,Xi))t.call(this,i)})}addEventListener(t,e,i=null){let s=null;if((null==i?void 0:i.signal)instanceof AbortSignal){const{signal:n}=i;if(n.aborted)return void Hu("LoopbackPort - cannot use an `aborted` signal.");const r=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}Vd(this,Xi).set(e,s)}removeEventListener(t,e){const i=Vd(this,Xi).get(e);null==i||i(),Vd(this,Xi).delete(e)}terminate(){for(const[,t]of Vd(this,Xi))null==t||t();Vd(this,Xi).clear()}}Xi=new WeakMap,Yi=new WeakMap;const Mg=1,Eg=2,Cg=1,Tg=2,Pg=3,Dg=4,Rg=5,Ig=6,Lg=7,Fg=8;function Ng(){}function Wg(t){if(t instanceof Zu||t instanceof Ku||t instanceof Xu||t instanceof Qu||t instanceof Yu)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||$u('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new Zu(t.message);case"InvalidPDFException":return new Ku(t.message);case"PasswordException":return new Xu(t.message,t.code);case"ResponseException":return new Qu(t.message,t.status,t.missing);case"UnknownErrorException":return new Yu(t.message,t.details)}return new Yu(t.message,t.toString())}class Bg{constructor(t,e,i){Gd(this,Qi),Gd(this,Ki,new AbortController),this.sourceName=t,this.targetName=e,this.comObj=i,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),i.addEventListener("message",Xd(this,Qi,Ji).bind(this),{signal:Vd(this,Ki).signal})}on(t,e){const i=this.actionHandler;if(i[t])throw new Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){const s=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[s]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(r){n.reject(r)}return n.promise}sendWithStream(t,e,i,s){const n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{const l=Promise.withResolvers();return this.streamControllers[n]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:i.desiredSize},s),l.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[n].pullCall=e,o.postMessage({sourceName:r,targetName:a,stream:Ig,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{ju(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[n].cancelCall=e,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:Cg,streamId:n,reason:Wg(t)}),e.promise}},i)}destroy(){var t;null==(t=Vd(this,Ki))||t.abort(),qd(this,Ki,null)}}Ki=new WeakMap,Qi=new WeakSet,Ji=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void Xd(this,Qi,ts).call(this,t);if(t.callback){const e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],t.callback===Mg)i.resolve(t.data);else{if(t.callback!==Eg)throw new Error("Unexpected callback case");i.reject(Wg(t.reason))}return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const i=this.sourceName,s=t.sourceName,n=this.comObj;return void Promise.try(e,t.data).then(function(e){n.postMessage({sourceName:i,targetName:s,callback:Mg,callbackId:t.callbackId,data:e})},function(e){n.postMessage({sourceName:i,targetName:s,callback:Eg,callbackId:t.callbackId,reason:Wg(e)})})}t.streamId?Xd(this,Qi,Zi).call(this,t):e(t.data)},Zi=function(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(t,r=1,a){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=r,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:i,targetName:s,stream:Dg,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Pg,streamId:e}),delete r.streamSinks[e])},error(t){ju(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Rg,streamId:e,reason:Wg(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(a,t.data,o).then(function(){n.postMessage({sourceName:i,targetName:s,stream:Fg,streamId:e,success:!0})},function(t){n.postMessage({sourceName:i,targetName:s,stream:Fg,streamId:e,reason:Wg(t)})})},ts=function(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case Fg:t.success?r.startCall.resolve():r.startCall.reject(Wg(t.reason));break;case Lg:t.success?r.pullCall.resolve():r.pullCall.reject(Wg(t.reason));break;case Ig:if(!a){n.postMessage({sourceName:i,targetName:s,stream:Lg,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||Ng).then(function(){n.postMessage({sourceName:i,targetName:s,stream:Lg,streamId:e,success:!0})},function(t){n.postMessage({sourceName:i,targetName:s,stream:Lg,streamId:e,reason:Wg(t)})});break;case Dg:if(ju(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case Pg:if(ju(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),Xd(this,Qi,es).call(this,r,e);break;case Rg:ju(r,"error should have stream controller"),r.controller.error(Wg(t.reason)),Xd(this,Qi,es).call(this,r,e);break;case Tg:t.success?r.cancelCall.resolve():r.cancelCall.reject(Wg(t.reason)),Xd(this,Qi,es).call(this,r,e);break;case Cg:if(!a)break;const o=Wg(t.reason);Promise.try(a.onCancel||Ng,o).then(function(){n.postMessage({sourceName:i,targetName:s,stream:Tg,streamId:e,success:!0})},function(t){n.postMessage({sourceName:i,targetName:s,stream:Tg,streamId:e,reason:Wg(t)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},es=async function(t,e){var i,s,n;await Promise.allSettled([null==(i=t.startCall)?void 0:i.promise,null==(s=t.pullCall)?void 0:s.promise,null==(n=t.cancelCall)?void 0:n.promise]),delete this.streamControllers[e]};class Og{constructor({enableHWA:t=!1}){Gd(this,is,!1),qd(this,is,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!Vd(this,is)})}}reset(t,e,i){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){$u("Abstract method `_createCanvas` called.")}}is=new WeakMap;class Ug extends Og{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class Hg{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(t=>({cMapData:t,isCompressed:this.isCompressed})).catch(t=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){$u("Abstract method `_fetch` called.")}}class $g extends Hg{async _fetch(t){const e=await vp(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):ep(e)}}class jg{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,s,n){return"none"}destroy(t=!1){}}class zg extends jg{constructor({docId:t,ownerDocument:e=globalThis.document}){super(),Gd(this,cs),Gd(this,ss),Gd(this,ns),Gd(this,rs),Gd(this,as),Gd(this,os),Gd(this,ls),Gd(this,hs,0),qd(this,as,t),qd(this,os,e)}addFilter(t){if(!t)return"none";let e=Vd(this,cs,ds).get(t);if(e)return e;const[i,s,n]=Xd(this,cs,gs).call(this,t),r=1===t.length?i:`${i}${s}${n}`;if(e=Vd(this,cs,ds).get(r),e)return Vd(this,cs,ds).set(t,e),e;const a=`g_${Vd(this,as)}_transfer_map_${Yd(this,hs)._++}`,o=Xd(this,cs,fs).call(this,a);Vd(this,cs,ds).set(t,o),Vd(this,cs,ds).set(r,o);const l=Xd(this,cs,ws).call(this,a);return Xd(this,cs,ys).call(this,i,s,n,l),o}addHCMFilter(t,e){var i;const s=`${t}-${e}`,n="base";let r=Vd(this,cs,us).get(n);if((null==r?void 0:r.key)===s)return r.url;if(r?(null==(i=r.filter)||i.remove(),r.key=s,r.url="none",r.filter=null):(r={key:s,url:"none",filter:null},Vd(this,cs,us).set(n,r)),!t||!e)return r.url;const a=Xd(this,cs,_s).call(this,t);t=np.makeHexColor(...a);const o=Xd(this,cs,_s).call(this,e);if(e=np.makeHexColor(...o),Vd(this,cs,ps).style.color="","#000000"===t&&"#ffffff"===e||t===e)return r.url;const l=new Array(256);for(let p=0;p<=255;p++){const t=p/255;l[p]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}const h=l.join(","),c=`g_${Vd(this,as)}_hcm_filter`,d=r.filter=Xd(this,cs,ws).call(this,c);Xd(this,cs,ys).call(this,h,h,h,d),Xd(this,cs,vs).call(this,d);const u=(t,e)=>{const i=a[t]/255,s=o[t]/255,n=new Array(e+1);for(let r=0;r<=e;r++)n[r]=i+r/e*(s-i);return n.join(",")};return Xd(this,cs,ys).call(this,u(0,5),u(1,5),u(2,5),d),r.url=Xd(this,cs,fs).call(this,c),r.url}addAlphaFilter(t){let e=Vd(this,cs,ds).get(t);if(e)return e;const[i]=Xd(this,cs,gs).call(this,[t]),s=`alpha_${i}`;if(e=Vd(this,cs,ds).get(s),e)return Vd(this,cs,ds).set(t,e),e;const n=`g_${Vd(this,as)}_alpha_map_${Yd(this,hs)._++}`,r=Xd(this,cs,fs).call(this,n);Vd(this,cs,ds).set(t,r),Vd(this,cs,ds).set(s,r);const a=Xd(this,cs,ws).call(this,n);return Xd(this,cs,As).call(this,i,a),r}addLuminosityFilter(t){let e,i,s=Vd(this,cs,ds).get(t||"luminosity");if(s)return s;if(t?([e]=Xd(this,cs,gs).call(this,[t]),i=`luminosity_${e}`):i="luminosity",s=Vd(this,cs,ds).get(i),s)return Vd(this,cs,ds).set(t,s),s;const n=`g_${Vd(this,as)}_luminosity_map_${Yd(this,hs)._++}`,r=Xd(this,cs,fs).call(this,n);Vd(this,cs,ds).set(t,r),Vd(this,cs,ds).set(i,r);const a=Xd(this,cs,ws).call(this,n);return Xd(this,cs,ms).call(this,a),t&&Xd(this,cs,As).call(this,e,a),r}addHighlightHCMFilter(t,e,i,s,n){var r;const a=`${e}-${i}-${s}-${n}`;let o=Vd(this,cs,us).get(t);if((null==o?void 0:o.key)===a)return o.url;if(o?(null==(r=o.filter)||r.remove(),o.key=a,o.url="none",o.filter=null):(o={key:a,url:"none",filter:null},Vd(this,cs,us).set(t,o)),!e||!i)return o.url;const[l,h]=[e,i].map(Xd(this,cs,_s).bind(this));let c=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),d=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),[u,p]=[s,n].map(Xd(this,cs,_s).bind(this));d<c&&([c,d,u,p]=[d,c,p,u]),Vd(this,cs,ps).style.color="";const g=(t,e,i)=>{const s=new Array(256),n=(d-c)/i,r=t/255,a=(e-t)/(255*i);let o=0;for(let l=0;l<=i;l++){const t=Math.round(c+l*n),e=r+l*a;for(let i=o;i<=t;i++)s[i]=e;o=t+1}for(let l=o;l<256;l++)s[l]=s[o-1];return s.join(",")},f=`g_${Vd(this,as)}_hcm_${t}_filter`,m=o.filter=Xd(this,cs,ws).call(this,f);return Xd(this,cs,vs).call(this,m),Xd(this,cs,ys).call(this,g(u[0],p[0],5),g(u[1],p[1],5),g(u[2],p[2],5),m),o.url=Xd(this,cs,fs).call(this,f),o.url}destroy(t=!1){var e,i,s,n;t&&(null==(e=Vd(this,ls))?void 0:e.size)||(null==(i=Vd(this,rs))||i.parentNode.parentNode.remove(),qd(this,rs,null),null==(s=Vd(this,ns))||s.clear(),qd(this,ns,null),null==(n=Vd(this,ls))||n.clear(),qd(this,ls,null),qd(this,hs,0))}}ss=new WeakMap,ns=new WeakMap,rs=new WeakMap,as=new WeakMap,os=new WeakMap,ls=new WeakMap,hs=new WeakMap,cs=new WeakSet,ds=function(){return Vd(this,ns)||qd(this,ns,new Map)},us=function(){return Vd(this,ls)||qd(this,ls,new Map)},ps=function(){if(!Vd(this,rs)){const t=Vd(this,os).createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const i=Vd(this,os).createElementNS(gp,"svg");i.setAttribute("width",0),i.setAttribute("height",0),qd(this,rs,Vd(this,os).createElementNS(gp,"defs")),t.append(i),i.append(Vd(this,rs)),Vd(this,os).body.append(t)}return Vd(this,rs)},gs=function(t){if(1===t.length){const e=t[0],i=new Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;const s=i.join(",");return[s,s,s]}const[e,i,s]=t,n=new Array(256),r=new Array(256),a=new Array(256);for(let o=0;o<256;o++)n[o]=e[o]/255,r[o]=i[o]/255,a[o]=s[o]/255;return[n.join(","),r.join(","),a.join(",")]},fs=function(t){if(void 0===Vd(this,ss)){qd(this,ss,"");const t=Vd(this,os).URL;t!==Vd(this,os).baseURI&&(yp(t)?Hu('#createUrl: ignore "data:"-URL for performance reasons.'):qd(this,ss,Vu(t,"")))}return`url(${Vd(this,ss)}#${t})`},ms=function(t){const e=Vd(this,os).createElementNS(gp,"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)},vs=function(t){const e=Vd(this,os).createElementNS(gp,"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)},ws=function(t){const e=Vd(this,os).createElementNS(gp,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),Vd(this,cs,ps).append(e),e},bs=function(t,e,i){const s=Vd(this,os).createElementNS(gp,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)},ys=function(t,e,i,s){const n=Vd(this,os).createElementNS(gp,"feComponentTransfer");s.append(n),Xd(this,cs,bs).call(this,n,"feFuncR",t),Xd(this,cs,bs).call(this,n,"feFuncG",e),Xd(this,cs,bs).call(this,n,"feFuncB",i)},As=function(t,e){const i=Vd(this,os).createElementNS(gp,"feComponentTransfer");e.append(i),Xd(this,cs,bs).call(this,i,"feFuncA",t)},_s=function(t){return Vd(this,cs,ps).style.color=t,Pp(getComputedStyle(Vd(this,cs,ps)).getPropertyValue("color"))};class Vg{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){$u("Abstract method `_fetch` called.")}}class Gg extends Vg{async _fetch(t){const e=await vp(t,"arraybuffer");return new Uint8Array(e)}}class qg{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw new Error("Wasm filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw new Error(`Unable to load wasm data at: ${e}`)})}async _fetch(t){$u("Abstract method `_fetch` called.")}}class Xg extends qg{async _fetch(t){const e=await vp(t,"arraybuffer");return new Uint8Array(e)}}async function Yg(t){const e=process.getBuiltinModule("fs"),i=await e.promises.readFile(t);return new Uint8Array(i)}iu&&Hu("Please use the `legacy` build in Node.js environments.");class Kg extends jg{}class Qg extends Og{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class Jg extends Hg{async _fetch(t){return Yg(t)}}class Zg extends Vg{async _fetch(t){return Yg(t)}}class tf extends qg{async _fetch(t){return Yg(t)}}const ef="__forcedDependency",{floor:sf,ceil:nf}=Math;function rf(t,e,i,s,n,r){t[4*e+0]=Math.min(t[4*e+0],i),t[4*e+1]=Math.min(t[4*e+1],s),t[4*e+2]=Math.max(t[4*e+2],n),t[4*e+3]=Math.max(t[4*e+3],r)}const af=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class of{constructor(t,e){Gd(this,xs),Gd(this,ks),qd(this,xs,t),qd(this,ks,e)}get length(){return Vd(this,xs).length}isEmpty(t){return Vd(this,xs)[t]===af}minX(t){return Vd(this,ks)[4*t+0]/256}minY(t){return Vd(this,ks)[4*t+1]/256}maxX(t){return(Vd(this,ks)[4*t+2]+1)/256}maxY(t){return(Vd(this,ks)[4*t+3]+1)/256}}xs=new WeakMap,ks=new WeakMap;const lf=(t,e)=>{if(!t)return;let i=t.get(e);return i||(i={dependencies:new Set,isRenderingOperation:!1},t.set(e,i)),i};class hf{constructor(t,e,i=!1){Gd(this,$s),Gd(this,Ss,{__proto__:null}),Gd(this,Ms,{__proto__:null,transform:[],moveText:[],sameLineText:[],[ef]:[]}),Gd(this,Es,new Map),Gd(this,Cs,[]),Gd(this,Ts,[]),Gd(this,Ps,[[1,0,0,1,0,0]]),Gd(this,Ds,[-1/0,-1/0,1/0,1/0]),Gd(this,Rs,new Float64Array([1/0,1/0,-1/0,-1/0])),Gd(this,Is,-1),Gd(this,Ls,new Set),Gd(this,Fs,new Map),Gd(this,Ns,new Map),Gd(this,Ws),Gd(this,Bs),Gd(this,Os),Gd(this,Us),Gd(this,Hs),qd(this,Ws,t.width),qd(this,Bs,t.height),Xd(this,$s,js).call(this,e),i&&qd(this,Hs,new Map)}growOperationsCount(t){t>=Vd(this,Us).length&&Xd(this,$s,js).call(this,t,Vd(this,Us))}save(t){return qd(this,Ss,{__proto__:Vd(this,Ss)}),qd(this,Ms,{__proto__:Vd(this,Ms),transform:{__proto__:Vd(this,Ms).transform},moveText:{__proto__:Vd(this,Ms).moveText},sameLineText:{__proto__:Vd(this,Ms).sameLineText},[ef]:{__proto__:Vd(this,Ms)[ef]}}),qd(this,Ds,{__proto__:Vd(this,Ds)}),Vd(this,Cs).push(t),this}restore(t){var e;const i=Object.getPrototypeOf(Vd(this,Ss));if(null===i)return this;qd(this,Ss,i),qd(this,Ms,Object.getPrototypeOf(Vd(this,Ms))),qd(this,Ds,Object.getPrototypeOf(Vd(this,Ds)));const s=Vd(this,Cs).pop();return void 0!==s&&(null==(e=lf(Vd(this,Hs),t))||e.dependencies.add(s),Vd(this,Us)[t]=Vd(this,Us)[s]),this}recordOpenMarker(t){return Vd(this,Cs).push(t),this}getOpenMarker(){return 0===Vd(this,Cs).length?null:Vd(this,Cs).at(-1)}recordCloseMarker(t){var e;const i=Vd(this,Cs).pop();return void 0!==i&&(null==(e=lf(Vd(this,Hs),t))||e.dependencies.add(i),Vd(this,Us)[t]=Vd(this,Us)[i]),this}beginMarkedContent(t){return Vd(this,Ts).push(t),this}endMarkedContent(t){var e;const i=Vd(this,Ts).pop();return void 0!==i&&(null==(e=lf(Vd(this,Hs),t))||e.dependencies.add(i),Vd(this,Us)[t]=Vd(this,Us)[i]),this}pushBaseTransform(t){return Vd(this,Ps).push(np.multiplyByDOMMatrix(Vd(this,Ps).at(-1),t.getTransform())),this}popBaseTransform(){return Vd(this,Ps).length>1&&Vd(this,Ps).pop(),this}recordSimpleData(t,e){return Vd(this,Ss)[t]=e,this}recordIncrementalData(t,e){return Vd(this,Ms)[t].push(e),this}resetIncrementalData(t,e){return Vd(this,Ms)[t].length=0,this}recordNamedData(t,e){return Vd(this,Es).set(t,e),this}recordSimpleDataFromNamed(t,e,i){Vd(this,Ss)[t]=Vd(this,Es).get(e)??i}recordFutureForcedDependency(t,e){return this.recordIncrementalData(ef,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in Vd(this,Ss)&&this.recordFutureForcedDependency(e,Vd(this,Ss)[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of Vd(this,Ls))this.recordFutureForcedDependency(ef,t);return this}resetBBox(t){return Vd(this,Is)!==t&&(qd(this,Is,t),Vd(this,Rs)[0]=1/0,Vd(this,Rs)[1]=1/0,Vd(this,Rs)[2]=-1/0,Vd(this,Rs)[3]=-1/0),this}recordClipBox(t,e,i,s,n,r){const a=np.multiplyByDOMMatrix(Vd(this,Ps).at(-1),e.getTransform()),o=[1/0,1/0,-1/0,-1/0];np.axialAlignedBoundingBox([i,n,s,r],a,o);const l=np.intersect(Vd(this,Ds),o);return l?(Vd(this,Ds)[0]=l[0],Vd(this,Ds)[1]=l[1],Vd(this,Ds)[2]=l[2],Vd(this,Ds)[3]=l[3]):(Vd(this,Ds)[0]=Vd(this,Ds)[1]=1/0,Vd(this,Ds)[2]=Vd(this,Ds)[3]=-1/0),this}recordBBox(t,e,i,s,n,r){const a=Vd(this,Ds);if(a[0]===1/0)return this;const o=np.multiplyByDOMMatrix(Vd(this,Ps).at(-1),e.getTransform());if(a[0]===-1/0)return np.axialAlignedBoundingBox([i,n,s,r],o,Vd(this,Rs)),this;const l=[1/0,1/0,-1/0,-1/0];return np.axialAlignedBoundingBox([i,n,s,r],o,l),Vd(this,Rs)[0]=Math.min(Vd(this,Rs)[0],Math.max(l[0],a[0])),Vd(this,Rs)[1]=Math.min(Vd(this,Rs)[1],Math.max(l[1],a[1])),Vd(this,Rs)[2]=Math.max(Vd(this,Rs)[2],Math.min(l[2],a[2])),Vd(this,Rs)[3]=Math.max(Vd(this,Rs)[3],Math.min(l[3],a[3])),this}recordCharacterBBox(t,e,i,s=1,n=0,r=0,a){const o=i.bbox;let l,h;if(o&&(l=o[2]!==o[0]&&o[3]!==o[1]&&Vd(this,Ns).get(i),!1!==l&&(h=[0,0,0,0],np.axialAlignedBoundingBox(o,i.fontMatrix,h),1===s&&0===n&&0===r||np.scaleMinMax([s,0,0,-s,n,r],h),l)))return this.recordBBox(t,e,h[0],h[2],h[1],h[3]);if(!a)return this.recordFullPageBBox(t);const c=a();return o&&h&&void 0===l&&(l=h[0]<=n-c.actualBoundingBoxLeft&&h[2]>=n+c.actualBoundingBoxRight&&h[1]<=r-c.actualBoundingBoxAscent&&h[3]>=r+c.actualBoundingBoxDescent,Vd(this,Ns).set(i,l),l)?this.recordBBox(t,e,h[0],h[2],h[1],h[3]):this.recordBBox(t,e,n-c.actualBoundingBoxLeft,n+c.actualBoundingBoxRight,r-c.actualBoundingBoxAscent,r+c.actualBoundingBoxDescent)}recordFullPageBBox(t){return Vd(this,Rs)[0]=Math.max(0,Vd(this,Ds)[0]),Vd(this,Rs)[1]=Math.max(0,Vd(this,Ds)[1]),Vd(this,Rs)[2]=Math.min(Vd(this,Ws),Vd(this,Ds)[2]),Vd(this,Rs)[3]=Math.min(Vd(this,Bs),Vd(this,Ds)[3]),this}getSimpleIndex(t){return Vd(this,Ss)[t]}recordDependencies(t,e){const i=Vd(this,Ls),s=Vd(this,Ss),n=Vd(this,Ms);for(const r of e)r in Vd(this,Ss)?i.add(s[r]):r in n&&n[r].forEach(i.add,i);return this}recordNamedDependency(t,e){return Vd(this,Es).has(e)&&Vd(this,Ls).add(Vd(this,Es).get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[ef]),Vd(this,Hs)){const e=lf(Vd(this,Hs),t),{dependencies:i}=e;Vd(this,Ls).forEach(i.add,i),Vd(this,Cs).forEach(i.add,i),Vd(this,Ts).forEach(i.add,i),i.delete(t),e.isRenderingOperation=!0}if(Vd(this,Is)===t){const i=sf(256*Vd(this,Rs)[0]/Vd(this,Ws)),s=sf(256*Vd(this,Rs)[1]/Vd(this,Bs)),n=nf(256*Vd(this,Rs)[2]/Vd(this,Ws)),r=nf(256*Vd(this,Rs)[3]/Vd(this,Bs));rf(Vd(this,Os),t,i,s,n,r);for(const e of Vd(this,Ls))e!==t&&rf(Vd(this,Os),e,i,s,n,r);for(const e of Vd(this,Cs))e!==t&&rf(Vd(this,Os),e,i,s,n,r);for(const e of Vd(this,Ts))e!==t&&rf(Vd(this,Os),e,i,s,n,r);e||(Vd(this,Ls).clear(),qd(this,Is,-1))}return this}recordShowTextOperation(t,e=!1){const i=Array.from(Vd(this,Ls));this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const s of i)this.recordIncrementalData("sameLineText",s);return this}bboxToClipBoxDropOperation(t,e=!1){return Vd(this,Is)===t&&(qd(this,Is,-1),Vd(this,Ds)[0]=Math.max(Vd(this,Ds)[0],Vd(this,Rs)[0]),Vd(this,Ds)[1]=Math.max(Vd(this,Ds)[1],Vd(this,Rs)[1]),Vd(this,Ds)[2]=Math.min(Vd(this,Ds)[2],Vd(this,Rs)[2]),Vd(this,Ds)[3]=Math.min(Vd(this,Ds)[3],Vd(this,Rs)[3]),e||Vd(this,Ls).clear()),this}_takePendingDependencies(){const t=Vd(this,Ls);return qd(this,Ls,new Set),t}_extractOperation(t){const e=Vd(this,Fs).get(t);return Vd(this,Fs).delete(t),e}_pushPendingDependencies(t){for(const e of t)Vd(this,Ls).add(e)}take(){return Vd(this,Ns).clear(),new of(Vd(this,Us),Vd(this,Os))}takeDebugMetadata(){return Vd(this,Hs)}}Ss=new WeakMap,Ms=new WeakMap,Es=new WeakMap,Cs=new WeakMap,Ts=new WeakMap,Ps=new WeakMap,Ds=new WeakMap,Rs=new WeakMap,Is=new WeakMap,Ls=new WeakMap,Fs=new WeakMap,Ns=new WeakMap,Ws=new WeakMap,Bs=new WeakMap,Os=new WeakMap,Us=new WeakMap,Hs=new WeakMap,$s=new WeakSet,js=function(t,e){const i=new ArrayBuffer(4*t);qd(this,Os,new Uint8ClampedArray(i)),qd(this,Us,new Uint32Array(i)),e&&e.length>0?(Vd(this,Us).set(e),Vd(this,Us).fill(af,e.length)):Vd(this,Us).fill(af)};zs=new WeakMap,Vs=new WeakMap,Gs=new WeakMap,qs=new WeakMap,Xs=new WeakMap;let cf=class t{constructor(e,i,s){if(Gd(this,zs),Gd(this,Vs),Gd(this,Gs),Gd(this,qs,0),Gd(this,Xs,0),e instanceof t&&Vd(e,Gs)===!!s)return e;qd(this,zs,e),qd(this,Vs,i),qd(this,Gs,!!s)}growOperationsCount(){throw new Error("Unreachable")}save(t){return Yd(this,Xs)._++,Vd(this,zs).save(Vd(this,Vs)),this}restore(t){return Vd(this,Xs)>0&&(Vd(this,zs).restore(Vd(this,Vs)),Yd(this,Xs)._--),this}recordOpenMarker(t){return Yd(this,qs)._++,this}getOpenMarker(){return Vd(this,qs)>0?Vd(this,Vs):Vd(this,zs).getOpenMarker()}recordCloseMarker(t){return Yd(this,qs)._--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return Vd(this,zs).pushBaseTransform(t),this}popBaseTransform(){return Vd(this,zs).popBaseTransform(),this}recordSimpleData(t,e){return Vd(this,zs).recordSimpleData(t,Vd(this,Vs)),this}recordIncrementalData(t,e){return Vd(this,zs).recordIncrementalData(t,Vd(this,Vs)),this}resetIncrementalData(t,e){return Vd(this,zs).resetIncrementalData(t,Vd(this,Vs)),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,i){return Vd(this,zs).recordSimpleDataFromNamed(t,e,Vd(this,Vs)),this}recordFutureForcedDependency(t,e){return Vd(this,zs).recordFutureForcedDependency(t,Vd(this,Vs)),this}inheritSimpleDataAsFutureForcedDependencies(t){return Vd(this,zs).inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return Vd(this,zs).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return Vd(this,Gs)||Vd(this,zs).resetBBox(Vd(this,Vs)),this}recordClipBox(t,e,i,s,n,r){return Vd(this,Gs)||Vd(this,zs).recordClipBox(Vd(this,Vs),e,i,s,n,r),this}recordBBox(t,e,i,s,n,r){return Vd(this,Gs)||Vd(this,zs).recordBBox(Vd(this,Vs),e,i,s,n,r),this}recordCharacterBBox(t,e,i,s,n,r,a){return Vd(this,Gs)||Vd(this,zs).recordCharacterBBox(Vd(this,Vs),e,i,s,n,r,a),this}recordFullPageBBox(t){return Vd(this,Gs)||Vd(this,zs).recordFullPageBBox(Vd(this,Vs)),this}getSimpleIndex(t){return Vd(this,zs).getSimpleIndex(t)}recordDependencies(t,e){return Vd(this,zs).recordDependencies(Vd(this,Vs),e),this}recordNamedDependency(t,e){return Vd(this,zs).recordNamedDependency(Vd(this,Vs),e),this}recordOperation(t){return Vd(this,zs).recordOperation(Vd(this,Vs),!0),this}recordShowTextOperation(t){return Vd(this,zs).recordShowTextOperation(Vd(this,Vs),!0),this}bboxToClipBoxDropOperation(t){return Vd(this,Gs)||Vd(this,zs).bboxToClipBoxDropOperation(Vd(this,Vs),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};const df=["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],uf=["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],pf=["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],gf=["filter","fillColor","fillAlpha"],ff=["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],mf=["transform"],vf=["transform","fillColor"],wf="Fill",bf="Stroke",yf="Shading";function Af(t,e){if(!e)return;const i=e[2]-e[0],s=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],i,s),t.clip(n)}class _f{isModifyingCurrentTransform(){return!1}getPattern(){$u("Abstract method `getPattern` called.")}}class xf extends _f{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;"axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const i of this._colorStops)e.addColorStop(i[0],i[1]);return e}getPattern(t,e,i,s){let n;if(s===bf||s===wf){const r=e.current.getClippedPathBoundingBox(s,Dp(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,l=e.cachedCanvases.getCanvas("pattern",a,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-r[0],-r[1]),i=np.transform(i,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),Af(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),n=t.createPattern(l.canvas,"no-repeat");const c=new DOMMatrix(i);n.setTransform(c)}else Af(t,this._bbox),n=this._createGradient(t);return n}}function kf(t,e,i,s,n,r,a,o){const l=e.coords,h=e.colors,c=t.data,d=4*t.width;let u;l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=r,r=a,a=u),l[s+1]>l[n+1]&&(u=s,s=n,n=u,u=a,a=o,o=u),l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=r,r=a,a=u);const p=(l[i]+e.offsetX)*e.scaleX,g=(l[i+1]+e.offsetY)*e.scaleY,f=(l[s]+e.offsetX)*e.scaleX,m=(l[s+1]+e.offsetY)*e.scaleY,v=(l[n]+e.offsetX)*e.scaleX,w=(l[n+1]+e.offsetY)*e.scaleY;if(g>=w)return;const b=h[r],y=h[r+1],A=h[r+2],_=h[a],x=h[a+1],k=h[a+2],S=h[o],M=h[o+1],E=h[o+2],C=Math.round(g),T=Math.round(w);let P,D,R,I,L,F,N,W;for(let B=C;B<=T;B++){if(B<m){const t=B<g?0:(g-B)/(g-m);P=p-(p-f)*t,D=b-(b-_)*t,R=y-(y-x)*t,I=A-(A-k)*t}else{let t;t=B>w?1:m===w?0:(m-B)/(m-w),P=f-(f-v)*t,D=_-(_-S)*t,R=x-(x-M)*t,I=k-(k-E)*t}let t;t=B<g?0:B>w?1:(g-B)/(g-w),L=p-(p-v)*t,F=b-(b-S)*t,N=y-(y-M)*t,W=A-(A-E)*t;const e=Math.round(Math.min(P,L)),i=Math.round(Math.max(P,L));let s=d*B+4*e;for(let n=e;n<=i;n++)t=(P-n)/(P-L),t<0?t=0:t>1&&(t=1),c[s++]=D-(D-F)*t|0,c[s++]=R-(R-N)*t|0,c[s++]=I-(I-W)*t|0,c[s++]=255}}function Sf(t,e,i){const s=e.coords,n=e.colors;let r,a;switch(e.type){case"lattice":const o=e.verticesPerRow,l=Math.floor(s.length/o)-1,h=o-1;for(r=0;r<l;r++){let e=r*o;for(let r=0;r<h;r++,e++)kf(t,i,s[e],s[e+1],s[e+o],n[e],n[e+1],n[e+o]),kf(t,i,s[e+o+1],s[e+1],s[e+o],n[e+o+1],n[e+1],n[e+o])}break;case"triangles":for(r=0,a=s.length;r<a;r+=3)kf(t,i,s[r],s[r+1],s[r+2],n[r],n[r+1],n[r+2]);break;default:throw new Error("illegal figure")}}class Mf extends _f{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,i){const s=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-s,a=Math.ceil(this._bounds[3])-n,o=Math.min(Math.ceil(Math.abs(r*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(a*t[1]*1.1)),3e3),h=r/o,c=a/l,d={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-n,scaleX:1/h,scaleY:1/c},u=o+4,p=l+4,g=i.getCanvas("mesh",u,p),f=g.context,m=f.createImageData(o,l);if(e){const t=m.data;for(let i=0,s=t.length;i<s;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}for(const v of this._figures)Sf(m,v,d);f.putImageData(m,2,2);return{canvas:g.canvas,offsetX:s-2*h,offsetY:n-2*c,scaleX:h,scaleY:c}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,s){Af(t,this._bbox);const n=new Float32Array(2);if(s===yf)np.singularValueDecompose2dScale(Dp(t),n);else if(this.matrix){np.singularValueDecompose2dScale(this.matrix,n);const[t,i]=n;np.singularValueDecompose2dScale(e.baseTransform,n),n[0]*=t,n[1]*=i}else np.singularValueDecompose2dScale(e.baseTransform,n);const r=this._createMeshCanvas(n,s===yf?null:this._background,e.cachedCanvases);return s!==yf&&(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 Ef extends _f{getPattern(){return"hotpink"}}const Cf=1,Tf=2,Pf=class t{constructor(t,e,i,s){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=s}createPatternCanvas(t,e){var i,s;const{bbox:n,operatorList:r,paintType:a,tilingType:o,color:l,canvasGraphicsFactory:h}=this;let{xstep:c,ystep:d}=this;c=Math.abs(c),d=Math.abs(d),Uu("TilingType: "+o);const u=n[0],p=n[1],g=n[2],f=n[3],m=g-u,v=f-p,w=new Float32Array(2);np.singularValueDecompose2dScale(this.matrix,w);const[b,y]=w;np.singularValueDecompose2dScale(this.baseTransform,w);const A=b*w[0],_=y*w[1];let x=m,k=v,S=!1,M=!1;const E=Math.ceil(c*A),C=Math.ceil(d*_);E>=Math.ceil(m*A)?x=c:S=!0,C>=Math.ceil(v*_)?k=d:M=!0;const T=this.getSizeAndScale(x,this.ctx.canvas.width,A),P=this.getSizeAndScale(k,this.ctx.canvas.height,_),D=t.cachedCanvases.getCanvas("pattern",T.size,P.size),R=D.context,I=h.createCanvasGraphics(R,e);if(I.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(I,a,l),R.translate(-T.scale*u,-P.scale*p),I.transform(0,T.scale,0,0,P.scale,0,0),R.save(),null==(i=I.dependencyTracker)||i.save(),this.clipBbox(I,u,p,g,f),I.baseTransform=Dp(I.ctx),I.executeOperatorList(r),I.endDrawing(),null==(s=I.dependencyTracker)||s.restore(),R.restore(),S||M){const e=D.canvas;S&&(x=c),M&&(k=d);const i=this.getSizeAndScale(x,this.ctx.canvas.width,A),s=this.getSizeAndScale(k,this.ctx.canvas.height,_),n=i.size,r=s.size,a=t.cachedCanvases.getCanvas("pattern-workaround",n,r),o=a.context,l=S?Math.floor(m/c):0,h=M?Math.floor(v/d):0;for(let t=0;t<=l;t++)for(let i=0;i<=h;i++)o.drawImage(e,n*t,r*i,n,r,0,0,n,r);return{canvas:a.canvas,scaleX:i.scale,scaleY:s.scale,offsetX:u,offsetY:p}}return{canvas:D.canvas,scaleX:T.scale,scaleY:P.scale,offsetX:u,offsetY:p}}getSizeAndScale(e,i,s){const n=Math.max(t.MAX_PATTERN_SIZE,i);let r=Math.ceil(e*s);return r>=n?r=n:s=r/e,{scale:s,size:r}}clipBbox(t,e,i,s,n){const r=s-e,a=n-i;t.ctx.rect(e,i,r,a),np.axialAlignedBoundingBox([e,i,s,n],Dp(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const s=t.ctx,n=t.current;switch(e){case Cf:const{fillStyle:t,strokeStyle:r}=this.ctx;s.fillStyle=n.fillColor=t,s.strokeStyle=n.strokeColor=r;break;case Tf:s.fillStyle=s.strokeStyle=i,n.fillColor=n.strokeColor=i;break;default:throw new Ju(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,s,n){let r=i;s!==yf&&(r=np.transform(r,e.baseTransform),this.matrix&&(r=np.transform(r,this.matrix)));const a=this.createPatternCanvas(e,n);let o=new DOMMatrix(r);o=o.translate(a.offsetX,a.offsetY),o=o.scale(1/a.scaleX,1/a.scaleY);const l=t.createPattern(a.canvas,"repeat");return l.setTransform(o),l}};jd(Pf,"MAX_PATTERN_SIZE",3e3);let Df=Pf;function Rf({src:t,srcPos:e=0,dest:i,width:s,height:n,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=ip.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],c=s>>3,d=7&s,u=t.length;i=new Uint32Array(i.buffer);let p=0;for(let g=0;g<n;g++){for(const n=e+c;e<n;e++){const s=e<u?t[e]:255;i[p++]=128&s?h:l,i[p++]=64&s?h:l,i[p++]=32&s?h:l,i[p++]=16&s?h:l,i[p++]=8&s?h:l,i[p++]=4&s?h:l,i[p++]=2&s?h:l,i[p++]=1&s?h:l}if(0===d)continue;const s=e<u?t[e++]:255;for(let t=0;t<d;t++)i[p++]=s&1<<7-t?h:l}return{srcPos:e,destPos:p}}const If=16,Lf=new DOMMatrix,Ff=new Float32Array(2),Nf=new Float32Array([1/0,1/0,-1/0,-1/0]);class Wf{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let s;return void 0!==this.cache[t]?(s=this.cache[t],this.canvasFactory.reset(s,e,i)):(s=this.canvasFactory.create(e,i),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function Bf(t,e,i,s,n,r,a,o,l,h){const[c,d,u,p,g,f]=Dp(t);if(0===d&&0===u){const m=a*c+g,v=Math.round(m),w=o*p+f,b=Math.round(w),y=(a+l)*c+g,A=Math.abs(Math.round(y)-v)||1,_=(o+h)*p+f,x=Math.abs(Math.round(_)-b)||1;return t.setTransform(Math.sign(c),0,0,Math.sign(p),v,b),t.drawImage(e,i,s,n,r,0,0,A,x),t.setTransform(c,d,u,p,g,f),[A,x]}if(0===c&&0===p){const m=o*u+g,v=Math.round(m),w=a*d+f,b=Math.round(w),y=(o+h)*u+g,A=Math.abs(Math.round(y)-v)||1,_=(a+l)*d+f,x=Math.abs(Math.round(_)-b)||1;return t.setTransform(0,Math.sign(d),Math.sign(u),0,v,b),t.drawImage(e,i,s,n,r,0,0,x,A),t.setTransform(c,d,u,p,g,f),[x,A]}t.drawImage(e,i,s,n,r,a,o,l,h);return[Math.hypot(c,d)*l,Math.hypot(u,p)*h]}class Of{constructor(t,e,i){jd(this,"alphaIsShape",!1),jd(this,"fontSize",0),jd(this,"fontSizeScale",1),jd(this,"textMatrix",null),jd(this,"textMatrixScale",1),jd(this,"fontMatrix",su),jd(this,"leading",0),jd(this,"x",0),jd(this,"y",0),jd(this,"lineX",0),jd(this,"lineY",0),jd(this,"charSpacing",0),jd(this,"wordSpacing",0),jd(this,"textHScale",1),jd(this,"textRenderingMode",wu),jd(this,"textRise",0),jd(this,"fillColor","#000000"),jd(this,"strokeColor","#000000"),jd(this,"patternFill",!1),jd(this,"patternStroke",!1),jd(this,"fillAlpha",1),jd(this,"strokeAlpha",1),jd(this,"lineWidth",1),jd(this,"activeSMask",null),jd(this,"transferMaps","none"),null==i||i(this),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=Nf.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=wf,e=null){const i=this.minMax.slice();if(t===bf){e||$u("Stroke bounding box must include transform."),np.singularValueDecompose2dScale(e,Ff);const t=Ff[0]*this.lineWidth/2,s=Ff[1]*this.lineWidth/2;i[0]-=t,i[1]-=s,i[2]+=t,i[3]+=s}return i}updateClipFromPath(){const t=np.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(Nf,0)}getClippedPathBoundingBox(t=wf,e=null){return np.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Uf(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,s=e.width,n=i%If,r=(i-n)/If,a=0===n?r:r+1,o=t.createImageData(s,If);let l,h=0;const c=e.data,d=o.data;let u,p,g,f;if(e.kind===ku.GRAYSCALE_1BPP){const e=c.byteLength,i=new Uint32Array(d.buffer,0,d.byteLength>>2),f=i.length,m=s+7>>3,v=4294967295,w=ip.isLittleEndian?4278190080:255;for(u=0;u<a;u++){for(g=u<r?If:n,l=0,p=0;p<g;p++){const t=e-h;let n=0;const r=t>m?s:8*t-7,a=-8&r;let o=0,d=0;for(;n<a;n+=8)d=c[h++],i[l++]=128&d?v:w,i[l++]=64&d?v:w,i[l++]=32&d?v:w,i[l++]=16&d?v:w,i[l++]=8&d?v:w,i[l++]=4&d?v:w,i[l++]=2&d?v:w,i[l++]=1&d?v:w;for(;n<r;n++)0===o&&(d=c[h++],o=128),i[l++]=d&o?v:w,o>>=1}for(;l<f;)i[l++]=0;t.putImageData(o,0,u*If)}}else if(e.kind===ku.RGBA_32BPP){for(p=0,f=s*If*4,u=0;u<r;u++)d.set(c.subarray(h,h+f)),h+=f,t.putImageData(o,0,p),p+=If;u<a&&(f=s*n*4,d.set(c.subarray(h,h+f)),t.putImageData(o,0,p))}else{if(e.kind!==ku.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=If,f=s*g,u=0;u<a;u++){for(u>=r&&(g=n,f=s*g),l=0,p=f;p--;)d[l++]=c[h++],d[l++]=c[h++],d[l++]=c[h++],d[l++]=255;t.putImageData(o,0,u*If)}}}function Hf(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,s=e.width,n=i%If,r=(i-n)/If,a=0===n?r:r+1,o=t.createImageData(s,If);let l=0;const h=e.data,c=o.data;for(let d=0;d<a;d++){const e=d<r?If:n;({srcPos:l}=Rf({src:h,srcPos:l,dest:c,width:s,height:e,nonBlackColor:0})),t.putImageData(o,0,d*If)}}function $f(t,e){const i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of i)void 0!==t[s]&&(e[s]=t[s]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function jf(t){t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0);const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}function zf(t,e){if(e)return!0;np.singularValueDecompose2dScale(t,Ff);const i=Math.fround(Lp.pixelRatio*mp.PDF_TO_CSS_UNITS);return Ff[0]<=i&&Ff[1]<=i}const Vf=["butt","round","square"],Gf=["miter","round","bevel"],qf={},Xf={};Ys=new WeakSet,Ks=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},Qs=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}},Js=function(t,e,i){const s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s};let Yf=class t{constructor(t,e,i,s,n,{optionalContentConfig:r,markedContentStack:a=null},o,l,h){Gd(this,Ys),this.ctx=t,this.current=new Of(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=n,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=r,this.cachedCanvases=new Wf(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=h??null}getObject(t,e,i=null){var s;return"string"==typeof e?(null==(s=this.dependencyTracker)||s.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):i}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,i){const t=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...Dp(this.compositeCtx))}this.ctx.save(),jf(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=Dp(this.ctx)}executeOperatorList(t,e,i,s,n){var r;const a=t.argsArray,o=t.fnArray;let l=e||0;const h=a.length;if(h===l)return l;const c=h-l>10&&"function"==typeof i,d=c?Date.now()+15:0;let u=0;const p=this.commonObjs,g=this.objs;let f,m;for(;;){if(void 0!==s&&l===s.nextBreakPoint)return s.breakIt(l,i),l;if(!n||n(l))if(f=o[l],m=a[l]??null,f!==Ru.dependency)null===m?this[f](l):this[f](l,...m);else for(const t of m){null==(r=this.dependencyTracker)||r.recordNamedData(t,l);const e=t.startsWith("g_")?p:g;if(!e.has(t))return e.get(t,i),l}if(l++,l===h)return l;if(c&&++u>10){if(Date.now()>d)return i(),l;u=0}}}endDrawing(){Xd(this,Ys,Ks).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),Xd(this,Ys,Qs).call(this)}_scaleImage(t,e){const i=t.width??t.displayWidth,s=t.height??t.displayHeight;let n,r,a=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=i,h=s,c="prescale1";for(;a>2&&l>1||o>2&&h>1;){let e=l,i=h;a>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),a/=l/e),o>2&&h>1&&(i=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/i),n=this.cachedCanvases.getCanvas(c,e,i),r=n.context,r.clearRect(0,0,e,i),r.drawImage(t,0,0,l,h,0,0,e,i),t=n.canvas,l=e,h=i,c="prescale1"===c?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t,e){var i,s;const n=this.ctx,{width:r,height:a}=e,o=this.current.fillColor,l=this.current.patternFill,h=Dp(n);let c,d,u,p;if((e.bitmap||e.data)&&e.count>1){const s=e.bitmap||e.data.buffer;d=JSON.stringify(l?h:[h.slice(0,4),o]),c=this._cachedBitmapsMap.get(s),c||(c=new Map,this._cachedBitmapsMap.set(s,c));const n=c.get(d);if(n&&!l){const e=Math.round(Math.min(h[0],h[2])+h[4]),s=Math.round(Math.min(h[1],h[3])+h[5]);return null==(i=this.dependencyTracker)||i.recordDependencies(t,vf),{canvas:n,offsetX:e,offsetY:s}}u=n}u||(p=this.cachedCanvases.getCanvas("maskCanvas",r,a),Hf(p.context,e));let g=np.transform(h,[1/r,0,0,-1/a,0,0]);g=np.transform(g,[1,0,0,1,0,-a]);const f=Nf.slice();np.axialAlignedBoundingBox([0,0,r,a],g,f);const[m,v,w,b]=f,y=Math.round(w-m)||1,A=Math.round(b-v)||1,_=this.cachedCanvases.getCanvas("fillCanvas",y,A),x=_.context,k=m,S=v;x.translate(-k,-S),x.transform(...g),u||(u=this._scaleImage(p.canvas,Rp(x)),u=u.img,c&&l&&c.set(d,u)),x.imageSmoothingEnabled=zf(Dp(x),e.interpolate),Bf(x,u,0,0,u.width,u.height,0,0,r,a),x.globalCompositeOperation="source-in";const M=np.transform(Rp(x),[1,0,0,1,-k,-S]);return x.fillStyle=l?o.getPattern(n,this,M,wf,t):o,x.fillRect(0,0,r,a),c&&!l&&(this.cachedCanvases.delete("fillCanvas"),c.set(d,_.canvas)),null==(s=this.dependencyTracker)||s.recordDependencies(t,vf),{canvas:_.canvas,offsetX:Math.round(k),offsetY:Math.round(S)}}setLineWidth(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("lineCap",t),this.ctx.lineCap=Vf[e]}setLineJoin(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("lineJoin",t),this.ctx.lineJoin=Gf[e]}setMiterLimit(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,i){var s;null==(s=this.dependencyTracker)||s.recordSimpleData("dash",t);const n=this.ctx;void 0!==n.setLineDash&&(n.setLineDash(e),n.lineDashOffset=i)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){var i,s,n,r,a;for(const[o,l]of e)switch(o){case"LW":this.setLineWidth(t,l);break;case"LC":this.setLineCap(t,l);break;case"LJ":this.setLineJoin(t,l);break;case"ML":this.setMiterLimit(t,l);break;case"D":this.setDash(t,l[0],l[1]);break;case"RI":this.setRenderingIntent(t,l);break;case"FL":this.setFlatness(t,l);break;case"Font":this.setFont(t,l[0],l[1]);break;case"CA":null==(i=this.dependencyTracker)||i.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=l;break;case"ca":null==(s=this.dependencyTracker)||s.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=l;break;case"BM":null==(n=this.dependencyTracker)||n.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=l;break;case"SMask":null==(r=this.dependencyTracker)||r.recordSimpleData("SMask",t),this.current.activeSMask=l?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":null==(a=this.dependencyTracker)||a.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(l)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(t){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const e=this.ctx.canvas.width,i=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,n=this.cachedCanvases.getCanvas(s,e,i);this.suspendedCtx=this.ctx;const r=this.ctx=n.context;r.setTransform(this.suspendedCtx.getTransform()),$f(this.suspendedCtx,r),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,i){e.translate(t,i),this.__originalTranslate(t,i)},t.scale=function(t,i){e.scale(t,i),this.__originalScale(t,i)},t.transform=function(t,i,s,n,r,a){e.transform(t,i,s,n,r,a),this.__originalTransform(t,i,s,n,r,a)},t.setTransform=function(t,i,s,n,r,a){e.setTransform(t,i,s,n,r,a),this.__originalSetTransform(t,i,s,n,r,a)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,i){e.moveTo(t,i),this.__originalMoveTo(t,i)},t.lineTo=function(t,i){e.lineTo(t,i),this.__originalLineTo(t,i)},t.bezierCurveTo=function(t,i,s,n,r,a){e.bezierCurveTo(t,i,s,n,r,a),this.__originalBezierCurveTo(t,i,s,n,r,a)},t.rect=function(t,i,s,n){e.rect(t,i,s,n),this.__originalRect(t,i,s,n)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(r,this.suspendedCtx),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),$f(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,i,s){const n=s[0],r=s[1],a=s[2]-n,o=s[3]-r;0!==a&&0!==o&&(this.genericComposeSMask(e.context,i,a,o,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,s,n,r,a,o,l,h,c){let d=t.canvas,u=o-h,p=l-c;if(r)if(u<0||p<0||u+i>d.width||p+s>d.height){const t=this.cachedCanvases.getCanvas("maskExtension",i,s),e=t.context;e.drawImage(d,-u,-p),e.globalCompositeOperation="destination-atop",e.fillStyle=r,e.fillRect(0,0,i,s),e.globalCompositeOperation="source-over",d=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const e=new Path2D;e.rect(u,p,i,s),t.clip(e),t.globalCompositeOperation="destination-atop",t.fillStyle=r,t.fillRect(u,p,i,s),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===n&&a?e.filter=this.filterFactory.addAlphaFilter(a):"Luminosity"===n&&(e.filter=this.filterFactory.addLuminosityFilter(a));const g=new Path2D;g.rect(o,l,i,s),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(d,u,p,i,s,o,l,i,s),e.restore()}save(t){var e;this.inSMaskMode&&$f(this.ctx,this.suspendedCtx),this.ctx.save();const i=this.current;this.stateStack.push(i),this.current=i.clone(),null==(e=this.dependencyTracker)||e.save(t)}restore(t){var e;null==(e=this.dependencyTracker)||e.restore(t),0!==this.stateStack.length?(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&$f(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null):this.inSMaskMode&&this.endSMaskMode()}transform(t,e,i,s,n,r,a){var o;null==(o=this.dependencyTracker)||o.recordIncrementalData("transform",t),this.ctx.transform(e,i,s,n,r,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i,s){let[n]=i;if(!s)return n||(n=i[0]=new Path2D),void this[e](t,n);if(null!==this.dependencyTracker){const i=e===Ru.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,s[0]-i,s[2]+i,s[1]-i,s[3]+i).recordDependencies(t,["transform"])}if(!(n instanceof Path2D)){const t=i[0]=new Path2D;for(let e=0,i=n.length;e<i;)switch(n[e++]){case Iu:t.moveTo(n[e++],n[e++]);break;case Lu:t.lineTo(n[e++],n[e++]);break;case Fu:t.bezierCurveTo(n[e++],n[e++],n[e++],n[e++],n[e++],n[e++]);break;case Nu:t.closePath();break;default:Hu(`Unrecognized drawing path operator: ${n[e-1]}`)}n=t}np.axialAlignedBoundingBox(s,Dp(this.ctx),this.current.minMax),this[e](t,n),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,i=!0){var s;const n=this.ctx,r=this.current.strokeColor;if(n.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof r&&(null==r?void 0:r.getPattern)){const i=r.isModifyingCurrentTransform()?n.getTransform():null;if(n.save(),n.strokeStyle=r.getPattern(n,this,Rp(n),bf,t),i){const t=new Path2D;t.addPath(e,n.getTransform().invertSelf().multiplySelf(i)),e=t}this.rescaleAndStroke(e,!1),n.restore()}else this.rescaleAndStroke(e,!0);null==(s=this.dependencyTracker)||s.recordDependencies(t,df),i&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(bf,Dp(this.ctx))),n.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,i=!0){var s,n,r;const a=this.ctx,o=this.current.fillColor;let l=!1;if(this.current.patternFill){const i=o.isModifyingCurrentTransform()?a.getTransform():null;if(null==(s=this.dependencyTracker)||s.save(t),a.save(),a.fillStyle=o.getPattern(a,this,Rp(a),wf,t),i){const t=new Path2D;t.addPath(e,a.getTransform().invertSelf().multiplySelf(i)),e=t}l=!0}const h=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==h&&(this.pendingEOFill?(a.fill(e,"evenodd"),this.pendingEOFill=!1):a.fill(e)),null==(n=this.dependencyTracker)||n.recordDependencies(t,uf),l&&(a.restore(),null==(r=this.dependencyTracker)||r.restore(t)),i&&this.consumePath(t,e,h)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){var i;this.ctx.fill(e),null==(i=this.dependencyTracker)||i.recordDependencies(t,gf).recordOperation(t)}clip(t){var e;null==(e=this.dependencyTracker)||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=qf}eoClip(t){var e;null==(e=this.dependencyTracker)||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=Xf}beginText(t){var e;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,null==(e=this.dependencyTracker)||e.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,i=this.ctx;if(this.dependencyTracker){const{dependencyTracker:i}=this;void 0!==e&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(void 0!==e){const t=new Path2D,s=i.getTransform().invertSelf();for(const{transform:i,x:n,y:r,fontSize:a,path:o}of e)o&&t.addPath(o,new DOMMatrix(i).preMultiplySelf(s).translate(n,r).scale(a,-a));i.clip(t)}delete this.pendingTextPaths}setCharSpacing(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,i){var s,n;null==(s=this.dependencyTracker)||s.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const r=this.commonObjs.get(e),a=this.current;if(!r)throw new Error(`Can't find font for ${e}`);if(a.fontMatrix=r.fontMatrix||su,0!==a.fontMatrix[0]&&0!==a.fontMatrix[3]||Hu("Invalid font matrix for font "+e),i<0?(i=-i,a.fontDirection=-1):a.fontDirection=1,this.current.font=r,this.current.fontSize=i,r.isType3Font)return;const o=r.loadedName||"sans-serif",l=(null==(n=r.systemFontInfo)?void 0:n.css)||`"${o}", ${r.fallbackName}`;let h="normal";r.black?h="900":r.bold&&(h="bold");const c=r.italic?"italic":"normal";let d=i;i<16?d=16:i>100&&(d=100),this.current.fontSizeScale=i/d,this.ctx.font=`${c} ${h} ${d}px ${l}`}setTextRenderingMode(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,i){var s;null==(s=this.dependencyTracker)||s.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=i}setLeadingMoveText(t,e,i){this.setLeading(t,-i),this.moveText(t,e,i)}setTextMatrix(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("textMatrix",t);const{current:s}=this;s.textMatrix=e,s.textMatrixScale=Math.hypot(e[0],e[1]),s.x=s.lineX=0,s.y=s.lineY=0}nextLine(t){var e;this.moveText(t,0,this.current.leading),null==(e=this.dependencyTracker)||e.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}paintChar(t,e,i,s,n,r){var a,o,l,h;const c=this.ctx,d=this.current,u=d.font,p=d.textRenderingMode,g=d.fontSize/d.fontSizeScale,f=p&_u,m=!!(p&xu),v=d.patternFill&&!u.missingFile,w=d.patternStroke&&!u.missingFile;let b;if((u.disableFontFace||m||v||w)&&!u.missingFile&&(b=u.getPathGenerator(this.commonObjs,e)),b&&(u.disableFontFace||v||w)){let e;if(c.save(),c.translate(i,s),c.scale(g,-g),null==(a=this.dependencyTracker)||a.recordCharacterBBox(t,c,u),f===wu||f===yu)if(n){e=c.getTransform(),c.setTransform(...n);const t=Xd(this,Ys,Js).call(this,b,e,n);c.fill(t)}else c.fill(b);if(f===bu||f===yu)if(r){e||(e=c.getTransform()),c.setTransform(...r);const{a:t,b:i,c:s,d:n}=e,a=np.inverseTransform(r),o=np.transform([t,i,s,n,0,0],a);np.singularValueDecompose2dScale(o,Ff),c.lineWidth*=Math.max(Ff[0],Ff[1])/g,c.stroke(Xd(this,Ys,Js).call(this,b,e,r))}else c.lineWidth/=g,c.stroke(b);c.restore()}else f!==wu&&f!==yu||(c.fillText(e,i,s),null==(o=this.dependencyTracker)||o.recordCharacterBBox(t,c,u,g,i,s,()=>c.measureText(e))),f!==bu&&f!==yu||(this.dependencyTracker&&(null==(l=this.dependencyTracker)||l.recordCharacterBBox(t,c,u,g,i,s,()=>c.measureText(e)).recordDependencies(t,df)),c.strokeText(e,i,s));if(m){(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Dp(c),x:i,y:s,fontSize:g,path:b}),null==(h=this.dependencyTracker)||h.recordCharacterBBox(t,c,u,g,i,s)}}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let i=!1;for(let s=3;s<e.length;s+=4)if(e[s]>0&&e[s]<255){i=!0;break}return Gu(this,"isFontSubpixelAAEnabled",i)}showText(t,e){var i,s,n,r;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,ff).resetBBox(t),this.current.textRenderingMode&xu&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const a=this.current,o=a.font;if(o.isType3Font)return this.showType3Text(t,e),void(null==(i=this.dependencyTracker)||i.recordShowTextOperation(t));const l=a.fontSize;if(0===l)return void(null==(s=this.dependencyTracker)||s.recordOperation(t));const h=this.ctx,c=a.fontSizeScale,d=a.charSpacing,u=a.wordSpacing,p=a.fontDirection,g=a.textHScale*p,f=e.length,m=o.vertical,v=m?1:-1,w=o.defaultVMetrics,b=l*a.fontMatrix[0],y=a.textRenderingMode===wu&&!o.disableFontFace&&!a.patternFill;let A,_;if(h.save(),a.textMatrix&&h.transform(...a.textMatrix),h.translate(a.x,a.y+a.textRise),p>0?h.scale(g,-1):h.scale(g,1),a.patternFill){h.save();const e=a.fillColor.getPattern(h,this,Rp(h),wf,t);A=Dp(h),h.restore(),h.fillStyle=e}if(a.patternStroke){h.save();const e=a.strokeColor.getPattern(h,this,Rp(h),bf,t);_=Dp(h),h.restore(),h.strokeStyle=e}let x=a.lineWidth;const k=a.textMatrixScale;if(0===k||0===x){const t=a.textRenderingMode&_u;t!==bu&&t!==yu||(x=this.getSinglePixelWidth())}else x/=k;if(1!==c&&(h.scale(c,c),x/=c),h.lineWidth=x,o.isInvalidPDFjsFont){const i=[];let s=0;for(const t of e)i.push(t.unicode),s+=t.width;const n=i.join("");if(h.fillText(n,0,0),null!==this.dependencyTracker){const e=h.measureText(n);this.dependencyTracker.recordBBox(t,this.ctx,-e.actualBoundingBoxLeft,e.actualBoundingBoxRight,-e.actualBoundingBoxAscent,e.actualBoundingBoxDescent).recordShowTextOperation(t)}return a.x+=s*b*g,h.restore(),void this.compose()}let S,M=0;for(S=0;S<f;++S){const i=e[S];if("number"==typeof i){M+=v*i*l/1e3;continue}let s=!1;const r=(i.isSpace?u:0)+d,a=i.fontChar,g=i.accent;let f,x,k,E=i.width;if(m){const t=i.vmetric||w,e=-(i.vmetric?t[1]:.5*E)*b,s=t[2]*b;E=t?-t[0]:E,f=e/c,x=(M+s)/c}else f=M/c,x=0;if(o.remeasure&&E>0){k=h.measureText(a);const t=1e3*k.width/l*c;if(E<t&&this.isFontSubpixelAAEnabled){const e=E/t;s=!0,h.save(),h.scale(e,1),f/=e}else E!==t&&(f+=(E-t)/2e3*l/c)}if(this.contentVisible&&(i.isInFont||o.missingFile))if(y&&!g)h.fillText(a,f,x),null==(n=this.dependencyTracker)||n.recordCharacterBBox(t,h,k?{bbox:null}:o,l/c,f,x,()=>k??h.measureText(a));else if(this.paintChar(t,a,f,x,A,_),g){const e=f+l*g.offset.x/c,i=x-l*g.offset.y/c;this.paintChar(t,g.fontChar,e,i,A,_)}M+=m?E*b-r*p:E*b+r*p,s&&h.restore()}m?a.y-=M:a.x+=M*g,h.restore(),this.compose(),null==(r=this.dependencyTracker)||r.recordShowTextOperation(t)}showType3Text(t,e){const i=this.ctx,s=this.current,n=s.font,r=s.fontSize,a=s.fontDirection,o=n.vertical?1:-1,l=s.charSpacing,h=s.wordSpacing,c=s.textHScale*a,d=s.fontMatrix||su,u=e.length;let p,g,f,m;if(s.textRenderingMode===Au||0===r)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,i.save(),s.textMatrix&&i.transform(...s.textMatrix),i.translate(s.x,s.y+s.textRise),i.scale(c,a);const v=this.dependencyTracker;for(this.dependencyTracker=v?new cf(v,t):null,p=0;p<u;++p){if(g=e[p],"number"==typeof g){m=o*g*r/1e3,this.ctx.translate(m,0),s.x+=m*c;continue}const t=(g.isSpace?h:0)+l,a=n.charProcOperatorList[g.operatorListId];a?this.contentVisible&&(this.save(),i.scale(r,r),i.transform(...d),this.executeOperatorList(a),this.restore()):Hu(`Type3 character "${g.operatorListId}" is not available.`);const u=[g.width,0];np.applyTransform(u,d),f=u[0]*r+t,i.translate(f,0),s.x+=f*c}i.restore(),v&&(this.dependencyTracker=v)}setCharWidth(t,e,i){}setCharWidthAndBounds(t,e,i,s,n,r,a){var o;const l=new Path2D;l.rect(s,n,r-s,a-n),this.ctx.clip(l),null==(o=this.dependencyTracker)||o.recordBBox(t,this.ctx,s,r,n,a).recordClipBox(t,this.ctx,s,r,n,a),this.endPath(t)}getColorN_Pattern(e,i){let s;if("TilingPattern"===i[0]){const e=this.baseTransform||Dp(this.ctx),n={createCanvasGraphics:(e,i)=>new t(e,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new cf(this.dependencyTracker,i,!0):null)};s=new Df(i,this.ctx,n,e)}else s=this._getPattern(e,i[1],i[2]);return s}setStrokeColorN(t,...e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("fillColor",t),this.current.fillColor=this.getColorN_Pattern(t,e),this.current.patternFill=!0}setStrokeRGBColor(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){var e;null==(e=this.dependencyTracker)||e.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1}setFillTransparent(t){var e;null==(e=this.dependencyTracker)||e.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e,i=null){let s;return this.cachedPatterns.has(e)?s=this.cachedPatterns.get(e):(s=function(t){switch(t[0]){case"RadialAxial":return new xf(t);case"Mesh":return new Mf(t);case"Dummy":return new Ef}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t,e)),this.cachedPatterns.set(e,s)),i&&(s.matrix=i),s}shadingFill(t,e){var i;if(!this.contentVisible)return;const s=this.ctx;this.save(t);const n=this._getPattern(t,e);s.fillStyle=n.getPattern(s,this,Rp(s),yf,t);const r=Rp(s);if(r){const{width:t,height:e}=s.canvas,i=Nf.slice();np.axialAlignedBoundingBox([0,0,t,e],r,i);const[n,a,o,l]=i;this.ctx.fillRect(n,a,o-n,l-a)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);null==(i=this.dependencyTracker)||i.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,mf).recordDependencies(t,uf).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){$u("Should not call beginInlineImage")}beginImageData(){$u("Should not call beginImageData")}paintFormXObjectBegin(t,e,i){var s;if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=Dp(this.ctx),i)){np.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);const[e,n,r,a]=i,o=new Path2D;o.rect(e,n,r-e,a-n),this.ctx.clip(o),null==(s=this.dependencyTracker)||s.recordClipBox(t,this.ctx,e,r,n,a),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){var i;if(!this.contentVisible)return;this.save(t),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const s=this.ctx;e.isolated||Uu("TODO: Support non-isolated groups."),e.knockout&&Hu("Knockout groups not supported.");const n=Dp(s);if(e.matrix&&s.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let r=Nf.slice();np.axialAlignedBoundingBox(e.bbox,Dp(s),r);const a=[0,0,s.canvas.width,s.canvas.height];r=np.intersect(r,a)||[0,0,0,0];const o=Math.floor(r[0]),l=Math.floor(r[1]),h=Math.max(Math.ceil(r[2])-o,1),c=Math.max(Math.ceil(r[3])-l,1);this.current.startNewPathAndClipBox([0,0,h,c]);let d="groupAt"+this.groupLevel;e.smask&&(d+="_smask_"+this.smaskCounter++%2);const u=this.cachedCanvases.getCanvas(d,h,c),p=u.context;p.translate(-o,-l),p.transform(...n);let g=new Path2D;const[f,m,v,w]=e.bbox;if(g.rect(f,m,v-f,w-m),e.matrix){const t=new Path2D;t.addPath(g,new DOMMatrix(e.matrix)),g=t}p.clip(g),e.smask&&this.smaskStack.push({canvas:u.canvas,context:p,offsetX:o,offsetY:l,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}),e.smask&&!this.dependencyTracker||(s.setTransform(1,0,0,1,0,0),s.translate(o,l),s.save()),$f(s,p),this.ctx=p,null==(i=this.dependencyTracker)||i.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(s),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(s),this.groupLevel++}endGroup(t,e){var i;if(!this.contentVisible)return;this.groupLevel--;const s=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,null==(i=this.dependencyTracker)||i.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&this.ctx.restore();else{this.ctx.restore();const e=Dp(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...e);const i=Nf.slice();np.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],e,i),this.ctx.drawImage(s.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(t,e,i,s,n,r){if(Xd(this,Ys,Ks).call(this),jf(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),i){const n=i[2]-i[0],a=i[3]-i[1];if(r&&this.annotationCanvasMap){(s=s.slice())[4]-=i[0],s[5]-=i[1],(i=i.slice())[0]=i[1]=0,i[2]=n,i[3]=a,np.singularValueDecompose2dScale(Dp(this.ctx),Ff);const{viewportScale:t}=this,r=Math.ceil(n*this.outputScaleX*t),o=Math.ceil(a*this.outputScaleY*t);this.annotationCanvas=this.canvasFactory.create(r,o);const{canvas:l,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(e,l),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(Ff[0],0,0,-Ff[1],0,a*Ff[1]),jf(this.ctx)}else{jf(this.ctx),this.endPath(t);const e=new Path2D;e.rect(i[0],i[1],n,a),this.ctx.clip(e)}}this.current=new Of(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(t,...s),this.transform(t,...n)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),Xd(this,Ys,Qs).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t,e){var i;if(!this.contentVisible)return;const s=e.count;(e=this.getObject(t,e.data,e)).count=s;const n=this.ctx,r=this._createMaskCanvas(t,e),a=r.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(a,r.offsetX,r.offsetY),null==(i=this.dependencyTracker)||i.resetBBox(t).recordBBox(t,this.ctx,r.offsetX,r.offsetX+a.width,r.offsetY,r.offsetY+a.height).recordOperation(t),n.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i,s=0,n=0,r,a){var o,l,h;if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const c=this.ctx;c.save();const d=Dp(c);c.transform(i,s,n,r,0,0);const u=this._createMaskCanvas(t,e);c.setTransform(1,0,0,1,u.offsetX-d[4],u.offsetY-d[5]),null==(o=this.dependencyTracker)||o.resetBBox(t);for(let p=0,g=a.length;p<g;p+=2){const e=np.transform(d,[i,s,n,r,a[p],a[p+1]]);c.drawImage(u.canvas,e[4],e[5]),null==(l=this.dependencyTracker)||l.recordBBox(t,this.ctx,e[4],e[4]+u.canvas.width,e[5],e[5]+u.canvas.height)}c.restore(),this.compose(),null==(h=this.dependencyTracker)||h.recordOperation(t)}paintImageMaskXObjectGroup(t,e){var i,s,n;if(!this.contentVisible)return;const r=this.ctx,a=this.current.fillColor,o=this.current.patternFill;null==(i=this.dependencyTracker)||i.resetBBox(t).recordDependencies(t,vf);for(const l of e){const{data:e,width:i,height:n,transform:h}=l,c=this.cachedCanvases.getCanvas("maskCanvas",i,n),d=c.context;d.save();Hf(d,this.getObject(t,e,l)),d.globalCompositeOperation="source-in",d.fillStyle=o?a.getPattern(d,this,Rp(r),wf,t):a,d.fillRect(0,0,i,n),d.restore(),r.save(),r.transform(...h),r.scale(1,-1),Bf(r,c.canvas,0,0,i,n,0,-1,1,1),null==(s=this.dependencyTracker)||s.recordBBox(t,r,0,i,0,n),r.restore()}this.compose(),null==(n=this.dependencyTracker)||n.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;const i=this.getObject(t,e);i?this.paintInlineImageXObject(t,i):Hu("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s,n){if(!this.contentVisible)return;const r=this.getObject(t,e);if(!r)return void Hu("Dependent image isn't ready yet");const a=r.width,o=r.height,l=[];for(let h=0,c=n.length;h<c;h+=2)l.push({transform:[i,0,0,s,n[h],n[h+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(t,r,l)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;const{bitmap:e,width:i,height:s}=t,n=this.cachedCanvases.getCanvas("inlineImage",i,s),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",n.canvas}paintInlineImageXObject(t,e){var i;if(!this.contentVisible)return;const s=e.width,n=e.height,r=this.ctx;this.save(t);const{filter:a}=r;let o;if("none"!==a&&""!==a&&(r.filter="none"),r.scale(1/s,-1/n),e.bitmap)o=this.applyTransferMapsToBitmap(e);else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)o=e;else{const t=this.cachedCanvases.getCanvas("inlineImage",s,n).context;Uf(t,e),o=this.applyTransferMapsToCanvas(t)}const l=this._scaleImage(o,Rp(r));r.imageSmoothingEnabled=zf(Dp(r),e.interpolate),null==(i=this.dependencyTracker)||i.resetBBox(t).recordBBox(t,r,0,s,-n,0).recordDependencies(t,pf).recordOperation(t),Bf(r,l.img,0,0,l.paintWidth,l.paintHeight,0,-n,s,n),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,i){var s,n,r;if(!this.contentVisible)return;const a=this.ctx;let o;if(e.bitmap)o=e.bitmap;else{const t=e.width,i=e.height,s=this.cachedCanvases.getCanvas("inlineImage",t,i).context;Uf(s,e),o=this.applyTransferMapsToCanvas(s)}null==(s=this.dependencyTracker)||s.resetBBox(t);for(const l of i)a.save(),a.transform(...l.transform),a.scale(1,-1),Bf(a,o,l.x,l.y,l.w,l.h,0,-1,1,1),null==(n=this.dependencyTracker)||n.recordBBox(t,a,0,1,-1,0),a.restore();null==(r=this.dependencyTracker)||r.recordOperation(t),this.compose()}paintSolidColorImageMask(t){var e;this.contentVisible&&(null==(e=this.dependencyTracker)||e.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,uf).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}markPointProps(t,e,i){}beginMarkedContent(t,e){var i;null==(i=this.dependencyTracker)||i.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,i){var s;null==(s=this.dependencyTracker)||s.beginMarkedContent(t),"OC"===e?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(i)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){var e;null==(e=this.dependencyTracker)||e.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,i){var s,n;const r=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(i);const a=this.ctx;this.pendingClip?(r||(this.pendingClip===Xf?a.clip(e,"evenodd"):a.clip(e)),this.pendingClip=null,null==(s=this.dependencyTracker)||s.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):null==(n=this.dependencyTracker)||n.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Dp(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:i,c:s,d:n}=this.ctx.getTransform();let r,a;if(0===i&&0===s){const i=Math.abs(e),s=Math.abs(n);if(i===s)if(0===t)r=a=1/i;else{const e=i*t;r=a=e<1?1/e:1}else if(0===t)r=1/i,a=1/s;else{const e=i*t,n=s*t;r=e<1?1/e:1,a=n<1?1/n:1}}else{const o=Math.abs(e*n-i*s),l=Math.hypot(e,i),h=Math.hypot(s,n);if(0===t)r=h/o,a=l/o;else{const e=t*o;r=h>e?h/e:1,a=l>e?l/e:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:i,current:{lineWidth:s}}=this,[n,r]=this.getScaleForStroking();if(n===r)return i.lineWidth=(s||1)*n,void i.stroke(t);const a=i.getLineDash();e&&i.save(),i.scale(n,r),Lf.a=1/n,Lf.d=1/r;const o=new Path2D;if(o.addPath(t,Lf),a.length>0){const t=Math.max(n,r);i.setLineDash(a.map(e=>e/t)),i.lineDashOffset/=t}i.lineWidth=s||1,i.stroke(o),e&&i.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};for(const ub in Ru)void 0!==Yf.prototype[ub]&&(Yf.prototype[Ru[ub]]=Yf.prototype[ub]);const Kf=class t{constructor(t){Gd(this,sn),Gd(this,Zs),Gd(this,tn),Gd(this,en),qd(this,Zs,t),qd(this,tn,new DataView(Vd(this,Zs))),qd(this,en,new TextDecoder)}static write(e){const i=new TextEncoder,s={};let n=0;for(const h of t.strings){const t=i.encode(e[h]);s[h]=t,n+=4+t.length}const r=new ArrayBuffer(n),a=new Uint8Array(r),o=new DataView(r);let l=0;for(const h of t.strings){const t=s[h],e=t.length;o.setUint32(l,e),a.set(t,l+4),l+=4+e}return ju(l===r.byteLength,"CssFontInfo.write: Buffer overflow"),r}get fontFamily(){return Xd(this,sn,nn).call(this,0)}get fontWeight(){return Xd(this,sn,nn).call(this,1)}get italicAngle(){return Xd(this,sn,nn).call(this,2)}};Zs=new WeakMap,tn=new WeakMap,en=new WeakMap,sn=new WeakSet,nn=function(t){ju(t<Kf.strings.length,"Invalid string index");let e=0;for(let s=0;s<t;s++)e+=Vd(this,tn).getUint32(e)+4;const i=Vd(this,tn).getUint32(e);return Vd(this,en).decode(new Uint8Array(Vd(this,Zs),e+4,i))},jd(Kf,"strings",["fontFamily","fontWeight","italicAngle"]);let Qf=Kf;const Jf=class t{constructor(t){Gd(this,ln),Gd(this,rn),Gd(this,an),Gd(this,on),qd(this,rn,t),qd(this,an,new DataView(Vd(this,rn))),qd(this,on,new TextDecoder)}static write(e){const i=new TextEncoder,s={};let n=0;for(const u of t.strings){const t=i.encode(e[u]);s[u]=t,n+=4+t.length}n+=4;let r,a,o=1+n;e.style&&(r=i.encode(e.style.style),a=i.encode(e.style.weight),o+=4+r.length+4+a.length);const l=new ArrayBuffer(o),h=new Uint8Array(l),c=new DataView(l);let d=0;c.setUint8(d++,e.guessFallback?1:0),c.setUint32(d,0),d+=4,n=0;for(const u of t.strings){const t=s[u],e=t.length;n+=4+e,c.setUint32(d,e),h.set(t,d+4),d+=4+e}return c.setUint32(d-n-4,n),e.style&&(c.setUint32(d,r.length),h.set(r,d+4),d+=4+r.length,c.setUint32(d,a.length),h.set(a,d+4),d+=4+a.length),ju(d<=l.byteLength,"SubstitionInfo.write: Buffer overflow"),l.transferToFixedLength(d)}get guessFallback(){return 0!==Vd(this,an).getUint8(0)}get css(){return Xd(this,ln,hn).call(this,0)}get loadedName(){return Xd(this,ln,hn).call(this,1)}get baseFontName(){return Xd(this,ln,hn).call(this,2)}get src(){return Xd(this,ln,hn).call(this,3)}get style(){let t=1;t+=4+Vd(this,an).getUint32(t);const e=Vd(this,an).getUint32(t),i=Vd(this,on).decode(new Uint8Array(Vd(this,rn),t+4,e));t+=4+e;const s=Vd(this,an).getUint32(t);return{style:i,weight:Vd(this,on).decode(new Uint8Array(Vd(this,rn),t+4,s))}}};rn=new WeakMap,an=new WeakMap,on=new WeakMap,ln=new WeakSet,hn=function(t){ju(t<Jf.strings.length,"Invalid string index");let e=5;for(let s=0;s<t;s++)e+=Vd(this,an).getUint32(e)+4;const i=Vd(this,an).getUint32(e);return Vd(this,on).decode(new Uint8Array(Vd(this,rn),e+4,i))},jd(Jf,"strings",["css","loadedName","baseFontName","src"]);let Zf=Jf;const tm=class t{constructor({data:t,extra:e}){Gd(this,wn),Gd(this,fn),Gd(this,mn),Gd(this,vn),qd(this,fn,t),qd(this,mn,new TextDecoder),qd(this,vn,new DataView(Vd(this,fn))),e&&Object.assign(this,e)}get black(){return Xd(this,wn,bn).call(this,0)}get bold(){return Xd(this,wn,bn).call(this,1)}get disableFontFace(){return Xd(this,wn,bn).call(this,2)}get fontExtraProperties(){return Xd(this,wn,bn).call(this,3)}get isInvalidPDFjsFont(){return Xd(this,wn,bn).call(this,4)}get isType3Font(){return Xd(this,wn,bn).call(this,5)}get italic(){return Xd(this,wn,bn).call(this,6)}get missingFile(){return Xd(this,wn,bn).call(this,7)}get remeasure(){return Xd(this,wn,bn).call(this,8)}get vertical(){return Xd(this,wn,bn).call(this,9)}get ascent(){return Xd(this,wn,yn).call(this,0)}get defaultWidth(){return Xd(this,wn,yn).call(this,1)}get descent(){return Xd(this,wn,yn).call(this,2)}get bbox(){let e=Vd(t,dn);if(0===Vd(this,vn).getUint8(e))return;e+=1;const i=[];for(let t=0;t<4;t++)i.push(Vd(this,vn).getInt16(e,!0)),e+=2;return i}get fontMatrix(){let e=Vd(t,un);if(0===Vd(this,vn).getUint8(e))return;e+=1;const i=[];for(let t=0;t<6;t++)i.push(Vd(this,vn).getFloat64(e,!0)),e+=8;return i}get defaultVMetrics(){let e=Vd(t,pn);if(0===Vd(this,vn).getUint8(e))return;e+=1;const i=[];for(let t=0;t<3;t++)i.push(Vd(this,vn).getInt16(e,!0)),e+=2;return i}get fallbackName(){return Xd(this,wn,An).call(this,0)}get loadedName(){return Xd(this,wn,An).call(this,1)}get mimetype(){return Xd(this,wn,An).call(this,2)}get name(){return Xd(this,wn,An).call(this,3)}get data(){let e=Vd(t,gn);e+=4+Vd(this,vn).getUint32(e);e+=4+Vd(this,vn).getUint32(e);e+=4+Vd(this,vn).getUint32(e);const i=Vd(this,vn).getUint32(e);if(0!==i)return new Uint8Array(Vd(this,fn),e+4,i)}clearData(){let e=Vd(t,gn);e+=4+Vd(this,vn).getUint32(e);e+=4+Vd(this,vn).getUint32(e);e+=4+Vd(this,vn).getUint32(e);const i=Vd(this,vn).getUint32(e);new Uint8Array(Vd(this,fn),e+4,i).fill(0),Vd(this,vn).setUint32(e,0)}get cssFontInfo(){let e=Vd(t,gn);e+=4+Vd(this,vn).getUint32(e);e+=4+Vd(this,vn).getUint32(e);const i=Vd(this,vn).getUint32(e);if(0===i)return null;const s=new Uint8Array(i);return s.set(new Uint8Array(Vd(this,fn),e+4,i)),new Qf(s.buffer)}get systemFontInfo(){let e=Vd(t,gn);e+=4+Vd(this,vn).getUint32(e);const i=Vd(this,vn).getUint32(e);if(0===i)return null;const s=new Uint8Array(i);return s.set(new Uint8Array(Vd(this,fn),e+4,i)),new Zf(s.buffer)}static write(e){const i=e.systemFontInfo?Zf.write(e.systemFontInfo):null,s=e.cssFontInfo?Qf.write(e.cssFontInfo):null,n=new TextEncoder,r={};let a=0;for(const f of t.strings)r[f]=n.encode(e[f]),a+=4+r[f].length;const o=Vd(t,gn)+4+a+4+(i?i.byteLength:0)+4+(s?s.byteLength:0)+4+(e.data?e.data.length:0),l=new ArrayBuffer(o),h=new Uint8Array(l),c=new DataView(l);let d=0;const u=t.bools.length;let p=0,g=0;for(let f=0;f<u;f++){const i=e[t.bools[f]];p|=(void 0===i?0:i?2:1)<<g,g+=2,8!==g&&f!==u-1||(c.setUint8(d++,p),p=0,g=0)}ju(d===Vd(t,cn),"FontInfo.write: Boolean properties offset mismatch");for(const f of t.numbers)c.setFloat64(d,e[f]),d+=8;if(ju(d===Vd(t,dn),"FontInfo.write: Number properties offset mismatch"),e.bbox){c.setUint8(d++,4);for(const t of e.bbox)c.setInt16(d,t,!0),d+=2}else c.setUint8(d++,0),d+=8;if(ju(d===Vd(t,un),"FontInfo.write: BBox properties offset mismatch"),e.fontMatrix){c.setUint8(d++,6);for(const t of e.fontMatrix)c.setFloat64(d,t,!0),d+=8}else c.setUint8(d++,0),d+=48;if(ju(d===Vd(t,pn),"FontInfo.write: FontMatrix properties offset mismatch"),e.defaultVMetrics){c.setUint8(d++,1);for(const t of e.defaultVMetrics)c.setInt16(d,t,!0),d+=2}else c.setUint8(d++,0),d+=6;ju(d===Vd(t,gn),"FontInfo.write: DefaultVMetrics properties offset mismatch"),c.setUint32(Vd(t,gn),0),d+=4;for(const f of t.strings){const t=r[f],e=t.length;c.setUint32(d,e),h.set(t,d+4),d+=4+e}if(c.setUint32(Vd(t,gn),d-Vd(t,gn)-4),i){const t=i.byteLength;c.setUint32(d,t),ju(d+4+t<=l.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),h.set(new Uint8Array(i),d+4),d+=4+t}else c.setUint32(d,0),d+=4;if(s){const t=s.byteLength;c.setUint32(d,t),ju(d+4+t<=l.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),h.set(new Uint8Array(s),d+4),d+=4+t}else c.setUint32(d,0),d+=4;return void 0===e.data?(c.setUint32(d,0),d+=4):(c.setUint32(d,e.data.length),h.set(e.data,d+4),d+=4+e.data.length),ju(d<=l.byteLength,"FontInfo.write: Buffer overflow"),l.transferToFixedLength(d)}};cn=new WeakMap,dn=new WeakMap,un=new WeakMap,pn=new WeakMap,gn=new WeakMap,fn=new WeakMap,mn=new WeakMap,vn=new WeakMap,wn=new WeakSet,bn=function(t){ju(t<tm.bools.length,"Invalid boolean index");const e=Math.floor(t/4),i=2*t%8,s=Vd(this,vn).getUint8(e)>>i&3;return 0===s?void 0:2===s},yn=function(t){return ju(t<tm.numbers.length,"Invalid number index"),Vd(this,vn).getFloat64(Vd(tm,cn)+8*t)},An=function(t){ju(t<tm.strings.length,"Invalid string index");let e=Vd(tm,gn)+4;for(let n=0;n<t;n++)e+=Vd(this,vn).getUint32(e)+4;const i=Vd(this,vn).getUint32(e),s=new Uint8Array(i);return s.set(new Uint8Array(Vd(this,fn),e+4,i)),Vd(this,mn).decode(s)},jd(tm,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),jd(tm,"numbers",["ascent","defaultWidth","descent"]),jd(tm,"strings",["fallbackName","loadedName","mimetype","name"]),Gd(tm,cn,Math.ceil(2*tm.bools.length/8)),Gd(tm,dn,Vd(tm,cn)+8*tm.numbers.length),Gd(tm,un,Vd(tm,dn)+1+8),Gd(tm,pn,Vd(tm,un)+1+48),Gd(tm,gn,Vd(tm,pn)+1+6);let em=tm;class im{static get workerPort(){return Vd(this,_n)}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");qd(this,_n,t)}static get workerSrc(){return Vd(this,xn)}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");qd(this,xn,t)}}_n=new WeakMap,xn=new WeakMap,Gd(im,_n,null),Gd(im,xn,"");class sm{constructor({parsedData:t,rawData:e}){Gd(this,kn),Gd(this,Sn),qd(this,kn,t),qd(this,Sn,e)}getRaw(){return Vd(this,Sn)}get(t){return Vd(this,kn).get(t)??null}[Symbol.iterator](){return Vd(this,kn).entries()}}kn=new WeakMap,Sn=new WeakMap;const nm=Symbol("INTERNAL");class rm{constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){Gd(this,Mn,!1),Gd(this,En,!1),Gd(this,Cn,!1),Gd(this,Tn,!0),qd(this,Mn,!!(t&au)),qd(this,En,!!(t&ou)),this.name=e,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(Vd(this,Cn))return Vd(this,Tn);if(!Vd(this,Tn))return!1;const{print:t,view:e}=this.usage;return Vd(this,Mn)?"OFF"!==(null==e?void 0:e.viewState):!Vd(this,En)||"OFF"!==(null==t?void 0:t.printState)}_setVisible(t,e,i=!1){t!==nm&&$u("Internal method `_setVisible` called."),qd(this,Cn,i),qd(this,Tn,e)}}Mn=new WeakMap,En=new WeakMap,Cn=new WeakMap,Tn=new WeakMap;class am{constructor(t,e=au){if(Gd(this,Ln),Gd(this,Pn,null),Gd(this,Dn,new Map),Gd(this,Rn,null),Gd(this,In,null),this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,qd(this,In,t.order);for(const i of t.groups)Vd(this,Dn).set(i.id,new rm(e,i));if("OFF"===t.baseState)for(const t of Vd(this,Dn).values())t._setVisible(nm,!1);for(const e of t.on)Vd(this,Dn).get(e)._setVisible(nm,!0);for(const e of t.off)Vd(this,Dn).get(e)._setVisible(nm,!1);qd(this,Rn,this.getHash())}}isVisible(t){if(0===Vd(this,Dn).size)return!0;if(!t)return Uu("Optional content group not defined."),!0;if("OCG"===t.type)return Vd(this,Dn).has(t.id)?Vd(this,Dn).get(t.id).visible:(Hu(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return Xd(this,Ln,Fn).call(this,t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!Vd(this,Dn).has(e))return Hu(`Optional content group not found: ${e}`),!0;if(Vd(this,Dn).get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!Vd(this,Dn).has(e))return Hu(`Optional content group not found: ${e}`),!0;if(!Vd(this,Dn).get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!Vd(this,Dn).has(e))return Hu(`Optional content group not found: ${e}`),!0;if(!Vd(this,Dn).get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!Vd(this,Dn).has(e))return Hu(`Optional content group not found: ${e}`),!0;if(Vd(this,Dn).get(e).visible)return!1}return!0}return Hu(`Unknown optional content policy ${t.policy}.`),!0}return Hu(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){var s;const n=Vd(this,Dn).get(t);if(n){if(i&&e&&n.rbGroups.length)for(const e of n.rbGroups)for(const i of e)i!==t&&(null==(s=Vd(this,Dn).get(i))||s._setVisible(nm,!1,!0));n._setVisible(nm,!!e,!0),qd(this,Pn,null)}else Hu(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let i;for(const s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}const t=Vd(this,Dn).get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}qd(this,Pn,null)}get hasInitialVisibility(){return null===Vd(this,Rn)||this.getHash()===Vd(this,Rn)}getOrder(){return Vd(this,Dn).size?Vd(this,In)?Vd(this,In).slice():[...Vd(this,Dn).keys()]:null}getGroup(t){return Vd(this,Dn).get(t)||null}getHash(){if(null!==Vd(this,Pn))return Vd(this,Pn);const t=new mg;for(const[e,i]of Vd(this,Dn))t.update(`${e}:${i.visible}`);return qd(this,Pn,t.hexdigest())}[Symbol.iterator](){return Vd(this,Dn).entries()}}Pn=new WeakMap,Dn=new WeakMap,Rn=new WeakMap,In=new WeakMap,Ln=new WeakSet,Fn=function(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let s=1;s<e;s++){const e=t[s];let n;if(Array.isArray(e))n=Xd(this,Ln,Fn).call(this,e);else{if(!Vd(this,Dn).has(e))return Hu(`Optional content group not found: ${e}`),!0;n=Vd(this,Dn).get(e).visible}switch(i){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return"And"===i};class om{constructor(t,{disableRange:e=!1,disableStream:i=!1}){ju(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:n,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,(null==n?void 0:n.length)>0){const t=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((t,e)=>{this._onReceiveData({begin:t,chunk:e})}),t.addProgressListener((t,e)=>{this._onProgress({loaded:t,total:e})}),t.addProgressiveReadListener(t=>{this._onReceiveData({chunk:t})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(void 0===t)this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i);else{ju(this._rangeReaders.some(function(e){return e._begin===t&&(e._enqueue(i),!0)}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t;return(null==(t=this._fullRequestReader)?void 0:t._loaded)??0}_onProgress(t){var e,i,s,n;void 0===t.total?null==(i=null==(e=this._rangeReaders[0])?void 0:e.onProgress)||i.call(e,{loaded:t.loaded}):null==(n=null==(s=this._fullRequestReader)?void 0:s.onProgress)||n.call(s,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;null==(t=this._fullRequestReader)||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){ju(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new lm(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new hm(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const i of this._rangeReaders.slice(0))i.cancel(t);this._pdfDataRangeTransport.abort()}}class lm{constructor(t,e,i=!1,s=null){this._stream=t,this._done=i||!1,this._filename=Ap(s)?s: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){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._queuedChunks.push(t);this._loaded+=t.byteLength}}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0){return{value:this._queuedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class hm{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function cm(t,e){const i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(const s in e){const t=e[s];void 0!==t&&i.append(s,t)}return i}function dm(t){var e;return(null==(e=URL.parse(t))?void 0:e.origin)??null}function um({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){const n={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(r))return n;if(n.suggestedLength=r,r<=2*i)return n;if(s||!e)return n;if("bytes"!==t.get("Accept-Ranges"))return n;return"identity"!==(t.get("Content-Encoding")||"identity")||(n.allowRangeRequests=!0),n}function pm(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){i=i[1];let t=a(i);return t=unescape(t),t=o(t),t=l(t),r(t)}if(i=function(t){const e=[];let i;const n=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=n.exec(t));){let[,t,s,n]=i;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[s,n]}const r=[];for(let s=0;s<e.length&&s in e;++s){let[t,i]=e[s];i=a(i),t&&(i=unescape(i),0===s&&(i=o(i))),r.push(i)}return r.join("")}(t),i)return r(l(i));if(i=s("filename","i").exec(t),i){i=i[1];let t=a(i);return t=l(t),r(t)}function s(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function n(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const s=new TextDecoder(t,{fatal:!0}),n=ep(i);i=s.decode(n),e=!1}catch{}}return i}function r(t){return e&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),e&&(t=n("iso-8859-1",t))),t}function a(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){const e=t.indexOf("'");return-1===e?t:n(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(t,e,i,s){if("q"===i||"Q"===i)return n(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(t,e){return String.fromCharCode(parseInt(e,16))}));try{s=atob(s)}catch{}return n(e,s)})}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(Ap(t))return t}return null}function gm(t,e){return new Qu(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,404===t||0===t&&e.startsWith("file:"))}function fm(t){return 200===t||206===t}function mm(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function vm(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(Hu(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class wm{constructor(t){jd(this,"_responseOrigin",null),this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=cm(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return(null==(t=this._fullRequestReader)?void 0:t._loaded)??0}getFullReader(){return ju(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new bm(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new ym(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const i of this._rangeRequestReaders.slice(0))i.cancel(t)}}class bm{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const i=new Headers(t.headers),s=e.url;fetch(s,mm(i,this._withCredentials,this._abortController)).then(e=>{if(t._responseOrigin=dm(e.url),!fm(e.status))throw gm(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();const i=e.headers,{allowRangeRequests:n,suggestedLength:r}=um({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=r||this._contentLength,this._filename=pm(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Zu("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(){var t;await this._headersCapability.promise;const{value:e,done:i}=await this._reader.read();return i?{value:e,done:i}:(this._loaded+=e.byteLength,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded,total:this._contentLength}),{value:vm(e),done:!1})}cancel(t){var e;null==(e=this._reader)||e.cancel(t),this._abortController.abort()}}class ym{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;const n=new Headers(t.headers);n.append("Range",`bytes=${e}-${i-1}`);const r=s.url;fetch(r,mm(n,this._withCredentials,this._abortController)).then(e=>{const i=dm(e.url);if(i!==t._responseOrigin)throw new Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!fm(e.status))throw gm(e.status,r);this._readCapability.resolve(),this._reader=e.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var t;await this._readCapability.promise;const{value:e,done:i}=await this._reader.read();return i?{value:e,done:i}:(this._loaded+=e.byteLength,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded}),{value:vm(e),done:!1})}cancel(t){var e;null==(e=this._reader)||e.cancel(t),this._abortController.abort()}}class Am{constructor({url:t,httpHeaders:e,withCredentials:i}){jd(this,"_responseOrigin",null),this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=cm(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,i=this.currXhrId++,s=this.pendingRequests[i]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[n,r]of this.headers)e.setRequestHeader(n,r);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.expectedStatus=206):s.expectedStatus=200,e.responseType="arraybuffer",ju(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){var i;const s=this.pendingRequests[t];s&&(null==(i=s.onProgress)||i.call(s,e))}onStateChange(t,e){const i=this.pendingRequests[t];if(!i)return;const s=i.xhr;if(s.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==s.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===s.status&&this.isHttp)return void i.onError(s.status);const n=s.status||200;if(!(200===n&&206===i.expectedStatus)&&n!==i.expectedStatus)return void i.onError(s.status);const r=function(t){const e=t.response;return"string"!=typeof e?e:ep(e).buffer}(s);if(206===n){const t=s.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?i.onDone({begin:parseInt(e[1],10),chunk:r}):(Hu('Missing or invalid "Content-Range" header.'),i.onError(0))}else r?i.onDone({begin:0,chunk:r}):i.onError(s.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class _m{constructor(t){this._source=t,this._manager=new Am(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return ju(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new xm(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new km(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const i of this._rangeRequestReaders.slice(0))i.cancel(t)}}class xm{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=dm(e.responseURL);const i=e.getAllResponseHeaders(),s=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(t=>{const[e,...i]=t.split(": ");return[e,i.join(": ")]}):[]),{allowRangeRequests:n,suggestedLength:r}=um({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=pm(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t)if(this._requests.length>0){this._requests.shift().resolve({value:t.chunk,done:!1})}else this._cachedChunks.push(t.chunk);if(this._done=!0,!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=gm(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var e;null==(e=this.onProgress)||e.call(this,{loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0){return{value:this._cachedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const 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 km{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){var t;const e=dm(null==(t=this._manager.getRequestXhr(this._requestId))?void 0:t.responseURL);e!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${e}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var t;null==(t=this.onClosed)||t.call(this,this)}_onDone(t){const e=t.chunk;if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunk=e;this._done=!0;for(const i of this._requests)i.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??(this._storedError=gm(t,this._url));for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var e;this.isStreamingSupported||null==(e=this.onProgress)||e.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const 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 Sm=/^[a-z][a-z0-9\-+.]+:/i;class Mm{constructor(t){this.source=t,this.url=function(t){if(Sm.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),ju("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return(null==(t=this._fullRequestReader)?void 0:t._loaded)??0}getFullReader(){return ju(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Em(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Cm(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const i of this._rangeRequestReaders.slice(0))i.cancel(t)}}class Em{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=process.getBuiltinModule("fs");i.promises.lstat(this._url).then(t=>{this._contentLength=t.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()},t=>{"ENOENT"===t.code&&(t=gm(0,this._url.href)),this._storedError=t,this._headersCapability.reject(t)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var t;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();if(null===e)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=e.length,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded,total:this._contentLength});return{value:new Uint8Array(e).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Zu("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Cm{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const s=t.source;this._isStreamingSupported=!s.disableStream;const n=process.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:e,end:i-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){var t;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();if(null===e)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=e.length,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded});return{value:new Uint8Array(e).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const Tm=Symbol("INITIAL_DATA");class Pm{constructor(){Gd(this,Wn),Gd(this,Nn,Object.create(null))}get(t,e=null){if(e){const i=Xd(this,Wn,Bn).call(this,t);return i.promise.then(()=>e(i.data)),null}const i=Vd(this,Nn)[t];if(!i||i.data===Tm)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=Vd(this,Nn)[t];return!!e&&e.data!==Tm}delete(t){const e=Vd(this,Nn)[t];return!(!e||e.data===Tm)&&(delete Vd(this,Nn)[t],!0)}resolve(t,e=null){const i=Xd(this,Wn,Bn).call(this,t);i.data=e,i.resolve()}clear(){var t;for(const e in Vd(this,Nn)){const{data:i}=Vd(this,Nn)[e];null==(t=null==i?void 0:i.bitmap)||t.close()}qd(this,Nn,Object.create(null))}*[Symbol.iterator](){for(const t in Vd(this,Nn)){const{data:e}=Vd(this,Nn)[t];e!==Tm&&(yield[t,e])}}}Nn=new WeakMap,Wn=new WeakSet,Bn=function(t){var e;return(e=Vd(this,Nn))[t]||(e[t]={...Promise.withResolvers(),data:Tm})};let Dm=(nr=class{constructor({textContentSource:t,container:e,viewport:i}){var s;if(Gd(this,cr),Gd(this,Un,Promise.withResolvers()),Gd(this,Hn,null),Gd(this,$n,!1),Gd(this,jn,!!(null==(On=globalThis.FontInspector)?void 0:On.enabled)),Gd(this,zn,null),Gd(this,Vn,null),Gd(this,Gn,0),Gd(this,qn,0),Gd(this,Xn,null),Gd(this,Yn,null),Gd(this,Kn,0),Gd(this,Qn,0),Gd(this,Jn,Object.create(null)),Gd(this,Zn,[]),Gd(this,tr,null),Gd(this,er,[]),Gd(this,ir,new WeakMap),Gd(this,sr,null),t instanceof ReadableStream)qd(this,tr,t);else{if("object"!=typeof t)throw new Error('No "textContentSource" parameter specified.');qd(this,tr,new ReadableStream({start(e){e.enqueue(t),e.close()}}))}qd(this,Hn,qd(this,Yn,e)),qd(this,Qn,i.scale*Lp.pixelRatio),qd(this,Kn,i.rotation),qd(this,Vn,{div:null,properties:null,ctx:null});const{pageWidth:n,pageHeight:r,pageX:a,pageY:o}=i.rawDims;qd(this,sr,[1,0,0,-1,-a,o+r]),qd(this,qn,n),qd(this,Gn,r),Xd(s=nr,gr,vr).call(s),Ip(e,i),Vd(this,Un).promise.finally(()=>{Vd(nr,hr).delete(this),qd(this,Vn,null),qd(this,Jn,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=ip.platform;return Gu(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const t=()=>{Vd(this,Xn).read().then(({value:e,done:i})=>{i?Vd(this,Un).resolve():(Vd(this,zn)??qd(this,zn,e.lang),Object.assign(Vd(this,Jn),e.styles),Xd(this,cr,dr).call(this,e.items),t())},Vd(this,Un).reject)};return qd(this,Xn,Vd(this,tr).getReader()),Vd(nr,hr).add(this),t(),Vd(this,Un).promise}update({viewport:t,onBefore:e=null}){var i;const s=t.scale*Lp.pixelRatio,n=t.rotation;if(n!==Vd(this,Kn)&&(null==e||e(),qd(this,Kn,n),Ip(Vd(this,Yn),{rotation:n})),s!==Vd(this,Qn)){null==e||e(),qd(this,Qn,s);const t={div:null,properties:null,ctx:Xd(i=nr,gr,fr).call(i,Vd(this,zn))};for(const e of Vd(this,er))t.properties=Vd(this,ir).get(e),t.div=e,Xd(this,cr,pr).call(this,t)}}cancel(){var t;const e=new Zu("TextLayer task cancelled.");null==(t=Vd(this,Xn))||t.cancel(e).catch(()=>{}),qd(this,Xn,null),Vd(this,Un).reject(e)}get textDivs(){return Vd(this,er)}get textContentItemsStr(){return Vd(this,Zn)}static cleanup(){if(!(Vd(this,hr).size>0)){Vd(this,rr).clear();for(const{canvas:t}of Vd(this,ar).values())t.remove();Vd(this,ar).clear()}}},Un=new WeakMap,Hn=new WeakMap,$n=new WeakMap,jn=new WeakMap,zn=new WeakMap,Vn=new WeakMap,Gn=new WeakMap,qn=new WeakMap,Xn=new WeakMap,Yn=new WeakMap,Kn=new WeakMap,Qn=new WeakMap,Jn=new WeakMap,Zn=new WeakMap,tr=new WeakMap,er=new WeakMap,ir=new WeakMap,sr=new WeakMap,rr=new WeakMap,ar=new WeakMap,or=new WeakMap,lr=new WeakMap,hr=new WeakMap,cr=new WeakSet,dr=function(t){var e,i;if(Vd(this,$n))return;(i=Vd(this,Vn)).ctx??(i.ctx=Xd(e=nr,gr,fr).call(e,Vd(this,zn)));const s=Vd(this,er),n=Vd(this,Zn);for(const r of t){if(s.length>1e5)return Hu("Ignoring additional textDivs for performance reasons."),void qd(this,$n,!0);if(void 0!==r.str)n.push(r.str),Xd(this,cr,ur).call(this,r);else if("beginMarkedContentProps"===r.type||"beginMarkedContent"===r.type){const t=Vd(this,Hn);qd(this,Hn,document.createElement("span")),Vd(this,Hn).classList.add("markedContent"),r.id&&Vd(this,Hn).setAttribute("id",`${r.id}`),t.append(Vd(this,Hn))}else"endMarkedContent"===r.type&&qd(this,Hn,Vd(this,Hn).parentNode)}},ur=function(t){var e;const i=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};Vd(this,er).push(i);const n=np.transform(Vd(this,sr),t.transform);let r=Math.atan2(n[1],n[0]);const a=Vd(this,Jn)[t.fontName];a.vertical&&(r+=Math.PI/2);let o=Vd(this,jn)&&a.fontSubstitution||a.fontFamily;o=nr.fontFamilyMap.get(o)||o;const l=Math.hypot(n[2],n[3]),h=l*Xd(e=nr,gr,wr).call(e,o,a,Vd(this,zn));let c,d;0===r?(c=n[4],d=n[5]-h):(c=n[4]+h*Math.sin(r),d=n[5]-h*Math.cos(r));const u="calc(var(--total-scale-factor) *",p=i.style;Vd(this,Hn)===Vd(this,Yn)?(p.left=`${(100*c/Vd(this,qn)).toFixed(2)}%`,p.top=`${(100*d/Vd(this,Gn)).toFixed(2)}%`):(p.left=`${u}${c.toFixed(2)}px)`,p.top=`${u}${d.toFixed(2)}px)`),p.fontSize=`${u}${(Vd(nr,lr)*l).toFixed(2)}px)`,p.fontFamily=o,s.fontSize=l,i.setAttribute("role","presentation"),i.textContent=t.str,i.dir=t.dir,Vd(this,jn)&&(i.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),0!==r&&(s.angle=r*(180/Math.PI));let g=!1;if(t.str.length>1)g=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(g=!0)}if(g&&(s.canvasWidth=a.vertical?t.height:t.width),Vd(this,ir).set(i,s),Vd(this,Vn).div=i,Vd(this,Vn).properties=s,Xd(this,cr,pr).call(this,Vd(this,Vn)),s.hasText&&Vd(this,Hn).append(i),s.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),Vd(this,Hn).append(t)}},pr=function(t){var e;const{div:i,properties:s,ctx:n}=t,{style:r}=i;let a="";if(Vd(nr,lr)>1&&(a=`scale(${1/Vd(nr,lr)})`),0!==s.canvasWidth&&s.hasText){const{fontFamily:t}=r,{canvasWidth:o,fontSize:l}=s;Xd(e=nr,gr,mr).call(e,n,l*Vd(this,Qn),t);const{width:h}=n.measureText(i.textContent);h>0&&(a=`scaleX(${o*Vd(this,Qn)/h}) ${a}`)}0!==s.angle&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(r.transform=a)},gr=new WeakSet,fr=function(t=null){let e=Vd(this,ar).get(t||(t=""));if(!e){const i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),Vd(this,ar).set(t,e),Vd(this,or).set(e,{size:0,family:""})}return e},mr=function(t,e,i){const s=Vd(this,or).get(t);e===s.size&&i===s.family||(t.font=`${e}px ${i}`,s.size=e,s.family=i)},vr=function(){if(null!==Vd(this,lr))return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),qd(this,lr,t.getBoundingClientRect().height),t.remove()},wr=function(t,e,i){const s=Vd(this,rr).get(t);if(s)return s;const n=Xd(this,gr,fr).call(this,i);n.canvas.width=n.canvas.height=30,Xd(this,gr,mr).call(this,n,30,t);const r=n.measureText(""),a=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);n.canvas.width=n.canvas.height=0;let l=.8;return a?l=a/(a+o):(ip.platform.isFirefox&&Hu("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?l=e.ascent:e.descent&&(l=1+e.descent)),Vd(this,rr).set(t,l),l},Gd(nr,gr),Gd(nr,rr,new Map),Gd(nr,ar,new Map),Gd(nr,or,new WeakMap),Gd(nr,lr,null),Gd(nr,hr,new Set),nr);function Rm(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new Lm,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;if("string"==typeof t){if(iu)return t;const e=URL.parse(t,window.location);if(e)return e.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(iu&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return ep(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(null==t?void 0:t.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,r=t.httpHeaders||null,a=!0===t.withCredentials,o=t.password??null,l=t.range instanceof Fm?t.range:null,h=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536;let c=t.worker instanceof Om?t.worker:null;const d=t.verbosity,u="string"!=typeof t.docBaseUrl||yp(t.docBaseUrl)?null:t.docBaseUrl,p=_g(t.cMapUrl),g=!1!==t.cMapPacked,f=t.CMapReaderFactory||(iu?Jg:$g),m=_g(t.iccUrl),v=_g(t.standardFontDataUrl),w=t.StandardFontDataFactory||(iu?Zg:Gg),b=_g(t.wasmUrl),y=t.WasmFactory||(iu?tf:Xg),A=!0!==t.stopAtErrors,_=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,x=!1!==t.isEvalSupported,k="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!iu,S="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!iu&&(ip.platform.isFirefox||!globalThis.chrome),M=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,E="boolean"==typeof t.disableFontFace?t.disableFontFace:iu,C=!0===t.fontExtraProperties,T=!0===t.enableXfa,P=t.ownerDocument||globalThis.document,D=!0===t.disableRange,R=!0===t.disableStream,I=!0===t.disableAutoFetch,L=!0===t.pdfBug,F=t.CanvasFactory||(iu?Qg:Ug),N=t.FilterFactory||(iu?Kg:zg),W=!0===t.enableHWA,B=!1!==t.useWasm,O=l?l.length:t.length??NaN,U="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!iu&&!E,H="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(f===$g&&w===Gg&&y===Xg&&p&&v&&b&&Sp(p,document.baseURI)&&Sp(v,document.baseURI)&&Sp(b,document.baseURI));var $;$=d,Number.isInteger($)&&(Bu=$);const j={canvasFactory:new F({ownerDocument:P,enableHWA:W}),filterFactory:new N({docId:i,ownerDocument:P}),cMapReaderFactory:H?null:new f({baseUrl:p,isCompressed:g}),standardFontDataFactory:H?null:new w({baseUrl:v}),wasmFactory:H?null:new y({baseUrl:b})};c||(c=Om.create({verbosity:d,port:im.workerPort}),e._worker=c);const z={docId:i,apiVersion:"5.4.296",data:n,password:o,disableAutoFetch:I,rangeChunkSize:h,length:O,docBaseUrl:u,enableXfa:T,evaluatorOptions:{maxImageSize:_,disableFontFace:E,ignoreErrors:A,isEvalSupported:x,isOffscreenCanvasSupported:k,isImageDecoderSupported:S,canvasMaxAreaInBytes:M,fontExtraProperties:C,useSystemFonts:U,useWasm:B,useWorkerFetch:H,cMapUrl:p,iccUrl:m,standardFontDataUrl:v,wasmUrl:b}},V={ownerDocument:P,pdfBug:L,styleElement:null,loadingParams:{disableAutoFetch:I,enableXfa:T}};return c.promise.then(function(){if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const t=c.messageHandler.sendWithPromise("GetDocRequest",z,n?[n.buffer]:null);let o;if(l)o=new om(l,{disableRange:D,disableStream:R});else if(!n){if(!s)throw new Error("getDocument - no `url` parameter provided.");const t=Sp(s)?wm:iu?Mm:_m;o=new t({url:s,length:O,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:D,disableStream:R})}return t.then(t=>{if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const s=new Bg(i,t,c.port),n=new Um(s,e,o,V,j,W);e._transport=n,s.send("Ready",null)})}).catch(e._capability.reject),e}const Im=class t{constructor(){jd(this,"_capability",Promise.withResolvers()),jd(this,"_transport",null),jd(this,"_worker",null),jd(this,"docId","d"+Yd(t,br)._++),jd(this,"destroyed",!1),jd(this,"onPassword",null),jd(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var t,e,i,s;this.destroyed=!0;try{(null==(t=this._worker)?void 0:t.port)&&(this._worker._pendingDestroy=!0),await(null==(e=this._transport)?void 0:e.destroy())}catch(n){throw(null==(i=this._worker)?void 0:i.port)&&delete this._worker._pendingDestroy,n}this._transport=null,null==(s=this._worker)||s.destroy(),this._worker=null}async getData(){return this._transport.getData()}};br=new WeakMap,Gd(Im,br,0);let Lm=Im,Fm=(Sr=class{constructor(t,e,i=!1,s=null){Gd(this,yr,Promise.withResolvers()),Gd(this,Ar,[]),Gd(this,_r,[]),Gd(this,xr,[]),Gd(this,kr,[]),this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s}addRangeListener(t){Vd(this,kr).push(t)}addProgressListener(t){Vd(this,xr).push(t)}addProgressiveReadListener(t){Vd(this,_r).push(t)}addProgressiveDoneListener(t){Vd(this,Ar).push(t)}onDataRange(t,e){for(const i of Vd(this,kr))i(t,e)}onDataProgress(t,e){Vd(this,yr).promise.then(()=>{for(const i of Vd(this,xr))i(t,e)})}onDataProgressiveRead(t){Vd(this,yr).promise.then(()=>{for(const e of Vd(this,_r))e(t)})}onDataProgressiveDone(){Vd(this,yr).promise.then(()=>{for(const t of Vd(this,Ar))t()})}transportReady(){Vd(this,yr).resolve()}requestDataRange(t,e){$u("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}},yr=new WeakMap,Ar=new WeakMap,_r=new WeakMap,xr=new WeakMap,kr=new WeakMap,Sr);class Nm{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Gu(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}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 Wm{constructor(t,e,i,s=!1){Gd(this,Er),Gd(this,Mr,!1),this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new kp:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new Pm,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new wp({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Gu(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return(null==(t=this._transport._htmlForXfa)?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,canvas:e=t.canvas,viewport:i,intent:s="display",annotationMode:n=pu.ENABLE,transform:r=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:h=null,printAnnotationStorage:c=null,isEditing:d=!1,recordOperations:u=!1,operationsFilter:p=null}){var g,f,m;null==(g=this._stats)||g.time("Overall");const v=this._transport.getRenderingIntent(s,n,c,d),{renderingIntent:w,cacheKey:b}=v;qd(this,Mr,!1),o||(o=this._transport.getOptionalContentConfig(w));let y=this._intentStates.get(b);y||(y=Object.create(null),this._intentStates.set(b,y)),y.streamReaderCancelTimeout&&(clearTimeout(y.streamReaderCancelTimeout),y.streamReaderCancelTimeout=null);const A=!!(w&ou);y.displayReadyCapability||(y.displayReadyCapability=Promise.withResolvers(),y.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(f=this._stats)||f.time("Page Request"),this._pumpOperatorList(v));const _=Boolean(this._pdfBug&&(null==(m=globalThis.StepperManager)?void 0:m.enabled)),x=!this.recordedBBoxes&&(u||_),k=t=>{var e,i;if(y.renderTasks.delete(S),x){const t=null==(e=S.gfx)?void 0:e.dependencyTracker.take();t&&(S.stepper&&S.stepper.setOperatorBBoxes(t,S.gfx.dependencyTracker.takeDebugMetadata()),u&&(this.recordedBBoxes=t))}A&&qd(this,Mr,!0),Xd(this,Er,Cr).call(this),t?(S.capability.reject(t),this._abortOperatorList({intentState:y,reason:t instanceof Error?t:new Error(t)})):S.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(null==(i=globalThis.Stats)?void 0:i.enabled)&&globalThis.Stats.add(this.pageNumber,this._stats))},S=new jm({callback:k,params:{canvas:e,canvasContext:t,dependencyTracker:x?new hf(e,y.operatorList.length,_):null,viewport:i,transform:r,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:y.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!A,pdfBug:this._pdfBug,pageColors:h,enableHWA:this._transport.enableHWA,operationsFilter:p});(y.renderTasks||(y.renderTasks=new Set)).add(S);const M=S.task;return Promise.all([y.displayReadyCapability.promise,o]).then(([t,e])=>{var i;if(this.destroyed)k();else{if(null==(i=this._stats)||i.time("Rendering"),!(e.renderingIntent&w))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");S.initializeGraphics({transparency:t,optionalContentConfig:e}),S.operatorListChanged()}}).catch(k),M}getOperatorList({intent:t="display",annotationMode:e=pu.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){var n;const r=this._transport.getRenderingIntent(t,e,i,s,!0);let a,o=this._intentStates.get(r.cacheKey);return o||(o=Object.create(null),this._intentStates.set(r.cacheKey,o)),o.opListReadCapability||(a=Object.create(null),a.operatorListChanged=function(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(a))},o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(a),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(n=this._stats)||n.time("Page Request"),this._pumpOperatorList(r)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(t=>up.textContent(t));const e=this.streamTextContent(t);return new Promise(function(t,i){const s=e.getReader(),n={items:[],styles:Object.create(null),lang:null};!function e(){s.read().then(function({value:i,done:s}){s?t(n):(n.lang??(n.lang=i.lang),Object.assign(n.styles,i.styles),n.items.push(...i.items),e())},i)}()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),qd(this,Mr,!1),Promise.all(t)}cleanup(t=!1){qd(this,Mr,!0);const e=Xd(this,Er,Cr).call(this);return t&&e&&this._stats&&(this._stats=new kp),e}_startRenderPage(t,e){var i,s;const n=this._intentStates.get(e);n&&(null==(i=this._stats)||i.timeEnd("Page Request"),null==(s=n.displayReadyCapability)||s.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const i of e.renderTasks)i.operatorListChanged();t.lastChunk&&Xd(this,Er,Cr).call(this)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){const{map:n,transfer:r}=i,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:s},r).getReader(),o=this._intentStates.get(e);o.streamReader=a;const l=()=>{a.read().then(({value:t,done:e})=>{e?o.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,o),l())},t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const t of o.renderTasks)t.operatorListChanged();Xd(this,Er,Cr).call(this)}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else{if(!o.opListReadCapability)throw t;o.opListReadCapability.reject(t)}}})};l()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof bp){let i=100;return e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i))}}if(t.streamReader.cancel(new Zu(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}Mr=new WeakMap,Er=new WeakSet,Cr=function(){if(!Vd(this,Mr)||this.destroyed)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),qd(this,Mr,!1),!0};const Bm=class t{constructor({name:e=null,port:i=null,verbosity:s=Ou()}={}){if(Gd(this,Nr),Gd(this,Tr,Promise.withResolvers()),Gd(this,Pr,null),Gd(this,Dr,null),Gd(this,Rr,null),this.name=e,this.destroyed=!1,this.verbosity=s,i){if(Vd(t,Fr).has(i))throw new Error("Cannot use more than one PDFWorker per port.");Vd(t,Fr).set(i,this),Xd(this,Nr,Br).call(this,i)}else Xd(this,Nr,Or).call(this)}get promise(){return Vd(this,Tr).promise}get port(){return Vd(this,Dr)}get messageHandler(){return Vd(this,Pr)}destroy(){var e,i;this.destroyed=!0,null==(e=Vd(this,Rr))||e.terminate(),qd(this,Rr,null),Vd(t,Fr).delete(Vd(this,Dr)),qd(this,Dr,null),null==(i=Vd(this,Pr))||i.destroy(),qd(this,Pr,null)}static create(e){const i=Vd(this,Fr).get(null==e?void 0:e.port);if(i){if(i._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return i}return new t(e)}static get workerSrc(){if(im.workerSrc)return im.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return Gu(this,"_setupFakeWorkerGlobal",(async()=>{if(Vd(this,Hr,$r))return Vd(this,Hr,$r);return(await import(this.workerSrc)).WorkerMessageHandler})())}};Tr=new WeakMap,Pr=new WeakMap,Dr=new WeakMap,Rr=new WeakMap,Ir=new WeakMap,Lr=new WeakMap,Fr=new WeakMap,Nr=new WeakSet,Wr=function(){Vd(this,Tr).resolve(),Vd(this,Pr).send("configure",{verbosity:this.verbosity})},Br=function(t){qd(this,Dr,t),qd(this,Pr,new Bg("main","worker",t)),Vd(this,Pr).on("ready",()=>{}),Xd(this,Nr,Wr).call(this)},Or=function(){if(Vd(Bm,Lr)||Vd(Bm,Hr,$r))return void Xd(this,Nr,Ur).call(this);let{workerSrc:t}=Bm;try{Bm._isSameOrigin(window.location,t)||(t=Bm._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),i=new Bg("main","worker",e),s=()=>{n.abort(),i.destroy(),e.terminate(),this.destroyed?Vd(this,Tr).reject(new Error("Worker was destroyed")):Xd(this,Nr,Ur).call(this)},n=new AbortController;e.addEventListener("error",()=>{Vd(this,Rr)||s()},{signal:n.signal}),i.on("test",t=>{n.abort(),!this.destroyed&&t?(qd(this,Pr,i),qd(this,Dr,e),qd(this,Rr,e),Xd(this,Nr,Wr).call(this)):s()}),i.on("ready",t=>{if(n.abort(),this.destroyed)s();else try{r()}catch{Xd(this,Nr,Ur).call(this)}});const r=()=>{const t=new Uint8Array;i.send("test",t,[t.buffer])};return void r()}catch{Uu("The worker has been disabled.")}Xd(this,Nr,Ur).call(this)},Ur=function(){Vd(Bm,Lr)||(Hu("Setting up fake worker."),qd(Bm,Lr,!0)),Bm._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void Vd(this,Tr).reject(new Error("Worker was destroyed"));const e=new Sg;qd(this,Dr,e);const i="fake"+Yd(Bm,Ir)._++,s=new Bg(i+"_worker",i,e);t.setup(s,e),qd(this,Pr,new Bg(i,i+"_worker",e)),Xd(this,Nr,Wr).call(this)}).catch(t=>{Vd(this,Tr).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},Hr=new WeakSet,$r=function(){var t;try{return(null==(t=globalThis.pdfjsWorker)?void 0:t.WorkerMessageHandler)||null}catch{return null}},Gd(Bm,Hr),Gd(Bm,Ir,0),Gd(Bm,Lr,!1),Gd(Bm,Fr,new WeakMap),iu&&(qd(Bm,Lr,!0),im.workerSrc||(im.workerSrc="./pdf.worker.mjs")),Bm._isSameOrigin=(t,e)=>{const i=URL.parse(t);if(!(null==i?void 0:i.origin)||"null"===i.origin)return!1;const s=new URL(e,i);return i.origin===s.origin},Bm._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},Bm.fromPort=t=>{var e;if(e="`PDFWorker.fromPort` - please use `PDFWorker.create` instead.",console.log("Deprecated API usage: "+e),!(null==t?void 0:t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");return Bm.create(t)};let Om=Bm;class Um{constructor(t,e,i,s,n,r){Gd(this,Xr),Gd(this,jr,new Map),Gd(this,zr,new Map),Gd(this,Vr,new Map),Gd(this,Gr,new Map),Gd(this,qr,null),this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Pm,this.fontLoader=new yg({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.wasmFactory=n.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=r,this.setupMessageHandler()}get annotationStorage(){return Gu(this,"annotationStorage",new wg)}getRenderingIntent(t,e=pu.ENABLE,i=null,s=!1,n=!1){let r=au,a=vg;switch(t){case"any":r=ru;break;case"display":break;case"print":r=ou;break;default:Hu(`getRenderingIntent - invalid intent: ${t}`)}const o=r&ou&&i instanceof bg?i:this.annotationStorage;switch(e){case pu.DISABLE:r+=cu;break;case pu.ENABLE:break;case pu.ENABLE_FORMS:r+=lu;break;case pu.ENABLE_STORAGE:r+=hu,a=o.serializable;break;default:Hu(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(r+=du),n&&(r+=uu);const{ids:l,hash:h}=o.modifiedIds;return{renderingIntent:r,cacheKey:[r,a.hash,h].join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){var t;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),null==(t=Vd(this,qr))||t.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const s of Vd(this,zr).values())e.push(s._destroy());Vd(this,zr).clear(),Vd(this,Vr).clear(),Vd(this,Gr).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const i=this.messageHandler.sendWithPromise("Terminate",null);return e.push(i),Promise.all(e).then(()=>{var t,e;this.commonObjs.clear(),this.fontLoader.clear(),Vd(this,jr).clear(),this.filterFactory.destroy(),Dm.cleanup(),null==(t=this._networkStream)||t.cancelAllRequests(new Zu("Worker was terminated.")),null==(e=this.messageHandler)||e.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(t,e)=>{ju(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then(function({value:t,done:i}){i?e.close():(ju(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("ReaderHeadersReady",async t=>{var i;await this._fullReader.headersReady;const{isStreamingSupported:s,isRangeSupported:n,contentLength:r}=this._fullReader;return s&&n||(this._lastProgress&&(null==(i=e.onProgress)||i.call(e,this._lastProgress)),this._fullReader.onProgress=t=>{var i;null==(i=e.onProgress)||i.call(e,{loaded:t.loaded,total:t.total})}),{isStreamingSupported:s,isRangeSupported:n,contentLength:r}}),t.on("GetRangeReader",(t,e)=>{ju(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const i=this._networkStream.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then(function({value:t,done:i}){i?e.close():(ju(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{i.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}):e.close()}),t.on("GetDoc",({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new Nm(t,this))}),t.on("DocException",t=>{e._capability.reject(Wg(t))}),t.on("PasswordRequest",t=>{qd(this,qr,Promise.withResolvers());try{if(!e.onPassword)throw Wg(t);const i=t=>{t instanceof Error?Vd(this,qr).reject(t):Vd(this,qr).resolve({password:t})};e.onPassword(i,t.code)}catch(i){Vd(this,qr).reject(i)}return Vd(this,qr).promise}),t.on("DataLoaded",t=>{var i;null==(i=e.onProgress)||i.call(e,{loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)}),t.on("StartRenderPage",t=>{if(this.destroyed)return;Vd(this,zr).get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}),t.on("commonobj",([e,i,s])=>{var n;if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(i){case"Font":if("error"in s){const t=s.error;Hu(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const r=new em(s),a=this._params.pdfBug&&(null==(n=globalThis.FontInspector)?void 0:n.enabled)?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,o=new Ag(r,a,s.extra,s.charProcOperatorList);this.fontLoader.bind(o).catch(()=>t.sendWithPromise("FontFallback",{id:e})).finally(()=>{!o.fontExtraProperties&&o.data&&o.clearData(),this.commonObjs.resolve(e,o)});break;case"CopyLocalImage":const{imageRef:l}=s;ju(l,"The imageRef must be defined.");for(const t of Vd(this,zr).values())for(const[,i]of t.objs)if((null==i?void 0:i.ref)===l)return i.dataLen?(this.commonObjs.resolve(e,structuredClone(i)),i.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,s);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([t,e,i,s])=>{var n;if(this.destroyed)return;const r=Vd(this,zr).get(e);if(!r.objs.has(t))if(0!==r._intentStates.size)switch(i){case"Image":case"Pattern":r.objs.resolve(t,s);break;default:throw new Error(`Got unknown object type ${i}`)}else null==(n=null==s?void 0:s.bitmap)||n.close()}),t.on("DocProgress",t=>{var i;this.destroyed||null==(i=e.onProgress)||i.call(e,{loaded:t.loaded,total:t.total})}),t.on("FetchBinaryData",async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");const e=this[t.type];if(!e)throw new Error(`${t.type} not initialized, see the \`useWorkerFetch\` parameter.`);return e.fetch(t)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var t;this.annotationStorage.size<=0&&Hu("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfer:i}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:(null==(t=this._fullReader)?void 0:t.filename)??null},i).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,i=Vd(this,Vr).get(e);if(i)return i;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(i=>{if(this.destroyed)throw new Error("Transport destroyed");i.refStr&&Vd(this,Gr).set(i.refStr,t);const s=new Wm(e,i,this,this._params.pdfBug);return Vd(this,zr).set(e,s),s});return Vd(this,Vr).set(e,s),s}getPageIndex(t){return xg(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 Xd(this,Xr,Yr).call(this,"GetFieldObjects")}hasJSActions(){return Xd(this,Xr,Yr).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return Xd(this,Xr,Yr).call(this,"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 Xd(this,Xr,Yr).call(this,"GetOptionalContentConfig").then(e=>new am(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=Vd(this,jr).get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then(t=>{var e,i;return{info:t[0],metadata:t[1]?new sm(t[1]):null,contentDispositionFilename:(null==(e=this._fullReader)?void 0:e.filename)??null,contentLength:(null==(i=this._fullReader)?void 0:i.contentLength)??null}});return Vd(this,jr).set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of Vd(this,zr).values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),Vd(this,jr).clear(),this.filterFactory.destroy(!0),Dm.cleanup()}}cachedPageNumber(t){if(!xg(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return Vd(this,Gr).get(e)??null}}jr=new WeakMap,zr=new WeakMap,Vr=new WeakMap,Gr=new WeakMap,qr=new WeakMap,Xr=new WeakSet,Yr=function(t,e=null){const i=Vd(this,jr).get(t);if(i)return i;const s=this.messageHandler.sendWithPromise(t,e);return Vd(this,jr).set(t,s),s};class Hm{constructor(t){Gd(this,Kr,null),jd(this,"onContinue",null),jd(this,"onError",null),qd(this,Kr,t)}get promise(){return Vd(this,Kr).capability.promise}cancel(t=0){Vd(this,Kr).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=Vd(this,Kr).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=Vd(this,Kr);return t.form||t.canvas&&(null==e?void 0:e.size)>0}}Kr=new WeakMap;const $m=class t{constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:c=!1,pageColors:d=null,enableHWA:u=!1,operationsFilter:p=null}){Gd(this,Qr,null),this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=c,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Hm(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=u,this._dependencyTracker=e.dependencyTracker,this._operationsFilter=p}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:i}){var s,n;if(this.cancelled)return;if(this._canvas){if(Vd(t,Jr).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.");Vd(t,Jr).add(this._canvas)}this._pdfBug&&(null==(s=globalThis.StepperManager)?void 0:s.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:r,transform:a,background:o,dependencyTracker:l}=this.params,h=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Yf(h,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:i},this.annotationCanvasMap,this.pageColors,l),this.gfx.beginDrawing({transform:a,viewport:r,transparency:e,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,null==(n=this.graphicsReadyCallback)||n.call(this)}cancel(e=null,i=0){var s,n,r;this.running=!1,this.cancelled=!0,null==(s=this.gfx)||s.endDrawing(),Vd(this,Qr)&&(window.cancelAnimationFrame(Vd(this,Qr)),qd(this,Qr,null)),Vd(t,Jr).delete(this._canvas),e||(e=new bp(`Rendering cancelled, page ${this._pageIndex+1}`,i)),this.callback(e),null==(r=(n=this.task).onError)||r.call(n,e)}operatorListChanged(){var t,e;this.graphicsReady?(null==(t=this.gfx.dependencyTracker)||t.growOperationsCount(this.operatorList.fnArray.length),null==(e=this.stepper)||e.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound)}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?qd(this,Qr,window.requestAnimationFrame(()=>{qd(this,Qr,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),Vd(t,Jr).delete(this._canvas),this.callback())))}};Qr=new WeakMap,Jr=new WeakMap,Gd($m,Jr,new WeakSet);let jm=$m;const zm="5.4.296",Vm="f56dc8601",Gm=class t{constructor({editor:e=null,uiManager:i=null}){var s,n;Gd(this,ca),Gd(this,Zr,null),Gd(this,ta,null),Gd(this,ea),Gd(this,ia,null),Gd(this,sa,!1),Gd(this,na,!1),Gd(this,ra,null),Gd(this,aa),Gd(this,oa,null),Gd(this,la,null),e?(qd(this,na,!1),qd(this,ra,e)):qd(this,na,!0),qd(this,la,(null==e?void 0:e._uiManager)||i),qd(this,aa,Vd(this,la)._eventBus),qd(this,ea,(null==(s=null==e?void 0:e.color)?void 0:s.toUpperCase())||(null==(n=Vd(this,la))?void 0:n.highlightColors.values().next().value)||"#FFFF98"),Vd(t,ha)||qd(t,ha,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return Gu(this,"_keyboardManager",new tg([[["Escape","mac+Escape"],t.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],t.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],t.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],t.prototype._moveToPrevious],[["Home","mac+Home"],t.prototype._moveToBeginning],[["End","mac+End"],t.prototype._moveToEnd]]))}renderButton(){const t=qd(this,Zr,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",Vd(this,ra)&&(t.ariaControls=`${Vd(this,ra).id}_colorpicker_dropdown`);const e=Vd(this,la)._signal;t.addEventListener("click",Xd(this,ca,ga).bind(this),{signal:e}),t.addEventListener("keydown",Xd(this,ca,pa).bind(this),{signal:e});const i=qd(this,ta,document.createElement("span"));return i.className="swatch",i.ariaHidden="true",i.style.backgroundColor=Vd(this,ea),t.append(i),t}renderMainDropdown(){const t=qd(this,ia,Xd(this,ca,da).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===Vd(this,Zr))return void Xd(this,ca,ga).call(this,t);const e=t.target.getAttribute("data-color");e&&Xd(this,ca,ua).call(this,e,t)}_moveToNext(t){var e,i;Vd(this,ca,ma)?t.target!==Vd(this,Zr)?null==(i=t.target.nextSibling)||i.focus():null==(e=Vd(this,ia).firstChild)||e.focus():Xd(this,ca,ga).call(this,t)}_moveToPrevious(t){var e,i;t.target!==(null==(e=Vd(this,ia))?void 0:e.firstChild)&&t.target!==Vd(this,Zr)?(Vd(this,ca,ma)||Xd(this,ca,ga).call(this,t),null==(i=t.target.previousSibling)||i.focus()):Vd(this,ca,ma)&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){var e;Vd(this,ca,ma)?null==(e=Vd(this,ia).firstChild)||e.focus():Xd(this,ca,ga).call(this,t)}_moveToEnd(t){var e;Vd(this,ca,ma)?null==(e=Vd(this,ia).lastChild)||e.focus():Xd(this,ca,ga).call(this,t)}hideDropdown(){var t,e;null==(t=Vd(this,ia))||t.classList.add("hidden"),Vd(this,Zr).ariaExpanded="false",null==(e=Vd(this,oa))||e.abort(),qd(this,oa,null)}_hideDropdownFromKeyboard(){var t;Vd(this,na)||(Vd(this,ca,ma)?(this.hideDropdown(),Vd(this,Zr).focus({preventScroll:!0,focusVisible:Vd(this,sa)})):null==(t=Vd(this,ra))||t.unselect())}updateColor(t){if(Vd(this,ta)&&(Vd(this,ta).style.backgroundColor=t),!Vd(this,ia))return;const e=Vd(this,la).highlightColors.values();for(const i of Vd(this,ia).children)i.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;null==(t=Vd(this,Zr))||t.remove(),qd(this,Zr,null),qd(this,ta,null),null==(e=Vd(this,ia))||e.remove(),qd(this,ia,null)}};Zr=new WeakMap,ta=new WeakMap,ea=new WeakMap,ia=new WeakMap,sa=new WeakMap,na=new WeakMap,ra=new WeakMap,aa=new WeakMap,oa=new WeakMap,la=new WeakMap,ha=new WeakMap,ca=new WeakSet,da=function(){const t=document.createElement("div"),e=Vd(this,la)._signal;t.addEventListener("contextmenu",Mp,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),Vd(this,ra)&&(t.id=`${Vd(this,ra).id}_colorpicker_dropdown`);for(const[i,s]of Vd(this,la).highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",s),n.title=i,n.setAttribute("data-l10n-id",Vd(Gm,ha)[i]);const r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=s,n.ariaSelected=s===Vd(this,ea),n.addEventListener("click",Xd(this,ca,ua).bind(this,s),{signal:e}),t.append(n)}return t.addEventListener("keydown",Xd(this,ca,pa).bind(this),{signal:e}),t},ua=function(t,e){e.stopPropagation(),Vd(this,aa).dispatch("switchannotationeditorparams",{source:this,type:mu.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)},pa=function(t){Gm._keyboardManager.exec(this,t)},ga=function(t){if(Vd(this,ca,ma))return void this.hideDropdown();if(qd(this,sa,0===t.detail),Vd(this,oa)||(qd(this,oa,new AbortController),window.addEventListener("pointerdown",Xd(this,ca,fa).bind(this),{signal:Vd(this,la).combinedSignal(Vd(this,oa))})),Vd(this,Zr).ariaExpanded="true",Vd(this,ia))return void Vd(this,ia).classList.remove("hidden");const e=qd(this,ia,Xd(this,ca,da).call(this));Vd(this,Zr).append(e)},fa=function(t){var e;(null==(e=Vd(this,ia))?void 0:e.contains(t.target))||this.hideDropdown()},ma=function(){return Vd(this,ia)&&!Vd(this,ia).classList.contains("hidden")},Gd(Gm,ha,null);let qm=Gm;const Xm=class t{constructor(e){Gd(this,va,null),Gd(this,wa,null),Gd(this,ba,null),qd(this,wa,e),qd(this,ba,e._uiManager),Vd(t,ya)||qd(t,ya,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(Vd(this,va))return Vd(this,va);const{editorType:e,colorType:i,colorValue:s}=Vd(this,wa),n=qd(this,va,document.createElement("input"));return n.type="color",n.value=s||"#000000",n.className="basicColorPicker",n.tabIndex=0,n.setAttribute("data-l10n-id",Vd(t,ya)[e]),n.addEventListener("input",()=>{Vd(this,ba).updateParams(i,n.value)},{signal:Vd(this,ba)._signal}),n}update(t){Vd(this,va)&&(Vd(this,va).value=t)}destroy(){var t;null==(t=Vd(this,va))||t.remove(),qd(this,va,null)}hideDropdown(){}};va=new WeakMap,wa=new WeakMap,ba=new WeakMap,ya=new WeakMap,Gd(Xm,ya,null);let Ym=Xm;function Km(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function Qm(t){return Math.max(0,Math.min(255,255*t))}class Jm{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=Qm(t),t,t]}static G_HTML([t]){const e=Km(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(Qm)}static RGB_HTML(t){return`#${t.map(Km).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[Qm(1-Math.min(1,t+s)),Qm(1-Math.min(1,i+s)),Qm(1-Math.min(1,e+s))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const s=1-t,n=1-e,r=1-i;return["CMYK",s,n,r,Math.min(s,n,r)]}}class Zm{create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){$u("Abstract method `_createSVG` called.")}}class tv extends Zm{_createSVG(t){return document.createElementNS(gp,t)}}const ev=new WeakSet,iv=60*(new Date).getTimezoneOffset()*1e3;class sv{static create(t){switch(t.data.annotationType){case Su.LINK:return new av(t);case Su.TEXT:return new ov(t);case Su.WIDGET:switch(t.data.fieldType){case"Tx":return new hv(t);case"Btn":return t.data.radioButton?new uv(t):t.data.checkBox?new dv(t):new pv(t);case"Ch":return new gv(t);case"Sig":return new cv(t)}return new lv(t);case Su.POPUP:return new fv(t);case Su.FREETEXT:return new vv(t);case Su.LINE:return new wv(t);case Su.SQUARE:return new bv(t);case Su.CIRCLE:return new yv(t);case Su.POLYLINE:return new Av(t);case Su.CARET:return new xv(t);case Su.INK:return new kv(t);case Su.POLYGON:return new _v(t);case Su.HIGHLIGHT:return new Sv(t);case Su.UNDERLINE:return new Mv(t);case Su.SQUIGGLY:return new Ev(t);case Su.STRIKEOUT:return new Cv(t);case Su.STAMP:return new Tv(t);case Su.FILEATTACHMENT:return new Pv(t);default:return new nv(t)}}}Aa=new WeakMap,_a=new WeakMap,xa=new WeakMap,ka=new WeakSet,Sa=function(t){const{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;null==i||i.splice(0,4,...t),e.left=100*(t[0]-a)/n+"%",e.top=100*(r-t[3]+o)/r+"%",0===s?(e.width=100*(t[2]-t[0])/n+"%",e.height=100*(t[3]-t[1])/r+"%"):this.setRotation(s)};let nv=class t{constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}={}){Gd(this,ka),Gd(this,Aa,null),Gd(this,_a,!1),Gd(this,xa,null),this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!(!(null==t?void 0:t.str)&&!(null==e?void 0:e.str))}get _isEditable(){return this.data.isEditable}get hasPopupData(){return t._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){var t;const{data:e}=this,i=null==(t=this.annotationStorage)?void 0:t.getEditor(e.id);return i?i.getData():e}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){var t;const e=null==(t=this.annotationStorage)?void 0:t.getEditor(this.data.id);if(e)return e.commentButtonPositionInPage;const{quadPoints:i,inkLists:s,rect:n}=this.data;let r=-1/0,a=-1/0;if((null==i?void 0:i.length)>=8){for(let t=0;t<i.length;t+=8)i[t+1]>a?(a=i[t+1],r=i[t+2]):i[t+1]===a&&(r=Math.max(r,i[t+2]));return[r,a]}if((null==s?void 0:s.length)>=1){for(const t of s)for(let e=0,i=t.length;e<i;e+=2)t[e+1]>a?(a=t[e+1],r=t[e]):t[e+1]===a&&(r=Math.max(r,t[e]));if(r!==1/0)return[r,a]}return n?[n[2],n[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:r}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-n)/i,t[1]=100*(t[1]-r)/s,t}get commentText(){var t,e,i;const{data:s}=this;return(null==(e=null==(t=this.annotationStorage.getRawValue(`${gu}${s.id}`))?void 0:t.popup)?void 0:e.contents)||(null==(i=s.contentsObj)?void 0:i.str)||""}set commentText(t){const{data:e}=this,i={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:i})||this.annotationStorage.setValue(`${gu}${e.id}`,{id:e.id,annotationType:e.annotationType,pageIndex:this.parent.page._pageIndex,popup:i,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){var t,e;null==(e=(null==(t=Vd(this,xa))?void 0:t.popup)||this.popup)||e.remove(),qd(this,xa,this.popup=null)}updateEdited(t){var e;if(!this.container)return;t.rect&&(Vd(this,Aa)||qd(this,Aa,{rect:this.data.rect.slice(0)}));const{rect:i,popup:s}=t;i&&Xd(this,ka,Sa).call(this,i);let n=(null==(e=Vd(this,xa))?void 0:e.popup)||this.popup;!n&&(null==s?void 0:s.text)&&(this._createPopup(s),n=Vd(this,xa).popup),n&&(n.updateEdited(t),(null==s?void 0:s.deleted)&&(n.remove(),qd(this,xa,null),this.popup=null))}resetEdited(){var t;Vd(this,Aa)&&(Xd(this,ka,Sa).call(this,Vd(this,Aa).rect),null==(t=Vd(this,xa))||t.popup.resetEdited(),qd(this,Aa,null))}_createContainer(t){const{data:e,parent:{page:i,viewport:s}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof lv||this instanceof av||(n.tabIndex=0);const{style:r}=n;if(r.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof fv){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:a,height:o}=this;if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;if(t>0||i>0){const e=`calc(${t}px * var(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`;r.borderRadius=e}else if(this instanceof uv){const t=`calc(${a}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`;r.borderRadius=t}switch(e.borderStyle.style){case Mu:r.borderStyle="solid";break;case Eu:r.borderStyle="dashed";break;case Cu:Hu("Unimplemented border style: beveled");break;case Tu:Hu("Unimplemented border style: inset");break;case Pu:r.borderBottomStyle="solid"}const s=e.borderColor||null;s?(qd(this,_a,!0),r.borderColor=np.makeHexColor(0|s[0],0|s[1],0|s[2])):r.borderWidth=0}const l=np.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:h,pageHeight:c,pageX:d,pageY:u}=s.rawDims;r.left=100*(l[0]-d)/h+"%",r.top=100*(l[1]-u)/c+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(r.width=100*a/h+"%",r.height=100*o/c+"%"):this.setRotation(p,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims;let{width:n,height:r}=this;t%180!=0&&([n,r]=[r,n]),e.style.width=100*n/i+"%",e.style.height=100*r/s+"%",e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,i)=>{const s=i.detail[t],n=s[0],r=s.slice(1);i.target.style[e]=Jm[`${n}_HTML`](r),this.annotationStorage.setValue(this.data.id,{[e]:Jm[`${n}_rgb`](r)})};return Gu(this,"_commonActions",{display:t=>{const{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout(()=>t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const s of Object.keys(e.detail)){const n=t[s]||i[s];null==n||n(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[s,n]of Object.entries(e)){const r=i[s];if(r){r({detail:{[s]:n},target:t}),delete e[s]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,s,n]=this.data.rect.map(t=>Math.fround(t));if(8===t.length){const[r,a,o,l]=t.subarray(2,6);if(s===r&&n===a&&e===o&&i===l)return}const{style:r}=this.container;let a;if(Vd(this,_a)){const{borderColor:t,borderWidth:e}=r;r.borderWidth=0,a=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const o=s-e,l=n-i,{svgFactory:h}=this,c=h.createElement("svg");c.classList.add("quadrilateralsContainer"),c.setAttribute("width",0),c.setAttribute("height",0),c.role="none";const d=h.createElement("defs");c.append(d);const u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),d.append(u);for(let g=2,f=t.length;g<f;g+=8){const i=t[g],s=t[g+1],r=t[g+2],c=t[g+3],d=h.createElement("rect"),p=(r-e)/o,f=(n-s)/l,m=(i-r)/o,v=(s-c)/l;d.setAttribute("x",p),d.setAttribute("y",f),d.setAttribute("width",m),d.setAttribute("height",v),u.append(d),null==a||a.push(`<rect vector-effect="non-scaling-stroke" x="${p}" y="${f}" width="${m}" height="${v}"/>`)}Vd(this,_a)&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(c),this.container.style.clipPath=`url(#${p})`}_createPopup(t=null){const{data:e}=this;let i,s;t?(i={str:t.text},s=t.date):(i=e.contentsObj,s=e.modificationDate);const n=qd(this,xa,new fv({data:{color:e.color,titleObj:e.titleObj,modificationDate:s,contentsObj:i,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}));this.parent._commentManager||this.parent.div.append(n.render())}get hasPopupElement(){return!!(Vd(this,xa)||this.popup||this.data.popupRef)}get extraPopupElement(){return Vd(this,xa)}render(){$u("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const s=this._fieldObjects[t];if(s)for(const{page:t,id:n,exportValues:r}of s){if(-1===t)continue;if(n===e)continue;const s="string"==typeof r?r:null,a=document.querySelector(`[data-element-id="${n}"]`);!a||ev.has(a)?i.push({id:n,exportValue:s,domElement:a}):Hu(`_getElementsByName - element not allowed: ${n}`)}return i}for(const s of document.getElementsByName(t)){const{exportValue:t}=s,n=s.getAttribute("data-element-id");n!==e&&(ev.has(s)&&i.push({id:n,exportValue:t,domElement:s}))}return i}show(){var t;this.container&&(this.container.hidden=!1),null==(t=this.popup)||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),null==(t=this.popup)||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{var i;null==(i=this.linkService.eventBus)||i.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}};class rv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:t}=this;t.hasComment&&(this._createPopup(t.comment),this.extraPopupElement.popup.renderCommentButton())}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.container.remove(),this.container=null,this.removePopup()}}class av extends nv{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!(null==e?void 0:e.ignoreBorder),createQuadrilaterals:!0}),Gd(this,Ma),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action,t.overlaidText),s=!0):t.attachment?(Xd(this,Ma,Ca).call(this,i,t.attachment,t.overlaidText,t.attachmentDest),s=!0):t.setOCGState?(Xd(this,Ma,Ta).call(this,i,t.setOCGState,t.overlaidText),s=!0):t.dest?(this._bindLink(i,t.dest,t.overlaidText),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&this.container.append(i),this.container}_bindLink(t,e,i=""){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&Xd(this,Ma,Ea).call(this),i&&(t.title=i)}_bindNamedAction(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),i&&(t.title=i),Xd(this,Ma,Ea).call(this)}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const s of Object.keys(e.actions)){const n=i.get(s);n&&(t[n]=()=>{var t;return null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1})}e.overlaidText&&(t.title=e.overlaidText),t.onclick||(t.onclick=()=>!1),Xd(this,Ma,Ea).call(this)}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),Xd(this,Ma,Ea).call(this),!this._fieldObjects)return Hu('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(i||(t.onclick=()=>!1));t.onclick=()=>{var t;null==i||i();const{fields:s,refs:n,include:r}=e,a=[];if(0!==s.length||0!==n.length){const t=new Set(n);for(const e of s){const i=this._fieldObjects[e]||[];for(const{id:e}of i)t.add(e)}for(const e of Object.values(this._fieldObjects))for(const i of e)t.has(i.id)===r&&a.push(i)}else for(const e of Object.values(this._fieldObjects))a.push(...e);const o=this.annotationStorage,l=[];for(const e of a){const{id:t}=e;switch(l.push(t),e.type){case"text":{const i=e.defaultValue||"";o.setValue(t,{value:i});break}case"checkbox":case"radiobutton":{const i=e.defaultValue===e.exportValues;o.setValue(t,{value:i});break}case"combobox":case"listbox":{const i=e.defaultValue||"";o.setValue(t,{value:i});break}default:continue}const i=document.querySelector(`[data-element-id="${t}"]`);i&&(ev.has(i)?i.dispatchEvent(new Event("resetform")):Hu(`_bindResetFormAction - element not allowed: ${t}`))}return this.enableScripting&&(null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:l,name:"ResetForm"}})),!1}}}Ma=new WeakSet,Ea=function(){this.container.setAttribute("data-internal-link","")},Ca=function(t,e,i="",s=null){t.href=this.linkService.getAnchorUrl(""),e.description?t.title=e.description:i&&(t.title=i),t.onclick=()=>{var t;return null==(t=this.downloadManager)||t.openOrDownloadData(e.content,e.filename,s),!1},Xd(this,Ma,Ea).call(this)},Ta=function(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),i&&(t.title=i),Xd(this,Ma,Ea).call(this)};class ov extends nv{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 lv extends nv{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&("CANVAS"===(null==(e=t.previousSibling)?void 0:e.nodeName)&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return ip.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,n){i.includes("mouse")?t.addEventListener(i,t=>{var e;null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})}):t.addEventListener(i,t=>{var r;if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}n&&(null==(r=this.linkService.eventBus)||r.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t)}}))})}_setEventListeners(t,e,i,s){var n,r,a;for(const[o,l]of i)("Action"===l||(null==(n=this.data.actions)?void 0:n[l]))&&("Focus"!==l&&"Blur"!==l||e||(e={focused:!1}),this._setEventListener(t,e,o,l,s),"Focus"!==l||(null==(r=this.data.actions)?void 0:r.Blur)?"Blur"!==l||(null==(a=this.data.actions)?void 0:a.Focus)||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":np.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,n=t.style;let r;const a=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=t/(Math.round(t/(nu*s))||1);r=Math.min(s,a(e/nu))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(s,a(t/nu))}n.fontSize=`calc(${r}px * var(--total-scale-factor))`,n.color=np.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class hv extends lv{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,s){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=i),n.setValue(r.id,{[s]:i})}render(){var t,e;const i=this.annotationStorage,s=this.data.id;this.container.classList.add("textWidgetAnnotation");let n=null;if(this.renderForms){const r=i.getValue(s,{value:this.data.fieldValue});let a=r.value||"";const o=i.getValue(s,{charLimit:this.data.maxLen}).charLimit;o&&a.length>o&&(a=a.slice(0,o));let l=r.formattedValue||(null==(t=this.data.textContent)?void 0:t.join("\n"))||null;l&&this.data.comb&&(l=l.replaceAll(/\s+/g,""));const h={userValue:a,formattedValue:l,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement("textarea"),n.textContent=l??a,this.data.doNotScroll&&(n.style.overflowY="hidden")):(n=document.createElement("input"),n.type=this.data.password?"password":"text",n.setAttribute("value",l??a),this.data.doNotScroll&&(n.style.overflowX="hidden")),this.data.hasOwnCanvas&&(n.hidden=!0),ev.add(n),n.setAttribute("data-element-id",s),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=0;const{datetimeFormat:c,datetimeType:d,timeStep:u}=this.data,p=!!d&&this.enableScripting;c&&(n.title=c),this._setRequired(n,this.data.required),o&&(n.maxLength=o),n.addEventListener("input",t=>{i.setValue(s,{value:t.target.value}),this.setPropertyOnSiblings(n,"value",t.target.value,"value"),h.formattedValue=null}),n.addEventListener("resetform",t=>{const e=this.data.defaultFieldValue??"";n.value=h.userValue=e,h.formattedValue=null});let g=t=>{const{formattedValue:e}=h;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener("focus",t=>{var e;if(h.focused)return;const{target:i}=t;if(p&&(i.type=d,u&&(i.step=u)),h.userValue){const t=h.userValue;if(p)if("time"===d){const e=new Date(t),s=[e.getHours(),e.getMinutes(),e.getSeconds()];i.value=s.map(t=>t.toString().padStart(2,"0")).join(":")}else i.value=new Date(t-iv).toISOString().split("date"===d?"T":".",1)[0];else i.value=t}h.lastCommittedValue=i.value,h.commitKey=1,(null==(e=this.data.actions)?void 0:e.Focus)||(h.focused=!0)}),n.addEventListener("updatefromsandbox",t=>{this.showElementAndHideCanvas(t.target);const e={value(t){h.userValue=t.detail.value??"",p||i.setValue(s,{value:h.userValue.toString()}),t.target.value=h.userValue},formattedValue(t){const{formattedValue:e}=t.detail;h.formattedValue=e,null!=e&&t.target!==document.activeElement&&(t.target.value=e);const n={formattedValue:e};p&&(n.value=e),i.setValue(s,n)},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:t=>{var e;const{charLimit:n}=t.detail,{target:r}=t;if(0===n)return void r.removeAttribute("maxLength");r.setAttribute("maxLength",n);let a=h.userValue;!a||a.length<=n||(a=a.slice(0,n),r.value=h.userValue=a,i.setValue(s,{value:a}),null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s,name:"Keystroke",value:a,willCommit:!0,commitKey:1,selStart:r.selectionStart,selEnd:r.selectionEnd}}))}};this._dispatchEventFromSandbox(e,t)}),n.addEventListener("keydown",t=>{var e;h.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(h.commitKey=3):i=2,-1===i)return;const{value:n}=t.target;h.lastCommittedValue!==n&&(h.lastCommittedValue=n,h.userValue=n,null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s,name:"Keystroke",value:n,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))});const t=g;g=null,n.addEventListener("blur",e=>{var i,n;if(!h.focused||!e.relatedTarget)return;(null==(i=this.data.actions)?void 0:i.Blur)||(h.focused=!1);const{target:r}=e;let{value:a}=r;if(p){if(a&&"time"===d){const t=a.split(":").map(t=>parseInt(t,10));a=new Date(2e3,0,1,t[0],t[1],t[2]||0).valueOf(),r.step=""}else a.includes("T")||(a=`${a}T00:00`),a=new Date(a).valueOf();r.type="text"}h.userValue=a,h.lastCommittedValue!==a&&(null==(n=this.linkService.eventBus)||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s,name:"Keystroke",value:a,willCommit:!0,commitKey:h.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}})),t(e)}),(null==(e=this.data.actions)?void 0:e.Keystroke)&&n.addEventListener("beforeinput",t=>{var e;h.lastCommittedValue=null;const{data:i,target:n}=t,{value:r,selectionStart:a,selectionEnd:o}=n;let l=a,c=o;switch(t.inputType){case"deleteWordBackward":{const t=r.substring(0,a).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{const t=r.substring(a).match(/^[^\w]*\w*/);t&&(c+=t[0].length);break}case"deleteContentBackward":a===o&&(l-=1);break;case"deleteContentForward":a===o&&(c+=1)}t.preventDefault(),null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s,name:"Keystroke",value:r,change:i||"",willCommit:!1,selStart:l,selEnd:c}})}),this._setEventListeners(n,h,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.value)}if(g&&n.addEventListener("blur",g),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/o;n.classList.add("comb"),n.style.letterSpacing=`calc(${t}px * var(--total-scale-factor) - 1ch)`}}else n=document.createElement("div"),n.textContent=this.data.fieldValue,n.style.verticalAlign="middle",n.style.display="table-cell",this.data.hasOwnCanvas&&(n.hidden=!0);return this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class cv extends lv{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class dv extends lv{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return ev.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=0,n.addEventListener("change",s=>{const{name:n,checked:r}=s.target;for(const a of this._getElementsByName(n,i)){const i=r&&a.exportValue===e.exportValue;a.domElement&&(a.domElement.checked=i),t.setValue(a.id,{value:i})}t.setValue(i,{value:r})}),n.addEventListener("resetform",t=>{const i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",e=>{const s={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}};this._dispatchEventFromSandbox(s,e)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class uv extends lv{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(const r of this._getElementsByName(e.fieldName,i))t.setValue(r.id,{value:!1});const n=document.createElement("input");if(ev.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.tabIndex=0,n.addEventListener("change",e=>{const{name:s,checked:n}=e.target;for(const r of this._getElementsByName(s,i))t.setValue(r.id,{value:!1});t.setValue(i,{value:n})}),n.addEventListener("resetform",t=>{const i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue}),this.enableScripting&&this.hasJSActions){const s=e.buttonValue;n.addEventListener("updatefromsandbox",e=>{const n={value:e=>{const n=s===e.detail.value;for(const s of this._getElementsByName(e.target.name)){const e=n&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}};this._dispatchEventFromSandbox(n,e)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class pv extends av{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({},t)})),t}}class gv extends lv{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");ev.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=0;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",t=>{const e=this.data.defaultFieldValue;for(const i of s.options)i.selected=i.value===e});for(const h of this.data.options){const t=document.createElement("option");t.textContent=h.displayValue,t.value=h.exportValue,i.value.includes(h.exportValue)&&(t.setAttribute("selected",!0),n=!1),s.append(t)}let r=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),r=()=>{t.remove(),s.removeEventListener("input",r),r=null},s.addEventListener("input",r)}const a=t=>{const e=t?"value":"textContent",{options:i,multiple:n}=s;return n?Array.prototype.filter.call(i,t=>t.selected).map(t=>t[e]):-1===i.selectedIndex?null:i[i.selectedIndex][e]};let o=a(!1);const l=t=>{const e=t.target.options;return Array.prototype.map.call(e,t=>({displayValue:t.textContent,exportValue:t.value}))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",i=>{const n={value(i){null==r||r();const n=i.detail.value,l=new Set(Array.isArray(n)?n:[n]);for(const t of s.options)t.selected=l.has(t.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(t){s.multiple=!0},remove(i){const n=s.options,r=i.detail.remove;if(n[r].selected=!1,s.remove(r),n.length>0){-1===Array.prototype.findIndex.call(n,t=>t.selected)&&(n[0].selected=!0)}t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(i){const{index:n,displayValue:r,exportValue:h}=i.detail.insert,c=s.children[n],d=document.createElement("option");d.textContent=r,d.value=h,c?c.before(d):s.append(d),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},items(i){const{items:n}=i.detail;for(;0!==s.length;)s.remove(0);for(const t of n){const{displayValue:e,exportValue:i}=t,n=document.createElement("option");n.textContent=e,n.value=i,s.append(n)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},indices(i){const s=new Set(i.detail.indices);for(const t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(n,i)}),s.addEventListener("input",i=>{var s;const n=a(!0),r=a(!1);t.setValue(e,{value:n}),i.preventDefault(),null==(s=this.linkService.eventBus)||s.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:r,changeEx:n,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],t=>t.target.value)):s.addEventListener("input",function(i){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class fv extends nv{constructor(t){const{data:e,elements:i,parent:s}=t,n=!!s._commentManager;if(super(t,{isRenderable:!n&&nv._hasPopupData(e)}),Gd(this,Pa),this.elements=i,n&&nv._hasPopupData(e)){const t=this.popup=Xd(this,Pa,Da).call(this);for(const e of i)e.popup=t}else this.popup=null}render(){const{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";const e=this.popup=Xd(this,Pa,Da).call(this),i=[];for(const s of this.elements)s.popup=e,s.container.ariaHasPopup="dialog",i.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",i.map(t=>`${hp}${t}`).join(",")),this.container}}Pa=new WeakSet,Da=function(){return new mv({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})};class mv{constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:n,contentsObj:r,richText:a,parent:o,rect:l,parentRect:h,open:c,commentManager:d=null}){Gd(this,no),Gd(this,Ra,null),Gd(this,Ia,Xd(this,no,go).bind(this)),Gd(this,La,Xd(this,no,wo).bind(this)),Gd(this,Fa,Xd(this,no,vo).bind(this)),Gd(this,Na,Xd(this,no,mo).bind(this)),Gd(this,Wa,null),Gd(this,Ba,null),Gd(this,Oa,null),Gd(this,Ua,null),Gd(this,Ha,null),Gd(this,$a,null),Gd(this,ja,null),Gd(this,za,!1),Gd(this,Va,null),Gd(this,Ga,null),Gd(this,qa,null),Gd(this,Xa,null),Gd(this,Ya,null),Gd(this,Ka,null),Gd(this,Qa,null),Gd(this,Ja,null),Gd(this,Za,null),Gd(this,to,null),Gd(this,eo,!1),Gd(this,io,null),Gd(this,so,null),qd(this,Ba,t),qd(this,Za,s),qd(this,Oa,r),qd(this,Ja,a),qd(this,$a,o),qd(this,Wa,e),qd(this,Qa,l),qd(this,ja,h),qd(this,Ha,i),qd(this,Ra,d),qd(this,io,i[0]),qd(this,Ua,Cp.toDateObject(n)),this.trigger=i.flatMap(t=>t.getElementsToTriggerPopup()),d?this.renderCommentButton():(Xd(this,no,ro).call(this),Vd(this,Ba).hidden=!0,c&&Xd(this,no,mo).call(this))}renderCommentButton(){if(Vd(this,Xa))return;if(Vd(this,Ya)||Xd(this,no,ao).call(this),!Vd(this,Ya))return;const{signal:t}=qd(this,Ga,new AbortController),e=!!Vd(this,io).extraPopupElement,i=()=>{Vd(this,Ra).toggleCommentPopup(this,!0,void 0,!e)},s=()=>{Vd(this,Ra).toggleCommentPopup(this,!1,!0,!e)},n=()=>{Vd(this,Ra).toggleCommentPopup(this,!1,!1)};if(e){qd(this,Xa,Vd(this,io).container);for(const e of this.trigger)e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.addEventListener("keydown",Vd(this,Ia),{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",s,{signal:t}),e.addEventListener("pointerleave",n,{signal:t}),e.classList.add("popupTriggerArea")}else{const e=qd(this,Xa,document.createElement("button"));e.className="annotationCommentButton";const r=Vd(this,io).container;e.style.zIndex=r.style.zIndex+1,e.tabIndex=0,e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button"),Xd(this,no,lo).call(this),Xd(this,no,oo).call(this),e.addEventListener("keydown",Vd(this,Ia),{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",s,{signal:t}),e.addEventListener("pointerleave",n,{signal:t}),r.after(e)}}get commentButtonColor(){const{color:t,opacity:e}=Vd(this,io).commentData;return t?Vd(this,$a)._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{var t;null==(t=Vd(this,Xa))||t.focus()},0)}getData(){const{richText:t,color:e,opacity:i,creationDate:s,modificationDate:n}=Vd(this,io).commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:i,creationDate:s,modificationDate:n}}get elementBeforePopup(){return Vd(this,Xa)}get comment(){return Vd(this,so)||qd(this,so,Vd(this,io).commentText),Vd(this,so)}set comment(t){t!==this.comment&&(Vd(this,io).commentText=qd(this,so,t))}get parentBoundingClientRect(){return Vd(this,io).layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){Vd(this,Xa)&&(Vd(this,Xa).classList.toggle("selected",t),Vd(this,Xa).ariaExpanded=e)}setSelectedCommentButton(t){Vd(this,Xa).classList.toggle("selected",t)}get commentPopupPosition(){if(Vd(this,Ka))return Vd(this,Ka);const{x:t,y:e,height:i}=Vd(this,Xa).getBoundingClientRect(),{x:s,y:n,width:r,height:a}=Vd(this,io).layer.getBoundingClientRect();return[(t-s)/r,(e+i-n)/a]}set commentPopupPosition(t){qd(this,Ka,t)}hasDefaultPopupPosition(){return null===Vd(this,Ka)}get commentButtonPosition(){return Vd(this,Ya)}get commentButtonWidth(){return Vd(this,Xa).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,i]=Vd(this,Ka)||this.commentButtonPosition.map(t=>t/100),s=this.parentBoundingClientRect,{x:n,y:r,width:a,height:o}=s;Vd(this,Ra).showDialog(null,this,n+e*a,r+i*o,{...t,parentDimensions:s})}render(){var t,e;if(Vd(this,Va))return;const i=qd(this,Va,document.createElement("div"));if(i.className="popup",Vd(this,Wa)){const t=i.style.outlineColor=np.makeHexColor(...Vd(this,Wa));i.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`}const s=document.createElement("span");if(s.className="header",null==(t=Vd(this,Za))?void 0:t.str){const t=document.createElement("span");t.className="title",s.append(t),({dir:t.dir,str:t.textContent}=Vd(this,Za))}if(i.append(s),Vd(this,Ua)){const t=document.createElement("time");t.className="popupDate",t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:Vd(this,Ua).valueOf()})),t.dateTime=Vd(this,Ua).toISOString(),s.append(t)}Vp({html:Vd(this,no,ho)||Vd(this,Oa).str,dir:null==(e=Vd(this,Oa))?void 0:e.dir,className:"popupContent"},i),Vd(this,Ba).append(i)}updateEdited({rect:t,popup:e,deleted:i}){var s;if(Vd(this,Ra))return i?(this.remove(),qd(this,so,null)):e&&(e.deleted?this.remove():(Xd(this,no,lo).call(this),qd(this,so,e.text))),void(t&&(qd(this,Ya,null),Xd(this,no,ao).call(this),Xd(this,no,oo).call(this)));i||(null==e?void 0:e.deleted)?this.remove():(Xd(this,no,ro).call(this),Vd(this,to)||qd(this,to,{contentsObj:Vd(this,Oa),richText:Vd(this,Ja)}),t&&qd(this,qa,null),e&&e.text&&(qd(this,Ja,Xd(this,no,po).call(this,e.text)),qd(this,Ua,Cp.toDateObject(e.date)),qd(this,Oa,null)),null==(s=Vd(this,Va))||s.remove(),qd(this,Va,null))}resetEdited(){var t;Vd(this,to)&&(({contentsObj:Yd(this,Oa)._,richText:Yd(this,Ja)._}=Vd(this,to)),qd(this,to,null),null==(t=Vd(this,Va))||t.remove(),qd(this,Va,null),qd(this,qa,null))}remove(){var t,e,i;if(null==(t=Vd(this,Ga))||t.abort(),qd(this,Ga,null),null==(e=Vd(this,Va))||e.remove(),qd(this,Va,null),qd(this,eo,!1),qd(this,za,!1),null==(i=Vd(this,Xa))||i.remove(),qd(this,Xa,null),this.trigger)for(const s of this.trigger)s.classList.remove("popupTriggerArea")}forceHide(){qd(this,eo,this.isVisible),Vd(this,eo)&&(Vd(this,Ba).hidden=!0)}maybeShow(){Vd(this,Ra)||(Xd(this,no,ro).call(this),Vd(this,eo)&&(Vd(this,Va)||Xd(this,no,vo).call(this),qd(this,eo,!1),Vd(this,Ba).hidden=!1))}get isVisible(){return!Vd(this,Ra)&&!1===Vd(this,Ba).hidden}}Ra=new WeakMap,Ia=new WeakMap,La=new WeakMap,Fa=new WeakMap,Na=new WeakMap,Wa=new WeakMap,Ba=new WeakMap,Oa=new WeakMap,Ua=new WeakMap,Ha=new WeakMap,$a=new WeakMap,ja=new WeakMap,za=new WeakMap,Va=new WeakMap,Ga=new WeakMap,qa=new WeakMap,Xa=new WeakMap,Ya=new WeakMap,Ka=new WeakMap,Qa=new WeakMap,Ja=new WeakMap,Za=new WeakMap,to=new WeakMap,eo=new WeakMap,io=new WeakMap,so=new WeakMap,no=new WeakSet,ro=function(){var t;if(Vd(this,Ga))return;qd(this,Ga,new AbortController);const{signal:e}=Vd(this,Ga);for(const i of this.trigger)i.addEventListener("click",Vd(this,Na),{signal:e}),i.addEventListener("pointerenter",Vd(this,Fa),{signal:e}),i.addEventListener("pointerleave",Vd(this,La),{signal:e}),i.classList.add("popupTriggerArea");for(const i of Vd(this,Ha))null==(t=i.container)||t.addEventListener("keydown",Vd(this,Ia),{signal:e})},ao=function(){const t=Vd(this,Ha).find(t=>t.hasCommentButton);t&&qd(this,Ya,t._normalizePoint(t.commentButtonPosition))},oo=function(){if(Vd(this,io).extraPopupElement&&!Vd(this,io).editor)return;this.renderCommentButton();const[t,e]=Vd(this,Ya),{style:i}=Vd(this,Xa);i.left=`calc(${t}%)`,i.top=`calc(${e}% - var(--comment-button-dim))`},lo=function(){Vd(this,io).extraPopupElement||(this.renderCommentButton(),Vd(this,Xa).style.backgroundColor=this.commentButtonColor||"")},ho=function(){const t=Vd(this,Ja),e=Vd(this,Oa);return!(null==t?void 0:t.str)||(null==e?void 0:e.str)&&e.str!==t.str?null:Vd(this,Ja).html||null},co=function(){var t,e,i;return(null==(i=null==(e=null==(t=Vd(this,no,ho))?void 0:t.attributes)?void 0:e.style)?void 0:i.fontSize)||0},uo=function(){var t,e,i;return(null==(i=null==(e=null==(t=Vd(this,no,ho))?void 0:t.attributes)?void 0:e.style)?void 0:i.color)||null},po=function(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:Vd(this,no,uo),fontSize:Vd(this,no,co)?`calc(${Vd(this,no,co)}px * var(--total-scale-factor))`:""}};for(const n of t.split("\n"))e.push({name:"span",value:n,attributes:s});return i},go=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&Vd(this,za))&&Xd(this,no,mo).call(this)},fo=function(){if(null!==Vd(this,qa))return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=Vd(this,$a);let r=!!Vd(this,ja),a=Vd(this,r?ja:Qa);for(const u of Vd(this,Ha))if(!a||null!==np.intersect(u.data.rect,a)){a=u.data.rect,r=!0;break}const o=np.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),l=r?a[2]-a[0]+5:0,h=o[0]+l,c=o[1];qd(this,qa,[100*(h-s)/e,100*(c-n)/i]);const{style:d}=Vd(this,Ba);d.left=`${Vd(this,qa)[0]}%`,d.top=`${Vd(this,qa)[1]}%`},mo=function(){Vd(this,Ra)?Vd(this,Ra).toggleCommentPopup(this,!1):(qd(this,za,!Vd(this,za)),Vd(this,za)?(Xd(this,no,vo).call(this),Vd(this,Ba).addEventListener("click",Vd(this,Na)),Vd(this,Ba).addEventListener("keydown",Vd(this,Ia))):(Xd(this,no,wo).call(this),Vd(this,Ba).removeEventListener("click",Vd(this,Na)),Vd(this,Ba).removeEventListener("keydown",Vd(this,Ia))))},vo=function(){Vd(this,Va)||this.render(),this.isVisible?Vd(this,za)&&Vd(this,Ba).classList.add("focused"):(Xd(this,no,fo).call(this),Vd(this,Ba).hidden=!1,Vd(this,Ba).style.zIndex=parseInt(Vd(this,Ba).style.zIndex)+1e3)},wo=function(){Vd(this,Ba).classList.remove("focused"),!Vd(this,za)&&this.isVisible&&(Vd(this,Ba).hidden=!0,Vd(this,Ba).style.zIndex=parseInt(Vd(this,Ba).style.zIndex)-1e3)};class vv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=fu.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class wv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Gd(this,bo,null)}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=qd(this,bo,this.svgFactory.createElement("svg:line"));return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return Vd(this,bo)}addHighlightArea(){this.container.classList.add("highlightArea")}}bo=new WeakMap;class bv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Gd(this,yo,null)}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=qd(this,yo,this.svgFactory.createElement("svg:rect"));return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",i-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return Vd(this,yo)}addHighlightArea(){this.container.classList.add("highlightArea")}}yo=new WeakMap;class yv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Gd(this,Ao,null)}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=qd(this,Ao,this.svgFactory.createElement("svg:ellipse"));return r.setAttribute("cx",e/2),r.setAttribute("cy",i/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",i/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return Vd(this,Ao)}addHighlightArea(){this.container.classList.add("highlightArea")}}Ao=new WeakMap;class Av extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Gd(this,_o,null),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:i,popupRef:s},width:n,height:r}=this;if(!e)return this.container;const a=this.svgFactory.create(n,r,!0);let o=[];for(let h=0,c=e.length;h<c;h+=2){const i=e[h]-t[0],s=t[3]-e[h+1];o.push(`${i},${s}`)}o=o.join(" ");const l=qd(this,_o,this.svgFactory.createElement(this.svgElementName));return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),a.append(l),this.container.append(a),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return Vd(this,_o)}addHighlightArea(){this.container.classList.add("highlightArea")}}_o=new WeakMap;class _v extends Av{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class xv extends nv{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 kv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Gd(this,So),Gd(this,xo,null),Gd(this,ko,[]),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?fu.HIGHLIGHT:fu.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:i,borderStyle:s,popupRef:n}}=this,{transform:r,width:a,height:o}=Xd(this,So,Mo).call(this,e,t),l=this.svgFactory.create(a,o,!0),h=qd(this,xo,this.svgFactory.createElement("svg:g"));l.append(h),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",r);for(let c=0,d=i.length;c<d;c++){const t=this.svgFactory.createElement(this.svgElementName);Vd(this,ko).push(t),t.setAttribute("points",i[c].join(",")),h.append(t)}return!n&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:i,rect:s}=t,n=Vd(this,xo);if(e>=0&&n.setAttribute("stroke-width",e||1),i)for(let r=0,a=Vd(this,ko).length;r<a;r++)Vd(this,ko)[r].setAttribute("points",i[r].join(","));if(s){const{transform:t,width:e,height:i}=Xd(this,So,Mo).call(this,this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return Vd(this,ko)}addHighlightArea(){this.container.classList.add("highlightArea")}}xo=new WeakMap,ko=new WeakMap,So=new WeakSet,Mo=function(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}};class Sv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=fu.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const e=document.createElement("mark");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Mv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),t){const e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Ev extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),t){const e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Cv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),t){const e=document.createElement("s");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Tv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=fu.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class Pv extends nv{constructor(t){var e;super(t,{isRenderable:!0}),Gd(this,Co),Gd(this,Eo,null);const{file:i}=this.data;this.filename=i.filename,this.content=i.content,null==(e=this.linkService.eventBus)||e.dispatch("fileattachmentannotation",{source:this,...i})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let i;e.hasAppearance||0===e.fillAlpha?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),i.addEventListener("dblclick",Xd(this,Co,To).bind(this)),qd(this,Eo,i);const{isMac:s}=ip.platform;return t.addEventListener("keydown",t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&Xd(this,Co,To).call(this)}),!e.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return Vd(this,Eo)}addHighlightArea(){this.container.classList.add("highlightArea")}}Eo=new WeakMap,Co=new WeakSet,To=function(){var t;null==(t=this.downloadManager)||t.openOrDownloadData(this.content,this.filename)};let Dv=(Oo=class{constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:r,structTreeLayer:a,commentManager:o,linkService:l,annotationStorage:h}){Gd(this,No),Gd(this,Po,null),Gd(this,Do,null),Gd(this,Ro,null),Gd(this,Io,new Map),Gd(this,Lo,null),Gd(this,Fo,null),this.div=t,qd(this,Po,e),qd(this,Do,i),qd(this,Lo,a||null),qd(this,Fo,l||null),qd(this,Ro,h||new wg),this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=s,this._commentManager=o||null}hasEditableAnnotations(){return Vd(this,Io).size>0}async render(t){var e,i,s;const{annotations:n}=t,r=this.div;Ip(r,this.viewport);const a=new Map,o={data:null,layer:r,linkService:Vd(this,Fo),downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new tv,annotationStorage:Vd(this,Ro),enableComment:!0===t.enableComment,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const l of n){if(l.noHTML)continue;const t=l.annotationType===Su.POPUP;if(t){const t=a.get(l.id);if(!t)continue;o.elements=t}else if(l.rect[2]===l.rect[0]||l.rect[3]===l.rect[1])continue;o.data=l;const n=sv.create(o);if(!n.isRenderable)continue;if(!t&&l.popupRef){const t=a.get(l.popupRef);t?t.push(n):a.set(l.popupRef,[n])}const r=n.render();l.hidden&&(r.style.visibility="hidden"),await Xd(this,No,Wo).call(this,r,l.id,o.elements),null==(i=null==(e=n.extraPopupElement)?void 0:e.popup)||i.renderCommentButton(),n._isEditable&&(Vd(this,Io).set(n.data.id,n),null==(s=this._annotationEditorUIManager)||s.renderAnnotationElement(n))}Xd(this,No,Bo).call(this)}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:Vd(this,Fo),svgFactory:new tv,parent:this};for(const i of t){i.borderStyle||(i.borderStyle=Oo._defaultBorderStyle),e.data=i;const t=sv.create(e);if(!t.isRenderable)continue;const s=t.render();await Xd(this,No,Wo).call(this,s,i.id,null)}}update({viewport:t}){const e=this.div;this.viewport=t,Ip(e,{rotation:t.rotation}),Xd(this,No,Bo).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(Vd(this,Io).values())}getEditableAnnotation(t){return Vd(this,Io).get(t)}addFakeAnnotation(t){var e;const{div:i}=this,{id:s,rotation:n}=t,r=new rv({data:{id:s,rect:t.getPDFRect(),rotation:n},editor:t,layer:i,parent:this,enableComment:!!this._commentManager,linkService:Vd(this,Fo),annotationStorage:Vd(this,Ro)}),a=r.render();return i.append(a),null==(e=Vd(this,Po))||e.moveElementInDOM(i,a,a,!1),r.createOrUpdatePopup(),r}static get _defaultBorderStyle(){return Gu(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Mu,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}},Po=new WeakMap,Do=new WeakMap,Ro=new WeakMap,Io=new WeakMap,Lo=new WeakMap,Fo=new WeakMap,No=new WeakSet,Wo=async function(t,e,i){var s,n;const r=t.firstChild||t,a=r.id=`${hp}${e}`,o=await(null==(s=Vd(this,Lo))?void 0:s.getAriaAttributes(a));if(o)for(const[l,h]of o)r.setAttribute(l,h);i?i.at(-1).container.after(t):(this.div.append(t),null==(n=Vd(this,Po))||n.moveElementInDOM(this.div,t,r,!1))},Bo=function(){var t;if(!Vd(this,Do))return;const e=this.div;for(const[i,s]of Vd(this,Do)){const n=e.querySelector(`[data-annotation-id="${i}"]`);if(!n)continue;s.className="annotationContent";const{firstChild:r}=n;r?"CANVAS"===r.nodeName?r.replaceWith(s):r.classList.contains("annotationContent")?r.after(s):r.before(s):n.append(s);const a=Vd(this,Io).get(i);a&&(a._hasNoCanvas?(null==(t=this._annotationEditorUIManager)||t.setMissingCanvas(i,n.id,s),a._hasNoCanvas=!1):a.canvas=s)}Vd(this,Do).clear()},Oo);const Rv=/\r\n?|\n/g,Iv=class t extends dg{constructor(e){super({...e,name:"freeTextEditor"}),Gd(this,zo),Gd(this,Uo,""),Gd(this,Ho,`${this.id}-editor`),Gd(this,$o,null),Gd(this,jo),jd(this,"_colorPicker",null),this.color=e.color||t._defaultColor||dg._defaultLineColor,qd(this,jo,e.fontSize||t._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}static get _keyboardManager(){const e=t.prototype,i=t=>t.isEmpty(),s=ng.TRANSLATE_SMALL,n=ng.TRANSLATE_BIG;return Gu(this,"_keyboardManager",new tg([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-s,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-n,0],checker:i}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[s,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[n,0],checker:i}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-s],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-n],checker:i}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,s],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,n],checker:i}]]))}static initialize(t,e){dg.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,i){switch(e){case mu.FREETEXT_SIZE:t._defaultFontSize=i;break;case mu.FREETEXT_COLOR:t._defaultColor=i}}updateParams(t,e){switch(t){case mu.FREETEXT_SIZE:Xd(this,zo,Vo).call(this,e);break;case mu.FREETEXT_COLOR:Xd(this,zo,Go).call(this,e)}}static get defaultPropertiesToUpdate(){return[[mu.FREETEXT_SIZE,t._defaultFontSize],[mu.FREETEXT_COLOR,t._defaultColor||dg._defaultLineColor]]}get propertiesToUpdate(){return[[mu.FREETEXT_SIZE,Vd(this,jo)],[mu.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Ym(this)),[["colorPicker",this._colorPicker]]}get colorType(){return mu.FREETEXT_COLOR}onUpdatedColor(){var t;this.editorDiv.style.color=this.color,null==(t=this._colorPicker)||t.update(this.color),super.onUpdatedColor()}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const e=this.parentScale;return[-t._internalPadding*e,-(t._internalPadding+Vd(this,jo))*e]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),qd(this,$o,new AbortController);const t=this._uiManager.combinedSignal(Vd(this,$o));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t}),!0}disableEditMode(){var t;return!!super.disableEditMode()&&(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",Vd(this,Ho)),this._isDraggable=!0,null==(t=Vd(this,$o))||t.abort(),qd(this,$o,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0)}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){var e;this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),(null==(e=this._initialOptions)?void 0:e.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()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=Vd(this,Uo),e=qd(this,Uo,Xd(this,zo,qo).call(this).trimEnd());if(t===e)return;const i=t=>{qd(this,Uo,t),t?(Xd(this,zo,Qo).call(this),this._uiManager.rebuild(this),Xd(this,zo,Xo).call(this)):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),Xd(this,zo,Xo).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(e){t._keyboardManager.exec(this,e)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let t,e;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",Vd(this,Ho)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${Vd(this,jo)}px * var(--total-scale-factor))`,i.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[i,s]=this.parentDimensions;if(this.annotationElementId){const{position:n}=this._initialData;let[r,a]=this.getInitialTranslation();[r,a]=this.pageTranslationToScreen(r,a);const[o,l]=this.pageDimensions,[h,c]=this.pageTranslation;let d,u;switch(this.rotation){case 0:d=t+(n[0]-h)/o,u=e+this.height-(n[1]-c)/l;break;case 90:d=t+(n[0]-h)/o,u=e-(n[1]-c)/l,[r,a]=[a,-r];break;case 180:d=t-this.width+(n[0]-h)/o,u=e-(n[1]-c)/l,[r,a]=[-r,-a];break;case 270:d=t+(n[0]-h-this.height*l)/o,u=e+(n[1]-c-this.width*o)/l,[r,a]=[-a,r]}this.setAt(d*i,u*s,r,a)}else this._moveAfterPaste(t,e);Xd(this,zo,Qo).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var i,s,n;const r=e.clipboardData||window.clipboardData,{types:a}=r;if(1===a.length&&"text/plain"===a[0])return;e.preventDefault();const o=Xd(i=t,Yo,Zo).call(i,r.getData("text")||"").replaceAll(Rv,"\n");if(!o)return;const l=window.getSelection();if(!l.rangeCount)return;this.editorDiv.normalize(),l.deleteFromDocument();const h=l.getRangeAt(0);if(!o.includes("\n"))return h.insertNode(document.createTextNode(o)),this.editorDiv.normalize(),void l.collapseToStart();const{startContainer:c,startOffset:d}=h,u=[],p=[];if(c.nodeType===Node.TEXT_NODE){const e=c.parentElement;if(p.push(c.nodeValue.slice(d).replaceAll(Rv,"")),e!==this.editorDiv){let i=u;for(const n of this.editorDiv.childNodes)n!==e?i.push(Xd(s=t,Yo,Ko).call(s,n)):i=p}u.push(c.nodeValue.slice(0,d).replaceAll(Rv,""))}else if(c===this.editorDiv){let e=u,i=0;for(const s of this.editorDiv.childNodes)i++===d&&(e=p),e.push(Xd(n=t,Yo,Ko).call(n,s))}qd(this,Uo,`${u.join("\n")}${o}${p.join("\n")}`),Xd(this,zo,Qo).call(this);const g=new Range;let f=Math.sumPrecise(u.map(t=>t.length));for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(f<=e){g.setStart(t,f),g.setEnd(t,f);break}f-=e}l.removeAllRanges(),l.addRange(g)}get contentDiv(){return this.editorDiv}getPDFRect(){const e=t._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,i,s){var n;let r=null;if(e instanceof vv){const{data:{defaultAppearanceData:{fontSize:t,fontColor:i},rect:s,rotation:n,id:a,popupRef:o,richText:l,contentsObj:h,creationDate:c,modificationDate:d},textContent:u,textPosition:p,parent:{page:{pageNumber:g}}}=e;if(!u||0===u.length)return null;r=e={annotationType:fu.FREETEXT,color:Array.from(i),fontSize:t,value:u.join("\n"),position:p,pageIndex:g-1,rect:s.slice(0),rotation:n,annotationElementId:a,id:a,deleted:!1,popupRef:o,comment:(null==h?void 0:h.str)||null,richText:l,creationDate:c,modificationDate:d}}const a=await super.deserialize(e,i,s);return qd(a,jo,e.fontSize),a.color=np.makeHexColor(...e.color),qd(a,Uo,Xd(n=t,Yo,Zo).call(n,e.value)),a._initialData=r,e.comment&&a.setCommentData(e),a}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=dg._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(t),{color:e,fontSize:Vd(this,jo),value:Xd(this,zo,Jo).call(this)});return this.addComment(i),t?(i.isCopy=!0,i):this.annotationElementId&&!Xd(this,zo,tl).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(!e)return null;const{style:i}=e;i.fontSize=`calc(${Vd(this,jo)}px * var(--total-scale-factor))`,i.color=this.color,e.replaceChildren();for(const s of Vd(this,Uo).split("\n")){const t=document.createElement("div");t.append(s?document.createTextNode(s):document.createElement("br")),e.append(t)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:Vd(this,Uo)}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}};Uo=new WeakMap,Ho=new WeakMap,$o=new WeakMap,jo=new WeakMap,zo=new WeakSet,Vo=function(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-Vd(this,jo))*this.parentScale),qd(this,jo,t),Xd(this,zo,Xo).call(this)},i=Vd(this,jo);this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:mu.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},Go=function(t){const e=t=>{this.color=t,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:mu.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},qo=function(){var t;const e=[];this.editorDiv.normalize();let i=null;for(const s of this.editorDiv.childNodes)(null==i?void 0:i.nodeType)===Node.TEXT_NODE&&"BR"===s.nodeName||(e.push(Xd(t=Iv,Yo,Ko).call(t,s)),i=s);return e.join("\n")},Xo=function(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,s=e.style.display,n=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),i=e.getBoundingClientRect(),e.remove(),e.style.display=s,e.classList.toggle("hidden",n)}this.rotation%180==this.parentRotation%180?(this.width=i.width/t,this.height=i.height/e):(this.width=i.height/t,this.height=i.width/e),this.fixAndSetPosition()},Yo=new WeakSet,Ko=function(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Rv,"")},Qo=function(){if(this.editorDiv.replaceChildren(),Vd(this,Uo))for(const t of Vd(this,Uo).split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}},Jo=function(){return Vd(this,Uo).replaceAll(" "," ")},Zo=function(t){return t.replaceAll(" "," ")},tl=function(t){const{value:e,fontSize:i,color:s,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some((t,e)=>t!==s[e])||t.pageIndex!==n},Gd(Iv,Yo),jd(Iv,"_freeTextDefaultContent",""),jd(Iv,"_internalPadding",0),jd(Iv,"_defaultColor",null),jd(Iv,"_defaultFontSize",10),jd(Iv,"_type","freetext"),jd(Iv,"_editorType",fu.FREETEXT);let Lv=Iv;class Fv{toSVGPath(){$u("Abstract method `toSVGPath` must be implemented.")}get box(){$u("Abstract getter `box` must be implemented.")}serialize(t,e){$u("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,n,r){r||(r=new Float32Array(t.length));for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*s,r[a+1]=i+t[a+1]*n;return r}static _rescaleAndSwap(t,e,i,s,n,r){r||(r=new Float32Array(t.length));for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*s,r[a+1]=i+t[a]*n;return r}static _translate(t,e,i,s){s||(s=new Float32Array(t.length));for(let n=0,r=t.length;n<r;n+=2)s[n]=e+t[n],s[n+1]=i+t[n+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,s,n){switch(n){case 90:return[1-e/i,t/s];case 180:return[1-t/i,1-e/s];case 270:return[e/i,1-t/s];default:return[t/i,e/s]}}static _normalizePagePoint(t,e,i){switch(i){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,i,s,n,r){return[(t+5*i)/6,(e+5*s)/6,(5*i+n)/6,(5*s+r)/6,(i+n)/2,(s+r)/2]}}jd(Fv,"PRECISION",1e-4);const Nv=class t{constructor({x:e,y:i},s,n,r,a,o=0){Gd(this,vl),Gd(this,el),Gd(this,il,[]),Gd(this,sl),Gd(this,nl),Gd(this,rl,[]),Gd(this,al,new Float32Array(18)),Gd(this,ol),Gd(this,ll),Gd(this,hl),Gd(this,cl),Gd(this,dl),Gd(this,ul),Gd(this,pl,[]),qd(this,el,s),qd(this,ul,r*n),qd(this,nl,a),Vd(this,al).set([NaN,NaN,NaN,NaN,e,i],6),qd(this,sl,o),qd(this,cl,Vd(t,gl)*n),qd(this,hl,Vd(t,ml)*n),qd(this,dl,n),Vd(this,pl).push(e,i)}isEmpty(){return isNaN(Vd(this,al)[8])}add({x:t,y:e}){var i;qd(this,ol,t),qd(this,ll,e);const[s,n,r,a]=Vd(this,el);let[o,l,h,c]=Vd(this,al).subarray(8,12);const d=t-h,u=e-c,p=Math.hypot(d,u);if(p<Vd(this,hl))return!1;const g=p-Vd(this,cl),f=g/p,m=f*d,v=f*u;let w=o,b=l;o=h,l=c,h+=m,c+=v,null==(i=Vd(this,pl))||i.push(t,e);const y=m/g,A=-v/g*Vd(this,ul),_=y*Vd(this,ul);if(Vd(this,al).set(Vd(this,al).subarray(2,8),0),Vd(this,al).set([h+A,c+_],4),Vd(this,al).set(Vd(this,al).subarray(14,18),12),Vd(this,al).set([h-A,c-_],16),isNaN(Vd(this,al)[6]))return 0===Vd(this,rl).length&&(Vd(this,al).set([o+A,l+_],2),Vd(this,rl).push(NaN,NaN,NaN,NaN,(o+A-s)/r,(l+_-n)/a),Vd(this,al).set([o-A,l-_],14),Vd(this,il).push(NaN,NaN,NaN,NaN,(o-A-s)/r,(l-_-n)/a)),Vd(this,al).set([w,b,o,l,h,c],6),!this.isEmpty();Vd(this,al).set([w,b,o,l,h,c],6);return Math.abs(Math.atan2(b-l,w-o)-Math.atan2(v,m))<Math.PI/2?([o,l,h,c]=Vd(this,al).subarray(2,6),Vd(this,rl).push(NaN,NaN,NaN,NaN,((o+h)/2-s)/r,((l+c)/2-n)/a),[o,l,w,b]=Vd(this,al).subarray(14,18),Vd(this,il).push(NaN,NaN,NaN,NaN,((w+o)/2-s)/r,((b+l)/2-n)/a),!0):([w,b,o,l,h,c]=Vd(this,al).subarray(0,6),Vd(this,rl).push(((w+5*o)/6-s)/r,((b+5*l)/6-n)/a,((5*o+h)/6-s)/r,((5*l+c)/6-n)/a,((o+h)/2-s)/r,((l+c)/2-n)/a),[h,c,o,l,w,b]=Vd(this,al).subarray(12,18),Vd(this,il).push(((w+5*o)/6-s)/r,((b+5*l)/6-n)/a,((5*o+h)/6-s)/r,((5*l+c)/6-n)/a,((o+h)/2-s)/r,((l+c)/2-n)/a),!0)}toSVGPath(){if(this.isEmpty())return"";const t=Vd(this,rl),e=Vd(this,il);if(isNaN(Vd(this,al)[6])&&!this.isEmpty())return Xd(this,vl,bl).call(this);const i=[];i.push(`M${t[4]} ${t[5]}`);for(let s=6;s<t.length;s+=6)isNaN(t[s])?i.push(`L${t[s+4]} ${t[s+5]}`):i.push(`C${t[s]} ${t[s+1]} ${t[s+2]} ${t[s+3]} ${t[s+4]} ${t[s+5]}`);Xd(this,vl,Al).call(this,i);for(let s=e.length-6;s>=6;s-=6)isNaN(e[s])?i.push(`L${e[s+4]} ${e[s+5]}`):i.push(`C${e[s]} ${e[s+1]} ${e[s+2]} ${e[s+3]} ${e[s+4]} ${e[s+5]}`);return Xd(this,vl,yl).call(this,i),i.join(" ")}newFreeDrawOutline(t,e,i,s,n,r){return new Bv(t,e,i,s,n,r)}getOutlines(){var t;const e=Vd(this,rl),i=Vd(this,il),s=Vd(this,al),[n,r,a,o]=Vd(this,el),l=new Float32Array(((null==(t=Vd(this,pl))?void 0:t.length)??0)+2);for(let d=0,u=l.length-2;d<u;d+=2)l[d]=(Vd(this,pl)[d]-n)/a,l[d+1]=(Vd(this,pl)[d+1]-r)/o;if(l[l.length-2]=(Vd(this,ol)-n)/a,l[l.length-1]=(Vd(this,ll)-r)/o,isNaN(s[6])&&!this.isEmpty())return Xd(this,vl,_l).call(this,l);const h=new Float32Array(Vd(this,rl).length+24+Vd(this,il).length);let c=e.length;for(let d=0;d<c;d+=2)isNaN(e[d])?h[d]=h[d+1]=NaN:(h[d]=e[d],h[d+1]=e[d+1]);c=Xd(this,vl,kl).call(this,h,c);for(let d=i.length-6;d>=6;d-=6)for(let t=0;t<6;t+=2)isNaN(i[d+t])?(h[c]=h[c+1]=NaN,c+=2):(h[c]=i[d+t],h[c+1]=i[d+t+1],c+=2);return Xd(this,vl,xl).call(this,h,c),this.newFreeDrawOutline(h,l,Vd(this,el),Vd(this,dl),Vd(this,sl),Vd(this,nl))}};el=new WeakMap,il=new WeakMap,sl=new WeakMap,nl=new WeakMap,rl=new WeakMap,al=new WeakMap,ol=new WeakMap,ll=new WeakMap,hl=new WeakMap,cl=new WeakMap,dl=new WeakMap,ul=new WeakMap,pl=new WeakMap,gl=new WeakMap,fl=new WeakMap,ml=new WeakMap,vl=new WeakSet,wl=function(){const t=Vd(this,al).subarray(4,6),e=Vd(this,al).subarray(16,18),[i,s,n,r]=Vd(this,el);return[(Vd(this,ol)+(t[0]-e[0])/2-i)/n,(Vd(this,ll)+(t[1]-e[1])/2-s)/r,(Vd(this,ol)+(e[0]-t[0])/2-i)/n,(Vd(this,ll)+(e[1]-t[1])/2-s)/r]},bl=function(){const[t,e,i,s]=Vd(this,el),[n,r,a,o]=Xd(this,vl,wl).call(this);return`M${(Vd(this,al)[2]-t)/i} ${(Vd(this,al)[3]-e)/s} L${(Vd(this,al)[4]-t)/i} ${(Vd(this,al)[5]-e)/s} L${n} ${r} L${a} ${o} L${(Vd(this,al)[16]-t)/i} ${(Vd(this,al)[17]-e)/s} L${(Vd(this,al)[14]-t)/i} ${(Vd(this,al)[15]-e)/s} Z`},yl=function(t){const e=Vd(this,il);t.push(`L${e[4]} ${e[5]} Z`)},Al=function(t){const[e,i,s,n]=Vd(this,el),r=Vd(this,al).subarray(4,6),a=Vd(this,al).subarray(16,18),[o,l,h,c]=Xd(this,vl,wl).call(this);t.push(`L${(r[0]-e)/s} ${(r[1]-i)/n} L${o} ${l} L${h} ${c} L${(a[0]-e)/s} ${(a[1]-i)/n}`)},_l=function(t){const e=Vd(this,al),[i,s,n,r]=Vd(this,el),[a,o,l,h]=Xd(this,vl,wl).call(this),c=new Float32Array(36);return c.set([NaN,NaN,NaN,NaN,(e[2]-i)/n,(e[3]-s)/r,NaN,NaN,NaN,NaN,(e[4]-i)/n,(e[5]-s)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/n,(e[17]-s)/r,NaN,NaN,NaN,NaN,(e[14]-i)/n,(e[15]-s)/r],0),this.newFreeDrawOutline(c,t,Vd(this,el),Vd(this,dl),Vd(this,sl),Vd(this,nl))},xl=function(t,e){const i=Vd(this,il);return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6},kl=function(t,e){const i=Vd(this,al).subarray(4,6),s=Vd(this,al).subarray(16,18),[n,r,a,o]=Vd(this,el),[l,h,c,d]=Xd(this,vl,wl).call(this);return t.set([NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,c,d,NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/o],e),e+24},Gd(Nv,gl,8),Gd(Nv,fl,2),Gd(Nv,ml,Vd(Nv,gl)+Vd(Nv,fl));let Wv=Nv;class Bv extends Fv{constructor(t,e,i,s,n,r){super(),Gd(this,Rl),Gd(this,Sl),Gd(this,Ml,new Float32Array(4)),Gd(this,El),Gd(this,Cl),Gd(this,Tl),Gd(this,Pl),Gd(this,Dl),qd(this,Dl,t),qd(this,Tl,e),qd(this,Sl,i),qd(this,Pl,s),qd(this,El,n),qd(this,Cl,r),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],Xd(this,Rl,Il).call(this,r);const[a,o,l,h]=Vd(this,Ml);for(let c=0,d=t.length;c<d;c+=2)t[c]=(t[c]-a)/l,t[c+1]=(t[c+1]-o)/h;for(let c=0,d=e.length;c<d;c+=2)e[c]=(e[c]-a)/l,e[c+1]=(e[c+1]-o)/h}toSVGPath(){const t=[`M${Vd(this,Dl)[4]} ${Vd(this,Dl)[5]}`];for(let e=6,i=Vd(this,Dl).length;e<i;e+=6)isNaN(Vd(this,Dl)[e])?t.push(`L${Vd(this,Dl)[e+4]} ${Vd(this,Dl)[e+5]}`):t.push(`C${Vd(this,Dl)[e]} ${Vd(this,Dl)[e+1]} ${Vd(this,Dl)[e+2]} ${Vd(this,Dl)[e+3]} ${Vd(this,Dl)[e+4]} ${Vd(this,Dl)[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,i,s],n){const r=i-t,a=s-e;let o,l;switch(n){case 0:o=Fv._rescale(Vd(this,Dl),t,s,r,-a),l=Fv._rescale(Vd(this,Tl),t,s,r,-a);break;case 90:o=Fv._rescaleAndSwap(Vd(this,Dl),t,e,r,a),l=Fv._rescaleAndSwap(Vd(this,Tl),t,e,r,a);break;case 180:o=Fv._rescale(Vd(this,Dl),i,e,-r,a),l=Fv._rescale(Vd(this,Tl),i,e,-r,a);break;case 270:o=Fv._rescaleAndSwap(Vd(this,Dl),i,s,-r,-a),l=Fv._rescaleAndSwap(Vd(this,Tl),i,s,-r,-a)}return{outline:Array.from(o),points:[Array.from(l)]}}get box(){return Vd(this,Ml)}newOutliner(t,e,i,s,n,r=0){return new Wv(t,e,i,s,n,r)}getNewOutline(t,e){const[i,s,n,r]=Vd(this,Ml),[a,o,l,h]=Vd(this,Sl),c=n*l,d=r*h,u=i*l+a,p=s*h+o,g=this.newOutliner({x:Vd(this,Tl)[0]*c+u,y:Vd(this,Tl)[1]*d+p},Vd(this,Sl),Vd(this,Pl),t,Vd(this,Cl),e??Vd(this,El));for(let f=2;f<Vd(this,Tl).length;f+=2)g.add({x:Vd(this,Tl)[f]*c+u,y:Vd(this,Tl)[f+1]*d+p});return g.getOutlines()}}Sl=new WeakMap,Ml=new WeakMap,El=new WeakMap,Cl=new WeakMap,Tl=new WeakMap,Pl=new WeakMap,Dl=new WeakMap,Rl=new WeakSet,Il=function(t){const e=Vd(this,Dl);let i=e[4],s=e[5];const n=[i,s,i,s];let r=i,a=s,o=i,l=s;const h=t?Math.max:Math.min,c=new Float32Array(4);for(let u=6,p=e.length;u<p;u+=6){const t=e[u+4],d=e[u+5];isNaN(e[u])?(np.pointBoundingBox(t,d,n),a>d?(r=t,a=d):a===d&&(r=h(r,t)),l<d?(o=t,l=d):l===d&&(o=h(o,t))):(c[0]=c[1]=1/0,c[2]=c[3]=-1/0,np.bezierBoundingBox(i,s,...e.slice(u,u+6),c),np.rectBoundingBox(c[0],c[1],c[2],c[3],n),a>c[1]?(r=c[0],a=c[1]):a===c[1]&&(r=h(r,c[0])),l<c[3]?(o=c[2],l=c[3]):l===c[3]&&(o=h(o,c[2]))),i=t,s=d}const d=Vd(this,Ml);d[0]=n[0]-Vd(this,El),d[1]=n[1]-Vd(this,El),d[2]=n[2]-n[0]+2*Vd(this,El),d[3]=n[3]-n[1]+2*Vd(this,El),this.firstPoint=[r,a],this.lastPoint=[o,l]};class Ov{constructor(t,e=0,i=0,s=!0){Gd(this,Ol),Gd(this,Ll),Gd(this,Fl),Gd(this,Nl),Gd(this,Wl,[]),Gd(this,Bl,[]);const n=[1/0,1/0,-1/0,-1/0],r=10**-4;for(const{x:g,y:f,width:m,height:v}of t){const t=Math.floor((g-e)/r)*r,i=Math.ceil((g+m+e)/r)*r,s=Math.floor((f-e)/r)*r,a=Math.ceil((f+v+e)/r)*r,o=[t,s,a,!0],l=[i,s,a,!1];Vd(this,Wl).push(o,l),np.rectBoundingBox(t,s,i,a,n)}const a=n[2]-n[0]+2*i,o=n[3]-n[1]+2*i,l=n[0]-i,h=n[1]-i;let c=s?-1/0:1/0,d=1/0;const u=Vd(this,Wl).at(s?-1:-2),p=[u[0],u[2]];for(const g of Vd(this,Wl)){const[t,e,i,n]=g;!n&&s?e<d?(d=e,c=t):e===d&&(c=Math.max(c,t)):n&&!s&&(e<d?(d=e,c=t):e===d&&(c=Math.min(c,t))),g[0]=(t-l)/a,g[1]=(e-h)/o,g[2]=(i-h)/o}qd(this,Ll,new Float32Array([l,h,a,o])),qd(this,Fl,[c,d]),qd(this,Nl,p)}getOutlines(){Vd(this,Wl).sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);const t=[];for(const e of Vd(this,Wl))e[3]?(t.push(...Xd(this,Ol,zl).call(this,e)),Xd(this,Ol,$l).call(this,e)):(Xd(this,Ol,jl).call(this,e),t.push(...Xd(this,Ol,zl).call(this,e)));return Xd(this,Ol,Ul).call(this,t)}}Ll=new WeakMap,Fl=new WeakMap,Nl=new WeakMap,Wl=new WeakMap,Bl=new WeakMap,Ol=new WeakSet,Ul=function(t){const e=[],i=new Set;for(const r of t){const[t,i,s]=r;e.push([t,i,r],[t,s,r])}e.sort((t,e)=>t[1]-e[1]||t[0]-e[0]);for(let r=0,a=e.length;r<a;r+=2){const t=e[r][2],s=e[r+1][2];t.push(s),s.push(t),i.add(t),i.add(s)}const s=[];let n;for(;i.size>0;){const t=i.values().next().value;let[e,r,a,o,l]=t;i.delete(t);let h=e,c=r;for(n=[e,a],s.push(n);;){let t;if(i.has(o))t=o;else{if(!i.has(l))break;t=l}i.delete(t),[e,r,a,o,l]=t,h!==e&&(n.push(h,c,e,c===r?r:a),h=e),c=c===r?a:r}n.push(h,c)}return new Uv(s,Vd(this,Ll),Vd(this,Fl),Vd(this,Nl))},Hl=function(t){const e=Vd(this,Bl);let i=0,s=e.length-1;for(;i<=s;){const n=i+s>>1,r=e[n][0];if(r===t)return n;r<t?i=n+1:s=n-1}return s+1},$l=function([,t,e]){const i=Xd(this,Ol,Hl).call(this,t);Vd(this,Bl).splice(i,0,[t,e])},jl=function([,t,e]){const i=Xd(this,Ol,Hl).call(this,t);for(let s=i;s<Vd(this,Bl).length;s++){const[i,n]=Vd(this,Bl)[s];if(i!==t)break;if(i===t&&n===e)return void Vd(this,Bl).splice(s,1)}for(let s=i-1;s>=0;s--){const[i,n]=Vd(this,Bl)[s];if(i!==t)break;if(i===t&&n===e)return void Vd(this,Bl).splice(s,1)}},zl=function(t){const[e,i,s]=t,n=[[e,i,s]],r=Xd(this,Ol,Hl).call(this,s);for(let a=0;a<r;a++){const[t,i]=Vd(this,Bl)[a];for(let s=0,r=n.length;s<r;s++){const[,a,o]=n[s];if(!(i<=a||o<=t))if(a>=t)if(o>i)n[s][1]=i;else{if(1===r)return[];n.splice(s,1),s--,r--}else n[s][2]=t,o>i&&n.push([e,i,o])}}return n};class Uv extends Fv{constructor(t,e,i,s){super(),Gd(this,Vl),Gd(this,Gl),qd(this,Gl,t),qd(this,Vl,e),this.firstPoint=i,this.lastPoint=s}toSVGPath(){const t=[];for(const e of Vd(this,Gl)){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n<e.length;n+=2){const r=e[n],a=e[n+1];r===i?(t.push(`V${a}`),s=a):a===s&&(t.push(`H${r}`),i=r)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],n){const r=[],a=i-t,o=s-e;for(const l of Vd(this,Gl)){const e=new Array(l.length);for(let i=0;i<l.length;i+=2)e[i]=t+l[i]*a,e[i+1]=s-l[i+1]*o;r.push(e)}return r}get box(){return Vd(this,Vl)}get classNamesForOutlining(){return["highlightOutline"]}}Vl=new WeakMap,Gl=new WeakMap;class Hv extends Wv{newFreeDrawOutline(t,e,i,s,n,r){return new $v(t,e,i,s,n,r)}}class $v extends Bv{newOutliner(t,e,i,s,n,r=0){return new Hv(t,e,i,s,n,r)}}const jv=class t extends dg{constructor(e){super({...e,name:"highlightEditor"}),Gd(this,dh),Gd(this,ql,null),Gd(this,Xl,0),Gd(this,Yl),Gd(this,Kl,null),Gd(this,Ql,null),Gd(this,Jl,null),Gd(this,Zl,null),Gd(this,th,0),Gd(this,eh,null),Gd(this,ih,null),Gd(this,sh,null),Gd(this,nh,!1),Gd(this,rh,null),Gd(this,ah,null),Gd(this,oh,null),Gd(this,lh,""),Gd(this,hh),Gd(this,ch,""),this.color=e.color||t._defaultColor,qd(this,hh,e.thickness||t._defaultThickness),this.opacity=e.opacity||t._defaultOpacity,qd(this,Yl,e.boxes||null),qd(this,ch,e.methodOfCreation||""),qd(this,lh,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",e.highlightId>-1?(qd(this,nh,!0),Xd(this,dh,ph).call(this,e),Xd(this,dh,wh).call(this)):Vd(this,Yl)&&(qd(this,ql,e.anchorNode),qd(this,Xl,e.anchorOffset),qd(this,Zl,e.focusNode),qd(this,th,e.focusOffset),Xd(this,dh,uh).call(this),Xd(this,dh,wh).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const e=t.prototype;return Gu(this,"_keyboardManager",new tg([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:Vd(this,nh)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:Vd(this,hh),methodOfCreation:Vd(this,ch)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(e,i){var s;dg.initialize(e,i),t._defaultColor||(t._defaultColor=(null==(s=i.highlightColors)?void 0:s.values().next().value)||"#fff066")}static updateDefaultParams(e,i){switch(e){case mu.HIGHLIGHT_COLOR:t._defaultColor=i;break;case mu.HIGHLIGHT_THICKNESS:t._defaultThickness=i}}translateInPage(t,e){}get toolbarPosition(){return Vd(this,ah)}get commentButtonPosition(){return Vd(this,rh)}updateParams(t,e){switch(t){case mu.HIGHLIGHT_COLOR:Xd(this,dh,gh).call(this,e);break;case mu.HIGHLIGHT_THICKNESS:Xd(this,dh,fh).call(this,e)}}static get defaultPropertiesToUpdate(){return[[mu.HIGHLIGHT_COLOR,t._defaultColor],[mu.HIGHLIGHT_THICKNESS,t._defaultThickness]]}get propertiesToUpdate(){return[[mu.HIGHLIGHT_COLOR,this.color||t._defaultColor],[mu.HIGHLIGHT_THICKNESS,Vd(this,hh)||t._defaultThickness],[mu.HIGHLIGHT_FREE,Vd(this,nh)]]}onUpdatedColor(){var t,e;null==(t=this.parent)||t.drawLayer.updateProperties(Vd(this,sh),{root:{fill:this.color,"fill-opacity":this.opacity}}),null==(e=Vd(this,Ql))||e.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){if(this._uiManager.highlightColors){return[["colorPicker",qd(this,Ql,new qm({editor:this}))]]}return super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(Xd(this,dh,xh).call(this))}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,Xd(this,dh,xh).call(this))}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){Xd(this,dh,vh).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(Xd(this,dh,wh).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e;let i=!1;this.parent&&!t?Xd(this,dh,vh).call(this):t&&(Xd(this,dh,wh).call(this,t),i=!this.parent&&(null==(e=this.div)?void 0:e.classList.contains("selectedEditor"))),super.setParent(t),this.show(this._isVisible),i&&this.select()}rotate(e){var i,s,n;const{drawLayer:r}=this.parent;let a;Vd(this,nh)?(e=(e-this.rotation+360)%360,a=Xd(i=t,bh,yh).call(i,Vd(this,ih).box,e)):a=Xd(s=t,bh,yh).call(s,[this.x,this.y,this.width,this.height],e),r.updateProperties(Vd(this,sh),{bbox:a,root:{"data-main-rotation":e}}),r.updateProperties(Vd(this,oh),{bbox:Xd(n=t,bh,yh).call(n,Vd(this,Jl).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const t=super.render();Vd(this,lh)&&(t.setAttribute("aria-label",Vd(this,lh)),t.setAttribute("role","mark")),Vd(this,nh)?t.classList.add("free"):this.div.addEventListener("keydown",Xd(this,dh,Ah).bind(this),{signal:this._uiManager._signal});const e=qd(this,eh,document.createElement("div"));return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=Vd(this,Kl),this.setDims(this.width,this.height),Yp(this,Vd(this,eh),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){var t;this.isSelected||null==(t=this.parent)||t.drawLayer.updateProperties(Vd(this,oh),{rootClass:{hovered:!0}})}pointerleave(){var t;this.isSelected||null==(t=this.parent)||t.drawLayer.updateProperties(Vd(this,oh),{rootClass:{hovered:!1}})}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:Xd(this,dh,_h).call(this,!0);break;case 1:case 3:Xd(this,dh,_h).call(this,!1)}}select(){var t;super.select(),Vd(this,oh)&&(null==(t=this.parent)||t.drawLayer.updateProperties(Vd(this,oh),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var t;super.unselect(),Vd(this,oh)&&(null==(t=this.parent)||t.drawLayer.updateProperties(Vd(this,oh),{rootClass:{selected:!1}}),Vd(this,nh)||Xd(this,dh,_h).call(this,!1))}get _mustFixPosition(){return!Vd(this,nh)}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(Vd(this,sh),{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(Vd(this,oh),{rootClass:{hidden:!t}}))}static startHighlighting(t,e,{target:i,x:s,y:n}){const{x:r,y:a,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,c=t.combinedSignal(h),d=e=>{h.abort(),Xd(this,bh,Eh).call(this,t,e)};window.addEventListener("blur",d,{signal:c}),window.addEventListener("pointerup",d,{signal:c}),window.addEventListener("pointerdown",Ep,{capture:!0,passive:!1,signal:c}),window.addEventListener("contextmenu",Mp,{signal:c}),i.addEventListener("pointermove",Xd(this,bh,Mh).bind(this,t),{signal:c}),this._freeHighlight=new Hv({x:s,y:n},[r,a,o,l],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static async deserialize(t,e,i){var s,n,r,a;let o=null;if(t instanceof Sv){const{data:{quadPoints:e,rect:i,rotation:s,id:n,color:r,opacity:a,popupRef:l,richText:h,contentsObj:c,creationDate:d,modificationDate:u},parent:{page:{pageNumber:p}}}=t;o=t={annotationType:fu.HIGHLIGHT,color:Array.from(r),opacity:a,quadPoints:e,boxes:null,pageIndex:p-1,rect:i.slice(0),rotation:s,annotationElementId:n,id:n,deleted:!1,popupRef:l,richText:h,comment:(null==c?void 0:c.str)||null,creationDate:d,modificationDate:u}}else if(t instanceof kv){const{data:{inkLists:e,rect:i,rotation:s,id:n,color:r,borderStyle:{rawWidth:a},popupRef:l,richText:h,contentsObj:c,creationDate:d,modificationDate:u},parent:{page:{pageNumber:p}}}=t;o=t={annotationType:fu.HIGHLIGHT,color:Array.from(r),thickness:a,inkLists:e,boxes:null,pageIndex:p-1,rect:i.slice(0),rotation:s,annotationElementId:n,id:n,deleted:!1,popupRef:l,richText:h,comment:(null==c?void 0:c.str)||null,creationDate:d,modificationDate:u}}const{color:l,quadPoints:h,inkLists:c,opacity:d}=t,u=await super.deserialize(t,e,i);u.color=np.makeHexColor(...l),u.opacity=d||1,c&&qd(u,hh,t.thickness),u._initialData=o,t.comment&&u.setCommentData(t);const[p,g]=u.pageDimensions,[f,m]=u.pageTranslation;if(h){const t=qd(u,Yl,[]);for(let e=0;e<h.length;e+=8)t.push({x:(h[e]-f)/p,y:1-(h[e+1]-m)/g,width:(h[e+2]-h[e])/p,height:(h[e+1]-h[e+5])/g});Xd(s=u,dh,uh).call(s),Xd(n=u,dh,wh).call(n),u.rotate(u.rotation)}else if(c){qd(u,nh,!0);const t=c[0],i={x:t[0]-f,y:g-(t[1]-m)},s=new Hv(i,[0,0,p,g],1,Vd(u,hh)/2,!0,.001);for(let e=0,r=t.length;e<r;e+=2)i.x=t[e]-f,i.y=g-(t[e+1]-m),s.add(i);const{id:n,clipPathId:o}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:u.color,"fill-opacity":u._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:s.toSVGPath()}},!0,!0);Xd(r=u,dh,ph).call(r,{highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:o}),Xd(a=u,dh,wh).call(a),u.rotate(u.parentRotation)}return u}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=dg._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i=super.serialize(t);return Object.assign(i,{color:e,opacity:this.opacity,thickness:Vd(this,hh),quadPoints:Xd(this,dh,kh).call(this),outlines:Xd(this,dh,Sh).call(this,i.rect)}),this.addComment(i),this.annotationElementId&&!Xd(this,dh,Ch).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}};ql=new WeakMap,Xl=new WeakMap,Yl=new WeakMap,Kl=new WeakMap,Ql=new WeakMap,Jl=new WeakMap,Zl=new WeakMap,th=new WeakMap,eh=new WeakMap,ih=new WeakMap,sh=new WeakMap,nh=new WeakMap,rh=new WeakMap,ah=new WeakMap,oh=new WeakMap,lh=new WeakMap,hh=new WeakMap,ch=new WeakMap,dh=new WeakSet,uh=function(){const t=new Ov(Vd(this,Yl),.001);qd(this,ih,t.getOutlines()),[this.x,this.y,this.width,this.height]=Vd(this,ih).box;const e=new Ov(Vd(this,Yl),.0025,.001,"ltr"===this._uiManager.direction);qd(this,Jl,e.getOutlines());const{firstPoint:i}=Vd(this,ih);qd(this,rh,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]);const{lastPoint:s}=Vd(this,Jl);qd(this,ah,[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height])},ph=function({highlightOutlines:t,highlightId:e,clipPathId:i}){var s,n;qd(this,ih,t);if(qd(this,Jl,t.getNewOutline(Vd(this,hh)/2+1.5,.0025)),e>=0)qd(this,sh,e),qd(this,Kl,i),this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),qd(this,oh,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:Vd(this,Jl).box,path:{d:Vd(this,Jl).toSVGPath()}},!0));else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(Vd(this,sh),{bbox:Xd(s=jv,bh,yh).call(s,Vd(this,ih).box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(Vd(this,oh),{bbox:Xd(n=jv,bh,yh).call(n,Vd(this,Jl).box,e),path:{d:Vd(this,Jl).toSVGPath()}})}const[r,a,o,l]=t.box;switch(this.rotation){case 0:this.x=r,this.y=a,this.width=o,this.height=l;break;case 90:{const[t,e]=this.parentDimensions;this.x=a,this.y=1-r,this.width=o*e/t,this.height=l*t/e;break}case 180:this.x=1-r,this.y=1-a,this.width=o,this.height=l;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-a,this.y=r,this.width=o*e/t,this.height=l*t/e;break}}const{firstPoint:h}=t;qd(this,rh,[(h[0]-r)/o,(h[1]-a)/l]);const{lastPoint:c}=Vd(this,Jl);qd(this,ah,[(c[0]-r)/o,(c[1]-a)/l])},gh=function(t){const e=(t,e)=>{this.color=t,this.opacity=e,this.onUpdatedColor()},i=this.color,s=this.opacity;this.addCommands({cmd:e.bind(this,t,jv._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:mu.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)},fh=function(t){const e=Vd(this,hh),i=t=>{qd(this,hh,t),Xd(this,dh,mh).call(this,t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:mu.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)},mh=function(t){Vd(this,nh)&&(Xd(this,dh,ph).call(this,{highlightOutlines:Vd(this,ih).getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims(this.width,this.height))},vh=function(){null!==Vd(this,sh)&&this.parent&&(this.parent.drawLayer.remove(Vd(this,sh)),qd(this,sh,null),this.parent.drawLayer.remove(Vd(this,oh)),qd(this,oh,null))},wh=function(t=this.parent){null===Vd(this,sh)&&(({id:Yd(this,sh)._,clipPathId:Yd(this,Kl)._}=t.drawLayer.draw({bbox:Vd(this,ih).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:Vd(this,nh)},path:{d:Vd(this,ih).toSVGPath()}},!1,!0)),qd(this,oh,t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:Vd(this,nh)},bbox:Vd(this,Jl).box,path:{d:Vd(this,Jl).toSVGPath()}},Vd(this,nh))),Vd(this,eh)&&(Vd(this,eh).style.clipPath=Vd(this,Kl)))},bh=new WeakSet,yh=function([t,e,i,s],n){switch(n){case 90:return[1-e-s,t,s,i];case 180:return[1-t-i,1-e-s,i,s];case 270:return[e,1-t-i,s,i]}return[t,e,i,s]},Ah=function(t){jv._keyboardManager.exec(this,t)},_h=function(t){if(!Vd(this,ql))return;const e=window.getSelection();t?e.setPosition(Vd(this,ql),Vd(this,Xl)):e.setPosition(Vd(this,Zl),Vd(this,th))},xh=function(){return Vd(this,nh)?this.rotation:0},kh=function(){if(Vd(this,nh))return null;const[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=Vd(this,Yl),r=new Float32Array(8*n.length);let a=0;for(const{x:o,y:l,width:h,height:c}of n){const n=o*t+i,d=(1-l)*e+s;r[a]=r[a+4]=n,r[a+1]=r[a+3]=d,r[a+2]=r[a+6]=n+h*t,r[a+5]=r[a+7]=d-c*e,a+=8}return r},Sh=function(t){return Vd(this,ih).serialize(t,Xd(this,dh,xh).call(this))},Mh=function(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},Eh=function(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},Ch=function(t){const{color:e}=this._initialData;return this.hasEditedComment||t.color.some((t,i)=>t!==e[i])},Gd(jv,bh),jd(jv,"_defaultColor",null),jd(jv,"_defaultOpacity",1),jd(jv,"_defaultThickness",12),jd(jv,"_type","highlight"),jd(jv,"_editorType",fu.HIGHLIGHT),jd(jv,"_freeHighlightId",-1),jd(jv,"_freeHighlight",null),jd(jv,"_freeHighlightClipId","");let zv=jv;class Vv{constructor(){Gd(this,Th,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,i]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,i)}updateSVGProperty(t,e){Vd(this,Th)[t]=e}toSVGProperties(){const t=Vd(this,Th);return qd(this,Th,Object.create(null)),{root:t}}reset(){qd(this,Th,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){$u("Not implemented")}}Th=new WeakMap;const Gv=class t extends dg{constructor(t){super(t),Gd(this,Oh),Gd(this,Ph,null),Gd(this,Dh),jd(this,"_colorPicker",null),jd(this,"_drawId",null),qd(this,Dh,t.mustBeCommitted||!1),this._addOutlines(t)}onUpdatedColor(){var t;null==(t=this._colorPicker)||t.update(this.color),super.onUpdatedColor()}_addOutlines(t){t.drawOutlines&&(Xd(this,Oh,Uh).call(this,t),Xd(this,Oh,jh).call(this))}static _mergeSVGProperties(t,e){const i=new Set(Object.keys(t));for(const[s,n]of Object.entries(e))i.has(s)?Object.assign(t[s],n):t[s]=n;return t}static getDefaultDrawingOptions(t){$u("Not implemented")}static get typesMap(){$u("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,i){const s=this.typesMap.get(e);s&&this._defaultDrawingOptions.updateProperty(s,i),this._currentParent&&(Vd(t,Rh).updateProperty(s,i),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){const s=this._drawingOptions,n=s[e],r=i=>{var n;s.updateProperty(e,i);const r=Vd(this,Ph).updateProperty(e,i);r&&Xd(this,Oh,Gh).call(this,r),null==(n=this.parent)||n.drawLayer.updateProperties(this._drawId,s.toSVGProperties()),t===this.colorType&&this.onUpdatedColor()};this.addCommands({cmd:r.bind(this,i),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;null==(e=this.parent)||e.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties(Vd(this,Ph).getPathResizingSVGProperties(Xd(this,Oh,Vh).call(this)),{bbox:Xd(this,Oh,qh).call(this)}))}_onResized(){var e;null==(e=this.parent)||e.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties(Vd(this,Ph).getPathResizedSVGProperties(Xd(this,Oh,Vh).call(this)),{bbox:Xd(this,Oh,qh).call(this)}))}_onTranslating(t,e){var i;null==(i=this.parent)||i.drawLayer.updateProperties(this._drawId,{bbox:Xd(this,Oh,qh).call(this)})}_onTranslated(){var e;null==(e=this.parent)||e.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties(Vd(this,Ph).getPathTranslatedSVGProperties(Xd(this,Oh,Vh).call(this),this.parentDimensions),{bbox:Xd(this,Oh,qh).call(this)}))}_onStartDragging(){var t;null==(t=this.parent)||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var t;null==(t=this.parent)||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,Vd(this,Dh)&&(qd(this,Dh,!1),this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){Xd(this,Oh,$h).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(Xd(this,Oh,jh).call(this),Xd(this,Oh,Gh).call(this,Vd(this,Ph).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e;let i=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),Xd(this,Oh,$h).call(this)):t&&(this._uiManager.addShouldRescale(this),Xd(this,Oh,jh).call(this,t),i=!this.parent&&(null==(e=this.div)?void 0:e.classList.contains("selectedEditor"))),super.setParent(t),i&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties({bbox:Xd(this,Oh,qh).call(this)},Vd(this,Ph).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&Xd(this,Oh,Gh).call(this,Vd(this,Ph).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const i=super.render();i.classList.add("draw");const s=document.createElement("div");return i.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),i}static createDrawerInstance(t,e,i,s,n){$u("Not implemented")}static startDrawing(e,i,s,n){var r;const{target:a,offsetX:o,offsetY:l,pointerId:h,pointerType:c}=n;if(Vd(t,Nh)&&Vd(t,Nh)!==c)return;const{viewport:{rotation:d}}=e,{width:u,height:p}=a.getBoundingClientRect(),g=qd(t,Ih,new AbortController),f=e.combinedSignal(g);Vd(t,Fh)||qd(t,Fh,h),Vd(t,Nh)??qd(t,Nh,c),window.addEventListener("pointerup",e=>{var i;Vd(t,Fh)===e.pointerId?this._endDraw(e):null==(i=Vd(t,Wh))||i.delete(e.pointerId)},{signal:f}),window.addEventListener("pointercancel",e=>{var i;Vd(t,Fh)===e.pointerId?this._currentParent.endDrawingSession():null==(i=Vd(t,Wh))||i.delete(e.pointerId)},{signal:f}),window.addEventListener("pointerdown",e=>{Vd(t,Nh)===e.pointerType&&((Vd(t,Wh)||qd(t,Wh,new Set)).add(e.pointerId),Vd(t,Rh).isCancellable()&&(Vd(t,Rh).removeLastElement(),Vd(t,Rh).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",Mp,{signal:f}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:f}),a.addEventListener("touchmove",e=>{e.timeStamp===Vd(t,Bh)&&Ep(e)},{signal:f}),e.toggleDrawing(),null==(r=i._editorUndoBar)||r.hide(),Vd(t,Rh)?e.drawLayer.updateProperties(this._currentDrawId,Vd(t,Rh).startNew(o,l,u,p,d)):(i.updateUIForDefaultProperties(this),qd(t,Rh,this.createDrawerInstance(o,l,u,p,d)),qd(t,Lh,this.getDefaultDrawingOptions()),this._currentParent=e,({id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(Vd(t,Lh).toSVGProperties(),Vd(t,Rh).defaultSVGProperties),!0,!1)))}static _drawMove(e){var i;if(qd(t,Bh,-1),!Vd(t,Rh))return;const{offsetX:s,offsetY:n,pointerId:r}=e;Vd(t,Fh)===r&&((null==(i=Vd(t,Wh))?void 0:i.size)>=1?this._endDraw(e):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,Vd(t,Rh).add(s,n)),qd(t,Bh,e.timeStamp),Ep(e)))}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,qd(t,Rh,null),qd(t,Lh,null),qd(t,Nh,null),qd(t,Bh,NaN)),Vd(t,Ih)&&(Vd(t,Ih).abort(),qd(t,Ih,null),qd(t,Fh,NaN),qd(t,Wh,null))}static _endDraw(e){const i=this._currentParent;if(i){if(i.toggleDrawing(!0),this._cleanup(!1),(null==e?void 0:e.target)===i.div&&i.drawLayer.updateProperties(this._currentDrawId,Vd(t,Rh).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const e=Vd(t,Rh),s=this._currentDrawId,n=e.getLastElement();return void i.addCommands({cmd:()=>{i.drawLayer.updateProperties(s,e.setLastElement(n))},undo:()=>{i.drawLayer.updateProperties(s,e.removeLastElement())},mustExec:!1,type:mu.DRAW_STEP})}this.endDrawing(!1)}}static endDrawing(e){const i=this._currentParent;if(!i)return null;if(i.toggleDrawing(!0),i.cleanUndoStack(mu.DRAW_STEP),!Vd(t,Rh).isEmpty()){const{pageDimensions:[s,n],scale:r}=i,a=i.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:Vd(t,Rh).getOutlines(s*r,n*r,r,this._INNER_MARGIN),drawingOptions:Vd(t,Lh),mustBeCommitted:!e});return this._cleanup(!0),a}return i.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,n,r){$u("Not implemented")}static async deserialize(t,e,i){var s,n;const{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}=e.viewport,h=this.deserializeDraw(o,l,r,a,this._INNER_MARGIN,t),c=await super.deserialize(t,e,i);return c.createDrawingOptions(t),Xd(s=c,Oh,Uh).call(s,{drawOutlines:h}),Xd(n=c,Oh,jh).call(n),c.onScaleChanging(),c.rotate(),c}serializeDraw(t){const[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return Vd(this,Ph).serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};Ph=new WeakMap,Dh=new WeakMap,Rh=new WeakMap,Ih=new WeakMap,Lh=new WeakMap,Fh=new WeakMap,Nh=new WeakMap,Wh=new WeakMap,Bh=new WeakMap,Oh=new WeakSet,Uh=function({drawOutlines:t,drawId:e,drawingOptions:i}){qd(this,Ph,t),this._drawingOptions||(this._drawingOptions=i),this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=Xd(this,Oh,Hh).call(this,t,this.parent),Xd(this,Oh,Gh).call(this,t.box)},Hh=function(t,e){const{id:i}=e.drawLayer.draw(Gv._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i},$h=function(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},jh=function(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=Xd(this,Oh,Hh).call(this,Vd(this,Ph),t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))},zh=function([t,e,i,s]){const{parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[e,1-t,i*(r/n),s*(n/r)];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,i*(r/n),s*(n/r)];default:return[t,e,i,s]}},Vh=function(){const{x:t,y:e,width:i,height:s,parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[1-e,t,i*(n/r),s*(r/n)];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,i*(n/r),s*(r/n)];default:return[t,e,i,s]}},Gh=function(t){[this.x,this.y,this.width,this.height]=Xd(this,Oh,zh).call(this,t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},qh=function(){const{x:t,y:e,width:i,height:s,rotation:n,parentRotation:r,parentDimensions:[a,o]}=this;switch((4*n+r)/90){case 1:return[1-e-s,t,s,i];case 2:return[1-t-i,1-e-s,i,s];case 3:return[e,1-t-i,s,i];case 4:return[t,e-i*(a/o),s*(o/a),i*(a/o)];case 5:return[1-e,t,i*(a/o),s*(o/a)];case 6:return[1-t-s*(o/a),1-e,s*(o/a),i*(a/o)];case 7:return[e-i*(a/o),1-t-s*(o/a),i*(a/o),s*(o/a)];case 8:return[t-i,e-s,i,s];case 9:return[1-e,t-i,s,i];case 10:return[1-t,1-e,i,s];case 11:return[e-s,1-t,s,i];case 12:return[t-s*(o/a),e,s*(o/a),i*(a/o)];case 13:return[1-e-i*(a/o),t-s*(o/a),i*(a/o),s*(o/a)];case 14:return[1-t,1-e-i*(a/o),s*(o/a),i*(a/o)];case 15:return[e,1-t,i*(a/o),s*(o/a)];default:return[t,e,i,s]}},jd(Gv,"_currentDrawId",-1),jd(Gv,"_currentParent",null),Gd(Gv,Rh,null),Gd(Gv,Ih,null),Gd(Gv,Lh,null),Gd(Gv,Fh,NaN),Gd(Gv,Nh,null),Gd(Gv,Wh,null),Gd(Gv,Bh,NaN),jd(Gv,"_INNER_MARGIN",3);let qv=Gv;class Xv{constructor(t,e,i,s,n,r){Gd(this,rc),Gd(this,Xh,new Float64Array(6)),Gd(this,Yh),Gd(this,Kh),Gd(this,Qh),Gd(this,Jh),Gd(this,Zh),Gd(this,tc,""),Gd(this,ec,0),Gd(this,ic,new Yv),Gd(this,sc),Gd(this,nc),qd(this,sc,i),qd(this,nc,s),qd(this,Qh,n),qd(this,Jh,r),[t,e]=Xd(this,rc,ac).call(this,t,e);const a=qd(this,Yh,[NaN,NaN,NaN,NaN,t,e]);qd(this,Zh,[t,e]),qd(this,Kh,[{line:a,points:Vd(this,Zh)}]),Vd(this,Xh).set(a,0)}updateProperty(t,e){"stroke-width"===t&&qd(this,Jh,e)}isEmpty(){return!Vd(this,Kh)||0===Vd(this,Kh).length}isCancellable(){return Vd(this,Zh).length<=10}add(t,e){[t,e]=Xd(this,rc,ac).call(this,t,e);const[i,s,n,r]=Vd(this,Xh).subarray(2,6),a=t-n,o=e-r;return Math.hypot(Vd(this,sc)*a,Vd(this,nc)*o)<=2?null:(Vd(this,Zh).push(t,e),isNaN(i)?(Vd(this,Xh).set([n,r,t,e],2),Vd(this,Yh).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(Vd(this,Xh)[0])&&Vd(this,Yh).splice(6,6),Vd(this,Xh).set([i,s,n,r,t,e],0),Vd(this,Yh).push(...Fv.createBezierPoints(i,s,n,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const i=this.add(t,e);return i||(2===Vd(this,Zh).length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,n){qd(this,sc,i),qd(this,nc,s),qd(this,Qh,n),[t,e]=Xd(this,rc,ac).call(this,t,e);const r=qd(this,Yh,[NaN,NaN,NaN,NaN,t,e]);qd(this,Zh,[t,e]);const a=Vd(this,Kh).at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),Vd(this,Kh).push({line:r,points:Vd(this,Zh)}),Vd(this,Xh).set(r,0),qd(this,ec,0),this.toSVGPath(),null}getLastElement(){return Vd(this,Kh).at(-1)}setLastElement(t){return Vd(this,Kh)?(Vd(this,Kh).push(t),qd(this,Yh,t.line),qd(this,Zh,t.points),qd(this,ec,0),{path:{d:this.toSVGPath()}}):Vd(this,ic).setLastElement(t)}removeLastElement(){if(!Vd(this,Kh))return Vd(this,ic).removeLastElement();Vd(this,Kh).pop(),qd(this,tc,"");for(let t=0,e=Vd(this,Kh).length;t<e;t++){const{line:e,points:i}=Vd(this,Kh)[t];qd(this,Yh,e),qd(this,Zh,i),qd(this,ec,0),this.toSVGPath()}return{path:{d:Vd(this,tc)}}}toSVGPath(){const t=Fv.svgRound(Vd(this,Yh)[4]),e=Fv.svgRound(Vd(this,Yh)[5]);if(2===Vd(this,Zh).length)return qd(this,tc,`${Vd(this,tc)} M ${t} ${e} Z`),Vd(this,tc);if(Vd(this,Zh).length<=6){const i=Vd(this,tc).lastIndexOf("M");qd(this,tc,`${Vd(this,tc).slice(0,i)} M ${t} ${e}`),qd(this,ec,6)}if(4===Vd(this,Zh).length){const t=Fv.svgRound(Vd(this,Yh)[10]),e=Fv.svgRound(Vd(this,Yh)[11]);return qd(this,tc,`${Vd(this,tc)} L ${t} ${e}`),qd(this,ec,12),Vd(this,tc)}const i=[];0===Vd(this,ec)&&(i.push(`M ${t} ${e}`),qd(this,ec,6));for(let s=Vd(this,ec),n=Vd(this,Yh).length;s<n;s+=6){const[t,e,n,r,a,o]=Vd(this,Yh).slice(s,s+6).map(Fv.svgRound);i.push(`C${t} ${e} ${n} ${r} ${a} ${o}`)}return qd(this,tc,Vd(this,tc)+i.join(" ")),qd(this,ec,Vd(this,Yh).length),Vd(this,tc)}getOutlines(t,e,i,s){const n=Vd(this,Kh).at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),Vd(this,ic).build(Vd(this,Kh),t,e,i,Vd(this,Qh),Vd(this,Jh),s),qd(this,Xh,null),qd(this,Yh,null),qd(this,Kh,null),qd(this,tc,null),Vd(this,ic)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Xh=new WeakMap,Yh=new WeakMap,Kh=new WeakMap,Qh=new WeakMap,Jh=new WeakMap,Zh=new WeakMap,tc=new WeakMap,ec=new WeakMap,ic=new WeakMap,sc=new WeakMap,nc=new WeakMap,rc=new WeakSet,ac=function(t,e){return Fv._normalizePoint(t,e,Vd(this,sc),Vd(this,nc),Vd(this,Qh))};class Yv extends Fv{constructor(){super(...arguments),Gd(this,mc),Gd(this,oc),Gd(this,lc,0),Gd(this,hc),Gd(this,cc),Gd(this,dc),Gd(this,uc),Gd(this,pc),Gd(this,gc),Gd(this,fc)}build(t,e,i,s,n,r,a){qd(this,dc,e),qd(this,uc,i),qd(this,pc,s),qd(this,gc,n),qd(this,fc,r),qd(this,hc,a??0),qd(this,cc,t),Xd(this,mc,bc).call(this)}get thickness(){return Vd(this,fc)}setLastElement(t){return Vd(this,cc).push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return Vd(this,cc).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of Vd(this,cc))if(t.push(`M${Fv.svgRound(e[4])} ${Fv.svgRound(e[5])}`),6!==e.length)if(12===e.length&&isNaN(e[6]))t.push(`L${Fv.svgRound(e[10])} ${Fv.svgRound(e[11])}`);else for(let i=6,s=e.length;i<s;i+=6){const[s,n,r,a,o,l]=e.subarray(i,i+6).map(Fv.svgRound);t.push(`C${s} ${n} ${r} ${a} ${o} ${l}`)}else t.push("Z");return t.join("")}serialize([t,e,i,s],n){const r=[],a=[],[o,l,h,c]=Xd(this,mc,wc).call(this);let d,u,p,g,f,m,v,w,b;switch(Vd(this,gc)){case 0:b=Fv._rescale,d=t,u=e+s,p=i,g=-s,f=t+o*i,m=e+(1-l-c)*s,v=t+(o+h)*i,w=e+(1-l)*s;break;case 90:b=Fv._rescaleAndSwap,d=t,u=e,p=i,g=s,f=t+l*i,m=e+o*s,v=t+(l+c)*i,w=e+(o+h)*s;break;case 180:b=Fv._rescale,d=t+i,u=e,p=-i,g=s,f=t+(1-o-h)*i,m=e+l*s,v=t+(1-o)*i,w=e+(l+c)*s;break;case 270:b=Fv._rescaleAndSwap,d=t+i,u=e+s,p=-i,g=-s,f=t+(1-l-c)*i,m=e+(1-o-h)*s,v=t+(1-l)*i,w=e+(1-o)*s}for(const{line:y,points:A}of Vd(this,cc))r.push(b(y,d,u,p,g,n?new Array(y.length):null)),a.push(b(A,d,u,p,g,n?new Array(A.length):null));return{lines:r,points:a,rect:[f,m,v,w]}}static deserialize(t,e,i,s,n,{paths:{lines:r,points:a},rotation:o,thickness:l}){const h=[];let c,d,u,p,g;switch(o){case 0:g=Fv._rescale,c=-t/i,d=e/s+1,u=1/i,p=-1/s;break;case 90:g=Fv._rescaleAndSwap,c=-e/s,d=-t/i,u=1/s,p=1/i;break;case 180:g=Fv._rescale,c=t/i+1,d=-e/s,u=-1/i,p=1/s;break;case 270:g=Fv._rescaleAndSwap,c=e/s+1,d=t/i+1,u=-1/s,p=-1/i}if(!r){r=[];for(const t of a){const e=t.length;if(2===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}const i=new Float32Array(3*(e-2));r.push(i);let[s,n,a,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,n],0);for(let r=4;r<e;r+=2){const e=t[r],l=t[r+1];i.set(Fv.createBezierPoints(s,n,a,o,e,l),3*(r-2)),[s,n,a,o]=[a,o,e,l]}}}for(let m=0,v=r.length;m<v;m++)h.push({line:g(r[m].map(t=>t??NaN),c,d,u,p),points:g(a[m].map(t=>t??NaN),c,d,u,p)});const f=new this.prototype.constructor;return f.build(h,i,s,1,o,l,n),f}get box(){return Vd(this,oc)}updateProperty(t,e){return"stroke-width"===t?Xd(this,mc,yc).call(this,e):null}updateParentDimensions([t,e],i){const[s,n]=Xd(this,mc,vc).call(this);qd(this,dc,t),qd(this,uc,e),qd(this,pc,i);const[r,a]=Xd(this,mc,vc).call(this),o=r-s,l=a-n,h=Vd(this,oc);return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return qd(this,lc,t),{path:{transform:this.rotationTransform}}}get viewBox(){return Vd(this,oc).map(Fv.svgRound).join(" ")}get defaultProperties(){const[t,e]=Vd(this,oc);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Fv.svgRound(t)} ${Fv.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=Vd(this,oc);let i=0,s=0,n=0,r=0,a=0,o=0;switch(Vd(this,lc)){case 90:s=e/t,n=-t/e,a=t;break;case 180:i=-1,r=-1,a=t,o=e;break;case 270:s=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${n} ${r} ${Fv.svgRound(a)} ${Fv.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){const[n,r]=Xd(this,mc,vc).call(this),[a,o,l,h]=Vd(this,oc);if(Math.abs(l-n)<=Fv.PRECISION||Math.abs(h-r)<=Fv.PRECISION){const n=t+i/2-(a+l/2),r=e+s/2-(o+h/2);return{path:{"transform-origin":`${Fv.svgRound(t)} ${Fv.svgRound(e)}`,transform:`${this.rotationTransform} translate(${n} ${r})`}}}const c=(i-2*n)/(l-2*n),d=(s-2*r)/(h-2*r),u=l/i,p=h/s;return{path:{"transform-origin":`${Fv.svgRound(a)} ${Fv.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${p}) translate(${Fv.svgRound(n)} ${Fv.svgRound(r)}) scale(${c} ${d}) translate(${Fv.svgRound(-n)} ${Fv.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,i,s]){const[n,r]=Xd(this,mc,vc).call(this),a=Vd(this,oc),[o,l,h,c]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=s,Math.abs(h-n)<=Fv.PRECISION||Math.abs(c-r)<=Fv.PRECISION){const n=t+i/2-(o+h/2),r=e+s/2-(l+c/2);for(const{line:t,points:e}of Vd(this,cc))Fv._translate(t,n,r,t),Fv._translate(e,n,r,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Fv.svgRound(t)} ${Fv.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const d=(i-2*n)/(h-2*n),u=(s-2*r)/(c-2*r),p=-d*(o+n)+t+n,g=-u*(l+r)+e+r;if(1!==d||1!==u||0!==p||0!==g)for(const{line:f,points:m}of Vd(this,cc))Fv._rescale(f,p,g,d,u,f),Fv._rescale(m,p,g,d,u,m);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Fv.svgRound(t)} ${Fv.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[s,n]=i,r=Vd(this,oc),a=t-r[0],o=e-r[1];if(Vd(this,dc)===s&&Vd(this,uc)===n)for(const{line:l,points:h}of Vd(this,cc))Fv._translate(l,a,o,l),Fv._translate(h,a,o,h);else{const t=Vd(this,dc)/s,e=Vd(this,uc)/n;qd(this,dc,s),qd(this,uc,n);for(const{line:i,points:s}of Vd(this,cc))Fv._rescale(i,a,o,t,e,i),Fv._rescale(s,a,o,t,e,s);r[2]*=t,r[3]*=e}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Fv.svgRound(t)} ${Fv.svgRound(e)}`}}}get defaultSVGProperties(){const t=Vd(this,oc);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Fv.svgRound(t[0])} ${Fv.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}oc=new WeakMap,lc=new WeakMap,hc=new WeakMap,cc=new WeakMap,dc=new WeakMap,uc=new WeakMap,pc=new WeakMap,gc=new WeakMap,fc=new WeakMap,mc=new WeakSet,vc=function(t=Vd(this,fc)){const e=Vd(this,hc)+t/2*Vd(this,pc);return Vd(this,gc)%180==0?[e/Vd(this,dc),e/Vd(this,uc)]:[e/Vd(this,uc),e/Vd(this,dc)]},wc=function(){const[t,e,i,s]=Vd(this,oc),[n,r]=Xd(this,mc,vc).call(this,0);return[t+n,e+r,i-2*n,s-2*r]},bc=function(){const t=qd(this,oc,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:s}of Vd(this,cc)){if(s.length<=12){for(let e=4,i=s.length;e<i;e+=6)np.pointBoundingBox(s[e],s[e+1],t);continue}let e=s[4],i=s[5];for(let n=6,r=s.length;n<r;n+=6){const[r,a,o,l,h,c]=s.subarray(n,n+6);np.bezierBoundingBox(e,i,r,a,o,l,h,c,t),e=h,i=c}}const[e,i]=Xd(this,mc,vc).call(this);t[0]=cp(t[0]-e,0,1),t[1]=cp(t[1]-i,0,1),t[2]=cp(t[2]+e,0,1),t[3]=cp(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]},yc=function(t){const[e,i]=Xd(this,mc,vc).call(this);qd(this,fc,t);const[s,n]=Xd(this,mc,vc).call(this),[r,a]=[s-e,n-i],o=Vd(this,oc);return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o};class Kv extends Vv{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:dg._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??(e=this["stroke-width"]),e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new Kv(this._viewParameters);return t.updateAll(this),t}}const Qv=class t extends qv{constructor(t){super({...t,name:"inkEditor"}),Gd(this,Ac),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){dg.initialize(t,e),this._defaultDrawingOptions=new Kv(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Gu(this,"typesMap",new Map([[mu.INK_THICKNESS,"stroke-width"],[mu.INK_COLOR,"stroke"],[mu.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,n){return new Xv(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,r){return Yv.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){let s=null;if(t instanceof kv){const{data:{inkLists:e,rect:i,rotation:n,id:r,color:a,opacity:o,borderStyle:{rawWidth:l},popupRef:h,richText:c,contentsObj:d,creationDate:u,modificationDate:p},parent:{page:{pageNumber:g}}}=t;s=t={annotationType:fu.INK,color:Array.from(a),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:g-1,rect:i.slice(0),rotation:n,annotationElementId:r,id:r,deleted:!1,popupRef:h,richText:c,comment:(null==d?void 0:d.str)||null,creationDate:u,modificationDate:p}}const n=await super.deserialize(t,e,i);return n._initialData=s,t.comment&&n.setCommentData(t),n}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Ym(this)),[["colorPicker",this._colorPicker]]}get colorType(){return mu.INK_COLOR}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:i,opacity:s}){this._drawingOptions=t.getDefaultDrawingOptions({stroke:np.makeHexColor(...e),"stroke-width":i,"stroke-opacity":s})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{stroke:s,"stroke-opacity":n,"stroke-width":r}}=this,a=Object.assign(super.serialize(t),{color:dg._colorManager.convert(s),opacity:n,thickness:r,paths:{lines:e,points:i}});return this.addComment(a),t?(a.isCopy=!0,a):this.annotationElementId&&!Xd(this,Ac,_c).call(this,a)?null:(a.id=this.annotationElementId,a)}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;const{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}};Ac=new WeakSet,_c=function(t){const{color:e,thickness:i,opacity:s,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((t,i)=>t!==e[i])||t.thickness!==i||t.opacity!==s||t.pageIndex!==n},jd(Qv,"_type","ink"),jd(Qv,"_editorType",fu.INK),jd(Qv,"_defaultDrawingOptions",null);let Jv=Qv;class Zv extends Yv{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}class tw{static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:s},n,r,a,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1});const c=h.font=`${i} ${s} 200px ${e}`,{actualBoundingBoxLeft:d,actualBoundingBoxRight:u,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:f,fontBoundingBoxDescent:m,width:v}=h.measureText(t),w=1.5,b=Math.ceil(Math.max(Math.abs(d)+Math.abs(u)||0,v)*w),y=Math.ceil(Math.max(Math.abs(p)+Math.abs(g)||200,Math.abs(f)+Math.abs(m)||200)*w);l=new OffscreenCanvas(b,y),h=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=c,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,b,y),h.fillStyle="black",h.fillText(t,.5*b/2,1.5*y/2);const A=Xd(this,kc,Lc).call(this,h.getImageData(0,0,b,y).data),_=Xd(this,kc,Ic).call(this,A),x=Xd(this,kc,Fc).call(this,_),k=Xd(this,kc,Tc).call(this,A,b,y,x);return this.processDrawnLines({lines:{curves:k,width:b,height:y},pageWidth:n,pageHeight:r,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,i,s,n){const[r,a,o]=Xd(this,kc,Nc).call(this,t),[l,h]=Xd(this,kc,Rc).call(this,r,a,o,Math.hypot(a,o)*Vd(this,xc).sigmaSFactor,Vd(this,xc).sigmaR,Vd(this,xc).kernelSize),c=Xd(this,kc,Fc).call(this,h),d=Xd(this,kc,Tc).call(this,l,a,o,c);return this.processDrawnLines({lines:{curves:d,width:a,height:o},pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:r,areContours:a}){s%180!=0&&([e,i]=[i,e]);const{curves:o,width:l,height:h}=t,c=t.thickness??0,d=[],u=Math.min(e/l,i/h),p=u/e,g=u/i,f=[];for(const{points:v}of o){const t=r?Xd(this,kc,Dc).call(this,v):v;if(!t)continue;f.push(t);const e=t.length,i=new Float32Array(e),s=new Float32Array(3*(2===e?2:e-2));if(d.push({line:s,points:i}),2===e){i[0]=t[0]*p,i[1]=t[1]*g,s.set([NaN,NaN,NaN,NaN,i[0],i[1]],0);continue}let[n,a,o,l]=t;n*=p,a*=g,o*=p,l*=g,i.set([n,a,o,l],0),s.set([NaN,NaN,NaN,NaN,n,a],0);for(let r=4;r<e;r+=2){const e=i[r]=t[r]*p,h=i[r+1]=t[r+1]*g;s.set(Fv.createBezierPoints(n,a,o,l,e,h),3*(r-2)),[n,a,o,l]=[o,l,e,h]}}if(0===d.length)return null;const m=a?new Zv:new Yv;return m.build(d,e,i,1,s,a?0:c,n),{outline:m,newCurves:f,areContours:a,thickness:c,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:s,height:n}){let r,a=1/0,o=-1/0,l=0;for(const v of t){l+=v.length;for(let t=2,e=v.length;t<e;t++){const e=v[t]-v[t-2];a=Math.min(a,e),o=Math.max(o,e)}}r=a>=-128&&o<=127?Int8Array:a>=-32768&&o<=32767?Int16Array:Int32Array;const h=t.length,c=8+3*h,d=new Uint32Array(c);let u=0;d[u++]=c*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*r.BYTES_PER_ELEMENT,d[u++]=0,d[u++]=s,d[u++]=n,d[u++]=e?0:1,d[u++]=Math.max(0,Math.floor(i??0)),d[u++]=h,d[u++]=r.BYTES_PER_ELEMENT;for(const v of t)d[u++]=v.length-2,d[u++]=v[0],d[u++]=v[1];const p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(d);const f=r.prototype.constructor;for(const v of t){const t=new f(v.length-2);for(let e=2,i=v.length;e<i;e++)t[e-2]=v[e]-v[e-2];g.write(t)}g.close();const m=await new Response(p.readable).arrayBuffer();return dp(new Uint8Array(m))}static async decompressSignature(t){try{const i=(e=t,Uint8Array.fromBase64?Uint8Array.fromBase64(e):ep(atob(e))),{readable:s,writable:n}=new DecompressionStream("deflate-raw"),r=n.getWriter();await r.ready,r.write(i).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let a=null,o=0;for await(const t of s)a||(a=new Uint8Array(new Uint32Array(t.buffer,0,4)[0])),a.set(t,o),o+=t.length;const l=new Uint32Array(a.buffer,0,a.length>>2),h=l[1];if(0!==h)throw new Error(`Invalid version: ${h}`);const c=l[2],d=l[3],u=0===l[4],p=l[5],g=l[6],f=l[7],m=[],v=(8+3*g)*Uint32Array.BYTES_PER_ELEMENT;let w;switch(f){case Int8Array.BYTES_PER_ELEMENT:w=new Int8Array(a.buffer,v);break;case Int16Array.BYTES_PER_ELEMENT:w=new Int16Array(a.buffer,v);break;case Int32Array.BYTES_PER_ELEMENT:w=new Int32Array(a.buffer,v)}o=0;for(let t=0;t<g;t++){const e=l[3*t+8],i=new Float32Array(e+2);m.push(i);for(let s=0;s<2;s++)i[s]=l[3*t+8+s+1];for(let t=0;t<e;t++)i[t+2]=i[t]+w[o++]}return{areContours:u,thickness:p,outlines:m,width:c,height:d}}catch(i){return Hu(`decompressSignature: ${i}`),null}var e}}xc=new WeakMap,kc=new WeakSet,Sc=function(t,e,i,s){return s-=e,0===(i-=t)?s>0?0:4:1===i?s+6:2-s},Mc=new WeakMap,Ec=function(t,e,i,s,n,r,a){const o=Xd(this,kc,Sc).call(this,i,s,n,r);for(let l=0;l<8;l++){const n=(-l+o-a+16)%8;if(0!==t[(i+Vd(this,Mc)[2*n])*e+(s+Vd(this,Mc)[2*n+1])])return n}return-1},Cc=function(t,e,i,s,n,r,a){const o=Xd(this,kc,Sc).call(this,i,s,n,r);for(let l=0;l<8;l++){const n=(l+o+a+16)%8;if(0!==t[(i+Vd(this,Mc)[2*n])*e+(s+Vd(this,Mc)[2*n+1])])return n}return-1},Tc=function(t,e,i,s){const n=t.length,r=new Int32Array(n);for(let h=0;h<n;h++)r[h]=t[h]<=s?1:0;for(let h=1;h<i-1;h++)r[h*e]=r[h*e+e-1]=0;for(let h=0;h<e;h++)r[h]=r[e*i-1-h]=0;let a,o=1;const l=[];for(let h=1;h<i-1;h++){a=1;for(let t=1;t<e-1;t++){const i=h*e+t,s=r[i];if(0===s)continue;let n=h,c=t;if(1===s&&0===r[i-1])o+=1,c-=1;else{if(!(s>=1&&0===r[i+1])){1!==s&&(a=Math.abs(s));continue}o+=1,c+=1,s>1&&(a=s)}const d=[t,h],u=c===t+1,p={isHole:u,points:d,id:o,parent:0};let g;l.push(p);for(const t of l)if(t.id===a){g=t;break}g?g.isHole?p.parent=u?g.parent:a:p.parent=u?a:g.parent:p.parent=u?a:0;const f=Xd(this,kc,Ec).call(this,r,e,h,t,n,c,0);if(-1===f){r[i]=-o,1!==r[i]&&(a=Math.abs(r[i]));continue}let m=Vd(this,Mc)[2*f],v=Vd(this,Mc)[2*f+1];const w=h+m,b=t+v;n=w,c=b;let y=h,A=t;for(;;){const s=Xd(this,kc,Cc).call(this,r,e,y,A,n,c,1);m=Vd(this,Mc)[2*s],v=Vd(this,Mc)[2*s+1];const l=y+m,u=A+v;d.push(u,l);const p=y*e+A;if(0===r[p+1]?r[p]=-o:1===r[p]&&(r[p]=o),l===h&&u===t&&y===w&&A===b){1!==r[i]&&(a=Math.abs(r[i]));break}n=y,c=A,y=l,A=u}}}return l},Pc=function(t,e,i,s){if(i-e<=4){for(let n=e;n<i-2;n+=2)s.push(t[n],t[n+1]);return}const n=t[e],r=t[e+1],a=t[i-4]-n,o=t[i-3]-r,l=Math.hypot(a,o),h=a/l,c=o/l,d=h*r-c*n,u=o/a,p=1/l,g=Math.atan(u),f=Math.cos(g),m=Math.sin(g),v=p*(Math.abs(f)+Math.abs(m)),w=p*(1-v+v**2),b=Math.max(Math.atan(Math.abs(m+f)*w),Math.atan(Math.abs(m-f)*w));let y=0,A=e;for(let _=e+2;_<i-2;_+=2){const e=Math.abs(d-h*t[_+1]+c*t[_]);e>y&&(A=_,y=e)}y>(l*b)**2?(Xd(this,kc,Pc).call(this,t,e,A+2,s),Xd(this,kc,Pc).call(this,t,A,i,s)):s.push(n,r)},Dc=function(t){const e=[],i=t.length;return Xd(this,kc,Pc).call(this,t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e},Rc=function(t,e,i,s,n,r){const a=new Float32Array(r**2),o=-2*s**2,l=r>>1;for(let g=0;g<r;g++){const t=(g-l)**2;for(let e=0;e<r;e++)a[g*r+e]=Math.exp((t+(e-l)**2)/o)}const h=new Float32Array(256),c=-2*n**2;for(let g=0;g<256;g++)h[g]=Math.exp(g**2/c);const d=t.length,u=new Uint8Array(d),p=new Uint32Array(256);for(let g=0;g<i;g++)for(let s=0;s<e;s++){const n=g*e+s,o=t[n];let c=0,d=0;for(let u=0;u<r;u++){const n=g+u-l;if(!(n<0||n>=i))for(let i=0;i<r;i++){const p=s+i-l;if(p<0||p>=e)continue;const g=t[n*e+p],f=a[u*r+i]*h[Math.abs(g-o)];c+=g*f,d+=f}}p[u[n]=Math.round(c/d)]++}return[u,p]},Ic=function(t){const e=new Uint32Array(256);for(const i of t)e[i]++;return e},Lc=function(t){const e=t.length,i=new Uint8ClampedArray(e>>2);let s=-1/0,n=1/0;for(let a=0,o=i.length;a<o;a++){const e=i[a]=t[a<<2];s=Math.max(s,e),n=Math.min(n,e)}const r=255/(s-n);for(let a=0,o=i.length;a<o;a++)i[a]=(i[a]-n)*r;return i},Fc=function(t){let e,i=-1/0,s=-1/0;const n=t.findIndex(t=>0!==t);let r=n,a=n;for(e=n;e<256;e++){const n=t[e];n>i&&(e-r>s&&(s=e-r,a=e-1),i=n,r=e)}for(e=a-1;e>=0&&!(t[e]>t[e+1]);e--);return e},Nc=function(t){const e=t,{width:i,height:s}=t,{maxDim:n}=Vd(this,xc);let r=i,a=s;if(i>n||s>n){let o=i,l=s,h=Math.log2(Math.max(i,s)/n);const c=Math.floor(h);h=h===c?c-1:c;for(let i=0;i<h;i++){r=Math.ceil(o/2),a=Math.ceil(l/2);const i=new OffscreenCanvas(r,a);i.getContext("2d").drawImage(t,0,0,o,l,0,0,r,a),o=r,l=a,t!==e&&t.close(),t=i.transferToImageBitmap()}const d=Math.min(n/r,n/a);r=Math.round(r*d),a=Math.round(a*d)}const o=new OffscreenCanvas(r,a).getContext("2d",{willReadFrequently:!0});o.fillStyle="white",o.fillRect(0,0,r,a),o.filter="grayscale(1)",o.drawImage(t,0,0,t.width,t.height,0,0,r,a);const l=o.getImageData(0,0,r,a).data;return[Xd(this,kc,Lc).call(this,l),r,a]},Gd(tw,kc),Gd(tw,xc,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),Gd(tw,Mc,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class ew extends Vv{constructor(){super(),super.updateProperties({fill:dg._defaultLineColor,"stroke-width":0})}clone(){const t=new ew;return t.updateAll(this),t}}class iw extends Kv{constructor(t){super(t),super.updateProperties({stroke:dg._defaultLineColor,"stroke-width":1})}clone(){const t=new iw(this._viewParameters);return t.updateAll(this),t}}const sw=class t extends qv{constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),Gd(this,Wc,!1),Gd(this,Bc,null),Gd(this,Oc,null),Gd(this,Uc,null),this._willKeepAspectRatio=!0,qd(this,Oc,t.signatureData||null),qd(this,Bc,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){dg.initialize(t,e),this._defaultDrawingOptions=new ew,this._defaultDrawnSignatureOptions=new iw(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return Gu(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!Vd(this,Bc)}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,i;const{_isCopy:s}=this;if(s&&(this._isCopy=!1,e=this.x,i=this.y),super.render(),null===this._drawId)if(Vd(this,Oc)){const{lines:e,mustSmooth:i,areContours:s,description:n,uuid:r,heightInPage:a}=Vd(this,Oc),{rawDims:{pageWidth:o,pageHeight:l},rotation:h}=this.parent.viewport,c=tw.processDrawnLines({lines:e,pageWidth:o,pageHeight:l,rotation:h,innerMargin:t._INNER_MARGIN,mustSmooth:i,areContours:s});this.addSignature(c,a,n,r)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:Vd(this,Bc)||""}));return s&&(this._isCopy=!0,this._moveAfterPaste(e,i)),this.div}setUuid(t){qd(this,Uc,t),this.addEditToolbar()}getUuid(){return Vd(this,Uc)}get description(){return Vd(this,Bc)}set description(t){qd(this,Bc,t),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{null==e||e.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:i,width:s,height:n}=Vd(this,Oc),r=Math.max(s,n);return{areContours:e,outline:tw.processDrawnLines({lines:{curves:t.map(t=>({points:t})),thickness:i,width:s,height:n},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,i,s,n){const{x:r,y:a}=this,{outline:o}=qd(this,Oc,e);let l;qd(this,Wc,o instanceof Zv),this.description=s,Vd(this,Wc)?l=t.getDefaultDrawingOptions():(l=t._defaultDrawnSignatureOptions.clone(),l.updateProperties({"stroke-width":o.thickness})),this._addOutlines({drawOutlines:o,drawingOptions:l});const[,h]=this.pageDimensions;let c=i/h;c=c>=1?.5:c,this.width*=c/this.height,this.width>=1&&(c*=.9/this.width,this.width=.9),this.height=c,this.setDims(),this.x=r,this.y=a,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(n),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!n,hasDescription:!!s}}),this.div.hidden=!1}getFromImage(e){const{rawDims:{pageWidth:i,pageHeight:s},rotation:n}=this.parent.viewport;return tw.process(e,i,s,n,t._INNER_MARGIN)}getFromText(e,i){const{rawDims:{pageWidth:s,pageHeight:n},rotation:r}=this.parent.viewport;return tw.extractContoursFromText(e,i,s,n,r,t._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:i,pageHeight:s},rotation:n}=this.parent.viewport;return tw.processDrawnLines({lines:e,pageWidth:i,pageHeight:s,rotation:n,innerMargin:t._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:i}){e?this._drawingOptions=t.getDefaultDrawingOptions():(this._drawingOptions=t._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":i}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":s}}=this,n=Object.assign(super.serialize(t),{isSignature:!0,areContours:Vd(this,Wc),color:[0,0,0],thickness:Vd(this,Wc)?0:s});return this.addComment(n),t?(n.paths={lines:e,points:i},n.uuid=Vd(this,Uc),n.isCopy=!0):n.lines=e,Vd(this,Bc)&&(n.accessibilityData={type:"Figure",alt:Vd(this,Bc)}),n}static deserializeDraw(t,e,i,s,n,r){return r.areContours?Zv.deserialize(t,e,i,s,n,r):Yv.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){var s;const n=await super.deserialize(t,e,i);return qd(n,Wc,t.areContours),n.description=(null==(s=t.accessibilityData)?void 0:s.alt)||"",qd(n,Uc,t.uuid),n}};Wc=new WeakMap,Bc=new WeakMap,Oc=new WeakMap,Uc=new WeakMap,jd(sw,"_type","signature"),jd(sw,"_editorType",fu.SIGNATURE),jd(sw,"_defaultDrawingOptions",null);let nw=sw;class rw extends dg{constructor(t){super({...t,name:"stampEditor"}),Gd(this,Jc),Gd(this,Hc,null),Gd(this,$c,null),Gd(this,jc,null),Gd(this,zc,null),Gd(this,Vc,null),Gd(this,Gc,""),Gd(this,qc,null),Gd(this,Xc,!1),Gd(this,Yc,null),Gd(this,Kc,!1),Gd(this,Qc,!1),qd(this,zc,t.bitmapUrl),qd(this,Vc,t.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){dg.initialize(t,e)}static isHandlingMimeForPasting(t){return Fp.includes(t)}static paste(t,e){e.pasteEditor({mode:fu.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var t;return{type:"stamp",hasAltText:!!(null==(t=this.altTextData)?void 0:t.altText)}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!(await i.isEnabledFor("altText")))throw new Error("ML isn't enabled for alt text.");const{data:s,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:s,width:n,height:r,channels:s.length/(n*r)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");const o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}remove(){var t;Vd(this,$c)&&(qd(this,Hc,null),this._uiManager.imageManager.deleteId(Vd(this,$c)),null==(t=Vd(this,qc))||t.remove(),qd(this,qc,null),Vd(this,Yc)&&(clearTimeout(Vd(this,Yc)),qd(this,Yc,null))),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(Vd(this,$c)&&null===Vd(this,qc)&&Xd(this,Jc,ed).call(this),this.isAttachedToDOM||this.parent.add(this))):Vd(this,$c)&&Xd(this,Jc,ed).call(this)}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(Vd(this,jc)||Vd(this,Hc)||Vd(this,zc)||Vd(this,Vc)||Vd(this,$c)||Vd(this,Xc))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),Vd(this,Xc)||(Vd(this,Hc)?Xd(this,Jc,id).call(this):Xd(this,Jc,ed).call(this)),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:i,bitmap:s}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(qd(this,$c,i),s&&qd(this,Hc,s),qd(this,Xc,!1),Xd(this,Jc,id).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==Vd(this,Yc)&&clearTimeout(Vd(this,Yc));qd(this,Yc,setTimeout(()=>{qd(this,Yc,null),Xd(this,Jc,nd).call(this)},200))}copyCanvas(t,e,i=!1){t||(t=224);const{width:s,height:n}=Vd(this,Hc),r=new Lp;let a=Vd(this,Hc),o=s,l=n,h=null;if(e){if(s>e||n>e){const t=Math.min(e/s,e/n);o=Math.floor(s*t),l=Math.floor(n*t)}h=document.createElement("canvas");const t=h.width=Math.ceil(o*r.sx),i=h.height=Math.ceil(l*r.sy);Vd(this,Kc)||(a=Xd(this,Jc,sd).call(this,t,i));const c=h.getContext("2d");c.filter=this._uiManager.hcmFilter;let d="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":Np.isDarkMode&&(d="#8f8f9d",u="#42414d");const p=15,g=p*r.sx,f=p*r.sy,m=new OffscreenCanvas(2*g,2*f),v=m.getContext("2d");v.fillStyle=d,v.fillRect(0,0,2*g,2*f),v.fillStyle=u,v.fillRect(0,0,g,f),v.fillRect(g,f,g,f),c.fillStyle=c.createPattern(m,"repeat"),c.fillRect(0,0,t,i),c.drawImage(a,0,0,a.width,a.height,0,0,t,i)}let c=null;if(i){let e,i;if(r.symmetric&&a.width<t&&a.height<t)e=a.width,i=a.height;else if(a=Vd(this,Hc),s>t||n>t){const r=Math.min(t/s,t/n);e=Math.floor(s*r),i=Math.floor(n*r),Vd(this,Kc)||(a=Xd(this,Jc,sd).call(this,e,i))}const o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(a,0,0,a.width,a.height,0,0,e,i),c={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:c}}static async deserialize(t,e,i){var s;let n=null,r=!1;if(t instanceof Tv){const{data:{rect:a,rotation:o,id:l,structParent:h,popupRef:c,richText:d,contentsObj:u,creationDate:p,modificationDate:g},container:f,parent:{page:{pageNumber:m}},canvas:v}=t;let w,b;v?(delete t.canvas,({id:w,bitmap:b}=i.imageManager.getFromCanvas(f.id,v)),v.remove()):(r=!0,t._hasNoCanvas=!0);const y=(null==(s=await e._structTree.getAriaAttributes(`${hp}${l}`))?void 0:s.get("aria-label"))||"";n=t={annotationType:fu.STAMP,bitmapId:w,bitmap:b,pageIndex:m-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,accessibilityData:{decorative:!1,altText:y},isSvg:!1,structParent:h,popupRef:c,richText:d,comment:(null==u?void 0:u.str)||null,creationDate:p,modificationDate:g}}const a=await super.deserialize(t,e,i),{rect:o,bitmap:l,bitmapUrl:h,bitmapId:c,isSvg:d,accessibilityData:u}=t;r?(i.addMissingCanvas(t.id,a),qd(a,Xc,!0)):c&&i.imageManager.isValidId(c)?(qd(a,$c,c),l&&qd(a,Hc,l)):qd(a,zc,h),qd(a,Kc,d);const[p,g]=a.pageDimensions;return a.width=(o[2]-o[0])/p,a.height=(o[3]-o[1])/g,u&&(a.altTextData=u),a._initialData=n,t.comment&&a.setCommentData(t),qd(a,Qc,!!n),a}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i=Object.assign(super.serialize(t),{bitmapId:Vd(this,$c),isSvg:Vd(this,Kc)});if(this.addComment(i),t)return i.bitmapUrl=Xd(this,Jc,rd).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(i.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const t=Xd(this,Jc,ad).call(this,i);return t.isSame?null:(t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(null===e)return i;e.stamps||(e.stamps=new Map);const r=Vd(this,Kc)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(Vd(this,$c))){if(Vd(this,Kc)){const t=e.stamps.get(Vd(this,$c));r>t.area&&(t.area=r,t.serialized.bitmap.close(),t.serialized.bitmap=Xd(this,Jc,rd).call(this,!1))}}else e.stamps.set(Vd(this,$c),{area:r,serialized:i}),i.bitmap=Xd(this,Jc,rd).call(this,!1);return i}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}Hc=new WeakMap,$c=new WeakMap,jc=new WeakMap,zc=new WeakMap,Vc=new WeakMap,Gc=new WeakMap,qc=new WeakMap,Xc=new WeakMap,Yc=new WeakMap,Kc=new WeakMap,Qc=new WeakMap,Jc=new WeakSet,Zc=function(t,e=!1){t?(qd(this,Hc,t.bitmap),e||(qd(this,$c,t.id),qd(this,Kc,t.isSvg)),t.file&&qd(this,Gc,t.file.name),Xd(this,Jc,id).call(this)):this.remove()},td=function(){if(qd(this,jc,null),this._uiManager.enableWaiting(!1),Vd(this,qc))if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&Vd(this,Hc))this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&Vd(this,Hc)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},ed=function(){if(Vd(this,$c))return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(Vd(this,$c)).then(t=>Xd(this,Jc,Zc).call(this,t,!0)).finally(()=>Xd(this,Jc,td).call(this));if(Vd(this,zc)){const t=Vd(this,zc);return qd(this,zc,null),this._uiManager.enableWaiting(!0),void qd(this,jc,this._uiManager.imageManager.getFromUrl(t).then(t=>Xd(this,Jc,Zc).call(this,t)).finally(()=>Xd(this,Jc,td).call(this)))}if(Vd(this,Vc)){const t=Vd(this,Vc);return qd(this,Vc,null),this._uiManager.enableWaiting(!0),void qd(this,jc,this._uiManager.imageManager.getFromFile(t).then(t=>Xd(this,Jc,Zc).call(this,t)).finally(()=>Xd(this,Jc,td).call(this)))}const t=document.createElement("input");t.type="file",t.accept=Fp.join(",");const e=this._uiManager._signal;qd(this,jc,new Promise(i=>{t.addEventListener("change",async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),Xd(this,Jc,Zc).call(this,e)}else this.remove();i()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:e})}).finally(()=>Xd(this,Jc,td).call(this))),t.click()},id=function(){var t;const{div:e}=this;let{width:i,height:s}=Vd(this,Hc);const[n,r]=this.pageDimensions,a=.75;if(this.width)i=this.width*n,s=this.height*r;else if(i>a*n||s>a*r){const t=Math.min(a*n/i,a*r/s);i*=t,s*=t}this._uiManager.enableWaiting(!1);const o=qd(this,qc,document.createElement("canvas"));o.setAttribute("role","img"),this.addContainer(o),this.width=i/n,this.height=s/r,this.setDims(),(null==(t=this._initialOptions)?void 0:t.isCentered)?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1),Xd(this,Jc,nd).call(this),Vd(this,Qc)||(this.parent.addUndoableEditor(this),qd(this,Qc,!0)),this._reportTelemetry({action:"inserted_image"}),Vd(this,Gc)&&this.div.setAttribute("aria-description",Vd(this,Gc)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},sd=function(t,e){const{width:i,height:s}=Vd(this,Hc);let n=i,r=s,a=Vd(this,Hc);for(;n>2*t||r>2*e;){const i=n,s=r;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));const o=new OffscreenCanvas(n,r);o.getContext("2d").drawImage(a,0,0,i,s,0,0,n,r),a=o.transferToImageBitmap()}return a},nd=function(){const[t,e]=this.parentDimensions,{width:i,height:s}=this,n=new Lp,r=Math.ceil(i*t*n.sx),a=Math.ceil(s*e*n.sy),o=Vd(this,qc);if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;const l=Vd(this,Kc)?Vd(this,Hc):Xd(this,Jc,sd).call(this,r,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,r,a)},rd=function(t){if(t){if(Vd(this,Kc)){const t=this._uiManager.imageManager.getSvgUrl(Vd(this,$c));if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=Vd(this,Hc));return t.getContext("2d").drawImage(Vd(this,Hc),0,0),t.toDataURL()}if(Vd(this,Kc)){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*mp.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*mp.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(Vd(this,Hc),0,0,Vd(this,Hc).width,Vd(this,Hc).height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(Vd(this,Hc))},ad=function(t){var e;const{pageIndex:i,accessibilityData:{altText:s}}=this._initialData,n=t.pageIndex===i,r=((null==(e=t.accessibilityData)?void 0:e.alt)||"")===s;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&n&&r,isSameAltText:r}},jd(rw,"_type","stamp"),jd(rw,"_editorType",fu.STAMP);const aw=class t{constructor({uiManager:e,pageIndex:i,div:s,structTreeLayer:n,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:c}){Gd(this,kd),Gd(this,od),Gd(this,ld,!1),Gd(this,hd,null),Gd(this,cd,null),Gd(this,dd,null),Gd(this,ud,new Map),Gd(this,pd,!1),Gd(this,gd,!1),Gd(this,fd,!1),Gd(this,md,null),Gd(this,vd,null),Gd(this,wd,null),Gd(this,bd,null),Gd(this,yd,null),Gd(this,Ad,-1),Gd(this,_d);const d=[...Vd(t,xd).values()];if(!t._initialized){t._initialized=!0;for(const t of d)t.initialize(c,e)}e.registerEditorTypes(d),qd(this,_d,e),this.pageIndex=i,this.div=s,qd(this,od,r),qd(this,hd,a),this.viewport=h,qd(this,wd,l),this.drawLayer=o,this._structTree=n,Vd(this,_d).addLayer(this)}get isEmpty(){return 0===Vd(this,ud).size}get isInvisible(){return this.isEmpty&&Vd(this,_d).getMode()===fu.NONE}updateToolbar(t){Vd(this,_d).updateToolbar(t)}updateMode(e=Vd(this,_d).getMode()){switch(Xd(this,kd,Pd).call(this),e){case fu.NONE:return this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case fu.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case fu.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:i}=this.div;if(i.toggle("nonEditing",!1),e===fu.POPUP)i.toggle("commentEditing",!0);else{i.toggle("commentEditing",!1);for(const s of Vd(t,xd).values())i.toggle(`${s._type}Editing`,e===s._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===(null==(e=Vd(this,wd))?void 0:e.div)}setEditingState(t){Vd(this,_d).setEditingState(t)}addCommands(t){Vd(this,_d).addCommands(t)}cleanUndoStack(t){Vd(this,_d).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;null==(e=Vd(this,hd))||e.div.classList.toggle("disabled",!t)}async enable(){var t;qd(this,fd,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),null==(t=Vd(this,yd))||t.abort(),qd(this,yd,null);const e=new Set;for(const s of Vd(this,kd,Sd))s.enableEditing(),s.show(!0),s.annotationElementId&&(Vd(this,_d).removeChangedExistingAnnotation(s),e.add(s.annotationElementId));const i=Vd(this,hd);if(i)for(const s of i.getEditableAnnotations()){if(s.hide(),Vd(this,_d).isDeletedAnnotationElement(s.data.id))continue;if(e.has(s.data.id))continue;const t=await this.deserialize(s);t&&(this.addOrRebuild(t),t.enableEditing())}qd(this,fd,!1),Vd(this,_d)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var e;if(qd(this,gd,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),Vd(this,wd)&&!Vd(this,yd)){qd(this,yd,new AbortController);const t=Vd(this,_d).combinedSignal(Vd(this,yd));Vd(this,wd).div.addEventListener("pointerdown",t=>{const{clientX:e,clientY:i,timeStamp:s}=t;if(s-Vd(this,Ad)>500)return void qd(this,Ad,s);qd(this,Ad,-1);const{classList:n}=this.div;n.toggle("getElements",!0);const r=document.elementsFromPoint(e,i);if(n.toggle("getElements",!1),!this.div.contains(r[0]))return;let a;const o=new RegExp(`^${gu}[0-9]+$`);for(const h of r)if(o.test(h.id)){a=h.id;break}if(!a)return;const l=Vd(this,ud).get(a);null===(null==l?void 0:l.annotationElementId)&&(t.stopPropagation(),t.preventDefault(),l.dblclick(t))},{signal:t,capture:!0})}const i=Vd(this,hd);if(i){const t=new Map,s=new Map;for(const r of Vd(this,kd,Sd))r.disableEditing(),r.annotationElementId?null===r.serialize()?(s.set(r.annotationElementId,r),null==(e=this.getEditableAnnotation(r.annotationElementId))||e.show(),r.remove()):t.set(r.annotationElementId,r):r.updateFakeAnnotationElement(i);const n=i.getEditableAnnotations();for(const e of n){const{id:i}=e.data;if(Vd(this,_d).isDeletedAnnotationElement(i)){e.updateEdited({deleted:!0});continue}let n=s.get(i);n?(n.resetAnnotationElement(e),n.show(!1),e.show()):(n=t.get(i),n&&(Vd(this,_d).addChangedExistingAnnotation(n),n.renderAnnotationElement(e)&&n.show(!1)),e.show())}}Xd(this,kd,Pd).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const n of Vd(t,xd).values())s.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),qd(this,gd,!1)}getEditableAnnotation(t){var e;return(null==(e=Vd(this,hd))?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){Vd(this,_d).getActive()!==t&&Vd(this,_d).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(null==(t=Vd(this,wd))?void 0:t.div)&&!Vd(this,bd)){qd(this,bd,new AbortController);const t=Vd(this,_d).combinedSignal(Vd(this,bd));Vd(this,wd).div.addEventListener("pointerdown",Xd(this,kd,Md).bind(this),{signal:t}),Vd(this,wd).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(null==(t=Vd(this,wd))?void 0:t.div)&&Vd(this,bd)&&(Vd(this,bd).abort(),qd(this,bd,null),Vd(this,wd).div.classList.remove("highlighting"))}enableClick(){if(Vd(this,cd))return;qd(this,cd,new AbortController);const t=Vd(this,_d).combinedSignal(Vd(this,cd));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;null==(t=Vd(this,cd))||t.abort(),qd(this,cd,null)}attach(t){Vd(this,ud).set(t.id,t);const{annotationElementId:e}=t;e&&Vd(this,_d).isDeletedAnnotationElement(e)&&Vd(this,_d).removeDeletedAnnotationElement(t)}detach(t){var e;Vd(this,ud).delete(t.id),null==(e=Vd(this,od))||e.removePointerInTextLayer(t.contentDiv),!Vd(this,gd)&&t.annotationElementId&&Vd(this,_d).addDeletedAnnotationElement(t)}remove(t){this.detach(t),Vd(this,_d).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(Vd(this,_d).addDeletedAnnotationElement(t.annotationElementId),dg.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),null==(e=t.parent)||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),Vd(this,_d).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!Vd(this,fd)),Vd(this,_d).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var e;if(!t.isAttachedToDOM)return;const{activeElement:i}=document;t.div.contains(i)&&!Vd(this,dd)&&(t._focusEventsAllowed=!1,qd(this,dd,setTimeout(()=>{qd(this,dd,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:Vd(this,_d)._signal}),i.focus())},0))),t._structTreeParentId=null==(e=Vd(this,od))?void 0:e.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getEditorByUID(t){for(const e of Vd(this,ud).values())if(e.uid===t)return e;return null}getNextId(){return Vd(this,_d).getId()}combinedSignal(t){return Vd(this,_d).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return null==(t=Vd(this,kd,Ed))?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await Vd(this,_d).updateMode(t.mode);const{offsetX:i,offsetY:s}=Xd(this,kd,Td).call(this),n=this.getNextId(),r=Xd(this,kd,Cd).call(this,{parent:this,id:n,x:i,y:s,uiManager:Vd(this,_d),isCentered:!0,...e});r&&this.add(r)}async deserialize(e){var i;return await(null==(i=Vd(t,xd).get(e.annotationType??e.annotationEditorType))?void 0:i.deserialize(e,this,Vd(this,_d)))||null}createAndAddNewEditor(t,e,i={}){const s=this.getNextId(),n=Xd(this,kd,Cd).call(this,{parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:Vd(this,_d),isCentered:e,...i});return n&&this.add(n),n}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(Xd(this,kd,Td).call(this),!0,t)}setSelected(t){Vd(this,_d).setSelected(t)}toggleSelected(t){Vd(this,_d).toggleSelected(t)}unselect(t){Vd(this,_d).unselect(t)}pointerup(t){var e;const{isMac:i}=ip.platform;if(0!==t.button||t.ctrlKey&&i)return;if(t.target!==this.div)return;if(!Vd(this,pd))return;if(qd(this,pd,!1),(null==(e=Vd(this,kd,Ed))?void 0:e.isDrawer)&&Vd(this,kd,Ed).supportMultipleDrawings)return;if(!Vd(this,ld))return void qd(this,ld,!0);const s=Vd(this,_d).getMode();s!==fu.STAMP&&s!==fu.SIGNATURE?this.createAndAddNewEditor(t,!1):Vd(this,_d).unselectAll()}pointerdown(t){var e;if(Vd(this,_d).getMode()===fu.HIGHLIGHT&&this.enableTextSelection(),Vd(this,pd))return void qd(this,pd,!1);const{isMac:i}=ip.platform;if(0!==t.button||t.ctrlKey&&i)return;if(t.target!==this.div)return;if(qd(this,pd,!0),null==(e=Vd(this,kd,Ed))?void 0:e.isDrawer)return void this.startDrawingSession(t);const s=Vd(this,_d).getActive();qd(this,ld,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),Vd(this,md))return void Vd(this,kd,Ed).startDrawing(this,Vd(this,_d),!1,t);Vd(this,_d).setCurrentDrawingSession(this),qd(this,md,new AbortController);const e=Vd(this,_d).combinedSignal(Vd(this,md));this.div.addEventListener("blur",({relatedTarget:t})=>{t&&!this.div.contains(t)&&(qd(this,vd,null),this.commitOrRemove())},{signal:e}),Vd(this,kd,Ed).startDrawing(this,Vd(this,_d),!1,t)}pause(t){if(t){const{activeElement:t}=document;return void(this.div.contains(t)&&qd(this,vd,t))}Vd(this,vd)&&setTimeout(()=>{var t;null==(t=Vd(this,vd))||t.focus(),qd(this,vd,null)},0)}endDrawingSession(t=!1){return Vd(this,md)?(Vd(this,_d).setCurrentDrawingSession(null),Vd(this,md).abort(),qd(this,md,null),qd(this,vd,null),Vd(this,kd,Ed).endDrawing(t)):null}findNewParent(t,e,i){const s=Vd(this,_d).findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!Vd(this,md)&&(this.endDrawingSession(),!0)}onScaleChanging(){Vd(this,md)&&Vd(this,kd,Ed).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),(null==(t=Vd(this,_d).getActive())?void 0:t.parent)===this&&(Vd(this,_d).commitOrRemove(),Vd(this,_d).setActiveEditor(null)),Vd(this,dd)&&(clearTimeout(Vd(this,dd)),qd(this,dd,null));for(const i of Vd(this,ud).values())null==(e=Vd(this,od))||e.removePointerInTextLayer(i.contentDiv),i.setParent(null),i.isAttachedToDOM=!1,i.div.remove();this.div=null,Vd(this,ud).clear(),Vd(this,_d).removeLayer(this)}render({viewport:t}){this.viewport=t,Ip(this.div,t);for(const e of Vd(this,_d).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){Vd(this,_d).commitOrRemove(),Xd(this,kd,Pd).call(this);const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,Ip(this.div,{rotation:i}),e!==i)for(const s of Vd(this,ud).values())s.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return Vd(this,_d).viewParameters.realScale}};od=new WeakMap,ld=new WeakMap,hd=new WeakMap,cd=new WeakMap,dd=new WeakMap,ud=new WeakMap,pd=new WeakMap,gd=new WeakMap,fd=new WeakMap,md=new WeakMap,vd=new WeakMap,wd=new WeakMap,bd=new WeakMap,yd=new WeakMap,Ad=new WeakMap,_d=new WeakMap,xd=new WeakMap,kd=new WeakSet,Sd=function(){return 0!==Vd(this,ud).size?Vd(this,ud).values():Vd(this,_d).getEditors(this.pageIndex)},Md=function(t){Vd(this,_d).unselectAll();const{target:e}=t;if(e===Vd(this,wd).div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&Vd(this,wd).div.contains(e)){const{isMac:e}=ip.platform;if(0!==t.button||t.ctrlKey&&e)return;Vd(this,_d).showAllEditors("highlight",!0,!0),Vd(this,wd).div.classList.add("free"),this.toggleDrawing(),zv.startHighlighting(this,"ltr"===Vd(this,_d).direction,{target:Vd(this,wd).div,x:t.x,y:t.y}),Vd(this,wd).div.addEventListener("pointerup",()=>{Vd(this,wd).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:Vd(this,_d)._signal}),t.preventDefault()}},Ed=function(){return Vd(aw,xd).get(Vd(this,_d).getMode())},Cd=function(t){const e=Vd(this,kd,Ed);return e?new e.prototype.constructor(t):null},Td=function(){const{x:t,y:e,width:i,height:s}=this.boundingClientRect,n=Math.max(0,t),r=Math.max(0,e),a=(n+Math.min(window.innerWidth,t+i))/2-t,o=(r+Math.min(window.innerHeight,e+s))/2-e,[l,h]=this.viewport.rotation%180==0?[a,o]:[o,a];return{offsetX:l,offsetY:h}},Pd=function(){for(const t of Vd(this,ud).values())t.isEmpty()&&t.remove()},jd(aw,"_initialized",!1),Gd(aw,xd,new Map([Lv,Jv,rw,zv,nw].map(t=>[t._editorType,t])));let ow=aw;const lw=class t{constructor({pageIndex:t}){Gd(this,Wd),Gd(this,Dd,null),Gd(this,Rd,new Map),Gd(this,Id,new Map),this.pageIndex=t}setParent(t){if(Vd(this,Dd)){if(Vd(this,Dd)!==t){if(Vd(this,Rd).size>0)for(const e of Vd(this,Rd).values())e.remove(),t.append(e);qd(this,Dd,t)}}else qd(this,Dd,t)}static get _svgFactory(){return Gu(this,"_svgFactory",new tv)}draw(e,i=!1,s=!1){const n=Yd(t,Ld)._++,r=Xd(this,Wd,Bd).call(this),a=t._svgFactory.createElement("defs");r.append(a);const o=t._svgFactory.createElement("path");a.append(o);const l=`path_p${this.pageIndex}_${n}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),i&&Vd(this,Id).set(n,o);const h=s?Xd(this,Wd,Od).call(this,a,l):null,c=t._svgFactory.createElement("use");return r.append(c),c.setAttribute("href",`#${l}`),this.updateProperties(r,e),Vd(this,Rd).set(n,r),{id:n,clipPathId:`url(#${h})`}}drawOutline(e,i){const s=Yd(t,Ld)._++,n=Xd(this,Wd,Bd).call(this),r=t._svgFactory.createElement("defs");n.append(r);const a=t._svgFactory.createElement("path");r.append(a);const o=`path_p${this.pageIndex}_${s}`;let l;if(a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),i){const e=t._svgFactory.createElement("mask");r.append(e),l=`mask_p${this.pageIndex}_${s}`,e.setAttribute("id",l),e.setAttribute("maskUnits","objectBoundingBox");const i=t._svgFactory.createElement("rect");e.append(i),i.setAttribute("width","1"),i.setAttribute("height","1"),i.setAttribute("fill","white");const n=t._svgFactory.createElement("use");e.append(n),n.setAttribute("href",`#${o}`),n.setAttribute("stroke","none"),n.setAttribute("fill","black"),n.setAttribute("fill-rule","nonzero"),n.classList.add("mask")}const h=t._svgFactory.createElement("use");n.append(h),h.setAttribute("href",`#${o}`),l&&h.setAttribute("mask",`url(#${l})`);const c=h.cloneNode();return n.append(c),h.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(n,e),Vd(this,Rd).set(s,n),s}finalizeDraw(t,e){Vd(this,Id).delete(t),this.updateProperties(t,e)}updateProperties(e,i){var s;if(!i)return;const{root:n,bbox:r,rootClass:a,path:o}=i,l="number"==typeof e?Vd(this,Rd).get(e):e;if(l){if(n&&Xd(this,Wd,Ud).call(this,l,n),r&&Xd(s=t,Fd,Nd).call(s,l,r),a){const{classList:t}=l;for(const[e,i]of Object.entries(a))t.toggle(e,i)}if(o){const t=l.firstChild.firstChild;Xd(this,Wd,Ud).call(this,t,o)}}}updateParent(t,e){if(e===this)return;const i=Vd(this,Rd).get(t);i&&(Vd(e,Dd).append(i),Vd(this,Rd).delete(t),Vd(e,Rd).set(t,i))}remove(t){Vd(this,Id).delete(t),null!==Vd(this,Dd)&&(Vd(this,Rd).get(t).remove(),Vd(this,Rd).delete(t))}destroy(){qd(this,Dd,null);for(const t of Vd(this,Rd).values())t.remove();Vd(this,Rd).clear(),Vd(this,Id).clear()}};Dd=new WeakMap,Rd=new WeakMap,Id=new WeakMap,Ld=new WeakMap,Fd=new WeakSet,Nd=function(t,[e,i,s,n]){const{style:r}=t;r.top=100*i+"%",r.left=100*e+"%",r.width=100*s+"%",r.height=100*n+"%"},Wd=new WeakSet,Bd=function(){const t=lw._svgFactory.create(1,1,!0);return Vd(this,Dd).append(t),t.setAttribute("aria-hidden",!0),t},Od=function(t,e){const i=lw._svgFactory.createElement("clipPath");t.append(i);const s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");const n=lw._svgFactory.createElement("use");return i.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),s},Ud=function(t,e){for(const[i,s]of Object.entries(e))null===s?t.removeAttribute(i):t.setAttribute(i,s)},Gd(lw,Fd),Gd(lw,Ld,0);let hw=lw;globalThis._pdfjsTestingUtils={HighlightOutliner:Ov},globalThis.pdfjsLib={AbortException:Zu,AnnotationEditorLayer:ow,AnnotationEditorParamsType:mu,AnnotationEditorType:fu,AnnotationEditorUIManager:ng,AnnotationLayer:Dv,AnnotationMode:pu,AnnotationType:Su,applyOpacity:Bp,build:Vm,ColorPicker:qm,createValidAbsoluteUrl:zu,CSSConstants:Wp,DOMSVGFactory:tv,DrawLayer:hw,FeatureTest:ip,fetchData:vp,findContrastColor:zp,getDocument:Rm,getFilenameFromUrl:_p,getPdfFilenameFromUrl:xp,getRGB:Pp,getUuid:lp,getXfaPageViewport:Tp,GlobalWorkerOptions:im,ImageKind:ku,InvalidPDFException:Ku,isDataScheme:yp,isPdfFile:Ap,isValidExplicitDest:kg,MathClamp:cp,noContextMenu:Mp,normalizeUnicode:op,OPS:Ru,OutputScale:Lp,PasswordResponses:Wu,PDFDataRangeTransport:Fm,PDFDateString:Cp,PDFWorker:Om,PermissionFlag:vu,PixelsPerInch:mp,RenderingCancelledException:bp,renderRichText:Vp,ResponseException:Qu,setLayerDimensions:Ip,shadow:Gu,SignatureExtractor:tw,stopEvent:Ep,SupportedImageMimeTypes:Fp,TextLayer:Dm,TouchManager:hg,updateUrlHash:Vu,Util:np,VerbosityLevel:Du,version:zm,XfaLayer:pp};const cw=Object.freeze(Object.defineProperty({__proto__:null,AbortException:Zu,AnnotationEditorLayer:ow,AnnotationEditorParamsType:mu,AnnotationEditorType:fu,AnnotationEditorUIManager:ng,AnnotationLayer:Dv,AnnotationMode:pu,AnnotationType:Su,CSSConstants:Wp,ColorPicker:qm,DOMSVGFactory:tv,DrawLayer:hw,FeatureTest:ip,GlobalWorkerOptions:im,ImageKind:ku,InvalidPDFException:Ku,MathClamp:cp,OPS:Ru,OutputScale:Lp,PDFDataRangeTransport:Fm,PDFDateString:Cp,PDFWorker:Om,PasswordResponses:Wu,PermissionFlag:vu,PixelsPerInch:mp,RenderingCancelledException:bp,ResponseException:Qu,SignatureExtractor:tw,SupportedImageMimeTypes:Fp,TextLayer:Dm,TouchManager:hg,Util:np,VerbosityLevel:Du,XfaLayer:pp,applyOpacity:Bp,build:Vm,createValidAbsoluteUrl:zu,fetchData:vp,findContrastColor:zp,getDocument:Rm,getFilenameFromUrl:_p,getPdfFilenameFromUrl:xp,getRGB:Pp,getUuid:lp,getXfaPageViewport:Tp,isDataScheme:yp,isPdfFile:Ap,isValidExplicitDest:kg,noContextMenu:Mp,normalizeUnicode:op,renderRichText:Vp,setLayerDimensions:Ip,shadow:Gu,stopEvent:Ep,updateUrlHash:Vu,version:zm},Symbol.toStringTag,{value:"Module"}));var dw=Object.prototype.hasOwnProperty;function uw(t,e,i){for(i of t.keys())if(pw(i,e))return i}function pw(t,e){var i,s,n;if(t===e)return!0;if(t&&e&&(i=t.constructor)===e.constructor){if(i===Date)return t.getTime()===e.getTime();if(i===RegExp)return t.toString()===e.toString();if(i===Array){if((s=t.length)===e.length)for(;s--&&pw(t[s],e[s]););return-1===s}if(i===Set){if(t.size!==e.size)return!1;for(s of t){if((n=s)&&"object"==typeof n&&!(n=uw(e,n)))return!1;if(!e.has(n))return!1}return!0}if(i===Map){if(t.size!==e.size)return!1;for(s of t){if((n=s[0])&&"object"==typeof n&&!(n=uw(e,n)))return!1;if(!pw(s[1],e.get(n)))return!1}return!0}if(i===ArrayBuffer)t=new Uint8Array(t),e=new Uint8Array(e);else if(i===DataView){if((s=t.byteLength)===e.byteLength)for(;s--&&t.getInt8(s)===e.getInt8(s););return-1===s}if(ArrayBuffer.isView(t)){if((s=t.byteLength)===e.byteLength)for(;s--&&t[s]===e[s];);return-1===s}if(!i||"object"==typeof t){for(i in s=0,t){if(dw.call(t,i)&&++s&&!dw.call(e,i))return!1;if(!(i in e)||!pw(t[i],e[i]))return!1}return Object.keys(e).length===s}}return t!=t&&e!=e}function gw(t){let e=!1;return{promise:new Promise((i,s)=>{t.then(t=>!e&&i(t)).catch(t=>!e&&s(t))}),cancel(){e=!0}}}const fw=["onCopy","onCut","onPaste","onCompositionEnd","onCompositionStart","onCompositionUpdate","onFocus","onBlur","onInput","onInvalid","onReset","onSubmit","onLoad","onError","onKeyDown","onKeyPress","onKeyUp","onAbort","onCanPlay","onCanPlayThrough","onDurationChange","onEmptied","onEncrypted","onEnded","onError","onLoadedData","onLoadedMetadata","onLoadStart","onPause","onPlay","onPlaying","onProgress","onRateChange","onSeeked","onSeeking","onStalled","onSuspend","onTimeUpdate","onVolumeChange","onWaiting","onClick","onContextMenu","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop","onSelect","onTouchCancel","onTouchEnd","onTouchMove","onTouchStart","onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onGotPointerCapture","onLostPointerCapture","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut","onScroll","onWheel","onAnimationStart","onAnimationEnd","onAnimationIteration","onTransitionEnd","onChange","onToggle"];function mw(t,e){const i={};for(const s of fw){const n=t[s];n&&(i[s]=e?t=>n(t,e(s)):n)}return i}function vw(t,e){if(!t)throw new Error("Invariant failed")}const ww=Kd(function(){}),bw=Qd.createContext(null);class yw{constructor(){this.externalLinkEnabled=!0,this.externalLinkRel=void 0,this.externalLinkTarget=void 0,this.isInPresentationMode=!1,this.pdfDocument=void 0,this.pdfViewer=void 0}setDocument(t){this.pdfDocument=t}setViewer(t){this.pdfViewer=t}setExternalLinkRel(t){this.externalLinkRel=t}setExternalLinkTarget(t){this.externalLinkTarget=t}setHash(){}setHistory(){}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return vw(this.pdfViewer),this.pdfViewer.currentPageNumber||0}set page(t){vw(this.pdfViewer),this.pdfViewer.currentPageNumber=t}get rotation(){return 0}set rotation(t){}addLinkAttributes(t,e,i){t.href=e,t.rel=this.externalLinkRel||"noopener noreferrer nofollow",t.target=i?"_blank":this.externalLinkTarget||""}goToDestination(t){return new Promise(e=>{vw(this.pdfDocument),vw(t),"string"==typeof t?this.pdfDocument.getDestination(t).then(e):Array.isArray(t)?e(t):t.then(e)}).then(t=>{vw(Array.isArray(t));const e=t[0];new Promise(t=>{vw(this.pdfDocument),e instanceof Object?this.pdfDocument.getPageIndex(e).then(e=>{t(e)}).catch(()=>{vw(!1)}):"number"==typeof e?t(e):vw(!1)}).then(e=>{const i=e+1;vw(this.pdfViewer),vw(i>=1&&i<=this.pagesCount),this.pdfViewer.scrollPageIntoView({dest:t,pageIndex:e,pageNumber:i})})})}goToPage(t){const e=t-1;vw(this.pdfViewer),vw(t>=1&&t<=this.pagesCount),this.pdfViewer.scrollPageIntoView({pageIndex:e,pageNumber:t})}goToXY(){}cachePageRef(){}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}executeNamedAction(){}executeSetOCGState(){}isPageVisible(){return!0}isPageCached(){return!0}navigateTo(t){this.goToDestination(t)}}function Aw({children:t,type:e}){return Jd.jsx("div",{className:`react-pdf__message react-pdf__message--${e}`,children:t})}const _w=1,xw=2;function kw(t,e){switch(e.type){case"RESOLVE":return{value:e.value,error:void 0};case"REJECT":return{value:!1,error:e.error};case"RESET":return{value:void 0,error:void 0};default:return t}}function Sw(){return Qd.useReducer(kw,{value:void 0,error:void 0})}const Mw="undefined"!=typeof window,Ew=Mw&&"file:"===window.location.protocol;function Cw(t){return function(t){return void 0!==t}(t)&&null!==t}function Tw(t){return function(t){return"string"==typeof t}(t)&&/^data:/.test(t)}function Pw(t){vw(Tw(t));const[e="",i=""]=t.split(",");return-1!==e.split(";").indexOf("base64")?atob(i):unescape(i)}function Dw(){return Mw&&window.devicePixelRatio||1}const Rw="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function Iw(){ww(!Ew,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${Rw}`)}function Lw(t){(null==t?void 0:t.cancel)&&t.cancel()}function Fw(t,e){return Object.defineProperty(t,"width",{get(){return this.getViewport({scale:e}).width},configurable:!0}),Object.defineProperty(t,"height",{get(){return this.getViewport({scale:e}).height},configurable:!0}),Object.defineProperty(t,"originalWidth",{get(){return this.getViewport({scale:1}).width},configurable:!0}),Object.defineProperty(t,"originalHeight",{get(){return this.getViewport({scale:1}).height},configurable:!0}),t}function Nw(t){return"AbortException"===t.name||"RenderingCancelledException"===t.name}const{PDFDataRangeTransport:Ww}=cw,Bw=(t,e)=>{switch(e){case _w:t(prompt("Enter the password to open this PDF file."));break;case xw:t(prompt("Invalid password. Please try again."));break}};function Ow(t){return"object"==typeof t&&null!==t&&("data"in t||"range"in t||"url"in t)}const Uw=Qd.forwardRef(function({children:t,className:e,error:i="Failed to load PDF file.",externalLinkRel:s,externalLinkTarget:n,file:r,inputRef:a,imageResourcesPath:o,loading:l="Loading PDF…",noData:h="No PDF file specified.",onItemClick:c,onLoadError:d,onLoadProgress:u,onLoadSuccess:p,onPassword:g=Bw,onSourceError:f,onSourceSuccess:m,options:v,renderMode:w,rotate:b,scale:y,...A},_){const[x,k]=Sw(),{value:S,error:M}=x,[E,C]=Sw(),{value:T,error:P}=E,D=Qd.useRef(new yw),R=Qd.useRef([]),I=Qd.useRef(void 0),L=Qd.useRef(void 0);r&&r!==I.current&&Ow(r)&&(ww(!pw(r,I.current),'File prop passed to <Document /> changed, but it\'s equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "file" prop.'),I.current=r),v&&v!==L.current&&(ww(!pw(v,L.current),'Options prop passed to <Document /> changed, but it\'s equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "options" prop.'),L.current=v);const F=Qd.useRef({scrollPageIntoView:t=>{const{dest:e,pageNumber:i,pageIndex:s=i-1}=t;if(c)return void c({dest:e,pageIndex:s,pageNumber:i});const n=R.current[s];n?n.scrollIntoView():ww(!1,`An internal link leading to page ${i} was clicked, but neither <Document> was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to <Document> and handle navigating by yourself or ensure that all pages are rendered within <Document>.`)}});Qd.useImperativeHandle(_,()=>({linkService:D,pages:R,viewer:F}),[]),Qd.useEffect(function(){k({type:"RESET"})},[r,k]);const N=Qd.useCallback(async()=>{if(!r)return null;if("string"==typeof r){if(Tw(r)){return{data:Pw(r)}}return Iw(),{url:r}}if(r instanceof Ww)return{range:r};if(r instanceof ArrayBuffer)return{data:r};if(Mw&&function(t){return vw(Mw),t instanceof Blob}(r)){const t=await function(t){return new Promise((e,i)=>{const s=new FileReader;s.onload=()=>{if(!s.result)return i(new Error("Error while reading a file."));e(s.result)},s.onerror=t=>{if(!t.target)return i(new Error("Error while reading a file."));const{error:e}=t.target;if(!e)return i(new Error("Error while reading a file."));switch(e.code){case e.NOT_FOUND_ERR:return i(new Error("Error while reading a file: File not found."));case e.SECURITY_ERR:return i(new Error("Error while reading a file: Security error."));case e.ABORT_ERR:return i(new Error("Error while reading a file: Aborted."));default:return i(new Error("Error while reading a file."))}},s.readAsArrayBuffer(t)})}(r);return{data:t}}if(vw("object"==typeof r),vw(Ow(r)),"url"in r&&"string"==typeof r.url){if(Tw(r.url)){const{url:t,...e}=r;return{data:Pw(t),...e}}Iw()}return r},[r]);Qd.useEffect(()=>{const t=gw(N());return t.promise.then(t=>{k({type:"RESOLVE",value:t})}).catch(t=>{k({type:"REJECT",error:t})}),()=>{Lw(t)}},[N,k]),Qd.useEffect(()=>{void 0!==S&&(!1!==S?m&&m():M&&(ww(!1,M.toString()),f&&f(M)))},[S]),Qd.useEffect(function(){C({type:"RESET"})},[C,S]),Qd.useEffect(function(){if(!S)return;const t=Rm(v?{...S,...v}:S);u&&(t.onProgress=u),g&&(t.onPassword=g);const e=t;return e.promise.then(t=>{e.destroyed||C({type:"RESOLVE",value:t})}).catch(t=>{e.destroyed||C({type:"REJECT",error:t})}),()=>{e.destroy()}},[v,C,S]),Qd.useEffect(()=>{void 0!==T&&(!1!==T?T&&(p&&p(T),R.current=new Array(T.numPages),D.current.setDocument(T)):P&&(ww(!1,P.toString()),d&&d(P)))},[T]),Qd.useEffect(function(){D.current.setViewer(F.current),D.current.setExternalLinkRel(s),D.current.setExternalLinkTarget(n)},[s,n]);const W=Qd.useCallback((t,e)=>{R.current[t]=e},[]),B=Qd.useCallback(t=>{delete R.current[t]},[]),O=Qd.useMemo(()=>({imageResourcesPath:o,linkService:D.current,onItemClick:c,pdf:T,registerPage:W,renderMode:w,rotate:b,scale:y,unregisterPage:B}),[o,c,T,W,w,b,y,B]),U=Qd.useMemo(()=>mw(A,()=>T),[A,T]);return Jd.jsx("div",{className:Zd("react-pdf__Document",e),ref:a,...U,children:r?null==T?Jd.jsx(Aw,{type:"loading",children:"function"==typeof l?l():l}):!1===T?Jd.jsx(Aw,{type:"error",children:"function"==typeof i?i():i}):function(){if(e=O,!Boolean(null==e?void 0:e.pdf))throw new Error("pdf is undefined");var e;const i="function"==typeof t?t(O):t;return Jd.jsx(bw.Provider,{value:O,children:i})}():Jd.jsx(Aw,{type:"no-data",children:"function"==typeof h?h():h})})});function Hw(){return Qd.useContext(bw)}function $w(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=t.filter(Boolean);return i.length<=1?i[0]||null:function(t){for(var e=0,s=i;e<s.length;e++){var n=s[e];"function"==typeof n?n(t):n&&(n.current=t)}}}const jw=Qd.createContext(null);function zw(){return Qd.useContext(jw)}function Vw(){const t=Hw(),e=zw();vw(e);const i={...t,...e},{filterAnnotations:s,imageResourcesPath:n,linkService:r,onGetAnnotationsError:a,onGetAnnotationsSuccess:o,onRenderAnnotationLayerError:l,onRenderAnnotationLayerSuccess:h,page:c,pdf:d,renderForms:u,rotate:p,scale:g=1}=i;vw(d),vw(c),vw(r);const[f,m]=Sw(),{value:v,error:w}=f,b=Qd.useRef(null);ww(1===Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"),10),"AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations"),Qd.useEffect(function(){m({type:"RESET"})},[m,c]),Qd.useEffect(function(){if(!c)return;const t=gw(c.getAnnotations()),e=t;return t.promise.then(t=>{m({type:"RESOLVE",value:t})}).catch(t=>{m({type:"REJECT",error:t})}),()=>{Lw(e)}},[m,c]),Qd.useEffect(()=>{void 0!==v&&(!1!==v?v&&o&&o(v):w&&(ww(!1,w.toString()),a&&a(w)))},[v]);const y=Qd.useMemo(()=>c.getViewport({scale:g,rotation:p}),[c,p,g]);return Qd.useEffect(function(){if(!(d&&c&&r&&v))return;const{current:t}=b;if(!t)return;const e=y.clone({dontFlip:!0}),i={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,annotationStorage:d.annotationStorage,commentManager:null,div:t,l10n:null,linkService:r,page:c,structTreeLayer:null,viewport:e},a={annotations:s?s({annotations:v}):v,annotationStorage:d.annotationStorage,div:t,imageResourcesPath:n,linkService:r,page:c,renderForms:u,viewport:e};t.innerHTML="";try{new Dv(i).render(a),h&&h()}catch(o){!function(t){ww(!1,`${t}`),l&&l(t)}(o)}return()=>{}},[v,s,n,r,c,d,u,y]),Jd.jsx("div",{className:Zd("react-pdf__Page__annotations","annotationLayer"),ref:b})}const Gw={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"columnheader",TBody:null,TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},qw=/^H(\d+)$/;function Xw(t){return"children"in t}function Yw(t){return!!Xw(t)&&(1===t.children.length&&0 in t.children&&"id"in t.children[0])}function Kw(t){const e={};if(Xw(t)){const{role:i}=t,s=i.match(qw);if(s)e.role="heading",e["aria-level"]=Number(s[1]);else if(function(t){return t in Gw}(i)){const t=Gw[i];t&&(e.role=t)}}return e}function Qw(t){const e={};if(Xw(t)){if(void 0!==t.alt&&(e["aria-label"]=t.alt),void 0!==t.lang&&(e.lang=t.lang),Yw(t)){const[i]=t.children;if(i){const t=Qw(i);return{...e,...t}}}}else"id"in t&&(e["aria-owns"]=t.id);return e}function Jw({className:t,node:e}){const i=Qd.useMemo(()=>function(t){return t?{...Kw(t),...Qw(t)}:null}(e),[e]),s=Qd.useMemo(()=>Xw(e)?Yw(e)?null:e.children.map((t,e)=>Jd.jsx(Jw,{node:t},e)):null,[e]);return Jd.jsx("span",{className:t,...i,children:s})}function Zw(){const t=zw();vw(t);const{onGetStructTreeError:e,onGetStructTreeSuccess:i}=t,[s,n]=Sw(),{value:r,error:a}=s,{customTextRenderer:o,page:l}=t;return Qd.useEffect(function(){n({type:"RESET"})},[n,l]),Qd.useEffect(function(){if(o)return;if(!l)return;const t=gw(l.getStructTree()),e=t;return t.promise.then(t=>{n({type:"RESOLVE",value:t})}).catch(t=>{n({type:"REJECT",error:t})}),()=>Lw(e)},[o,l,n]),Qd.useEffect(()=>{void 0!==r&&(!1!==r?r&&i&&i(r):a&&(ww(!1,a.toString()),e&&e(a)))},[r]),r?Jd.jsx(Jw,{className:"react-pdf__Page__structTree structTree",node:r}):null}const tb=pu;function eb(t){const e=zw();vw(e);const i={...e,...t},{_className:s,canvasBackground:n,devicePixelRatio:r=Dw(),onRenderError:a,onRenderSuccess:o,page:l,renderForms:h,renderTextLayer:c,pageColors:d,rotate:u,scale:p}=i,{canvasRef:g}=t;vw(l);const f=Qd.useRef(null);function m(t){Nw(t)||(ww(!1,t.toString()),a&&a(t))}const v=Qd.useMemo(()=>l.getViewport({scale:p*r,rotation:u}),[r,l,u,p]),w=Qd.useMemo(()=>l.getViewport({scale:p,rotation:u}),[l,u,p]);Qd.useEffect(function(){if(!l)return;l.cleanup();const{current:t}=f;if(!t)return;t.width=v.width,t.height=v.height,t.style.width=`${Math.floor(w.width)}px`,t.style.height=`${Math.floor(w.height)}px`,t.style.visibility="hidden";const e={annotationMode:h?tb.ENABLE_FORMS:tb.ENABLE,canvas:t,canvasContext:t.getContext("2d",{alpha:!1}),pageColors:d,viewport:v};n&&(e.background=n);const i=l.render(e),s=i;return i.promise.then(()=>{t.style.visibility="",l&&o&&o(Fw(l,p))}).catch(m),()=>Lw(s)},[n,l,d,h,v,w]);const b=Qd.useCallback(()=>{const{current:t}=f;t&&(t.width=0,t.height=0)},[]);return Qd.useEffect(()=>b,[b]),Jd.jsx("canvas",{className:`${s}__canvas`,dir:"ltr",ref:$w(g,f),style:{display:"block",userSelect:"none"},children:c?Jd.jsx(Zw,{}):null})}const ib=new Set(["base","embed","iframe","link","meta","object","script","style","template"]),sb=new Set(["action","formaction","href","poster","src","xlink:href"]);function nb(t){return function(t){return t.nodeType===Node.ELEMENT_NODE}(t)&&t instanceof HTMLElement}function rb(t){var e;return nb(t)&&!function(t){return nb(t)&&ib.has(t.tagName.toLowerCase())}(t)?function(t){const e=document.createElement(t.tagName.toLowerCase());return Array.from(t.attributes).forEach(t=>{const i=t.name.toLowerCase();i.startsWith("on")||"srcdoc"===i||sb.has(i)&&function(t){let e="";for(const i of t){const t=i.charCodeAt(0);t<=32||127===t||(e+=i.toLowerCase())}return e.startsWith("javascript:")||e.startsWith("vbscript:")}(t.value)||e.setAttribute(t.name,t.value)}),Array.from(t.childNodes).forEach(t=>{e.append(rb(t))}),e}(t):document.createTextNode(null!==(e=t.textContent)&&void 0!==e?e:"")}function ab(){const t=zw();vw(t);const{customTextRenderer:e,onGetTextError:i,onGetTextSuccess:s,onRenderTextLayerError:n,onRenderTextLayerSuccess:r,page:a,pageIndex:o,pageNumber:l,rotate:h,scale:c}=t;vw(a);const[d,u]=Sw(),{value:p,error:g}=d,f=Qd.useRef(null);ww(1===Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"),10),"TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer"),Qd.useEffect(function(){u({type:"RESET"})},[a,u]),Qd.useEffect(function(){if(!a)return;const t=gw(a.getTextContent()),e=t;return t.promise.then(t=>{u({type:"RESOLVE",value:t})}).catch(t=>{u({type:"REJECT",error:t})}),()=>Lw(e)},[a,u]),Qd.useEffect(()=>{void 0!==p&&(!1!==p?p&&s&&s(p):g&&(ww(!1,g.toString()),i&&i(g)))},[p]);const m=Qd.useCallback(()=>{r&&r()},[r]),v=Qd.useCallback(t=>{Nw(t)||(ww(!1,t.toString()),n&&n(t))},[n]);const w=Qd.useMemo(()=>a.getViewport({scale:c,rotation:h}),[a,h,c]);return Qd.useLayoutEffect(function(){if(!a||!p)return;const{current:t}=f;if(!t)return;t.innerHTML="";const i=a.streamTextContent({includeMarkedContent:!0}),s=new Dm({container:t,textContentSource:i,viewport:w}),n=s;return s.render().then(()=>{const i=document.createElement("div");i.className="endOfContent",t.append(i);const s=t.querySelectorAll('[role="presentation"]');if(e){let t=0;p.items.forEach((i,n)=>{if(!function(t){return"str"in t}(i))return;const r=s[t];if(!r)return;!function(t,e){const i=document.createElement("template");i.innerHTML=e;const s=document.createDocumentFragment();Array.from(i.content.childNodes).forEach(t=>{s.append(rb(t))}),t.replaceChildren(s)}(r,e({pageIndex:o,pageNumber:l,itemIndex:n,...i})),t+=i.str&&i.hasEOL?2:1})}m()}).catch(v),()=>Lw(n)},[e,v,m,a,o,l,p,w]),Jd.jsx("div",{className:Zd("react-pdf__Page__textContent","textLayer"),onMouseUp:function(){const t=f.current;t&&t.classList.remove("selecting")},onMouseDown:function(){const t=f.current;t&&t.classList.add("selecting")},ref:f})}const ob=1;function lb(t){const e={...Hw(),...t},{_className:i="react-pdf__Page",_enableRegisterUnregisterPage:s=!0,canvasBackground:n,canvasRef:r,children:a,className:o,customRenderer:l,customTextRenderer:h,devicePixelRatio:c,error:d="Failed to load the page.",filterAnnotations:u,height:p,inputRef:g,loading:f="Loading page…",noData:m="No page specified.",onGetAnnotationsError:v,onGetAnnotationsSuccess:w,onGetStructTreeError:b,onGetStructTreeSuccess:y,onGetTextError:A,onGetTextSuccess:_,onLoadError:x,onLoadSuccess:k,onRenderAnnotationLayerError:S,onRenderAnnotationLayerSuccess:M,onRenderError:E,onRenderSuccess:C,onRenderTextLayerError:T,onRenderTextLayerSuccess:P,pageColors:D,pageIndex:R,pageNumber:I,pdf:L,registerPage:F,renderAnnotationLayer:N=!0,renderForms:W=!1,renderMode:B="canvas",renderTextLayer:O=!0,rotate:U,scale:H=ob,unregisterPage:$,width:j,...z}=e,[V,G]=Sw(),{value:q,error:X}=V,Y=Qd.useRef(null);vw(L);const K=Cw(I)?I-1:null!=R?R:null,Q=null!=I?I:Cw(R)?R+1:null,J=null!=U?U:q?q.rotate:null,Z=Qd.useMemo(()=>{if(!q)return null;let t=1;const e=null!=H?H:ob;if(j||p){const e=q.getViewport({scale:1,rotation:J});j?t=j/e.width:p&&(t=p/e.height)}return e*t},[p,q,J,H,j]);Qd.useEffect(function(){return()=>{Cw(K)&&s&&$&&$(K)}},[s,L,K,$]),Qd.useEffect(function(){G({type:"RESET"})},[G,L,K]),Qd.useEffect(function(){if(!L||!Q)return;const t=gw(L.getPage(Q)),e=t;return t.promise.then(t=>{G({type:"RESOLVE",value:t})}).catch(t=>{G({type:"REJECT",error:t})}),()=>Lw(e)},[G,L,Q]),Qd.useEffect(()=>{void 0!==q&&(!1!==q?function(){if(k){if(!q||!Z)return;k(Fw(q,Z))}if(s&&F){if(!Cw(K)||!Y.current)return;F(K,Y.current)}}():X&&(ww(!1,X.toString()),x&&x(X)))},[q,Z]);const tt=Qd.useMemo(()=>Cw(K)&&Q&&Cw(J)&&Cw(Z)?{_className:i,canvasBackground:n,customTextRenderer:h,devicePixelRatio:c,filterAnnotations:u,onGetAnnotationsError:v,onGetAnnotationsSuccess:w,onGetStructTreeError:b,onGetStructTreeSuccess:y,onGetTextError:A,onGetTextSuccess:_,onRenderAnnotationLayerError:S,onRenderAnnotationLayerSuccess:M,onRenderError:E,onRenderSuccess:C,onRenderTextLayerError:T,onRenderTextLayerSuccess:P,page:q,pageColors:D,pageIndex:K,pageNumber:Q,renderForms:W,renderTextLayer:O,rotate:J,scale:Z}:null,[i,n,h,c,u,v,w,b,y,A,_,S,M,E,C,T,P,q,D,K,Q,W,O,J,Z]),et=Qd.useMemo(()=>mw(z,()=>q?Z?Fw(q,Z):void 0:q),[z,q,Z]),it=`${K}@${Z}/${J}`;function st(){switch(B){case"custom":return vw(l),Jd.jsx(l,{},`${it}_custom`);case"none":return null;default:return Jd.jsx(eb,{canvasRef:r},`${it}_canvas`)}}return Jd.jsx("div",{className:Zd(i,o),"data-page-number":Q,ref:$w(g,Y),style:{"--scale-round-x":"1px","--scale-round-y":"1px","--scale-factor":"1","--user-unit":`${Z}`,"--total-scale-factor":"calc(var(--scale-factor) * var(--user-unit))",backgroundColor:n||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"},...et,children:Q?null===L||null==q?Jd.jsx(Aw,{type:"loading",children:"function"==typeof f?f():f}):!1===L||!1===q?Jd.jsx(Aw,{type:"error",children:"function"==typeof d?d():d}):function(){if(t=tt,!Boolean(null==t?void 0:t.page))throw new Error("page is undefined");var t;const e="function"==typeof a?a(tt):a;return Jd.jsxs(jw.Provider,{value:tt,children:[st(),O?Jd.jsx(ab,{},`${it}_text`):null,N?Jd.jsx(Vw,{},`${it}_annotations`):null,e]})}():Jd.jsx(Aw,{type:"no-data",children:"function"==typeof m?m():m})})}ww(!Ew,`Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${Rw}`),im.workerSrc="pdf.worker.mjs";im.workerSrc="/assets/pdf.worker.min-iDqQPrd3.mjs";function hb({pageNumber:t,scale:e}){const i=Qd.useRef(null),[s,n]=Qd.useState(!1);return Qd.useEffect(()=>{if(s||!i.current)return;const t=new IntersectionObserver(e=>{e[0].isIntersecting&&(n(!0),t.disconnect())},{rootMargin:"600px 0px"});return t.observe(i.current),()=>t.disconnect()},[s]),Jd.jsx("div",{ref:i,style:s?void 0:{minHeight:1e3*e,width:"100%"},children:s&&Jd.jsx(lb,{pageNumber:t,scale:e,renderTextLayer:!0,renderAnnotationLayer:!0,className:"rounded-md shadow-sm"})})}const cb=new Set(["pdf"]);function db({filePath:t,zoom:e}){const[i,s]=Qd.useState(null),[n,r]=Qd.useState(null),[a,o]=Qd.useState(0);Qd.useEffect(()=>{const e=new AbortController;return s(null),r(null),o(0),(async()=>{try{const i=await async function(t,e){let i=eu(t);const s=tu();s&&(i+=`${i.includes("?")?"&":"?"}token=${encodeURIComponent(s)}`);const n=await fetch(i,{signal:e});if(!n.ok)throw new Error(`Failed to fetch PDF: ${n.status}`);return n.arrayBuffer()}(t,e.signal);s(i)}catch(i){if("AbortError"===(null==i?void 0:i.name))return;r(i instanceof Error&&i.message?i.message:"Failed to load PDF")}})(),()=>e.abort()},[t]);const l=Qd.useMemo(()=>i?{data:i}:null,[i]);return n?Jd.jsx("p",{className:"text-sm text-destructive p-4",children:n}):l?Jd.jsx("div",{className:"flex flex-col items-center gap-3 p-4",children:Jd.jsx(Uw,{file:l,onLoadSuccess:({numPages:t})=>o(t),onLoadError:t=>r((null==t?void 0:t.message)||"未知错误"),loading:Jd.jsx("p",{className:"text-sm text-muted-foreground",children:"解析 PDF..."}),error:Jd.jsx("p",{className:"text-sm text-destructive",children:"PDF 解析失败"}),children:Array.from({length:a},(t,i)=>Jd.jsx(hb,{pageNumber:i+1,scale:e/100},i))})}):Jd.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"加载 PDF 中..."})}export{cb as PDF_EXTS,db as PdfPreview};
1
+ var t,e,i,s,n,r,a,o,l,h,c,d,u,p,g,f,m,v,w,b,y,A,_,x,k,S,M,E,C,T,P,D,R,I,L,F,N,W,B,O,U,H,$,j,z,V,G,q,X,Y,K,Q,J,Z,tt,et,it,st,nt,rt,at,ot,lt,ht,ct,dt,ut,pt,gt,ft,mt,vt,wt,bt,yt,At,_t,xt,kt,St,Mt,Et,Ct,Tt,Pt,Dt,Rt,It,Lt,Ft,Nt,Wt,Bt,Ot,Ut,Ht,$t,jt,zt,Vt,Gt,qt,Xt,Yt,Kt,Qt,Jt,Zt,te,ee,ie,se,ne,re,ae,oe,le,he,ce,de,ue,pe,ge,fe,me,ve,we,be,ye,Ae,_e,xe,ke,Se,Me,Ee,Ce,Te,Pe,De,Re,Ie,Le,Fe,Ne,We,Be,Oe,Ue,He,$e,je,ze,Ve,Ge,qe,Xe,Ye,Ke,Qe,Je,Ze,ti,ei,ii,si,ni,ri,ai,oi,li,hi,ci,di,ui,pi,gi,fi,mi,vi,wi,bi,yi,Ai,_i,xi,ki,Si,Mi,Ei,Ci,Ti,Pi,Di,Ri,Ii,Li,Fi,Ni,Wi,Bi,Oi,Ui,Hi,$i,ji,zi,Vi,Gi,qi,Xi,Yi,Ki,Qi,Ji,Zi,ts,es,is,ss,ns,rs,as,os,ls,hs,cs,ds,us,ps,gs,fs,ms,vs,ws,bs,ys,As,_s,xs,ks,Ss,Ms,Es,Cs,Ts,Ps,Ds,Rs,Is,Ls,Fs,Ns,Ws,Bs,Os,Us,Hs,$s,js,zs,Vs,Gs,qs,Xs,Ys,Ks,Qs,Js,Zs,tn,en,sn,nn,rn,an,on,ln,hn,cn,dn,un,pn,gn,fn,mn,vn,wn,bn,yn,An,_n,xn,kn,Sn,Mn,En,Cn,Tn,Pn,Dn,Rn,In,Ln,Fn,Nn,Wn,Bn,On,Un,Hn,$n,jn,zn,Vn,Gn,qn,Xn,Yn,Kn,Qn,Jn,Zn,tr,er,ir,sr,nr,rr,ar,or,lr,hr,cr,dr,ur,pr,gr,fr,mr,vr,wr,br,yr,Ar,_r,xr,kr,Sr,Mr,Er,Cr,Tr,Pr,Dr,Rr,Ir,Lr,Fr,Nr,Wr,Br,Or,Ur,Hr,$r,jr,zr,Vr,Gr,qr,Xr,Yr,Kr,Qr,Jr,Zr,ta,ea,ia,sa,na,ra,aa,oa,la,ha,ca,da,ua,pa,ga,fa,ma,va,wa,ba,ya,Aa,_a,xa,ka,Sa,Ma,Ea,Ca,Ta,Pa,Da,Ra,Ia,La,Fa,Na,Wa,Ba,Oa,Ua,Ha,$a,ja,za,Va,Ga,qa,Xa,Ya,Ka,Qa,Ja,Za,to,eo,io,so,no,ro,ao,oo,lo,ho,co,uo,po,go,fo,mo,vo,wo,bo,yo,Ao,_o,xo,ko,So,Mo,Eo,Co,To,Po,Do,Ro,Io,Lo,Fo,No,Wo,Bo,Oo,Uo,Ho,$o,jo,zo,Vo,Go,qo,Xo,Yo,Ko,Qo,Jo,Zo,tl,el,il,sl,nl,rl,al,ol,ll,hl,cl,dl,ul,pl,gl,fl,ml,vl,wl,bl,yl,Al,_l,xl,kl,Sl,Ml,El,Cl,Tl,Pl,Dl,Rl,Il,Ll,Fl,Nl,Wl,Bl,Ol,Ul,Hl,$l,jl,zl,Vl,Gl,ql,Xl,Yl,Kl,Ql,Jl,Zl,th,eh,ih,sh,nh,rh,ah,oh,lh,hh,ch,dh,uh,ph,gh,fh,mh,vh,wh,bh,yh,Ah,_h,xh,kh,Sh,Mh,Eh,Ch,Th,Ph,Dh,Rh,Ih,Lh,Fh,Nh,Wh,Bh,Oh,Uh,Hh,$h,jh,zh,Vh,Gh,qh,Xh,Yh,Kh,Qh,Jh,Zh,tc,ec,ic,sc,nc,rc,ac,oc,lc,hc,cc,dc,uc,pc,gc,fc,mc,vc,wc,bc,yc,Ac,_c,xc,kc,Sc,Mc,Ec,Cc,Tc,Pc,Dc,Rc,Ic,Lc,Fc,Nc,Wc,Bc,Oc,Uc,Hc,$c,jc,zc,Vc,Gc,qc,Xc,Yc,Kc,Qc,Jc,Zc,td,ed,id,sd,nd,rd,ad,od,ld,hd,cd,dd,ud,pd,gd,fd,md,vd,wd,bd,yd,Ad,_d,xd,kd,Sd,Md,Ed,Cd,Td,Pd,Dd,Rd,Id,Ld,Fd,Nd,Wd,Bd,Od,Ud,Hd=Object.defineProperty,$d=t=>{throw TypeError(t)},jd=(t,e,i)=>((t,e,i)=>e in t?Hd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i),zd=(t,e,i)=>e.has(t)||$d("Cannot "+i),Vd=(t,e,i)=>(zd(t,e,"read from private field"),i?i.call(t):e.get(t)),Gd=(t,e,i)=>e.has(t)?$d("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),qd=(t,e,i,s)=>(zd(t,e,"write to private field"),s?s.call(t,i):e.set(t,i),i),Xd=(t,e,i)=>(zd(t,e,"access private method"),i),Yd=(t,e,i,s)=>({set _(s){qd(t,e,s,i)},get _(){return Vd(t,e,s)}});import{bD as Kd,r as Qd,j as Jd,bL as Zd,g as tu,f as eu}from"./index-PkEuCOb6.js";const iu=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),su=[.001,0,0,.001,0,0],nu=1.35,ru=1,au=2,ou=4,lu=16,hu=32,cu=64,du=128,uu=256,pu={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},gu="pdfjs_internal_editor_",fu={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},mu={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_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},vu={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},wu=0,bu=1,yu=2,Au=3,_u=3,xu=4,ku={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Su={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},Mu=1,Eu=2,Cu=3,Tu=4,Pu=5,Du={ERRORS:0,WARNINGS:1,INFOS:5},Ru={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},Iu=0,Lu=1,Fu=2,Nu=3,Wu={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Bu=Du.WARNINGS;function Ou(){return Bu}function Uu(t){Bu>=Du.INFOS&&console.info(`Info: ${t}`)}function Hu(t){Bu>=Du.WARNINGS&&console.warn(`Warning: ${t}`)}function $u(t){throw new Error(t)}function ju(t,e){t||$u(e)}function zu(t,e=null,i=null){if(!t)return null;if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);(null==e?void 0:e.length)>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch{}}const s=e?URL.parse(t,e):URL.parse(t);return function(t){switch(null==t?void 0:t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s)?s:null}function Vu(t,e,i=!1){const s=URL.parse(t);return s?(s.hash=e,s.href):i&&zu(t,"http://example.com")?t.split("#",1)[0]+""+(e?`#${e}`:""):""}function Gu(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}const qu=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class Xu extends qu{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Yu extends qu{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Ku extends qu{constructor(t){super(t,"InvalidPDFException")}}class Qu extends qu{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}}class Ju extends qu{constructor(t){super(t,"FormatError")}}class Zu extends qu{constructor(t){super(t,"AbortException")}}function tp(t){"object"==typeof t&&void 0!==(null==t?void 0:t.length)||$u("Invalid argument for bytesToString");const e=t.length,i=8192;if(e<i)return String.fromCharCode.apply(null,t);const s=[];for(let n=0;n<e;n+=i){const r=Math.min(n+i,e),a=t.subarray(n,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function ep(t){"string"!=typeof t&&$u("Invalid argument for stringToBytes");const e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}class ip{static get isLittleEndian(){return Gu(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return Gu(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return Gu(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return Gu(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){const{platform:t,userAgent:e}=navigator;return Gu(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){var t,e;return Gu(this,"isCSSRoundSupported",null==(e=null==(t=globalThis.CSS)?void 0:t.supports)?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const sp=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));class np{static makeHexColor(t,e,i){return`#${sp[t]}${sp[e]}${sp[i]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,i=0){const s=t[i],n=t[i+1];t[i]=s*e[0]+n*e[2]+e[4],t[i+1]=s*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){const s=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5];for(let h=0;h<6;h+=2){const e=t[i+h],c=t[i+h+1];t[i+h]=e*s+c*r+o,t[i+h+1]=e*n+c*a+l}}static applyInverseTransform(t,e){const i=t[0],s=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-s*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-i*e[1]+s*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,i){const s=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5],h=t[0],c=t[1],d=t[2],u=t[3];let p=s*h+o,g=p,f=s*d+o,m=f,v=a*c+l,w=v,b=a*u+l,y=b;if(0!==n||0!==r){const t=n*h,e=n*d,i=r*c,s=r*u;p+=i,m+=i,f+=s,g+=s,v+=t,y+=t,b+=e,w+=e}i[0]=Math.min(i[0],p,f,g,m),i[1]=Math.min(i[1],v,b,w,y),i[2]=Math.max(i[2],p,f,g,m),i[3]=Math.max(i[3],v,b,w,y)}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){const i=t[0],s=t[1],n=t[2],r=t[3],a=i**2+s**2,o=i*n+s*r,l=n**2+r**2,h=(a+l)/2,c=Math.sqrt(h**2-(a*l-o**2));e[0]=Math.sqrt(h+c||1),e[1]=Math.sqrt(h-c||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[i,n,s,r]}static pointBoundingBox(t,e,i){i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],t),i[3]=Math.max(i[3],e)}static rectBoundingBox(t,e,i,s,n){n[0]=Math.min(n[0],t,i),n[1]=Math.min(n[1],e,s),n[2]=Math.max(n[2],t,i),n[3]=Math.max(n[3],e,s)}static bezierBoundingBox(e,s,n,r,a,o,l,h,c){c[0]=Math.min(c[0],e,l),c[1]=Math.min(c[1],s,h),c[2]=Math.max(c[2],e,l),c[3]=Math.max(c[3],s,h),Xd(this,t,i).call(this,e,n,a,l,s,r,o,h,3*(3*(n-a)-e+l),6*(e-2*n+a),3*(n-e),c),Xd(this,t,i).call(this,e,n,a,l,s,r,o,h,3*(3*(r-o)-s+h),6*(s-2*r+o),3*(r-s),c)}}t=new WeakSet,e=function(t,e,i,s,n,r,a,o,l,h){if(l<=0||l>=1)return;const c=1-l,d=l*l,u=d*l,p=c*(c*(c*t+3*l*e)+3*d*i)+u*s,g=c*(c*(c*n+3*l*r)+3*d*a)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)},i=function(i,s,n,r,a,o,l,h,c,d,u,p){if(Math.abs(c)<1e-12)return void(Math.abs(d)>=1e-12&&Xd(this,t,e).call(this,i,s,n,r,a,o,l,h,-u/d,p));const g=d**2-4*u*c;if(g<0)return;const f=Math.sqrt(g),m=2*c;Xd(this,t,e).call(this,i,s,n,r,a,o,l,h,(-d+f)/m,p),Xd(this,t,e).call(this,i,s,n,r,a,o,l,h,(-d-f)/m,p)},Gd(np,t);let rp=null,ap=null;function op(t){return rp||(rp=/([\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,ap=new Map([["ſt","ſt"]])),t.replaceAll(rp,(t,e,i)=>e?e.normalize("NFKC"):ap.get(i))}function lp(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),tp(t)}const hp="pdfjs_internal_id_";function cp(t,e,i){return Math.min(Math.max(t,e),i)}function dp(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(tp(t))}"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise(i=>{i(t(...e))})}),"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(t){return t.reduce((t,e)=>t+e,0)});class up{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};return function t(i){var s;if(!i)return;let n=null;const r=i.name;if("#text"===r)n=i.value;else{if(!up.shouldBuildText(r))return;(null==(s=null==i?void 0:i.attributes)?void 0:s.textContent)?n=i.attributes.textContent:i.value&&(n=i.value)}if(null!==n&&e.push({str:n}),i.children)for(const e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}class pp{static setupStorage(t,e,i,s,n){const r=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==r.value&&(t.textContent=r.value),"print"===n)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})});break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(r.value===i.attributes.xfaOn?t.setAttribute("checked",!0):r.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})})}else{if(null!==r.value&&t.setAttribute("value",r.value),"print"===n)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})})}break;case"select":if(null!==r.value){t.setAttribute("value",r.value);for(const t of i.children)t.attributes.value===r.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",t=>{const i=t.target.options,n=-1===i.selectedIndex?"":i[i.selectedIndex].value;s.setValue(e,{value:n})})}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;"radio"===r.type&&(r.name=`${r.name}-${s}`);for(const[o,l]of Object.entries(r))if(null!=l)switch(o){case"class":l.length&&t.setAttribute(o,l.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",l);break;case"style":Object.assign(t.style,l);break;case"textContent":t.textContent=l;break;default:(!a||"href"!==o&&"newWindow"!==o)&&t.setAttribute(o,l)}a&&n.addLinkAttributes(t,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(t,r.dataId,e,i)}static render(t){var e,i;const s=t.annotationStorage,n=t.linkService,r=t.xfaHtml,a=t.intent||"display",o=document.createElement(r.name);r.attributes&&this.setAttributes({html:o,element:r,intent:a,linkService:n});const l="richText"!==a,h=t.div;if(h.append(o),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;h.style.transform=e}l&&h.setAttribute("class","xfaLayer xfaFont");const c=[];if(0===r.children.length){if(r.value){const t=document.createTextNode(r.value);o.append(t),l&&up.shouldBuildText(r.name)&&c.push(t)}return{textDivs:c}}const d=[[r,-1,o]];for(;d.length>0;){const[t,r,o]=d.at(-1);if(r+1===t.children.length){d.pop();continue}const h=t.children[++d.at(-1)[1]];if(null===h)continue;const{name:u}=h;if("#text"===u){const t=document.createTextNode(h.value);c.push(t),o.append(t);continue}const p=(null==(e=null==h?void 0:h.attributes)?void 0:e.xmlns)?document.createElementNS(h.attributes.xmlns,u):document.createElement(u);if(o.append(p),h.attributes&&this.setAttributes({html:p,element:h,storage:s,intent:a,linkService:n}),(null==(i=h.children)?void 0:i.length)>0)d.push([h,-1,p]);else if(h.value){const t=document.createTextNode(h.value);l&&up.shouldBuildText(u)&&c.push(t),p.append(t)}}for(const u of h.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))u.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 gp="http://www.w3.org/2000/svg",fp=class{};jd(fp,"CSS",96),jd(fp,"PDF",72),jd(fp,"PDF_TO_CSS_UNITS",fp.CSS/fp.PDF);let mp=fp;async function vp(t,e="text"){if(Sp(t,document.baseURI)){const i=await fetch(t);if(!i.ok)throw new Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise((i,s)=>{const n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType=e,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE)if(200!==n.status&&0!==n.status)s(new Error(n.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void i(n.response)}i(n.responseText)}},n.send(null)})}class wp{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=n,this.offsetY=r,i*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let h,c,d,u,p,g,f,m;switch((s%=360)<0&&(s+=360),s){case 180:h=-1,c=0,d=0,u=1;break;case 90:h=0,c=1,d=1,u=0;break;case 270:h=0,c=-1,d=-1,u=0;break;case 0:h=1,c=0,d=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(d=-d,u=-u),0===h?(p=Math.abs(l-t[1])*i+n,g=Math.abs(o-t[0])*i+r,f=(t[3]-t[1])*i,m=(t[2]-t[0])*i):(p=Math.abs(o-t[0])*i+n,g=Math.abs(l-t[1])*i+r,f=(t[2]-t[0])*i,m=(t[3]-t[1])*i),this.transform=[h*i,c*i,d*i,u*i,p-h*i*o-d*i*l,g-c*i*o-u*i*l],this.width=f,this.height=m}get rawDims(){const t=this.viewBox;return Gu(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new wp({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){const i=[t,e];return np.applyTransform(i,this.transform),i}convertToViewportRectangle(t){const e=[t[0],t[1]];np.applyTransform(e,this.transform);const i=[t[2],t[3]];return np.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){const i=[t,e];return np.applyInverseTransform(i,this.transform),i}}class bp extends qu{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function yp(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function Ap(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function _p(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function xp(t,e="document.pdf"){if("string"!=typeof t)return e;if(yp(t))return Hu('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const i=(t=>{try{return new URL(t)}catch{try{return new URL(decodeURIComponent(t))}catch{try{return new URL(t,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(t),"https://foo.bar")}catch{return null}}}}})(t);if(!i)return e;const s=t=>{try{let e=decodeURIComponent(t);return e.includes("/")?(e=e.split("/").at(-1),e.test(/^\.pdf$/i)?e:t):e}catch{return t}},n=/\.pdf$/i,r=i.pathname.split("/").at(-1);if(n.test(r))return s(r);if(i.searchParams.size>0){const t=Array.from(i.searchParams.values()).reverse();for(const i of t)if(n.test(i))return s(i);const e=Array.from(i.searchParams.keys()).reverse();for(const i of e)if(n.test(i))return s(i)}if(i.hash){const t=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(i.hash);if(t)return s(t[0])}return e}class kp{constructor(){jd(this,"started",Object.create(null)),jd(this,"times",[])}time(t){t in this.started&&Hu(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||Hu(`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:i}of this.times)e=Math.max(i.length,e);for(const{name:i,start:s,end:n}of this.times)t.push(`${i.padEnd(e)} ${n-s}ms\n`);return t.join("")}}function Sp(t,e){const i=e?URL.parse(t,e):URL.parse(t);return"http:"===(null==i?void 0:i.protocol)||"https:"===(null==i?void 0:i.protocol)}function Mp(t){t.preventDefault()}function Ep(t){t.preventDefault(),t.stopPropagation()}class Cp{static toDateObject(t){if(t instanceof Date)return t;if(!t||"string"!=typeof t)return null;Vd(this,s)||qd(this,s,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=Vd(this,s).exec(t);if(!e)return null;const i=parseInt(e[1],10);let n=parseInt(e[2],10);n=n>=1&&n<=12?n-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(e[6],10);l=l>=0&&l<=59?l:0;const h=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,"-"===h?(a+=c,o+=d):"+"===h&&(a-=c,o-=d),new Date(Date.UTC(i,n,r,a,o,l))}}function Tp(t,{scale:e=1,rotation:i=0}){const{width:s,height:n}=t.attributes.style,r=[0,0,parseInt(s),parseInt(n)];return new wp({viewBox:r,userUnit:1,scale:e,rotation:i})}function Pp(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(t=>parseInt(t)):t.startsWith("rgba(")?t.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(Hu(`Not a valid color format: "${t}"`),[0,0,0])}function Dp(t){const{a:e,b:i,c:s,d:n,e:r,f:a}=t.getTransform();return[e,i,s,n,r,a]}function Rp(t){const{a:e,b:i,c:s,d:n,e:r,f:a}=t.getTransform().invertSelf();return[e,i,s,n,r,a]}function Ip(t,e,i=!1,s=!0){if(e instanceof wp){const{pageWidth:s,pageHeight:n}=e.rawDims,{style:r}=t,a=ip.isCSSRoundSupported,o=`var(--total-scale-factor) * ${s}px`,l=`var(--total-scale-factor) * ${n}px`,h=a?`round(down, ${o}, var(--scale-round-x))`:`calc(${o})`,c=a?`round(down, ${l}, var(--scale-round-y))`:`calc(${l})`;i&&e.rotation%180!=0?(r.width=c,r.height=h):(r.width=h,r.height=c)}s&&t.setAttribute("data-main-rotation",e.rotation)}s=new WeakMap,Gd(Cp,s);class Lp{constructor(){const{pixelRatio:t}=Lp;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,i,s,n=-1){let r=1/0,a=1/0,o=1/0;(i=Lp.capPixels(i,n))>0&&(r=Math.sqrt(i/(t*e))),-1!==s&&(a=s/t,o=s/e);const l=Math.min(r,a,o);return(this.sx>l||this.sy>l)&&(this.sx=l,this.sy=l,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,i):i}return t}}const Fp=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class Np{static get isDarkMode(){var t;return Gu(this,"isDarkMode",!!(null==(t=null==window?void 0:window.matchMedia)?void 0:t.call(window,"(prefers-color-scheme: dark)").matches))}}class Wp{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);const{color:i}=window.getComputedStyle(t);return t.remove(),Gu(this,"commentForegroundColor",Pp(i))}}function Bp(t,e,i,s){const n=255*(1-(s=Math.min(Math.max(s??1,0),1)));return[t=Math.round(t*s+n),e=Math.round(e*s+n),i=Math.round(i*s+n)]}function Op(t,e){const i=t[0]/255,s=t[1]/255,n=t[2]/255,r=Math.max(i,s,n),a=Math.min(i,s,n),o=(r+a)/2;if(r===a)e[0]=e[1]=0;else{const t=r-a;switch(e[1]=o<.5?t/(r+a):t/(2-r-a),r){case i:e[0]=60*((s-n)/t+(s<n?6:0));break;case s:e[0]=60*((n-i)/t+2);break;case n:e[0]=60*((i-s)/t+4)}}e[2]=o}function Up(t,e){const i=t[0],s=t[1],n=t[2],r=(1-Math.abs(2*n-1))*s,a=r*(1-Math.abs(i/60%2-1)),o=n-r/2;switch(Math.floor(i/60)){case 0:e[0]=r+o,e[1]=a+o,e[2]=o;break;case 1:e[0]=a+o,e[1]=r+o,e[2]=o;break;case 2:e[0]=o,e[1]=r+o,e[2]=a+o;break;case 3:e[0]=o,e[1]=a+o,e[2]=r+o;break;case 4:e[0]=a+o,e[1]=o,e[2]=r+o;break;case 5:case 6:e[0]=r+o,e[1]=o,e[2]=a+o}}function Hp(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function $p(t,e,i){Up(t,i),i.map(Hp);const s=.2126*i[0]+.7152*i[1]+.0722*i[2];Up(e,i),i.map(Hp);const n=.2126*i[0]+.7152*i[1]+.0722*i[2];return s>n?(s+.05)/(n+.05):(n+.05)/(s+.05)}const jp=new Map;function zp(t,e){const i=t[0]+256*t[1]+65536*t[2]+16777216*e[0]+4294967296*e[1]+1099511627776*e[2];let s=jp.get(i);if(s)return s;const n=new Float32Array(9),r=n.subarray(0,3),a=n.subarray(3,6);Op(t,a);const o=n.subarray(6,9);Op(e,o);const l=o[2]<.5,h=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),$p(a,o,r)<h){let t,e;l?(t=a[2],e=1):(t=0,e=a[2]);const i=.005;for(;e-t>i;){const i=a[2]=(t+e)/2;l===$p(a,o,r)<h?t=i:e=i}a[2]=l?e:t}return Up(a,r),s=np.makeHexColor(Math.round(255*r[0]),Math.round(255*r[1]),Math.round(255*r[2])),jp.set(i,s),s}function Vp({html:t,dir:e,className:i},s){const n=document.createDocumentFragment();if("string"==typeof t){const i=document.createElement("p");i.dir=e||"auto";const s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t){const n=s[t];i.append(document.createTextNode(n)),t<e-1&&i.append(document.createElement("br"))}n.append(i)}else pp.render({xfaHtml:t,div:n,intent:"richText"});n.firstChild.classList.add("richText",i),s.append(n)}const Gp=class t{constructor(e){Gd(this,f),Gd(this,n,null),Gd(this,r,null),Gd(this,a),Gd(this,o,null),Gd(this,l,null),Gd(this,h,null),Gd(this,c,null),Gd(this,d,null),qd(this,a,e),Vd(t,u)||qd(t,u,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const e=qd(this,n,document.createElement("div"));e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const i=Vd(this,a)._uiManager._signal;i instanceof AbortSignal&&!i.aborted&&(e.addEventListener("contextmenu",Mp,{signal:i}),e.addEventListener("pointerdown",Xd(t,p,g),{signal:i}));const s=qd(this,o,document.createElement("div"));s.className="buttons",e.append(s);const r=Vd(this,a).toolbarPosition;if(r){const{style:t}=e,i="ltr"===Vd(this,a)._uiManager.direction?1-r[0]:r[0];t.insetInlineEnd=100*i+"%",t.top=`calc(${100*r[1]}% + var(--editor-toolbar-vert-offset))`}return e}get div(){return Vd(this,n)}hide(){var t;Vd(this,n).classList.add("hidden"),null==(t=Vd(this,r))||t.hideDropdown()}show(){var t,e;Vd(this,n).classList.remove("hidden"),null==(t=Vd(this,l))||t.shown(),null==(e=Vd(this,h))||e.shown()}addDeleteButton(){const{editorType:e,_uiManager:i}=Vd(this,a),s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",Vd(t,u)[e]),Xd(this,f,w).call(this,s)&&s.addEventListener("click",t=>{i.delete()},{signal:i._signal}),Vd(this,o).append(s)}async addAltText(t){const e=await t.render();Xd(this,f,w).call(this,e),Vd(this,o).append(e,Vd(this,f,b)),qd(this,l,t)}addComment(t,e=null){if(Vd(this,h))return;const i=t.renderForToolbar();if(!i)return;Xd(this,f,w).call(this,i);const s=qd(this,c,Vd(this,f,b));e?(Vd(this,o).insertBefore(i,e),Vd(this,o).insertBefore(s,e)):Vd(this,o).append(i,s),qd(this,h,t),t.toolbar=this}addColorPicker(t){if(Vd(this,r))return;qd(this,r,t);const e=t.renderButton();Xd(this,f,w).call(this,e),Vd(this,o).append(e,Vd(this,f,b))}async addEditSignatureButton(t){const e=qd(this,d,await t.renderEditButton(Vd(this,a)));Xd(this,f,w).call(this,e),Vd(this,o).append(e,Vd(this,f,b))}removeButton(t){var e,i;if("comment"===t)null==(e=Vd(this,h))||e.removeToolbarCommentButton(),qd(this,h,null),null==(i=Vd(this,c))||i.remove(),qd(this,c,null)}async addButton(t,e){switch(t){case"colorPicker":this.addColorPicker(e);break;case"altText":await this.addAltText(e);break;case"editSignature":await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":this.addComment(e)}}async addButtonBefore(t,e,i){const s=Vd(this,o).querySelector(i);s&&"comment"===t&&this.addComment(e,s)}updateEditSignatureButton(t){Vd(this,d)&&(Vd(this,d).title=t)}remove(){var t;Vd(this,n).remove(),null==(t=Vd(this,r))||t.destroy(),qd(this,r,null)}};n=new WeakMap,r=new WeakMap,a=new WeakMap,o=new WeakMap,l=new WeakMap,h=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakMap,p=new WeakSet,g=function(t){t.stopPropagation()},f=new WeakSet,m=function(t){Vd(this,a)._focusEventsAllowed=!1,Ep(t)},v=function(t){Vd(this,a)._focusEventsAllowed=!0,Ep(t)},w=function(t){const e=Vd(this,a)._uiManager._signal;return e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("focusin",Xd(this,f,m).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",Xd(this,f,v).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Mp,{signal:e}),!0)},b=function(){const t=document.createElement("div");return t.className="divider",t},Gd(Gp,p),Gd(Gp,u,null);let qp=Gp;class Xp{constructor(t){Gd(this,x),Gd(this,y,null),Gd(this,A,null),Gd(this,_),qd(this,_,t)}show(t,e,i){const[s,n]=Xd(this,x,S).call(this,e,i),{style:r}=Vd(this,A)||qd(this,A,Xd(this,x,k).call(this));t.append(Vd(this,A)),r.insetInlineEnd=100*s+"%",r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){Vd(this,A).remove()}}function Yp(t,e,i){for(const s of i)e.addEventListener(s,t[s].bind(t))}y=new WeakMap,A=new WeakMap,_=new WeakMap,x=new WeakSet,k=function(){const t=qd(this,A,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar");const e=Vd(this,_)._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",Mp,{signal:e});const i=qd(this,y,document.createElement("div"));return i.className="buttons",t.append(i),Vd(this,_).hasCommentManager()&&Xd(this,x,M).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{Vd(this,_).commentSelection("floating_button")}),Xd(this,x,M).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{Vd(this,_).highlightSelection("floating_button")}),t},S=function(t,e){let i=0,s=0;for(const n of t){const t=n.y+n.height;if(t<i)continue;const r=n.x+(e?n.width:0);t>i?(s=r,i=t):e?r>s&&(s=r):r<s&&(s=r)}return[e?1-s:s,i]},M=function(t,e,i,s){const n=document.createElement("button");n.classList.add("basic",t),n.tabIndex=0,n.setAttribute("data-l10n-id",e);const r=document.createElement("span");n.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id",i);const a=Vd(this,_)._signal;a instanceof AbortSignal&&!a.aborted&&(n.addEventListener("contextmenu",Mp,{signal:a}),n.addEventListener("click",s,{signal:a})),Vd(this,y).append(n)};class Kp{constructor(){Gd(this,E,0)}get id(){return`${gu}${Yd(this,E)._++}`}}E=new WeakMap;const Qp=class{constructor(){Gd(this,D),Gd(this,C,lp()),Gd(this,T,0),Gd(this,P,null)}static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>';return Gu(this,"_isSVGFittingCanvas",e.decode().then(()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0])))}async getFromFile(t){const{lastModified:e,name:i,size:s,type:n}=t;return Xd(this,D,R).call(this,`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return Xd(this,D,R).call(this,t,t)}async getFromBlob(t,e){const i=await e;return Xd(this,D,R).call(this,t,i)}async getFromId(t){Vd(this,P)||qd(this,P,new Map);const e=Vd(this,P).get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){Vd(this,P)||qd(this,P,new Map);let i=Vd(this,P).get(t);if(null==i?void 0:i.bitmap)return i.refCounter+=1,i;const s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${Vd(this,C)}_${Yd(this,T)._++}`,refCounter:1,isSvg:!1},Vd(this,P).set(t,i),Vd(this,P).set(i.id,i),i}getSvgUrl(t){const e=Vd(this,P).get(t);return(null==e?void 0:e.isSvg)?e.svgUrl:null}deleteId(t){var e;Vd(this,P)||qd(this,P,new Map);const i=Vd(this,P).get(t);if(!i)return;if(i.refCounter-=1,0!==i.refCounter)return;const{bitmap:s}=i;if(!i.url&&!i.file){const t=new OffscreenCanvas(s.width,s.height);t.getContext("bitmaprenderer").transferFromImageBitmap(s),i.blobPromise=t.convertToBlob()}null==(e=s.close)||e.call(s),i.bitmap=null}isValidId(t){return t.startsWith(`image_${Vd(this,C)}_`)}};C=new WeakMap,T=new WeakMap,P=new WeakMap,D=new WeakSet,R=async function(t,e){Vd(this,P)||qd(this,P,new Map);let i=Vd(this,P).get(t);if(null===i)return null;if(null==i?void 0:i.bitmap)return i.refCounter+=1,i;try{let t;if(i||(i={bitmap:null,id:`image_${Vd(this,C)}_${Yd(this,T)._++}`,refCounter:0,isSvg:!1}),"string"==typeof e?(i.url=e,t=await vp(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=Qp._isSVGFittingCanvas,s=new FileReader,n=new Image,r=new Promise((t,r)=>{n.onload=()=>{i.bitmap=n,i.isSvg=!0,t()},s.onload=async()=>{const t=i.svgUrl=s.result;n.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},n.onerror=s.onerror=r});s.readAsDataURL(t),await r}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(s){Hu(s),i=null}return Vd(this,P).set(t,i),i&&Vd(this,P).set(i.id,i),i};let Jp=Qp;class Zp{constructor(t=128){Gd(this,I,[]),Gd(this,L,!1),Gd(this,F),Gd(this,N,-1),qd(this,F,t)}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(s&&t(),Vd(this,L))return;const o={cmd:t,undo:e,post:i,type:n};if(-1===Vd(this,N))return Vd(this,I).length>0&&(Vd(this,I).length=0),qd(this,N,0),void Vd(this,I).push(o);if(r&&Vd(this,I)[Vd(this,N)].type===n)return a&&(o.undo=Vd(this,I)[Vd(this,N)].undo),void(Vd(this,I)[Vd(this,N)]=o);const l=Vd(this,N)+1;l===Vd(this,F)?Vd(this,I).splice(0,1):(qd(this,N,l),l<Vd(this,I).length&&Vd(this,I).splice(l)),Vd(this,I).push(o)}undo(){if(-1===Vd(this,N))return;qd(this,L,!0);const{undo:t,post:e}=Vd(this,I)[Vd(this,N)];t(),null==e||e(),qd(this,L,!1),qd(this,N,Vd(this,N)-1)}redo(){if(Vd(this,N)<Vd(this,I).length-1){qd(this,N,Vd(this,N)+1),qd(this,L,!0);const{cmd:t,post:e}=Vd(this,I)[Vd(this,N)];t(),null==e||e(),qd(this,L,!1)}}hasSomethingToUndo(){return-1!==Vd(this,N)}hasSomethingToRedo(){return Vd(this,N)<Vd(this,I).length-1}cleanType(t){if(-1!==Vd(this,N)){for(let e=Vd(this,N);e>=0;e--)if(Vd(this,I)[e].type!==t)return Vd(this,I).splice(e+1,Vd(this,N)-e),void qd(this,N,e);Vd(this,I).length=0,qd(this,N,-1)}}destroy(){qd(this,I,null)}}I=new WeakMap,L=new WeakMap,F=new WeakMap,N=new WeakMap;class tg{constructor(t){Gd(this,W),this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=ip.platform;for(const[i,s,n={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const i=this.callbacks.get(Xd(this,W,B).call(this,e));if(!i)return;const{callback:s,options:{bubbles:n=!1,args:r=[],checker:a=null}}=i;a&&!a(t,e)||(s.bind(t,...r,e)(),n||Ep(e))}}W=new WeakSet,B=function(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};const eg=class t{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(const i of t.keys()){e.style.color=i;const s=window.getComputedStyle(e).color;t.set(i,Pp(s))}e.remove()}(t),Gu(this,"_colors",t)}convert(e){const i=Pp(e);if(!window.matchMedia("(forced-colors: active)").matches)return i;for(const[s,n]of this._colors)if(n.every((t,e)=>t===i[e]))return t._colorsMapping.get(s);return i}getHexCode(t){const e=this._colors.get(t);return e?np.makeHexColor(...e):t}};jd(eg,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let ig=eg;const sg=class t{constructor(t,e,i,s,n,r,a,o,l,h,c,d,u,p,g,f){Gd(this,Lt),Gd(this,O,new AbortController),Gd(this,U,null),Gd(this,H,null),Gd(this,$,new Map),Gd(this,j,new Map),Gd(this,z,null),Gd(this,V,null),Gd(this,G,null),Gd(this,q,new Zp),Gd(this,X,null),Gd(this,Y,null),Gd(this,K,null),Gd(this,Q,0),Gd(this,J,new Set),Gd(this,Z,null),Gd(this,tt,null),Gd(this,et,new Set),jd(this,"_editorUndoBar",null),Gd(this,it,!1),Gd(this,st,!1),Gd(this,nt,!1),Gd(this,rt,null),Gd(this,at,null),Gd(this,ot,null),Gd(this,lt,null),Gd(this,ht,!1),Gd(this,ct,null),Gd(this,dt,new Kp),Gd(this,ut,!1),Gd(this,pt,!1),Gd(this,gt,!1),Gd(this,ft,null),Gd(this,mt,null),Gd(this,vt,null),Gd(this,wt,null),Gd(this,bt,null),Gd(this,yt,fu.NONE),Gd(this,At,new Set),Gd(this,_t,null),Gd(this,xt,null),Gd(this,kt,null),Gd(this,St,null),Gd(this,Mt,null),Gd(this,Et,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),Gd(this,Ct,[0,0]),Gd(this,Tt,null),Gd(this,Pt,null),Gd(this,Dt,null),Gd(this,Rt,null),Gd(this,It,null);const m=this._signal=Vd(this,O).signal;qd(this,Pt,t),qd(this,Dt,e),qd(this,Rt,i),qd(this,z,s),qd(this,X,n),qd(this,xt,r),qd(this,Mt,o),this._eventBus=a,a._on("editingaction",this.onEditingAction.bind(this),{signal:m}),a._on("pagechanging",this.onPageChanging.bind(this),{signal:m}),a._on("scalechanging",this.onScaleChanging.bind(this),{signal:m}),a._on("rotationchanging",this.onRotationChanging.bind(this),{signal:m}),a._on("setpreference",this.onSetPreference.bind(this),{signal:m}),a._on("switchannotationeditorparams",t=>this.updateParams(t.type,t.value),{signal:m}),window.addEventListener("pointerdown",()=>{qd(this,pt,!0)},{capture:!0,signal:m}),window.addEventListener("pointerup",()=>{qd(this,pt,!1)},{capture:!0,signal:m}),Xd(this,Lt,Ut).call(this),Xd(this,Lt,qt).call(this),Xd(this,Lt,jt).call(this),qd(this,V,o.annotationStorage),qd(this,rt,o.filterFactory),qd(this,kt,l),qd(this,lt,h||null),qd(this,it,c),qd(this,st,d),qd(this,nt,u),qd(this,bt,p||null),this.viewParameters={realScale:mp.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=!1!==f,null==n||n.setSidebarUiManager(this)}static get _keyboardManager(){const e=t.prototype,i=t=>Vd(t,Pt).contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),s=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},n=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return Gu(this,"_keyboardManager",new tg([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],e.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:s}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&Vd(t,Pt).contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&Vd(t,Pt).contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-n,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-r,0],checker:i}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[n,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[r,0],checker:i}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-n],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-r],checker:i}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,n],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,r],checker:i}]]))}destroy(){var t,e,i,s,n,r,a,o,l;null==(t=Vd(this,It))||t.resolve(),qd(this,It,null),null==(e=Vd(this,O))||e.abort(),qd(this,O,null),this._signal=null;for(const h of Vd(this,j).values())h.destroy();Vd(this,j).clear(),Vd(this,$).clear(),Vd(this,et).clear(),null==(i=Vd(this,wt))||i.clear(),qd(this,U,null),Vd(this,At).clear(),Vd(this,q).destroy(),null==(s=Vd(this,z))||s.destroy(),null==(n=Vd(this,X))||n.destroy(),null==(r=Vd(this,xt))||r.destroy(),null==(a=Vd(this,ct))||a.hide(),qd(this,ct,null),null==(o=Vd(this,vt))||o.destroy(),qd(this,vt,null),qd(this,H,null),Vd(this,at)&&(clearTimeout(Vd(this,at)),qd(this,at,null)),Vd(this,Tt)&&(clearTimeout(Vd(this,Tt)),qd(this,Tt,null)),null==(l=this._editorUndoBar)||l.destroy(),qd(this,Mt,null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return Vd(this,bt)}get useNewAltTextFlow(){return Vd(this,st)}get useNewAltTextWhenAddingImage(){return Vd(this,nt)}get hcmFilter(){return Gu(this,"hcmFilter",Vd(this,kt)?Vd(this,rt).addHCMFilter(Vd(this,kt).foreground,Vd(this,kt).background):"none")}get direction(){return Gu(this,"direction",getComputedStyle(Vd(this,Pt)).direction)}get _highlightColors(){return Gu(this,"_highlightColors",Vd(this,lt)?new Map(Vd(this,lt).split(",").map(t=>((t=t.split("=").map(t=>t.trim()))[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return Gu(this,"highlightColors",null);const e=new Map,i=!!Vd(this,kt);for(const[s,n]of t){const t=s.endsWith("_HCM");i&&t?e.set(s.replace("_HCM",""),n):i||t||e.set(s,n)}return Gu(this,"highlightColors",e)}get highlightColorNames(){return Gu(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),qd(this,K,t)}setMainHighlightColorPicker(t){qd(this,vt,t)}editAltText(t,e=!1){var i;null==(i=Vd(this,z))||i.editAltText(this,t,e)}hasCommentManager(){return!!Vd(this,X)}editComment(t,e,i,s){var n;null==(n=Vd(this,X))||n.showDialog(this,t,e,i,s)}selectComment(t,e){const i=Vd(this,j).get(t),s=null==i?void 0:i.getEditorByUID(e);null==s||s.toggleComment(!0,!0)}updateComment(t){var e;null==(e=Vd(this,X))||e.updateComment(t.getData())}updatePopupColor(t){var e;null==(e=Vd(this,X))||e.updatePopupColor(t)}removeComment(t){var e;null==(e=Vd(this,X))||e.removeComments([t.uid])}toggleComment(t,e,i=void 0){var s;null==(s=Vd(this,X))||s.toggleCommentPopup(t,e,i)}makeCommentColor(t,e){var i;return t&&(null==(i=Vd(this,X))?void 0:i.makeCommentColor(t,e))||null}getCommentDialogElement(){var t;return(null==(t=Vd(this,X))?void 0:t.dialogElement)||null}async waitForEditorsRendered(t){if(Vd(this,j).has(t-1))return;const{resolve:e,promise:i}=Promise.withResolvers(),s=i=>{i.pageNumber===t&&(this._eventBus._off("editorsrendered",s),e())};this._eventBus.on("editorsrendered",s),await i}getSignature(t){var e;null==(e=Vd(this,xt))||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return Vd(this,xt)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){if("enableNewAltTextWhenAddingImage"===t)qd(this,nt,e)}onPageChanging({pageNumber:t}){qd(this,Q,t-1)}focusMainContainer(){Vd(this,Pt).focus()}findParent(t,e){for(const i of Vd(this,j).values()){const{x:s,y:n,width:r,height:a}=i.div.getBoundingClientRect();if(t>=s&&t<=s+r&&e>=n&&e<=n+a)return i}return null}disableUserSelect(t=!1){Vd(this,Dt).classList.toggle("noUserSelect",t)}addShouldRescale(t){Vd(this,et).add(t)}removeShouldRescale(t){Vd(this,et).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*mp.PDF_TO_CSS_UNITS;for(const i of Vd(this,et))i.onScaleChanging();null==(e=Vd(this,K))||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t="",e=!1){const i=document.getSelection();if(!i||i.isCollapsed)return;const{anchorNode:s,anchorOffset:n,focusNode:r,focusOffset:a}=i,o=i.toString(),l=Xd(this,Lt,Ft).call(this,i).closest(".textLayer"),h=this.getSelectionBoxes(l);if(!h)return;i.empty();const c=Xd(this,Lt,Nt).call(this,l),d=Vd(this,yt)===fu.NONE,u=()=>{const i=null==c?void 0:c.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:s,anchorOffset:n,focusNode:r,focusOffset:a,text:o});d&&this.showAllEditors("highlight",!0,!0),e&&(null==i||i.editComment())};d?this.switchToMode(fu.HIGHLIGHT,u):u()}commentSelection(t=""){this.highlightSelection(t,!0)}getAndRemoveDataFromAnnotationStorage(t){if(!Vd(this,V))return null;const e=`${gu}${t}`,i=Vd(this,V).getRawValue(e);return i&&Vd(this,V).remove(e),i}addToAnnotationStorage(t){t.isEmpty()||!Vd(this,V)||Vd(this,V).has(t.id)||Vd(this,V).setValue(t.id,t)}a11yAlert(t,e=null){const i=Vd(this,Rt);i&&(i.setAttribute("data-l10n-id",t),e?i.setAttribute("data-l10n-args",JSON.stringify(e)):i.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,Vd(this,ht)&&(qd(this,ht,!1),Xd(this,Lt,Ot).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of Vd(this,At))if(e.div.contains(t)){qd(this,mt,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!Vd(this,mt))return;const[t,e]=Vd(this,mt);qd(this,mt,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){Xd(this,Lt,jt).call(this),Xd(this,Lt,Vt).call(this)}removeEditListeners(){Xd(this,Lt,zt).call(this),Xd(this,Lt,Gt).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of Vd(this,tt))if(i.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const i of Vd(this,tt))if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){var e;if(t.preventDefault(),null==(e=Vd(this,U))||e.commitOrRemove(),!this.hasSelection)return;const i=[];for(const s of Vd(this,At)){const t=s.serialize(!0);t&&i.push(t)}0!==i.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(i))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const r of e.items)for(const t of Vd(this,tt))if(t.isHandlingMimeForPasting(r.type))return void t.paste(r,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(n){return void Hu(`paste: "${n.message}".`)}if(!Array.isArray(i))return;this.unselectAll();const s=this.currentLayer;try{const t=[];for(const r of i){const e=await s.deserialize(r);if(!e)return;t.push(e)}const e=()=>{for(const e of t)Xd(this,Lt,Jt).call(this,e);Xd(this,Lt,ee).call(this,t)},n=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:n,mustExec:!0})}catch(n){Hu(`paste: "${n.message}".`)}}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0),Vd(this,yt)===fu.NONE||this.isEditorHandlingKeyboard||t._keyboardManager.exec(this,e)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,Vd(this,ht)&&(qd(this,ht,!1),Xd(this,Lt,Ot).call(this,"main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu")}}setEditingState(t){t?(Xd(this,Lt,Ht).call(this),Xd(this,Lt,Vt).call(this),Xd(this,Lt,Xt).call(this,{isEditing:Vd(this,yt)!==fu.NONE,isEmpty:Xd(this,Lt,te).call(this),hasSomethingToUndo:Vd(this,q).hasSomethingToUndo(),hasSomethingToRedo:Vd(this,q).hasSomethingToRedo(),hasSelectedEditor:!1})):(Xd(this,Lt,$t).call(this),Xd(this,Lt,Gt).call(this),Xd(this,Lt,Xt).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!Vd(this,tt)){qd(this,tt,t);for(const t of Vd(this,tt))Xd(this,Lt,Yt).call(this,t.defaultPropertiesToUpdate)}}getId(){return Vd(this,dt).id}get currentLayer(){return Vd(this,j).get(Vd(this,Q))}getLayer(t){return Vd(this,j).get(t)}get currentPageIndex(){return Vd(this,Q)}addLayer(t){Vd(this,j).set(t.pageIndex,t),Vd(this,ut)?t.enable():t.disable()}removeLayer(t){Vd(this,j).delete(t.pageIndex)}async updateMode(t,e=null,i=!1,s=!1,n=!1){var r,a,o,l,h,c;if(Vd(this,yt)!==t&&(!Vd(this,It)||(await Vd(this,It).promise,Vd(this,It)))){if(qd(this,It,Promise.withResolvers()),null==(r=Vd(this,K))||r.commitOrRemove(),Vd(this,yt)===fu.POPUP&&(null==(a=Vd(this,X))||a.hideSidebar()),null==(o=Vd(this,X))||o.destroyPopup(),qd(this,yt,t),t===fu.NONE){this.setEditingState(!1),Xd(this,Lt,Qt).call(this);for(const t of Vd(this,$).values())t.hideStandaloneCommentButton();return null==(l=this._editorUndoBar)||l.hide(),this.toggleComment(null),void Vd(this,It).resolve()}for(const t of Vd(this,$).values())t.addStandaloneCommentButton();t===fu.SIGNATURE&&await(null==(h=Vd(this,xt))?void 0:h.loadSignatures()),this.setEditingState(!0),await Xd(this,Lt,Kt).call(this),this.unselectAll();for(const e of Vd(this,j).values())e.updateMode(t);if(t===fu.POPUP){Vd(this,H)||qd(this,H,await Vd(this,Mt).getAnnotationsByType(new Set(Vd(this,tt).map(t=>t._editorType))));const t=new Set,e=[];for(const i of Vd(this,$).values()){const{annotationElementId:s,hasComment:n,deleted:r}=i;s&&t.add(s),n&&!r&&e.push(i.getData())}for(const i of Vd(this,H)){const{id:s,popupRef:n,contentsObj:r}=i;n&&(null==r?void 0:r.str)&&!t.has(s)&&!Vd(this,J).has(s)&&e.push(i)}null==(c=Vd(this,X))||c.showSidebar(e)}if(!e)return i&&this.addNewEditorFromKeyboard(),void Vd(this,It).resolve();for(const t of Vd(this,$).values())t.uid===e?(this.setSelected(t),n?t.editComment():s?t.enterInEditMode():t.focus()):t.unselect();Vd(this,It).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==Vd(this,yt)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(Vd(this,tt)){switch(t){case mu.CREATE:return void this.currentLayer.addNewEditor(e);case mu.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(Vd(this,St)||qd(this,St,new Map)).set(t,e),this.showAllEditors("highlight",e)}if(this.hasSelection)for(const i of Vd(this,At))i.updateParams(t,e);else for(const i of Vd(this,tt))i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){var s;for(const n of Vd(this,$).values())n.editorType===t&&n.show(e);((null==(s=Vd(this,St))?void 0:s.get(mu.HIGHLIGHT_SHOW_ALL))??!0)!==e&&Xd(this,Lt,Yt).call(this,[[mu.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(Vd(this,gt)!==t){qd(this,gt,t);for(const e of Vd(this,j).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}*getEditors(t){for(const e of Vd(this,$).values())e.pageIndex===t&&(yield e)}getEditor(t){return Vd(this,$).get(t)}addEditor(t){Vd(this,$).set(t.id,t)}removeEditor(t){var e,i;t.div.contains(document.activeElement)&&(Vd(this,at)&&clearTimeout(Vd(this,at)),qd(this,at,setTimeout(()=>{this.focusMainContainer(),qd(this,at,null)},0))),Vd(this,$).delete(t.id),t.annotationElementId&&(null==(e=Vd(this,wt))||e.delete(t.annotationElementId)),this.unselect(t),t.annotationElementId&&Vd(this,J).has(t.annotationElementId)||null==(i=Vd(this,V))||i.remove(t.id)}addDeletedAnnotationElement(t){Vd(this,J).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return Vd(this,J).has(t)}removeDeletedAnnotationElement(t){Vd(this,J).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){Vd(this,U)!==t&&(qd(this,U,t),t&&Xd(this,Lt,Yt).call(this,t.propertiesToUpdate))}updateUI(t){Vd(this,Lt,Zt)===t&&Xd(this,Lt,Yt).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){Xd(this,Lt,Yt).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(Vd(this,At).has(t))return Vd(this,At).delete(t),t.unselect(),void Xd(this,Lt,Xt).call(this,{hasSelectedEditor:this.hasSelection});Vd(this,At).add(t),t.select(),Xd(this,Lt,Yt).call(this,t.propertiesToUpdate),Xd(this,Lt,Xt).call(this,{hasSelectedEditor:!0})}setSelected(t){var e;this.updateToolbar({mode:t.mode,editId:t.id}),null==(e=Vd(this,K))||e.commitOrRemove();for(const i of Vd(this,At))i!==t&&i.unselect();Vd(this,At).clear(),Vd(this,At).add(t),t.select(),Xd(this,Lt,Yt).call(this,t.propertiesToUpdate),Xd(this,Lt,Xt).call(this,{hasSelectedEditor:!0})}isSelected(t){return Vd(this,At).has(t)}get firstSelectedEditor(){return Vd(this,At).values().next().value}unselect(t){t.unselect(),Vd(this,At).delete(t),Xd(this,Lt,Xt).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==Vd(this,At).size}get isEnterHandled(){return 1===Vd(this,At).size&&this.firstSelectedEditor.isEnterHandled}undo(){var t;Vd(this,q).undo(),Xd(this,Lt,Xt).call(this,{hasSomethingToUndo:Vd(this,q).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:Xd(this,Lt,te).call(this)}),null==(t=this._editorUndoBar)||t.hide()}redo(){Vd(this,q).redo(),Xd(this,Lt,Xt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:Vd(this,q).hasSomethingToRedo(),isEmpty:Xd(this,Lt,te).call(this)})}addCommands(t){Vd(this,q).add(t),Xd(this,Lt,Xt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:Xd(this,Lt,te).call(this)})}cleanUndoStack(t){Vd(this,q).cleanType(t)}delete(){var t;this.commitOrRemove();const e=null==(t=this.currentLayer)?void 0:t.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const i=e?[e]:[...Vd(this,At)],s=()=>{for(const t of i)Xd(this,Lt,Jt).call(this,t)};this.addCommands({cmd:()=>{var t;null==(t=this._editorUndoBar)||t.show(s,1===i.length?i[0].editorType:i.length);for(const e of i)e.remove()},undo:s,mustExec:!0})}commitOrRemove(){var t;null==(t=Vd(this,U))||t.commitOrRemove()}hasSomethingToControl(){return Vd(this,U)||this.hasSelection}selectAll(){for(const t of Vd(this,At))t.commit();Xd(this,Lt,ee).call(this,Vd(this,$).values())}unselectAll(){var t;if((!Vd(this,U)||(Vd(this,U).commitOrRemove(),Vd(this,yt)===fu.NONE))&&!(null==(t=Vd(this,K))?void 0:t.commitOrRemove())&&this.hasSelection){for(const t of Vd(this,At))t.unselect();Vd(this,At).clear(),Xd(this,Lt,Xt).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;Vd(this,Ct)[0]+=t,Vd(this,Ct)[1]+=e;const[s,n]=Vd(this,Ct),r=[...Vd(this,At)];Vd(this,Tt)&&clearTimeout(Vd(this,Tt)),qd(this,Tt,setTimeout(()=>{qd(this,Tt,null),Vd(this,Ct)[0]=Vd(this,Ct)[1]=0,this.addCommands({cmd:()=>{for(const t of r)Vd(this,$).has(t.id)&&(t.translateInPage(s,n),t.translationDone())},undo:()=>{for(const t of r)Vd(this,$).has(t.id)&&(t.translateInPage(-s,-n),t.translationDone())},mustExec:!1})},1e3));for(const a of r)a.translateInPage(t,e),a.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),qd(this,Z,new Map);for(const t of Vd(this,At))Vd(this,Z).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!Vd(this,Z))return!1;this.disableUserSelect(!1);const t=Vd(this,Z);qd(this,Z,null);let e=!1;for(const[{x:s,y:n,pageIndex:r},a]of t)a.newX=s,a.newY=n,a.newPageIndex=r,e||(e=s!==a.savedX||n!==a.savedY||r!==a.savedPageIndex);if(!e)return!1;const i=(t,e,i,s)=>{if(Vd(this,$).has(t.id)){const n=Vd(this,j).get(s);n?t._setParentAndPosition(n,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(const[e,{newX:s,newY:n,newPageIndex:r}]of t)i(e,s,n,r)},undo:()=>{for(const[e,{savedX:s,savedY:n,savedPageIndex:r}]of t)i(e,s,n,r)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(Vd(this,Z))for(const i of Vd(this,Z).keys())i.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return(null==(t=this.getActive())?void 0:t.shouldGetKeyboardEvents())||1===Vd(this,At).size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return Vd(this,U)===t}getActive(){return Vd(this,U)}getMode(){return Vd(this,yt)}isEditingMode(){return Vd(this,yt)!==fu.NONE}get imageManager(){return Gu(this,"imageManager",new Jp)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let l=0,h=e.rangeCount;l<h;l++)if(!t.contains(e.getRangeAt(l).commonAncestorContainer))return null;const{x:i,y:s,width:n,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(t,e,a,o)=>({x:(e-s)/r,y:1-(t+a-i)/n,width:o/r,height:a/n});break;case"180":a=(t,e,a,o)=>({x:1-(t+a-i)/n,y:1-(e+o-s)/r,width:a/n,height:o/r});break;case"270":a=(t,e,a,o)=>({x:1-(e+o-s)/r,y:(t-i)/n,width:o/r,height:a/n});break;default:a=(t,e,a,o)=>({x:(t-i)/n,y:(e-s)/r,width:a/n,height:o/r})}const o=[];for(let l=0,h=e.rangeCount;l<h;l++){const t=e.getRangeAt(l);if(!t.collapsed)for(const{x:e,y:i,width:s,height:n}of t.getClientRects())0!==s&&0!==n&&o.push(a(e,i,s,n))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(Vd(this,G)||qd(this,G,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;null==(e=Vd(this,G))||e.delete(t)}renderAnnotationElement(t){var e;const i=null==(e=Vd(this,G))?void 0:e.get(t.data.id);if(!i)return;const s=Vd(this,V).getRawValue(i);s&&(Vd(this,yt)!==fu.NONE||s.hasBeenModified)&&s.renderAnnotationElement(t)}setMissingCanvas(t,e,i){var s;const n=null==(s=Vd(this,wt))?void 0:s.get(t);n&&(n.setCanvas(e,i),Vd(this,wt).delete(t))}addMissingCanvas(t,e){(Vd(this,wt)||qd(this,wt,new Map)).set(t,e)}};O=new WeakMap,U=new WeakMap,H=new WeakMap,$=new WeakMap,j=new WeakMap,z=new WeakMap,V=new WeakMap,G=new WeakMap,q=new WeakMap,X=new WeakMap,Y=new WeakMap,K=new WeakMap,Q=new WeakMap,J=new WeakMap,Z=new WeakMap,tt=new WeakMap,et=new WeakMap,it=new WeakMap,st=new WeakMap,nt=new WeakMap,rt=new WeakMap,at=new WeakMap,ot=new WeakMap,lt=new WeakMap,ht=new WeakMap,ct=new WeakMap,dt=new WeakMap,ut=new WeakMap,pt=new WeakMap,gt=new WeakMap,ft=new WeakMap,mt=new WeakMap,vt=new WeakMap,wt=new WeakMap,bt=new WeakMap,yt=new WeakMap,At=new WeakMap,_t=new WeakMap,xt=new WeakMap,kt=new WeakMap,St=new WeakMap,Mt=new WeakMap,Et=new WeakMap,Ct=new WeakMap,Tt=new WeakMap,Pt=new WeakMap,Dt=new WeakMap,Rt=new WeakMap,It=new WeakMap,Lt=new WeakSet,Ft=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},Nt=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const i of Vd(this,j).values())if(i.hasTextLayer(t))return i;return null},Wt=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=Xd(this,Lt,Ft).call(this,t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(Vd(this,ct)||qd(this,ct,new Xp(this)),Vd(this,ct).show(e,i,"ltr"===this.direction))},Bt=function(){var t,e,i;const s=document.getSelection();if(!s||s.isCollapsed)return void(Vd(this,_t)&&(null==(t=Vd(this,ct))||t.hide(),qd(this,_t,null),Xd(this,Lt,Xt).call(this,{hasSelectedText:!1})));const{anchorNode:n}=s;if(n===Vd(this,_t))return;const r=Xd(this,Lt,Ft).call(this,s).closest(".textLayer");if(r){if(null==(i=Vd(this,ct))||i.hide(),qd(this,_t,n),Xd(this,Lt,Xt).call(this,{hasSelectedText:!0}),(Vd(this,yt)===fu.HIGHLIGHT||Vd(this,yt)===fu.NONE)&&(Vd(this,yt)===fu.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),qd(this,ht,this.isShiftKeyDown),!this.isShiftKeyDown)){const t=Vd(this,yt)===fu.HIGHLIGHT?Xd(this,Lt,Nt).call(this,r):null;if(null==t||t.toggleDrawing(),Vd(this,pt)){const e=new AbortController,i=this.combinedSignal(e),s=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),null==t||t.toggleDrawing(!0),"pointerup"===i.type&&Xd(this,Lt,Ot).call(this,"main_toolbar"))};window.addEventListener("pointerup",s,{signal:i}),window.addEventListener("blur",s,{signal:i})}else null==t||t.toggleDrawing(!0),Xd(this,Lt,Ot).call(this,"main_toolbar")}}else Vd(this,_t)&&(null==(e=Vd(this,ct))||e.hide(),qd(this,_t,null),Xd(this,Lt,Xt).call(this,{hasSelectedText:!1}))},Ot=function(t=""){Vd(this,yt)===fu.HIGHLIGHT?this.highlightSelection(t):Vd(this,it)&&Xd(this,Lt,Wt).call(this)},Ut=function(){document.addEventListener("selectionchange",Xd(this,Lt,Bt).bind(this),{signal:this._signal})},Ht=function(){if(Vd(this,ot))return;qd(this,ot,new AbortController);const t=this.combinedSignal(Vd(this,ot));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},$t=function(){var t;null==(t=Vd(this,ot))||t.abort(),qd(this,ot,null)},jt=function(){if(Vd(this,ft))return;qd(this,ft,new AbortController);const t=this.combinedSignal(Vd(this,ft));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},zt=function(){var t;null==(t=Vd(this,ft))||t.abort(),qd(this,ft,null)},Vt=function(){if(Vd(this,Y))return;qd(this,Y,new AbortController);const t=this.combinedSignal(Vd(this,Y));document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})},Gt=function(){var t;null==(t=Vd(this,Y))||t.abort(),qd(this,Y,null)},qt=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},Xt=function(t){Object.entries(t).some(([t,e])=>Vd(this,Et)[t]!==e)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(Vd(this,Et),t)}),Vd(this,yt)===fu.HIGHLIGHT&&!1===t.hasSelectedEditor&&Xd(this,Lt,Yt).call(this,[[mu.HIGHLIGHT_FREE,!0]]))},Yt=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},Kt=async function(){if(!Vd(this,ut)){qd(this,ut,!0);const t=[];for(const e of Vd(this,j).values())t.push(e.enable());await Promise.all(t);for(const e of Vd(this,$).values())e.enable()}},Qt=function(){if(this.unselectAll(),Vd(this,ut)){qd(this,ut,!1);for(const t of Vd(this,j).values())t.disable();for(const t of Vd(this,$).values())t.disable()}},Jt=function(t){const e=Vd(this,j).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Zt=function(){let t=null;for(t of Vd(this,At));return t},te=function(){if(0===Vd(this,$).size)return!0;if(1===Vd(this,$).size)for(const t of Vd(this,$).values())return t.isEmpty();return!1},ee=function(t){for(const e of Vd(this,At))e.unselect();Vd(this,At).clear();for(const e of t)e.isEmpty()||(Vd(this,At).add(e),e.select());Xd(this,Lt,Xt).call(this,{hasSelectedEditor:this.hasSelection})},jd(sg,"TRANSLATE_SMALL",1),jd(sg,"TRANSLATE_BIG",10);let ng=sg;const rg=class t{constructor(e){Gd(this,fe),Gd(this,ie,null),Gd(this,se,!1),Gd(this,ne,null),Gd(this,re,null),Gd(this,ae,null),Gd(this,oe,null),Gd(this,le,!1),Gd(this,he,null),Gd(this,ce,null),Gd(this,de,null),Gd(this,ue,null),Gd(this,pe,!1),qd(this,ce,e),qd(this,pe,e._uiManager.useNewAltTextFlow),Vd(t,ge)||qd(t,ge,Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(e){t._l10n??(t._l10n=e)}async render(){const e=qd(this,ne,document.createElement("button"));e.className="altText",e.tabIndex="0";const i=qd(this,re,document.createElement("span"));e.append(i),Vd(this,pe)?(e.classList.add("new"),e.setAttribute("data-l10n-id",Vd(t,ge).missing),i.setAttribute("data-l10n-id",Vd(t,ge)["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),i.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=Vd(this,ce)._uiManager._signal;e.addEventListener("contextmenu",Mp,{signal:s}),e.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:s});const n=t=>{t.preventDefault(),Vd(this,ce)._uiManager.editAltText(Vd(this,ce)),Vd(this,pe)&&Vd(this,ce)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:Vd(this,fe,me)}})};return e.addEventListener("click",n,{capture:!0,signal:s}),e.addEventListener("keydown",t=>{t.target===e&&"Enter"===t.key&&(qd(this,le,!0),n(t))},{signal:s}),await Xd(this,fe,ve).call(this),e}finish(){Vd(this,ne)&&(Vd(this,ne).focus({focusVisible:Vd(this,le)}),qd(this,le,!1))}isEmpty(){return Vd(this,pe)?null===Vd(this,ie):!Vd(this,ie)&&!Vd(this,se)}hasData(){return Vd(this,pe)?null!==Vd(this,ie)||!!Vd(this,de):this.isEmpty()}get guessedText(){return Vd(this,de)}async setGuessedText(e){null===Vd(this,ie)&&(qd(this,de,e),qd(this,ue,await t._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e})),Xd(this,fe,ve).call(this))}toggleAltTextBadge(t=!1){var e;if(!Vd(this,pe)||Vd(this,ie))return null==(e=Vd(this,he))||e.remove(),void qd(this,he,null);if(!Vd(this,he)){const t=qd(this,he,document.createElement("div"));t.className="noAltTextBadge",Vd(this,ce).div.append(t)}Vd(this,he).classList.toggle("hidden",!t)}serialize(t){let e=Vd(this,ie);return t||Vd(this,de)!==e||(e=Vd(this,ue)),{altText:e,decorative:Vd(this,se),guessedText:Vd(this,de),textWithDisclaimer:Vd(this,ue)}}get data(){return{altText:Vd(this,ie),decorative:Vd(this,se)}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:n=!1}){i&&(qd(this,de,i),qd(this,ue,s)),Vd(this,ie)===t&&Vd(this,se)===e||(n||(qd(this,ie,t),qd(this,se,e)),Xd(this,fe,ve).call(this))}toggle(t=!1){Vd(this,ne)&&(!t&&Vd(this,oe)&&(clearTimeout(Vd(this,oe)),qd(this,oe,null)),Vd(this,ne).disabled=!t)}shown(){Vd(this,ce)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:Vd(this,fe,me)}})}destroy(){var t,e;null==(t=Vd(this,ne))||t.remove(),qd(this,ne,null),qd(this,re,null),qd(this,ae,null),null==(e=Vd(this,he))||e.remove(),qd(this,he,null)}};ie=new WeakMap,se=new WeakMap,ne=new WeakMap,re=new WeakMap,ae=new WeakMap,oe=new WeakMap,le=new WeakMap,he=new WeakMap,ce=new WeakMap,de=new WeakMap,ue=new WeakMap,pe=new WeakMap,ge=new WeakMap,fe=new WeakSet,me=function(){return(Vd(this,ie)?"added":null===Vd(this,ie)&&this.guessedText&&"review")||"missing"},ve=async function(){var t,e,i;const s=Vd(this,ne);if(!s)return;if(Vd(this,pe)){if(s.classList.toggle("done",!!Vd(this,ie)),s.setAttribute("data-l10n-id",Vd(rg,ge)[Vd(this,fe,me)]),null==(t=Vd(this,re))||t.setAttribute("data-l10n-id",Vd(rg,ge)[`${Vd(this,fe,me)}-label`]),!Vd(this,ie))return void(null==(e=Vd(this,ae))||e.remove())}else{if(!Vd(this,ie)&&!Vd(this,se))return s.classList.remove("done"),void(null==(i=Vd(this,ae))||i.remove());s.classList.add("done"),s.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let n=Vd(this,ae);if(!n){qd(this,ae,n=document.createElement("span")),n.className="tooltip",n.setAttribute("role","tooltip"),n.id=`alt-text-tooltip-${Vd(this,ce).id}`;const t=100,e=Vd(this,ce)._uiManager._signal;e.addEventListener("abort",()=>{clearTimeout(Vd(this,oe)),qd(this,oe,null)},{once:!0}),s.addEventListener("mouseenter",()=>{qd(this,oe,setTimeout(()=>{qd(this,oe,null),Vd(this,ae).classList.add("show"),Vd(this,ce)._reportTelemetry({action:"alt_text_tooltip"})},t))},{signal:e}),s.addEventListener("mouseleave",()=>{var t;Vd(this,oe)&&(clearTimeout(Vd(this,oe)),qd(this,oe,null)),null==(t=Vd(this,ae))||t.classList.remove("show")},{signal:e})}Vd(this,se)?n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(n.removeAttribute("data-l10n-id"),n.textContent=Vd(this,ie)),n.parentNode||s.append(n);const r=Vd(this,ce).getElementForAltText();null==r||r.setAttribute("aria-describedby",n.id)},Gd(rg,ge,null),jd(rg,"_l10n",null);let ag=rg;class og{constructor(t){Gd(this,Ce),Gd(this,we,null),Gd(this,be,null),Gd(this,ye,!1),Gd(this,Ae,null),Gd(this,_e,null),Gd(this,xe,null),Gd(this,ke,null),Gd(this,Se,null),Gd(this,Me,!1),Gd(this,Ee,null),qd(this,Ae,t)}renderForToolbar(){const t=qd(this,be,document.createElement("button"));return t.className="comment",Xd(this,Ce,Te).call(this,t,!1)}renderForStandalone(){const t=qd(this,we,document.createElement("button"));t.className="annotationCommentButton";const e=Vd(this,Ae).commentButtonPosition;if(e){const{style:i}=t;i.insetInlineEnd=`calc(${100*("ltr"===Vd(this,Ae)._uiManager.direction?1-e[0]:e[0])}% - var(--comment-button-dim))`,i.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const s=Vd(this,Ae).commentButtonColor;s&&(i.backgroundColor=s)}return Xd(this,Ce,Te).call(this,t,!0)}focusButton(){setTimeout(()=>{var t;null==(t=Vd(this,we)??Vd(this,be))||t.focus()},0)}onUpdatedColor(){if(!Vd(this,we))return;const t=Vd(this,Ae).commentButtonColor;t&&(Vd(this,we).style.backgroundColor=t),Vd(this,Ae)._uiManager.updatePopupColor(Vd(this,Ae))}get commentButtonWidth(){var t;return((null==(t=Vd(this,we))?void 0:t.getBoundingClientRect().width)??0)/Vd(this,Ae).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(Vd(this,Ee))return Vd(this,Ee);if(!Vd(this,we))return null;const{x:t,y:e,height:i}=Vd(this,we).getBoundingClientRect(),{x:s,y:n,width:r,height:a}=Vd(this,Ae).parent.boundingClientRect;return[(t-s)/r,(e+i-n)/a]}set commentPopupPositionInLayer(t){qd(this,Ee,t)}hasDefaultPopupPosition(){return null===Vd(this,Ee)}removeStandaloneCommentButton(){var t;null==(t=Vd(this,we))||t.remove(),qd(this,we,null)}removeToolbarCommentButton(){var t;null==(t=Vd(this,be))||t.remove(),qd(this,be,null)}setCommentButtonStates({selected:t,hasPopup:e}){Vd(this,we)&&(Vd(this,we).classList.toggle("selected",t),Vd(this,we).ariaExpanded=e)}edit(t){const e=this.commentPopupPositionInLayer;let i,s;if(e)[i,s]=e;else{[i,s]=Vd(this,Ae).commentButtonPosition;const{width:t,height:e,x:n,y:r}=Vd(this,Ae);i=n+i*t,s=r+s*e}const n=Vd(this,Ae).parent.boundingClientRect,{x:r,y:a,width:o,height:l}=n;Vd(this,Ae)._uiManager.editComment(Vd(this,Ae),r+i*o,a+s*l,{...t,parentDimensions:n})}finish(){Vd(this,be)&&(Vd(this,be).focus({focusVisible:Vd(this,ye)}),qd(this,ye,!1))}isDeleted(){return Vd(this,Me)||""===Vd(this,ke)}isEmpty(){return null===Vd(this,ke)}hasBeenEdited(){return this.isDeleted()||Vd(this,ke)!==Vd(this,_e)}serialize(){return this.data}get data(){return{text:Vd(this,ke),richText:Vd(this,xe),date:Vd(this,Se),deleted:this.isDeleted()}}set data(t){if(t!==Vd(this,ke)&&qd(this,xe,null),null===t)return qd(this,ke,""),void qd(this,Me,!0);qd(this,ke,t),qd(this,Se,new Date),qd(this,Me,!1)}setInitialText(t,e=null){qd(this,_e,t),this.data=t,qd(this,Se,null),qd(this,xe,e)}shown(){}destroy(){var t,e;null==(t=Vd(this,be))||t.remove(),qd(this,be,null),null==(e=Vd(this,we))||e.remove(),qd(this,we,null),qd(this,ke,""),qd(this,xe,null),qd(this,Se,null),qd(this,Ae,null),qd(this,ye,!1),qd(this,Me,!1)}}we=new WeakMap,be=new WeakMap,ye=new WeakMap,Ae=new WeakMap,_e=new WeakMap,xe=new WeakMap,ke=new WeakMap,Se=new WeakMap,Me=new WeakMap,Ee=new WeakMap,Ce=new WeakSet,Te=function(t,e){if(!Vd(this,Ae)._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[Vd(this,Ae)._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button"));const i=Vd(this,Ae)._uiManager._signal;if(!(i instanceof AbortSignal)||i.aborted)return t;t.addEventListener("contextmenu",Mp,{signal:i}),e&&(t.addEventListener("focusin",t=>{Vd(this,Ae)._focusEventsAllowed=!1,Ep(t)},{capture:!0,signal:i}),t.addEventListener("focusout",t=>{Vd(this,Ae)._focusEventsAllowed=!0,Ep(t)},{capture:!0,signal:i})),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});const s=e=>{e.preventDefault(),t===Vd(this,be)?this.edit():Vd(this,Ae).toggleComment(!0)};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(qd(this,ye,!0),s(e))},{signal:i}),t.addEventListener("pointerenter",()=>{Vd(this,Ae).toggleComment(!1,!0)},{signal:i}),t.addEventListener("pointerleave",()=>{Vd(this,Ae).toggleComment(!1,!1)},{signal:i}),t};const lg=class{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:r=null,signal:a}){Gd(this,$e),Gd(this,Pe),Gd(this,De,!1),Gd(this,Re,null),Gd(this,Ie),Gd(this,Le),Gd(this,Fe),Gd(this,Ne),Gd(this,We,null),Gd(this,Be),Gd(this,Oe,null),Gd(this,Ue),Gd(this,He,null),qd(this,Pe,t),qd(this,Re,i),qd(this,Ie,e),qd(this,Le,s),qd(this,Fe,n),qd(this,Ne,r),qd(this,Ue,new AbortController),qd(this,Be,AbortSignal.any([a,Vd(this,Ue).signal])),t.addEventListener("touchstart",Xd(this,$e,je).bind(this),{passive:!1,signal:Vd(this,Be)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Lp.pixelRatio}destroy(){var t,e;null==(t=Vd(this,Ue))||t.abort(),qd(this,Ue,null),null==(e=Vd(this,We))||e.abort(),qd(this,We,null)}};Pe=new WeakMap,De=new WeakMap,Re=new WeakMap,Ie=new WeakMap,Le=new WeakMap,Fe=new WeakMap,Ne=new WeakMap,We=new WeakMap,Be=new WeakMap,Oe=new WeakMap,Ue=new WeakMap,He=new WeakMap,$e=new WeakSet,je=function(t){var e,i,s;if(null==(e=Vd(this,Ie))?void 0:e.call(this))return;if(1===t.touches.length){if(Vd(this,We))return;const t=qd(this,We,new AbortController),e=AbortSignal.any([Vd(this,Be),t.signal]),i=Vd(this,Pe),s={capture:!0,signal:e,passive:!1},n=t=>{var e;"touch"===t.pointerType&&(null==(e=Vd(this,We))||e.abort(),qd(this,We,null))};return i.addEventListener("pointerdown",t=>{"touch"===t.pointerType&&(Ep(t),n(t))},s),i.addEventListener("pointerup",n,s),void i.addEventListener("pointercancel",n,s)}if(!Vd(this,He)){qd(this,He,new AbortController);const t=AbortSignal.any([Vd(this,Be),Vd(this,He).signal]),e=Vd(this,Pe),s={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",Xd(this,$e,ze).bind(this),s);const n=Xd(this,$e,Ve).bind(this);e.addEventListener("touchend",n,s),e.addEventListener("touchcancel",n,s),s.capture=!0,e.addEventListener("pointerdown",Ep,s),e.addEventListener("pointermove",Ep,s),e.addEventListener("pointercancel",Ep,s),e.addEventListener("pointerup",Ep,s),null==(i=Vd(this,Le))||i.call(this)}if(Ep(t),2!==t.touches.length||(null==(s=Vd(this,Re))?void 0:s.call(this)))return void qd(this,Oe,null);let[n,r]=t.touches;n.identifier>r.identifier&&([n,r]=[r,n]),qd(this,Oe,{touch0X:n.screenX,touch0Y:n.screenY,touch1X:r.screenX,touch1Y:r.screenY})},ze=function(t){var e;if(!Vd(this,Oe)||2!==t.touches.length)return;Ep(t);let[i,s]=t.touches;i.identifier>s.identifier&&([i,s]=[s,i]);const{screenX:n,screenY:r}=i,{screenX:a,screenY:o}=s,l=Vd(this,Oe),{touch0X:h,touch0Y:c,touch1X:d,touch1Y:u}=l,p=d-h,g=u-c,f=a-n,m=o-r,v=Math.hypot(f,m)||1,w=Math.hypot(p,g)||1;if(!Vd(this,De)&&Math.abs(w-v)<=lg.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=n,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,!Vd(this,De))return void qd(this,De,!0);const b=[(n+a)/2,(r+o)/2];null==(e=Vd(this,Fe))||e.call(this,b,w,v)},Ve=function(t){var e;t.touches.length>=2||(Vd(this,He)&&(Vd(this,He).abort(),qd(this,He,null),null==(e=Vd(this,Ne))||e.call(this)),Vd(this,Oe)&&(Ep(t),qd(this,Oe,null),qd(this,De,!1)))};let hg=lg;const cg=class t{constructor(e){Gd(this,wi),Gd(this,Ge,null),Gd(this,qe,null),Gd(this,Xe,null),Gd(this,Ye,null),Gd(this,Ke,null),Gd(this,Qe,!1),Gd(this,Je,null),Gd(this,Ze,""),Gd(this,ti,null),Gd(this,ei,null),Gd(this,ii,null),Gd(this,si,null),Gd(this,ni,null),Gd(this,ri,""),Gd(this,ai,!1),Gd(this,oi,null),Gd(this,li,!1),Gd(this,hi,!1),Gd(this,ci,!1),Gd(this,di,null),Gd(this,ui,0),Gd(this,pi,0),Gd(this,gi,null),Gd(this,fi,null),jd(this,"isSelected",!1),jd(this,"_isCopy",!1),jd(this,"_editToolbar",null),jd(this,"_initialOptions",Object.create(null)),jd(this,"_initialData",null),jd(this,"_isVisible",!0),jd(this,"_uiManager",null),jd(this,"_focusEventsAllowed",!0),Gd(this,mi,!1),Gd(this,vi,t._zIndex++),this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null,this.annotationElementId=e.annotationElementId||null,this.creationDate=e.creationDate||new Date,this.modificationDate=e.modificationDate||null;const{rotation:i,rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:a}}=this.parent.viewport;this.rotation=i,this.pageRotation=(360+i-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,n],this.pageTranslation=[r,a];const[o,l]=this.parentDimensions;this.x=e.x/o,this.y=e.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const e=t.prototype._resizeWithKeyboard,i=ng.TRANSLATE_SMALL,s=ng.TRANSLATE_BIG;return Gu(this,"_resizerKeyboardManager",new tg([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-i,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[i,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-i]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,i]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,s]}],[["Escape","mac+Escape"],t.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return Gu(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new ug({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(e,i){if(t._l10n??(t._l10n=e),t._l10nResizer||(t._l10nResizer=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"})),-1!==t._borderLineWidth)return;const s=getComputedStyle(document.documentElement);t._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){$u("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return Vd(this,mi)}set _isDraggable(t){var e;qd(this,mi,t),null==(e=this.div)||e.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=Vd(this,vi)}setParent(t){var e;null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(Xd(this,wi,Bi).call(this),null==(e=Vd(this,si))||e.remove(),qd(this,si,null)),this.parent=t}focusin(t){this._focusEventsAllowed&&(Vd(this,ai)?qd(this,ai,!1):this.parent.setSelected(this))}focusout(t){var e;if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const i=t.relatedTarget;(null==i?void 0:i.closest(`#${this.id}`))||(t.preventDefault(),(null==(e=this.parent)?void 0:e.isMultipleSelection)||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){const[n,r]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/r,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s),this._onTranslated()}translate(t,e){Xd(this,wi,bi).call(this,this.parentDimensions,t,e)}translateInPage(t,e){Vd(this,oi)||qd(this,oi,[this.x,this.y,this.width,this.height]),Xd(this,wi,bi).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){Vd(this,oi)||qd(this,oi,[this.x,this.y,this.width,this.height]);const{div:i,parentDimensions:[s,n]}=this;if(this.x+=t/s,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:a}=this;const[o,l]=this.getBaseTranslation();r+=o,a+=l;const{style:h}=i;h.left=`${(100*r).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!Vd(this,oi)&&(Vd(this,oi)[0]!==this.x||Vd(this,oi)[1]!==this.y)}get _hasBeenResized(){return!!Vd(this,oi)&&(Vd(this,oi)[2]!==this.width||Vd(this,oi)[3]!==this.height)}getBaseTranslation(){const[e,i]=this.parentDimensions,{_borderLineWidth:s}=t,n=s/e,r=s/i;switch(this.rotation){case 90:return[-n,r];case 180:return[n,r];case 270:return[n,-r];default:return[-n,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[i,s]}=this;let{x:n,y:r,width:a,height:o}=this;if(a*=i,o*=s,n*=i,r*=s,this._mustFixPosition)switch(t){case 0:n=cp(n,0,i-a),r=cp(r,0,s-o);break;case 90:n=cp(n,0,i-o),r=cp(r,a,s);break;case 180:n=cp(n,a,i),r=cp(r,o,s);break;case 270:n=cp(n,o,i),r=cp(r,0,s-a)}this.x=n/=i,this.y=r/=s;const[l,h]=this.getBaseTranslation();n+=l,r+=h,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(e,i){var s;return Xd(s=t,yi,Ai).call(s,e,i,this.parentRotation)}pageTranslationToScreen(e,i){var s;return Xd(s=t,yi,Ai).call(s,e,i,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(){const{div:{style:t},width:e,height:i}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*i).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(1e4*t)/1e4}_onResizing(){}altTextFinish(){var t;null==(t=Vd(this,Xe))||t.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||Vd(this,hi))return this._editToolbar;this._editToolbar=new qp(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,i]of t)await this._editToolbar.addButton(e,i);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){var t;null==(t=this._editToolbar)||t.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){var t;null==(t=this._editToolbar)||t.removeButton("comment")}removeEditToolbar(){var t,e;null==(t=this._editToolbar)||t.remove(),this._editToolbar=null,null==(e=Vd(this,Xe))||e.destroy()}addContainer(t){var e;const i=null==(e=this._editToolbar)?void 0:e.div;i?i.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return Vd(this,Xe)||(ag.initialize(t._l10n),qd(this,Xe,new ag(this)),Vd(this,Ge)&&(Vd(this,Xe).data=Vd(this,Ge),qd(this,Ge,null))),Vd(this,Xe)}get altTextData(){var t;return null==(t=Vd(this,Xe))?void 0:t.data}set altTextData(t){Vd(this,Xe)&&(Vd(this,Xe).data=t)}get guessedAltText(){var t;return null==(t=Vd(this,Xe))?void 0:t.guessedText}async setGuessedAltText(t){var e;await(null==(e=Vd(this,Xe))?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return null==(e=Vd(this,Xe))?void 0:e.serialize(t)}hasAltText(){return!!Vd(this,Xe)&&!Vd(this,Xe).isEmpty()}hasAltTextData(){var t;return(null==(t=Vd(this,Xe))?void 0:t.hasData())??!1}focusCommentButton(){var t;null==(t=Vd(this,Ye))||t.focusButton()}addCommentButton(){return Vd(this,Ye)||qd(this,Ye,new og(this))}addStandaloneCommentButton(){Vd(this,Ke)?this._uiManager.isEditingMode()&&Vd(this,Ke).classList.remove("hidden"):this.hasComment&&(qd(this,Ke,Vd(this,Ye).renderForStandalone()),this.div.append(Vd(this,Ke)))}removeStandaloneCommentButton(){Vd(this,Ye).removeStandaloneCommentButton(),qd(this,Ke,null)}hideStandaloneCommentButton(){var t;null==(t=Vd(this,Ke))||t.classList.add("hidden")}get comment(){const{data:{richText:t,text:e,date:i,deleted:s}}=Vd(this,Ye);return{text:e,richText:t,date:i,deleted:s,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){Vd(this,Ye)||qd(this,Ye,new og(this)),Vd(this,Ye).data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:i}){if(!e)return;if(Vd(this,Ye)||qd(this,Ye,new og(this)),Vd(this,Ye).setInitialText(t,i),!this.annotationElementId)return;const s=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);s&&this.updateFromAnnotationLayer(s)}get hasEditedComment(){var t;return null==(t=Vd(this,Ye))?void 0:t.hasBeenEdited()}get hasDeletedComment(){var t;return null==(t=Vd(this,Ye))?void 0:t.isDeleted()}get hasComment(){return!!Vd(this,Ye)&&!Vd(this,Ye).isEmpty()&&!Vd(this,Ye).isDeleted()}async editComment(t){Vd(this,Ye)||qd(this,Ye,new og(this)),Vd(this,Ye).edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){Vd(this,Ye).setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const e=180,i=100,[,,,s]=t.rect,[n]=this.pageDimensions,[r]=this.pageTranslation,a=r+n+1,o=s-i,l=a+e;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[a,o,l,s]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){Vd(this,Ye).data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){var t;const e=this.div=document.createElement("div");e.setAttribute("data-editor-rotation",(360-this.rotation)%360),e.className=this.name,e.setAttribute("id",this.id),e.tabIndex=Vd(this,Qe)?-1:0,e.setAttribute("role","application"),this.defaultL10nId&&e.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||e.classList.add("hidden"),this.setInForeground(),Xd(this,wi,Ii).call(this);const[i,s]=this.parentDimensions;this.parentRotation%180!=0&&(e.style.maxWidth=`${(100*s/i).toFixed(2)}%`,e.style.maxHeight=`${(100*i/s).toFixed(2)}%`);const[n,r]=this.getInitialTranslation();return this.translate(n,r),Yp(this,e,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(Vd(this,fi)||qd(this,fi,new hg({container:e,isPinchingDisabled:()=>!this.isSelected,onPinchStart:Xd(this,wi,Ci).bind(this),onPinching:Xd(this,wi,Ti).bind(this),onPinchEnd:Xd(this,wi,Pi).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),null==(t=this._uiManager._editorUndoBar)||t.hide(),e}pointerdown(t){const{isMac:e}=ip.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(qd(this,ai,!0),this._isDraggable?Xd(this,wi,Ri).call(this,t):Xd(this,wi,Di).call(this,t))}_onStartDragging(){}_onStopDragging(){}moveInDOM(){Vd(this,di)&&clearTimeout(Vd(this,di)),qd(this,di,setTimeout(()=>{var t;qd(this,di,null),null==(t=this.parent)||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){const s=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/s,h=e/s,c=this.x*n,d=this.y*r,u=this.width*n,p=this.height*r;switch(i){case 0:return[c+l+a,r-d-h-p+o,c+l+u+a,r-d-h+o];case 90:return[c+h+a,r-d+l+o,c+h+p+a,r-d+l+u+o];case 180:return[c-l-u+a,r-d+h+o,c-l+a,r-d+h+p+o];case 270:return[c-h-p+a,r-d-l-u+o,c-h+a,r-d-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,s,n,r]=t,a=n-i,o=r-s;switch(this.rotation){case 0:return[i,e-r,a,o];case 90:return[i,e-s,o,a];case 180:return[n,e-s,a,o];case 270:return[n,e-r,o,a];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&t._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var t;null==(t=Vd(this,Ye))||t.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:i,opacity:s,deleted:n,richText:r},uid:a,pageIndex:o,creationDate:l,modificationDate:h}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:r,contentsObj:{str:t},creationDate:l,modificationDate:i||h,popupRef:!n,color:e,opacity:s}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),qd(this,hi,!0),!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),qd(this,hi,!1),!0)}isInEditMode(){return Vd(this,hi)}shouldGetKeyboardEvents(){return Vd(this,ci)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&s>0&&t<n&&i>0}rebuild(){Xd(this,wi,Ii).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:(null==(t=this._initialData)?void 0:t.popupRef)||""}}serialize(t=!1,e=null){var i;return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:(null==(i=this._initialData)?void 0:i.popupRef)||""}}static async deserialize(t,e,i){const s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});s.rotation=t.rotation,qd(s,Ge,t.accessibilityData),s._isCopy=t.isCopy||!1;const[n,r]=s.pageDimensions,[a,o,l,h]=s.getRectInCurrentCoords(t.rect,r);return s.x=a/n,s.y=o/r,s.width=l/n,s.height=h/r,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){var t,e;if(null==(t=Vd(this,ni))||t.abort(),qd(this,ni,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),Vd(this,di)&&(clearTimeout(Vd(this,di)),qd(this,di,null)),Xd(this,wi,Bi).call(this),this.removeEditToolbar(),Vd(this,gi)){for(const t of Vd(this,gi).values())clearTimeout(t);qd(this,gi,null)}this.parent=null,null==(e=Vd(this,fi))||e.destroy(),qd(this,fi,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(Xd(this,wi,xi).call(this),Vd(this,ti).classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return"ltr"===this._uiManager.direction?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[e,i]}=this,[s,n,r,a]=this.getPDFRect();return[t._round(s+(r-s)*e),t._round(n+(a-n)*(1-i))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return Vd(this,Ye).commentPopupPositionInLayer}set commentPopupPosition(t){Vd(this,Ye).commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return Vd(this,Ye).hasDefaultPopupPosition()}get commentButtonWidth(){return Vd(this,Ye).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){Vd(this,Ye).setCommentButtonStates(t)}keydown(e){if(!this.isResizable||e.target!==this.div||"Enter"!==e.key)return;this._uiManager.setSelected(this),qd(this,ii,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const i=Vd(this,ti).children;if(!Vd(this,qe)){qd(this,qe,Array.from(i));const e=Xd(this,wi,Li).bind(this),s=Xd(this,wi,Fi).bind(this),n=this._uiManager._signal;for(const i of Vd(this,qe)){const r=i.getAttribute("data-resizer-name");i.setAttribute("role","spinbutton"),i.addEventListener("keydown",e,{signal:n}),i.addEventListener("blur",s,{signal:n}),i.addEventListener("focus",Xd(this,wi,Ni).bind(this,r),{signal:n}),i.setAttribute("data-l10n-id",t._l10nResizer[r])}}const s=Vd(this,qe)[0];let n=0;for(const t of i){if(t===s)break;n++}const r=(360-this.rotation+this.parentRotation)%360/90*(Vd(this,qe).length/4);if(r!==n){if(r<n)for(let t=0;t<n-r;t++)Vd(this,ti).append(Vd(this,ti).firstChild);else if(r>n)for(let t=0;t<r-n;t++)Vd(this,ti).firstChild.before(Vd(this,ti).lastChild);let e=0;for(const s of i){const i=Vd(this,qe)[e++].getAttribute("data-resizer-name");s.setAttribute("data-l10n-id",t._l10nResizer[i])}}Xd(this,wi,Wi).call(this,0),qd(this,ci,!0),Vd(this,ti).firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}_resizeWithKeyboard(t,e){Vd(this,ci)&&Xd(this,wi,Ei).call(this,Vd(this,ri),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){Xd(this,wi,Bi).call(this),this.div.focus()}select(){var t,e,i;this.isSelected&&this._editToolbar?this._editToolbar.show():(this.isSelected=!0,this.makeResizable(),null==(t=this.div)||t.classList.add("selectedEditor"),this._editToolbar?(null==(e=this._editToolbar)||e.show(),null==(i=Vd(this,Xe))||i.toggleAltTextBadge(!1)):this.addEditToolbar().then(()=>{var t,e;(null==(t=this.div)?void 0:t.classList.contains("selectedEditor"))&&(null==(e=this._editToolbar)||e.show())}))}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>{var t;return null==(t=this.div)?void 0:t.focus({preventScroll:!0})},0)}unselect(){var t,e,i,s,n;this.isSelected&&(this.isSelected=!1,null==(t=Vd(this,ti))||t.classList.add("hidden"),null==(e=this.div)||e.classList.remove("selectedEditor"),(null==(i=this.div)?void 0:i.contains(document.activeElement))&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),null==(s=this._editToolbar)||s.hide(),null==(n=Vd(this,Xe))||n.toggleAltTextBadge(!0),this.hasComment&&this._uiManager.toggleComment(this,!1,!1))}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){"BUTTON"!==t.target.nodeName&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return Vd(this,li)}set isEditing(t){qd(this,li,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,i=!1){if(i){Vd(this,gi)||qd(this,gi,new Map);const{action:i}=e;let s=Vd(this,gi).get(i);return s&&clearTimeout(s),s=setTimeout(()=>{this._reportTelemetry(e),Vd(this,gi).delete(i),0===Vd(this,gi).size&&qd(this,gi,null)},t._telemetryTimeout),void Vd(this,gi).set(i,s)}e.type||(e.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),qd(this,Qe,!1)}disable(){this.div&&(this.div.tabIndex=-1),qd(this,Qe,!0)}updateFakeAnnotationElement(t){if(Vd(this,si)||this.deleted)return this.deleted?(Vd(this,si).remove(),void qd(this,si,null)):void((this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&Vd(this,si).updateEdited({rect:this.getPDFRect(),popup:this.comment}));qd(this,si,t.addFakeAnnotation(this))}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===(null==e?void 0:e.nodeName)&&e.classList.contains("annotationContent")&&e.remove()}};Ge=new WeakMap,qe=new WeakMap,Xe=new WeakMap,Ye=new WeakMap,Ke=new WeakMap,Qe=new WeakMap,Je=new WeakMap,Ze=new WeakMap,ti=new WeakMap,ei=new WeakMap,ii=new WeakMap,si=new WeakMap,ni=new WeakMap,ri=new WeakMap,ai=new WeakMap,oi=new WeakMap,li=new WeakMap,hi=new WeakMap,ci=new WeakMap,di=new WeakMap,ui=new WeakMap,pi=new WeakMap,gi=new WeakMap,fi=new WeakMap,mi=new WeakMap,vi=new WeakMap,wi=new WeakSet,bi=function([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},yi=new WeakSet,Ai=function(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},_i=function(t){switch(t){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}},xi=function(){if(Vd(this,ti))return;qd(this,ti,document.createElement("div")),Vd(this,ti).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const i of t){const t=document.createElement("div");Vd(this,ti).append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",Xd(this,wi,ki).bind(this,i),{signal:e}),t.addEventListener("contextmenu",Mp,{signal:e}),t.tabIndex=-1}this.div.prepend(Vd(this,ti))},ki=function(t,e){var i;e.preventDefault();const{isMac:s}=ip.platform;if(0!==e.button||e.ctrlKey&&s)return;null==(i=Vd(this,Xe))||i.toggle(!1);const n=this._isDraggable;this._isDraggable=!1,qd(this,ei,[e.screenX,e.screenY]);const r=new AbortController,a=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",Xd(this,wi,Ei).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Ep,{passive:!1,signal:a}),window.addEventListener("contextmenu",Mp,{signal:a}),qd(this,ii,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const h=()=>{var t;r.abort(),this.parent.togglePointerEvents(!0),null==(t=Vd(this,Xe))||t.toggle(!0),this._isDraggable=n,this.parent.div.style.cursor=o,this.div.style.cursor=l,Xd(this,wi,Mi).call(this)};window.addEventListener("pointerup",h,{signal:a}),window.addEventListener("blur",h,{signal:a})},Si=function(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()},Mi=function(){if(!Vd(this,ii))return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=Vd(this,ii);qd(this,ii,null);const n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===i&&o===s||this.addCommands({cmd:Xd(this,wi,Si).bind(this,n,r,a,o),undo:Xd(this,wi,Si).bind(this,t,e,i,s),mustExec:!0})},Ei=function(t,e){const[i,s]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,l=cg.MIN_SIZE/i,h=cg.MIN_SIZE/s,c=Xd(this,wi,_i).call(this,this.rotation),d=(t,e)=>[c[0]*t+c[2]*e,c[1]*t+c[3]*e],u=Xd(this,wi,_i).call(this,360-this.rotation);let p,g,f=!1,m=!1;switch(t){case"topLeft":f=!0,p=(t,e)=>[0,0],g=(t,e)=>[t,e];break;case"topMiddle":p=(t,e)=>[t/2,0],g=(t,e)=>[t/2,e];break;case"topRight":f=!0,p=(t,e)=>[t,0],g=(t,e)=>[0,e];break;case"middleRight":m=!0,p=(t,e)=>[t,e/2],g=(t,e)=>[0,e/2];break;case"bottomRight":f=!0,p=(t,e)=>[t,e],g=(t,e)=>[0,0];break;case"bottomMiddle":p=(t,e)=>[t/2,e],g=(t,e)=>[t/2,0];break;case"bottomLeft":f=!0,p=(t,e)=>[0,e],g=(t,e)=>[t,0];break;case"middleLeft":m=!0,p=(t,e)=>[0,e/2],g=(t,e)=>[t,e/2]}const v=p(a,o),w=g(a,o);let b=d(...w);const y=cg._round(n+b[0]),A=cg._round(r+b[1]);let _,x,k=1,S=1;if(e.fromKeyboard)({deltaX:_,deltaY:x}=e);else{const{screenX:t,screenY:i}=e,[s,n]=Vd(this,ei);[_,x]=this.screenToPageTranslation(t-s,i-n),Vd(this,ei)[0]=t,Vd(this,ei)[1]=i}var M,E;if([_,x]=(M=_/i,E=x/s,[u[0]*M+u[2]*E,u[1]*M+u[3]*E]),f){const t=Math.hypot(a,o);k=S=Math.max(Math.min(Math.hypot(w[0]-v[0]-_,w[1]-v[1]-x)/t,1/a,1/o),l/a,h/o)}else m?k=cp(Math.abs(w[0]-v[0]-_),l,1)/a:S=cp(Math.abs(w[1]-v[1]-x),h,1)/o;const C=cg._round(a*k),T=cg._round(o*S);b=d(...g(C,T));const P=y-b[0],D=A-b[1];Vd(this,oi)||qd(this,oi,[this.x,this.y,this.width,this.height]),this.width=C,this.height=T,this.x=P,this.y=D,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Ci=function(){var t;qd(this,ii,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),null==(t=Vd(this,Xe))||t.toggle(!1),this.parent.togglePointerEvents(!1)},Ti=function(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;const n=Xd(this,wi,_i).call(this,this.rotation),r=(t,e)=>[n[0]*t+n[2]*e,n[1]*t+n[3]*e],[a,o]=this.parentDimensions,l=this.x,h=this.y,c=this.width,d=this.height,u=cg.MIN_SIZE/a,p=cg.MIN_SIZE/o;s=Math.max(Math.min(s,1/c,1/d),u/c,p/d);const g=cg._round(c*s),f=cg._round(d*s);if(g===c&&f===d)return;Vd(this,oi)||qd(this,oi,[l,h,c,d]);const m=r(c/2,d/2),v=cg._round(l+m[0]),w=cg._round(h+m[1]),b=r(g/2,f/2);this.x=v-b[0],this.y=w-b[1],this.width=g,this.height=f,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Pi=function(){var t;null==(t=Vd(this,Xe))||t.toggle(!0),this.parent.togglePointerEvents(!0),Xd(this,wi,Mi).call(this)},Di=function(t){const{isMac:e}=ip.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Ri=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const s=new AbortController,n=this._uiManager.combinedSignal(s),r={capture:!0,passive:!1,signal:n},a=t=>{s.abort(),qd(this,Je,null),qd(this,ai,!1),this._uiManager.endDragSession()||Xd(this,wi,Di).call(this,t),i&&this._onStopDragging()};e&&(qd(this,ui,t.clientX),qd(this,pi,t.clientY),qd(this,Je,t.pointerId),qd(this,Ze,t.pointerType),window.addEventListener("pointermove",t=>{i||(i=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:e,clientY:s,pointerId:n}=t;if(n!==Vd(this,Je))return void Ep(t);const[r,a]=this.screenToPageTranslation(e-Vd(this,ui),s-Vd(this,pi));qd(this,ui,e),qd(this,pi,s),this._uiManager.dragSelectedEditors(r,a)},r),window.addEventListener("touchmove",Ep,r),window.addEventListener("pointerdown",t=>{t.pointerType===Vd(this,Ze)&&(Vd(this,fi)||t.isPrimary)&&a(t),Ep(t)},r));const o=t=>{Vd(this,Je)&&Vd(this,Je)!==t.pointerId?Ep(t):a(t)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})},Ii=function(){if(Vd(this,ni)||!this.div)return;qd(this,ni,new AbortController);const t=this._uiManager.combinedSignal(Vd(this,ni));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Li=function(t){cg._resizerKeyboardManager.exec(this,t)},Fi=function(t){var e;Vd(this,ci)&&(null==(e=t.relatedTarget)?void 0:e.parentNode)!==Vd(this,ti)&&Xd(this,wi,Bi).call(this)},Ni=function(t){qd(this,ri,Vd(this,ci)?t:"")},Wi=function(t){if(Vd(this,qe))for(const e of Vd(this,qe))e.tabIndex=t},Bi=function(){qd(this,ci,!1),Xd(this,wi,Wi).call(this,-1),Xd(this,wi,Mi).call(this)},Gd(cg,yi),jd(cg,"_l10n",null),jd(cg,"_l10nResizer",null),jd(cg,"_borderLineWidth",-1),jd(cg,"_colorManager",new ig),jd(cg,"_zIndex",1),jd(cg,"_telemetryTimeout",1e3);let dg=cg;class ug extends dg{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const pg=3285377520,gg=4294901760,fg=65535;class mg{constructor(t){this.h1=t?4294967295&t:pg,this.h2=t?4294967295&t:pg}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,n=t.length;s<n;s++){const n=t.charCodeAt(s);n<=255?e[i++]=n:(e[i++]=n>>>8,e[i++]=255&n)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),i=e.byteLength}const s=i>>2,n=i-4*s,r=new Uint32Array(e.buffer,0,s);let a=0,o=0,l=this.h1,h=this.h2;const c=3432918353,d=461845907,u=11601,p=13715;for(let g=0;g<s;g++)1&g?(a=r[g],a=a*c&gg|a*u&fg,a=a<<15|a>>>17,a=a*d&gg|a*p&fg,l^=a,l=l<<13|l>>>19,l=5*l+3864292196):(o=r[g],o=o*c&gg|o*u&fg,o=o<<15|o>>>17,o=o*d&gg|o*p&fg,h^=o,h=h<<13|h>>>19,h=5*h+3864292196);switch(a=0,n){case 3:a^=e[4*s+2]<<16;case 2:a^=e[4*s+1]<<8;case 1:a^=e[4*s],a=a*c&gg|a*u&fg,a=a<<15|a>>>17,a=a*d&gg|a*p&fg,1&s?l^=a:h^=a}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&gg|36045*t&fg,e=4283543511*e&gg|(2950163797*(e<<16|t>>>16)&gg)>>>16,t^=e>>>1,t=444984403*t&gg|60499*t&fg,e=3301882366*e&gg|(3120437893*(e<<16|t>>>16)&gg)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const vg=Object.freeze({map:null,hash:"",transfer:void 0});class wg{constructor(){Gd(this,ji),Gd(this,Oi,!1),Gd(this,Ui,null),Gd(this,Hi,null),Gd(this,$i,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=Vd(this,$i).get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return Vd(this,$i).get(t)}remove(t){const e=Vd(this,$i).get(t);if(void 0!==e&&(e instanceof dg&&Vd(this,Hi).delete(e.annotationElementId),Vd(this,$i).delete(t),0===Vd(this,$i).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor)){for(const t of Vd(this,$i).values())if(t instanceof dg)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=Vd(this,$i).get(t);let s=!1;if(void 0!==i)for(const[n,r]of Object.entries(e))i[n]!==r&&(s=!0,i[n]=r);else s=!0,Vd(this,$i).set(t,e);s&&Xd(this,ji,zi).call(this),e instanceof dg&&((Vd(this,Hi)||qd(this,Hi,new Map)).set(e.annotationElementId,e),"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type))}has(t){return Vd(this,$i).has(t)}get size(){return Vd(this,$i).size}resetModified(){Vd(this,Oi)&&(qd(this,Oi,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new bg(this)}get serializable(){if(0===Vd(this,$i).size)return vg;const t=new Map,e=new mg,i=[],s=Object.create(null);let n=!1;for(const[r,a]of Vd(this,$i)){const i=a instanceof dg?a.serialize(!1,s):a;i&&(t.set(r,i),e.update(`${r}:${JSON.stringify(i)}`),n||(n=!!i.bitmap))}if(n)for(const r of t.values())r.bitmap&&i.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:vg}get editorStats(){let t=null;const e=new Map;let i=0,s=0;for(const n of Vd(this,$i).values()){if(!(n instanceof dg)){n.popup&&(n.popup.deleted?s+=1:i+=1);continue}n.isCommentDeleted?s+=1:n.hasEditedComment&&(i+=1);const r=n.telemetryFinalData;if(!r)continue;const{type:a}=r;e.has(a)||e.set(a,Object.getPrototypeOf(n).constructor),t||(t=Object.create(null));const o=t[a]||(t[a]=new Map);for(const[t,e]of Object.entries(r)){if("type"===t)continue;let i=o.get(t);i||(i=new Map,o.set(t,i));const s=i.get(e)??0;i.set(e,s+1)}}if((s>0||i>0)&&(t||(t=Object.create(null)),t.comments={deleted:s,edited:i}),!t)return null;for(const[n,r]of e)t[n]=r.computeTelemetryFinalData(t[n]);return t}resetModifiedIds(){qd(this,Ui,null)}updateEditor(t,e){var i;const s=null==(i=Vd(this,Hi))?void 0:i.get(t);return!!s&&(s.updateFromAnnotationLayer(e),!0)}getEditor(t){var e;return(null==(e=Vd(this,Hi))?void 0:e.get(t))||null}get modifiedIds(){if(Vd(this,Ui))return Vd(this,Ui);const t=[];if(Vd(this,Hi))for(const e of Vd(this,Hi).values())e.serialize()&&t.push(e.annotationElementId);return qd(this,Ui,{ids:new Set(t),hash:t.join(",")})}[Symbol.iterator](){return Vd(this,$i).entries()}}Oi=new WeakMap,Ui=new WeakMap,Hi=new WeakMap,$i=new WeakMap,ji=new WeakSet,zi=function(){Vd(this,Oi)||(qd(this,Oi,!0),"function"==typeof this.onSetModified&&this.onSetModified())};class bg extends wg{constructor(t){super(),Gd(this,Vi);const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);qd(this,Vi,{map:n,hash:i,transfer:s})}get print(){$u("Should not call PrintAnnotationStorage.print")}get serializable(){return Vd(this,Vi)}get modifiedIds(){return Gu(this,"modifiedIds",{ids:new Set,hash:""})}}Vi=new WeakMap;class yg{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){Gd(this,Gi,new Set),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(),Vd(this,Gi).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}){if(t&&!Vd(this,Gi).has(t.loadedName)){if(ju(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:e,src:s,style:n}=t,r=new FontFace(e,s,n);this.addNativeFontFace(r);try{await r.load(),Vd(this,Gi).add(e),null==i||i(t)}catch{Hu(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}return}$u("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void(await this.loadSystemFont(t));if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw Hu(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(e=>{const i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){var t;return Gu(this,"isFontLoadingAPISupported",!!(null==(t=this._document)?void 0:t.fonts))}get isSyncFontLoadingSupported(){return Gu(this,"isSyncFontLoadingSupported",iu||ip.platform.isFirefox)}_queueLoadingCallback(t){const{loadingRequests:e}=this,i={done:!1,complete:function(){for(ju(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;){const t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(i),i}get _loadTestFont(){return Gu(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function i(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function s(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let n,r;const a=this._document.createElement("canvas");a.width=1,a.height=1;const o=a.getContext("2d");let l=0;const h=`lt${Date.now()}${this.loadTestFontId++}`;let c=this._loadTestFont;c=s(c,976,h.length,h);const d=1482184792;let u=i(c,16);for(n=0,r=h.length-3;n<r;n+=4)u=u-d+i(h,n)|0;var p;n<h.length&&(u=u-d+i(h+"XXX",n)|0),c=s(c,16,4,(p=u,String.fromCharCode(p>>24&255,p>>16&255,p>>8&255,255&p)));const g=`@font-face {font-family:"${h}";src:${`url(data:font/opentype;base64,${btoa(c)});`}}`;this.insertRule(g);const f=this._document.createElement("div");f.style.visibility="hidden",f.style.width=f.style.height="10px",f.style.position="absolute",f.style.top=f.style.left="0px";for(const m of[t.loadedName,h]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=m,f.append(t)}this._document.body.append(f),function t(e,i){if(++l>30)return Hu("Load test font never loaded."),void i();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?i():setTimeout(t.bind(null,e,i))}(h,()=>{f.remove(),e.complete()})}}Gi=new WeakMap;class Ag{constructor(t,e=null,i,s){Gd(this,qi),this.compiledGlyphs=Object.create(null),qd(this,qi,t),this._inspectFont=e,i&&Object.assign(this,i),s&&(this.charProcOperatorList=s)}createNativeFontFace(){var t;if(!this.data||this.disableFontFace)return null;let e;if(this.cssFontInfo){const t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}else e=new FontFace(this.loadedName,this.data,{});return null==(t=this._inspectFont)||t.call(this,this),e}createFontFaceRule(){var t;if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${dp(this.data)});`;let i;if(this.cssFontInfo){let t=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(t+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),i=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${t}src:${e}}`}else i=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return null==(t=this._inspectFont)||t.call(this,this,e),i}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];const i=this.loadedName+"_path_"+e;let s;try{s=t.get(i)}catch(r){Hu(`getPathGenerator - ignoring character: "${r}".`)}const n=new Path2D(s||"");return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=n}get black(){return Vd(this,qi).black}get bold(){return Vd(this,qi).bold}get disableFontFace(){return Vd(this,qi).disableFontFace??!1}get fontExtraProperties(){return Vd(this,qi).fontExtraProperties??!1}get isInvalidPDFjsFont(){return Vd(this,qi).isInvalidPDFjsFont}get isType3Font(){return Vd(this,qi).isType3Font}get italic(){return Vd(this,qi).italic}get missingFile(){return Vd(this,qi).missingFile}get remeasure(){return Vd(this,qi).remeasure}get vertical(){return Vd(this,qi).vertical}get ascent(){return Vd(this,qi).ascent}get defaultWidth(){return Vd(this,qi).defaultWidth}get descent(){return Vd(this,qi).descent}get bbox(){return Vd(this,qi).bbox}get fontMatrix(){return Vd(this,qi).fontMatrix}get fallbackName(){return Vd(this,qi).fallbackName}get loadedName(){return Vd(this,qi).loadedName}get mimetype(){return Vd(this,qi).mimetype}get name(){return Vd(this,qi).name}get data(){return Vd(this,qi).data}clearData(){Vd(this,qi).clearData()}get cssFontInfo(){return Vd(this,qi).cssFontInfo}get systemFontInfo(){return Vd(this,qi).systemFontInfo}get defaultVMetrics(){return Vd(this,qi).defaultVMetrics}}function _g(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}qi=new WeakMap;const xg=t=>"object"==typeof t&&Number.isInteger(null==t?void 0:t.num)&&t.num>=0&&Number.isInteger(null==t?void 0:t.gen)&&t.gen>=0,kg=function(t,e,i){if(!Array.isArray(i)||i.length<2)return!1;const[s,n,...r]=i;if(!t(s)&&!Number.isInteger(s))return!1;if(!e(n))return!1;const a=r.length;let o=!0;switch(n.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return 0===a;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(4!==a)return!1;o=!1;break;default:return!1}for(const l of r)if(!("number"==typeof l||o&&null===l))return!1;return!0}.bind(null,xg,t=>"object"==typeof t&&"string"==typeof(null==t?void 0:t.name));class Sg{constructor(){Gd(this,Xi,new Map),Gd(this,Yi,Promise.resolve())}postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};Vd(this,Yi).then(()=>{for(const[t]of Vd(this,Xi))t.call(this,i)})}addEventListener(t,e,i=null){let s=null;if((null==i?void 0:i.signal)instanceof AbortSignal){const{signal:n}=i;if(n.aborted)return void Hu("LoopbackPort - cannot use an `aborted` signal.");const r=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}Vd(this,Xi).set(e,s)}removeEventListener(t,e){const i=Vd(this,Xi).get(e);null==i||i(),Vd(this,Xi).delete(e)}terminate(){for(const[,t]of Vd(this,Xi))null==t||t();Vd(this,Xi).clear()}}Xi=new WeakMap,Yi=new WeakMap;const Mg=1,Eg=2,Cg=1,Tg=2,Pg=3,Dg=4,Rg=5,Ig=6,Lg=7,Fg=8;function Ng(){}function Wg(t){if(t instanceof Zu||t instanceof Ku||t instanceof Xu||t instanceof Qu||t instanceof Yu)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||$u('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new Zu(t.message);case"InvalidPDFException":return new Ku(t.message);case"PasswordException":return new Xu(t.message,t.code);case"ResponseException":return new Qu(t.message,t.status,t.missing);case"UnknownErrorException":return new Yu(t.message,t.details)}return new Yu(t.message,t.toString())}class Bg{constructor(t,e,i){Gd(this,Qi),Gd(this,Ki,new AbortController),this.sourceName=t,this.targetName=e,this.comObj=i,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),i.addEventListener("message",Xd(this,Qi,Ji).bind(this),{signal:Vd(this,Ki).signal})}on(t,e){const i=this.actionHandler;if(i[t])throw new Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){const s=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[s]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(r){n.reject(r)}return n.promise}sendWithStream(t,e,i,s){const n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{const l=Promise.withResolvers();return this.streamControllers[n]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:i.desiredSize},s),l.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[n].pullCall=e,o.postMessage({sourceName:r,targetName:a,stream:Ig,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{ju(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[n].cancelCall=e,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:Cg,streamId:n,reason:Wg(t)}),e.promise}},i)}destroy(){var t;null==(t=Vd(this,Ki))||t.abort(),qd(this,Ki,null)}}Ki=new WeakMap,Qi=new WeakSet,Ji=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void Xd(this,Qi,ts).call(this,t);if(t.callback){const e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],t.callback===Mg)i.resolve(t.data);else{if(t.callback!==Eg)throw new Error("Unexpected callback case");i.reject(Wg(t.reason))}return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const i=this.sourceName,s=t.sourceName,n=this.comObj;return void Promise.try(e,t.data).then(function(e){n.postMessage({sourceName:i,targetName:s,callback:Mg,callbackId:t.callbackId,data:e})},function(e){n.postMessage({sourceName:i,targetName:s,callback:Eg,callbackId:t.callbackId,reason:Wg(e)})})}t.streamId?Xd(this,Qi,Zi).call(this,t):e(t.data)},Zi=function(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(t,r=1,a){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=r,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:i,targetName:s,stream:Dg,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Pg,streamId:e}),delete r.streamSinks[e])},error(t){ju(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Rg,streamId:e,reason:Wg(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(a,t.data,o).then(function(){n.postMessage({sourceName:i,targetName:s,stream:Fg,streamId:e,success:!0})},function(t){n.postMessage({sourceName:i,targetName:s,stream:Fg,streamId:e,reason:Wg(t)})})},ts=function(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case Fg:t.success?r.startCall.resolve():r.startCall.reject(Wg(t.reason));break;case Lg:t.success?r.pullCall.resolve():r.pullCall.reject(Wg(t.reason));break;case Ig:if(!a){n.postMessage({sourceName:i,targetName:s,stream:Lg,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||Ng).then(function(){n.postMessage({sourceName:i,targetName:s,stream:Lg,streamId:e,success:!0})},function(t){n.postMessage({sourceName:i,targetName:s,stream:Lg,streamId:e,reason:Wg(t)})});break;case Dg:if(ju(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case Pg:if(ju(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),Xd(this,Qi,es).call(this,r,e);break;case Rg:ju(r,"error should have stream controller"),r.controller.error(Wg(t.reason)),Xd(this,Qi,es).call(this,r,e);break;case Tg:t.success?r.cancelCall.resolve():r.cancelCall.reject(Wg(t.reason)),Xd(this,Qi,es).call(this,r,e);break;case Cg:if(!a)break;const o=Wg(t.reason);Promise.try(a.onCancel||Ng,o).then(function(){n.postMessage({sourceName:i,targetName:s,stream:Tg,streamId:e,success:!0})},function(t){n.postMessage({sourceName:i,targetName:s,stream:Tg,streamId:e,reason:Wg(t)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},es=async function(t,e){var i,s,n;await Promise.allSettled([null==(i=t.startCall)?void 0:i.promise,null==(s=t.pullCall)?void 0:s.promise,null==(n=t.cancelCall)?void 0:n.promise]),delete this.streamControllers[e]};class Og{constructor({enableHWA:t=!1}){Gd(this,is,!1),qd(this,is,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!Vd(this,is)})}}reset(t,e,i){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){$u("Abstract method `_createCanvas` called.")}}is=new WeakMap;class Ug extends Og{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class Hg{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(t=>({cMapData:t,isCompressed:this.isCompressed})).catch(t=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){$u("Abstract method `_fetch` called.")}}class $g extends Hg{async _fetch(t){const e=await vp(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):ep(e)}}class jg{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,s,n){return"none"}destroy(t=!1){}}class zg extends jg{constructor({docId:t,ownerDocument:e=globalThis.document}){super(),Gd(this,cs),Gd(this,ss),Gd(this,ns),Gd(this,rs),Gd(this,as),Gd(this,os),Gd(this,ls),Gd(this,hs,0),qd(this,as,t),qd(this,os,e)}addFilter(t){if(!t)return"none";let e=Vd(this,cs,ds).get(t);if(e)return e;const[i,s,n]=Xd(this,cs,gs).call(this,t),r=1===t.length?i:`${i}${s}${n}`;if(e=Vd(this,cs,ds).get(r),e)return Vd(this,cs,ds).set(t,e),e;const a=`g_${Vd(this,as)}_transfer_map_${Yd(this,hs)._++}`,o=Xd(this,cs,fs).call(this,a);Vd(this,cs,ds).set(t,o),Vd(this,cs,ds).set(r,o);const l=Xd(this,cs,ws).call(this,a);return Xd(this,cs,ys).call(this,i,s,n,l),o}addHCMFilter(t,e){var i;const s=`${t}-${e}`,n="base";let r=Vd(this,cs,us).get(n);if((null==r?void 0:r.key)===s)return r.url;if(r?(null==(i=r.filter)||i.remove(),r.key=s,r.url="none",r.filter=null):(r={key:s,url:"none",filter:null},Vd(this,cs,us).set(n,r)),!t||!e)return r.url;const a=Xd(this,cs,_s).call(this,t);t=np.makeHexColor(...a);const o=Xd(this,cs,_s).call(this,e);if(e=np.makeHexColor(...o),Vd(this,cs,ps).style.color="","#000000"===t&&"#ffffff"===e||t===e)return r.url;const l=new Array(256);for(let p=0;p<=255;p++){const t=p/255;l[p]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}const h=l.join(","),c=`g_${Vd(this,as)}_hcm_filter`,d=r.filter=Xd(this,cs,ws).call(this,c);Xd(this,cs,ys).call(this,h,h,h,d),Xd(this,cs,vs).call(this,d);const u=(t,e)=>{const i=a[t]/255,s=o[t]/255,n=new Array(e+1);for(let r=0;r<=e;r++)n[r]=i+r/e*(s-i);return n.join(",")};return Xd(this,cs,ys).call(this,u(0,5),u(1,5),u(2,5),d),r.url=Xd(this,cs,fs).call(this,c),r.url}addAlphaFilter(t){let e=Vd(this,cs,ds).get(t);if(e)return e;const[i]=Xd(this,cs,gs).call(this,[t]),s=`alpha_${i}`;if(e=Vd(this,cs,ds).get(s),e)return Vd(this,cs,ds).set(t,e),e;const n=`g_${Vd(this,as)}_alpha_map_${Yd(this,hs)._++}`,r=Xd(this,cs,fs).call(this,n);Vd(this,cs,ds).set(t,r),Vd(this,cs,ds).set(s,r);const a=Xd(this,cs,ws).call(this,n);return Xd(this,cs,As).call(this,i,a),r}addLuminosityFilter(t){let e,i,s=Vd(this,cs,ds).get(t||"luminosity");if(s)return s;if(t?([e]=Xd(this,cs,gs).call(this,[t]),i=`luminosity_${e}`):i="luminosity",s=Vd(this,cs,ds).get(i),s)return Vd(this,cs,ds).set(t,s),s;const n=`g_${Vd(this,as)}_luminosity_map_${Yd(this,hs)._++}`,r=Xd(this,cs,fs).call(this,n);Vd(this,cs,ds).set(t,r),Vd(this,cs,ds).set(i,r);const a=Xd(this,cs,ws).call(this,n);return Xd(this,cs,ms).call(this,a),t&&Xd(this,cs,As).call(this,e,a),r}addHighlightHCMFilter(t,e,i,s,n){var r;const a=`${e}-${i}-${s}-${n}`;let o=Vd(this,cs,us).get(t);if((null==o?void 0:o.key)===a)return o.url;if(o?(null==(r=o.filter)||r.remove(),o.key=a,o.url="none",o.filter=null):(o={key:a,url:"none",filter:null},Vd(this,cs,us).set(t,o)),!e||!i)return o.url;const[l,h]=[e,i].map(Xd(this,cs,_s).bind(this));let c=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),d=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),[u,p]=[s,n].map(Xd(this,cs,_s).bind(this));d<c&&([c,d,u,p]=[d,c,p,u]),Vd(this,cs,ps).style.color="";const g=(t,e,i)=>{const s=new Array(256),n=(d-c)/i,r=t/255,a=(e-t)/(255*i);let o=0;for(let l=0;l<=i;l++){const t=Math.round(c+l*n),e=r+l*a;for(let i=o;i<=t;i++)s[i]=e;o=t+1}for(let l=o;l<256;l++)s[l]=s[o-1];return s.join(",")},f=`g_${Vd(this,as)}_hcm_${t}_filter`,m=o.filter=Xd(this,cs,ws).call(this,f);return Xd(this,cs,vs).call(this,m),Xd(this,cs,ys).call(this,g(u[0],p[0],5),g(u[1],p[1],5),g(u[2],p[2],5),m),o.url=Xd(this,cs,fs).call(this,f),o.url}destroy(t=!1){var e,i,s,n;t&&(null==(e=Vd(this,ls))?void 0:e.size)||(null==(i=Vd(this,rs))||i.parentNode.parentNode.remove(),qd(this,rs,null),null==(s=Vd(this,ns))||s.clear(),qd(this,ns,null),null==(n=Vd(this,ls))||n.clear(),qd(this,ls,null),qd(this,hs,0))}}ss=new WeakMap,ns=new WeakMap,rs=new WeakMap,as=new WeakMap,os=new WeakMap,ls=new WeakMap,hs=new WeakMap,cs=new WeakSet,ds=function(){return Vd(this,ns)||qd(this,ns,new Map)},us=function(){return Vd(this,ls)||qd(this,ls,new Map)},ps=function(){if(!Vd(this,rs)){const t=Vd(this,os).createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const i=Vd(this,os).createElementNS(gp,"svg");i.setAttribute("width",0),i.setAttribute("height",0),qd(this,rs,Vd(this,os).createElementNS(gp,"defs")),t.append(i),i.append(Vd(this,rs)),Vd(this,os).body.append(t)}return Vd(this,rs)},gs=function(t){if(1===t.length){const e=t[0],i=new Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;const s=i.join(",");return[s,s,s]}const[e,i,s]=t,n=new Array(256),r=new Array(256),a=new Array(256);for(let o=0;o<256;o++)n[o]=e[o]/255,r[o]=i[o]/255,a[o]=s[o]/255;return[n.join(","),r.join(","),a.join(",")]},fs=function(t){if(void 0===Vd(this,ss)){qd(this,ss,"");const t=Vd(this,os).URL;t!==Vd(this,os).baseURI&&(yp(t)?Hu('#createUrl: ignore "data:"-URL for performance reasons.'):qd(this,ss,Vu(t,"")))}return`url(${Vd(this,ss)}#${t})`},ms=function(t){const e=Vd(this,os).createElementNS(gp,"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)},vs=function(t){const e=Vd(this,os).createElementNS(gp,"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)},ws=function(t){const e=Vd(this,os).createElementNS(gp,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),Vd(this,cs,ps).append(e),e},bs=function(t,e,i){const s=Vd(this,os).createElementNS(gp,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)},ys=function(t,e,i,s){const n=Vd(this,os).createElementNS(gp,"feComponentTransfer");s.append(n),Xd(this,cs,bs).call(this,n,"feFuncR",t),Xd(this,cs,bs).call(this,n,"feFuncG",e),Xd(this,cs,bs).call(this,n,"feFuncB",i)},As=function(t,e){const i=Vd(this,os).createElementNS(gp,"feComponentTransfer");e.append(i),Xd(this,cs,bs).call(this,i,"feFuncA",t)},_s=function(t){return Vd(this,cs,ps).style.color=t,Pp(getComputedStyle(Vd(this,cs,ps)).getPropertyValue("color"))};class Vg{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){$u("Abstract method `_fetch` called.")}}class Gg extends Vg{async _fetch(t){const e=await vp(t,"arraybuffer");return new Uint8Array(e)}}class qg{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw new Error("Wasm filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw new Error(`Unable to load wasm data at: ${e}`)})}async _fetch(t){$u("Abstract method `_fetch` called.")}}class Xg extends qg{async _fetch(t){const e=await vp(t,"arraybuffer");return new Uint8Array(e)}}async function Yg(t){const e=process.getBuiltinModule("fs"),i=await e.promises.readFile(t);return new Uint8Array(i)}iu&&Hu("Please use the `legacy` build in Node.js environments.");class Kg extends jg{}class Qg extends Og{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class Jg extends Hg{async _fetch(t){return Yg(t)}}class Zg extends Vg{async _fetch(t){return Yg(t)}}class tf extends qg{async _fetch(t){return Yg(t)}}const ef="__forcedDependency",{floor:sf,ceil:nf}=Math;function rf(t,e,i,s,n,r){t[4*e+0]=Math.min(t[4*e+0],i),t[4*e+1]=Math.min(t[4*e+1],s),t[4*e+2]=Math.max(t[4*e+2],n),t[4*e+3]=Math.max(t[4*e+3],r)}const af=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class of{constructor(t,e){Gd(this,xs),Gd(this,ks),qd(this,xs,t),qd(this,ks,e)}get length(){return Vd(this,xs).length}isEmpty(t){return Vd(this,xs)[t]===af}minX(t){return Vd(this,ks)[4*t+0]/256}minY(t){return Vd(this,ks)[4*t+1]/256}maxX(t){return(Vd(this,ks)[4*t+2]+1)/256}maxY(t){return(Vd(this,ks)[4*t+3]+1)/256}}xs=new WeakMap,ks=new WeakMap;const lf=(t,e)=>{if(!t)return;let i=t.get(e);return i||(i={dependencies:new Set,isRenderingOperation:!1},t.set(e,i)),i};class hf{constructor(t,e,i=!1){Gd(this,$s),Gd(this,Ss,{__proto__:null}),Gd(this,Ms,{__proto__:null,transform:[],moveText:[],sameLineText:[],[ef]:[]}),Gd(this,Es,new Map),Gd(this,Cs,[]),Gd(this,Ts,[]),Gd(this,Ps,[[1,0,0,1,0,0]]),Gd(this,Ds,[-1/0,-1/0,1/0,1/0]),Gd(this,Rs,new Float64Array([1/0,1/0,-1/0,-1/0])),Gd(this,Is,-1),Gd(this,Ls,new Set),Gd(this,Fs,new Map),Gd(this,Ns,new Map),Gd(this,Ws),Gd(this,Bs),Gd(this,Os),Gd(this,Us),Gd(this,Hs),qd(this,Ws,t.width),qd(this,Bs,t.height),Xd(this,$s,js).call(this,e),i&&qd(this,Hs,new Map)}growOperationsCount(t){t>=Vd(this,Us).length&&Xd(this,$s,js).call(this,t,Vd(this,Us))}save(t){return qd(this,Ss,{__proto__:Vd(this,Ss)}),qd(this,Ms,{__proto__:Vd(this,Ms),transform:{__proto__:Vd(this,Ms).transform},moveText:{__proto__:Vd(this,Ms).moveText},sameLineText:{__proto__:Vd(this,Ms).sameLineText},[ef]:{__proto__:Vd(this,Ms)[ef]}}),qd(this,Ds,{__proto__:Vd(this,Ds)}),Vd(this,Cs).push(t),this}restore(t){var e;const i=Object.getPrototypeOf(Vd(this,Ss));if(null===i)return this;qd(this,Ss,i),qd(this,Ms,Object.getPrototypeOf(Vd(this,Ms))),qd(this,Ds,Object.getPrototypeOf(Vd(this,Ds)));const s=Vd(this,Cs).pop();return void 0!==s&&(null==(e=lf(Vd(this,Hs),t))||e.dependencies.add(s),Vd(this,Us)[t]=Vd(this,Us)[s]),this}recordOpenMarker(t){return Vd(this,Cs).push(t),this}getOpenMarker(){return 0===Vd(this,Cs).length?null:Vd(this,Cs).at(-1)}recordCloseMarker(t){var e;const i=Vd(this,Cs).pop();return void 0!==i&&(null==(e=lf(Vd(this,Hs),t))||e.dependencies.add(i),Vd(this,Us)[t]=Vd(this,Us)[i]),this}beginMarkedContent(t){return Vd(this,Ts).push(t),this}endMarkedContent(t){var e;const i=Vd(this,Ts).pop();return void 0!==i&&(null==(e=lf(Vd(this,Hs),t))||e.dependencies.add(i),Vd(this,Us)[t]=Vd(this,Us)[i]),this}pushBaseTransform(t){return Vd(this,Ps).push(np.multiplyByDOMMatrix(Vd(this,Ps).at(-1),t.getTransform())),this}popBaseTransform(){return Vd(this,Ps).length>1&&Vd(this,Ps).pop(),this}recordSimpleData(t,e){return Vd(this,Ss)[t]=e,this}recordIncrementalData(t,e){return Vd(this,Ms)[t].push(e),this}resetIncrementalData(t,e){return Vd(this,Ms)[t].length=0,this}recordNamedData(t,e){return Vd(this,Es).set(t,e),this}recordSimpleDataFromNamed(t,e,i){Vd(this,Ss)[t]=Vd(this,Es).get(e)??i}recordFutureForcedDependency(t,e){return this.recordIncrementalData(ef,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in Vd(this,Ss)&&this.recordFutureForcedDependency(e,Vd(this,Ss)[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of Vd(this,Ls))this.recordFutureForcedDependency(ef,t);return this}resetBBox(t){return Vd(this,Is)!==t&&(qd(this,Is,t),Vd(this,Rs)[0]=1/0,Vd(this,Rs)[1]=1/0,Vd(this,Rs)[2]=-1/0,Vd(this,Rs)[3]=-1/0),this}recordClipBox(t,e,i,s,n,r){const a=np.multiplyByDOMMatrix(Vd(this,Ps).at(-1),e.getTransform()),o=[1/0,1/0,-1/0,-1/0];np.axialAlignedBoundingBox([i,n,s,r],a,o);const l=np.intersect(Vd(this,Ds),o);return l?(Vd(this,Ds)[0]=l[0],Vd(this,Ds)[1]=l[1],Vd(this,Ds)[2]=l[2],Vd(this,Ds)[3]=l[3]):(Vd(this,Ds)[0]=Vd(this,Ds)[1]=1/0,Vd(this,Ds)[2]=Vd(this,Ds)[3]=-1/0),this}recordBBox(t,e,i,s,n,r){const a=Vd(this,Ds);if(a[0]===1/0)return this;const o=np.multiplyByDOMMatrix(Vd(this,Ps).at(-1),e.getTransform());if(a[0]===-1/0)return np.axialAlignedBoundingBox([i,n,s,r],o,Vd(this,Rs)),this;const l=[1/0,1/0,-1/0,-1/0];return np.axialAlignedBoundingBox([i,n,s,r],o,l),Vd(this,Rs)[0]=Math.min(Vd(this,Rs)[0],Math.max(l[0],a[0])),Vd(this,Rs)[1]=Math.min(Vd(this,Rs)[1],Math.max(l[1],a[1])),Vd(this,Rs)[2]=Math.max(Vd(this,Rs)[2],Math.min(l[2],a[2])),Vd(this,Rs)[3]=Math.max(Vd(this,Rs)[3],Math.min(l[3],a[3])),this}recordCharacterBBox(t,e,i,s=1,n=0,r=0,a){const o=i.bbox;let l,h;if(o&&(l=o[2]!==o[0]&&o[3]!==o[1]&&Vd(this,Ns).get(i),!1!==l&&(h=[0,0,0,0],np.axialAlignedBoundingBox(o,i.fontMatrix,h),1===s&&0===n&&0===r||np.scaleMinMax([s,0,0,-s,n,r],h),l)))return this.recordBBox(t,e,h[0],h[2],h[1],h[3]);if(!a)return this.recordFullPageBBox(t);const c=a();return o&&h&&void 0===l&&(l=h[0]<=n-c.actualBoundingBoxLeft&&h[2]>=n+c.actualBoundingBoxRight&&h[1]<=r-c.actualBoundingBoxAscent&&h[3]>=r+c.actualBoundingBoxDescent,Vd(this,Ns).set(i,l),l)?this.recordBBox(t,e,h[0],h[2],h[1],h[3]):this.recordBBox(t,e,n-c.actualBoundingBoxLeft,n+c.actualBoundingBoxRight,r-c.actualBoundingBoxAscent,r+c.actualBoundingBoxDescent)}recordFullPageBBox(t){return Vd(this,Rs)[0]=Math.max(0,Vd(this,Ds)[0]),Vd(this,Rs)[1]=Math.max(0,Vd(this,Ds)[1]),Vd(this,Rs)[2]=Math.min(Vd(this,Ws),Vd(this,Ds)[2]),Vd(this,Rs)[3]=Math.min(Vd(this,Bs),Vd(this,Ds)[3]),this}getSimpleIndex(t){return Vd(this,Ss)[t]}recordDependencies(t,e){const i=Vd(this,Ls),s=Vd(this,Ss),n=Vd(this,Ms);for(const r of e)r in Vd(this,Ss)?i.add(s[r]):r in n&&n[r].forEach(i.add,i);return this}recordNamedDependency(t,e){return Vd(this,Es).has(e)&&Vd(this,Ls).add(Vd(this,Es).get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[ef]),Vd(this,Hs)){const e=lf(Vd(this,Hs),t),{dependencies:i}=e;Vd(this,Ls).forEach(i.add,i),Vd(this,Cs).forEach(i.add,i),Vd(this,Ts).forEach(i.add,i),i.delete(t),e.isRenderingOperation=!0}if(Vd(this,Is)===t){const i=sf(256*Vd(this,Rs)[0]/Vd(this,Ws)),s=sf(256*Vd(this,Rs)[1]/Vd(this,Bs)),n=nf(256*Vd(this,Rs)[2]/Vd(this,Ws)),r=nf(256*Vd(this,Rs)[3]/Vd(this,Bs));rf(Vd(this,Os),t,i,s,n,r);for(const e of Vd(this,Ls))e!==t&&rf(Vd(this,Os),e,i,s,n,r);for(const e of Vd(this,Cs))e!==t&&rf(Vd(this,Os),e,i,s,n,r);for(const e of Vd(this,Ts))e!==t&&rf(Vd(this,Os),e,i,s,n,r);e||(Vd(this,Ls).clear(),qd(this,Is,-1))}return this}recordShowTextOperation(t,e=!1){const i=Array.from(Vd(this,Ls));this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const s of i)this.recordIncrementalData("sameLineText",s);return this}bboxToClipBoxDropOperation(t,e=!1){return Vd(this,Is)===t&&(qd(this,Is,-1),Vd(this,Ds)[0]=Math.max(Vd(this,Ds)[0],Vd(this,Rs)[0]),Vd(this,Ds)[1]=Math.max(Vd(this,Ds)[1],Vd(this,Rs)[1]),Vd(this,Ds)[2]=Math.min(Vd(this,Ds)[2],Vd(this,Rs)[2]),Vd(this,Ds)[3]=Math.min(Vd(this,Ds)[3],Vd(this,Rs)[3]),e||Vd(this,Ls).clear()),this}_takePendingDependencies(){const t=Vd(this,Ls);return qd(this,Ls,new Set),t}_extractOperation(t){const e=Vd(this,Fs).get(t);return Vd(this,Fs).delete(t),e}_pushPendingDependencies(t){for(const e of t)Vd(this,Ls).add(e)}take(){return Vd(this,Ns).clear(),new of(Vd(this,Us),Vd(this,Os))}takeDebugMetadata(){return Vd(this,Hs)}}Ss=new WeakMap,Ms=new WeakMap,Es=new WeakMap,Cs=new WeakMap,Ts=new WeakMap,Ps=new WeakMap,Ds=new WeakMap,Rs=new WeakMap,Is=new WeakMap,Ls=new WeakMap,Fs=new WeakMap,Ns=new WeakMap,Ws=new WeakMap,Bs=new WeakMap,Os=new WeakMap,Us=new WeakMap,Hs=new WeakMap,$s=new WeakSet,js=function(t,e){const i=new ArrayBuffer(4*t);qd(this,Os,new Uint8ClampedArray(i)),qd(this,Us,new Uint32Array(i)),e&&e.length>0?(Vd(this,Us).set(e),Vd(this,Us).fill(af,e.length)):Vd(this,Us).fill(af)};zs=new WeakMap,Vs=new WeakMap,Gs=new WeakMap,qs=new WeakMap,Xs=new WeakMap;let cf=class t{constructor(e,i,s){if(Gd(this,zs),Gd(this,Vs),Gd(this,Gs),Gd(this,qs,0),Gd(this,Xs,0),e instanceof t&&Vd(e,Gs)===!!s)return e;qd(this,zs,e),qd(this,Vs,i),qd(this,Gs,!!s)}growOperationsCount(){throw new Error("Unreachable")}save(t){return Yd(this,Xs)._++,Vd(this,zs).save(Vd(this,Vs)),this}restore(t){return Vd(this,Xs)>0&&(Vd(this,zs).restore(Vd(this,Vs)),Yd(this,Xs)._--),this}recordOpenMarker(t){return Yd(this,qs)._++,this}getOpenMarker(){return Vd(this,qs)>0?Vd(this,Vs):Vd(this,zs).getOpenMarker()}recordCloseMarker(t){return Yd(this,qs)._--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return Vd(this,zs).pushBaseTransform(t),this}popBaseTransform(){return Vd(this,zs).popBaseTransform(),this}recordSimpleData(t,e){return Vd(this,zs).recordSimpleData(t,Vd(this,Vs)),this}recordIncrementalData(t,e){return Vd(this,zs).recordIncrementalData(t,Vd(this,Vs)),this}resetIncrementalData(t,e){return Vd(this,zs).resetIncrementalData(t,Vd(this,Vs)),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,i){return Vd(this,zs).recordSimpleDataFromNamed(t,e,Vd(this,Vs)),this}recordFutureForcedDependency(t,e){return Vd(this,zs).recordFutureForcedDependency(t,Vd(this,Vs)),this}inheritSimpleDataAsFutureForcedDependencies(t){return Vd(this,zs).inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return Vd(this,zs).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return Vd(this,Gs)||Vd(this,zs).resetBBox(Vd(this,Vs)),this}recordClipBox(t,e,i,s,n,r){return Vd(this,Gs)||Vd(this,zs).recordClipBox(Vd(this,Vs),e,i,s,n,r),this}recordBBox(t,e,i,s,n,r){return Vd(this,Gs)||Vd(this,zs).recordBBox(Vd(this,Vs),e,i,s,n,r),this}recordCharacterBBox(t,e,i,s,n,r,a){return Vd(this,Gs)||Vd(this,zs).recordCharacterBBox(Vd(this,Vs),e,i,s,n,r,a),this}recordFullPageBBox(t){return Vd(this,Gs)||Vd(this,zs).recordFullPageBBox(Vd(this,Vs)),this}getSimpleIndex(t){return Vd(this,zs).getSimpleIndex(t)}recordDependencies(t,e){return Vd(this,zs).recordDependencies(Vd(this,Vs),e),this}recordNamedDependency(t,e){return Vd(this,zs).recordNamedDependency(Vd(this,Vs),e),this}recordOperation(t){return Vd(this,zs).recordOperation(Vd(this,Vs),!0),this}recordShowTextOperation(t){return Vd(this,zs).recordShowTextOperation(Vd(this,Vs),!0),this}bboxToClipBoxDropOperation(t){return Vd(this,Gs)||Vd(this,zs).bboxToClipBoxDropOperation(Vd(this,Vs),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};const df=["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],uf=["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],pf=["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],gf=["filter","fillColor","fillAlpha"],ff=["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],mf=["transform"],vf=["transform","fillColor"],wf="Fill",bf="Stroke",yf="Shading";function Af(t,e){if(!e)return;const i=e[2]-e[0],s=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],i,s),t.clip(n)}class _f{isModifyingCurrentTransform(){return!1}getPattern(){$u("Abstract method `getPattern` called.")}}class xf extends _f{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;"axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const i of this._colorStops)e.addColorStop(i[0],i[1]);return e}getPattern(t,e,i,s){let n;if(s===bf||s===wf){const r=e.current.getClippedPathBoundingBox(s,Dp(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,l=e.cachedCanvases.getCanvas("pattern",a,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-r[0],-r[1]),i=np.transform(i,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),Af(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),n=t.createPattern(l.canvas,"no-repeat");const c=new DOMMatrix(i);n.setTransform(c)}else Af(t,this._bbox),n=this._createGradient(t);return n}}function kf(t,e,i,s,n,r,a,o){const l=e.coords,h=e.colors,c=t.data,d=4*t.width;let u;l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=r,r=a,a=u),l[s+1]>l[n+1]&&(u=s,s=n,n=u,u=a,a=o,o=u),l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=r,r=a,a=u);const p=(l[i]+e.offsetX)*e.scaleX,g=(l[i+1]+e.offsetY)*e.scaleY,f=(l[s]+e.offsetX)*e.scaleX,m=(l[s+1]+e.offsetY)*e.scaleY,v=(l[n]+e.offsetX)*e.scaleX,w=(l[n+1]+e.offsetY)*e.scaleY;if(g>=w)return;const b=h[r],y=h[r+1],A=h[r+2],_=h[a],x=h[a+1],k=h[a+2],S=h[o],M=h[o+1],E=h[o+2],C=Math.round(g),T=Math.round(w);let P,D,R,I,L,F,N,W;for(let B=C;B<=T;B++){if(B<m){const t=B<g?0:(g-B)/(g-m);P=p-(p-f)*t,D=b-(b-_)*t,R=y-(y-x)*t,I=A-(A-k)*t}else{let t;t=B>w?1:m===w?0:(m-B)/(m-w),P=f-(f-v)*t,D=_-(_-S)*t,R=x-(x-M)*t,I=k-(k-E)*t}let t;t=B<g?0:B>w?1:(g-B)/(g-w),L=p-(p-v)*t,F=b-(b-S)*t,N=y-(y-M)*t,W=A-(A-E)*t;const e=Math.round(Math.min(P,L)),i=Math.round(Math.max(P,L));let s=d*B+4*e;for(let n=e;n<=i;n++)t=(P-n)/(P-L),t<0?t=0:t>1&&(t=1),c[s++]=D-(D-F)*t|0,c[s++]=R-(R-N)*t|0,c[s++]=I-(I-W)*t|0,c[s++]=255}}function Sf(t,e,i){const s=e.coords,n=e.colors;let r,a;switch(e.type){case"lattice":const o=e.verticesPerRow,l=Math.floor(s.length/o)-1,h=o-1;for(r=0;r<l;r++){let e=r*o;for(let r=0;r<h;r++,e++)kf(t,i,s[e],s[e+1],s[e+o],n[e],n[e+1],n[e+o]),kf(t,i,s[e+o+1],s[e+1],s[e+o],n[e+o+1],n[e+1],n[e+o])}break;case"triangles":for(r=0,a=s.length;r<a;r+=3)kf(t,i,s[r],s[r+1],s[r+2],n[r],n[r+1],n[r+2]);break;default:throw new Error("illegal figure")}}class Mf extends _f{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,i){const s=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-s,a=Math.ceil(this._bounds[3])-n,o=Math.min(Math.ceil(Math.abs(r*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(a*t[1]*1.1)),3e3),h=r/o,c=a/l,d={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-n,scaleX:1/h,scaleY:1/c},u=o+4,p=l+4,g=i.getCanvas("mesh",u,p),f=g.context,m=f.createImageData(o,l);if(e){const t=m.data;for(let i=0,s=t.length;i<s;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}for(const v of this._figures)Sf(m,v,d);f.putImageData(m,2,2);return{canvas:g.canvas,offsetX:s-2*h,offsetY:n-2*c,scaleX:h,scaleY:c}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,s){Af(t,this._bbox);const n=new Float32Array(2);if(s===yf)np.singularValueDecompose2dScale(Dp(t),n);else if(this.matrix){np.singularValueDecompose2dScale(this.matrix,n);const[t,i]=n;np.singularValueDecompose2dScale(e.baseTransform,n),n[0]*=t,n[1]*=i}else np.singularValueDecompose2dScale(e.baseTransform,n);const r=this._createMeshCanvas(n,s===yf?null:this._background,e.cachedCanvases);return s!==yf&&(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 Ef extends _f{getPattern(){return"hotpink"}}const Cf=1,Tf=2,Pf=class t{constructor(t,e,i,s){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=s}createPatternCanvas(t,e){var i,s;const{bbox:n,operatorList:r,paintType:a,tilingType:o,color:l,canvasGraphicsFactory:h}=this;let{xstep:c,ystep:d}=this;c=Math.abs(c),d=Math.abs(d),Uu("TilingType: "+o);const u=n[0],p=n[1],g=n[2],f=n[3],m=g-u,v=f-p,w=new Float32Array(2);np.singularValueDecompose2dScale(this.matrix,w);const[b,y]=w;np.singularValueDecompose2dScale(this.baseTransform,w);const A=b*w[0],_=y*w[1];let x=m,k=v,S=!1,M=!1;const E=Math.ceil(c*A),C=Math.ceil(d*_);E>=Math.ceil(m*A)?x=c:S=!0,C>=Math.ceil(v*_)?k=d:M=!0;const T=this.getSizeAndScale(x,this.ctx.canvas.width,A),P=this.getSizeAndScale(k,this.ctx.canvas.height,_),D=t.cachedCanvases.getCanvas("pattern",T.size,P.size),R=D.context,I=h.createCanvasGraphics(R,e);if(I.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(I,a,l),R.translate(-T.scale*u,-P.scale*p),I.transform(0,T.scale,0,0,P.scale,0,0),R.save(),null==(i=I.dependencyTracker)||i.save(),this.clipBbox(I,u,p,g,f),I.baseTransform=Dp(I.ctx),I.executeOperatorList(r),I.endDrawing(),null==(s=I.dependencyTracker)||s.restore(),R.restore(),S||M){const e=D.canvas;S&&(x=c),M&&(k=d);const i=this.getSizeAndScale(x,this.ctx.canvas.width,A),s=this.getSizeAndScale(k,this.ctx.canvas.height,_),n=i.size,r=s.size,a=t.cachedCanvases.getCanvas("pattern-workaround",n,r),o=a.context,l=S?Math.floor(m/c):0,h=M?Math.floor(v/d):0;for(let t=0;t<=l;t++)for(let i=0;i<=h;i++)o.drawImage(e,n*t,r*i,n,r,0,0,n,r);return{canvas:a.canvas,scaleX:i.scale,scaleY:s.scale,offsetX:u,offsetY:p}}return{canvas:D.canvas,scaleX:T.scale,scaleY:P.scale,offsetX:u,offsetY:p}}getSizeAndScale(e,i,s){const n=Math.max(t.MAX_PATTERN_SIZE,i);let r=Math.ceil(e*s);return r>=n?r=n:s=r/e,{scale:s,size:r}}clipBbox(t,e,i,s,n){const r=s-e,a=n-i;t.ctx.rect(e,i,r,a),np.axialAlignedBoundingBox([e,i,s,n],Dp(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const s=t.ctx,n=t.current;switch(e){case Cf:const{fillStyle:t,strokeStyle:r}=this.ctx;s.fillStyle=n.fillColor=t,s.strokeStyle=n.strokeColor=r;break;case Tf:s.fillStyle=s.strokeStyle=i,n.fillColor=n.strokeColor=i;break;default:throw new Ju(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,s,n){let r=i;s!==yf&&(r=np.transform(r,e.baseTransform),this.matrix&&(r=np.transform(r,this.matrix)));const a=this.createPatternCanvas(e,n);let o=new DOMMatrix(r);o=o.translate(a.offsetX,a.offsetY),o=o.scale(1/a.scaleX,1/a.scaleY);const l=t.createPattern(a.canvas,"repeat");return l.setTransform(o),l}};jd(Pf,"MAX_PATTERN_SIZE",3e3);let Df=Pf;function Rf({src:t,srcPos:e=0,dest:i,width:s,height:n,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=ip.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],c=s>>3,d=7&s,u=t.length;i=new Uint32Array(i.buffer);let p=0;for(let g=0;g<n;g++){for(const n=e+c;e<n;e++){const s=e<u?t[e]:255;i[p++]=128&s?h:l,i[p++]=64&s?h:l,i[p++]=32&s?h:l,i[p++]=16&s?h:l,i[p++]=8&s?h:l,i[p++]=4&s?h:l,i[p++]=2&s?h:l,i[p++]=1&s?h:l}if(0===d)continue;const s=e<u?t[e++]:255;for(let t=0;t<d;t++)i[p++]=s&1<<7-t?h:l}return{srcPos:e,destPos:p}}const If=16,Lf=new DOMMatrix,Ff=new Float32Array(2),Nf=new Float32Array([1/0,1/0,-1/0,-1/0]);class Wf{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let s;return void 0!==this.cache[t]?(s=this.cache[t],this.canvasFactory.reset(s,e,i)):(s=this.canvasFactory.create(e,i),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function Bf(t,e,i,s,n,r,a,o,l,h){const[c,d,u,p,g,f]=Dp(t);if(0===d&&0===u){const m=a*c+g,v=Math.round(m),w=o*p+f,b=Math.round(w),y=(a+l)*c+g,A=Math.abs(Math.round(y)-v)||1,_=(o+h)*p+f,x=Math.abs(Math.round(_)-b)||1;return t.setTransform(Math.sign(c),0,0,Math.sign(p),v,b),t.drawImage(e,i,s,n,r,0,0,A,x),t.setTransform(c,d,u,p,g,f),[A,x]}if(0===c&&0===p){const m=o*u+g,v=Math.round(m),w=a*d+f,b=Math.round(w),y=(o+h)*u+g,A=Math.abs(Math.round(y)-v)||1,_=(a+l)*d+f,x=Math.abs(Math.round(_)-b)||1;return t.setTransform(0,Math.sign(d),Math.sign(u),0,v,b),t.drawImage(e,i,s,n,r,0,0,x,A),t.setTransform(c,d,u,p,g,f),[x,A]}t.drawImage(e,i,s,n,r,a,o,l,h);return[Math.hypot(c,d)*l,Math.hypot(u,p)*h]}class Of{constructor(t,e,i){jd(this,"alphaIsShape",!1),jd(this,"fontSize",0),jd(this,"fontSizeScale",1),jd(this,"textMatrix",null),jd(this,"textMatrixScale",1),jd(this,"fontMatrix",su),jd(this,"leading",0),jd(this,"x",0),jd(this,"y",0),jd(this,"lineX",0),jd(this,"lineY",0),jd(this,"charSpacing",0),jd(this,"wordSpacing",0),jd(this,"textHScale",1),jd(this,"textRenderingMode",wu),jd(this,"textRise",0),jd(this,"fillColor","#000000"),jd(this,"strokeColor","#000000"),jd(this,"patternFill",!1),jd(this,"patternStroke",!1),jd(this,"fillAlpha",1),jd(this,"strokeAlpha",1),jd(this,"lineWidth",1),jd(this,"activeSMask",null),jd(this,"transferMaps","none"),null==i||i(this),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=Nf.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=wf,e=null){const i=this.minMax.slice();if(t===bf){e||$u("Stroke bounding box must include transform."),np.singularValueDecompose2dScale(e,Ff);const t=Ff[0]*this.lineWidth/2,s=Ff[1]*this.lineWidth/2;i[0]-=t,i[1]-=s,i[2]+=t,i[3]+=s}return i}updateClipFromPath(){const t=np.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(Nf,0)}getClippedPathBoundingBox(t=wf,e=null){return np.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Uf(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,s=e.width,n=i%If,r=(i-n)/If,a=0===n?r:r+1,o=t.createImageData(s,If);let l,h=0;const c=e.data,d=o.data;let u,p,g,f;if(e.kind===ku.GRAYSCALE_1BPP){const e=c.byteLength,i=new Uint32Array(d.buffer,0,d.byteLength>>2),f=i.length,m=s+7>>3,v=4294967295,w=ip.isLittleEndian?4278190080:255;for(u=0;u<a;u++){for(g=u<r?If:n,l=0,p=0;p<g;p++){const t=e-h;let n=0;const r=t>m?s:8*t-7,a=-8&r;let o=0,d=0;for(;n<a;n+=8)d=c[h++],i[l++]=128&d?v:w,i[l++]=64&d?v:w,i[l++]=32&d?v:w,i[l++]=16&d?v:w,i[l++]=8&d?v:w,i[l++]=4&d?v:w,i[l++]=2&d?v:w,i[l++]=1&d?v:w;for(;n<r;n++)0===o&&(d=c[h++],o=128),i[l++]=d&o?v:w,o>>=1}for(;l<f;)i[l++]=0;t.putImageData(o,0,u*If)}}else if(e.kind===ku.RGBA_32BPP){for(p=0,f=s*If*4,u=0;u<r;u++)d.set(c.subarray(h,h+f)),h+=f,t.putImageData(o,0,p),p+=If;u<a&&(f=s*n*4,d.set(c.subarray(h,h+f)),t.putImageData(o,0,p))}else{if(e.kind!==ku.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=If,f=s*g,u=0;u<a;u++){for(u>=r&&(g=n,f=s*g),l=0,p=f;p--;)d[l++]=c[h++],d[l++]=c[h++],d[l++]=c[h++],d[l++]=255;t.putImageData(o,0,u*If)}}}function Hf(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,s=e.width,n=i%If,r=(i-n)/If,a=0===n?r:r+1,o=t.createImageData(s,If);let l=0;const h=e.data,c=o.data;for(let d=0;d<a;d++){const e=d<r?If:n;({srcPos:l}=Rf({src:h,srcPos:l,dest:c,width:s,height:e,nonBlackColor:0})),t.putImageData(o,0,d*If)}}function $f(t,e){const i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of i)void 0!==t[s]&&(e[s]=t[s]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function jf(t){t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0);const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}function zf(t,e){if(e)return!0;np.singularValueDecompose2dScale(t,Ff);const i=Math.fround(Lp.pixelRatio*mp.PDF_TO_CSS_UNITS);return Ff[0]<=i&&Ff[1]<=i}const Vf=["butt","round","square"],Gf=["miter","round","bevel"],qf={},Xf={};Ys=new WeakSet,Ks=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},Qs=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}},Js=function(t,e,i){const s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s};let Yf=class t{constructor(t,e,i,s,n,{optionalContentConfig:r,markedContentStack:a=null},o,l,h){Gd(this,Ys),this.ctx=t,this.current=new Of(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=n,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=r,this.cachedCanvases=new Wf(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=h??null}getObject(t,e,i=null){var s;return"string"==typeof e?(null==(s=this.dependencyTracker)||s.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):i}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,i){const t=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...Dp(this.compositeCtx))}this.ctx.save(),jf(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=Dp(this.ctx)}executeOperatorList(t,e,i,s,n){var r;const a=t.argsArray,o=t.fnArray;let l=e||0;const h=a.length;if(h===l)return l;const c=h-l>10&&"function"==typeof i,d=c?Date.now()+15:0;let u=0;const p=this.commonObjs,g=this.objs;let f,m;for(;;){if(void 0!==s&&l===s.nextBreakPoint)return s.breakIt(l,i),l;if(!n||n(l))if(f=o[l],m=a[l]??null,f!==Ru.dependency)null===m?this[f](l):this[f](l,...m);else for(const t of m){null==(r=this.dependencyTracker)||r.recordNamedData(t,l);const e=t.startsWith("g_")?p:g;if(!e.has(t))return e.get(t,i),l}if(l++,l===h)return l;if(c&&++u>10){if(Date.now()>d)return i(),l;u=0}}}endDrawing(){Xd(this,Ys,Ks).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),Xd(this,Ys,Qs).call(this)}_scaleImage(t,e){const i=t.width??t.displayWidth,s=t.height??t.displayHeight;let n,r,a=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=i,h=s,c="prescale1";for(;a>2&&l>1||o>2&&h>1;){let e=l,i=h;a>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),a/=l/e),o>2&&h>1&&(i=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/i),n=this.cachedCanvases.getCanvas(c,e,i),r=n.context,r.clearRect(0,0,e,i),r.drawImage(t,0,0,l,h,0,0,e,i),t=n.canvas,l=e,h=i,c="prescale1"===c?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t,e){var i,s;const n=this.ctx,{width:r,height:a}=e,o=this.current.fillColor,l=this.current.patternFill,h=Dp(n);let c,d,u,p;if((e.bitmap||e.data)&&e.count>1){const s=e.bitmap||e.data.buffer;d=JSON.stringify(l?h:[h.slice(0,4),o]),c=this._cachedBitmapsMap.get(s),c||(c=new Map,this._cachedBitmapsMap.set(s,c));const n=c.get(d);if(n&&!l){const e=Math.round(Math.min(h[0],h[2])+h[4]),s=Math.round(Math.min(h[1],h[3])+h[5]);return null==(i=this.dependencyTracker)||i.recordDependencies(t,vf),{canvas:n,offsetX:e,offsetY:s}}u=n}u||(p=this.cachedCanvases.getCanvas("maskCanvas",r,a),Hf(p.context,e));let g=np.transform(h,[1/r,0,0,-1/a,0,0]);g=np.transform(g,[1,0,0,1,0,-a]);const f=Nf.slice();np.axialAlignedBoundingBox([0,0,r,a],g,f);const[m,v,w,b]=f,y=Math.round(w-m)||1,A=Math.round(b-v)||1,_=this.cachedCanvases.getCanvas("fillCanvas",y,A),x=_.context,k=m,S=v;x.translate(-k,-S),x.transform(...g),u||(u=this._scaleImage(p.canvas,Rp(x)),u=u.img,c&&l&&c.set(d,u)),x.imageSmoothingEnabled=zf(Dp(x),e.interpolate),Bf(x,u,0,0,u.width,u.height,0,0,r,a),x.globalCompositeOperation="source-in";const M=np.transform(Rp(x),[1,0,0,1,-k,-S]);return x.fillStyle=l?o.getPattern(n,this,M,wf,t):o,x.fillRect(0,0,r,a),c&&!l&&(this.cachedCanvases.delete("fillCanvas"),c.set(d,_.canvas)),null==(s=this.dependencyTracker)||s.recordDependencies(t,vf),{canvas:_.canvas,offsetX:Math.round(k),offsetY:Math.round(S)}}setLineWidth(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("lineCap",t),this.ctx.lineCap=Vf[e]}setLineJoin(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("lineJoin",t),this.ctx.lineJoin=Gf[e]}setMiterLimit(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,i){var s;null==(s=this.dependencyTracker)||s.recordSimpleData("dash",t);const n=this.ctx;void 0!==n.setLineDash&&(n.setLineDash(e),n.lineDashOffset=i)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){var i,s,n,r,a;for(const[o,l]of e)switch(o){case"LW":this.setLineWidth(t,l);break;case"LC":this.setLineCap(t,l);break;case"LJ":this.setLineJoin(t,l);break;case"ML":this.setMiterLimit(t,l);break;case"D":this.setDash(t,l[0],l[1]);break;case"RI":this.setRenderingIntent(t,l);break;case"FL":this.setFlatness(t,l);break;case"Font":this.setFont(t,l[0],l[1]);break;case"CA":null==(i=this.dependencyTracker)||i.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=l;break;case"ca":null==(s=this.dependencyTracker)||s.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=l;break;case"BM":null==(n=this.dependencyTracker)||n.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=l;break;case"SMask":null==(r=this.dependencyTracker)||r.recordSimpleData("SMask",t),this.current.activeSMask=l?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":null==(a=this.dependencyTracker)||a.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(l)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(t){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const e=this.ctx.canvas.width,i=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,n=this.cachedCanvases.getCanvas(s,e,i);this.suspendedCtx=this.ctx;const r=this.ctx=n.context;r.setTransform(this.suspendedCtx.getTransform()),$f(this.suspendedCtx,r),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,i){e.translate(t,i),this.__originalTranslate(t,i)},t.scale=function(t,i){e.scale(t,i),this.__originalScale(t,i)},t.transform=function(t,i,s,n,r,a){e.transform(t,i,s,n,r,a),this.__originalTransform(t,i,s,n,r,a)},t.setTransform=function(t,i,s,n,r,a){e.setTransform(t,i,s,n,r,a),this.__originalSetTransform(t,i,s,n,r,a)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,i){e.moveTo(t,i),this.__originalMoveTo(t,i)},t.lineTo=function(t,i){e.lineTo(t,i),this.__originalLineTo(t,i)},t.bezierCurveTo=function(t,i,s,n,r,a){e.bezierCurveTo(t,i,s,n,r,a),this.__originalBezierCurveTo(t,i,s,n,r,a)},t.rect=function(t,i,s,n){e.rect(t,i,s,n),this.__originalRect(t,i,s,n)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(r,this.suspendedCtx),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),$f(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,i,s){const n=s[0],r=s[1],a=s[2]-n,o=s[3]-r;0!==a&&0!==o&&(this.genericComposeSMask(e.context,i,a,o,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,s,n,r,a,o,l,h,c){let d=t.canvas,u=o-h,p=l-c;if(r)if(u<0||p<0||u+i>d.width||p+s>d.height){const t=this.cachedCanvases.getCanvas("maskExtension",i,s),e=t.context;e.drawImage(d,-u,-p),e.globalCompositeOperation="destination-atop",e.fillStyle=r,e.fillRect(0,0,i,s),e.globalCompositeOperation="source-over",d=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const e=new Path2D;e.rect(u,p,i,s),t.clip(e),t.globalCompositeOperation="destination-atop",t.fillStyle=r,t.fillRect(u,p,i,s),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===n&&a?e.filter=this.filterFactory.addAlphaFilter(a):"Luminosity"===n&&(e.filter=this.filterFactory.addLuminosityFilter(a));const g=new Path2D;g.rect(o,l,i,s),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(d,u,p,i,s,o,l,i,s),e.restore()}save(t){var e;this.inSMaskMode&&$f(this.ctx,this.suspendedCtx),this.ctx.save();const i=this.current;this.stateStack.push(i),this.current=i.clone(),null==(e=this.dependencyTracker)||e.save(t)}restore(t){var e;null==(e=this.dependencyTracker)||e.restore(t),0!==this.stateStack.length?(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&$f(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null):this.inSMaskMode&&this.endSMaskMode()}transform(t,e,i,s,n,r,a){var o;null==(o=this.dependencyTracker)||o.recordIncrementalData("transform",t),this.ctx.transform(e,i,s,n,r,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i,s){let[n]=i;if(!s)return n||(n=i[0]=new Path2D),void this[e](t,n);if(null!==this.dependencyTracker){const i=e===Ru.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,s[0]-i,s[2]+i,s[1]-i,s[3]+i).recordDependencies(t,["transform"])}if(!(n instanceof Path2D)){const t=i[0]=new Path2D;for(let e=0,i=n.length;e<i;)switch(n[e++]){case Iu:t.moveTo(n[e++],n[e++]);break;case Lu:t.lineTo(n[e++],n[e++]);break;case Fu:t.bezierCurveTo(n[e++],n[e++],n[e++],n[e++],n[e++],n[e++]);break;case Nu:t.closePath();break;default:Hu(`Unrecognized drawing path operator: ${n[e-1]}`)}n=t}np.axialAlignedBoundingBox(s,Dp(this.ctx),this.current.minMax),this[e](t,n),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,i=!0){var s;const n=this.ctx,r=this.current.strokeColor;if(n.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof r&&(null==r?void 0:r.getPattern)){const i=r.isModifyingCurrentTransform()?n.getTransform():null;if(n.save(),n.strokeStyle=r.getPattern(n,this,Rp(n),bf,t),i){const t=new Path2D;t.addPath(e,n.getTransform().invertSelf().multiplySelf(i)),e=t}this.rescaleAndStroke(e,!1),n.restore()}else this.rescaleAndStroke(e,!0);null==(s=this.dependencyTracker)||s.recordDependencies(t,df),i&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(bf,Dp(this.ctx))),n.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,i=!0){var s,n,r;const a=this.ctx,o=this.current.fillColor;let l=!1;if(this.current.patternFill){const i=o.isModifyingCurrentTransform()?a.getTransform():null;if(null==(s=this.dependencyTracker)||s.save(t),a.save(),a.fillStyle=o.getPattern(a,this,Rp(a),wf,t),i){const t=new Path2D;t.addPath(e,a.getTransform().invertSelf().multiplySelf(i)),e=t}l=!0}const h=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==h&&(this.pendingEOFill?(a.fill(e,"evenodd"),this.pendingEOFill=!1):a.fill(e)),null==(n=this.dependencyTracker)||n.recordDependencies(t,uf),l&&(a.restore(),null==(r=this.dependencyTracker)||r.restore(t)),i&&this.consumePath(t,e,h)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){var i;this.ctx.fill(e),null==(i=this.dependencyTracker)||i.recordDependencies(t,gf).recordOperation(t)}clip(t){var e;null==(e=this.dependencyTracker)||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=qf}eoClip(t){var e;null==(e=this.dependencyTracker)||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=Xf}beginText(t){var e;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,null==(e=this.dependencyTracker)||e.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,i=this.ctx;if(this.dependencyTracker){const{dependencyTracker:i}=this;void 0!==e&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(void 0!==e){const t=new Path2D,s=i.getTransform().invertSelf();for(const{transform:i,x:n,y:r,fontSize:a,path:o}of e)o&&t.addPath(o,new DOMMatrix(i).preMultiplySelf(s).translate(n,r).scale(a,-a));i.clip(t)}delete this.pendingTextPaths}setCharSpacing(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,i){var s,n;null==(s=this.dependencyTracker)||s.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const r=this.commonObjs.get(e),a=this.current;if(!r)throw new Error(`Can't find font for ${e}`);if(a.fontMatrix=r.fontMatrix||su,0!==a.fontMatrix[0]&&0!==a.fontMatrix[3]||Hu("Invalid font matrix for font "+e),i<0?(i=-i,a.fontDirection=-1):a.fontDirection=1,this.current.font=r,this.current.fontSize=i,r.isType3Font)return;const o=r.loadedName||"sans-serif",l=(null==(n=r.systemFontInfo)?void 0:n.css)||`"${o}", ${r.fallbackName}`;let h="normal";r.black?h="900":r.bold&&(h="bold");const c=r.italic?"italic":"normal";let d=i;i<16?d=16:i>100&&(d=100),this.current.fontSizeScale=i/d,this.ctx.font=`${c} ${h} ${d}px ${l}`}setTextRenderingMode(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,i){var s;null==(s=this.dependencyTracker)||s.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=i}setLeadingMoveText(t,e,i){this.setLeading(t,-i),this.moveText(t,e,i)}setTextMatrix(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("textMatrix",t);const{current:s}=this;s.textMatrix=e,s.textMatrixScale=Math.hypot(e[0],e[1]),s.x=s.lineX=0,s.y=s.lineY=0}nextLine(t){var e;this.moveText(t,0,this.current.leading),null==(e=this.dependencyTracker)||e.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}paintChar(t,e,i,s,n,r){var a,o,l,h;const c=this.ctx,d=this.current,u=d.font,p=d.textRenderingMode,g=d.fontSize/d.fontSizeScale,f=p&_u,m=!!(p&xu),v=d.patternFill&&!u.missingFile,w=d.patternStroke&&!u.missingFile;let b;if((u.disableFontFace||m||v||w)&&!u.missingFile&&(b=u.getPathGenerator(this.commonObjs,e)),b&&(u.disableFontFace||v||w)){let e;if(c.save(),c.translate(i,s),c.scale(g,-g),null==(a=this.dependencyTracker)||a.recordCharacterBBox(t,c,u),f===wu||f===yu)if(n){e=c.getTransform(),c.setTransform(...n);const t=Xd(this,Ys,Js).call(this,b,e,n);c.fill(t)}else c.fill(b);if(f===bu||f===yu)if(r){e||(e=c.getTransform()),c.setTransform(...r);const{a:t,b:i,c:s,d:n}=e,a=np.inverseTransform(r),o=np.transform([t,i,s,n,0,0],a);np.singularValueDecompose2dScale(o,Ff),c.lineWidth*=Math.max(Ff[0],Ff[1])/g,c.stroke(Xd(this,Ys,Js).call(this,b,e,r))}else c.lineWidth/=g,c.stroke(b);c.restore()}else f!==wu&&f!==yu||(c.fillText(e,i,s),null==(o=this.dependencyTracker)||o.recordCharacterBBox(t,c,u,g,i,s,()=>c.measureText(e))),f!==bu&&f!==yu||(this.dependencyTracker&&(null==(l=this.dependencyTracker)||l.recordCharacterBBox(t,c,u,g,i,s,()=>c.measureText(e)).recordDependencies(t,df)),c.strokeText(e,i,s));if(m){(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Dp(c),x:i,y:s,fontSize:g,path:b}),null==(h=this.dependencyTracker)||h.recordCharacterBBox(t,c,u,g,i,s)}}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let i=!1;for(let s=3;s<e.length;s+=4)if(e[s]>0&&e[s]<255){i=!0;break}return Gu(this,"isFontSubpixelAAEnabled",i)}showText(t,e){var i,s,n,r;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,ff).resetBBox(t),this.current.textRenderingMode&xu&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const a=this.current,o=a.font;if(o.isType3Font)return this.showType3Text(t,e),void(null==(i=this.dependencyTracker)||i.recordShowTextOperation(t));const l=a.fontSize;if(0===l)return void(null==(s=this.dependencyTracker)||s.recordOperation(t));const h=this.ctx,c=a.fontSizeScale,d=a.charSpacing,u=a.wordSpacing,p=a.fontDirection,g=a.textHScale*p,f=e.length,m=o.vertical,v=m?1:-1,w=o.defaultVMetrics,b=l*a.fontMatrix[0],y=a.textRenderingMode===wu&&!o.disableFontFace&&!a.patternFill;let A,_;if(h.save(),a.textMatrix&&h.transform(...a.textMatrix),h.translate(a.x,a.y+a.textRise),p>0?h.scale(g,-1):h.scale(g,1),a.patternFill){h.save();const e=a.fillColor.getPattern(h,this,Rp(h),wf,t);A=Dp(h),h.restore(),h.fillStyle=e}if(a.patternStroke){h.save();const e=a.strokeColor.getPattern(h,this,Rp(h),bf,t);_=Dp(h),h.restore(),h.strokeStyle=e}let x=a.lineWidth;const k=a.textMatrixScale;if(0===k||0===x){const t=a.textRenderingMode&_u;t!==bu&&t!==yu||(x=this.getSinglePixelWidth())}else x/=k;if(1!==c&&(h.scale(c,c),x/=c),h.lineWidth=x,o.isInvalidPDFjsFont){const i=[];let s=0;for(const t of e)i.push(t.unicode),s+=t.width;const n=i.join("");if(h.fillText(n,0,0),null!==this.dependencyTracker){const e=h.measureText(n);this.dependencyTracker.recordBBox(t,this.ctx,-e.actualBoundingBoxLeft,e.actualBoundingBoxRight,-e.actualBoundingBoxAscent,e.actualBoundingBoxDescent).recordShowTextOperation(t)}return a.x+=s*b*g,h.restore(),void this.compose()}let S,M=0;for(S=0;S<f;++S){const i=e[S];if("number"==typeof i){M+=v*i*l/1e3;continue}let s=!1;const r=(i.isSpace?u:0)+d,a=i.fontChar,g=i.accent;let f,x,k,E=i.width;if(m){const t=i.vmetric||w,e=-(i.vmetric?t[1]:.5*E)*b,s=t[2]*b;E=t?-t[0]:E,f=e/c,x=(M+s)/c}else f=M/c,x=0;if(o.remeasure&&E>0){k=h.measureText(a);const t=1e3*k.width/l*c;if(E<t&&this.isFontSubpixelAAEnabled){const e=E/t;s=!0,h.save(),h.scale(e,1),f/=e}else E!==t&&(f+=(E-t)/2e3*l/c)}if(this.contentVisible&&(i.isInFont||o.missingFile))if(y&&!g)h.fillText(a,f,x),null==(n=this.dependencyTracker)||n.recordCharacterBBox(t,h,k?{bbox:null}:o,l/c,f,x,()=>k??h.measureText(a));else if(this.paintChar(t,a,f,x,A,_),g){const e=f+l*g.offset.x/c,i=x-l*g.offset.y/c;this.paintChar(t,g.fontChar,e,i,A,_)}M+=m?E*b-r*p:E*b+r*p,s&&h.restore()}m?a.y-=M:a.x+=M*g,h.restore(),this.compose(),null==(r=this.dependencyTracker)||r.recordShowTextOperation(t)}showType3Text(t,e){const i=this.ctx,s=this.current,n=s.font,r=s.fontSize,a=s.fontDirection,o=n.vertical?1:-1,l=s.charSpacing,h=s.wordSpacing,c=s.textHScale*a,d=s.fontMatrix||su,u=e.length;let p,g,f,m;if(s.textRenderingMode===Au||0===r)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,i.save(),s.textMatrix&&i.transform(...s.textMatrix),i.translate(s.x,s.y+s.textRise),i.scale(c,a);const v=this.dependencyTracker;for(this.dependencyTracker=v?new cf(v,t):null,p=0;p<u;++p){if(g=e[p],"number"==typeof g){m=o*g*r/1e3,this.ctx.translate(m,0),s.x+=m*c;continue}const t=(g.isSpace?h:0)+l,a=n.charProcOperatorList[g.operatorListId];a?this.contentVisible&&(this.save(),i.scale(r,r),i.transform(...d),this.executeOperatorList(a),this.restore()):Hu(`Type3 character "${g.operatorListId}" is not available.`);const u=[g.width,0];np.applyTransform(u,d),f=u[0]*r+t,i.translate(f,0),s.x+=f*c}i.restore(),v&&(this.dependencyTracker=v)}setCharWidth(t,e,i){}setCharWidthAndBounds(t,e,i,s,n,r,a){var o;const l=new Path2D;l.rect(s,n,r-s,a-n),this.ctx.clip(l),null==(o=this.dependencyTracker)||o.recordBBox(t,this.ctx,s,r,n,a).recordClipBox(t,this.ctx,s,r,n,a),this.endPath(t)}getColorN_Pattern(e,i){let s;if("TilingPattern"===i[0]){const e=this.baseTransform||Dp(this.ctx),n={createCanvasGraphics:(e,i)=>new t(e,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new cf(this.dependencyTracker,i,!0):null)};s=new Df(i,this.ctx,n,e)}else s=this._getPattern(e,i[1],i[2]);return s}setStrokeColorN(t,...e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("fillColor",t),this.current.fillColor=this.getColorN_Pattern(t,e),this.current.patternFill=!0}setStrokeRGBColor(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){var e;null==(e=this.dependencyTracker)||e.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){var i;null==(i=this.dependencyTracker)||i.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1}setFillTransparent(t){var e;null==(e=this.dependencyTracker)||e.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e,i=null){let s;return this.cachedPatterns.has(e)?s=this.cachedPatterns.get(e):(s=function(t){switch(t[0]){case"RadialAxial":return new xf(t);case"Mesh":return new Mf(t);case"Dummy":return new Ef}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t,e)),this.cachedPatterns.set(e,s)),i&&(s.matrix=i),s}shadingFill(t,e){var i;if(!this.contentVisible)return;const s=this.ctx;this.save(t);const n=this._getPattern(t,e);s.fillStyle=n.getPattern(s,this,Rp(s),yf,t);const r=Rp(s);if(r){const{width:t,height:e}=s.canvas,i=Nf.slice();np.axialAlignedBoundingBox([0,0,t,e],r,i);const[n,a,o,l]=i;this.ctx.fillRect(n,a,o-n,l-a)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);null==(i=this.dependencyTracker)||i.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,mf).recordDependencies(t,uf).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){$u("Should not call beginInlineImage")}beginImageData(){$u("Should not call beginImageData")}paintFormXObjectBegin(t,e,i){var s;if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=Dp(this.ctx),i)){np.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);const[e,n,r,a]=i,o=new Path2D;o.rect(e,n,r-e,a-n),this.ctx.clip(o),null==(s=this.dependencyTracker)||s.recordClipBox(t,this.ctx,e,r,n,a),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){var i;if(!this.contentVisible)return;this.save(t),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const s=this.ctx;e.isolated||Uu("TODO: Support non-isolated groups."),e.knockout&&Hu("Knockout groups not supported.");const n=Dp(s);if(e.matrix&&s.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let r=Nf.slice();np.axialAlignedBoundingBox(e.bbox,Dp(s),r);const a=[0,0,s.canvas.width,s.canvas.height];r=np.intersect(r,a)||[0,0,0,0];const o=Math.floor(r[0]),l=Math.floor(r[1]),h=Math.max(Math.ceil(r[2])-o,1),c=Math.max(Math.ceil(r[3])-l,1);this.current.startNewPathAndClipBox([0,0,h,c]);let d="groupAt"+this.groupLevel;e.smask&&(d+="_smask_"+this.smaskCounter++%2);const u=this.cachedCanvases.getCanvas(d,h,c),p=u.context;p.translate(-o,-l),p.transform(...n);let g=new Path2D;const[f,m,v,w]=e.bbox;if(g.rect(f,m,v-f,w-m),e.matrix){const t=new Path2D;t.addPath(g,new DOMMatrix(e.matrix)),g=t}p.clip(g),e.smask&&this.smaskStack.push({canvas:u.canvas,context:p,offsetX:o,offsetY:l,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}),e.smask&&!this.dependencyTracker||(s.setTransform(1,0,0,1,0,0),s.translate(o,l),s.save()),$f(s,p),this.ctx=p,null==(i=this.dependencyTracker)||i.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(s),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(s),this.groupLevel++}endGroup(t,e){var i;if(!this.contentVisible)return;this.groupLevel--;const s=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,null==(i=this.dependencyTracker)||i.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&this.ctx.restore();else{this.ctx.restore();const e=Dp(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...e);const i=Nf.slice();np.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],e,i),this.ctx.drawImage(s.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(t,e,i,s,n,r){if(Xd(this,Ys,Ks).call(this),jf(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),i){const n=i[2]-i[0],a=i[3]-i[1];if(r&&this.annotationCanvasMap){(s=s.slice())[4]-=i[0],s[5]-=i[1],(i=i.slice())[0]=i[1]=0,i[2]=n,i[3]=a,np.singularValueDecompose2dScale(Dp(this.ctx),Ff);const{viewportScale:t}=this,r=Math.ceil(n*this.outputScaleX*t),o=Math.ceil(a*this.outputScaleY*t);this.annotationCanvas=this.canvasFactory.create(r,o);const{canvas:l,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(e,l),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(Ff[0],0,0,-Ff[1],0,a*Ff[1]),jf(this.ctx)}else{jf(this.ctx),this.endPath(t);const e=new Path2D;e.rect(i[0],i[1],n,a),this.ctx.clip(e)}}this.current=new Of(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(t,...s),this.transform(t,...n)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),Xd(this,Ys,Qs).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t,e){var i;if(!this.contentVisible)return;const s=e.count;(e=this.getObject(t,e.data,e)).count=s;const n=this.ctx,r=this._createMaskCanvas(t,e),a=r.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(a,r.offsetX,r.offsetY),null==(i=this.dependencyTracker)||i.resetBBox(t).recordBBox(t,this.ctx,r.offsetX,r.offsetX+a.width,r.offsetY,r.offsetY+a.height).recordOperation(t),n.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i,s=0,n=0,r,a){var o,l,h;if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const c=this.ctx;c.save();const d=Dp(c);c.transform(i,s,n,r,0,0);const u=this._createMaskCanvas(t,e);c.setTransform(1,0,0,1,u.offsetX-d[4],u.offsetY-d[5]),null==(o=this.dependencyTracker)||o.resetBBox(t);for(let p=0,g=a.length;p<g;p+=2){const e=np.transform(d,[i,s,n,r,a[p],a[p+1]]);c.drawImage(u.canvas,e[4],e[5]),null==(l=this.dependencyTracker)||l.recordBBox(t,this.ctx,e[4],e[4]+u.canvas.width,e[5],e[5]+u.canvas.height)}c.restore(),this.compose(),null==(h=this.dependencyTracker)||h.recordOperation(t)}paintImageMaskXObjectGroup(t,e){var i,s,n;if(!this.contentVisible)return;const r=this.ctx,a=this.current.fillColor,o=this.current.patternFill;null==(i=this.dependencyTracker)||i.resetBBox(t).recordDependencies(t,vf);for(const l of e){const{data:e,width:i,height:n,transform:h}=l,c=this.cachedCanvases.getCanvas("maskCanvas",i,n),d=c.context;d.save();Hf(d,this.getObject(t,e,l)),d.globalCompositeOperation="source-in",d.fillStyle=o?a.getPattern(d,this,Rp(r),wf,t):a,d.fillRect(0,0,i,n),d.restore(),r.save(),r.transform(...h),r.scale(1,-1),Bf(r,c.canvas,0,0,i,n,0,-1,1,1),null==(s=this.dependencyTracker)||s.recordBBox(t,r,0,i,0,n),r.restore()}this.compose(),null==(n=this.dependencyTracker)||n.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;const i=this.getObject(t,e);i?this.paintInlineImageXObject(t,i):Hu("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s,n){if(!this.contentVisible)return;const r=this.getObject(t,e);if(!r)return void Hu("Dependent image isn't ready yet");const a=r.width,o=r.height,l=[];for(let h=0,c=n.length;h<c;h+=2)l.push({transform:[i,0,0,s,n[h],n[h+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(t,r,l)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;const{bitmap:e,width:i,height:s}=t,n=this.cachedCanvases.getCanvas("inlineImage",i,s),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",n.canvas}paintInlineImageXObject(t,e){var i;if(!this.contentVisible)return;const s=e.width,n=e.height,r=this.ctx;this.save(t);const{filter:a}=r;let o;if("none"!==a&&""!==a&&(r.filter="none"),r.scale(1/s,-1/n),e.bitmap)o=this.applyTransferMapsToBitmap(e);else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)o=e;else{const t=this.cachedCanvases.getCanvas("inlineImage",s,n).context;Uf(t,e),o=this.applyTransferMapsToCanvas(t)}const l=this._scaleImage(o,Rp(r));r.imageSmoothingEnabled=zf(Dp(r),e.interpolate),null==(i=this.dependencyTracker)||i.resetBBox(t).recordBBox(t,r,0,s,-n,0).recordDependencies(t,pf).recordOperation(t),Bf(r,l.img,0,0,l.paintWidth,l.paintHeight,0,-n,s,n),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,i){var s,n,r;if(!this.contentVisible)return;const a=this.ctx;let o;if(e.bitmap)o=e.bitmap;else{const t=e.width,i=e.height,s=this.cachedCanvases.getCanvas("inlineImage",t,i).context;Uf(s,e),o=this.applyTransferMapsToCanvas(s)}null==(s=this.dependencyTracker)||s.resetBBox(t);for(const l of i)a.save(),a.transform(...l.transform),a.scale(1,-1),Bf(a,o,l.x,l.y,l.w,l.h,0,-1,1,1),null==(n=this.dependencyTracker)||n.recordBBox(t,a,0,1,-1,0),a.restore();null==(r=this.dependencyTracker)||r.recordOperation(t),this.compose()}paintSolidColorImageMask(t){var e;this.contentVisible&&(null==(e=this.dependencyTracker)||e.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,uf).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}markPointProps(t,e,i){}beginMarkedContent(t,e){var i;null==(i=this.dependencyTracker)||i.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,i){var s;null==(s=this.dependencyTracker)||s.beginMarkedContent(t),"OC"===e?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(i)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){var e;null==(e=this.dependencyTracker)||e.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,i){var s,n;const r=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(i);const a=this.ctx;this.pendingClip?(r||(this.pendingClip===Xf?a.clip(e,"evenodd"):a.clip(e)),this.pendingClip=null,null==(s=this.dependencyTracker)||s.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):null==(n=this.dependencyTracker)||n.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Dp(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:i,c:s,d:n}=this.ctx.getTransform();let r,a;if(0===i&&0===s){const i=Math.abs(e),s=Math.abs(n);if(i===s)if(0===t)r=a=1/i;else{const e=i*t;r=a=e<1?1/e:1}else if(0===t)r=1/i,a=1/s;else{const e=i*t,n=s*t;r=e<1?1/e:1,a=n<1?1/n:1}}else{const o=Math.abs(e*n-i*s),l=Math.hypot(e,i),h=Math.hypot(s,n);if(0===t)r=h/o,a=l/o;else{const e=t*o;r=h>e?h/e:1,a=l>e?l/e:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:i,current:{lineWidth:s}}=this,[n,r]=this.getScaleForStroking();if(n===r)return i.lineWidth=(s||1)*n,void i.stroke(t);const a=i.getLineDash();e&&i.save(),i.scale(n,r),Lf.a=1/n,Lf.d=1/r;const o=new Path2D;if(o.addPath(t,Lf),a.length>0){const t=Math.max(n,r);i.setLineDash(a.map(e=>e/t)),i.lineDashOffset/=t}i.lineWidth=s||1,i.stroke(o),e&&i.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};for(const ub in Ru)void 0!==Yf.prototype[ub]&&(Yf.prototype[Ru[ub]]=Yf.prototype[ub]);const Kf=class t{constructor(t){Gd(this,sn),Gd(this,Zs),Gd(this,tn),Gd(this,en),qd(this,Zs,t),qd(this,tn,new DataView(Vd(this,Zs))),qd(this,en,new TextDecoder)}static write(e){const i=new TextEncoder,s={};let n=0;for(const h of t.strings){const t=i.encode(e[h]);s[h]=t,n+=4+t.length}const r=new ArrayBuffer(n),a=new Uint8Array(r),o=new DataView(r);let l=0;for(const h of t.strings){const t=s[h],e=t.length;o.setUint32(l,e),a.set(t,l+4),l+=4+e}return ju(l===r.byteLength,"CssFontInfo.write: Buffer overflow"),r}get fontFamily(){return Xd(this,sn,nn).call(this,0)}get fontWeight(){return Xd(this,sn,nn).call(this,1)}get italicAngle(){return Xd(this,sn,nn).call(this,2)}};Zs=new WeakMap,tn=new WeakMap,en=new WeakMap,sn=new WeakSet,nn=function(t){ju(t<Kf.strings.length,"Invalid string index");let e=0;for(let s=0;s<t;s++)e+=Vd(this,tn).getUint32(e)+4;const i=Vd(this,tn).getUint32(e);return Vd(this,en).decode(new Uint8Array(Vd(this,Zs),e+4,i))},jd(Kf,"strings",["fontFamily","fontWeight","italicAngle"]);let Qf=Kf;const Jf=class t{constructor(t){Gd(this,ln),Gd(this,rn),Gd(this,an),Gd(this,on),qd(this,rn,t),qd(this,an,new DataView(Vd(this,rn))),qd(this,on,new TextDecoder)}static write(e){const i=new TextEncoder,s={};let n=0;for(const u of t.strings){const t=i.encode(e[u]);s[u]=t,n+=4+t.length}n+=4;let r,a,o=1+n;e.style&&(r=i.encode(e.style.style),a=i.encode(e.style.weight),o+=4+r.length+4+a.length);const l=new ArrayBuffer(o),h=new Uint8Array(l),c=new DataView(l);let d=0;c.setUint8(d++,e.guessFallback?1:0),c.setUint32(d,0),d+=4,n=0;for(const u of t.strings){const t=s[u],e=t.length;n+=4+e,c.setUint32(d,e),h.set(t,d+4),d+=4+e}return c.setUint32(d-n-4,n),e.style&&(c.setUint32(d,r.length),h.set(r,d+4),d+=4+r.length,c.setUint32(d,a.length),h.set(a,d+4),d+=4+a.length),ju(d<=l.byteLength,"SubstitionInfo.write: Buffer overflow"),l.transferToFixedLength(d)}get guessFallback(){return 0!==Vd(this,an).getUint8(0)}get css(){return Xd(this,ln,hn).call(this,0)}get loadedName(){return Xd(this,ln,hn).call(this,1)}get baseFontName(){return Xd(this,ln,hn).call(this,2)}get src(){return Xd(this,ln,hn).call(this,3)}get style(){let t=1;t+=4+Vd(this,an).getUint32(t);const e=Vd(this,an).getUint32(t),i=Vd(this,on).decode(new Uint8Array(Vd(this,rn),t+4,e));t+=4+e;const s=Vd(this,an).getUint32(t);return{style:i,weight:Vd(this,on).decode(new Uint8Array(Vd(this,rn),t+4,s))}}};rn=new WeakMap,an=new WeakMap,on=new WeakMap,ln=new WeakSet,hn=function(t){ju(t<Jf.strings.length,"Invalid string index");let e=5;for(let s=0;s<t;s++)e+=Vd(this,an).getUint32(e)+4;const i=Vd(this,an).getUint32(e);return Vd(this,on).decode(new Uint8Array(Vd(this,rn),e+4,i))},jd(Jf,"strings",["css","loadedName","baseFontName","src"]);let Zf=Jf;const tm=class t{constructor({data:t,extra:e}){Gd(this,wn),Gd(this,fn),Gd(this,mn),Gd(this,vn),qd(this,fn,t),qd(this,mn,new TextDecoder),qd(this,vn,new DataView(Vd(this,fn))),e&&Object.assign(this,e)}get black(){return Xd(this,wn,bn).call(this,0)}get bold(){return Xd(this,wn,bn).call(this,1)}get disableFontFace(){return Xd(this,wn,bn).call(this,2)}get fontExtraProperties(){return Xd(this,wn,bn).call(this,3)}get isInvalidPDFjsFont(){return Xd(this,wn,bn).call(this,4)}get isType3Font(){return Xd(this,wn,bn).call(this,5)}get italic(){return Xd(this,wn,bn).call(this,6)}get missingFile(){return Xd(this,wn,bn).call(this,7)}get remeasure(){return Xd(this,wn,bn).call(this,8)}get vertical(){return Xd(this,wn,bn).call(this,9)}get ascent(){return Xd(this,wn,yn).call(this,0)}get defaultWidth(){return Xd(this,wn,yn).call(this,1)}get descent(){return Xd(this,wn,yn).call(this,2)}get bbox(){let e=Vd(t,dn);if(0===Vd(this,vn).getUint8(e))return;e+=1;const i=[];for(let t=0;t<4;t++)i.push(Vd(this,vn).getInt16(e,!0)),e+=2;return i}get fontMatrix(){let e=Vd(t,un);if(0===Vd(this,vn).getUint8(e))return;e+=1;const i=[];for(let t=0;t<6;t++)i.push(Vd(this,vn).getFloat64(e,!0)),e+=8;return i}get defaultVMetrics(){let e=Vd(t,pn);if(0===Vd(this,vn).getUint8(e))return;e+=1;const i=[];for(let t=0;t<3;t++)i.push(Vd(this,vn).getInt16(e,!0)),e+=2;return i}get fallbackName(){return Xd(this,wn,An).call(this,0)}get loadedName(){return Xd(this,wn,An).call(this,1)}get mimetype(){return Xd(this,wn,An).call(this,2)}get name(){return Xd(this,wn,An).call(this,3)}get data(){let e=Vd(t,gn);e+=4+Vd(this,vn).getUint32(e);e+=4+Vd(this,vn).getUint32(e);e+=4+Vd(this,vn).getUint32(e);const i=Vd(this,vn).getUint32(e);if(0!==i)return new Uint8Array(Vd(this,fn),e+4,i)}clearData(){let e=Vd(t,gn);e+=4+Vd(this,vn).getUint32(e);e+=4+Vd(this,vn).getUint32(e);e+=4+Vd(this,vn).getUint32(e);const i=Vd(this,vn).getUint32(e);new Uint8Array(Vd(this,fn),e+4,i).fill(0),Vd(this,vn).setUint32(e,0)}get cssFontInfo(){let e=Vd(t,gn);e+=4+Vd(this,vn).getUint32(e);e+=4+Vd(this,vn).getUint32(e);const i=Vd(this,vn).getUint32(e);if(0===i)return null;const s=new Uint8Array(i);return s.set(new Uint8Array(Vd(this,fn),e+4,i)),new Qf(s.buffer)}get systemFontInfo(){let e=Vd(t,gn);e+=4+Vd(this,vn).getUint32(e);const i=Vd(this,vn).getUint32(e);if(0===i)return null;const s=new Uint8Array(i);return s.set(new Uint8Array(Vd(this,fn),e+4,i)),new Zf(s.buffer)}static write(e){const i=e.systemFontInfo?Zf.write(e.systemFontInfo):null,s=e.cssFontInfo?Qf.write(e.cssFontInfo):null,n=new TextEncoder,r={};let a=0;for(const f of t.strings)r[f]=n.encode(e[f]),a+=4+r[f].length;const o=Vd(t,gn)+4+a+4+(i?i.byteLength:0)+4+(s?s.byteLength:0)+4+(e.data?e.data.length:0),l=new ArrayBuffer(o),h=new Uint8Array(l),c=new DataView(l);let d=0;const u=t.bools.length;let p=0,g=0;for(let f=0;f<u;f++){const i=e[t.bools[f]];p|=(void 0===i?0:i?2:1)<<g,g+=2,8!==g&&f!==u-1||(c.setUint8(d++,p),p=0,g=0)}ju(d===Vd(t,cn),"FontInfo.write: Boolean properties offset mismatch");for(const f of t.numbers)c.setFloat64(d,e[f]),d+=8;if(ju(d===Vd(t,dn),"FontInfo.write: Number properties offset mismatch"),e.bbox){c.setUint8(d++,4);for(const t of e.bbox)c.setInt16(d,t,!0),d+=2}else c.setUint8(d++,0),d+=8;if(ju(d===Vd(t,un),"FontInfo.write: BBox properties offset mismatch"),e.fontMatrix){c.setUint8(d++,6);for(const t of e.fontMatrix)c.setFloat64(d,t,!0),d+=8}else c.setUint8(d++,0),d+=48;if(ju(d===Vd(t,pn),"FontInfo.write: FontMatrix properties offset mismatch"),e.defaultVMetrics){c.setUint8(d++,1);for(const t of e.defaultVMetrics)c.setInt16(d,t,!0),d+=2}else c.setUint8(d++,0),d+=6;ju(d===Vd(t,gn),"FontInfo.write: DefaultVMetrics properties offset mismatch"),c.setUint32(Vd(t,gn),0),d+=4;for(const f of t.strings){const t=r[f],e=t.length;c.setUint32(d,e),h.set(t,d+4),d+=4+e}if(c.setUint32(Vd(t,gn),d-Vd(t,gn)-4),i){const t=i.byteLength;c.setUint32(d,t),ju(d+4+t<=l.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),h.set(new Uint8Array(i),d+4),d+=4+t}else c.setUint32(d,0),d+=4;if(s){const t=s.byteLength;c.setUint32(d,t),ju(d+4+t<=l.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),h.set(new Uint8Array(s),d+4),d+=4+t}else c.setUint32(d,0),d+=4;return void 0===e.data?(c.setUint32(d,0),d+=4):(c.setUint32(d,e.data.length),h.set(e.data,d+4),d+=4+e.data.length),ju(d<=l.byteLength,"FontInfo.write: Buffer overflow"),l.transferToFixedLength(d)}};cn=new WeakMap,dn=new WeakMap,un=new WeakMap,pn=new WeakMap,gn=new WeakMap,fn=new WeakMap,mn=new WeakMap,vn=new WeakMap,wn=new WeakSet,bn=function(t){ju(t<tm.bools.length,"Invalid boolean index");const e=Math.floor(t/4),i=2*t%8,s=Vd(this,vn).getUint8(e)>>i&3;return 0===s?void 0:2===s},yn=function(t){return ju(t<tm.numbers.length,"Invalid number index"),Vd(this,vn).getFloat64(Vd(tm,cn)+8*t)},An=function(t){ju(t<tm.strings.length,"Invalid string index");let e=Vd(tm,gn)+4;for(let n=0;n<t;n++)e+=Vd(this,vn).getUint32(e)+4;const i=Vd(this,vn).getUint32(e),s=new Uint8Array(i);return s.set(new Uint8Array(Vd(this,fn),e+4,i)),Vd(this,mn).decode(s)},jd(tm,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),jd(tm,"numbers",["ascent","defaultWidth","descent"]),jd(tm,"strings",["fallbackName","loadedName","mimetype","name"]),Gd(tm,cn,Math.ceil(2*tm.bools.length/8)),Gd(tm,dn,Vd(tm,cn)+8*tm.numbers.length),Gd(tm,un,Vd(tm,dn)+1+8),Gd(tm,pn,Vd(tm,un)+1+48),Gd(tm,gn,Vd(tm,pn)+1+6);let em=tm;class im{static get workerPort(){return Vd(this,_n)}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");qd(this,_n,t)}static get workerSrc(){return Vd(this,xn)}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");qd(this,xn,t)}}_n=new WeakMap,xn=new WeakMap,Gd(im,_n,null),Gd(im,xn,"");class sm{constructor({parsedData:t,rawData:e}){Gd(this,kn),Gd(this,Sn),qd(this,kn,t),qd(this,Sn,e)}getRaw(){return Vd(this,Sn)}get(t){return Vd(this,kn).get(t)??null}[Symbol.iterator](){return Vd(this,kn).entries()}}kn=new WeakMap,Sn=new WeakMap;const nm=Symbol("INTERNAL");class rm{constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){Gd(this,Mn,!1),Gd(this,En,!1),Gd(this,Cn,!1),Gd(this,Tn,!0),qd(this,Mn,!!(t&au)),qd(this,En,!!(t&ou)),this.name=e,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(Vd(this,Cn))return Vd(this,Tn);if(!Vd(this,Tn))return!1;const{print:t,view:e}=this.usage;return Vd(this,Mn)?"OFF"!==(null==e?void 0:e.viewState):!Vd(this,En)||"OFF"!==(null==t?void 0:t.printState)}_setVisible(t,e,i=!1){t!==nm&&$u("Internal method `_setVisible` called."),qd(this,Cn,i),qd(this,Tn,e)}}Mn=new WeakMap,En=new WeakMap,Cn=new WeakMap,Tn=new WeakMap;class am{constructor(t,e=au){if(Gd(this,Ln),Gd(this,Pn,null),Gd(this,Dn,new Map),Gd(this,Rn,null),Gd(this,In,null),this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,qd(this,In,t.order);for(const i of t.groups)Vd(this,Dn).set(i.id,new rm(e,i));if("OFF"===t.baseState)for(const t of Vd(this,Dn).values())t._setVisible(nm,!1);for(const e of t.on)Vd(this,Dn).get(e)._setVisible(nm,!0);for(const e of t.off)Vd(this,Dn).get(e)._setVisible(nm,!1);qd(this,Rn,this.getHash())}}isVisible(t){if(0===Vd(this,Dn).size)return!0;if(!t)return Uu("Optional content group not defined."),!0;if("OCG"===t.type)return Vd(this,Dn).has(t.id)?Vd(this,Dn).get(t.id).visible:(Hu(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return Xd(this,Ln,Fn).call(this,t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!Vd(this,Dn).has(e))return Hu(`Optional content group not found: ${e}`),!0;if(Vd(this,Dn).get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!Vd(this,Dn).has(e))return Hu(`Optional content group not found: ${e}`),!0;if(!Vd(this,Dn).get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!Vd(this,Dn).has(e))return Hu(`Optional content group not found: ${e}`),!0;if(!Vd(this,Dn).get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!Vd(this,Dn).has(e))return Hu(`Optional content group not found: ${e}`),!0;if(Vd(this,Dn).get(e).visible)return!1}return!0}return Hu(`Unknown optional content policy ${t.policy}.`),!0}return Hu(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){var s;const n=Vd(this,Dn).get(t);if(n){if(i&&e&&n.rbGroups.length)for(const e of n.rbGroups)for(const i of e)i!==t&&(null==(s=Vd(this,Dn).get(i))||s._setVisible(nm,!1,!0));n._setVisible(nm,!!e,!0),qd(this,Pn,null)}else Hu(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let i;for(const s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}const t=Vd(this,Dn).get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}qd(this,Pn,null)}get hasInitialVisibility(){return null===Vd(this,Rn)||this.getHash()===Vd(this,Rn)}getOrder(){return Vd(this,Dn).size?Vd(this,In)?Vd(this,In).slice():[...Vd(this,Dn).keys()]:null}getGroup(t){return Vd(this,Dn).get(t)||null}getHash(){if(null!==Vd(this,Pn))return Vd(this,Pn);const t=new mg;for(const[e,i]of Vd(this,Dn))t.update(`${e}:${i.visible}`);return qd(this,Pn,t.hexdigest())}[Symbol.iterator](){return Vd(this,Dn).entries()}}Pn=new WeakMap,Dn=new WeakMap,Rn=new WeakMap,In=new WeakMap,Ln=new WeakSet,Fn=function(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let s=1;s<e;s++){const e=t[s];let n;if(Array.isArray(e))n=Xd(this,Ln,Fn).call(this,e);else{if(!Vd(this,Dn).has(e))return Hu(`Optional content group not found: ${e}`),!0;n=Vd(this,Dn).get(e).visible}switch(i){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return"And"===i};class om{constructor(t,{disableRange:e=!1,disableStream:i=!1}){ju(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:n,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,(null==n?void 0:n.length)>0){const t=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((t,e)=>{this._onReceiveData({begin:t,chunk:e})}),t.addProgressListener((t,e)=>{this._onProgress({loaded:t,total:e})}),t.addProgressiveReadListener(t=>{this._onReceiveData({chunk:t})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(void 0===t)this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i);else{ju(this._rangeReaders.some(function(e){return e._begin===t&&(e._enqueue(i),!0)}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t;return(null==(t=this._fullRequestReader)?void 0:t._loaded)??0}_onProgress(t){var e,i,s,n;void 0===t.total?null==(i=null==(e=this._rangeReaders[0])?void 0:e.onProgress)||i.call(e,{loaded:t.loaded}):null==(n=null==(s=this._fullRequestReader)?void 0:s.onProgress)||n.call(s,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;null==(t=this._fullRequestReader)||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){ju(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new lm(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new hm(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const i of this._rangeReaders.slice(0))i.cancel(t);this._pdfDataRangeTransport.abort()}}class lm{constructor(t,e,i=!1,s=null){this._stream=t,this._done=i||!1,this._filename=Ap(s)?s: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){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._queuedChunks.push(t);this._loaded+=t.byteLength}}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0){return{value:this._queuedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class hm{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function cm(t,e){const i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(const s in e){const t=e[s];void 0!==t&&i.append(s,t)}return i}function dm(t){var e;return(null==(e=URL.parse(t))?void 0:e.origin)??null}function um({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){const n={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(r))return n;if(n.suggestedLength=r,r<=2*i)return n;if(s||!e)return n;if("bytes"!==t.get("Accept-Ranges"))return n;return"identity"!==(t.get("Content-Encoding")||"identity")||(n.allowRangeRequests=!0),n}function pm(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){i=i[1];let t=a(i);return t=unescape(t),t=o(t),t=l(t),r(t)}if(i=function(t){const e=[];let i;const n=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=n.exec(t));){let[,t,s,n]=i;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[s,n]}const r=[];for(let s=0;s<e.length&&s in e;++s){let[t,i]=e[s];i=a(i),t&&(i=unescape(i),0===s&&(i=o(i))),r.push(i)}return r.join("")}(t),i)return r(l(i));if(i=s("filename","i").exec(t),i){i=i[1];let t=a(i);return t=l(t),r(t)}function s(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function n(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const s=new TextDecoder(t,{fatal:!0}),n=ep(i);i=s.decode(n),e=!1}catch{}}return i}function r(t){return e&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),e&&(t=n("iso-8859-1",t))),t}function a(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){const e=t.indexOf("'");return-1===e?t:n(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(t,e,i,s){if("q"===i||"Q"===i)return n(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(t,e){return String.fromCharCode(parseInt(e,16))}));try{s=atob(s)}catch{}return n(e,s)})}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(Ap(t))return t}return null}function gm(t,e){return new Qu(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,404===t||0===t&&e.startsWith("file:"))}function fm(t){return 200===t||206===t}function mm(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function vm(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(Hu(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class wm{constructor(t){jd(this,"_responseOrigin",null),this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=cm(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return(null==(t=this._fullRequestReader)?void 0:t._loaded)??0}getFullReader(){return ju(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new bm(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new ym(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const i of this._rangeRequestReaders.slice(0))i.cancel(t)}}class bm{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const i=new Headers(t.headers),s=e.url;fetch(s,mm(i,this._withCredentials,this._abortController)).then(e=>{if(t._responseOrigin=dm(e.url),!fm(e.status))throw gm(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();const i=e.headers,{allowRangeRequests:n,suggestedLength:r}=um({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=r||this._contentLength,this._filename=pm(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Zu("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(){var t;await this._headersCapability.promise;const{value:e,done:i}=await this._reader.read();return i?{value:e,done:i}:(this._loaded+=e.byteLength,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded,total:this._contentLength}),{value:vm(e),done:!1})}cancel(t){var e;null==(e=this._reader)||e.cancel(t),this._abortController.abort()}}class ym{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;const n=new Headers(t.headers);n.append("Range",`bytes=${e}-${i-1}`);const r=s.url;fetch(r,mm(n,this._withCredentials,this._abortController)).then(e=>{const i=dm(e.url);if(i!==t._responseOrigin)throw new Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!fm(e.status))throw gm(e.status,r);this._readCapability.resolve(),this._reader=e.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var t;await this._readCapability.promise;const{value:e,done:i}=await this._reader.read();return i?{value:e,done:i}:(this._loaded+=e.byteLength,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded}),{value:vm(e),done:!1})}cancel(t){var e;null==(e=this._reader)||e.cancel(t),this._abortController.abort()}}class Am{constructor({url:t,httpHeaders:e,withCredentials:i}){jd(this,"_responseOrigin",null),this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=cm(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,i=this.currXhrId++,s=this.pendingRequests[i]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[n,r]of this.headers)e.setRequestHeader(n,r);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.expectedStatus=206):s.expectedStatus=200,e.responseType="arraybuffer",ju(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){var i;const s=this.pendingRequests[t];s&&(null==(i=s.onProgress)||i.call(s,e))}onStateChange(t,e){const i=this.pendingRequests[t];if(!i)return;const s=i.xhr;if(s.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==s.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===s.status&&this.isHttp)return void i.onError(s.status);const n=s.status||200;if(!(200===n&&206===i.expectedStatus)&&n!==i.expectedStatus)return void i.onError(s.status);const r=function(t){const e=t.response;return"string"!=typeof e?e:ep(e).buffer}(s);if(206===n){const t=s.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?i.onDone({begin:parseInt(e[1],10),chunk:r}):(Hu('Missing or invalid "Content-Range" header.'),i.onError(0))}else r?i.onDone({begin:0,chunk:r}):i.onError(s.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class _m{constructor(t){this._source=t,this._manager=new Am(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return ju(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new xm(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new km(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const i of this._rangeRequestReaders.slice(0))i.cancel(t)}}class xm{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=dm(e.responseURL);const i=e.getAllResponseHeaders(),s=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(t=>{const[e,...i]=t.split(": ");return[e,i.join(": ")]}):[]),{allowRangeRequests:n,suggestedLength:r}=um({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=pm(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t)if(this._requests.length>0){this._requests.shift().resolve({value:t.chunk,done:!1})}else this._cachedChunks.push(t.chunk);if(this._done=!0,!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=gm(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var e;null==(e=this.onProgress)||e.call(this,{loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0){return{value:this._cachedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const 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 km{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){var t;const e=dm(null==(t=this._manager.getRequestXhr(this._requestId))?void 0:t.responseURL);e!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${e}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var t;null==(t=this.onClosed)||t.call(this,this)}_onDone(t){const e=t.chunk;if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunk=e;this._done=!0;for(const i of this._requests)i.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??(this._storedError=gm(t,this._url));for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var e;this.isStreamingSupported||null==(e=this.onProgress)||e.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const 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 Sm=/^[a-z][a-z0-9\-+.]+:/i;class Mm{constructor(t){this.source=t,this.url=function(t){if(Sm.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),ju("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return(null==(t=this._fullRequestReader)?void 0:t._loaded)??0}getFullReader(){return ju(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Em(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Cm(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const i of this._rangeRequestReaders.slice(0))i.cancel(t)}}class Em{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=process.getBuiltinModule("fs");i.promises.lstat(this._url).then(t=>{this._contentLength=t.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()},t=>{"ENOENT"===t.code&&(t=gm(0,this._url.href)),this._storedError=t,this._headersCapability.reject(t)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var t;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();if(null===e)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=e.length,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded,total:this._contentLength});return{value:new Uint8Array(e).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Zu("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Cm{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const s=t.source;this._isStreamingSupported=!s.disableStream;const n=process.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:e,end:i-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){var t;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();if(null===e)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=e.length,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded});return{value:new Uint8Array(e).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const Tm=Symbol("INITIAL_DATA");class Pm{constructor(){Gd(this,Wn),Gd(this,Nn,Object.create(null))}get(t,e=null){if(e){const i=Xd(this,Wn,Bn).call(this,t);return i.promise.then(()=>e(i.data)),null}const i=Vd(this,Nn)[t];if(!i||i.data===Tm)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=Vd(this,Nn)[t];return!!e&&e.data!==Tm}delete(t){const e=Vd(this,Nn)[t];return!(!e||e.data===Tm)&&(delete Vd(this,Nn)[t],!0)}resolve(t,e=null){const i=Xd(this,Wn,Bn).call(this,t);i.data=e,i.resolve()}clear(){var t;for(const e in Vd(this,Nn)){const{data:i}=Vd(this,Nn)[e];null==(t=null==i?void 0:i.bitmap)||t.close()}qd(this,Nn,Object.create(null))}*[Symbol.iterator](){for(const t in Vd(this,Nn)){const{data:e}=Vd(this,Nn)[t];e!==Tm&&(yield[t,e])}}}Nn=new WeakMap,Wn=new WeakSet,Bn=function(t){var e;return(e=Vd(this,Nn))[t]||(e[t]={...Promise.withResolvers(),data:Tm})};let Dm=(nr=class{constructor({textContentSource:t,container:e,viewport:i}){var s;if(Gd(this,cr),Gd(this,Un,Promise.withResolvers()),Gd(this,Hn,null),Gd(this,$n,!1),Gd(this,jn,!!(null==(On=globalThis.FontInspector)?void 0:On.enabled)),Gd(this,zn,null),Gd(this,Vn,null),Gd(this,Gn,0),Gd(this,qn,0),Gd(this,Xn,null),Gd(this,Yn,null),Gd(this,Kn,0),Gd(this,Qn,0),Gd(this,Jn,Object.create(null)),Gd(this,Zn,[]),Gd(this,tr,null),Gd(this,er,[]),Gd(this,ir,new WeakMap),Gd(this,sr,null),t instanceof ReadableStream)qd(this,tr,t);else{if("object"!=typeof t)throw new Error('No "textContentSource" parameter specified.');qd(this,tr,new ReadableStream({start(e){e.enqueue(t),e.close()}}))}qd(this,Hn,qd(this,Yn,e)),qd(this,Qn,i.scale*Lp.pixelRatio),qd(this,Kn,i.rotation),qd(this,Vn,{div:null,properties:null,ctx:null});const{pageWidth:n,pageHeight:r,pageX:a,pageY:o}=i.rawDims;qd(this,sr,[1,0,0,-1,-a,o+r]),qd(this,qn,n),qd(this,Gn,r),Xd(s=nr,gr,vr).call(s),Ip(e,i),Vd(this,Un).promise.finally(()=>{Vd(nr,hr).delete(this),qd(this,Vn,null),qd(this,Jn,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=ip.platform;return Gu(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const t=()=>{Vd(this,Xn).read().then(({value:e,done:i})=>{i?Vd(this,Un).resolve():(Vd(this,zn)??qd(this,zn,e.lang),Object.assign(Vd(this,Jn),e.styles),Xd(this,cr,dr).call(this,e.items),t())},Vd(this,Un).reject)};return qd(this,Xn,Vd(this,tr).getReader()),Vd(nr,hr).add(this),t(),Vd(this,Un).promise}update({viewport:t,onBefore:e=null}){var i;const s=t.scale*Lp.pixelRatio,n=t.rotation;if(n!==Vd(this,Kn)&&(null==e||e(),qd(this,Kn,n),Ip(Vd(this,Yn),{rotation:n})),s!==Vd(this,Qn)){null==e||e(),qd(this,Qn,s);const t={div:null,properties:null,ctx:Xd(i=nr,gr,fr).call(i,Vd(this,zn))};for(const e of Vd(this,er))t.properties=Vd(this,ir).get(e),t.div=e,Xd(this,cr,pr).call(this,t)}}cancel(){var t;const e=new Zu("TextLayer task cancelled.");null==(t=Vd(this,Xn))||t.cancel(e).catch(()=>{}),qd(this,Xn,null),Vd(this,Un).reject(e)}get textDivs(){return Vd(this,er)}get textContentItemsStr(){return Vd(this,Zn)}static cleanup(){if(!(Vd(this,hr).size>0)){Vd(this,rr).clear();for(const{canvas:t}of Vd(this,ar).values())t.remove();Vd(this,ar).clear()}}},Un=new WeakMap,Hn=new WeakMap,$n=new WeakMap,jn=new WeakMap,zn=new WeakMap,Vn=new WeakMap,Gn=new WeakMap,qn=new WeakMap,Xn=new WeakMap,Yn=new WeakMap,Kn=new WeakMap,Qn=new WeakMap,Jn=new WeakMap,Zn=new WeakMap,tr=new WeakMap,er=new WeakMap,ir=new WeakMap,sr=new WeakMap,rr=new WeakMap,ar=new WeakMap,or=new WeakMap,lr=new WeakMap,hr=new WeakMap,cr=new WeakSet,dr=function(t){var e,i;if(Vd(this,$n))return;(i=Vd(this,Vn)).ctx??(i.ctx=Xd(e=nr,gr,fr).call(e,Vd(this,zn)));const s=Vd(this,er),n=Vd(this,Zn);for(const r of t){if(s.length>1e5)return Hu("Ignoring additional textDivs for performance reasons."),void qd(this,$n,!0);if(void 0!==r.str)n.push(r.str),Xd(this,cr,ur).call(this,r);else if("beginMarkedContentProps"===r.type||"beginMarkedContent"===r.type){const t=Vd(this,Hn);qd(this,Hn,document.createElement("span")),Vd(this,Hn).classList.add("markedContent"),r.id&&Vd(this,Hn).setAttribute("id",`${r.id}`),t.append(Vd(this,Hn))}else"endMarkedContent"===r.type&&qd(this,Hn,Vd(this,Hn).parentNode)}},ur=function(t){var e;const i=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};Vd(this,er).push(i);const n=np.transform(Vd(this,sr),t.transform);let r=Math.atan2(n[1],n[0]);const a=Vd(this,Jn)[t.fontName];a.vertical&&(r+=Math.PI/2);let o=Vd(this,jn)&&a.fontSubstitution||a.fontFamily;o=nr.fontFamilyMap.get(o)||o;const l=Math.hypot(n[2],n[3]),h=l*Xd(e=nr,gr,wr).call(e,o,a,Vd(this,zn));let c,d;0===r?(c=n[4],d=n[5]-h):(c=n[4]+h*Math.sin(r),d=n[5]-h*Math.cos(r));const u="calc(var(--total-scale-factor) *",p=i.style;Vd(this,Hn)===Vd(this,Yn)?(p.left=`${(100*c/Vd(this,qn)).toFixed(2)}%`,p.top=`${(100*d/Vd(this,Gn)).toFixed(2)}%`):(p.left=`${u}${c.toFixed(2)}px)`,p.top=`${u}${d.toFixed(2)}px)`),p.fontSize=`${u}${(Vd(nr,lr)*l).toFixed(2)}px)`,p.fontFamily=o,s.fontSize=l,i.setAttribute("role","presentation"),i.textContent=t.str,i.dir=t.dir,Vd(this,jn)&&(i.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),0!==r&&(s.angle=r*(180/Math.PI));let g=!1;if(t.str.length>1)g=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(g=!0)}if(g&&(s.canvasWidth=a.vertical?t.height:t.width),Vd(this,ir).set(i,s),Vd(this,Vn).div=i,Vd(this,Vn).properties=s,Xd(this,cr,pr).call(this,Vd(this,Vn)),s.hasText&&Vd(this,Hn).append(i),s.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),Vd(this,Hn).append(t)}},pr=function(t){var e;const{div:i,properties:s,ctx:n}=t,{style:r}=i;let a="";if(Vd(nr,lr)>1&&(a=`scale(${1/Vd(nr,lr)})`),0!==s.canvasWidth&&s.hasText){const{fontFamily:t}=r,{canvasWidth:o,fontSize:l}=s;Xd(e=nr,gr,mr).call(e,n,l*Vd(this,Qn),t);const{width:h}=n.measureText(i.textContent);h>0&&(a=`scaleX(${o*Vd(this,Qn)/h}) ${a}`)}0!==s.angle&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(r.transform=a)},gr=new WeakSet,fr=function(t=null){let e=Vd(this,ar).get(t||(t=""));if(!e){const i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),Vd(this,ar).set(t,e),Vd(this,or).set(e,{size:0,family:""})}return e},mr=function(t,e,i){const s=Vd(this,or).get(t);e===s.size&&i===s.family||(t.font=`${e}px ${i}`,s.size=e,s.family=i)},vr=function(){if(null!==Vd(this,lr))return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),qd(this,lr,t.getBoundingClientRect().height),t.remove()},wr=function(t,e,i){const s=Vd(this,rr).get(t);if(s)return s;const n=Xd(this,gr,fr).call(this,i);n.canvas.width=n.canvas.height=30,Xd(this,gr,mr).call(this,n,30,t);const r=n.measureText(""),a=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);n.canvas.width=n.canvas.height=0;let l=.8;return a?l=a/(a+o):(ip.platform.isFirefox&&Hu("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?l=e.ascent:e.descent&&(l=1+e.descent)),Vd(this,rr).set(t,l),l},Gd(nr,gr),Gd(nr,rr,new Map),Gd(nr,ar,new Map),Gd(nr,or,new WeakMap),Gd(nr,lr,null),Gd(nr,hr,new Set),nr);function Rm(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new Lm,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;if("string"==typeof t){if(iu)return t;const e=URL.parse(t,window.location);if(e)return e.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(iu&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return ep(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(null==t?void 0:t.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,r=t.httpHeaders||null,a=!0===t.withCredentials,o=t.password??null,l=t.range instanceof Fm?t.range:null,h=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536;let c=t.worker instanceof Om?t.worker:null;const d=t.verbosity,u="string"!=typeof t.docBaseUrl||yp(t.docBaseUrl)?null:t.docBaseUrl,p=_g(t.cMapUrl),g=!1!==t.cMapPacked,f=t.CMapReaderFactory||(iu?Jg:$g),m=_g(t.iccUrl),v=_g(t.standardFontDataUrl),w=t.StandardFontDataFactory||(iu?Zg:Gg),b=_g(t.wasmUrl),y=t.WasmFactory||(iu?tf:Xg),A=!0!==t.stopAtErrors,_=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,x=!1!==t.isEvalSupported,k="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!iu,S="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!iu&&(ip.platform.isFirefox||!globalThis.chrome),M=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,E="boolean"==typeof t.disableFontFace?t.disableFontFace:iu,C=!0===t.fontExtraProperties,T=!0===t.enableXfa,P=t.ownerDocument||globalThis.document,D=!0===t.disableRange,R=!0===t.disableStream,I=!0===t.disableAutoFetch,L=!0===t.pdfBug,F=t.CanvasFactory||(iu?Qg:Ug),N=t.FilterFactory||(iu?Kg:zg),W=!0===t.enableHWA,B=!1!==t.useWasm,O=l?l.length:t.length??NaN,U="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!iu&&!E,H="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(f===$g&&w===Gg&&y===Xg&&p&&v&&b&&Sp(p,document.baseURI)&&Sp(v,document.baseURI)&&Sp(b,document.baseURI));var $;$=d,Number.isInteger($)&&(Bu=$);const j={canvasFactory:new F({ownerDocument:P,enableHWA:W}),filterFactory:new N({docId:i,ownerDocument:P}),cMapReaderFactory:H?null:new f({baseUrl:p,isCompressed:g}),standardFontDataFactory:H?null:new w({baseUrl:v}),wasmFactory:H?null:new y({baseUrl:b})};c||(c=Om.create({verbosity:d,port:im.workerPort}),e._worker=c);const z={docId:i,apiVersion:"5.4.296",data:n,password:o,disableAutoFetch:I,rangeChunkSize:h,length:O,docBaseUrl:u,enableXfa:T,evaluatorOptions:{maxImageSize:_,disableFontFace:E,ignoreErrors:A,isEvalSupported:x,isOffscreenCanvasSupported:k,isImageDecoderSupported:S,canvasMaxAreaInBytes:M,fontExtraProperties:C,useSystemFonts:U,useWasm:B,useWorkerFetch:H,cMapUrl:p,iccUrl:m,standardFontDataUrl:v,wasmUrl:b}},V={ownerDocument:P,pdfBug:L,styleElement:null,loadingParams:{disableAutoFetch:I,enableXfa:T}};return c.promise.then(function(){if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const t=c.messageHandler.sendWithPromise("GetDocRequest",z,n?[n.buffer]:null);let o;if(l)o=new om(l,{disableRange:D,disableStream:R});else if(!n){if(!s)throw new Error("getDocument - no `url` parameter provided.");const t=Sp(s)?wm:iu?Mm:_m;o=new t({url:s,length:O,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:D,disableStream:R})}return t.then(t=>{if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const s=new Bg(i,t,c.port),n=new Um(s,e,o,V,j,W);e._transport=n,s.send("Ready",null)})}).catch(e._capability.reject),e}const Im=class t{constructor(){jd(this,"_capability",Promise.withResolvers()),jd(this,"_transport",null),jd(this,"_worker",null),jd(this,"docId","d"+Yd(t,br)._++),jd(this,"destroyed",!1),jd(this,"onPassword",null),jd(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var t,e,i,s;this.destroyed=!0;try{(null==(t=this._worker)?void 0:t.port)&&(this._worker._pendingDestroy=!0),await(null==(e=this._transport)?void 0:e.destroy())}catch(n){throw(null==(i=this._worker)?void 0:i.port)&&delete this._worker._pendingDestroy,n}this._transport=null,null==(s=this._worker)||s.destroy(),this._worker=null}async getData(){return this._transport.getData()}};br=new WeakMap,Gd(Im,br,0);let Lm=Im,Fm=(Sr=class{constructor(t,e,i=!1,s=null){Gd(this,yr,Promise.withResolvers()),Gd(this,Ar,[]),Gd(this,_r,[]),Gd(this,xr,[]),Gd(this,kr,[]),this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s}addRangeListener(t){Vd(this,kr).push(t)}addProgressListener(t){Vd(this,xr).push(t)}addProgressiveReadListener(t){Vd(this,_r).push(t)}addProgressiveDoneListener(t){Vd(this,Ar).push(t)}onDataRange(t,e){for(const i of Vd(this,kr))i(t,e)}onDataProgress(t,e){Vd(this,yr).promise.then(()=>{for(const i of Vd(this,xr))i(t,e)})}onDataProgressiveRead(t){Vd(this,yr).promise.then(()=>{for(const e of Vd(this,_r))e(t)})}onDataProgressiveDone(){Vd(this,yr).promise.then(()=>{for(const t of Vd(this,Ar))t()})}transportReady(){Vd(this,yr).resolve()}requestDataRange(t,e){$u("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}},yr=new WeakMap,Ar=new WeakMap,_r=new WeakMap,xr=new WeakMap,kr=new WeakMap,Sr);class Nm{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Gu(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}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 Wm{constructor(t,e,i,s=!1){Gd(this,Er),Gd(this,Mr,!1),this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new kp:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new Pm,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new wp({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Gu(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return(null==(t=this._transport._htmlForXfa)?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,canvas:e=t.canvas,viewport:i,intent:s="display",annotationMode:n=pu.ENABLE,transform:r=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:h=null,printAnnotationStorage:c=null,isEditing:d=!1,recordOperations:u=!1,operationsFilter:p=null}){var g,f,m;null==(g=this._stats)||g.time("Overall");const v=this._transport.getRenderingIntent(s,n,c,d),{renderingIntent:w,cacheKey:b}=v;qd(this,Mr,!1),o||(o=this._transport.getOptionalContentConfig(w));let y=this._intentStates.get(b);y||(y=Object.create(null),this._intentStates.set(b,y)),y.streamReaderCancelTimeout&&(clearTimeout(y.streamReaderCancelTimeout),y.streamReaderCancelTimeout=null);const A=!!(w&ou);y.displayReadyCapability||(y.displayReadyCapability=Promise.withResolvers(),y.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(f=this._stats)||f.time("Page Request"),this._pumpOperatorList(v));const _=Boolean(this._pdfBug&&(null==(m=globalThis.StepperManager)?void 0:m.enabled)),x=!this.recordedBBoxes&&(u||_),k=t=>{var e,i;if(y.renderTasks.delete(S),x){const t=null==(e=S.gfx)?void 0:e.dependencyTracker.take();t&&(S.stepper&&S.stepper.setOperatorBBoxes(t,S.gfx.dependencyTracker.takeDebugMetadata()),u&&(this.recordedBBoxes=t))}A&&qd(this,Mr,!0),Xd(this,Er,Cr).call(this),t?(S.capability.reject(t),this._abortOperatorList({intentState:y,reason:t instanceof Error?t:new Error(t)})):S.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(null==(i=globalThis.Stats)?void 0:i.enabled)&&globalThis.Stats.add(this.pageNumber,this._stats))},S=new jm({callback:k,params:{canvas:e,canvasContext:t,dependencyTracker:x?new hf(e,y.operatorList.length,_):null,viewport:i,transform:r,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:y.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!A,pdfBug:this._pdfBug,pageColors:h,enableHWA:this._transport.enableHWA,operationsFilter:p});(y.renderTasks||(y.renderTasks=new Set)).add(S);const M=S.task;return Promise.all([y.displayReadyCapability.promise,o]).then(([t,e])=>{var i;if(this.destroyed)k();else{if(null==(i=this._stats)||i.time("Rendering"),!(e.renderingIntent&w))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");S.initializeGraphics({transparency:t,optionalContentConfig:e}),S.operatorListChanged()}}).catch(k),M}getOperatorList({intent:t="display",annotationMode:e=pu.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){var n;const r=this._transport.getRenderingIntent(t,e,i,s,!0);let a,o=this._intentStates.get(r.cacheKey);return o||(o=Object.create(null),this._intentStates.set(r.cacheKey,o)),o.opListReadCapability||(a=Object.create(null),a.operatorListChanged=function(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(a))},o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(a),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(n=this._stats)||n.time("Page Request"),this._pumpOperatorList(r)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(t=>up.textContent(t));const e=this.streamTextContent(t);return new Promise(function(t,i){const s=e.getReader(),n={items:[],styles:Object.create(null),lang:null};!function e(){s.read().then(function({value:i,done:s}){s?t(n):(n.lang??(n.lang=i.lang),Object.assign(n.styles,i.styles),n.items.push(...i.items),e())},i)}()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),qd(this,Mr,!1),Promise.all(t)}cleanup(t=!1){qd(this,Mr,!0);const e=Xd(this,Er,Cr).call(this);return t&&e&&this._stats&&(this._stats=new kp),e}_startRenderPage(t,e){var i,s;const n=this._intentStates.get(e);n&&(null==(i=this._stats)||i.timeEnd("Page Request"),null==(s=n.displayReadyCapability)||s.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const i of e.renderTasks)i.operatorListChanged();t.lastChunk&&Xd(this,Er,Cr).call(this)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){const{map:n,transfer:r}=i,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:s},r).getReader(),o=this._intentStates.get(e);o.streamReader=a;const l=()=>{a.read().then(({value:t,done:e})=>{e?o.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,o),l())},t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const t of o.renderTasks)t.operatorListChanged();Xd(this,Er,Cr).call(this)}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else{if(!o.opListReadCapability)throw t;o.opListReadCapability.reject(t)}}})};l()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof bp){let i=100;return e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i))}}if(t.streamReader.cancel(new Zu(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}Mr=new WeakMap,Er=new WeakSet,Cr=function(){if(!Vd(this,Mr)||this.destroyed)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),qd(this,Mr,!1),!0};const Bm=class t{constructor({name:e=null,port:i=null,verbosity:s=Ou()}={}){if(Gd(this,Nr),Gd(this,Tr,Promise.withResolvers()),Gd(this,Pr,null),Gd(this,Dr,null),Gd(this,Rr,null),this.name=e,this.destroyed=!1,this.verbosity=s,i){if(Vd(t,Fr).has(i))throw new Error("Cannot use more than one PDFWorker per port.");Vd(t,Fr).set(i,this),Xd(this,Nr,Br).call(this,i)}else Xd(this,Nr,Or).call(this)}get promise(){return Vd(this,Tr).promise}get port(){return Vd(this,Dr)}get messageHandler(){return Vd(this,Pr)}destroy(){var e,i;this.destroyed=!0,null==(e=Vd(this,Rr))||e.terminate(),qd(this,Rr,null),Vd(t,Fr).delete(Vd(this,Dr)),qd(this,Dr,null),null==(i=Vd(this,Pr))||i.destroy(),qd(this,Pr,null)}static create(e){const i=Vd(this,Fr).get(null==e?void 0:e.port);if(i){if(i._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return i}return new t(e)}static get workerSrc(){if(im.workerSrc)return im.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return Gu(this,"_setupFakeWorkerGlobal",(async()=>{if(Vd(this,Hr,$r))return Vd(this,Hr,$r);return(await import(this.workerSrc)).WorkerMessageHandler})())}};Tr=new WeakMap,Pr=new WeakMap,Dr=new WeakMap,Rr=new WeakMap,Ir=new WeakMap,Lr=new WeakMap,Fr=new WeakMap,Nr=new WeakSet,Wr=function(){Vd(this,Tr).resolve(),Vd(this,Pr).send("configure",{verbosity:this.verbosity})},Br=function(t){qd(this,Dr,t),qd(this,Pr,new Bg("main","worker",t)),Vd(this,Pr).on("ready",()=>{}),Xd(this,Nr,Wr).call(this)},Or=function(){if(Vd(Bm,Lr)||Vd(Bm,Hr,$r))return void Xd(this,Nr,Ur).call(this);let{workerSrc:t}=Bm;try{Bm._isSameOrigin(window.location,t)||(t=Bm._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),i=new Bg("main","worker",e),s=()=>{n.abort(),i.destroy(),e.terminate(),this.destroyed?Vd(this,Tr).reject(new Error("Worker was destroyed")):Xd(this,Nr,Ur).call(this)},n=new AbortController;e.addEventListener("error",()=>{Vd(this,Rr)||s()},{signal:n.signal}),i.on("test",t=>{n.abort(),!this.destroyed&&t?(qd(this,Pr,i),qd(this,Dr,e),qd(this,Rr,e),Xd(this,Nr,Wr).call(this)):s()}),i.on("ready",t=>{if(n.abort(),this.destroyed)s();else try{r()}catch{Xd(this,Nr,Ur).call(this)}});const r=()=>{const t=new Uint8Array;i.send("test",t,[t.buffer])};return void r()}catch{Uu("The worker has been disabled.")}Xd(this,Nr,Ur).call(this)},Ur=function(){Vd(Bm,Lr)||(Hu("Setting up fake worker."),qd(Bm,Lr,!0)),Bm._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void Vd(this,Tr).reject(new Error("Worker was destroyed"));const e=new Sg;qd(this,Dr,e);const i="fake"+Yd(Bm,Ir)._++,s=new Bg(i+"_worker",i,e);t.setup(s,e),qd(this,Pr,new Bg(i,i+"_worker",e)),Xd(this,Nr,Wr).call(this)}).catch(t=>{Vd(this,Tr).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},Hr=new WeakSet,$r=function(){var t;try{return(null==(t=globalThis.pdfjsWorker)?void 0:t.WorkerMessageHandler)||null}catch{return null}},Gd(Bm,Hr),Gd(Bm,Ir,0),Gd(Bm,Lr,!1),Gd(Bm,Fr,new WeakMap),iu&&(qd(Bm,Lr,!0),im.workerSrc||(im.workerSrc="./pdf.worker.mjs")),Bm._isSameOrigin=(t,e)=>{const i=URL.parse(t);if(!(null==i?void 0:i.origin)||"null"===i.origin)return!1;const s=new URL(e,i);return i.origin===s.origin},Bm._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},Bm.fromPort=t=>{var e;if(e="`PDFWorker.fromPort` - please use `PDFWorker.create` instead.",console.log("Deprecated API usage: "+e),!(null==t?void 0:t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");return Bm.create(t)};let Om=Bm;class Um{constructor(t,e,i,s,n,r){Gd(this,Xr),Gd(this,jr,new Map),Gd(this,zr,new Map),Gd(this,Vr,new Map),Gd(this,Gr,new Map),Gd(this,qr,null),this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Pm,this.fontLoader=new yg({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.wasmFactory=n.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=r,this.setupMessageHandler()}get annotationStorage(){return Gu(this,"annotationStorage",new wg)}getRenderingIntent(t,e=pu.ENABLE,i=null,s=!1,n=!1){let r=au,a=vg;switch(t){case"any":r=ru;break;case"display":break;case"print":r=ou;break;default:Hu(`getRenderingIntent - invalid intent: ${t}`)}const o=r&ou&&i instanceof bg?i:this.annotationStorage;switch(e){case pu.DISABLE:r+=cu;break;case pu.ENABLE:break;case pu.ENABLE_FORMS:r+=lu;break;case pu.ENABLE_STORAGE:r+=hu,a=o.serializable;break;default:Hu(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(r+=du),n&&(r+=uu);const{ids:l,hash:h}=o.modifiedIds;return{renderingIntent:r,cacheKey:[r,a.hash,h].join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){var t;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),null==(t=Vd(this,qr))||t.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const s of Vd(this,zr).values())e.push(s._destroy());Vd(this,zr).clear(),Vd(this,Vr).clear(),Vd(this,Gr).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const i=this.messageHandler.sendWithPromise("Terminate",null);return e.push(i),Promise.all(e).then(()=>{var t,e;this.commonObjs.clear(),this.fontLoader.clear(),Vd(this,jr).clear(),this.filterFactory.destroy(),Dm.cleanup(),null==(t=this._networkStream)||t.cancelAllRequests(new Zu("Worker was terminated.")),null==(e=this.messageHandler)||e.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(t,e)=>{ju(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then(function({value:t,done:i}){i?e.close():(ju(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("ReaderHeadersReady",async t=>{var i;await this._fullReader.headersReady;const{isStreamingSupported:s,isRangeSupported:n,contentLength:r}=this._fullReader;return s&&n||(this._lastProgress&&(null==(i=e.onProgress)||i.call(e,this._lastProgress)),this._fullReader.onProgress=t=>{var i;null==(i=e.onProgress)||i.call(e,{loaded:t.loaded,total:t.total})}),{isStreamingSupported:s,isRangeSupported:n,contentLength:r}}),t.on("GetRangeReader",(t,e)=>{ju(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const i=this._networkStream.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then(function({value:t,done:i}){i?e.close():(ju(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{i.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}):e.close()}),t.on("GetDoc",({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new Nm(t,this))}),t.on("DocException",t=>{e._capability.reject(Wg(t))}),t.on("PasswordRequest",t=>{qd(this,qr,Promise.withResolvers());try{if(!e.onPassword)throw Wg(t);const i=t=>{t instanceof Error?Vd(this,qr).reject(t):Vd(this,qr).resolve({password:t})};e.onPassword(i,t.code)}catch(i){Vd(this,qr).reject(i)}return Vd(this,qr).promise}),t.on("DataLoaded",t=>{var i;null==(i=e.onProgress)||i.call(e,{loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)}),t.on("StartRenderPage",t=>{if(this.destroyed)return;Vd(this,zr).get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}),t.on("commonobj",([e,i,s])=>{var n;if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(i){case"Font":if("error"in s){const t=s.error;Hu(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const r=new em(s),a=this._params.pdfBug&&(null==(n=globalThis.FontInspector)?void 0:n.enabled)?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,o=new Ag(r,a,s.extra,s.charProcOperatorList);this.fontLoader.bind(o).catch(()=>t.sendWithPromise("FontFallback",{id:e})).finally(()=>{!o.fontExtraProperties&&o.data&&o.clearData(),this.commonObjs.resolve(e,o)});break;case"CopyLocalImage":const{imageRef:l}=s;ju(l,"The imageRef must be defined.");for(const t of Vd(this,zr).values())for(const[,i]of t.objs)if((null==i?void 0:i.ref)===l)return i.dataLen?(this.commonObjs.resolve(e,structuredClone(i)),i.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,s);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([t,e,i,s])=>{var n;if(this.destroyed)return;const r=Vd(this,zr).get(e);if(!r.objs.has(t))if(0!==r._intentStates.size)switch(i){case"Image":case"Pattern":r.objs.resolve(t,s);break;default:throw new Error(`Got unknown object type ${i}`)}else null==(n=null==s?void 0:s.bitmap)||n.close()}),t.on("DocProgress",t=>{var i;this.destroyed||null==(i=e.onProgress)||i.call(e,{loaded:t.loaded,total:t.total})}),t.on("FetchBinaryData",async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");const e=this[t.type];if(!e)throw new Error(`${t.type} not initialized, see the \`useWorkerFetch\` parameter.`);return e.fetch(t)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var t;this.annotationStorage.size<=0&&Hu("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfer:i}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:(null==(t=this._fullReader)?void 0:t.filename)??null},i).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,i=Vd(this,Vr).get(e);if(i)return i;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(i=>{if(this.destroyed)throw new Error("Transport destroyed");i.refStr&&Vd(this,Gr).set(i.refStr,t);const s=new Wm(e,i,this,this._params.pdfBug);return Vd(this,zr).set(e,s),s});return Vd(this,Vr).set(e,s),s}getPageIndex(t){return xg(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 Xd(this,Xr,Yr).call(this,"GetFieldObjects")}hasJSActions(){return Xd(this,Xr,Yr).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return Xd(this,Xr,Yr).call(this,"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 Xd(this,Xr,Yr).call(this,"GetOptionalContentConfig").then(e=>new am(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=Vd(this,jr).get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then(t=>{var e,i;return{info:t[0],metadata:t[1]?new sm(t[1]):null,contentDispositionFilename:(null==(e=this._fullReader)?void 0:e.filename)??null,contentLength:(null==(i=this._fullReader)?void 0:i.contentLength)??null}});return Vd(this,jr).set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of Vd(this,zr).values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),Vd(this,jr).clear(),this.filterFactory.destroy(!0),Dm.cleanup()}}cachedPageNumber(t){if(!xg(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return Vd(this,Gr).get(e)??null}}jr=new WeakMap,zr=new WeakMap,Vr=new WeakMap,Gr=new WeakMap,qr=new WeakMap,Xr=new WeakSet,Yr=function(t,e=null){const i=Vd(this,jr).get(t);if(i)return i;const s=this.messageHandler.sendWithPromise(t,e);return Vd(this,jr).set(t,s),s};class Hm{constructor(t){Gd(this,Kr,null),jd(this,"onContinue",null),jd(this,"onError",null),qd(this,Kr,t)}get promise(){return Vd(this,Kr).capability.promise}cancel(t=0){Vd(this,Kr).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=Vd(this,Kr).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=Vd(this,Kr);return t.form||t.canvas&&(null==e?void 0:e.size)>0}}Kr=new WeakMap;const $m=class t{constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:c=!1,pageColors:d=null,enableHWA:u=!1,operationsFilter:p=null}){Gd(this,Qr,null),this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=c,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Hm(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=u,this._dependencyTracker=e.dependencyTracker,this._operationsFilter=p}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:i}){var s,n;if(this.cancelled)return;if(this._canvas){if(Vd(t,Jr).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.");Vd(t,Jr).add(this._canvas)}this._pdfBug&&(null==(s=globalThis.StepperManager)?void 0:s.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:r,transform:a,background:o,dependencyTracker:l}=this.params,h=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Yf(h,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:i},this.annotationCanvasMap,this.pageColors,l),this.gfx.beginDrawing({transform:a,viewport:r,transparency:e,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,null==(n=this.graphicsReadyCallback)||n.call(this)}cancel(e=null,i=0){var s,n,r;this.running=!1,this.cancelled=!0,null==(s=this.gfx)||s.endDrawing(),Vd(this,Qr)&&(window.cancelAnimationFrame(Vd(this,Qr)),qd(this,Qr,null)),Vd(t,Jr).delete(this._canvas),e||(e=new bp(`Rendering cancelled, page ${this._pageIndex+1}`,i)),this.callback(e),null==(r=(n=this.task).onError)||r.call(n,e)}operatorListChanged(){var t,e;this.graphicsReady?(null==(t=this.gfx.dependencyTracker)||t.growOperationsCount(this.operatorList.fnArray.length),null==(e=this.stepper)||e.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound)}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?qd(this,Qr,window.requestAnimationFrame(()=>{qd(this,Qr,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),Vd(t,Jr).delete(this._canvas),this.callback())))}};Qr=new WeakMap,Jr=new WeakMap,Gd($m,Jr,new WeakSet);let jm=$m;const zm="5.4.296",Vm="f56dc8601",Gm=class t{constructor({editor:e=null,uiManager:i=null}){var s,n;Gd(this,ca),Gd(this,Zr,null),Gd(this,ta,null),Gd(this,ea),Gd(this,ia,null),Gd(this,sa,!1),Gd(this,na,!1),Gd(this,ra,null),Gd(this,aa),Gd(this,oa,null),Gd(this,la,null),e?(qd(this,na,!1),qd(this,ra,e)):qd(this,na,!0),qd(this,la,(null==e?void 0:e._uiManager)||i),qd(this,aa,Vd(this,la)._eventBus),qd(this,ea,(null==(s=null==e?void 0:e.color)?void 0:s.toUpperCase())||(null==(n=Vd(this,la))?void 0:n.highlightColors.values().next().value)||"#FFFF98"),Vd(t,ha)||qd(t,ha,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return Gu(this,"_keyboardManager",new tg([[["Escape","mac+Escape"],t.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],t.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],t.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],t.prototype._moveToPrevious],[["Home","mac+Home"],t.prototype._moveToBeginning],[["End","mac+End"],t.prototype._moveToEnd]]))}renderButton(){const t=qd(this,Zr,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",Vd(this,ra)&&(t.ariaControls=`${Vd(this,ra).id}_colorpicker_dropdown`);const e=Vd(this,la)._signal;t.addEventListener("click",Xd(this,ca,ga).bind(this),{signal:e}),t.addEventListener("keydown",Xd(this,ca,pa).bind(this),{signal:e});const i=qd(this,ta,document.createElement("span"));return i.className="swatch",i.ariaHidden="true",i.style.backgroundColor=Vd(this,ea),t.append(i),t}renderMainDropdown(){const t=qd(this,ia,Xd(this,ca,da).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===Vd(this,Zr))return void Xd(this,ca,ga).call(this,t);const e=t.target.getAttribute("data-color");e&&Xd(this,ca,ua).call(this,e,t)}_moveToNext(t){var e,i;Vd(this,ca,ma)?t.target!==Vd(this,Zr)?null==(i=t.target.nextSibling)||i.focus():null==(e=Vd(this,ia).firstChild)||e.focus():Xd(this,ca,ga).call(this,t)}_moveToPrevious(t){var e,i;t.target!==(null==(e=Vd(this,ia))?void 0:e.firstChild)&&t.target!==Vd(this,Zr)?(Vd(this,ca,ma)||Xd(this,ca,ga).call(this,t),null==(i=t.target.previousSibling)||i.focus()):Vd(this,ca,ma)&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){var e;Vd(this,ca,ma)?null==(e=Vd(this,ia).firstChild)||e.focus():Xd(this,ca,ga).call(this,t)}_moveToEnd(t){var e;Vd(this,ca,ma)?null==(e=Vd(this,ia).lastChild)||e.focus():Xd(this,ca,ga).call(this,t)}hideDropdown(){var t,e;null==(t=Vd(this,ia))||t.classList.add("hidden"),Vd(this,Zr).ariaExpanded="false",null==(e=Vd(this,oa))||e.abort(),qd(this,oa,null)}_hideDropdownFromKeyboard(){var t;Vd(this,na)||(Vd(this,ca,ma)?(this.hideDropdown(),Vd(this,Zr).focus({preventScroll:!0,focusVisible:Vd(this,sa)})):null==(t=Vd(this,ra))||t.unselect())}updateColor(t){if(Vd(this,ta)&&(Vd(this,ta).style.backgroundColor=t),!Vd(this,ia))return;const e=Vd(this,la).highlightColors.values();for(const i of Vd(this,ia).children)i.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;null==(t=Vd(this,Zr))||t.remove(),qd(this,Zr,null),qd(this,ta,null),null==(e=Vd(this,ia))||e.remove(),qd(this,ia,null)}};Zr=new WeakMap,ta=new WeakMap,ea=new WeakMap,ia=new WeakMap,sa=new WeakMap,na=new WeakMap,ra=new WeakMap,aa=new WeakMap,oa=new WeakMap,la=new WeakMap,ha=new WeakMap,ca=new WeakSet,da=function(){const t=document.createElement("div"),e=Vd(this,la)._signal;t.addEventListener("contextmenu",Mp,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),Vd(this,ra)&&(t.id=`${Vd(this,ra).id}_colorpicker_dropdown`);for(const[i,s]of Vd(this,la).highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",s),n.title=i,n.setAttribute("data-l10n-id",Vd(Gm,ha)[i]);const r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=s,n.ariaSelected=s===Vd(this,ea),n.addEventListener("click",Xd(this,ca,ua).bind(this,s),{signal:e}),t.append(n)}return t.addEventListener("keydown",Xd(this,ca,pa).bind(this),{signal:e}),t},ua=function(t,e){e.stopPropagation(),Vd(this,aa).dispatch("switchannotationeditorparams",{source:this,type:mu.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)},pa=function(t){Gm._keyboardManager.exec(this,t)},ga=function(t){if(Vd(this,ca,ma))return void this.hideDropdown();if(qd(this,sa,0===t.detail),Vd(this,oa)||(qd(this,oa,new AbortController),window.addEventListener("pointerdown",Xd(this,ca,fa).bind(this),{signal:Vd(this,la).combinedSignal(Vd(this,oa))})),Vd(this,Zr).ariaExpanded="true",Vd(this,ia))return void Vd(this,ia).classList.remove("hidden");const e=qd(this,ia,Xd(this,ca,da).call(this));Vd(this,Zr).append(e)},fa=function(t){var e;(null==(e=Vd(this,ia))?void 0:e.contains(t.target))||this.hideDropdown()},ma=function(){return Vd(this,ia)&&!Vd(this,ia).classList.contains("hidden")},Gd(Gm,ha,null);let qm=Gm;const Xm=class t{constructor(e){Gd(this,va,null),Gd(this,wa,null),Gd(this,ba,null),qd(this,wa,e),qd(this,ba,e._uiManager),Vd(t,ya)||qd(t,ya,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(Vd(this,va))return Vd(this,va);const{editorType:e,colorType:i,colorValue:s}=Vd(this,wa),n=qd(this,va,document.createElement("input"));return n.type="color",n.value=s||"#000000",n.className="basicColorPicker",n.tabIndex=0,n.setAttribute("data-l10n-id",Vd(t,ya)[e]),n.addEventListener("input",()=>{Vd(this,ba).updateParams(i,n.value)},{signal:Vd(this,ba)._signal}),n}update(t){Vd(this,va)&&(Vd(this,va).value=t)}destroy(){var t;null==(t=Vd(this,va))||t.remove(),qd(this,va,null)}hideDropdown(){}};va=new WeakMap,wa=new WeakMap,ba=new WeakMap,ya=new WeakMap,Gd(Xm,ya,null);let Ym=Xm;function Km(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function Qm(t){return Math.max(0,Math.min(255,255*t))}class Jm{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=Qm(t),t,t]}static G_HTML([t]){const e=Km(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(Qm)}static RGB_HTML(t){return`#${t.map(Km).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[Qm(1-Math.min(1,t+s)),Qm(1-Math.min(1,i+s)),Qm(1-Math.min(1,e+s))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const s=1-t,n=1-e,r=1-i;return["CMYK",s,n,r,Math.min(s,n,r)]}}class Zm{create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){$u("Abstract method `_createSVG` called.")}}class tv extends Zm{_createSVG(t){return document.createElementNS(gp,t)}}const ev=new WeakSet,iv=60*(new Date).getTimezoneOffset()*1e3;class sv{static create(t){switch(t.data.annotationType){case Su.LINK:return new av(t);case Su.TEXT:return new ov(t);case Su.WIDGET:switch(t.data.fieldType){case"Tx":return new hv(t);case"Btn":return t.data.radioButton?new uv(t):t.data.checkBox?new dv(t):new pv(t);case"Ch":return new gv(t);case"Sig":return new cv(t)}return new lv(t);case Su.POPUP:return new fv(t);case Su.FREETEXT:return new vv(t);case Su.LINE:return new wv(t);case Su.SQUARE:return new bv(t);case Su.CIRCLE:return new yv(t);case Su.POLYLINE:return new Av(t);case Su.CARET:return new xv(t);case Su.INK:return new kv(t);case Su.POLYGON:return new _v(t);case Su.HIGHLIGHT:return new Sv(t);case Su.UNDERLINE:return new Mv(t);case Su.SQUIGGLY:return new Ev(t);case Su.STRIKEOUT:return new Cv(t);case Su.STAMP:return new Tv(t);case Su.FILEATTACHMENT:return new Pv(t);default:return new nv(t)}}}Aa=new WeakMap,_a=new WeakMap,xa=new WeakMap,ka=new WeakSet,Sa=function(t){const{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;null==i||i.splice(0,4,...t),e.left=100*(t[0]-a)/n+"%",e.top=100*(r-t[3]+o)/r+"%",0===s?(e.width=100*(t[2]-t[0])/n+"%",e.height=100*(t[3]-t[1])/r+"%"):this.setRotation(s)};let nv=class t{constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}={}){Gd(this,ka),Gd(this,Aa,null),Gd(this,_a,!1),Gd(this,xa,null),this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!(!(null==t?void 0:t.str)&&!(null==e?void 0:e.str))}get _isEditable(){return this.data.isEditable}get hasPopupData(){return t._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){var t;const{data:e}=this,i=null==(t=this.annotationStorage)?void 0:t.getEditor(e.id);return i?i.getData():e}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){var t;const e=null==(t=this.annotationStorage)?void 0:t.getEditor(this.data.id);if(e)return e.commentButtonPositionInPage;const{quadPoints:i,inkLists:s,rect:n}=this.data;let r=-1/0,a=-1/0;if((null==i?void 0:i.length)>=8){for(let t=0;t<i.length;t+=8)i[t+1]>a?(a=i[t+1],r=i[t+2]):i[t+1]===a&&(r=Math.max(r,i[t+2]));return[r,a]}if((null==s?void 0:s.length)>=1){for(const t of s)for(let e=0,i=t.length;e<i;e+=2)t[e+1]>a?(a=t[e+1],r=t[e]):t[e+1]===a&&(r=Math.max(r,t[e]));if(r!==1/0)return[r,a]}return n?[n[2],n[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:r}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-n)/i,t[1]=100*(t[1]-r)/s,t}get commentText(){var t,e,i;const{data:s}=this;return(null==(e=null==(t=this.annotationStorage.getRawValue(`${gu}${s.id}`))?void 0:t.popup)?void 0:e.contents)||(null==(i=s.contentsObj)?void 0:i.str)||""}set commentText(t){const{data:e}=this,i={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:i})||this.annotationStorage.setValue(`${gu}${e.id}`,{id:e.id,annotationType:e.annotationType,pageIndex:this.parent.page._pageIndex,popup:i,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){var t,e;null==(e=(null==(t=Vd(this,xa))?void 0:t.popup)||this.popup)||e.remove(),qd(this,xa,this.popup=null)}updateEdited(t){var e;if(!this.container)return;t.rect&&(Vd(this,Aa)||qd(this,Aa,{rect:this.data.rect.slice(0)}));const{rect:i,popup:s}=t;i&&Xd(this,ka,Sa).call(this,i);let n=(null==(e=Vd(this,xa))?void 0:e.popup)||this.popup;!n&&(null==s?void 0:s.text)&&(this._createPopup(s),n=Vd(this,xa).popup),n&&(n.updateEdited(t),(null==s?void 0:s.deleted)&&(n.remove(),qd(this,xa,null),this.popup=null))}resetEdited(){var t;Vd(this,Aa)&&(Xd(this,ka,Sa).call(this,Vd(this,Aa).rect),null==(t=Vd(this,xa))||t.popup.resetEdited(),qd(this,Aa,null))}_createContainer(t){const{data:e,parent:{page:i,viewport:s}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof lv||this instanceof av||(n.tabIndex=0);const{style:r}=n;if(r.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof fv){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:a,height:o}=this;if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;if(t>0||i>0){const e=`calc(${t}px * var(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`;r.borderRadius=e}else if(this instanceof uv){const t=`calc(${a}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`;r.borderRadius=t}switch(e.borderStyle.style){case Mu:r.borderStyle="solid";break;case Eu:r.borderStyle="dashed";break;case Cu:Hu("Unimplemented border style: beveled");break;case Tu:Hu("Unimplemented border style: inset");break;case Pu:r.borderBottomStyle="solid"}const s=e.borderColor||null;s?(qd(this,_a,!0),r.borderColor=np.makeHexColor(0|s[0],0|s[1],0|s[2])):r.borderWidth=0}const l=np.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:h,pageHeight:c,pageX:d,pageY:u}=s.rawDims;r.left=100*(l[0]-d)/h+"%",r.top=100*(l[1]-u)/c+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(r.width=100*a/h+"%",r.height=100*o/c+"%"):this.setRotation(p,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims;let{width:n,height:r}=this;t%180!=0&&([n,r]=[r,n]),e.style.width=100*n/i+"%",e.style.height=100*r/s+"%",e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,i)=>{const s=i.detail[t],n=s[0],r=s.slice(1);i.target.style[e]=Jm[`${n}_HTML`](r),this.annotationStorage.setValue(this.data.id,{[e]:Jm[`${n}_rgb`](r)})};return Gu(this,"_commonActions",{display:t=>{const{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout(()=>t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const s of Object.keys(e.detail)){const n=t[s]||i[s];null==n||n(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[s,n]of Object.entries(e)){const r=i[s];if(r){r({detail:{[s]:n},target:t}),delete e[s]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,s,n]=this.data.rect.map(t=>Math.fround(t));if(8===t.length){const[r,a,o,l]=t.subarray(2,6);if(s===r&&n===a&&e===o&&i===l)return}const{style:r}=this.container;let a;if(Vd(this,_a)){const{borderColor:t,borderWidth:e}=r;r.borderWidth=0,a=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const o=s-e,l=n-i,{svgFactory:h}=this,c=h.createElement("svg");c.classList.add("quadrilateralsContainer"),c.setAttribute("width",0),c.setAttribute("height",0),c.role="none";const d=h.createElement("defs");c.append(d);const u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),d.append(u);for(let g=2,f=t.length;g<f;g+=8){const i=t[g],s=t[g+1],r=t[g+2],c=t[g+3],d=h.createElement("rect"),p=(r-e)/o,f=(n-s)/l,m=(i-r)/o,v=(s-c)/l;d.setAttribute("x",p),d.setAttribute("y",f),d.setAttribute("width",m),d.setAttribute("height",v),u.append(d),null==a||a.push(`<rect vector-effect="non-scaling-stroke" x="${p}" y="${f}" width="${m}" height="${v}"/>`)}Vd(this,_a)&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(c),this.container.style.clipPath=`url(#${p})`}_createPopup(t=null){const{data:e}=this;let i,s;t?(i={str:t.text},s=t.date):(i=e.contentsObj,s=e.modificationDate);const n=qd(this,xa,new fv({data:{color:e.color,titleObj:e.titleObj,modificationDate:s,contentsObj:i,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}));this.parent._commentManager||this.parent.div.append(n.render())}get hasPopupElement(){return!!(Vd(this,xa)||this.popup||this.data.popupRef)}get extraPopupElement(){return Vd(this,xa)}render(){$u("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const s=this._fieldObjects[t];if(s)for(const{page:t,id:n,exportValues:r}of s){if(-1===t)continue;if(n===e)continue;const s="string"==typeof r?r:null,a=document.querySelector(`[data-element-id="${n}"]`);!a||ev.has(a)?i.push({id:n,exportValue:s,domElement:a}):Hu(`_getElementsByName - element not allowed: ${n}`)}return i}for(const s of document.getElementsByName(t)){const{exportValue:t}=s,n=s.getAttribute("data-element-id");n!==e&&(ev.has(s)&&i.push({id:n,exportValue:t,domElement:s}))}return i}show(){var t;this.container&&(this.container.hidden=!1),null==(t=this.popup)||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),null==(t=this.popup)||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{var i;null==(i=this.linkService.eventBus)||i.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}};class rv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:t}=this;t.hasComment&&(this._createPopup(t.comment),this.extraPopupElement.popup.renderCommentButton())}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.container.remove(),this.container=null,this.removePopup()}}class av extends nv{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!(null==e?void 0:e.ignoreBorder),createQuadrilaterals:!0}),Gd(this,Ma),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action,t.overlaidText),s=!0):t.attachment?(Xd(this,Ma,Ca).call(this,i,t.attachment,t.overlaidText,t.attachmentDest),s=!0):t.setOCGState?(Xd(this,Ma,Ta).call(this,i,t.setOCGState,t.overlaidText),s=!0):t.dest?(this._bindLink(i,t.dest,t.overlaidText),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&this.container.append(i),this.container}_bindLink(t,e,i=""){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&Xd(this,Ma,Ea).call(this),i&&(t.title=i)}_bindNamedAction(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),i&&(t.title=i),Xd(this,Ma,Ea).call(this)}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const s of Object.keys(e.actions)){const n=i.get(s);n&&(t[n]=()=>{var t;return null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1})}e.overlaidText&&(t.title=e.overlaidText),t.onclick||(t.onclick=()=>!1),Xd(this,Ma,Ea).call(this)}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),Xd(this,Ma,Ea).call(this),!this._fieldObjects)return Hu('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(i||(t.onclick=()=>!1));t.onclick=()=>{var t;null==i||i();const{fields:s,refs:n,include:r}=e,a=[];if(0!==s.length||0!==n.length){const t=new Set(n);for(const e of s){const i=this._fieldObjects[e]||[];for(const{id:e}of i)t.add(e)}for(const e of Object.values(this._fieldObjects))for(const i of e)t.has(i.id)===r&&a.push(i)}else for(const e of Object.values(this._fieldObjects))a.push(...e);const o=this.annotationStorage,l=[];for(const e of a){const{id:t}=e;switch(l.push(t),e.type){case"text":{const i=e.defaultValue||"";o.setValue(t,{value:i});break}case"checkbox":case"radiobutton":{const i=e.defaultValue===e.exportValues;o.setValue(t,{value:i});break}case"combobox":case"listbox":{const i=e.defaultValue||"";o.setValue(t,{value:i});break}default:continue}const i=document.querySelector(`[data-element-id="${t}"]`);i&&(ev.has(i)?i.dispatchEvent(new Event("resetform")):Hu(`_bindResetFormAction - element not allowed: ${t}`))}return this.enableScripting&&(null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:l,name:"ResetForm"}})),!1}}}Ma=new WeakSet,Ea=function(){this.container.setAttribute("data-internal-link","")},Ca=function(t,e,i="",s=null){t.href=this.linkService.getAnchorUrl(""),e.description?t.title=e.description:i&&(t.title=i),t.onclick=()=>{var t;return null==(t=this.downloadManager)||t.openOrDownloadData(e.content,e.filename,s),!1},Xd(this,Ma,Ea).call(this)},Ta=function(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),i&&(t.title=i),Xd(this,Ma,Ea).call(this)};class ov extends nv{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 lv extends nv{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&("CANVAS"===(null==(e=t.previousSibling)?void 0:e.nodeName)&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return ip.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,n){i.includes("mouse")?t.addEventListener(i,t=>{var e;null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})}):t.addEventListener(i,t=>{var r;if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}n&&(null==(r=this.linkService.eventBus)||r.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t)}}))})}_setEventListeners(t,e,i,s){var n,r,a;for(const[o,l]of i)("Action"===l||(null==(n=this.data.actions)?void 0:n[l]))&&("Focus"!==l&&"Blur"!==l||e||(e={focused:!1}),this._setEventListener(t,e,o,l,s),"Focus"!==l||(null==(r=this.data.actions)?void 0:r.Blur)?"Blur"!==l||(null==(a=this.data.actions)?void 0:a.Focus)||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":np.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,n=t.style;let r;const a=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=t/(Math.round(t/(nu*s))||1);r=Math.min(s,a(e/nu))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(s,a(t/nu))}n.fontSize=`calc(${r}px * var(--total-scale-factor))`,n.color=np.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class hv extends lv{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,s){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=i),n.setValue(r.id,{[s]:i})}render(){var t,e;const i=this.annotationStorage,s=this.data.id;this.container.classList.add("textWidgetAnnotation");let n=null;if(this.renderForms){const r=i.getValue(s,{value:this.data.fieldValue});let a=r.value||"";const o=i.getValue(s,{charLimit:this.data.maxLen}).charLimit;o&&a.length>o&&(a=a.slice(0,o));let l=r.formattedValue||(null==(t=this.data.textContent)?void 0:t.join("\n"))||null;l&&this.data.comb&&(l=l.replaceAll(/\s+/g,""));const h={userValue:a,formattedValue:l,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement("textarea"),n.textContent=l??a,this.data.doNotScroll&&(n.style.overflowY="hidden")):(n=document.createElement("input"),n.type=this.data.password?"password":"text",n.setAttribute("value",l??a),this.data.doNotScroll&&(n.style.overflowX="hidden")),this.data.hasOwnCanvas&&(n.hidden=!0),ev.add(n),n.setAttribute("data-element-id",s),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=0;const{datetimeFormat:c,datetimeType:d,timeStep:u}=this.data,p=!!d&&this.enableScripting;c&&(n.title=c),this._setRequired(n,this.data.required),o&&(n.maxLength=o),n.addEventListener("input",t=>{i.setValue(s,{value:t.target.value}),this.setPropertyOnSiblings(n,"value",t.target.value,"value"),h.formattedValue=null}),n.addEventListener("resetform",t=>{const e=this.data.defaultFieldValue??"";n.value=h.userValue=e,h.formattedValue=null});let g=t=>{const{formattedValue:e}=h;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener("focus",t=>{var e;if(h.focused)return;const{target:i}=t;if(p&&(i.type=d,u&&(i.step=u)),h.userValue){const t=h.userValue;if(p)if("time"===d){const e=new Date(t),s=[e.getHours(),e.getMinutes(),e.getSeconds()];i.value=s.map(t=>t.toString().padStart(2,"0")).join(":")}else i.value=new Date(t-iv).toISOString().split("date"===d?"T":".",1)[0];else i.value=t}h.lastCommittedValue=i.value,h.commitKey=1,(null==(e=this.data.actions)?void 0:e.Focus)||(h.focused=!0)}),n.addEventListener("updatefromsandbox",t=>{this.showElementAndHideCanvas(t.target);const e={value(t){h.userValue=t.detail.value??"",p||i.setValue(s,{value:h.userValue.toString()}),t.target.value=h.userValue},formattedValue(t){const{formattedValue:e}=t.detail;h.formattedValue=e,null!=e&&t.target!==document.activeElement&&(t.target.value=e);const n={formattedValue:e};p&&(n.value=e),i.setValue(s,n)},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:t=>{var e;const{charLimit:n}=t.detail,{target:r}=t;if(0===n)return void r.removeAttribute("maxLength");r.setAttribute("maxLength",n);let a=h.userValue;!a||a.length<=n||(a=a.slice(0,n),r.value=h.userValue=a,i.setValue(s,{value:a}),null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s,name:"Keystroke",value:a,willCommit:!0,commitKey:1,selStart:r.selectionStart,selEnd:r.selectionEnd}}))}};this._dispatchEventFromSandbox(e,t)}),n.addEventListener("keydown",t=>{var e;h.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(h.commitKey=3):i=2,-1===i)return;const{value:n}=t.target;h.lastCommittedValue!==n&&(h.lastCommittedValue=n,h.userValue=n,null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s,name:"Keystroke",value:n,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))});const t=g;g=null,n.addEventListener("blur",e=>{var i,n;if(!h.focused||!e.relatedTarget)return;(null==(i=this.data.actions)?void 0:i.Blur)||(h.focused=!1);const{target:r}=e;let{value:a}=r;if(p){if(a&&"time"===d){const t=a.split(":").map(t=>parseInt(t,10));a=new Date(2e3,0,1,t[0],t[1],t[2]||0).valueOf(),r.step=""}else a.includes("T")||(a=`${a}T00:00`),a=new Date(a).valueOf();r.type="text"}h.userValue=a,h.lastCommittedValue!==a&&(null==(n=this.linkService.eventBus)||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s,name:"Keystroke",value:a,willCommit:!0,commitKey:h.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}})),t(e)}),(null==(e=this.data.actions)?void 0:e.Keystroke)&&n.addEventListener("beforeinput",t=>{var e;h.lastCommittedValue=null;const{data:i,target:n}=t,{value:r,selectionStart:a,selectionEnd:o}=n;let l=a,c=o;switch(t.inputType){case"deleteWordBackward":{const t=r.substring(0,a).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{const t=r.substring(a).match(/^[^\w]*\w*/);t&&(c+=t[0].length);break}case"deleteContentBackward":a===o&&(l-=1);break;case"deleteContentForward":a===o&&(c+=1)}t.preventDefault(),null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s,name:"Keystroke",value:r,change:i||"",willCommit:!1,selStart:l,selEnd:c}})}),this._setEventListeners(n,h,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.value)}if(g&&n.addEventListener("blur",g),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/o;n.classList.add("comb"),n.style.letterSpacing=`calc(${t}px * var(--total-scale-factor) - 1ch)`}}else n=document.createElement("div"),n.textContent=this.data.fieldValue,n.style.verticalAlign="middle",n.style.display="table-cell",this.data.hasOwnCanvas&&(n.hidden=!0);return this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class cv extends lv{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class dv extends lv{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return ev.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=0,n.addEventListener("change",s=>{const{name:n,checked:r}=s.target;for(const a of this._getElementsByName(n,i)){const i=r&&a.exportValue===e.exportValue;a.domElement&&(a.domElement.checked=i),t.setValue(a.id,{value:i})}t.setValue(i,{value:r})}),n.addEventListener("resetform",t=>{const i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",e=>{const s={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}};this._dispatchEventFromSandbox(s,e)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class uv extends lv{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(const r of this._getElementsByName(e.fieldName,i))t.setValue(r.id,{value:!1});const n=document.createElement("input");if(ev.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.tabIndex=0,n.addEventListener("change",e=>{const{name:s,checked:n}=e.target;for(const r of this._getElementsByName(s,i))t.setValue(r.id,{value:!1});t.setValue(i,{value:n})}),n.addEventListener("resetform",t=>{const i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue}),this.enableScripting&&this.hasJSActions){const s=e.buttonValue;n.addEventListener("updatefromsandbox",e=>{const n={value:e=>{const n=s===e.detail.value;for(const s of this._getElementsByName(e.target.name)){const e=n&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}};this._dispatchEventFromSandbox(n,e)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class pv extends av{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({},t)})),t}}class gv extends lv{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");ev.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=0;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",t=>{const e=this.data.defaultFieldValue;for(const i of s.options)i.selected=i.value===e});for(const h of this.data.options){const t=document.createElement("option");t.textContent=h.displayValue,t.value=h.exportValue,i.value.includes(h.exportValue)&&(t.setAttribute("selected",!0),n=!1),s.append(t)}let r=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),r=()=>{t.remove(),s.removeEventListener("input",r),r=null},s.addEventListener("input",r)}const a=t=>{const e=t?"value":"textContent",{options:i,multiple:n}=s;return n?Array.prototype.filter.call(i,t=>t.selected).map(t=>t[e]):-1===i.selectedIndex?null:i[i.selectedIndex][e]};let o=a(!1);const l=t=>{const e=t.target.options;return Array.prototype.map.call(e,t=>({displayValue:t.textContent,exportValue:t.value}))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",i=>{const n={value(i){null==r||r();const n=i.detail.value,l=new Set(Array.isArray(n)?n:[n]);for(const t of s.options)t.selected=l.has(t.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(t){s.multiple=!0},remove(i){const n=s.options,r=i.detail.remove;if(n[r].selected=!1,s.remove(r),n.length>0){-1===Array.prototype.findIndex.call(n,t=>t.selected)&&(n[0].selected=!0)}t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(i){const{index:n,displayValue:r,exportValue:h}=i.detail.insert,c=s.children[n],d=document.createElement("option");d.textContent=r,d.value=h,c?c.before(d):s.append(d),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},items(i){const{items:n}=i.detail;for(;0!==s.length;)s.remove(0);for(const t of n){const{displayValue:e,exportValue:i}=t,n=document.createElement("option");n.textContent=e,n.value=i,s.append(n)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},indices(i){const s=new Set(i.detail.indices);for(const t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(n,i)}),s.addEventListener("input",i=>{var s;const n=a(!0),r=a(!1);t.setValue(e,{value:n}),i.preventDefault(),null==(s=this.linkService.eventBus)||s.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:r,changeEx:n,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],t=>t.target.value)):s.addEventListener("input",function(i){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class fv extends nv{constructor(t){const{data:e,elements:i,parent:s}=t,n=!!s._commentManager;if(super(t,{isRenderable:!n&&nv._hasPopupData(e)}),Gd(this,Pa),this.elements=i,n&&nv._hasPopupData(e)){const t=this.popup=Xd(this,Pa,Da).call(this);for(const e of i)e.popup=t}else this.popup=null}render(){const{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";const e=this.popup=Xd(this,Pa,Da).call(this),i=[];for(const s of this.elements)s.popup=e,s.container.ariaHasPopup="dialog",i.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",i.map(t=>`${hp}${t}`).join(",")),this.container}}Pa=new WeakSet,Da=function(){return new mv({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})};class mv{constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:n,contentsObj:r,richText:a,parent:o,rect:l,parentRect:h,open:c,commentManager:d=null}){Gd(this,no),Gd(this,Ra,null),Gd(this,Ia,Xd(this,no,go).bind(this)),Gd(this,La,Xd(this,no,wo).bind(this)),Gd(this,Fa,Xd(this,no,vo).bind(this)),Gd(this,Na,Xd(this,no,mo).bind(this)),Gd(this,Wa,null),Gd(this,Ba,null),Gd(this,Oa,null),Gd(this,Ua,null),Gd(this,Ha,null),Gd(this,$a,null),Gd(this,ja,null),Gd(this,za,!1),Gd(this,Va,null),Gd(this,Ga,null),Gd(this,qa,null),Gd(this,Xa,null),Gd(this,Ya,null),Gd(this,Ka,null),Gd(this,Qa,null),Gd(this,Ja,null),Gd(this,Za,null),Gd(this,to,null),Gd(this,eo,!1),Gd(this,io,null),Gd(this,so,null),qd(this,Ba,t),qd(this,Za,s),qd(this,Oa,r),qd(this,Ja,a),qd(this,$a,o),qd(this,Wa,e),qd(this,Qa,l),qd(this,ja,h),qd(this,Ha,i),qd(this,Ra,d),qd(this,io,i[0]),qd(this,Ua,Cp.toDateObject(n)),this.trigger=i.flatMap(t=>t.getElementsToTriggerPopup()),d?this.renderCommentButton():(Xd(this,no,ro).call(this),Vd(this,Ba).hidden=!0,c&&Xd(this,no,mo).call(this))}renderCommentButton(){if(Vd(this,Xa))return;if(Vd(this,Ya)||Xd(this,no,ao).call(this),!Vd(this,Ya))return;const{signal:t}=qd(this,Ga,new AbortController),e=!!Vd(this,io).extraPopupElement,i=()=>{Vd(this,Ra).toggleCommentPopup(this,!0,void 0,!e)},s=()=>{Vd(this,Ra).toggleCommentPopup(this,!1,!0,!e)},n=()=>{Vd(this,Ra).toggleCommentPopup(this,!1,!1)};if(e){qd(this,Xa,Vd(this,io).container);for(const e of this.trigger)e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.addEventListener("keydown",Vd(this,Ia),{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",s,{signal:t}),e.addEventListener("pointerleave",n,{signal:t}),e.classList.add("popupTriggerArea")}else{const e=qd(this,Xa,document.createElement("button"));e.className="annotationCommentButton";const r=Vd(this,io).container;e.style.zIndex=r.style.zIndex+1,e.tabIndex=0,e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button"),Xd(this,no,lo).call(this),Xd(this,no,oo).call(this),e.addEventListener("keydown",Vd(this,Ia),{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",s,{signal:t}),e.addEventListener("pointerleave",n,{signal:t}),r.after(e)}}get commentButtonColor(){const{color:t,opacity:e}=Vd(this,io).commentData;return t?Vd(this,$a)._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{var t;null==(t=Vd(this,Xa))||t.focus()},0)}getData(){const{richText:t,color:e,opacity:i,creationDate:s,modificationDate:n}=Vd(this,io).commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:i,creationDate:s,modificationDate:n}}get elementBeforePopup(){return Vd(this,Xa)}get comment(){return Vd(this,so)||qd(this,so,Vd(this,io).commentText),Vd(this,so)}set comment(t){t!==this.comment&&(Vd(this,io).commentText=qd(this,so,t))}get parentBoundingClientRect(){return Vd(this,io).layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){Vd(this,Xa)&&(Vd(this,Xa).classList.toggle("selected",t),Vd(this,Xa).ariaExpanded=e)}setSelectedCommentButton(t){Vd(this,Xa).classList.toggle("selected",t)}get commentPopupPosition(){if(Vd(this,Ka))return Vd(this,Ka);const{x:t,y:e,height:i}=Vd(this,Xa).getBoundingClientRect(),{x:s,y:n,width:r,height:a}=Vd(this,io).layer.getBoundingClientRect();return[(t-s)/r,(e+i-n)/a]}set commentPopupPosition(t){qd(this,Ka,t)}hasDefaultPopupPosition(){return null===Vd(this,Ka)}get commentButtonPosition(){return Vd(this,Ya)}get commentButtonWidth(){return Vd(this,Xa).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,i]=Vd(this,Ka)||this.commentButtonPosition.map(t=>t/100),s=this.parentBoundingClientRect,{x:n,y:r,width:a,height:o}=s;Vd(this,Ra).showDialog(null,this,n+e*a,r+i*o,{...t,parentDimensions:s})}render(){var t,e;if(Vd(this,Va))return;const i=qd(this,Va,document.createElement("div"));if(i.className="popup",Vd(this,Wa)){const t=i.style.outlineColor=np.makeHexColor(...Vd(this,Wa));i.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`}const s=document.createElement("span");if(s.className="header",null==(t=Vd(this,Za))?void 0:t.str){const t=document.createElement("span");t.className="title",s.append(t),({dir:t.dir,str:t.textContent}=Vd(this,Za))}if(i.append(s),Vd(this,Ua)){const t=document.createElement("time");t.className="popupDate",t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:Vd(this,Ua).valueOf()})),t.dateTime=Vd(this,Ua).toISOString(),s.append(t)}Vp({html:Vd(this,no,ho)||Vd(this,Oa).str,dir:null==(e=Vd(this,Oa))?void 0:e.dir,className:"popupContent"},i),Vd(this,Ba).append(i)}updateEdited({rect:t,popup:e,deleted:i}){var s;if(Vd(this,Ra))return i?(this.remove(),qd(this,so,null)):e&&(e.deleted?this.remove():(Xd(this,no,lo).call(this),qd(this,so,e.text))),void(t&&(qd(this,Ya,null),Xd(this,no,ao).call(this),Xd(this,no,oo).call(this)));i||(null==e?void 0:e.deleted)?this.remove():(Xd(this,no,ro).call(this),Vd(this,to)||qd(this,to,{contentsObj:Vd(this,Oa),richText:Vd(this,Ja)}),t&&qd(this,qa,null),e&&e.text&&(qd(this,Ja,Xd(this,no,po).call(this,e.text)),qd(this,Ua,Cp.toDateObject(e.date)),qd(this,Oa,null)),null==(s=Vd(this,Va))||s.remove(),qd(this,Va,null))}resetEdited(){var t;Vd(this,to)&&(({contentsObj:Yd(this,Oa)._,richText:Yd(this,Ja)._}=Vd(this,to)),qd(this,to,null),null==(t=Vd(this,Va))||t.remove(),qd(this,Va,null),qd(this,qa,null))}remove(){var t,e,i;if(null==(t=Vd(this,Ga))||t.abort(),qd(this,Ga,null),null==(e=Vd(this,Va))||e.remove(),qd(this,Va,null),qd(this,eo,!1),qd(this,za,!1),null==(i=Vd(this,Xa))||i.remove(),qd(this,Xa,null),this.trigger)for(const s of this.trigger)s.classList.remove("popupTriggerArea")}forceHide(){qd(this,eo,this.isVisible),Vd(this,eo)&&(Vd(this,Ba).hidden=!0)}maybeShow(){Vd(this,Ra)||(Xd(this,no,ro).call(this),Vd(this,eo)&&(Vd(this,Va)||Xd(this,no,vo).call(this),qd(this,eo,!1),Vd(this,Ba).hidden=!1))}get isVisible(){return!Vd(this,Ra)&&!1===Vd(this,Ba).hidden}}Ra=new WeakMap,Ia=new WeakMap,La=new WeakMap,Fa=new WeakMap,Na=new WeakMap,Wa=new WeakMap,Ba=new WeakMap,Oa=new WeakMap,Ua=new WeakMap,Ha=new WeakMap,$a=new WeakMap,ja=new WeakMap,za=new WeakMap,Va=new WeakMap,Ga=new WeakMap,qa=new WeakMap,Xa=new WeakMap,Ya=new WeakMap,Ka=new WeakMap,Qa=new WeakMap,Ja=new WeakMap,Za=new WeakMap,to=new WeakMap,eo=new WeakMap,io=new WeakMap,so=new WeakMap,no=new WeakSet,ro=function(){var t;if(Vd(this,Ga))return;qd(this,Ga,new AbortController);const{signal:e}=Vd(this,Ga);for(const i of this.trigger)i.addEventListener("click",Vd(this,Na),{signal:e}),i.addEventListener("pointerenter",Vd(this,Fa),{signal:e}),i.addEventListener("pointerleave",Vd(this,La),{signal:e}),i.classList.add("popupTriggerArea");for(const i of Vd(this,Ha))null==(t=i.container)||t.addEventListener("keydown",Vd(this,Ia),{signal:e})},ao=function(){const t=Vd(this,Ha).find(t=>t.hasCommentButton);t&&qd(this,Ya,t._normalizePoint(t.commentButtonPosition))},oo=function(){if(Vd(this,io).extraPopupElement&&!Vd(this,io).editor)return;this.renderCommentButton();const[t,e]=Vd(this,Ya),{style:i}=Vd(this,Xa);i.left=`calc(${t}%)`,i.top=`calc(${e}% - var(--comment-button-dim))`},lo=function(){Vd(this,io).extraPopupElement||(this.renderCommentButton(),Vd(this,Xa).style.backgroundColor=this.commentButtonColor||"")},ho=function(){const t=Vd(this,Ja),e=Vd(this,Oa);return!(null==t?void 0:t.str)||(null==e?void 0:e.str)&&e.str!==t.str?null:Vd(this,Ja).html||null},co=function(){var t,e,i;return(null==(i=null==(e=null==(t=Vd(this,no,ho))?void 0:t.attributes)?void 0:e.style)?void 0:i.fontSize)||0},uo=function(){var t,e,i;return(null==(i=null==(e=null==(t=Vd(this,no,ho))?void 0:t.attributes)?void 0:e.style)?void 0:i.color)||null},po=function(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:Vd(this,no,uo),fontSize:Vd(this,no,co)?`calc(${Vd(this,no,co)}px * var(--total-scale-factor))`:""}};for(const n of t.split("\n"))e.push({name:"span",value:n,attributes:s});return i},go=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&Vd(this,za))&&Xd(this,no,mo).call(this)},fo=function(){if(null!==Vd(this,qa))return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=Vd(this,$a);let r=!!Vd(this,ja),a=Vd(this,r?ja:Qa);for(const u of Vd(this,Ha))if(!a||null!==np.intersect(u.data.rect,a)){a=u.data.rect,r=!0;break}const o=np.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),l=r?a[2]-a[0]+5:0,h=o[0]+l,c=o[1];qd(this,qa,[100*(h-s)/e,100*(c-n)/i]);const{style:d}=Vd(this,Ba);d.left=`${Vd(this,qa)[0]}%`,d.top=`${Vd(this,qa)[1]}%`},mo=function(){Vd(this,Ra)?Vd(this,Ra).toggleCommentPopup(this,!1):(qd(this,za,!Vd(this,za)),Vd(this,za)?(Xd(this,no,vo).call(this),Vd(this,Ba).addEventListener("click",Vd(this,Na)),Vd(this,Ba).addEventListener("keydown",Vd(this,Ia))):(Xd(this,no,wo).call(this),Vd(this,Ba).removeEventListener("click",Vd(this,Na)),Vd(this,Ba).removeEventListener("keydown",Vd(this,Ia))))},vo=function(){Vd(this,Va)||this.render(),this.isVisible?Vd(this,za)&&Vd(this,Ba).classList.add("focused"):(Xd(this,no,fo).call(this),Vd(this,Ba).hidden=!1,Vd(this,Ba).style.zIndex=parseInt(Vd(this,Ba).style.zIndex)+1e3)},wo=function(){Vd(this,Ba).classList.remove("focused"),!Vd(this,za)&&this.isVisible&&(Vd(this,Ba).hidden=!0,Vd(this,Ba).style.zIndex=parseInt(Vd(this,Ba).style.zIndex)-1e3)};class vv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=fu.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class wv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Gd(this,bo,null)}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=qd(this,bo,this.svgFactory.createElement("svg:line"));return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return Vd(this,bo)}addHighlightArea(){this.container.classList.add("highlightArea")}}bo=new WeakMap;class bv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Gd(this,yo,null)}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=qd(this,yo,this.svgFactory.createElement("svg:rect"));return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",i-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return Vd(this,yo)}addHighlightArea(){this.container.classList.add("highlightArea")}}yo=new WeakMap;class yv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Gd(this,Ao,null)}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=qd(this,Ao,this.svgFactory.createElement("svg:ellipse"));return r.setAttribute("cx",e/2),r.setAttribute("cy",i/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",i/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return Vd(this,Ao)}addHighlightArea(){this.container.classList.add("highlightArea")}}Ao=new WeakMap;class Av extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Gd(this,_o,null),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:i,popupRef:s},width:n,height:r}=this;if(!e)return this.container;const a=this.svgFactory.create(n,r,!0);let o=[];for(let h=0,c=e.length;h<c;h+=2){const i=e[h]-t[0],s=t[3]-e[h+1];o.push(`${i},${s}`)}o=o.join(" ");const l=qd(this,_o,this.svgFactory.createElement(this.svgElementName));return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),a.append(l),this.container.append(a),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return Vd(this,_o)}addHighlightArea(){this.container.classList.add("highlightArea")}}_o=new WeakMap;class _v extends Av{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class xv extends nv{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 kv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Gd(this,So),Gd(this,xo,null),Gd(this,ko,[]),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?fu.HIGHLIGHT:fu.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:i,borderStyle:s,popupRef:n}}=this,{transform:r,width:a,height:o}=Xd(this,So,Mo).call(this,e,t),l=this.svgFactory.create(a,o,!0),h=qd(this,xo,this.svgFactory.createElement("svg:g"));l.append(h),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",r);for(let c=0,d=i.length;c<d;c++){const t=this.svgFactory.createElement(this.svgElementName);Vd(this,ko).push(t),t.setAttribute("points",i[c].join(",")),h.append(t)}return!n&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:i,rect:s}=t,n=Vd(this,xo);if(e>=0&&n.setAttribute("stroke-width",e||1),i)for(let r=0,a=Vd(this,ko).length;r<a;r++)Vd(this,ko)[r].setAttribute("points",i[r].join(","));if(s){const{transform:t,width:e,height:i}=Xd(this,So,Mo).call(this,this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return Vd(this,ko)}addHighlightArea(){this.container.classList.add("highlightArea")}}xo=new WeakMap,ko=new WeakMap,So=new WeakSet,Mo=function(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}};class Sv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=fu.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const e=document.createElement("mark");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Mv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),t){const e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Ev extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),t){const e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Cv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),t){const e=document.createElement("s");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Tv extends nv{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=fu.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class Pv extends nv{constructor(t){var e;super(t,{isRenderable:!0}),Gd(this,Co),Gd(this,Eo,null);const{file:i}=this.data;this.filename=i.filename,this.content=i.content,null==(e=this.linkService.eventBus)||e.dispatch("fileattachmentannotation",{source:this,...i})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let i;e.hasAppearance||0===e.fillAlpha?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),i.addEventListener("dblclick",Xd(this,Co,To).bind(this)),qd(this,Eo,i);const{isMac:s}=ip.platform;return t.addEventListener("keydown",t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&Xd(this,Co,To).call(this)}),!e.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return Vd(this,Eo)}addHighlightArea(){this.container.classList.add("highlightArea")}}Eo=new WeakMap,Co=new WeakSet,To=function(){var t;null==(t=this.downloadManager)||t.openOrDownloadData(this.content,this.filename)};let Dv=(Oo=class{constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:r,structTreeLayer:a,commentManager:o,linkService:l,annotationStorage:h}){Gd(this,No),Gd(this,Po,null),Gd(this,Do,null),Gd(this,Ro,null),Gd(this,Io,new Map),Gd(this,Lo,null),Gd(this,Fo,null),this.div=t,qd(this,Po,e),qd(this,Do,i),qd(this,Lo,a||null),qd(this,Fo,l||null),qd(this,Ro,h||new wg),this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=s,this._commentManager=o||null}hasEditableAnnotations(){return Vd(this,Io).size>0}async render(t){var e,i,s;const{annotations:n}=t,r=this.div;Ip(r,this.viewport);const a=new Map,o={data:null,layer:r,linkService:Vd(this,Fo),downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new tv,annotationStorage:Vd(this,Ro),enableComment:!0===t.enableComment,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const l of n){if(l.noHTML)continue;const t=l.annotationType===Su.POPUP;if(t){const t=a.get(l.id);if(!t)continue;o.elements=t}else if(l.rect[2]===l.rect[0]||l.rect[3]===l.rect[1])continue;o.data=l;const n=sv.create(o);if(!n.isRenderable)continue;if(!t&&l.popupRef){const t=a.get(l.popupRef);t?t.push(n):a.set(l.popupRef,[n])}const r=n.render();l.hidden&&(r.style.visibility="hidden"),await Xd(this,No,Wo).call(this,r,l.id,o.elements),null==(i=null==(e=n.extraPopupElement)?void 0:e.popup)||i.renderCommentButton(),n._isEditable&&(Vd(this,Io).set(n.data.id,n),null==(s=this._annotationEditorUIManager)||s.renderAnnotationElement(n))}Xd(this,No,Bo).call(this)}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:Vd(this,Fo),svgFactory:new tv,parent:this};for(const i of t){i.borderStyle||(i.borderStyle=Oo._defaultBorderStyle),e.data=i;const t=sv.create(e);if(!t.isRenderable)continue;const s=t.render();await Xd(this,No,Wo).call(this,s,i.id,null)}}update({viewport:t}){const e=this.div;this.viewport=t,Ip(e,{rotation:t.rotation}),Xd(this,No,Bo).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(Vd(this,Io).values())}getEditableAnnotation(t){return Vd(this,Io).get(t)}addFakeAnnotation(t){var e;const{div:i}=this,{id:s,rotation:n}=t,r=new rv({data:{id:s,rect:t.getPDFRect(),rotation:n},editor:t,layer:i,parent:this,enableComment:!!this._commentManager,linkService:Vd(this,Fo),annotationStorage:Vd(this,Ro)}),a=r.render();return i.append(a),null==(e=Vd(this,Po))||e.moveElementInDOM(i,a,a,!1),r.createOrUpdatePopup(),r}static get _defaultBorderStyle(){return Gu(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Mu,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}},Po=new WeakMap,Do=new WeakMap,Ro=new WeakMap,Io=new WeakMap,Lo=new WeakMap,Fo=new WeakMap,No=new WeakSet,Wo=async function(t,e,i){var s,n;const r=t.firstChild||t,a=r.id=`${hp}${e}`,o=await(null==(s=Vd(this,Lo))?void 0:s.getAriaAttributes(a));if(o)for(const[l,h]of o)r.setAttribute(l,h);i?i.at(-1).container.after(t):(this.div.append(t),null==(n=Vd(this,Po))||n.moveElementInDOM(this.div,t,r,!1))},Bo=function(){var t;if(!Vd(this,Do))return;const e=this.div;for(const[i,s]of Vd(this,Do)){const n=e.querySelector(`[data-annotation-id="${i}"]`);if(!n)continue;s.className="annotationContent";const{firstChild:r}=n;r?"CANVAS"===r.nodeName?r.replaceWith(s):r.classList.contains("annotationContent")?r.after(s):r.before(s):n.append(s);const a=Vd(this,Io).get(i);a&&(a._hasNoCanvas?(null==(t=this._annotationEditorUIManager)||t.setMissingCanvas(i,n.id,s),a._hasNoCanvas=!1):a.canvas=s)}Vd(this,Do).clear()},Oo);const Rv=/\r\n?|\n/g,Iv=class t extends dg{constructor(e){super({...e,name:"freeTextEditor"}),Gd(this,zo),Gd(this,Uo,""),Gd(this,Ho,`${this.id}-editor`),Gd(this,$o,null),Gd(this,jo),jd(this,"_colorPicker",null),this.color=e.color||t._defaultColor||dg._defaultLineColor,qd(this,jo,e.fontSize||t._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}static get _keyboardManager(){const e=t.prototype,i=t=>t.isEmpty(),s=ng.TRANSLATE_SMALL,n=ng.TRANSLATE_BIG;return Gu(this,"_keyboardManager",new tg([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-s,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-n,0],checker:i}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[s,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[n,0],checker:i}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-s],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-n],checker:i}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,s],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,n],checker:i}]]))}static initialize(t,e){dg.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,i){switch(e){case mu.FREETEXT_SIZE:t._defaultFontSize=i;break;case mu.FREETEXT_COLOR:t._defaultColor=i}}updateParams(t,e){switch(t){case mu.FREETEXT_SIZE:Xd(this,zo,Vo).call(this,e);break;case mu.FREETEXT_COLOR:Xd(this,zo,Go).call(this,e)}}static get defaultPropertiesToUpdate(){return[[mu.FREETEXT_SIZE,t._defaultFontSize],[mu.FREETEXT_COLOR,t._defaultColor||dg._defaultLineColor]]}get propertiesToUpdate(){return[[mu.FREETEXT_SIZE,Vd(this,jo)],[mu.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Ym(this)),[["colorPicker",this._colorPicker]]}get colorType(){return mu.FREETEXT_COLOR}onUpdatedColor(){var t;this.editorDiv.style.color=this.color,null==(t=this._colorPicker)||t.update(this.color),super.onUpdatedColor()}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const e=this.parentScale;return[-t._internalPadding*e,-(t._internalPadding+Vd(this,jo))*e]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),qd(this,$o,new AbortController);const t=this._uiManager.combinedSignal(Vd(this,$o));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t}),!0}disableEditMode(){var t;return!!super.disableEditMode()&&(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",Vd(this,Ho)),this._isDraggable=!0,null==(t=Vd(this,$o))||t.abort(),qd(this,$o,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0)}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){var e;this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),(null==(e=this._initialOptions)?void 0:e.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()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=Vd(this,Uo),e=qd(this,Uo,Xd(this,zo,qo).call(this).trimEnd());if(t===e)return;const i=t=>{qd(this,Uo,t),t?(Xd(this,zo,Qo).call(this),this._uiManager.rebuild(this),Xd(this,zo,Xo).call(this)):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),Xd(this,zo,Xo).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(e){t._keyboardManager.exec(this,e)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let t,e;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",Vd(this,Ho)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${Vd(this,jo)}px * var(--total-scale-factor))`,i.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[i,s]=this.parentDimensions;if(this.annotationElementId){const{position:n}=this._initialData;let[r,a]=this.getInitialTranslation();[r,a]=this.pageTranslationToScreen(r,a);const[o,l]=this.pageDimensions,[h,c]=this.pageTranslation;let d,u;switch(this.rotation){case 0:d=t+(n[0]-h)/o,u=e+this.height-(n[1]-c)/l;break;case 90:d=t+(n[0]-h)/o,u=e-(n[1]-c)/l,[r,a]=[a,-r];break;case 180:d=t-this.width+(n[0]-h)/o,u=e-(n[1]-c)/l,[r,a]=[-r,-a];break;case 270:d=t+(n[0]-h-this.height*l)/o,u=e+(n[1]-c-this.width*o)/l,[r,a]=[-a,r]}this.setAt(d*i,u*s,r,a)}else this._moveAfterPaste(t,e);Xd(this,zo,Qo).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var i,s,n;const r=e.clipboardData||window.clipboardData,{types:a}=r;if(1===a.length&&"text/plain"===a[0])return;e.preventDefault();const o=Xd(i=t,Yo,Zo).call(i,r.getData("text")||"").replaceAll(Rv,"\n");if(!o)return;const l=window.getSelection();if(!l.rangeCount)return;this.editorDiv.normalize(),l.deleteFromDocument();const h=l.getRangeAt(0);if(!o.includes("\n"))return h.insertNode(document.createTextNode(o)),this.editorDiv.normalize(),void l.collapseToStart();const{startContainer:c,startOffset:d}=h,u=[],p=[];if(c.nodeType===Node.TEXT_NODE){const e=c.parentElement;if(p.push(c.nodeValue.slice(d).replaceAll(Rv,"")),e!==this.editorDiv){let i=u;for(const n of this.editorDiv.childNodes)n!==e?i.push(Xd(s=t,Yo,Ko).call(s,n)):i=p}u.push(c.nodeValue.slice(0,d).replaceAll(Rv,""))}else if(c===this.editorDiv){let e=u,i=0;for(const s of this.editorDiv.childNodes)i++===d&&(e=p),e.push(Xd(n=t,Yo,Ko).call(n,s))}qd(this,Uo,`${u.join("\n")}${o}${p.join("\n")}`),Xd(this,zo,Qo).call(this);const g=new Range;let f=Math.sumPrecise(u.map(t=>t.length));for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(f<=e){g.setStart(t,f),g.setEnd(t,f);break}f-=e}l.removeAllRanges(),l.addRange(g)}get contentDiv(){return this.editorDiv}getPDFRect(){const e=t._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,i,s){var n;let r=null;if(e instanceof vv){const{data:{defaultAppearanceData:{fontSize:t,fontColor:i},rect:s,rotation:n,id:a,popupRef:o,richText:l,contentsObj:h,creationDate:c,modificationDate:d},textContent:u,textPosition:p,parent:{page:{pageNumber:g}}}=e;if(!u||0===u.length)return null;r=e={annotationType:fu.FREETEXT,color:Array.from(i),fontSize:t,value:u.join("\n"),position:p,pageIndex:g-1,rect:s.slice(0),rotation:n,annotationElementId:a,id:a,deleted:!1,popupRef:o,comment:(null==h?void 0:h.str)||null,richText:l,creationDate:c,modificationDate:d}}const a=await super.deserialize(e,i,s);return qd(a,jo,e.fontSize),a.color=np.makeHexColor(...e.color),qd(a,Uo,Xd(n=t,Yo,Zo).call(n,e.value)),a._initialData=r,e.comment&&a.setCommentData(e),a}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=dg._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(t),{color:e,fontSize:Vd(this,jo),value:Xd(this,zo,Jo).call(this)});return this.addComment(i),t?(i.isCopy=!0,i):this.annotationElementId&&!Xd(this,zo,tl).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(!e)return null;const{style:i}=e;i.fontSize=`calc(${Vd(this,jo)}px * var(--total-scale-factor))`,i.color=this.color,e.replaceChildren();for(const s of Vd(this,Uo).split("\n")){const t=document.createElement("div");t.append(s?document.createTextNode(s):document.createElement("br")),e.append(t)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:Vd(this,Uo)}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}};Uo=new WeakMap,Ho=new WeakMap,$o=new WeakMap,jo=new WeakMap,zo=new WeakSet,Vo=function(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-Vd(this,jo))*this.parentScale),qd(this,jo,t),Xd(this,zo,Xo).call(this)},i=Vd(this,jo);this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:mu.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},Go=function(t){const e=t=>{this.color=t,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:mu.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},qo=function(){var t;const e=[];this.editorDiv.normalize();let i=null;for(const s of this.editorDiv.childNodes)(null==i?void 0:i.nodeType)===Node.TEXT_NODE&&"BR"===s.nodeName||(e.push(Xd(t=Iv,Yo,Ko).call(t,s)),i=s);return e.join("\n")},Xo=function(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,s=e.style.display,n=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),i=e.getBoundingClientRect(),e.remove(),e.style.display=s,e.classList.toggle("hidden",n)}this.rotation%180==this.parentRotation%180?(this.width=i.width/t,this.height=i.height/e):(this.width=i.height/t,this.height=i.width/e),this.fixAndSetPosition()},Yo=new WeakSet,Ko=function(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Rv,"")},Qo=function(){if(this.editorDiv.replaceChildren(),Vd(this,Uo))for(const t of Vd(this,Uo).split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}},Jo=function(){return Vd(this,Uo).replaceAll(" "," ")},Zo=function(t){return t.replaceAll(" "," ")},tl=function(t){const{value:e,fontSize:i,color:s,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some((t,e)=>t!==s[e])||t.pageIndex!==n},Gd(Iv,Yo),jd(Iv,"_freeTextDefaultContent",""),jd(Iv,"_internalPadding",0),jd(Iv,"_defaultColor",null),jd(Iv,"_defaultFontSize",10),jd(Iv,"_type","freetext"),jd(Iv,"_editorType",fu.FREETEXT);let Lv=Iv;class Fv{toSVGPath(){$u("Abstract method `toSVGPath` must be implemented.")}get box(){$u("Abstract getter `box` must be implemented.")}serialize(t,e){$u("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,n,r){r||(r=new Float32Array(t.length));for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*s,r[a+1]=i+t[a+1]*n;return r}static _rescaleAndSwap(t,e,i,s,n,r){r||(r=new Float32Array(t.length));for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*s,r[a+1]=i+t[a]*n;return r}static _translate(t,e,i,s){s||(s=new Float32Array(t.length));for(let n=0,r=t.length;n<r;n+=2)s[n]=e+t[n],s[n+1]=i+t[n+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,s,n){switch(n){case 90:return[1-e/i,t/s];case 180:return[1-t/i,1-e/s];case 270:return[e/i,1-t/s];default:return[t/i,e/s]}}static _normalizePagePoint(t,e,i){switch(i){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,i,s,n,r){return[(t+5*i)/6,(e+5*s)/6,(5*i+n)/6,(5*s+r)/6,(i+n)/2,(s+r)/2]}}jd(Fv,"PRECISION",1e-4);const Nv=class t{constructor({x:e,y:i},s,n,r,a,o=0){Gd(this,vl),Gd(this,el),Gd(this,il,[]),Gd(this,sl),Gd(this,nl),Gd(this,rl,[]),Gd(this,al,new Float32Array(18)),Gd(this,ol),Gd(this,ll),Gd(this,hl),Gd(this,cl),Gd(this,dl),Gd(this,ul),Gd(this,pl,[]),qd(this,el,s),qd(this,ul,r*n),qd(this,nl,a),Vd(this,al).set([NaN,NaN,NaN,NaN,e,i],6),qd(this,sl,o),qd(this,cl,Vd(t,gl)*n),qd(this,hl,Vd(t,ml)*n),qd(this,dl,n),Vd(this,pl).push(e,i)}isEmpty(){return isNaN(Vd(this,al)[8])}add({x:t,y:e}){var i;qd(this,ol,t),qd(this,ll,e);const[s,n,r,a]=Vd(this,el);let[o,l,h,c]=Vd(this,al).subarray(8,12);const d=t-h,u=e-c,p=Math.hypot(d,u);if(p<Vd(this,hl))return!1;const g=p-Vd(this,cl),f=g/p,m=f*d,v=f*u;let w=o,b=l;o=h,l=c,h+=m,c+=v,null==(i=Vd(this,pl))||i.push(t,e);const y=m/g,A=-v/g*Vd(this,ul),_=y*Vd(this,ul);if(Vd(this,al).set(Vd(this,al).subarray(2,8),0),Vd(this,al).set([h+A,c+_],4),Vd(this,al).set(Vd(this,al).subarray(14,18),12),Vd(this,al).set([h-A,c-_],16),isNaN(Vd(this,al)[6]))return 0===Vd(this,rl).length&&(Vd(this,al).set([o+A,l+_],2),Vd(this,rl).push(NaN,NaN,NaN,NaN,(o+A-s)/r,(l+_-n)/a),Vd(this,al).set([o-A,l-_],14),Vd(this,il).push(NaN,NaN,NaN,NaN,(o-A-s)/r,(l-_-n)/a)),Vd(this,al).set([w,b,o,l,h,c],6),!this.isEmpty();Vd(this,al).set([w,b,o,l,h,c],6);return Math.abs(Math.atan2(b-l,w-o)-Math.atan2(v,m))<Math.PI/2?([o,l,h,c]=Vd(this,al).subarray(2,6),Vd(this,rl).push(NaN,NaN,NaN,NaN,((o+h)/2-s)/r,((l+c)/2-n)/a),[o,l,w,b]=Vd(this,al).subarray(14,18),Vd(this,il).push(NaN,NaN,NaN,NaN,((w+o)/2-s)/r,((b+l)/2-n)/a),!0):([w,b,o,l,h,c]=Vd(this,al).subarray(0,6),Vd(this,rl).push(((w+5*o)/6-s)/r,((b+5*l)/6-n)/a,((5*o+h)/6-s)/r,((5*l+c)/6-n)/a,((o+h)/2-s)/r,((l+c)/2-n)/a),[h,c,o,l,w,b]=Vd(this,al).subarray(12,18),Vd(this,il).push(((w+5*o)/6-s)/r,((b+5*l)/6-n)/a,((5*o+h)/6-s)/r,((5*l+c)/6-n)/a,((o+h)/2-s)/r,((l+c)/2-n)/a),!0)}toSVGPath(){if(this.isEmpty())return"";const t=Vd(this,rl),e=Vd(this,il);if(isNaN(Vd(this,al)[6])&&!this.isEmpty())return Xd(this,vl,bl).call(this);const i=[];i.push(`M${t[4]} ${t[5]}`);for(let s=6;s<t.length;s+=6)isNaN(t[s])?i.push(`L${t[s+4]} ${t[s+5]}`):i.push(`C${t[s]} ${t[s+1]} ${t[s+2]} ${t[s+3]} ${t[s+4]} ${t[s+5]}`);Xd(this,vl,Al).call(this,i);for(let s=e.length-6;s>=6;s-=6)isNaN(e[s])?i.push(`L${e[s+4]} ${e[s+5]}`):i.push(`C${e[s]} ${e[s+1]} ${e[s+2]} ${e[s+3]} ${e[s+4]} ${e[s+5]}`);return Xd(this,vl,yl).call(this,i),i.join(" ")}newFreeDrawOutline(t,e,i,s,n,r){return new Bv(t,e,i,s,n,r)}getOutlines(){var t;const e=Vd(this,rl),i=Vd(this,il),s=Vd(this,al),[n,r,a,o]=Vd(this,el),l=new Float32Array(((null==(t=Vd(this,pl))?void 0:t.length)??0)+2);for(let d=0,u=l.length-2;d<u;d+=2)l[d]=(Vd(this,pl)[d]-n)/a,l[d+1]=(Vd(this,pl)[d+1]-r)/o;if(l[l.length-2]=(Vd(this,ol)-n)/a,l[l.length-1]=(Vd(this,ll)-r)/o,isNaN(s[6])&&!this.isEmpty())return Xd(this,vl,_l).call(this,l);const h=new Float32Array(Vd(this,rl).length+24+Vd(this,il).length);let c=e.length;for(let d=0;d<c;d+=2)isNaN(e[d])?h[d]=h[d+1]=NaN:(h[d]=e[d],h[d+1]=e[d+1]);c=Xd(this,vl,kl).call(this,h,c);for(let d=i.length-6;d>=6;d-=6)for(let t=0;t<6;t+=2)isNaN(i[d+t])?(h[c]=h[c+1]=NaN,c+=2):(h[c]=i[d+t],h[c+1]=i[d+t+1],c+=2);return Xd(this,vl,xl).call(this,h,c),this.newFreeDrawOutline(h,l,Vd(this,el),Vd(this,dl),Vd(this,sl),Vd(this,nl))}};el=new WeakMap,il=new WeakMap,sl=new WeakMap,nl=new WeakMap,rl=new WeakMap,al=new WeakMap,ol=new WeakMap,ll=new WeakMap,hl=new WeakMap,cl=new WeakMap,dl=new WeakMap,ul=new WeakMap,pl=new WeakMap,gl=new WeakMap,fl=new WeakMap,ml=new WeakMap,vl=new WeakSet,wl=function(){const t=Vd(this,al).subarray(4,6),e=Vd(this,al).subarray(16,18),[i,s,n,r]=Vd(this,el);return[(Vd(this,ol)+(t[0]-e[0])/2-i)/n,(Vd(this,ll)+(t[1]-e[1])/2-s)/r,(Vd(this,ol)+(e[0]-t[0])/2-i)/n,(Vd(this,ll)+(e[1]-t[1])/2-s)/r]},bl=function(){const[t,e,i,s]=Vd(this,el),[n,r,a,o]=Xd(this,vl,wl).call(this);return`M${(Vd(this,al)[2]-t)/i} ${(Vd(this,al)[3]-e)/s} L${(Vd(this,al)[4]-t)/i} ${(Vd(this,al)[5]-e)/s} L${n} ${r} L${a} ${o} L${(Vd(this,al)[16]-t)/i} ${(Vd(this,al)[17]-e)/s} L${(Vd(this,al)[14]-t)/i} ${(Vd(this,al)[15]-e)/s} Z`},yl=function(t){const e=Vd(this,il);t.push(`L${e[4]} ${e[5]} Z`)},Al=function(t){const[e,i,s,n]=Vd(this,el),r=Vd(this,al).subarray(4,6),a=Vd(this,al).subarray(16,18),[o,l,h,c]=Xd(this,vl,wl).call(this);t.push(`L${(r[0]-e)/s} ${(r[1]-i)/n} L${o} ${l} L${h} ${c} L${(a[0]-e)/s} ${(a[1]-i)/n}`)},_l=function(t){const e=Vd(this,al),[i,s,n,r]=Vd(this,el),[a,o,l,h]=Xd(this,vl,wl).call(this),c=new Float32Array(36);return c.set([NaN,NaN,NaN,NaN,(e[2]-i)/n,(e[3]-s)/r,NaN,NaN,NaN,NaN,(e[4]-i)/n,(e[5]-s)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/n,(e[17]-s)/r,NaN,NaN,NaN,NaN,(e[14]-i)/n,(e[15]-s)/r],0),this.newFreeDrawOutline(c,t,Vd(this,el),Vd(this,dl),Vd(this,sl),Vd(this,nl))},xl=function(t,e){const i=Vd(this,il);return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6},kl=function(t,e){const i=Vd(this,al).subarray(4,6),s=Vd(this,al).subarray(16,18),[n,r,a,o]=Vd(this,el),[l,h,c,d]=Xd(this,vl,wl).call(this);return t.set([NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,c,d,NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/o],e),e+24},Gd(Nv,gl,8),Gd(Nv,fl,2),Gd(Nv,ml,Vd(Nv,gl)+Vd(Nv,fl));let Wv=Nv;class Bv extends Fv{constructor(t,e,i,s,n,r){super(),Gd(this,Rl),Gd(this,Sl),Gd(this,Ml,new Float32Array(4)),Gd(this,El),Gd(this,Cl),Gd(this,Tl),Gd(this,Pl),Gd(this,Dl),qd(this,Dl,t),qd(this,Tl,e),qd(this,Sl,i),qd(this,Pl,s),qd(this,El,n),qd(this,Cl,r),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],Xd(this,Rl,Il).call(this,r);const[a,o,l,h]=Vd(this,Ml);for(let c=0,d=t.length;c<d;c+=2)t[c]=(t[c]-a)/l,t[c+1]=(t[c+1]-o)/h;for(let c=0,d=e.length;c<d;c+=2)e[c]=(e[c]-a)/l,e[c+1]=(e[c+1]-o)/h}toSVGPath(){const t=[`M${Vd(this,Dl)[4]} ${Vd(this,Dl)[5]}`];for(let e=6,i=Vd(this,Dl).length;e<i;e+=6)isNaN(Vd(this,Dl)[e])?t.push(`L${Vd(this,Dl)[e+4]} ${Vd(this,Dl)[e+5]}`):t.push(`C${Vd(this,Dl)[e]} ${Vd(this,Dl)[e+1]} ${Vd(this,Dl)[e+2]} ${Vd(this,Dl)[e+3]} ${Vd(this,Dl)[e+4]} ${Vd(this,Dl)[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,i,s],n){const r=i-t,a=s-e;let o,l;switch(n){case 0:o=Fv._rescale(Vd(this,Dl),t,s,r,-a),l=Fv._rescale(Vd(this,Tl),t,s,r,-a);break;case 90:o=Fv._rescaleAndSwap(Vd(this,Dl),t,e,r,a),l=Fv._rescaleAndSwap(Vd(this,Tl),t,e,r,a);break;case 180:o=Fv._rescale(Vd(this,Dl),i,e,-r,a),l=Fv._rescale(Vd(this,Tl),i,e,-r,a);break;case 270:o=Fv._rescaleAndSwap(Vd(this,Dl),i,s,-r,-a),l=Fv._rescaleAndSwap(Vd(this,Tl),i,s,-r,-a)}return{outline:Array.from(o),points:[Array.from(l)]}}get box(){return Vd(this,Ml)}newOutliner(t,e,i,s,n,r=0){return new Wv(t,e,i,s,n,r)}getNewOutline(t,e){const[i,s,n,r]=Vd(this,Ml),[a,o,l,h]=Vd(this,Sl),c=n*l,d=r*h,u=i*l+a,p=s*h+o,g=this.newOutliner({x:Vd(this,Tl)[0]*c+u,y:Vd(this,Tl)[1]*d+p},Vd(this,Sl),Vd(this,Pl),t,Vd(this,Cl),e??Vd(this,El));for(let f=2;f<Vd(this,Tl).length;f+=2)g.add({x:Vd(this,Tl)[f]*c+u,y:Vd(this,Tl)[f+1]*d+p});return g.getOutlines()}}Sl=new WeakMap,Ml=new WeakMap,El=new WeakMap,Cl=new WeakMap,Tl=new WeakMap,Pl=new WeakMap,Dl=new WeakMap,Rl=new WeakSet,Il=function(t){const e=Vd(this,Dl);let i=e[4],s=e[5];const n=[i,s,i,s];let r=i,a=s,o=i,l=s;const h=t?Math.max:Math.min,c=new Float32Array(4);for(let u=6,p=e.length;u<p;u+=6){const t=e[u+4],d=e[u+5];isNaN(e[u])?(np.pointBoundingBox(t,d,n),a>d?(r=t,a=d):a===d&&(r=h(r,t)),l<d?(o=t,l=d):l===d&&(o=h(o,t))):(c[0]=c[1]=1/0,c[2]=c[3]=-1/0,np.bezierBoundingBox(i,s,...e.slice(u,u+6),c),np.rectBoundingBox(c[0],c[1],c[2],c[3],n),a>c[1]?(r=c[0],a=c[1]):a===c[1]&&(r=h(r,c[0])),l<c[3]?(o=c[2],l=c[3]):l===c[3]&&(o=h(o,c[2]))),i=t,s=d}const d=Vd(this,Ml);d[0]=n[0]-Vd(this,El),d[1]=n[1]-Vd(this,El),d[2]=n[2]-n[0]+2*Vd(this,El),d[3]=n[3]-n[1]+2*Vd(this,El),this.firstPoint=[r,a],this.lastPoint=[o,l]};class Ov{constructor(t,e=0,i=0,s=!0){Gd(this,Ol),Gd(this,Ll),Gd(this,Fl),Gd(this,Nl),Gd(this,Wl,[]),Gd(this,Bl,[]);const n=[1/0,1/0,-1/0,-1/0],r=10**-4;for(const{x:g,y:f,width:m,height:v}of t){const t=Math.floor((g-e)/r)*r,i=Math.ceil((g+m+e)/r)*r,s=Math.floor((f-e)/r)*r,a=Math.ceil((f+v+e)/r)*r,o=[t,s,a,!0],l=[i,s,a,!1];Vd(this,Wl).push(o,l),np.rectBoundingBox(t,s,i,a,n)}const a=n[2]-n[0]+2*i,o=n[3]-n[1]+2*i,l=n[0]-i,h=n[1]-i;let c=s?-1/0:1/0,d=1/0;const u=Vd(this,Wl).at(s?-1:-2),p=[u[0],u[2]];for(const g of Vd(this,Wl)){const[t,e,i,n]=g;!n&&s?e<d?(d=e,c=t):e===d&&(c=Math.max(c,t)):n&&!s&&(e<d?(d=e,c=t):e===d&&(c=Math.min(c,t))),g[0]=(t-l)/a,g[1]=(e-h)/o,g[2]=(i-h)/o}qd(this,Ll,new Float32Array([l,h,a,o])),qd(this,Fl,[c,d]),qd(this,Nl,p)}getOutlines(){Vd(this,Wl).sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);const t=[];for(const e of Vd(this,Wl))e[3]?(t.push(...Xd(this,Ol,zl).call(this,e)),Xd(this,Ol,$l).call(this,e)):(Xd(this,Ol,jl).call(this,e),t.push(...Xd(this,Ol,zl).call(this,e)));return Xd(this,Ol,Ul).call(this,t)}}Ll=new WeakMap,Fl=new WeakMap,Nl=new WeakMap,Wl=new WeakMap,Bl=new WeakMap,Ol=new WeakSet,Ul=function(t){const e=[],i=new Set;for(const r of t){const[t,i,s]=r;e.push([t,i,r],[t,s,r])}e.sort((t,e)=>t[1]-e[1]||t[0]-e[0]);for(let r=0,a=e.length;r<a;r+=2){const t=e[r][2],s=e[r+1][2];t.push(s),s.push(t),i.add(t),i.add(s)}const s=[];let n;for(;i.size>0;){const t=i.values().next().value;let[e,r,a,o,l]=t;i.delete(t);let h=e,c=r;for(n=[e,a],s.push(n);;){let t;if(i.has(o))t=o;else{if(!i.has(l))break;t=l}i.delete(t),[e,r,a,o,l]=t,h!==e&&(n.push(h,c,e,c===r?r:a),h=e),c=c===r?a:r}n.push(h,c)}return new Uv(s,Vd(this,Ll),Vd(this,Fl),Vd(this,Nl))},Hl=function(t){const e=Vd(this,Bl);let i=0,s=e.length-1;for(;i<=s;){const n=i+s>>1,r=e[n][0];if(r===t)return n;r<t?i=n+1:s=n-1}return s+1},$l=function([,t,e]){const i=Xd(this,Ol,Hl).call(this,t);Vd(this,Bl).splice(i,0,[t,e])},jl=function([,t,e]){const i=Xd(this,Ol,Hl).call(this,t);for(let s=i;s<Vd(this,Bl).length;s++){const[i,n]=Vd(this,Bl)[s];if(i!==t)break;if(i===t&&n===e)return void Vd(this,Bl).splice(s,1)}for(let s=i-1;s>=0;s--){const[i,n]=Vd(this,Bl)[s];if(i!==t)break;if(i===t&&n===e)return void Vd(this,Bl).splice(s,1)}},zl=function(t){const[e,i,s]=t,n=[[e,i,s]],r=Xd(this,Ol,Hl).call(this,s);for(let a=0;a<r;a++){const[t,i]=Vd(this,Bl)[a];for(let s=0,r=n.length;s<r;s++){const[,a,o]=n[s];if(!(i<=a||o<=t))if(a>=t)if(o>i)n[s][1]=i;else{if(1===r)return[];n.splice(s,1),s--,r--}else n[s][2]=t,o>i&&n.push([e,i,o])}}return n};class Uv extends Fv{constructor(t,e,i,s){super(),Gd(this,Vl),Gd(this,Gl),qd(this,Gl,t),qd(this,Vl,e),this.firstPoint=i,this.lastPoint=s}toSVGPath(){const t=[];for(const e of Vd(this,Gl)){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n<e.length;n+=2){const r=e[n],a=e[n+1];r===i?(t.push(`V${a}`),s=a):a===s&&(t.push(`H${r}`),i=r)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],n){const r=[],a=i-t,o=s-e;for(const l of Vd(this,Gl)){const e=new Array(l.length);for(let i=0;i<l.length;i+=2)e[i]=t+l[i]*a,e[i+1]=s-l[i+1]*o;r.push(e)}return r}get box(){return Vd(this,Vl)}get classNamesForOutlining(){return["highlightOutline"]}}Vl=new WeakMap,Gl=new WeakMap;class Hv extends Wv{newFreeDrawOutline(t,e,i,s,n,r){return new $v(t,e,i,s,n,r)}}class $v extends Bv{newOutliner(t,e,i,s,n,r=0){return new Hv(t,e,i,s,n,r)}}const jv=class t extends dg{constructor(e){super({...e,name:"highlightEditor"}),Gd(this,dh),Gd(this,ql,null),Gd(this,Xl,0),Gd(this,Yl),Gd(this,Kl,null),Gd(this,Ql,null),Gd(this,Jl,null),Gd(this,Zl,null),Gd(this,th,0),Gd(this,eh,null),Gd(this,ih,null),Gd(this,sh,null),Gd(this,nh,!1),Gd(this,rh,null),Gd(this,ah,null),Gd(this,oh,null),Gd(this,lh,""),Gd(this,hh),Gd(this,ch,""),this.color=e.color||t._defaultColor,qd(this,hh,e.thickness||t._defaultThickness),this.opacity=e.opacity||t._defaultOpacity,qd(this,Yl,e.boxes||null),qd(this,ch,e.methodOfCreation||""),qd(this,lh,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",e.highlightId>-1?(qd(this,nh,!0),Xd(this,dh,ph).call(this,e),Xd(this,dh,wh).call(this)):Vd(this,Yl)&&(qd(this,ql,e.anchorNode),qd(this,Xl,e.anchorOffset),qd(this,Zl,e.focusNode),qd(this,th,e.focusOffset),Xd(this,dh,uh).call(this),Xd(this,dh,wh).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const e=t.prototype;return Gu(this,"_keyboardManager",new tg([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:Vd(this,nh)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:Vd(this,hh),methodOfCreation:Vd(this,ch)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(e,i){var s;dg.initialize(e,i),t._defaultColor||(t._defaultColor=(null==(s=i.highlightColors)?void 0:s.values().next().value)||"#fff066")}static updateDefaultParams(e,i){switch(e){case mu.HIGHLIGHT_COLOR:t._defaultColor=i;break;case mu.HIGHLIGHT_THICKNESS:t._defaultThickness=i}}translateInPage(t,e){}get toolbarPosition(){return Vd(this,ah)}get commentButtonPosition(){return Vd(this,rh)}updateParams(t,e){switch(t){case mu.HIGHLIGHT_COLOR:Xd(this,dh,gh).call(this,e);break;case mu.HIGHLIGHT_THICKNESS:Xd(this,dh,fh).call(this,e)}}static get defaultPropertiesToUpdate(){return[[mu.HIGHLIGHT_COLOR,t._defaultColor],[mu.HIGHLIGHT_THICKNESS,t._defaultThickness]]}get propertiesToUpdate(){return[[mu.HIGHLIGHT_COLOR,this.color||t._defaultColor],[mu.HIGHLIGHT_THICKNESS,Vd(this,hh)||t._defaultThickness],[mu.HIGHLIGHT_FREE,Vd(this,nh)]]}onUpdatedColor(){var t,e;null==(t=this.parent)||t.drawLayer.updateProperties(Vd(this,sh),{root:{fill:this.color,"fill-opacity":this.opacity}}),null==(e=Vd(this,Ql))||e.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){if(this._uiManager.highlightColors){return[["colorPicker",qd(this,Ql,new qm({editor:this}))]]}return super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(Xd(this,dh,xh).call(this))}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,Xd(this,dh,xh).call(this))}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){Xd(this,dh,vh).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(Xd(this,dh,wh).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e;let i=!1;this.parent&&!t?Xd(this,dh,vh).call(this):t&&(Xd(this,dh,wh).call(this,t),i=!this.parent&&(null==(e=this.div)?void 0:e.classList.contains("selectedEditor"))),super.setParent(t),this.show(this._isVisible),i&&this.select()}rotate(e){var i,s,n;const{drawLayer:r}=this.parent;let a;Vd(this,nh)?(e=(e-this.rotation+360)%360,a=Xd(i=t,bh,yh).call(i,Vd(this,ih).box,e)):a=Xd(s=t,bh,yh).call(s,[this.x,this.y,this.width,this.height],e),r.updateProperties(Vd(this,sh),{bbox:a,root:{"data-main-rotation":e}}),r.updateProperties(Vd(this,oh),{bbox:Xd(n=t,bh,yh).call(n,Vd(this,Jl).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const t=super.render();Vd(this,lh)&&(t.setAttribute("aria-label",Vd(this,lh)),t.setAttribute("role","mark")),Vd(this,nh)?t.classList.add("free"):this.div.addEventListener("keydown",Xd(this,dh,Ah).bind(this),{signal:this._uiManager._signal});const e=qd(this,eh,document.createElement("div"));return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=Vd(this,Kl),this.setDims(this.width,this.height),Yp(this,Vd(this,eh),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){var t;this.isSelected||null==(t=this.parent)||t.drawLayer.updateProperties(Vd(this,oh),{rootClass:{hovered:!0}})}pointerleave(){var t;this.isSelected||null==(t=this.parent)||t.drawLayer.updateProperties(Vd(this,oh),{rootClass:{hovered:!1}})}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:Xd(this,dh,_h).call(this,!0);break;case 1:case 3:Xd(this,dh,_h).call(this,!1)}}select(){var t;super.select(),Vd(this,oh)&&(null==(t=this.parent)||t.drawLayer.updateProperties(Vd(this,oh),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var t;super.unselect(),Vd(this,oh)&&(null==(t=this.parent)||t.drawLayer.updateProperties(Vd(this,oh),{rootClass:{selected:!1}}),Vd(this,nh)||Xd(this,dh,_h).call(this,!1))}get _mustFixPosition(){return!Vd(this,nh)}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(Vd(this,sh),{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(Vd(this,oh),{rootClass:{hidden:!t}}))}static startHighlighting(t,e,{target:i,x:s,y:n}){const{x:r,y:a,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,c=t.combinedSignal(h),d=e=>{h.abort(),Xd(this,bh,Eh).call(this,t,e)};window.addEventListener("blur",d,{signal:c}),window.addEventListener("pointerup",d,{signal:c}),window.addEventListener("pointerdown",Ep,{capture:!0,passive:!1,signal:c}),window.addEventListener("contextmenu",Mp,{signal:c}),i.addEventListener("pointermove",Xd(this,bh,Mh).bind(this,t),{signal:c}),this._freeHighlight=new Hv({x:s,y:n},[r,a,o,l],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static async deserialize(t,e,i){var s,n,r,a;let o=null;if(t instanceof Sv){const{data:{quadPoints:e,rect:i,rotation:s,id:n,color:r,opacity:a,popupRef:l,richText:h,contentsObj:c,creationDate:d,modificationDate:u},parent:{page:{pageNumber:p}}}=t;o=t={annotationType:fu.HIGHLIGHT,color:Array.from(r),opacity:a,quadPoints:e,boxes:null,pageIndex:p-1,rect:i.slice(0),rotation:s,annotationElementId:n,id:n,deleted:!1,popupRef:l,richText:h,comment:(null==c?void 0:c.str)||null,creationDate:d,modificationDate:u}}else if(t instanceof kv){const{data:{inkLists:e,rect:i,rotation:s,id:n,color:r,borderStyle:{rawWidth:a},popupRef:l,richText:h,contentsObj:c,creationDate:d,modificationDate:u},parent:{page:{pageNumber:p}}}=t;o=t={annotationType:fu.HIGHLIGHT,color:Array.from(r),thickness:a,inkLists:e,boxes:null,pageIndex:p-1,rect:i.slice(0),rotation:s,annotationElementId:n,id:n,deleted:!1,popupRef:l,richText:h,comment:(null==c?void 0:c.str)||null,creationDate:d,modificationDate:u}}const{color:l,quadPoints:h,inkLists:c,opacity:d}=t,u=await super.deserialize(t,e,i);u.color=np.makeHexColor(...l),u.opacity=d||1,c&&qd(u,hh,t.thickness),u._initialData=o,t.comment&&u.setCommentData(t);const[p,g]=u.pageDimensions,[f,m]=u.pageTranslation;if(h){const t=qd(u,Yl,[]);for(let e=0;e<h.length;e+=8)t.push({x:(h[e]-f)/p,y:1-(h[e+1]-m)/g,width:(h[e+2]-h[e])/p,height:(h[e+1]-h[e+5])/g});Xd(s=u,dh,uh).call(s),Xd(n=u,dh,wh).call(n),u.rotate(u.rotation)}else if(c){qd(u,nh,!0);const t=c[0],i={x:t[0]-f,y:g-(t[1]-m)},s=new Hv(i,[0,0,p,g],1,Vd(u,hh)/2,!0,.001);for(let e=0,r=t.length;e<r;e+=2)i.x=t[e]-f,i.y=g-(t[e+1]-m),s.add(i);const{id:n,clipPathId:o}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:u.color,"fill-opacity":u._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:s.toSVGPath()}},!0,!0);Xd(r=u,dh,ph).call(r,{highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:o}),Xd(a=u,dh,wh).call(a),u.rotate(u.parentRotation)}return u}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=dg._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i=super.serialize(t);return Object.assign(i,{color:e,opacity:this.opacity,thickness:Vd(this,hh),quadPoints:Xd(this,dh,kh).call(this),outlines:Xd(this,dh,Sh).call(this,i.rect)}),this.addComment(i),this.annotationElementId&&!Xd(this,dh,Ch).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}};ql=new WeakMap,Xl=new WeakMap,Yl=new WeakMap,Kl=new WeakMap,Ql=new WeakMap,Jl=new WeakMap,Zl=new WeakMap,th=new WeakMap,eh=new WeakMap,ih=new WeakMap,sh=new WeakMap,nh=new WeakMap,rh=new WeakMap,ah=new WeakMap,oh=new WeakMap,lh=new WeakMap,hh=new WeakMap,ch=new WeakMap,dh=new WeakSet,uh=function(){const t=new Ov(Vd(this,Yl),.001);qd(this,ih,t.getOutlines()),[this.x,this.y,this.width,this.height]=Vd(this,ih).box;const e=new Ov(Vd(this,Yl),.0025,.001,"ltr"===this._uiManager.direction);qd(this,Jl,e.getOutlines());const{firstPoint:i}=Vd(this,ih);qd(this,rh,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]);const{lastPoint:s}=Vd(this,Jl);qd(this,ah,[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height])},ph=function({highlightOutlines:t,highlightId:e,clipPathId:i}){var s,n;qd(this,ih,t);if(qd(this,Jl,t.getNewOutline(Vd(this,hh)/2+1.5,.0025)),e>=0)qd(this,sh,e),qd(this,Kl,i),this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),qd(this,oh,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:Vd(this,Jl).box,path:{d:Vd(this,Jl).toSVGPath()}},!0));else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(Vd(this,sh),{bbox:Xd(s=jv,bh,yh).call(s,Vd(this,ih).box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(Vd(this,oh),{bbox:Xd(n=jv,bh,yh).call(n,Vd(this,Jl).box,e),path:{d:Vd(this,Jl).toSVGPath()}})}const[r,a,o,l]=t.box;switch(this.rotation){case 0:this.x=r,this.y=a,this.width=o,this.height=l;break;case 90:{const[t,e]=this.parentDimensions;this.x=a,this.y=1-r,this.width=o*e/t,this.height=l*t/e;break}case 180:this.x=1-r,this.y=1-a,this.width=o,this.height=l;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-a,this.y=r,this.width=o*e/t,this.height=l*t/e;break}}const{firstPoint:h}=t;qd(this,rh,[(h[0]-r)/o,(h[1]-a)/l]);const{lastPoint:c}=Vd(this,Jl);qd(this,ah,[(c[0]-r)/o,(c[1]-a)/l])},gh=function(t){const e=(t,e)=>{this.color=t,this.opacity=e,this.onUpdatedColor()},i=this.color,s=this.opacity;this.addCommands({cmd:e.bind(this,t,jv._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:mu.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)},fh=function(t){const e=Vd(this,hh),i=t=>{qd(this,hh,t),Xd(this,dh,mh).call(this,t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:mu.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)},mh=function(t){Vd(this,nh)&&(Xd(this,dh,ph).call(this,{highlightOutlines:Vd(this,ih).getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims(this.width,this.height))},vh=function(){null!==Vd(this,sh)&&this.parent&&(this.parent.drawLayer.remove(Vd(this,sh)),qd(this,sh,null),this.parent.drawLayer.remove(Vd(this,oh)),qd(this,oh,null))},wh=function(t=this.parent){null===Vd(this,sh)&&(({id:Yd(this,sh)._,clipPathId:Yd(this,Kl)._}=t.drawLayer.draw({bbox:Vd(this,ih).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:Vd(this,nh)},path:{d:Vd(this,ih).toSVGPath()}},!1,!0)),qd(this,oh,t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:Vd(this,nh)},bbox:Vd(this,Jl).box,path:{d:Vd(this,Jl).toSVGPath()}},Vd(this,nh))),Vd(this,eh)&&(Vd(this,eh).style.clipPath=Vd(this,Kl)))},bh=new WeakSet,yh=function([t,e,i,s],n){switch(n){case 90:return[1-e-s,t,s,i];case 180:return[1-t-i,1-e-s,i,s];case 270:return[e,1-t-i,s,i]}return[t,e,i,s]},Ah=function(t){jv._keyboardManager.exec(this,t)},_h=function(t){if(!Vd(this,ql))return;const e=window.getSelection();t?e.setPosition(Vd(this,ql),Vd(this,Xl)):e.setPosition(Vd(this,Zl),Vd(this,th))},xh=function(){return Vd(this,nh)?this.rotation:0},kh=function(){if(Vd(this,nh))return null;const[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=Vd(this,Yl),r=new Float32Array(8*n.length);let a=0;for(const{x:o,y:l,width:h,height:c}of n){const n=o*t+i,d=(1-l)*e+s;r[a]=r[a+4]=n,r[a+1]=r[a+3]=d,r[a+2]=r[a+6]=n+h*t,r[a+5]=r[a+7]=d-c*e,a+=8}return r},Sh=function(t){return Vd(this,ih).serialize(t,Xd(this,dh,xh).call(this))},Mh=function(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},Eh=function(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},Ch=function(t){const{color:e}=this._initialData;return this.hasEditedComment||t.color.some((t,i)=>t!==e[i])},Gd(jv,bh),jd(jv,"_defaultColor",null),jd(jv,"_defaultOpacity",1),jd(jv,"_defaultThickness",12),jd(jv,"_type","highlight"),jd(jv,"_editorType",fu.HIGHLIGHT),jd(jv,"_freeHighlightId",-1),jd(jv,"_freeHighlight",null),jd(jv,"_freeHighlightClipId","");let zv=jv;class Vv{constructor(){Gd(this,Th,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,i]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,i)}updateSVGProperty(t,e){Vd(this,Th)[t]=e}toSVGProperties(){const t=Vd(this,Th);return qd(this,Th,Object.create(null)),{root:t}}reset(){qd(this,Th,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){$u("Not implemented")}}Th=new WeakMap;const Gv=class t extends dg{constructor(t){super(t),Gd(this,Oh),Gd(this,Ph,null),Gd(this,Dh),jd(this,"_colorPicker",null),jd(this,"_drawId",null),qd(this,Dh,t.mustBeCommitted||!1),this._addOutlines(t)}onUpdatedColor(){var t;null==(t=this._colorPicker)||t.update(this.color),super.onUpdatedColor()}_addOutlines(t){t.drawOutlines&&(Xd(this,Oh,Uh).call(this,t),Xd(this,Oh,jh).call(this))}static _mergeSVGProperties(t,e){const i=new Set(Object.keys(t));for(const[s,n]of Object.entries(e))i.has(s)?Object.assign(t[s],n):t[s]=n;return t}static getDefaultDrawingOptions(t){$u("Not implemented")}static get typesMap(){$u("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,i){const s=this.typesMap.get(e);s&&this._defaultDrawingOptions.updateProperty(s,i),this._currentParent&&(Vd(t,Rh).updateProperty(s,i),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){const s=this._drawingOptions,n=s[e],r=i=>{var n;s.updateProperty(e,i);const r=Vd(this,Ph).updateProperty(e,i);r&&Xd(this,Oh,Gh).call(this,r),null==(n=this.parent)||n.drawLayer.updateProperties(this._drawId,s.toSVGProperties()),t===this.colorType&&this.onUpdatedColor()};this.addCommands({cmd:r.bind(this,i),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;null==(e=this.parent)||e.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties(Vd(this,Ph).getPathResizingSVGProperties(Xd(this,Oh,Vh).call(this)),{bbox:Xd(this,Oh,qh).call(this)}))}_onResized(){var e;null==(e=this.parent)||e.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties(Vd(this,Ph).getPathResizedSVGProperties(Xd(this,Oh,Vh).call(this)),{bbox:Xd(this,Oh,qh).call(this)}))}_onTranslating(t,e){var i;null==(i=this.parent)||i.drawLayer.updateProperties(this._drawId,{bbox:Xd(this,Oh,qh).call(this)})}_onTranslated(){var e;null==(e=this.parent)||e.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties(Vd(this,Ph).getPathTranslatedSVGProperties(Xd(this,Oh,Vh).call(this),this.parentDimensions),{bbox:Xd(this,Oh,qh).call(this)}))}_onStartDragging(){var t;null==(t=this.parent)||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var t;null==(t=this.parent)||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,Vd(this,Dh)&&(qd(this,Dh,!1),this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){Xd(this,Oh,$h).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(Xd(this,Oh,jh).call(this),Xd(this,Oh,Gh).call(this,Vd(this,Ph).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e;let i=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),Xd(this,Oh,$h).call(this)):t&&(this._uiManager.addShouldRescale(this),Xd(this,Oh,jh).call(this,t),i=!this.parent&&(null==(e=this.div)?void 0:e.classList.contains("selectedEditor"))),super.setParent(t),i&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties({bbox:Xd(this,Oh,qh).call(this)},Vd(this,Ph).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&Xd(this,Oh,Gh).call(this,Vd(this,Ph).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const i=super.render();i.classList.add("draw");const s=document.createElement("div");return i.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),i}static createDrawerInstance(t,e,i,s,n){$u("Not implemented")}static startDrawing(e,i,s,n){var r;const{target:a,offsetX:o,offsetY:l,pointerId:h,pointerType:c}=n;if(Vd(t,Nh)&&Vd(t,Nh)!==c)return;const{viewport:{rotation:d}}=e,{width:u,height:p}=a.getBoundingClientRect(),g=qd(t,Ih,new AbortController),f=e.combinedSignal(g);Vd(t,Fh)||qd(t,Fh,h),Vd(t,Nh)??qd(t,Nh,c),window.addEventListener("pointerup",e=>{var i;Vd(t,Fh)===e.pointerId?this._endDraw(e):null==(i=Vd(t,Wh))||i.delete(e.pointerId)},{signal:f}),window.addEventListener("pointercancel",e=>{var i;Vd(t,Fh)===e.pointerId?this._currentParent.endDrawingSession():null==(i=Vd(t,Wh))||i.delete(e.pointerId)},{signal:f}),window.addEventListener("pointerdown",e=>{Vd(t,Nh)===e.pointerType&&((Vd(t,Wh)||qd(t,Wh,new Set)).add(e.pointerId),Vd(t,Rh).isCancellable()&&(Vd(t,Rh).removeLastElement(),Vd(t,Rh).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",Mp,{signal:f}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:f}),a.addEventListener("touchmove",e=>{e.timeStamp===Vd(t,Bh)&&Ep(e)},{signal:f}),e.toggleDrawing(),null==(r=i._editorUndoBar)||r.hide(),Vd(t,Rh)?e.drawLayer.updateProperties(this._currentDrawId,Vd(t,Rh).startNew(o,l,u,p,d)):(i.updateUIForDefaultProperties(this),qd(t,Rh,this.createDrawerInstance(o,l,u,p,d)),qd(t,Lh,this.getDefaultDrawingOptions()),this._currentParent=e,({id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(Vd(t,Lh).toSVGProperties(),Vd(t,Rh).defaultSVGProperties),!0,!1)))}static _drawMove(e){var i;if(qd(t,Bh,-1),!Vd(t,Rh))return;const{offsetX:s,offsetY:n,pointerId:r}=e;Vd(t,Fh)===r&&((null==(i=Vd(t,Wh))?void 0:i.size)>=1?this._endDraw(e):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,Vd(t,Rh).add(s,n)),qd(t,Bh,e.timeStamp),Ep(e)))}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,qd(t,Rh,null),qd(t,Lh,null),qd(t,Nh,null),qd(t,Bh,NaN)),Vd(t,Ih)&&(Vd(t,Ih).abort(),qd(t,Ih,null),qd(t,Fh,NaN),qd(t,Wh,null))}static _endDraw(e){const i=this._currentParent;if(i){if(i.toggleDrawing(!0),this._cleanup(!1),(null==e?void 0:e.target)===i.div&&i.drawLayer.updateProperties(this._currentDrawId,Vd(t,Rh).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const e=Vd(t,Rh),s=this._currentDrawId,n=e.getLastElement();return void i.addCommands({cmd:()=>{i.drawLayer.updateProperties(s,e.setLastElement(n))},undo:()=>{i.drawLayer.updateProperties(s,e.removeLastElement())},mustExec:!1,type:mu.DRAW_STEP})}this.endDrawing(!1)}}static endDrawing(e){const i=this._currentParent;if(!i)return null;if(i.toggleDrawing(!0),i.cleanUndoStack(mu.DRAW_STEP),!Vd(t,Rh).isEmpty()){const{pageDimensions:[s,n],scale:r}=i,a=i.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:Vd(t,Rh).getOutlines(s*r,n*r,r,this._INNER_MARGIN),drawingOptions:Vd(t,Lh),mustBeCommitted:!e});return this._cleanup(!0),a}return i.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,n,r){$u("Not implemented")}static async deserialize(t,e,i){var s,n;const{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}=e.viewport,h=this.deserializeDraw(o,l,r,a,this._INNER_MARGIN,t),c=await super.deserialize(t,e,i);return c.createDrawingOptions(t),Xd(s=c,Oh,Uh).call(s,{drawOutlines:h}),Xd(n=c,Oh,jh).call(n),c.onScaleChanging(),c.rotate(),c}serializeDraw(t){const[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return Vd(this,Ph).serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};Ph=new WeakMap,Dh=new WeakMap,Rh=new WeakMap,Ih=new WeakMap,Lh=new WeakMap,Fh=new WeakMap,Nh=new WeakMap,Wh=new WeakMap,Bh=new WeakMap,Oh=new WeakSet,Uh=function({drawOutlines:t,drawId:e,drawingOptions:i}){qd(this,Ph,t),this._drawingOptions||(this._drawingOptions=i),this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=Xd(this,Oh,Hh).call(this,t,this.parent),Xd(this,Oh,Gh).call(this,t.box)},Hh=function(t,e){const{id:i}=e.drawLayer.draw(Gv._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i},$h=function(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},jh=function(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=Xd(this,Oh,Hh).call(this,Vd(this,Ph),t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))},zh=function([t,e,i,s]){const{parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[e,1-t,i*(r/n),s*(n/r)];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,i*(r/n),s*(n/r)];default:return[t,e,i,s]}},Vh=function(){const{x:t,y:e,width:i,height:s,parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[1-e,t,i*(n/r),s*(r/n)];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,i*(n/r),s*(r/n)];default:return[t,e,i,s]}},Gh=function(t){[this.x,this.y,this.width,this.height]=Xd(this,Oh,zh).call(this,t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},qh=function(){const{x:t,y:e,width:i,height:s,rotation:n,parentRotation:r,parentDimensions:[a,o]}=this;switch((4*n+r)/90){case 1:return[1-e-s,t,s,i];case 2:return[1-t-i,1-e-s,i,s];case 3:return[e,1-t-i,s,i];case 4:return[t,e-i*(a/o),s*(o/a),i*(a/o)];case 5:return[1-e,t,i*(a/o),s*(o/a)];case 6:return[1-t-s*(o/a),1-e,s*(o/a),i*(a/o)];case 7:return[e-i*(a/o),1-t-s*(o/a),i*(a/o),s*(o/a)];case 8:return[t-i,e-s,i,s];case 9:return[1-e,t-i,s,i];case 10:return[1-t,1-e,i,s];case 11:return[e-s,1-t,s,i];case 12:return[t-s*(o/a),e,s*(o/a),i*(a/o)];case 13:return[1-e-i*(a/o),t-s*(o/a),i*(a/o),s*(o/a)];case 14:return[1-t,1-e-i*(a/o),s*(o/a),i*(a/o)];case 15:return[e,1-t,i*(a/o),s*(o/a)];default:return[t,e,i,s]}},jd(Gv,"_currentDrawId",-1),jd(Gv,"_currentParent",null),Gd(Gv,Rh,null),Gd(Gv,Ih,null),Gd(Gv,Lh,null),Gd(Gv,Fh,NaN),Gd(Gv,Nh,null),Gd(Gv,Wh,null),Gd(Gv,Bh,NaN),jd(Gv,"_INNER_MARGIN",3);let qv=Gv;class Xv{constructor(t,e,i,s,n,r){Gd(this,rc),Gd(this,Xh,new Float64Array(6)),Gd(this,Yh),Gd(this,Kh),Gd(this,Qh),Gd(this,Jh),Gd(this,Zh),Gd(this,tc,""),Gd(this,ec,0),Gd(this,ic,new Yv),Gd(this,sc),Gd(this,nc),qd(this,sc,i),qd(this,nc,s),qd(this,Qh,n),qd(this,Jh,r),[t,e]=Xd(this,rc,ac).call(this,t,e);const a=qd(this,Yh,[NaN,NaN,NaN,NaN,t,e]);qd(this,Zh,[t,e]),qd(this,Kh,[{line:a,points:Vd(this,Zh)}]),Vd(this,Xh).set(a,0)}updateProperty(t,e){"stroke-width"===t&&qd(this,Jh,e)}isEmpty(){return!Vd(this,Kh)||0===Vd(this,Kh).length}isCancellable(){return Vd(this,Zh).length<=10}add(t,e){[t,e]=Xd(this,rc,ac).call(this,t,e);const[i,s,n,r]=Vd(this,Xh).subarray(2,6),a=t-n,o=e-r;return Math.hypot(Vd(this,sc)*a,Vd(this,nc)*o)<=2?null:(Vd(this,Zh).push(t,e),isNaN(i)?(Vd(this,Xh).set([n,r,t,e],2),Vd(this,Yh).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(Vd(this,Xh)[0])&&Vd(this,Yh).splice(6,6),Vd(this,Xh).set([i,s,n,r,t,e],0),Vd(this,Yh).push(...Fv.createBezierPoints(i,s,n,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const i=this.add(t,e);return i||(2===Vd(this,Zh).length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,n){qd(this,sc,i),qd(this,nc,s),qd(this,Qh,n),[t,e]=Xd(this,rc,ac).call(this,t,e);const r=qd(this,Yh,[NaN,NaN,NaN,NaN,t,e]);qd(this,Zh,[t,e]);const a=Vd(this,Kh).at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),Vd(this,Kh).push({line:r,points:Vd(this,Zh)}),Vd(this,Xh).set(r,0),qd(this,ec,0),this.toSVGPath(),null}getLastElement(){return Vd(this,Kh).at(-1)}setLastElement(t){return Vd(this,Kh)?(Vd(this,Kh).push(t),qd(this,Yh,t.line),qd(this,Zh,t.points),qd(this,ec,0),{path:{d:this.toSVGPath()}}):Vd(this,ic).setLastElement(t)}removeLastElement(){if(!Vd(this,Kh))return Vd(this,ic).removeLastElement();Vd(this,Kh).pop(),qd(this,tc,"");for(let t=0,e=Vd(this,Kh).length;t<e;t++){const{line:e,points:i}=Vd(this,Kh)[t];qd(this,Yh,e),qd(this,Zh,i),qd(this,ec,0),this.toSVGPath()}return{path:{d:Vd(this,tc)}}}toSVGPath(){const t=Fv.svgRound(Vd(this,Yh)[4]),e=Fv.svgRound(Vd(this,Yh)[5]);if(2===Vd(this,Zh).length)return qd(this,tc,`${Vd(this,tc)} M ${t} ${e} Z`),Vd(this,tc);if(Vd(this,Zh).length<=6){const i=Vd(this,tc).lastIndexOf("M");qd(this,tc,`${Vd(this,tc).slice(0,i)} M ${t} ${e}`),qd(this,ec,6)}if(4===Vd(this,Zh).length){const t=Fv.svgRound(Vd(this,Yh)[10]),e=Fv.svgRound(Vd(this,Yh)[11]);return qd(this,tc,`${Vd(this,tc)} L ${t} ${e}`),qd(this,ec,12),Vd(this,tc)}const i=[];0===Vd(this,ec)&&(i.push(`M ${t} ${e}`),qd(this,ec,6));for(let s=Vd(this,ec),n=Vd(this,Yh).length;s<n;s+=6){const[t,e,n,r,a,o]=Vd(this,Yh).slice(s,s+6).map(Fv.svgRound);i.push(`C${t} ${e} ${n} ${r} ${a} ${o}`)}return qd(this,tc,Vd(this,tc)+i.join(" ")),qd(this,ec,Vd(this,Yh).length),Vd(this,tc)}getOutlines(t,e,i,s){const n=Vd(this,Kh).at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),Vd(this,ic).build(Vd(this,Kh),t,e,i,Vd(this,Qh),Vd(this,Jh),s),qd(this,Xh,null),qd(this,Yh,null),qd(this,Kh,null),qd(this,tc,null),Vd(this,ic)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Xh=new WeakMap,Yh=new WeakMap,Kh=new WeakMap,Qh=new WeakMap,Jh=new WeakMap,Zh=new WeakMap,tc=new WeakMap,ec=new WeakMap,ic=new WeakMap,sc=new WeakMap,nc=new WeakMap,rc=new WeakSet,ac=function(t,e){return Fv._normalizePoint(t,e,Vd(this,sc),Vd(this,nc),Vd(this,Qh))};class Yv extends Fv{constructor(){super(...arguments),Gd(this,mc),Gd(this,oc),Gd(this,lc,0),Gd(this,hc),Gd(this,cc),Gd(this,dc),Gd(this,uc),Gd(this,pc),Gd(this,gc),Gd(this,fc)}build(t,e,i,s,n,r,a){qd(this,dc,e),qd(this,uc,i),qd(this,pc,s),qd(this,gc,n),qd(this,fc,r),qd(this,hc,a??0),qd(this,cc,t),Xd(this,mc,bc).call(this)}get thickness(){return Vd(this,fc)}setLastElement(t){return Vd(this,cc).push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return Vd(this,cc).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of Vd(this,cc))if(t.push(`M${Fv.svgRound(e[4])} ${Fv.svgRound(e[5])}`),6!==e.length)if(12===e.length&&isNaN(e[6]))t.push(`L${Fv.svgRound(e[10])} ${Fv.svgRound(e[11])}`);else for(let i=6,s=e.length;i<s;i+=6){const[s,n,r,a,o,l]=e.subarray(i,i+6).map(Fv.svgRound);t.push(`C${s} ${n} ${r} ${a} ${o} ${l}`)}else t.push("Z");return t.join("")}serialize([t,e,i,s],n){const r=[],a=[],[o,l,h,c]=Xd(this,mc,wc).call(this);let d,u,p,g,f,m,v,w,b;switch(Vd(this,gc)){case 0:b=Fv._rescale,d=t,u=e+s,p=i,g=-s,f=t+o*i,m=e+(1-l-c)*s,v=t+(o+h)*i,w=e+(1-l)*s;break;case 90:b=Fv._rescaleAndSwap,d=t,u=e,p=i,g=s,f=t+l*i,m=e+o*s,v=t+(l+c)*i,w=e+(o+h)*s;break;case 180:b=Fv._rescale,d=t+i,u=e,p=-i,g=s,f=t+(1-o-h)*i,m=e+l*s,v=t+(1-o)*i,w=e+(l+c)*s;break;case 270:b=Fv._rescaleAndSwap,d=t+i,u=e+s,p=-i,g=-s,f=t+(1-l-c)*i,m=e+(1-o-h)*s,v=t+(1-l)*i,w=e+(1-o)*s}for(const{line:y,points:A}of Vd(this,cc))r.push(b(y,d,u,p,g,n?new Array(y.length):null)),a.push(b(A,d,u,p,g,n?new Array(A.length):null));return{lines:r,points:a,rect:[f,m,v,w]}}static deserialize(t,e,i,s,n,{paths:{lines:r,points:a},rotation:o,thickness:l}){const h=[];let c,d,u,p,g;switch(o){case 0:g=Fv._rescale,c=-t/i,d=e/s+1,u=1/i,p=-1/s;break;case 90:g=Fv._rescaleAndSwap,c=-e/s,d=-t/i,u=1/s,p=1/i;break;case 180:g=Fv._rescale,c=t/i+1,d=-e/s,u=-1/i,p=1/s;break;case 270:g=Fv._rescaleAndSwap,c=e/s+1,d=t/i+1,u=-1/s,p=-1/i}if(!r){r=[];for(const t of a){const e=t.length;if(2===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}const i=new Float32Array(3*(e-2));r.push(i);let[s,n,a,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,n],0);for(let r=4;r<e;r+=2){const e=t[r],l=t[r+1];i.set(Fv.createBezierPoints(s,n,a,o,e,l),3*(r-2)),[s,n,a,o]=[a,o,e,l]}}}for(let m=0,v=r.length;m<v;m++)h.push({line:g(r[m].map(t=>t??NaN),c,d,u,p),points:g(a[m].map(t=>t??NaN),c,d,u,p)});const f=new this.prototype.constructor;return f.build(h,i,s,1,o,l,n),f}get box(){return Vd(this,oc)}updateProperty(t,e){return"stroke-width"===t?Xd(this,mc,yc).call(this,e):null}updateParentDimensions([t,e],i){const[s,n]=Xd(this,mc,vc).call(this);qd(this,dc,t),qd(this,uc,e),qd(this,pc,i);const[r,a]=Xd(this,mc,vc).call(this),o=r-s,l=a-n,h=Vd(this,oc);return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return qd(this,lc,t),{path:{transform:this.rotationTransform}}}get viewBox(){return Vd(this,oc).map(Fv.svgRound).join(" ")}get defaultProperties(){const[t,e]=Vd(this,oc);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Fv.svgRound(t)} ${Fv.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=Vd(this,oc);let i=0,s=0,n=0,r=0,a=0,o=0;switch(Vd(this,lc)){case 90:s=e/t,n=-t/e,a=t;break;case 180:i=-1,r=-1,a=t,o=e;break;case 270:s=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${n} ${r} ${Fv.svgRound(a)} ${Fv.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){const[n,r]=Xd(this,mc,vc).call(this),[a,o,l,h]=Vd(this,oc);if(Math.abs(l-n)<=Fv.PRECISION||Math.abs(h-r)<=Fv.PRECISION){const n=t+i/2-(a+l/2),r=e+s/2-(o+h/2);return{path:{"transform-origin":`${Fv.svgRound(t)} ${Fv.svgRound(e)}`,transform:`${this.rotationTransform} translate(${n} ${r})`}}}const c=(i-2*n)/(l-2*n),d=(s-2*r)/(h-2*r),u=l/i,p=h/s;return{path:{"transform-origin":`${Fv.svgRound(a)} ${Fv.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${p}) translate(${Fv.svgRound(n)} ${Fv.svgRound(r)}) scale(${c} ${d}) translate(${Fv.svgRound(-n)} ${Fv.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,i,s]){const[n,r]=Xd(this,mc,vc).call(this),a=Vd(this,oc),[o,l,h,c]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=s,Math.abs(h-n)<=Fv.PRECISION||Math.abs(c-r)<=Fv.PRECISION){const n=t+i/2-(o+h/2),r=e+s/2-(l+c/2);for(const{line:t,points:e}of Vd(this,cc))Fv._translate(t,n,r,t),Fv._translate(e,n,r,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Fv.svgRound(t)} ${Fv.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const d=(i-2*n)/(h-2*n),u=(s-2*r)/(c-2*r),p=-d*(o+n)+t+n,g=-u*(l+r)+e+r;if(1!==d||1!==u||0!==p||0!==g)for(const{line:f,points:m}of Vd(this,cc))Fv._rescale(f,p,g,d,u,f),Fv._rescale(m,p,g,d,u,m);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Fv.svgRound(t)} ${Fv.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[s,n]=i,r=Vd(this,oc),a=t-r[0],o=e-r[1];if(Vd(this,dc)===s&&Vd(this,uc)===n)for(const{line:l,points:h}of Vd(this,cc))Fv._translate(l,a,o,l),Fv._translate(h,a,o,h);else{const t=Vd(this,dc)/s,e=Vd(this,uc)/n;qd(this,dc,s),qd(this,uc,n);for(const{line:i,points:s}of Vd(this,cc))Fv._rescale(i,a,o,t,e,i),Fv._rescale(s,a,o,t,e,s);r[2]*=t,r[3]*=e}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Fv.svgRound(t)} ${Fv.svgRound(e)}`}}}get defaultSVGProperties(){const t=Vd(this,oc);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Fv.svgRound(t[0])} ${Fv.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}oc=new WeakMap,lc=new WeakMap,hc=new WeakMap,cc=new WeakMap,dc=new WeakMap,uc=new WeakMap,pc=new WeakMap,gc=new WeakMap,fc=new WeakMap,mc=new WeakSet,vc=function(t=Vd(this,fc)){const e=Vd(this,hc)+t/2*Vd(this,pc);return Vd(this,gc)%180==0?[e/Vd(this,dc),e/Vd(this,uc)]:[e/Vd(this,uc),e/Vd(this,dc)]},wc=function(){const[t,e,i,s]=Vd(this,oc),[n,r]=Xd(this,mc,vc).call(this,0);return[t+n,e+r,i-2*n,s-2*r]},bc=function(){const t=qd(this,oc,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:s}of Vd(this,cc)){if(s.length<=12){for(let e=4,i=s.length;e<i;e+=6)np.pointBoundingBox(s[e],s[e+1],t);continue}let e=s[4],i=s[5];for(let n=6,r=s.length;n<r;n+=6){const[r,a,o,l,h,c]=s.subarray(n,n+6);np.bezierBoundingBox(e,i,r,a,o,l,h,c,t),e=h,i=c}}const[e,i]=Xd(this,mc,vc).call(this);t[0]=cp(t[0]-e,0,1),t[1]=cp(t[1]-i,0,1),t[2]=cp(t[2]+e,0,1),t[3]=cp(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]},yc=function(t){const[e,i]=Xd(this,mc,vc).call(this);qd(this,fc,t);const[s,n]=Xd(this,mc,vc).call(this),[r,a]=[s-e,n-i],o=Vd(this,oc);return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o};class Kv extends Vv{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:dg._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??(e=this["stroke-width"]),e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new Kv(this._viewParameters);return t.updateAll(this),t}}const Qv=class t extends qv{constructor(t){super({...t,name:"inkEditor"}),Gd(this,Ac),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){dg.initialize(t,e),this._defaultDrawingOptions=new Kv(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Gu(this,"typesMap",new Map([[mu.INK_THICKNESS,"stroke-width"],[mu.INK_COLOR,"stroke"],[mu.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,n){return new Xv(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,r){return Yv.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){let s=null;if(t instanceof kv){const{data:{inkLists:e,rect:i,rotation:n,id:r,color:a,opacity:o,borderStyle:{rawWidth:l},popupRef:h,richText:c,contentsObj:d,creationDate:u,modificationDate:p},parent:{page:{pageNumber:g}}}=t;s=t={annotationType:fu.INK,color:Array.from(a),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:g-1,rect:i.slice(0),rotation:n,annotationElementId:r,id:r,deleted:!1,popupRef:h,richText:c,comment:(null==d?void 0:d.str)||null,creationDate:u,modificationDate:p}}const n=await super.deserialize(t,e,i);return n._initialData=s,t.comment&&n.setCommentData(t),n}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Ym(this)),[["colorPicker",this._colorPicker]]}get colorType(){return mu.INK_COLOR}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:i,opacity:s}){this._drawingOptions=t.getDefaultDrawingOptions({stroke:np.makeHexColor(...e),"stroke-width":i,"stroke-opacity":s})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{stroke:s,"stroke-opacity":n,"stroke-width":r}}=this,a=Object.assign(super.serialize(t),{color:dg._colorManager.convert(s),opacity:n,thickness:r,paths:{lines:e,points:i}});return this.addComment(a),t?(a.isCopy=!0,a):this.annotationElementId&&!Xd(this,Ac,_c).call(this,a)?null:(a.id=this.annotationElementId,a)}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;const{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}};Ac=new WeakSet,_c=function(t){const{color:e,thickness:i,opacity:s,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((t,i)=>t!==e[i])||t.thickness!==i||t.opacity!==s||t.pageIndex!==n},jd(Qv,"_type","ink"),jd(Qv,"_editorType",fu.INK),jd(Qv,"_defaultDrawingOptions",null);let Jv=Qv;class Zv extends Yv{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}class tw{static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:s},n,r,a,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1});const c=h.font=`${i} ${s} 200px ${e}`,{actualBoundingBoxLeft:d,actualBoundingBoxRight:u,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:f,fontBoundingBoxDescent:m,width:v}=h.measureText(t),w=1.5,b=Math.ceil(Math.max(Math.abs(d)+Math.abs(u)||0,v)*w),y=Math.ceil(Math.max(Math.abs(p)+Math.abs(g)||200,Math.abs(f)+Math.abs(m)||200)*w);l=new OffscreenCanvas(b,y),h=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=c,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,b,y),h.fillStyle="black",h.fillText(t,.5*b/2,1.5*y/2);const A=Xd(this,kc,Lc).call(this,h.getImageData(0,0,b,y).data),_=Xd(this,kc,Ic).call(this,A),x=Xd(this,kc,Fc).call(this,_),k=Xd(this,kc,Tc).call(this,A,b,y,x);return this.processDrawnLines({lines:{curves:k,width:b,height:y},pageWidth:n,pageHeight:r,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,i,s,n){const[r,a,o]=Xd(this,kc,Nc).call(this,t),[l,h]=Xd(this,kc,Rc).call(this,r,a,o,Math.hypot(a,o)*Vd(this,xc).sigmaSFactor,Vd(this,xc).sigmaR,Vd(this,xc).kernelSize),c=Xd(this,kc,Fc).call(this,h),d=Xd(this,kc,Tc).call(this,l,a,o,c);return this.processDrawnLines({lines:{curves:d,width:a,height:o},pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:r,areContours:a}){s%180!=0&&([e,i]=[i,e]);const{curves:o,width:l,height:h}=t,c=t.thickness??0,d=[],u=Math.min(e/l,i/h),p=u/e,g=u/i,f=[];for(const{points:v}of o){const t=r?Xd(this,kc,Dc).call(this,v):v;if(!t)continue;f.push(t);const e=t.length,i=new Float32Array(e),s=new Float32Array(3*(2===e?2:e-2));if(d.push({line:s,points:i}),2===e){i[0]=t[0]*p,i[1]=t[1]*g,s.set([NaN,NaN,NaN,NaN,i[0],i[1]],0);continue}let[n,a,o,l]=t;n*=p,a*=g,o*=p,l*=g,i.set([n,a,o,l],0),s.set([NaN,NaN,NaN,NaN,n,a],0);for(let r=4;r<e;r+=2){const e=i[r]=t[r]*p,h=i[r+1]=t[r+1]*g;s.set(Fv.createBezierPoints(n,a,o,l,e,h),3*(r-2)),[n,a,o,l]=[o,l,e,h]}}if(0===d.length)return null;const m=a?new Zv:new Yv;return m.build(d,e,i,1,s,a?0:c,n),{outline:m,newCurves:f,areContours:a,thickness:c,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:s,height:n}){let r,a=1/0,o=-1/0,l=0;for(const v of t){l+=v.length;for(let t=2,e=v.length;t<e;t++){const e=v[t]-v[t-2];a=Math.min(a,e),o=Math.max(o,e)}}r=a>=-128&&o<=127?Int8Array:a>=-32768&&o<=32767?Int16Array:Int32Array;const h=t.length,c=8+3*h,d=new Uint32Array(c);let u=0;d[u++]=c*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*r.BYTES_PER_ELEMENT,d[u++]=0,d[u++]=s,d[u++]=n,d[u++]=e?0:1,d[u++]=Math.max(0,Math.floor(i??0)),d[u++]=h,d[u++]=r.BYTES_PER_ELEMENT;for(const v of t)d[u++]=v.length-2,d[u++]=v[0],d[u++]=v[1];const p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(d);const f=r.prototype.constructor;for(const v of t){const t=new f(v.length-2);for(let e=2,i=v.length;e<i;e++)t[e-2]=v[e]-v[e-2];g.write(t)}g.close();const m=await new Response(p.readable).arrayBuffer();return dp(new Uint8Array(m))}static async decompressSignature(t){try{const i=(e=t,Uint8Array.fromBase64?Uint8Array.fromBase64(e):ep(atob(e))),{readable:s,writable:n}=new DecompressionStream("deflate-raw"),r=n.getWriter();await r.ready,r.write(i).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let a=null,o=0;for await(const t of s)a||(a=new Uint8Array(new Uint32Array(t.buffer,0,4)[0])),a.set(t,o),o+=t.length;const l=new Uint32Array(a.buffer,0,a.length>>2),h=l[1];if(0!==h)throw new Error(`Invalid version: ${h}`);const c=l[2],d=l[3],u=0===l[4],p=l[5],g=l[6],f=l[7],m=[],v=(8+3*g)*Uint32Array.BYTES_PER_ELEMENT;let w;switch(f){case Int8Array.BYTES_PER_ELEMENT:w=new Int8Array(a.buffer,v);break;case Int16Array.BYTES_PER_ELEMENT:w=new Int16Array(a.buffer,v);break;case Int32Array.BYTES_PER_ELEMENT:w=new Int32Array(a.buffer,v)}o=0;for(let t=0;t<g;t++){const e=l[3*t+8],i=new Float32Array(e+2);m.push(i);for(let s=0;s<2;s++)i[s]=l[3*t+8+s+1];for(let t=0;t<e;t++)i[t+2]=i[t]+w[o++]}return{areContours:u,thickness:p,outlines:m,width:c,height:d}}catch(i){return Hu(`decompressSignature: ${i}`),null}var e}}xc=new WeakMap,kc=new WeakSet,Sc=function(t,e,i,s){return s-=e,0===(i-=t)?s>0?0:4:1===i?s+6:2-s},Mc=new WeakMap,Ec=function(t,e,i,s,n,r,a){const o=Xd(this,kc,Sc).call(this,i,s,n,r);for(let l=0;l<8;l++){const n=(-l+o-a+16)%8;if(0!==t[(i+Vd(this,Mc)[2*n])*e+(s+Vd(this,Mc)[2*n+1])])return n}return-1},Cc=function(t,e,i,s,n,r,a){const o=Xd(this,kc,Sc).call(this,i,s,n,r);for(let l=0;l<8;l++){const n=(l+o+a+16)%8;if(0!==t[(i+Vd(this,Mc)[2*n])*e+(s+Vd(this,Mc)[2*n+1])])return n}return-1},Tc=function(t,e,i,s){const n=t.length,r=new Int32Array(n);for(let h=0;h<n;h++)r[h]=t[h]<=s?1:0;for(let h=1;h<i-1;h++)r[h*e]=r[h*e+e-1]=0;for(let h=0;h<e;h++)r[h]=r[e*i-1-h]=0;let a,o=1;const l=[];for(let h=1;h<i-1;h++){a=1;for(let t=1;t<e-1;t++){const i=h*e+t,s=r[i];if(0===s)continue;let n=h,c=t;if(1===s&&0===r[i-1])o+=1,c-=1;else{if(!(s>=1&&0===r[i+1])){1!==s&&(a=Math.abs(s));continue}o+=1,c+=1,s>1&&(a=s)}const d=[t,h],u=c===t+1,p={isHole:u,points:d,id:o,parent:0};let g;l.push(p);for(const t of l)if(t.id===a){g=t;break}g?g.isHole?p.parent=u?g.parent:a:p.parent=u?a:g.parent:p.parent=u?a:0;const f=Xd(this,kc,Ec).call(this,r,e,h,t,n,c,0);if(-1===f){r[i]=-o,1!==r[i]&&(a=Math.abs(r[i]));continue}let m=Vd(this,Mc)[2*f],v=Vd(this,Mc)[2*f+1];const w=h+m,b=t+v;n=w,c=b;let y=h,A=t;for(;;){const s=Xd(this,kc,Cc).call(this,r,e,y,A,n,c,1);m=Vd(this,Mc)[2*s],v=Vd(this,Mc)[2*s+1];const l=y+m,u=A+v;d.push(u,l);const p=y*e+A;if(0===r[p+1]?r[p]=-o:1===r[p]&&(r[p]=o),l===h&&u===t&&y===w&&A===b){1!==r[i]&&(a=Math.abs(r[i]));break}n=y,c=A,y=l,A=u}}}return l},Pc=function(t,e,i,s){if(i-e<=4){for(let n=e;n<i-2;n+=2)s.push(t[n],t[n+1]);return}const n=t[e],r=t[e+1],a=t[i-4]-n,o=t[i-3]-r,l=Math.hypot(a,o),h=a/l,c=o/l,d=h*r-c*n,u=o/a,p=1/l,g=Math.atan(u),f=Math.cos(g),m=Math.sin(g),v=p*(Math.abs(f)+Math.abs(m)),w=p*(1-v+v**2),b=Math.max(Math.atan(Math.abs(m+f)*w),Math.atan(Math.abs(m-f)*w));let y=0,A=e;for(let _=e+2;_<i-2;_+=2){const e=Math.abs(d-h*t[_+1]+c*t[_]);e>y&&(A=_,y=e)}y>(l*b)**2?(Xd(this,kc,Pc).call(this,t,e,A+2,s),Xd(this,kc,Pc).call(this,t,A,i,s)):s.push(n,r)},Dc=function(t){const e=[],i=t.length;return Xd(this,kc,Pc).call(this,t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e},Rc=function(t,e,i,s,n,r){const a=new Float32Array(r**2),o=-2*s**2,l=r>>1;for(let g=0;g<r;g++){const t=(g-l)**2;for(let e=0;e<r;e++)a[g*r+e]=Math.exp((t+(e-l)**2)/o)}const h=new Float32Array(256),c=-2*n**2;for(let g=0;g<256;g++)h[g]=Math.exp(g**2/c);const d=t.length,u=new Uint8Array(d),p=new Uint32Array(256);for(let g=0;g<i;g++)for(let s=0;s<e;s++){const n=g*e+s,o=t[n];let c=0,d=0;for(let u=0;u<r;u++){const n=g+u-l;if(!(n<0||n>=i))for(let i=0;i<r;i++){const p=s+i-l;if(p<0||p>=e)continue;const g=t[n*e+p],f=a[u*r+i]*h[Math.abs(g-o)];c+=g*f,d+=f}}p[u[n]=Math.round(c/d)]++}return[u,p]},Ic=function(t){const e=new Uint32Array(256);for(const i of t)e[i]++;return e},Lc=function(t){const e=t.length,i=new Uint8ClampedArray(e>>2);let s=-1/0,n=1/0;for(let a=0,o=i.length;a<o;a++){const e=i[a]=t[a<<2];s=Math.max(s,e),n=Math.min(n,e)}const r=255/(s-n);for(let a=0,o=i.length;a<o;a++)i[a]=(i[a]-n)*r;return i},Fc=function(t){let e,i=-1/0,s=-1/0;const n=t.findIndex(t=>0!==t);let r=n,a=n;for(e=n;e<256;e++){const n=t[e];n>i&&(e-r>s&&(s=e-r,a=e-1),i=n,r=e)}for(e=a-1;e>=0&&!(t[e]>t[e+1]);e--);return e},Nc=function(t){const e=t,{width:i,height:s}=t,{maxDim:n}=Vd(this,xc);let r=i,a=s;if(i>n||s>n){let o=i,l=s,h=Math.log2(Math.max(i,s)/n);const c=Math.floor(h);h=h===c?c-1:c;for(let i=0;i<h;i++){r=Math.ceil(o/2),a=Math.ceil(l/2);const i=new OffscreenCanvas(r,a);i.getContext("2d").drawImage(t,0,0,o,l,0,0,r,a),o=r,l=a,t!==e&&t.close(),t=i.transferToImageBitmap()}const d=Math.min(n/r,n/a);r=Math.round(r*d),a=Math.round(a*d)}const o=new OffscreenCanvas(r,a).getContext("2d",{willReadFrequently:!0});o.fillStyle="white",o.fillRect(0,0,r,a),o.filter="grayscale(1)",o.drawImage(t,0,0,t.width,t.height,0,0,r,a);const l=o.getImageData(0,0,r,a).data;return[Xd(this,kc,Lc).call(this,l),r,a]},Gd(tw,kc),Gd(tw,xc,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),Gd(tw,Mc,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class ew extends Vv{constructor(){super(),super.updateProperties({fill:dg._defaultLineColor,"stroke-width":0})}clone(){const t=new ew;return t.updateAll(this),t}}class iw extends Kv{constructor(t){super(t),super.updateProperties({stroke:dg._defaultLineColor,"stroke-width":1})}clone(){const t=new iw(this._viewParameters);return t.updateAll(this),t}}const sw=class t extends qv{constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),Gd(this,Wc,!1),Gd(this,Bc,null),Gd(this,Oc,null),Gd(this,Uc,null),this._willKeepAspectRatio=!0,qd(this,Oc,t.signatureData||null),qd(this,Bc,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){dg.initialize(t,e),this._defaultDrawingOptions=new ew,this._defaultDrawnSignatureOptions=new iw(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return Gu(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!Vd(this,Bc)}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,i;const{_isCopy:s}=this;if(s&&(this._isCopy=!1,e=this.x,i=this.y),super.render(),null===this._drawId)if(Vd(this,Oc)){const{lines:e,mustSmooth:i,areContours:s,description:n,uuid:r,heightInPage:a}=Vd(this,Oc),{rawDims:{pageWidth:o,pageHeight:l},rotation:h}=this.parent.viewport,c=tw.processDrawnLines({lines:e,pageWidth:o,pageHeight:l,rotation:h,innerMargin:t._INNER_MARGIN,mustSmooth:i,areContours:s});this.addSignature(c,a,n,r)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:Vd(this,Bc)||""}));return s&&(this._isCopy=!0,this._moveAfterPaste(e,i)),this.div}setUuid(t){qd(this,Uc,t),this.addEditToolbar()}getUuid(){return Vd(this,Uc)}get description(){return Vd(this,Bc)}set description(t){qd(this,Bc,t),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{null==e||e.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:i,width:s,height:n}=Vd(this,Oc),r=Math.max(s,n);return{areContours:e,outline:tw.processDrawnLines({lines:{curves:t.map(t=>({points:t})),thickness:i,width:s,height:n},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,i,s,n){const{x:r,y:a}=this,{outline:o}=qd(this,Oc,e);let l;qd(this,Wc,o instanceof Zv),this.description=s,Vd(this,Wc)?l=t.getDefaultDrawingOptions():(l=t._defaultDrawnSignatureOptions.clone(),l.updateProperties({"stroke-width":o.thickness})),this._addOutlines({drawOutlines:o,drawingOptions:l});const[,h]=this.pageDimensions;let c=i/h;c=c>=1?.5:c,this.width*=c/this.height,this.width>=1&&(c*=.9/this.width,this.width=.9),this.height=c,this.setDims(),this.x=r,this.y=a,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(n),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!n,hasDescription:!!s}}),this.div.hidden=!1}getFromImage(e){const{rawDims:{pageWidth:i,pageHeight:s},rotation:n}=this.parent.viewport;return tw.process(e,i,s,n,t._INNER_MARGIN)}getFromText(e,i){const{rawDims:{pageWidth:s,pageHeight:n},rotation:r}=this.parent.viewport;return tw.extractContoursFromText(e,i,s,n,r,t._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:i,pageHeight:s},rotation:n}=this.parent.viewport;return tw.processDrawnLines({lines:e,pageWidth:i,pageHeight:s,rotation:n,innerMargin:t._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:i}){e?this._drawingOptions=t.getDefaultDrawingOptions():(this._drawingOptions=t._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":i}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":s}}=this,n=Object.assign(super.serialize(t),{isSignature:!0,areContours:Vd(this,Wc),color:[0,0,0],thickness:Vd(this,Wc)?0:s});return this.addComment(n),t?(n.paths={lines:e,points:i},n.uuid=Vd(this,Uc),n.isCopy=!0):n.lines=e,Vd(this,Bc)&&(n.accessibilityData={type:"Figure",alt:Vd(this,Bc)}),n}static deserializeDraw(t,e,i,s,n,r){return r.areContours?Zv.deserialize(t,e,i,s,n,r):Yv.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){var s;const n=await super.deserialize(t,e,i);return qd(n,Wc,t.areContours),n.description=(null==(s=t.accessibilityData)?void 0:s.alt)||"",qd(n,Uc,t.uuid),n}};Wc=new WeakMap,Bc=new WeakMap,Oc=new WeakMap,Uc=new WeakMap,jd(sw,"_type","signature"),jd(sw,"_editorType",fu.SIGNATURE),jd(sw,"_defaultDrawingOptions",null);let nw=sw;class rw extends dg{constructor(t){super({...t,name:"stampEditor"}),Gd(this,Jc),Gd(this,Hc,null),Gd(this,$c,null),Gd(this,jc,null),Gd(this,zc,null),Gd(this,Vc,null),Gd(this,Gc,""),Gd(this,qc,null),Gd(this,Xc,!1),Gd(this,Yc,null),Gd(this,Kc,!1),Gd(this,Qc,!1),qd(this,zc,t.bitmapUrl),qd(this,Vc,t.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){dg.initialize(t,e)}static isHandlingMimeForPasting(t){return Fp.includes(t)}static paste(t,e){e.pasteEditor({mode:fu.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var t;return{type:"stamp",hasAltText:!!(null==(t=this.altTextData)?void 0:t.altText)}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!(await i.isEnabledFor("altText")))throw new Error("ML isn't enabled for alt text.");const{data:s,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:s,width:n,height:r,channels:s.length/(n*r)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");const o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}remove(){var t;Vd(this,$c)&&(qd(this,Hc,null),this._uiManager.imageManager.deleteId(Vd(this,$c)),null==(t=Vd(this,qc))||t.remove(),qd(this,qc,null),Vd(this,Yc)&&(clearTimeout(Vd(this,Yc)),qd(this,Yc,null))),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(Vd(this,$c)&&null===Vd(this,qc)&&Xd(this,Jc,ed).call(this),this.isAttachedToDOM||this.parent.add(this))):Vd(this,$c)&&Xd(this,Jc,ed).call(this)}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(Vd(this,jc)||Vd(this,Hc)||Vd(this,zc)||Vd(this,Vc)||Vd(this,$c)||Vd(this,Xc))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),Vd(this,Xc)||(Vd(this,Hc)?Xd(this,Jc,id).call(this):Xd(this,Jc,ed).call(this)),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:i,bitmap:s}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(qd(this,$c,i),s&&qd(this,Hc,s),qd(this,Xc,!1),Xd(this,Jc,id).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==Vd(this,Yc)&&clearTimeout(Vd(this,Yc));qd(this,Yc,setTimeout(()=>{qd(this,Yc,null),Xd(this,Jc,nd).call(this)},200))}copyCanvas(t,e,i=!1){t||(t=224);const{width:s,height:n}=Vd(this,Hc),r=new Lp;let a=Vd(this,Hc),o=s,l=n,h=null;if(e){if(s>e||n>e){const t=Math.min(e/s,e/n);o=Math.floor(s*t),l=Math.floor(n*t)}h=document.createElement("canvas");const t=h.width=Math.ceil(o*r.sx),i=h.height=Math.ceil(l*r.sy);Vd(this,Kc)||(a=Xd(this,Jc,sd).call(this,t,i));const c=h.getContext("2d");c.filter=this._uiManager.hcmFilter;let d="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":Np.isDarkMode&&(d="#8f8f9d",u="#42414d");const p=15,g=p*r.sx,f=p*r.sy,m=new OffscreenCanvas(2*g,2*f),v=m.getContext("2d");v.fillStyle=d,v.fillRect(0,0,2*g,2*f),v.fillStyle=u,v.fillRect(0,0,g,f),v.fillRect(g,f,g,f),c.fillStyle=c.createPattern(m,"repeat"),c.fillRect(0,0,t,i),c.drawImage(a,0,0,a.width,a.height,0,0,t,i)}let c=null;if(i){let e,i;if(r.symmetric&&a.width<t&&a.height<t)e=a.width,i=a.height;else if(a=Vd(this,Hc),s>t||n>t){const r=Math.min(t/s,t/n);e=Math.floor(s*r),i=Math.floor(n*r),Vd(this,Kc)||(a=Xd(this,Jc,sd).call(this,e,i))}const o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(a,0,0,a.width,a.height,0,0,e,i),c={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:c}}static async deserialize(t,e,i){var s;let n=null,r=!1;if(t instanceof Tv){const{data:{rect:a,rotation:o,id:l,structParent:h,popupRef:c,richText:d,contentsObj:u,creationDate:p,modificationDate:g},container:f,parent:{page:{pageNumber:m}},canvas:v}=t;let w,b;v?(delete t.canvas,({id:w,bitmap:b}=i.imageManager.getFromCanvas(f.id,v)),v.remove()):(r=!0,t._hasNoCanvas=!0);const y=(null==(s=await e._structTree.getAriaAttributes(`${hp}${l}`))?void 0:s.get("aria-label"))||"";n=t={annotationType:fu.STAMP,bitmapId:w,bitmap:b,pageIndex:m-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,accessibilityData:{decorative:!1,altText:y},isSvg:!1,structParent:h,popupRef:c,richText:d,comment:(null==u?void 0:u.str)||null,creationDate:p,modificationDate:g}}const a=await super.deserialize(t,e,i),{rect:o,bitmap:l,bitmapUrl:h,bitmapId:c,isSvg:d,accessibilityData:u}=t;r?(i.addMissingCanvas(t.id,a),qd(a,Xc,!0)):c&&i.imageManager.isValidId(c)?(qd(a,$c,c),l&&qd(a,Hc,l)):qd(a,zc,h),qd(a,Kc,d);const[p,g]=a.pageDimensions;return a.width=(o[2]-o[0])/p,a.height=(o[3]-o[1])/g,u&&(a.altTextData=u),a._initialData=n,t.comment&&a.setCommentData(t),qd(a,Qc,!!n),a}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i=Object.assign(super.serialize(t),{bitmapId:Vd(this,$c),isSvg:Vd(this,Kc)});if(this.addComment(i),t)return i.bitmapUrl=Xd(this,Jc,rd).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(i.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const t=Xd(this,Jc,ad).call(this,i);return t.isSame?null:(t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(null===e)return i;e.stamps||(e.stamps=new Map);const r=Vd(this,Kc)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(Vd(this,$c))){if(Vd(this,Kc)){const t=e.stamps.get(Vd(this,$c));r>t.area&&(t.area=r,t.serialized.bitmap.close(),t.serialized.bitmap=Xd(this,Jc,rd).call(this,!1))}}else e.stamps.set(Vd(this,$c),{area:r,serialized:i}),i.bitmap=Xd(this,Jc,rd).call(this,!1);return i}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}Hc=new WeakMap,$c=new WeakMap,jc=new WeakMap,zc=new WeakMap,Vc=new WeakMap,Gc=new WeakMap,qc=new WeakMap,Xc=new WeakMap,Yc=new WeakMap,Kc=new WeakMap,Qc=new WeakMap,Jc=new WeakSet,Zc=function(t,e=!1){t?(qd(this,Hc,t.bitmap),e||(qd(this,$c,t.id),qd(this,Kc,t.isSvg)),t.file&&qd(this,Gc,t.file.name),Xd(this,Jc,id).call(this)):this.remove()},td=function(){if(qd(this,jc,null),this._uiManager.enableWaiting(!1),Vd(this,qc))if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&Vd(this,Hc))this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&Vd(this,Hc)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},ed=function(){if(Vd(this,$c))return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(Vd(this,$c)).then(t=>Xd(this,Jc,Zc).call(this,t,!0)).finally(()=>Xd(this,Jc,td).call(this));if(Vd(this,zc)){const t=Vd(this,zc);return qd(this,zc,null),this._uiManager.enableWaiting(!0),void qd(this,jc,this._uiManager.imageManager.getFromUrl(t).then(t=>Xd(this,Jc,Zc).call(this,t)).finally(()=>Xd(this,Jc,td).call(this)))}if(Vd(this,Vc)){const t=Vd(this,Vc);return qd(this,Vc,null),this._uiManager.enableWaiting(!0),void qd(this,jc,this._uiManager.imageManager.getFromFile(t).then(t=>Xd(this,Jc,Zc).call(this,t)).finally(()=>Xd(this,Jc,td).call(this)))}const t=document.createElement("input");t.type="file",t.accept=Fp.join(",");const e=this._uiManager._signal;qd(this,jc,new Promise(i=>{t.addEventListener("change",async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),Xd(this,Jc,Zc).call(this,e)}else this.remove();i()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:e})}).finally(()=>Xd(this,Jc,td).call(this))),t.click()},id=function(){var t;const{div:e}=this;let{width:i,height:s}=Vd(this,Hc);const[n,r]=this.pageDimensions,a=.75;if(this.width)i=this.width*n,s=this.height*r;else if(i>a*n||s>a*r){const t=Math.min(a*n/i,a*r/s);i*=t,s*=t}this._uiManager.enableWaiting(!1);const o=qd(this,qc,document.createElement("canvas"));o.setAttribute("role","img"),this.addContainer(o),this.width=i/n,this.height=s/r,this.setDims(),(null==(t=this._initialOptions)?void 0:t.isCentered)?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1),Xd(this,Jc,nd).call(this),Vd(this,Qc)||(this.parent.addUndoableEditor(this),qd(this,Qc,!0)),this._reportTelemetry({action:"inserted_image"}),Vd(this,Gc)&&this.div.setAttribute("aria-description",Vd(this,Gc)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},sd=function(t,e){const{width:i,height:s}=Vd(this,Hc);let n=i,r=s,a=Vd(this,Hc);for(;n>2*t||r>2*e;){const i=n,s=r;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));const o=new OffscreenCanvas(n,r);o.getContext("2d").drawImage(a,0,0,i,s,0,0,n,r),a=o.transferToImageBitmap()}return a},nd=function(){const[t,e]=this.parentDimensions,{width:i,height:s}=this,n=new Lp,r=Math.ceil(i*t*n.sx),a=Math.ceil(s*e*n.sy),o=Vd(this,qc);if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;const l=Vd(this,Kc)?Vd(this,Hc):Xd(this,Jc,sd).call(this,r,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,r,a)},rd=function(t){if(t){if(Vd(this,Kc)){const t=this._uiManager.imageManager.getSvgUrl(Vd(this,$c));if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=Vd(this,Hc));return t.getContext("2d").drawImage(Vd(this,Hc),0,0),t.toDataURL()}if(Vd(this,Kc)){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*mp.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*mp.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(Vd(this,Hc),0,0,Vd(this,Hc).width,Vd(this,Hc).height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(Vd(this,Hc))},ad=function(t){var e;const{pageIndex:i,accessibilityData:{altText:s}}=this._initialData,n=t.pageIndex===i,r=((null==(e=t.accessibilityData)?void 0:e.alt)||"")===s;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&n&&r,isSameAltText:r}},jd(rw,"_type","stamp"),jd(rw,"_editorType",fu.STAMP);const aw=class t{constructor({uiManager:e,pageIndex:i,div:s,structTreeLayer:n,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:c}){Gd(this,kd),Gd(this,od),Gd(this,ld,!1),Gd(this,hd,null),Gd(this,cd,null),Gd(this,dd,null),Gd(this,ud,new Map),Gd(this,pd,!1),Gd(this,gd,!1),Gd(this,fd,!1),Gd(this,md,null),Gd(this,vd,null),Gd(this,wd,null),Gd(this,bd,null),Gd(this,yd,null),Gd(this,Ad,-1),Gd(this,_d);const d=[...Vd(t,xd).values()];if(!t._initialized){t._initialized=!0;for(const t of d)t.initialize(c,e)}e.registerEditorTypes(d),qd(this,_d,e),this.pageIndex=i,this.div=s,qd(this,od,r),qd(this,hd,a),this.viewport=h,qd(this,wd,l),this.drawLayer=o,this._structTree=n,Vd(this,_d).addLayer(this)}get isEmpty(){return 0===Vd(this,ud).size}get isInvisible(){return this.isEmpty&&Vd(this,_d).getMode()===fu.NONE}updateToolbar(t){Vd(this,_d).updateToolbar(t)}updateMode(e=Vd(this,_d).getMode()){switch(Xd(this,kd,Pd).call(this),e){case fu.NONE:return this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case fu.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case fu.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:i}=this.div;if(i.toggle("nonEditing",!1),e===fu.POPUP)i.toggle("commentEditing",!0);else{i.toggle("commentEditing",!1);for(const s of Vd(t,xd).values())i.toggle(`${s._type}Editing`,e===s._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===(null==(e=Vd(this,wd))?void 0:e.div)}setEditingState(t){Vd(this,_d).setEditingState(t)}addCommands(t){Vd(this,_d).addCommands(t)}cleanUndoStack(t){Vd(this,_d).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;null==(e=Vd(this,hd))||e.div.classList.toggle("disabled",!t)}async enable(){var t;qd(this,fd,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),null==(t=Vd(this,yd))||t.abort(),qd(this,yd,null);const e=new Set;for(const s of Vd(this,kd,Sd))s.enableEditing(),s.show(!0),s.annotationElementId&&(Vd(this,_d).removeChangedExistingAnnotation(s),e.add(s.annotationElementId));const i=Vd(this,hd);if(i)for(const s of i.getEditableAnnotations()){if(s.hide(),Vd(this,_d).isDeletedAnnotationElement(s.data.id))continue;if(e.has(s.data.id))continue;const t=await this.deserialize(s);t&&(this.addOrRebuild(t),t.enableEditing())}qd(this,fd,!1),Vd(this,_d)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var e;if(qd(this,gd,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),Vd(this,wd)&&!Vd(this,yd)){qd(this,yd,new AbortController);const t=Vd(this,_d).combinedSignal(Vd(this,yd));Vd(this,wd).div.addEventListener("pointerdown",t=>{const{clientX:e,clientY:i,timeStamp:s}=t;if(s-Vd(this,Ad)>500)return void qd(this,Ad,s);qd(this,Ad,-1);const{classList:n}=this.div;n.toggle("getElements",!0);const r=document.elementsFromPoint(e,i);if(n.toggle("getElements",!1),!this.div.contains(r[0]))return;let a;const o=new RegExp(`^${gu}[0-9]+$`);for(const h of r)if(o.test(h.id)){a=h.id;break}if(!a)return;const l=Vd(this,ud).get(a);null===(null==l?void 0:l.annotationElementId)&&(t.stopPropagation(),t.preventDefault(),l.dblclick(t))},{signal:t,capture:!0})}const i=Vd(this,hd);if(i){const t=new Map,s=new Map;for(const r of Vd(this,kd,Sd))r.disableEditing(),r.annotationElementId?null===r.serialize()?(s.set(r.annotationElementId,r),null==(e=this.getEditableAnnotation(r.annotationElementId))||e.show(),r.remove()):t.set(r.annotationElementId,r):r.updateFakeAnnotationElement(i);const n=i.getEditableAnnotations();for(const e of n){const{id:i}=e.data;if(Vd(this,_d).isDeletedAnnotationElement(i)){e.updateEdited({deleted:!0});continue}let n=s.get(i);n?(n.resetAnnotationElement(e),n.show(!1),e.show()):(n=t.get(i),n&&(Vd(this,_d).addChangedExistingAnnotation(n),n.renderAnnotationElement(e)&&n.show(!1)),e.show())}}Xd(this,kd,Pd).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const n of Vd(t,xd).values())s.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),qd(this,gd,!1)}getEditableAnnotation(t){var e;return(null==(e=Vd(this,hd))?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){Vd(this,_d).getActive()!==t&&Vd(this,_d).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(null==(t=Vd(this,wd))?void 0:t.div)&&!Vd(this,bd)){qd(this,bd,new AbortController);const t=Vd(this,_d).combinedSignal(Vd(this,bd));Vd(this,wd).div.addEventListener("pointerdown",Xd(this,kd,Md).bind(this),{signal:t}),Vd(this,wd).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(null==(t=Vd(this,wd))?void 0:t.div)&&Vd(this,bd)&&(Vd(this,bd).abort(),qd(this,bd,null),Vd(this,wd).div.classList.remove("highlighting"))}enableClick(){if(Vd(this,cd))return;qd(this,cd,new AbortController);const t=Vd(this,_d).combinedSignal(Vd(this,cd));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;null==(t=Vd(this,cd))||t.abort(),qd(this,cd,null)}attach(t){Vd(this,ud).set(t.id,t);const{annotationElementId:e}=t;e&&Vd(this,_d).isDeletedAnnotationElement(e)&&Vd(this,_d).removeDeletedAnnotationElement(t)}detach(t){var e;Vd(this,ud).delete(t.id),null==(e=Vd(this,od))||e.removePointerInTextLayer(t.contentDiv),!Vd(this,gd)&&t.annotationElementId&&Vd(this,_d).addDeletedAnnotationElement(t)}remove(t){this.detach(t),Vd(this,_d).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(Vd(this,_d).addDeletedAnnotationElement(t.annotationElementId),dg.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),null==(e=t.parent)||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),Vd(this,_d).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!Vd(this,fd)),Vd(this,_d).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var e;if(!t.isAttachedToDOM)return;const{activeElement:i}=document;t.div.contains(i)&&!Vd(this,dd)&&(t._focusEventsAllowed=!1,qd(this,dd,setTimeout(()=>{qd(this,dd,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:Vd(this,_d)._signal}),i.focus())},0))),t._structTreeParentId=null==(e=Vd(this,od))?void 0:e.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getEditorByUID(t){for(const e of Vd(this,ud).values())if(e.uid===t)return e;return null}getNextId(){return Vd(this,_d).getId()}combinedSignal(t){return Vd(this,_d).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return null==(t=Vd(this,kd,Ed))?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await Vd(this,_d).updateMode(t.mode);const{offsetX:i,offsetY:s}=Xd(this,kd,Td).call(this),n=this.getNextId(),r=Xd(this,kd,Cd).call(this,{parent:this,id:n,x:i,y:s,uiManager:Vd(this,_d),isCentered:!0,...e});r&&this.add(r)}async deserialize(e){var i;return await(null==(i=Vd(t,xd).get(e.annotationType??e.annotationEditorType))?void 0:i.deserialize(e,this,Vd(this,_d)))||null}createAndAddNewEditor(t,e,i={}){const s=this.getNextId(),n=Xd(this,kd,Cd).call(this,{parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:Vd(this,_d),isCentered:e,...i});return n&&this.add(n),n}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(Xd(this,kd,Td).call(this),!0,t)}setSelected(t){Vd(this,_d).setSelected(t)}toggleSelected(t){Vd(this,_d).toggleSelected(t)}unselect(t){Vd(this,_d).unselect(t)}pointerup(t){var e;const{isMac:i}=ip.platform;if(0!==t.button||t.ctrlKey&&i)return;if(t.target!==this.div)return;if(!Vd(this,pd))return;if(qd(this,pd,!1),(null==(e=Vd(this,kd,Ed))?void 0:e.isDrawer)&&Vd(this,kd,Ed).supportMultipleDrawings)return;if(!Vd(this,ld))return void qd(this,ld,!0);const s=Vd(this,_d).getMode();s!==fu.STAMP&&s!==fu.SIGNATURE?this.createAndAddNewEditor(t,!1):Vd(this,_d).unselectAll()}pointerdown(t){var e;if(Vd(this,_d).getMode()===fu.HIGHLIGHT&&this.enableTextSelection(),Vd(this,pd))return void qd(this,pd,!1);const{isMac:i}=ip.platform;if(0!==t.button||t.ctrlKey&&i)return;if(t.target!==this.div)return;if(qd(this,pd,!0),null==(e=Vd(this,kd,Ed))?void 0:e.isDrawer)return void this.startDrawingSession(t);const s=Vd(this,_d).getActive();qd(this,ld,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),Vd(this,md))return void Vd(this,kd,Ed).startDrawing(this,Vd(this,_d),!1,t);Vd(this,_d).setCurrentDrawingSession(this),qd(this,md,new AbortController);const e=Vd(this,_d).combinedSignal(Vd(this,md));this.div.addEventListener("blur",({relatedTarget:t})=>{t&&!this.div.contains(t)&&(qd(this,vd,null),this.commitOrRemove())},{signal:e}),Vd(this,kd,Ed).startDrawing(this,Vd(this,_d),!1,t)}pause(t){if(t){const{activeElement:t}=document;return void(this.div.contains(t)&&qd(this,vd,t))}Vd(this,vd)&&setTimeout(()=>{var t;null==(t=Vd(this,vd))||t.focus(),qd(this,vd,null)},0)}endDrawingSession(t=!1){return Vd(this,md)?(Vd(this,_d).setCurrentDrawingSession(null),Vd(this,md).abort(),qd(this,md,null),qd(this,vd,null),Vd(this,kd,Ed).endDrawing(t)):null}findNewParent(t,e,i){const s=Vd(this,_d).findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!Vd(this,md)&&(this.endDrawingSession(),!0)}onScaleChanging(){Vd(this,md)&&Vd(this,kd,Ed).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),(null==(t=Vd(this,_d).getActive())?void 0:t.parent)===this&&(Vd(this,_d).commitOrRemove(),Vd(this,_d).setActiveEditor(null)),Vd(this,dd)&&(clearTimeout(Vd(this,dd)),qd(this,dd,null));for(const i of Vd(this,ud).values())null==(e=Vd(this,od))||e.removePointerInTextLayer(i.contentDiv),i.setParent(null),i.isAttachedToDOM=!1,i.div.remove();this.div=null,Vd(this,ud).clear(),Vd(this,_d).removeLayer(this)}render({viewport:t}){this.viewport=t,Ip(this.div,t);for(const e of Vd(this,_d).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){Vd(this,_d).commitOrRemove(),Xd(this,kd,Pd).call(this);const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,Ip(this.div,{rotation:i}),e!==i)for(const s of Vd(this,ud).values())s.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return Vd(this,_d).viewParameters.realScale}};od=new WeakMap,ld=new WeakMap,hd=new WeakMap,cd=new WeakMap,dd=new WeakMap,ud=new WeakMap,pd=new WeakMap,gd=new WeakMap,fd=new WeakMap,md=new WeakMap,vd=new WeakMap,wd=new WeakMap,bd=new WeakMap,yd=new WeakMap,Ad=new WeakMap,_d=new WeakMap,xd=new WeakMap,kd=new WeakSet,Sd=function(){return 0!==Vd(this,ud).size?Vd(this,ud).values():Vd(this,_d).getEditors(this.pageIndex)},Md=function(t){Vd(this,_d).unselectAll();const{target:e}=t;if(e===Vd(this,wd).div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&Vd(this,wd).div.contains(e)){const{isMac:e}=ip.platform;if(0!==t.button||t.ctrlKey&&e)return;Vd(this,_d).showAllEditors("highlight",!0,!0),Vd(this,wd).div.classList.add("free"),this.toggleDrawing(),zv.startHighlighting(this,"ltr"===Vd(this,_d).direction,{target:Vd(this,wd).div,x:t.x,y:t.y}),Vd(this,wd).div.addEventListener("pointerup",()=>{Vd(this,wd).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:Vd(this,_d)._signal}),t.preventDefault()}},Ed=function(){return Vd(aw,xd).get(Vd(this,_d).getMode())},Cd=function(t){const e=Vd(this,kd,Ed);return e?new e.prototype.constructor(t):null},Td=function(){const{x:t,y:e,width:i,height:s}=this.boundingClientRect,n=Math.max(0,t),r=Math.max(0,e),a=(n+Math.min(window.innerWidth,t+i))/2-t,o=(r+Math.min(window.innerHeight,e+s))/2-e,[l,h]=this.viewport.rotation%180==0?[a,o]:[o,a];return{offsetX:l,offsetY:h}},Pd=function(){for(const t of Vd(this,ud).values())t.isEmpty()&&t.remove()},jd(aw,"_initialized",!1),Gd(aw,xd,new Map([Lv,Jv,rw,zv,nw].map(t=>[t._editorType,t])));let ow=aw;const lw=class t{constructor({pageIndex:t}){Gd(this,Wd),Gd(this,Dd,null),Gd(this,Rd,new Map),Gd(this,Id,new Map),this.pageIndex=t}setParent(t){if(Vd(this,Dd)){if(Vd(this,Dd)!==t){if(Vd(this,Rd).size>0)for(const e of Vd(this,Rd).values())e.remove(),t.append(e);qd(this,Dd,t)}}else qd(this,Dd,t)}static get _svgFactory(){return Gu(this,"_svgFactory",new tv)}draw(e,i=!1,s=!1){const n=Yd(t,Ld)._++,r=Xd(this,Wd,Bd).call(this),a=t._svgFactory.createElement("defs");r.append(a);const o=t._svgFactory.createElement("path");a.append(o);const l=`path_p${this.pageIndex}_${n}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),i&&Vd(this,Id).set(n,o);const h=s?Xd(this,Wd,Od).call(this,a,l):null,c=t._svgFactory.createElement("use");return r.append(c),c.setAttribute("href",`#${l}`),this.updateProperties(r,e),Vd(this,Rd).set(n,r),{id:n,clipPathId:`url(#${h})`}}drawOutline(e,i){const s=Yd(t,Ld)._++,n=Xd(this,Wd,Bd).call(this),r=t._svgFactory.createElement("defs");n.append(r);const a=t._svgFactory.createElement("path");r.append(a);const o=`path_p${this.pageIndex}_${s}`;let l;if(a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),i){const e=t._svgFactory.createElement("mask");r.append(e),l=`mask_p${this.pageIndex}_${s}`,e.setAttribute("id",l),e.setAttribute("maskUnits","objectBoundingBox");const i=t._svgFactory.createElement("rect");e.append(i),i.setAttribute("width","1"),i.setAttribute("height","1"),i.setAttribute("fill","white");const n=t._svgFactory.createElement("use");e.append(n),n.setAttribute("href",`#${o}`),n.setAttribute("stroke","none"),n.setAttribute("fill","black"),n.setAttribute("fill-rule","nonzero"),n.classList.add("mask")}const h=t._svgFactory.createElement("use");n.append(h),h.setAttribute("href",`#${o}`),l&&h.setAttribute("mask",`url(#${l})`);const c=h.cloneNode();return n.append(c),h.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(n,e),Vd(this,Rd).set(s,n),s}finalizeDraw(t,e){Vd(this,Id).delete(t),this.updateProperties(t,e)}updateProperties(e,i){var s;if(!i)return;const{root:n,bbox:r,rootClass:a,path:o}=i,l="number"==typeof e?Vd(this,Rd).get(e):e;if(l){if(n&&Xd(this,Wd,Ud).call(this,l,n),r&&Xd(s=t,Fd,Nd).call(s,l,r),a){const{classList:t}=l;for(const[e,i]of Object.entries(a))t.toggle(e,i)}if(o){const t=l.firstChild.firstChild;Xd(this,Wd,Ud).call(this,t,o)}}}updateParent(t,e){if(e===this)return;const i=Vd(this,Rd).get(t);i&&(Vd(e,Dd).append(i),Vd(this,Rd).delete(t),Vd(e,Rd).set(t,i))}remove(t){Vd(this,Id).delete(t),null!==Vd(this,Dd)&&(Vd(this,Rd).get(t).remove(),Vd(this,Rd).delete(t))}destroy(){qd(this,Dd,null);for(const t of Vd(this,Rd).values())t.remove();Vd(this,Rd).clear(),Vd(this,Id).clear()}};Dd=new WeakMap,Rd=new WeakMap,Id=new WeakMap,Ld=new WeakMap,Fd=new WeakSet,Nd=function(t,[e,i,s,n]){const{style:r}=t;r.top=100*i+"%",r.left=100*e+"%",r.width=100*s+"%",r.height=100*n+"%"},Wd=new WeakSet,Bd=function(){const t=lw._svgFactory.create(1,1,!0);return Vd(this,Dd).append(t),t.setAttribute("aria-hidden",!0),t},Od=function(t,e){const i=lw._svgFactory.createElement("clipPath");t.append(i);const s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");const n=lw._svgFactory.createElement("use");return i.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),s},Ud=function(t,e){for(const[i,s]of Object.entries(e))null===s?t.removeAttribute(i):t.setAttribute(i,s)},Gd(lw,Fd),Gd(lw,Ld,0);let hw=lw;globalThis._pdfjsTestingUtils={HighlightOutliner:Ov},globalThis.pdfjsLib={AbortException:Zu,AnnotationEditorLayer:ow,AnnotationEditorParamsType:mu,AnnotationEditorType:fu,AnnotationEditorUIManager:ng,AnnotationLayer:Dv,AnnotationMode:pu,AnnotationType:Su,applyOpacity:Bp,build:Vm,ColorPicker:qm,createValidAbsoluteUrl:zu,CSSConstants:Wp,DOMSVGFactory:tv,DrawLayer:hw,FeatureTest:ip,fetchData:vp,findContrastColor:zp,getDocument:Rm,getFilenameFromUrl:_p,getPdfFilenameFromUrl:xp,getRGB:Pp,getUuid:lp,getXfaPageViewport:Tp,GlobalWorkerOptions:im,ImageKind:ku,InvalidPDFException:Ku,isDataScheme:yp,isPdfFile:Ap,isValidExplicitDest:kg,MathClamp:cp,noContextMenu:Mp,normalizeUnicode:op,OPS:Ru,OutputScale:Lp,PasswordResponses:Wu,PDFDataRangeTransport:Fm,PDFDateString:Cp,PDFWorker:Om,PermissionFlag:vu,PixelsPerInch:mp,RenderingCancelledException:bp,renderRichText:Vp,ResponseException:Qu,setLayerDimensions:Ip,shadow:Gu,SignatureExtractor:tw,stopEvent:Ep,SupportedImageMimeTypes:Fp,TextLayer:Dm,TouchManager:hg,updateUrlHash:Vu,Util:np,VerbosityLevel:Du,version:zm,XfaLayer:pp};const cw=Object.freeze(Object.defineProperty({__proto__:null,AbortException:Zu,AnnotationEditorLayer:ow,AnnotationEditorParamsType:mu,AnnotationEditorType:fu,AnnotationEditorUIManager:ng,AnnotationLayer:Dv,AnnotationMode:pu,AnnotationType:Su,CSSConstants:Wp,ColorPicker:qm,DOMSVGFactory:tv,DrawLayer:hw,FeatureTest:ip,GlobalWorkerOptions:im,ImageKind:ku,InvalidPDFException:Ku,MathClamp:cp,OPS:Ru,OutputScale:Lp,PDFDataRangeTransport:Fm,PDFDateString:Cp,PDFWorker:Om,PasswordResponses:Wu,PermissionFlag:vu,PixelsPerInch:mp,RenderingCancelledException:bp,ResponseException:Qu,SignatureExtractor:tw,SupportedImageMimeTypes:Fp,TextLayer:Dm,TouchManager:hg,Util:np,VerbosityLevel:Du,XfaLayer:pp,applyOpacity:Bp,build:Vm,createValidAbsoluteUrl:zu,fetchData:vp,findContrastColor:zp,getDocument:Rm,getFilenameFromUrl:_p,getPdfFilenameFromUrl:xp,getRGB:Pp,getUuid:lp,getXfaPageViewport:Tp,isDataScheme:yp,isPdfFile:Ap,isValidExplicitDest:kg,noContextMenu:Mp,normalizeUnicode:op,renderRichText:Vp,setLayerDimensions:Ip,shadow:Gu,stopEvent:Ep,updateUrlHash:Vu,version:zm},Symbol.toStringTag,{value:"Module"}));var dw=Object.prototype.hasOwnProperty;function uw(t,e,i){for(i of t.keys())if(pw(i,e))return i}function pw(t,e){var i,s,n;if(t===e)return!0;if(t&&e&&(i=t.constructor)===e.constructor){if(i===Date)return t.getTime()===e.getTime();if(i===RegExp)return t.toString()===e.toString();if(i===Array){if((s=t.length)===e.length)for(;s--&&pw(t[s],e[s]););return-1===s}if(i===Set){if(t.size!==e.size)return!1;for(s of t){if((n=s)&&"object"==typeof n&&!(n=uw(e,n)))return!1;if(!e.has(n))return!1}return!0}if(i===Map){if(t.size!==e.size)return!1;for(s of t){if((n=s[0])&&"object"==typeof n&&!(n=uw(e,n)))return!1;if(!pw(s[1],e.get(n)))return!1}return!0}if(i===ArrayBuffer)t=new Uint8Array(t),e=new Uint8Array(e);else if(i===DataView){if((s=t.byteLength)===e.byteLength)for(;s--&&t.getInt8(s)===e.getInt8(s););return-1===s}if(ArrayBuffer.isView(t)){if((s=t.byteLength)===e.byteLength)for(;s--&&t[s]===e[s];);return-1===s}if(!i||"object"==typeof t){for(i in s=0,t){if(dw.call(t,i)&&++s&&!dw.call(e,i))return!1;if(!(i in e)||!pw(t[i],e[i]))return!1}return Object.keys(e).length===s}}return t!=t&&e!=e}function gw(t){let e=!1;return{promise:new Promise((i,s)=>{t.then(t=>!e&&i(t)).catch(t=>!e&&s(t))}),cancel(){e=!0}}}const fw=["onCopy","onCut","onPaste","onCompositionEnd","onCompositionStart","onCompositionUpdate","onFocus","onBlur","onInput","onInvalid","onReset","onSubmit","onLoad","onError","onKeyDown","onKeyPress","onKeyUp","onAbort","onCanPlay","onCanPlayThrough","onDurationChange","onEmptied","onEncrypted","onEnded","onError","onLoadedData","onLoadedMetadata","onLoadStart","onPause","onPlay","onPlaying","onProgress","onRateChange","onSeeked","onSeeking","onStalled","onSuspend","onTimeUpdate","onVolumeChange","onWaiting","onClick","onContextMenu","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop","onSelect","onTouchCancel","onTouchEnd","onTouchMove","onTouchStart","onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onGotPointerCapture","onLostPointerCapture","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut","onScroll","onWheel","onAnimationStart","onAnimationEnd","onAnimationIteration","onTransitionEnd","onChange","onToggle"];function mw(t,e){const i={};for(const s of fw){const n=t[s];n&&(i[s]=e?t=>n(t,e(s)):n)}return i}function vw(t,e){if(!t)throw new Error("Invariant failed")}const ww=Kd(function(){}),bw=Qd.createContext(null);class yw{constructor(){this.externalLinkEnabled=!0,this.externalLinkRel=void 0,this.externalLinkTarget=void 0,this.isInPresentationMode=!1,this.pdfDocument=void 0,this.pdfViewer=void 0}setDocument(t){this.pdfDocument=t}setViewer(t){this.pdfViewer=t}setExternalLinkRel(t){this.externalLinkRel=t}setExternalLinkTarget(t){this.externalLinkTarget=t}setHash(){}setHistory(){}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return vw(this.pdfViewer),this.pdfViewer.currentPageNumber||0}set page(t){vw(this.pdfViewer),this.pdfViewer.currentPageNumber=t}get rotation(){return 0}set rotation(t){}addLinkAttributes(t,e,i){t.href=e,t.rel=this.externalLinkRel||"noopener noreferrer nofollow",t.target=i?"_blank":this.externalLinkTarget||""}goToDestination(t){return new Promise(e=>{vw(this.pdfDocument),vw(t),"string"==typeof t?this.pdfDocument.getDestination(t).then(e):Array.isArray(t)?e(t):t.then(e)}).then(t=>{vw(Array.isArray(t));const e=t[0];new Promise(t=>{vw(this.pdfDocument),e instanceof Object?this.pdfDocument.getPageIndex(e).then(e=>{t(e)}).catch(()=>{vw(!1)}):"number"==typeof e?t(e):vw(!1)}).then(e=>{const i=e+1;vw(this.pdfViewer),vw(i>=1&&i<=this.pagesCount),this.pdfViewer.scrollPageIntoView({dest:t,pageIndex:e,pageNumber:i})})})}goToPage(t){const e=t-1;vw(this.pdfViewer),vw(t>=1&&t<=this.pagesCount),this.pdfViewer.scrollPageIntoView({pageIndex:e,pageNumber:t})}goToXY(){}cachePageRef(){}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}executeNamedAction(){}executeSetOCGState(){}isPageVisible(){return!0}isPageCached(){return!0}navigateTo(t){this.goToDestination(t)}}function Aw({children:t,type:e}){return Jd.jsx("div",{className:`react-pdf__message react-pdf__message--${e}`,children:t})}const _w=1,xw=2;function kw(t,e){switch(e.type){case"RESOLVE":return{value:e.value,error:void 0};case"REJECT":return{value:!1,error:e.error};case"RESET":return{value:void 0,error:void 0};default:return t}}function Sw(){return Qd.useReducer(kw,{value:void 0,error:void 0})}const Mw="undefined"!=typeof window,Ew=Mw&&"file:"===window.location.protocol;function Cw(t){return function(t){return void 0!==t}(t)&&null!==t}function Tw(t){return function(t){return"string"==typeof t}(t)&&/^data:/.test(t)}function Pw(t){vw(Tw(t));const[e="",i=""]=t.split(",");return-1!==e.split(";").indexOf("base64")?atob(i):unescape(i)}function Dw(){return Mw&&window.devicePixelRatio||1}const Rw="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function Iw(){ww(!Ew,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${Rw}`)}function Lw(t){(null==t?void 0:t.cancel)&&t.cancel()}function Fw(t,e){return Object.defineProperty(t,"width",{get(){return this.getViewport({scale:e}).width},configurable:!0}),Object.defineProperty(t,"height",{get(){return this.getViewport({scale:e}).height},configurable:!0}),Object.defineProperty(t,"originalWidth",{get(){return this.getViewport({scale:1}).width},configurable:!0}),Object.defineProperty(t,"originalHeight",{get(){return this.getViewport({scale:1}).height},configurable:!0}),t}function Nw(t){return"AbortException"===t.name||"RenderingCancelledException"===t.name}const{PDFDataRangeTransport:Ww}=cw,Bw=(t,e)=>{switch(e){case _w:t(prompt("Enter the password to open this PDF file."));break;case xw:t(prompt("Invalid password. Please try again."));break}};function Ow(t){return"object"==typeof t&&null!==t&&("data"in t||"range"in t||"url"in t)}const Uw=Qd.forwardRef(function({children:t,className:e,error:i="Failed to load PDF file.",externalLinkRel:s,externalLinkTarget:n,file:r,inputRef:a,imageResourcesPath:o,loading:l="Loading PDF…",noData:h="No PDF file specified.",onItemClick:c,onLoadError:d,onLoadProgress:u,onLoadSuccess:p,onPassword:g=Bw,onSourceError:f,onSourceSuccess:m,options:v,renderMode:w,rotate:b,scale:y,...A},_){const[x,k]=Sw(),{value:S,error:M}=x,[E,C]=Sw(),{value:T,error:P}=E,D=Qd.useRef(new yw),R=Qd.useRef([]),I=Qd.useRef(void 0),L=Qd.useRef(void 0);r&&r!==I.current&&Ow(r)&&(ww(!pw(r,I.current),'File prop passed to <Document /> changed, but it\'s equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "file" prop.'),I.current=r),v&&v!==L.current&&(ww(!pw(v,L.current),'Options prop passed to <Document /> changed, but it\'s equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "options" prop.'),L.current=v);const F=Qd.useRef({scrollPageIntoView:t=>{const{dest:e,pageNumber:i,pageIndex:s=i-1}=t;if(c)return void c({dest:e,pageIndex:s,pageNumber:i});const n=R.current[s];n?n.scrollIntoView():ww(!1,`An internal link leading to page ${i} was clicked, but neither <Document> was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to <Document> and handle navigating by yourself or ensure that all pages are rendered within <Document>.`)}});Qd.useImperativeHandle(_,()=>({linkService:D,pages:R,viewer:F}),[]),Qd.useEffect(function(){k({type:"RESET"})},[r,k]);const N=Qd.useCallback(async()=>{if(!r)return null;if("string"==typeof r){if(Tw(r)){return{data:Pw(r)}}return Iw(),{url:r}}if(r instanceof Ww)return{range:r};if(r instanceof ArrayBuffer)return{data:r};if(Mw&&function(t){return vw(Mw),t instanceof Blob}(r)){const t=await function(t){return new Promise((e,i)=>{const s=new FileReader;s.onload=()=>{if(!s.result)return i(new Error("Error while reading a file."));e(s.result)},s.onerror=t=>{if(!t.target)return i(new Error("Error while reading a file."));const{error:e}=t.target;if(!e)return i(new Error("Error while reading a file."));switch(e.code){case e.NOT_FOUND_ERR:return i(new Error("Error while reading a file: File not found."));case e.SECURITY_ERR:return i(new Error("Error while reading a file: Security error."));case e.ABORT_ERR:return i(new Error("Error while reading a file: Aborted."));default:return i(new Error("Error while reading a file."))}},s.readAsArrayBuffer(t)})}(r);return{data:t}}if(vw("object"==typeof r),vw(Ow(r)),"url"in r&&"string"==typeof r.url){if(Tw(r.url)){const{url:t,...e}=r;return{data:Pw(t),...e}}Iw()}return r},[r]);Qd.useEffect(()=>{const t=gw(N());return t.promise.then(t=>{k({type:"RESOLVE",value:t})}).catch(t=>{k({type:"REJECT",error:t})}),()=>{Lw(t)}},[N,k]),Qd.useEffect(()=>{void 0!==S&&(!1!==S?m&&m():M&&(ww(!1,M.toString()),f&&f(M)))},[S]),Qd.useEffect(function(){C({type:"RESET"})},[C,S]),Qd.useEffect(function(){if(!S)return;const t=Rm(v?{...S,...v}:S);u&&(t.onProgress=u),g&&(t.onPassword=g);const e=t;return e.promise.then(t=>{e.destroyed||C({type:"RESOLVE",value:t})}).catch(t=>{e.destroyed||C({type:"REJECT",error:t})}),()=>{e.destroy()}},[v,C,S]),Qd.useEffect(()=>{void 0!==T&&(!1!==T?T&&(p&&p(T),R.current=new Array(T.numPages),D.current.setDocument(T)):P&&(ww(!1,P.toString()),d&&d(P)))},[T]),Qd.useEffect(function(){D.current.setViewer(F.current),D.current.setExternalLinkRel(s),D.current.setExternalLinkTarget(n)},[s,n]);const W=Qd.useCallback((t,e)=>{R.current[t]=e},[]),B=Qd.useCallback(t=>{delete R.current[t]},[]),O=Qd.useMemo(()=>({imageResourcesPath:o,linkService:D.current,onItemClick:c,pdf:T,registerPage:W,renderMode:w,rotate:b,scale:y,unregisterPage:B}),[o,c,T,W,w,b,y,B]),U=Qd.useMemo(()=>mw(A,()=>T),[A,T]);return Jd.jsx("div",{className:Zd("react-pdf__Document",e),ref:a,...U,children:r?null==T?Jd.jsx(Aw,{type:"loading",children:"function"==typeof l?l():l}):!1===T?Jd.jsx(Aw,{type:"error",children:"function"==typeof i?i():i}):function(){if(e=O,!Boolean(null==e?void 0:e.pdf))throw new Error("pdf is undefined");var e;const i="function"==typeof t?t(O):t;return Jd.jsx(bw.Provider,{value:O,children:i})}():Jd.jsx(Aw,{type:"no-data",children:"function"==typeof h?h():h})})});function Hw(){return Qd.useContext(bw)}function $w(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=t.filter(Boolean);return i.length<=1?i[0]||null:function(t){for(var e=0,s=i;e<s.length;e++){var n=s[e];"function"==typeof n?n(t):n&&(n.current=t)}}}const jw=Qd.createContext(null);function zw(){return Qd.useContext(jw)}function Vw(){const t=Hw(),e=zw();vw(e);const i={...t,...e},{filterAnnotations:s,imageResourcesPath:n,linkService:r,onGetAnnotationsError:a,onGetAnnotationsSuccess:o,onRenderAnnotationLayerError:l,onRenderAnnotationLayerSuccess:h,page:c,pdf:d,renderForms:u,rotate:p,scale:g=1}=i;vw(d),vw(c),vw(r);const[f,m]=Sw(),{value:v,error:w}=f,b=Qd.useRef(null);ww(1===Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"),10),"AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations"),Qd.useEffect(function(){m({type:"RESET"})},[m,c]),Qd.useEffect(function(){if(!c)return;const t=gw(c.getAnnotations()),e=t;return t.promise.then(t=>{m({type:"RESOLVE",value:t})}).catch(t=>{m({type:"REJECT",error:t})}),()=>{Lw(e)}},[m,c]),Qd.useEffect(()=>{void 0!==v&&(!1!==v?v&&o&&o(v):w&&(ww(!1,w.toString()),a&&a(w)))},[v]);const y=Qd.useMemo(()=>c.getViewport({scale:g,rotation:p}),[c,p,g]);return Qd.useEffect(function(){if(!(d&&c&&r&&v))return;const{current:t}=b;if(!t)return;const e=y.clone({dontFlip:!0}),i={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,annotationStorage:d.annotationStorage,commentManager:null,div:t,l10n:null,linkService:r,page:c,structTreeLayer:null,viewport:e},a={annotations:s?s({annotations:v}):v,annotationStorage:d.annotationStorage,div:t,imageResourcesPath:n,linkService:r,page:c,renderForms:u,viewport:e};t.innerHTML="";try{new Dv(i).render(a),h&&h()}catch(o){!function(t){ww(!1,`${t}`),l&&l(t)}(o)}return()=>{}},[v,s,n,r,c,d,u,y]),Jd.jsx("div",{className:Zd("react-pdf__Page__annotations","annotationLayer"),ref:b})}const Gw={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"columnheader",TBody:null,TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},qw=/^H(\d+)$/;function Xw(t){return"children"in t}function Yw(t){return!!Xw(t)&&(1===t.children.length&&0 in t.children&&"id"in t.children[0])}function Kw(t){const e={};if(Xw(t)){const{role:i}=t,s=i.match(qw);if(s)e.role="heading",e["aria-level"]=Number(s[1]);else if(function(t){return t in Gw}(i)){const t=Gw[i];t&&(e.role=t)}}return e}function Qw(t){const e={};if(Xw(t)){if(void 0!==t.alt&&(e["aria-label"]=t.alt),void 0!==t.lang&&(e.lang=t.lang),Yw(t)){const[i]=t.children;if(i){const t=Qw(i);return{...e,...t}}}}else"id"in t&&(e["aria-owns"]=t.id);return e}function Jw({className:t,node:e}){const i=Qd.useMemo(()=>function(t){return t?{...Kw(t),...Qw(t)}:null}(e),[e]),s=Qd.useMemo(()=>Xw(e)?Yw(e)?null:e.children.map((t,e)=>Jd.jsx(Jw,{node:t},e)):null,[e]);return Jd.jsx("span",{className:t,...i,children:s})}function Zw(){const t=zw();vw(t);const{onGetStructTreeError:e,onGetStructTreeSuccess:i}=t,[s,n]=Sw(),{value:r,error:a}=s,{customTextRenderer:o,page:l}=t;return Qd.useEffect(function(){n({type:"RESET"})},[n,l]),Qd.useEffect(function(){if(o)return;if(!l)return;const t=gw(l.getStructTree()),e=t;return t.promise.then(t=>{n({type:"RESOLVE",value:t})}).catch(t=>{n({type:"REJECT",error:t})}),()=>Lw(e)},[o,l,n]),Qd.useEffect(()=>{void 0!==r&&(!1!==r?r&&i&&i(r):a&&(ww(!1,a.toString()),e&&e(a)))},[r]),r?Jd.jsx(Jw,{className:"react-pdf__Page__structTree structTree",node:r}):null}const tb=pu;function eb(t){const e=zw();vw(e);const i={...e,...t},{_className:s,canvasBackground:n,devicePixelRatio:r=Dw(),onRenderError:a,onRenderSuccess:o,page:l,renderForms:h,renderTextLayer:c,pageColors:d,rotate:u,scale:p}=i,{canvasRef:g}=t;vw(l);const f=Qd.useRef(null);function m(t){Nw(t)||(ww(!1,t.toString()),a&&a(t))}const v=Qd.useMemo(()=>l.getViewport({scale:p*r,rotation:u}),[r,l,u,p]),w=Qd.useMemo(()=>l.getViewport({scale:p,rotation:u}),[l,u,p]);Qd.useEffect(function(){if(!l)return;l.cleanup();const{current:t}=f;if(!t)return;t.width=v.width,t.height=v.height,t.style.width=`${Math.floor(w.width)}px`,t.style.height=`${Math.floor(w.height)}px`,t.style.visibility="hidden";const e={annotationMode:h?tb.ENABLE_FORMS:tb.ENABLE,canvas:t,canvasContext:t.getContext("2d",{alpha:!1}),pageColors:d,viewport:v};n&&(e.background=n);const i=l.render(e),s=i;return i.promise.then(()=>{t.style.visibility="",l&&o&&o(Fw(l,p))}).catch(m),()=>Lw(s)},[n,l,d,h,v,w]);const b=Qd.useCallback(()=>{const{current:t}=f;t&&(t.width=0,t.height=0)},[]);return Qd.useEffect(()=>b,[b]),Jd.jsx("canvas",{className:`${s}__canvas`,dir:"ltr",ref:$w(g,f),style:{display:"block",userSelect:"none"},children:c?Jd.jsx(Zw,{}):null})}const ib=new Set(["base","embed","iframe","link","meta","object","script","style","template"]),sb=new Set(["action","formaction","href","poster","src","xlink:href"]);function nb(t){return function(t){return t.nodeType===Node.ELEMENT_NODE}(t)&&t instanceof HTMLElement}function rb(t){var e;return nb(t)&&!function(t){return nb(t)&&ib.has(t.tagName.toLowerCase())}(t)?function(t){const e=document.createElement(t.tagName.toLowerCase());return Array.from(t.attributes).forEach(t=>{const i=t.name.toLowerCase();i.startsWith("on")||"srcdoc"===i||sb.has(i)&&function(t){let e="";for(const i of t){const t=i.charCodeAt(0);t<=32||127===t||(e+=i.toLowerCase())}return e.startsWith("javascript:")||e.startsWith("vbscript:")}(t.value)||e.setAttribute(t.name,t.value)}),Array.from(t.childNodes).forEach(t=>{e.append(rb(t))}),e}(t):document.createTextNode(null!==(e=t.textContent)&&void 0!==e?e:"")}function ab(){const t=zw();vw(t);const{customTextRenderer:e,onGetTextError:i,onGetTextSuccess:s,onRenderTextLayerError:n,onRenderTextLayerSuccess:r,page:a,pageIndex:o,pageNumber:l,rotate:h,scale:c}=t;vw(a);const[d,u]=Sw(),{value:p,error:g}=d,f=Qd.useRef(null);ww(1===Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"),10),"TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer"),Qd.useEffect(function(){u({type:"RESET"})},[a,u]),Qd.useEffect(function(){if(!a)return;const t=gw(a.getTextContent()),e=t;return t.promise.then(t=>{u({type:"RESOLVE",value:t})}).catch(t=>{u({type:"REJECT",error:t})}),()=>Lw(e)},[a,u]),Qd.useEffect(()=>{void 0!==p&&(!1!==p?p&&s&&s(p):g&&(ww(!1,g.toString()),i&&i(g)))},[p]);const m=Qd.useCallback(()=>{r&&r()},[r]),v=Qd.useCallback(t=>{Nw(t)||(ww(!1,t.toString()),n&&n(t))},[n]);const w=Qd.useMemo(()=>a.getViewport({scale:c,rotation:h}),[a,h,c]);return Qd.useLayoutEffect(function(){if(!a||!p)return;const{current:t}=f;if(!t)return;t.innerHTML="";const i=a.streamTextContent({includeMarkedContent:!0}),s=new Dm({container:t,textContentSource:i,viewport:w}),n=s;return s.render().then(()=>{const i=document.createElement("div");i.className="endOfContent",t.append(i);const s=t.querySelectorAll('[role="presentation"]');if(e){let t=0;p.items.forEach((i,n)=>{if(!function(t){return"str"in t}(i))return;const r=s[t];if(!r)return;!function(t,e){const i=document.createElement("template");i.innerHTML=e;const s=document.createDocumentFragment();Array.from(i.content.childNodes).forEach(t=>{s.append(rb(t))}),t.replaceChildren(s)}(r,e({pageIndex:o,pageNumber:l,itemIndex:n,...i})),t+=i.str&&i.hasEOL?2:1})}m()}).catch(v),()=>Lw(n)},[e,v,m,a,o,l,p,w]),Jd.jsx("div",{className:Zd("react-pdf__Page__textContent","textLayer"),onMouseUp:function(){const t=f.current;t&&t.classList.remove("selecting")},onMouseDown:function(){const t=f.current;t&&t.classList.add("selecting")},ref:f})}const ob=1;function lb(t){const e={...Hw(),...t},{_className:i="react-pdf__Page",_enableRegisterUnregisterPage:s=!0,canvasBackground:n,canvasRef:r,children:a,className:o,customRenderer:l,customTextRenderer:h,devicePixelRatio:c,error:d="Failed to load the page.",filterAnnotations:u,height:p,inputRef:g,loading:f="Loading page…",noData:m="No page specified.",onGetAnnotationsError:v,onGetAnnotationsSuccess:w,onGetStructTreeError:b,onGetStructTreeSuccess:y,onGetTextError:A,onGetTextSuccess:_,onLoadError:x,onLoadSuccess:k,onRenderAnnotationLayerError:S,onRenderAnnotationLayerSuccess:M,onRenderError:E,onRenderSuccess:C,onRenderTextLayerError:T,onRenderTextLayerSuccess:P,pageColors:D,pageIndex:R,pageNumber:I,pdf:L,registerPage:F,renderAnnotationLayer:N=!0,renderForms:W=!1,renderMode:B="canvas",renderTextLayer:O=!0,rotate:U,scale:H=ob,unregisterPage:$,width:j,...z}=e,[V,G]=Sw(),{value:q,error:X}=V,Y=Qd.useRef(null);vw(L);const K=Cw(I)?I-1:null!=R?R:null,Q=null!=I?I:Cw(R)?R+1:null,J=null!=U?U:q?q.rotate:null,Z=Qd.useMemo(()=>{if(!q)return null;let t=1;const e=null!=H?H:ob;if(j||p){const e=q.getViewport({scale:1,rotation:J});j?t=j/e.width:p&&(t=p/e.height)}return e*t},[p,q,J,H,j]);Qd.useEffect(function(){return()=>{Cw(K)&&s&&$&&$(K)}},[s,L,K,$]),Qd.useEffect(function(){G({type:"RESET"})},[G,L,K]),Qd.useEffect(function(){if(!L||!Q)return;const t=gw(L.getPage(Q)),e=t;return t.promise.then(t=>{G({type:"RESOLVE",value:t})}).catch(t=>{G({type:"REJECT",error:t})}),()=>Lw(e)},[G,L,Q]),Qd.useEffect(()=>{void 0!==q&&(!1!==q?function(){if(k){if(!q||!Z)return;k(Fw(q,Z))}if(s&&F){if(!Cw(K)||!Y.current)return;F(K,Y.current)}}():X&&(ww(!1,X.toString()),x&&x(X)))},[q,Z]);const tt=Qd.useMemo(()=>Cw(K)&&Q&&Cw(J)&&Cw(Z)?{_className:i,canvasBackground:n,customTextRenderer:h,devicePixelRatio:c,filterAnnotations:u,onGetAnnotationsError:v,onGetAnnotationsSuccess:w,onGetStructTreeError:b,onGetStructTreeSuccess:y,onGetTextError:A,onGetTextSuccess:_,onRenderAnnotationLayerError:S,onRenderAnnotationLayerSuccess:M,onRenderError:E,onRenderSuccess:C,onRenderTextLayerError:T,onRenderTextLayerSuccess:P,page:q,pageColors:D,pageIndex:K,pageNumber:Q,renderForms:W,renderTextLayer:O,rotate:J,scale:Z}:null,[i,n,h,c,u,v,w,b,y,A,_,S,M,E,C,T,P,q,D,K,Q,W,O,J,Z]),et=Qd.useMemo(()=>mw(z,()=>q?Z?Fw(q,Z):void 0:q),[z,q,Z]),it=`${K}@${Z}/${J}`;function st(){switch(B){case"custom":return vw(l),Jd.jsx(l,{},`${it}_custom`);case"none":return null;default:return Jd.jsx(eb,{canvasRef:r},`${it}_canvas`)}}return Jd.jsx("div",{className:Zd(i,o),"data-page-number":Q,ref:$w(g,Y),style:{"--scale-round-x":"1px","--scale-round-y":"1px","--scale-factor":"1","--user-unit":`${Z}`,"--total-scale-factor":"calc(var(--scale-factor) * var(--user-unit))",backgroundColor:n||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"},...et,children:Q?null===L||null==q?Jd.jsx(Aw,{type:"loading",children:"function"==typeof f?f():f}):!1===L||!1===q?Jd.jsx(Aw,{type:"error",children:"function"==typeof d?d():d}):function(){if(t=tt,!Boolean(null==t?void 0:t.page))throw new Error("page is undefined");var t;const e="function"==typeof a?a(tt):a;return Jd.jsxs(jw.Provider,{value:tt,children:[st(),O?Jd.jsx(ab,{},`${it}_text`):null,N?Jd.jsx(Vw,{},`${it}_annotations`):null,e]})}():Jd.jsx(Aw,{type:"no-data",children:"function"==typeof m?m():m})})}ww(!Ew,`Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${Rw}`),im.workerSrc="pdf.worker.mjs";im.workerSrc="/assets/pdf.worker.min-qwK7q_zL.mjs";function hb({pageNumber:t,scale:e}){const i=Qd.useRef(null),[s,n]=Qd.useState(!1);return Qd.useEffect(()=>{if(s||!i.current)return;const t=new IntersectionObserver(e=>{e[0].isIntersecting&&(n(!0),t.disconnect())},{rootMargin:"600px 0px"});return t.observe(i.current),()=>t.disconnect()},[s]),Jd.jsx("div",{ref:i,style:s?void 0:{minHeight:1e3*e,width:"100%"},children:s&&Jd.jsx(lb,{pageNumber:t,scale:e,renderTextLayer:!0,renderAnnotationLayer:!0,className:"rounded-md shadow-sm"})})}const cb=new Set(["pdf"]);function db({filePath:t,zoom:e}){const[i,s]=Qd.useState(null),[n,r]=Qd.useState(null),[a,o]=Qd.useState(0);Qd.useEffect(()=>{const e=new AbortController;return s(null),r(null),o(0),(async()=>{try{const i=await async function(t,e){let i=eu(t);const s=tu();s&&(i+=`${i.includes("?")?"&":"?"}token=${encodeURIComponent(s)}`);const n=await fetch(i,{signal:e});if(!n.ok)throw new Error(`Failed to fetch PDF: ${n.status}`);return n.arrayBuffer()}(t,e.signal);s(i)}catch(i){if("AbortError"===(null==i?void 0:i.name))return;r(i instanceof Error&&i.message?i.message:"Failed to load PDF")}})(),()=>e.abort()},[t]);const l=Qd.useMemo(()=>i?{data:i}:null,[i]);return n?Jd.jsx("p",{className:"text-sm text-destructive p-4",children:n}):l?Jd.jsx("div",{className:"flex flex-col items-center gap-3 p-4",children:Jd.jsx(Uw,{file:l,onLoadSuccess:({numPages:t})=>o(t),onLoadError:t=>r((null==t?void 0:t.message)||"未知错误"),loading:Jd.jsx("p",{className:"text-sm text-muted-foreground",children:"解析 PDF..."}),error:Jd.jsx("p",{className:"text-sm text-destructive",children:"PDF 解析失败"}),children:Array.from({length:a},(t,i)=>Jd.jsx(hb,{pageNumber:i+1,scale:e/100},i))})}):Jd.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"加载 PDF 中..."})}export{cb as PDF_EXTS,db as PdfPreview};