diff --git "a/assets/PaperReaderView-fLXDbLBc.js" "b/assets/PaperReaderView-fLXDbLBc.js" new file mode 100644--- /dev/null +++ "b/assets/PaperReaderView-fLXDbLBc.js" @@ -0,0 +1,12 @@ +var Lp=Object.defineProperty;var xd=c=>{throw TypeError(c)};var Mp=(c,t,e)=>t in c?Lp(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e;var Y=(c,t,e)=>Mp(c,typeof t!="symbol"?t+"":t,e),Mh=(c,t,e)=>t.has(c)||xd("Cannot "+e);var r=(c,t,e)=>(Mh(c,t,"read from private field"),e?e.call(c):t.get(c)),b=(c,t,e)=>t.has(c)?xd("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(c):t.set(c,e),p=(c,t,e,s)=>(Mh(c,t,"write to private field"),s?s.call(c,e):t.set(c,e),e),m=(c,t,e)=>(Mh(c,t,"access private method"),e);var he=(c,t,e,s)=>({set _(i){p(c,t,i,e)},get _(){return r(c,t,s)}});import{_ as fl,N as Ip,r as R,j as k,O as Ah,c as Fp,n as Dp,u as Op,y as Np,Q as Hp,L as rr,U as Bp,S as jp}from"./index-D_-UZEuL.js";import{u as $p}from"./useQuery-BZo4MZ3s.js";import{a as zp}from"./usePapers-BCHtBW8G.js";import{c as Gp}from"./chat-7zW8PrrA.js";import{s as Up}from"./safeExternalHref-CkBrsh84.js";import{ChatExperience as Wp}from"./ChatView-D5ne7HbB.js";import"./useInfiniteQuery-CFUEkcEs.js";import"./papers-DHqjKX7p.js";import"./ChatMessage-DwVcq3Ve.js";import"./chatSessions-CPPX7pkh.js";import"./chevron-down-DI19XsBw.js";import"./katex.min-BSBacQyE.js";import"./hover-card-DiJQFgx9.js";import"./github-DQuIliTJ.js";import"./github-iFSl-B6V.js";import"./PaperPreviewLink-B25cD-_k.js";import"./index-vCOH2DKd.js";import"./file-text--vrXMvWb.js";import"./openrouter-DNgcWuY9.js";import"./chatPrompts-CDY3UGU1.js";var ja={};ja.d=(c,t)=>{for(var e in t)ja.o(t,e)&&!ja.o(c,e)&&Object.defineProperty(c,e,{enumerable:!0,get:t[e]})};ja.o=(c,t)=>Object.prototype.hasOwnProperty.call(c,t);var Q=globalThis.pdfjsLib={};ja.d(Q,{AbortException:()=>er,AnnotationEditorLayer:()=>Jc,AnnotationEditorParamsType:()=>K,AnnotationEditorType:()=>tt,AnnotationEditorUIManager:()=>Yn,AnnotationLayer:()=>Gm,AnnotationMode:()=>di,ColorPicker:()=>Zl,DOMSVGFactory:()=>vd,DrawLayer:()=>sd,FeatureTest:()=>fe,GlobalWorkerOptions:()=>ii,ImageKind:()=>vl,InvalidPDFException:()=>iu,MissingPDFException:()=>tr,OPS:()=>Xe,OutputScale:()=>Wh,PDFDataRangeTransport:()=>Zu,PDFDateString:()=>fd,PDFWorker:()=>mr,PasswordResponses:()=>Yp,PermissionFlag:()=>Xp,PixelsPerInch:()=>Bi,RenderingCancelledException:()=>dd,TextLayer:()=>yc,UnexpectedResponseException:()=>_h,Util:()=>j,VerbosityLevel:()=>yh,XfaLayer:()=>ef,build:()=>Em,createValidAbsoluteUrl:()=>Zp,fetchData:()=>Sh,getDocument:()=>pm,getFilenameFromUrl:()=>lg,getPdfFilenameFromUrl:()=>hg,getXfaPageViewport:()=>cg,isDataScheme:()=>xh,isPdfFile:()=>ud,noContextMenu:()=>Ve,normalizeUnicode:()=>rg,setLayerDimensions:()=>Xn,shadow:()=>ot,version:()=>_m});const le=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),su=[1,0,0,1,0,0],$h=[.001,0,0,.001,0,0],Vp=1e7,Ih=1.35,Fe={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},di={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},qp="pdfjs_internal_editor_",tt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},K={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35},Xp={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},ee={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},vl={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Ot={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,WIDGET:20},wa={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},yh={ERRORS:0,WARNINGS:1,INFOS:5},Xe={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},Yp={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let vh=yh.WARNINGS;function Kp(c){Number.isInteger(c)&&(vh=c)}function Qp(){return vh}function wh(c){vh>=yh.INFOS&&console.log(`Info: ${c}`)}function st(c){vh>=yh.WARNINGS&&console.log(`Warning: ${c}`)}function wt(c){throw new Error(c)}function jt(c,t){c||wt(t)}function Jp(c){switch(c==null?void 0:c.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Zp(c,t=null,e=null){if(!c)return null;try{if(e&&typeof c=="string"){if(e.addDefaultProtocol&&c.startsWith("www.")){const i=c.match(/\./g);(i==null?void 0:i.length)>=2&&(c=`http://${c}`)}if(e.tryConvertEncoding)try{c=ng(c)}catch{}}const s=t?new URL(c,t):new URL(c);if(Jp(s))return s}catch{}return null}function ot(c,t,e,s=!1){return Object.defineProperty(c,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Gi=function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();class zh extends Gi{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Gh extends Gi{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class iu extends Gi{constructor(t){super(t,"InvalidPDFException")}}class tr extends Gi{constructor(t){super(t,"MissingPDFException")}}class _h extends Gi{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class tg extends Gi{constructor(t){super(t,"FormatError")}}class er extends Gi{constructor(t){super(t,"AbortException")}}function nu(c){(typeof c!="object"||(c==null?void 0:c.length)===void 0)&&wt("Invalid argument for bytesToString");const t=c.length,e=8192;if(t>24&255,c>>16&255,c>>8&255,c&255)}function hd(c){const t=Object.create(null);for(const[e,s]of c)t[e]=s;return t}function sg(){const c=new Uint8Array(4);return c[0]=1,new Uint32Array(c.buffer,0,1)[0]===1}function ig(){try{return new Function(""),!0}catch{return!1}}class fe{static get isLittleEndian(){return ot(this,"isLittleEndian",sg())}static get isEvalSupported(){return ot(this,"isEvalSupported",ig())}static get isOffscreenCanvasSupported(){return ot(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.platform)=="string"?ot(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof(navigator==null?void 0:navigator.userAgent)=="string"&&navigator.userAgent.includes("Firefox")}):ot(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){var t,e;return ot(this,"isCSSRoundSupported",(e=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const Fh=Array.from(Array(256).keys(),c=>c.toString(16).padStart(2,"0"));var ri,wl,Uh;class j{static makeHexColor(t,e,s){return`#${Fh[t]}${Fh[e]}${Fh[s]}`}static scaleMinMax(t,e){let s;t[0]?(t[0]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[3],e[3]*=t[3]):(s=e[0],e[0]=e[1],e[1]=s,s=e[2],e[2]=e[3],e[3]=s,t[1]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){const s=t[0]*e[0]+t[1]*e[2]+e[4],i=t[0]*e[1]+t[1]*e[3]+e[5];return[s,i]}static applyInverseTransform(t,e){const s=e[0]*e[3]-e[1]*e[2],i=(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/s,n=(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s;return[i,n]}static getAxialAlignedBoundingBox(t,e){const s=this.applyTransform(t,e),i=this.applyTransform(t.slice(2,4),e),n=this.applyTransform([t[0],t[3]],e),a=this.applyTransform([t[2],t[1]],e);return[Math.min(s[0],i[0],n[0],a[0]),Math.min(s[1],i[1],n[1],a[1]),Math.max(s[0],i[0],n[0],a[0]),Math.max(s[1],i[1],n[1],a[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],s=t[0]*e[0]+t[1]*e[2],i=t[0]*e[1]+t[1]*e[3],n=t[2]*e[0]+t[3]*e[2],a=t[2]*e[1]+t[3]*e[3],o=(s+a)/2,l=Math.sqrt((s+a)**2-4*(s*a-n*i))/2,h=o+l||1,d=o-l||1;return[Math.sqrt(h),Math.sqrt(d)]}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>a?null:[s,n,i,a]}static bezierBoundingBox(t,e,s,i,n,a,o,l,h){return h?(h[0]=Math.min(h[0],t,o),h[1]=Math.min(h[1],e,l),h[2]=Math.max(h[2],t,o),h[3]=Math.max(h[3],e,l)):h=[Math.min(t,o),Math.min(e,l),Math.max(t,o),Math.max(e,l)],m(this,ri,Uh).call(this,t,s,n,o,e,i,a,l,3*(-t+3*(s-n)+o),6*(t-2*s+n),3*(s-t),h),m(this,ri,Uh).call(this,t,s,n,o,e,i,a,l,3*(-e+3*(i-a)+l),6*(e-2*i+a),3*(i-e),h),h}}ri=new WeakSet,wl=function(t,e,s,i,n,a,o,l,h,d){if(h<=0||h>=1)return;const u=1-h,f=h*h,g=f*h,A=u*(u*(u*t+3*h*e)+3*f*s)+g*i,y=u*(u*(u*n+3*h*a)+3*f*o)+g*l;d[0]=Math.min(d[0],A),d[1]=Math.min(d[1],y),d[2]=Math.max(d[2],A),d[3]=Math.max(d[3],y)},Uh=function(t,e,s,i,n,a,o,l,h,d,u,f){if(Math.abs(h)<1e-12){Math.abs(d)>=1e-12&&m(this,ri,wl).call(this,t,e,s,i,n,a,o,l,-u/d,f);return}const g=d**2-4*u*h;if(g<0)return;const A=Math.sqrt(g),y=2*h;m(this,ri,wl).call(this,t,e,s,i,n,a,o,l,(-d+A)/y,f),m(this,ri,wl).call(this,t,e,s,i,n,a,o,l,(-d-A)/y,f)},b(j,ri);function ng(c){return decodeURIComponent(escape(c))}let Dh=null,Cd=null;function rg(c){return Dh||(Dh=/([\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,Cd=new Map([["ſt","ſt"]])),c.replaceAll(Dh,(t,e,s)=>e?e.normalize("NFKC"):Cd.get(s))}function ag(){if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.randomUUID)=="function")return crypto.randomUUID();const c=new Uint8Array(32);if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.getRandomValues)=="function")crypto.getRandomValues(c);else for(let t=0;t<32;t++)c[t]=Math.floor(Math.random()*255);return nu(c)}const cd="pdfjs_internal_id_",Rs={BEZIER_CURVE_TO:0,MOVE_TO:1,LINE_TO:2,QUADRATIC_CURVE_TO:3,RESTORE:4,SAVE:5,SCALE:6,TRANSFORM:7,TRANSLATE:8};function og(c){return Uint8Array.prototype.toBase64?c.toBase64():btoa(nu(c))}const ks="http://www.w3.org/2000/svg",Yi=class Yi{};Y(Yi,"CSS",96),Y(Yi,"PDF",72),Y(Yi,"PDF_TO_CSS_UNITS",Yi.CSS/Yi.PDF);let Bi=Yi;async function Sh(c,t="text"){if(Sa(c,document.baseURI)){const e=await fetch(c);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",c,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class al{constructor({viewBox:t,scale:e,rotation:s,offsetX:i=0,offsetY:n=0,dontFlip:a=!1}){this.viewBox=t,this.scale=e,this.rotation=s,this.offsetX=i,this.offsetY=n;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let h,d,u,f;switch(s%=360,s<0&&(s+=360),s){case 180:h=-1,d=0,u=0,f=1;break;case 90:h=0,d=1,u=1,f=0;break;case 270:h=0,d=-1,u=-1,f=0;break;case 0:h=1,d=0,u=0,f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(u=-u,f=-f);let g,A,y,w;h===0?(g=Math.abs(l-t[1])*e+i,A=Math.abs(o-t[0])*e+n,y=(t[3]-t[1])*e,w=(t[2]-t[0])*e):(g=Math.abs(o-t[0])*e+i,A=Math.abs(l-t[1])*e+n,y=(t[2]-t[0])*e,w=(t[3]-t[1])*e),this.transform=[h*e,d*e,u*e,f*e,g-h*e*o-u*e*l,A-d*e*o-f*e*l],this.width=y,this.height=w}get rawDims(){const{viewBox:t}=this;return ot(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new al({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){return j.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=j.applyTransform([t[0],t[1]],this.transform),s=j.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return j.applyInverseTransform([t,e],this.transform)}}class dd extends Gi{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function xh(c){const t=c.length;let e=0;for(;e=1&&i<=12?i-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let 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 d=parseInt(e[8],10);d=d>=0&&d<=23?d:0;let u=parseInt(e[9],10)||0;return u=u>=0&&u<=59?u:0,h==="-"?(a+=d,o+=u):h==="+"&&(a-=d,o-=u),new Date(Date.UTC(s,i,n,a,o,l))}}Ua=new WeakMap,b(fd,Ua);function cg(c,{scale:t=1,rotation:e=0}){const{width:s,height:i}=c.attributes.style,n=[0,0,parseInt(s),parseInt(i)];return new al({viewBox:n,scale:t,rotation:e})}function pd(c){if(c.startsWith("#")){const t=parseInt(c.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return c.startsWith("rgb(")?c.slice(4,-1).split(",").map(t=>parseInt(t)):c.startsWith("rgba(")?c.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(st(`Not a valid color format: "${c}"`),[0,0,0])}function dg(c){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const e of c.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;c.set(e,pd(s))}t.remove()}function Tt(c){const{a:t,b:e,c:s,d:i,e:n,f:a}=c.getTransform();return[t,e,s,i,n,a]}function Ps(c){const{a:t,b:e,c:s,d:i,e:n,f:a}=c.getTransform().invertSelf();return[t,e,s,i,n,a]}function Xn(c,t,e=!1,s=!0){if(t instanceof al){const{pageWidth:i,pageHeight:n}=t.rawDims,{style:a}=c,o=fe.isCSSRoundSupported,l=`var(--scale-factor) * ${i}px`,h=`var(--scale-factor) * ${n}px`,d=o?`round(down, ${l}, var(--scale-round-x, 1px))`:`calc(${l})`,u=o?`round(down, ${h}, var(--scale-round-y, 1px))`:`calc(${h})`;!e||t.rotation%180===0?(a.width=d,a.height=u):(a.width=u,a.height=d)}s&&c.setAttribute("data-main-rotation",t.rotation)}class Wh{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}}var ui,Qi,Ye,Ji,Wa,Va,eh,ru,pe,au,ou,_l,lu,qh;const Ls=class Ls{constructor(t){b(this,pe);b(this,ui,null);b(this,Qi,null);b(this,Ye);b(this,Ji,null);b(this,Wa,null);p(this,Ye,t),r(Ls,Va)||p(Ls,Va,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"}))}render(){const t=p(this,ui,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=r(this,Ye)._uiManager._signal;t.addEventListener("contextmenu",Ve,{signal:e}),t.addEventListener("pointerdown",m(Ls,eh,ru),{signal:e});const s=p(this,Ji,document.createElement("div"));s.className="buttons",t.append(s);const i=r(this,Ye).toolbarPosition;if(i){const{style:n}=t,a=r(this,Ye)._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=`${100*a}%`,n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return m(this,pe,lu).call(this),t}get div(){return r(this,ui)}hide(){var t;r(this,ui).classList.add("hidden"),(t=r(this,Qi))==null||t.hideDropdown()}show(){var t;r(this,ui).classList.remove("hidden"),(t=r(this,Wa))==null||t.shown()}async addAltText(t){const e=await t.render();m(this,pe,_l).call(this,e),r(this,Ji).prepend(e,r(this,pe,qh)),p(this,Wa,t)}addColorPicker(t){p(this,Qi,t);const e=t.renderButton();m(this,pe,_l).call(this,e),r(this,Ji).prepend(e,r(this,pe,qh))}remove(){var t;r(this,ui).remove(),(t=r(this,Qi))==null||t.destroy(),p(this,Qi,null)}};ui=new WeakMap,Qi=new WeakMap,Ye=new WeakMap,Ji=new WeakMap,Wa=new WeakMap,Va=new WeakMap,eh=new WeakSet,ru=function(t){t.stopPropagation()},pe=new WeakSet,au=function(t){r(this,Ye)._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()},ou=function(t){r(this,Ye)._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()},_l=function(t){const e=r(this,Ye)._uiManager._signal;t.addEventListener("focusin",m(this,pe,au).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",m(this,pe,ou).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Ve,{signal:e})},lu=function(){const{editorType:t,_uiManager:e}=r(this,Ye),s=document.createElement("button");s.className="delete",s.tabIndex=0,s.setAttribute("data-l10n-id",r(Ls,Va)[t]),m(this,pe,_l).call(this,s),s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),r(this,Ji).append(s)},qh=function(){const t=document.createElement("div");return t.className="divider",t},b(Ls,eh),b(Ls,Va,null);let Vh=Ls;var qa,Zi,tn,$i,hu,cu,du;class ug{constructor(t){b(this,$i);b(this,qa,null);b(this,Zi,null);b(this,tn);p(this,tn,t)}show(t,e,s){const[i,n]=m(this,$i,cu).call(this,e,s),{style:a}=r(this,Zi)||p(this,Zi,m(this,$i,hu).call(this));t.append(r(this,Zi)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){r(this,Zi).remove()}}qa=new WeakMap,Zi=new WeakMap,tn=new WeakMap,$i=new WeakSet,hu=function(){const t=p(this,Zi,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",Ve,{signal:r(this,tn)._signal});const e=p(this,qa,document.createElement("div"));return e.className="buttons",t.append(e),m(this,$i,du).call(this),t},cu=function(t,e){let s=0,i=0;for(const n of t){const a=n.y+n.height;if(as){i=o,s=a;continue}e?o>i&&(i=o):o{r(this,tn).highlightSelection("floating_button")},{signal:s}),r(this,qa).append(t)};function Kl(c,t,e){for(const s of e)t.addEventListener(s,c[s].bind(c))}function fg(c){return Math.round(Math.min(255,Math.max(1,255*c))).toString(16).padStart(2,"0")}var sh;class pg{constructor(){b(this,sh,0)}get id(){return`${qp}${he(this,sh)._++}`}}sh=new WeakMap;var yr,Xa,ie,vr,El;const _d=class _d{constructor(){b(this,vr);b(this,yr,ag());b(this,Xa,0);b(this,ie,null)}static get _isSVGFittingCanvas(){const t='data:image/svg+xml;charset=UTF-8,',s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;const n=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return ot(this,"_isSVGFittingCanvas",n)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return m(this,vr,El).call(this,`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return m(this,vr,El).call(this,t,t)}async getFromBlob(t,e){const s=await e;return m(this,vr,El).call(this,t,s)}async getFromId(t){r(this,ie)||p(this,ie,new Map);const e=r(this,ie).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:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){r(this,ie)||p(this,ie,new Map);let s=r(this,ie).get(t);if(s!=null&&s.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${r(this,yr)}_${he(this,Xa)._++}`,refCounter:1,isSvg:!1},r(this,ie).set(t,s),r(this,ie).set(s.id,s),s}getSvgUrl(t){const e=r(this,ie).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;r(this,ie)||p(this,ie,new Map);const e=r(this,ie).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const n=new OffscreenCanvas(s.width,s.height);n.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=n.convertToBlob()}(i=s.close)==null||i.call(s),e.bitmap=null}isValidId(t){return t.startsWith(`image_${r(this,yr)}_`)}};yr=new WeakMap,Xa=new WeakMap,ie=new WeakMap,vr=new WeakSet,El=async function(t,e){r(this,ie)||p(this,ie,new Map);let s=r(this,ie).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${r(this,yr)}_${he(this,Xa)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await Sh(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const n=_d._isSVGFittingCanvas,a=new FileReader,o=new Image,l=new Promise((h,d)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,h()},a.onload=async()=>{const u=s.svgUrl=a.result;o.src=await n?`${u}#svgView(preserveAspectRatio(none))`:u},o.onerror=a.onerror=d});a.readAsDataURL(i),await l}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){console.error(i),s=null}return r(this,ie).set(t,s),s&&r(this,ie).set(s.id,s),s};let Xh=_d;var Ut,fi,Ya,Wt;class gg{constructor(t=128){b(this,Ut,[]);b(this,fi,!1);b(this,Ya);b(this,Wt,-1);p(this,Ya,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&t(),r(this,fi))return;const l={cmd:t,undo:e,post:s,type:n};if(r(this,Wt)===-1){r(this,Ut).length>0&&(r(this,Ut).length=0),p(this,Wt,0),r(this,Ut).push(l);return}if(a&&r(this,Ut)[r(this,Wt)].type===n){o&&(l.undo=r(this,Ut)[r(this,Wt)].undo),r(this,Ut)[r(this,Wt)]=l;return}const h=r(this,Wt)+1;h===r(this,Ya)?r(this,Ut).splice(0,1):(p(this,Wt,h),hn===e[a]))return nh._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?j.makeHexColor(...e):t}};Y(nh,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let Yh=nh;var wr,Ce,Nt,Kt,_r,Is,Er,Ke,pi,Sr,en,cs,Qe,sn,Ka,Qa,xr,Ja,ds,gi,Cr,mi,us,rh,bi,Za,Ai,nn,to,eo,Vt,ut,Fs,rn,so,io,yi,fs,Ds,no,He,D,Sl,Kh,fu,pu,xl,gu,mu,bu,Qh,Au,Jh,Zh,yu,ce,hi,vu,wu,tc,_u,xa,ec;const pr=class pr{constructor(t,e,s,i,n,a,o,l,h,d,u){b(this,D);b(this,wr,new AbortController);b(this,Ce,null);b(this,Nt,new Map);b(this,Kt,new Map);b(this,_r,null);b(this,Is,null);b(this,Er,null);b(this,Ke,new gg);b(this,pi,null);b(this,Sr,0);b(this,en,new Set);b(this,cs,null);b(this,Qe,null);b(this,sn,new Set);b(this,Ka,!1);b(this,Qa,!1);b(this,xr,!1);b(this,Ja,null);b(this,ds,null);b(this,gi,null);b(this,Cr,null);b(this,mi,!1);b(this,us,null);b(this,rh,new pg);b(this,bi,!1);b(this,Za,!1);b(this,Ai,null);b(this,nn,null);b(this,to,null);b(this,eo,null);b(this,Vt,tt.NONE);b(this,ut,new Set);b(this,Fs,null);b(this,rn,null);b(this,so,null);b(this,io,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});b(this,yi,[0,0]);b(this,fs,null);b(this,Ds,null);b(this,no,null);b(this,He,null);const f=this._signal=r(this,wr).signal;p(this,Ds,t),p(this,no,e),p(this,_r,s),this._eventBus=i,i._on("editingaction",this.onEditingAction.bind(this),{signal:f}),i._on("pagechanging",this.onPageChanging.bind(this),{signal:f}),i._on("scalechanging",this.onScaleChanging.bind(this),{signal:f}),i._on("rotationchanging",this.onRotationChanging.bind(this),{signal:f}),i._on("setpreference",this.onSetPreference.bind(this),{signal:f}),i._on("switchannotationeditorparams",g=>this.updateParams(g.type,g.value),{signal:f}),m(this,D,gu).call(this),m(this,D,yu).call(this),m(this,D,Qh).call(this),p(this,Is,n.annotationStorage),p(this,Ja,n.filterFactory),p(this,rn,a),p(this,Cr,o||null),p(this,Ka,l),p(this,Qa,h),p(this,xr,d),p(this,eo,u||null),this.viewParameters={realScale:Bi.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}static get _keyboardManager(){const t=pr.prototype,e=a=>r(a,Ds).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),s=(a,{target:o})=>{if(o instanceof HTMLInputElement){const{type:l}=o;return l!=="text"&&l!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return ot(this,"_keyboardManager",new ol([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&r(a,Ds).contains(o)&&!a.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&r(a,Ds).contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}destroy(){var t,e,s,i;(t=r(this,He))==null||t.resolve(),p(this,He,null),(e=r(this,wr))==null||e.abort(),p(this,wr,null),this._signal=null;for(const n of r(this,Kt).values())n.destroy();r(this,Kt).clear(),r(this,Nt).clear(),r(this,sn).clear(),p(this,Ce,null),r(this,ut).clear(),r(this,Ke).destroy(),(s=r(this,_r))==null||s.destroy(),(i=r(this,us))==null||i.hide(),p(this,us,null),r(this,ds)&&(clearTimeout(r(this,ds)),p(this,ds,null)),r(this,fs)&&(clearTimeout(r(this,fs)),p(this,fs,null))}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return r(this,eo)}get useNewAltTextFlow(){return r(this,Qa)}get useNewAltTextWhenAddingImage(){return r(this,xr)}get hcmFilter(){return ot(this,"hcmFilter",r(this,rn)?r(this,Ja).addHCMFilter(r(this,rn).foreground,r(this,rn).background):"none")}get direction(){return ot(this,"direction",getComputedStyle(r(this,Ds)).direction)}get highlightColors(){return ot(this,"highlightColors",r(this,Cr)?new Map(r(this,Cr).split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return ot(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setMainHighlightColorPicker(t){p(this,to,t)}editAltText(t,e=!1){var s;(s=r(this,_r))==null||s.editAltText(this,t,e)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":p(this,xr,e);break}}onPageChanging({pageNumber:t}){p(this,Sr,t-1)}focusMainContainer(){r(this,Ds).focus()}findParent(t,e){for(const s of r(this,Kt).values()){const{x:i,y:n,width:a,height:o}=s.div.getBoundingClientRect();if(t>=i&&t<=i+a&&e>=n&&e<=n+o)return s}return null}disableUserSelect(t=!1){r(this,no).classList.toggle("noUserSelect",t)}addShouldRescale(t){r(this,sn).add(t)}removeShouldRescale(t){r(this,sn).delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Bi.PDF_TO_CSS_UNITS;for(const e of r(this,sn))e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:a}=e,o=e.toString(),h=m(this,D,Sl).call(this,e).closest(".textLayer"),d=this.getSelectionBoxes(h);if(!d)return;e.empty();const u=m(this,D,Kh).call(this,h),f=r(this,Vt)===tt.NONE,g=()=>{u==null||u.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:a,text:o}),f&&this.showAllEditors("highlight",!0,!0)};if(f){this.switchToMode(tt.HIGHLIGHT,g);return}g()}addToAnnotationStorage(t){!t.isEmpty()&&r(this,Is)&&!r(this,Is).has(t.id)&&r(this,Is).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,r(this,mi)&&(p(this,mi,!1),m(this,D,xl).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of r(this,ut))if(e.div.contains(t)){p(this,nn,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!r(this,nn))return;const[t,e]=r(this,nn);p(this,nn,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){m(this,D,Qh).call(this),m(this,D,Jh).call(this)}removeEditListeners(){m(this,D,Au).call(this),m(this,D,Zh).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of r(this,Qe))if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of r(this,Qe))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=r(this,Ce))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of r(this,ut)){const n=i.serialize(!0);n&&e.push(n)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const n of e.items)for(const a of r(this,Qe))if(a.isHandlingMimeForPasting(n.type)){a.paste(n,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){st(`paste: "${n.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const n=[];for(const l of s){const h=await i.deserialize(l);if(!h)return;n.push(h)}const a=()=>{for(const l of n)m(this,D,tc).call(this,l);m(this,D,ec).call(this,n)},o=()=>{for(const l of n)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(n){st(`paste: "${n.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),r(this,Vt)!==tt.NONE&&!this.isEditorHandlingKeyboard&&pr._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,r(this,mi)&&(p(this,mi,!1),m(this,D,xl).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}}setEditingState(t){t?(m(this,D,mu).call(this),m(this,D,Jh).call(this),m(this,D,ce).call(this,{isEditing:r(this,Vt)!==tt.NONE,isEmpty:m(this,D,xa).call(this),hasSomethingToUndo:r(this,Ke).hasSomethingToUndo(),hasSomethingToRedo:r(this,Ke).hasSomethingToRedo(),hasSelectedEditor:!1})):(m(this,D,bu).call(this),m(this,D,Zh).call(this),m(this,D,ce).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!r(this,Qe)){p(this,Qe,t);for(const e of r(this,Qe))m(this,D,hi).call(this,e.defaultPropertiesToUpdate)}}getId(){return r(this,rh).id}get currentLayer(){return r(this,Kt).get(r(this,Sr))}getLayer(t){return r(this,Kt).get(t)}get currentPageIndex(){return r(this,Sr)}addLayer(t){r(this,Kt).set(t.pageIndex,t),r(this,bi)?t.enable():t.disable()}removeLayer(t){r(this,Kt).delete(t.pageIndex)}async updateMode(t,e=null,s=!1){if(r(this,Vt)!==t&&!(r(this,He)&&(await r(this,He).promise,!r(this,He)))){if(p(this,He,Promise.withResolvers()),p(this,Vt,t),t===tt.NONE){this.setEditingState(!1),m(this,D,wu).call(this),r(this,He).resolve();return}this.setEditingState(!0),await m(this,D,vu).call(this),this.unselectAll();for(const i of r(this,Kt).values())i.updateMode(t);if(!e){s&&this.addNewEditorFromKeyboard(),r(this,He).resolve();return}for(const i of r(this,Nt).values())i.annotationElementId===e?(this.setSelected(i),i.enterInEditMode()):i.unselect();r(this,He).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==r(this,Vt)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){var s;if(r(this,Qe)){switch(t){case K.CREATE:this.currentLayer.addNewEditor();return;case K.HIGHLIGHT_DEFAULT_COLOR:(s=r(this,to))==null||s.updateColor(e);break;case K.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(r(this,so)||p(this,so,new Map)).set(t,e),this.showAllEditors("highlight",e);break}for(const i of r(this,ut))i.updateParams(t,e);for(const i of r(this,Qe))i.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var n;for(const a of r(this,Nt).values())a.editorType===t&&a.show(e);(((n=r(this,so))==null?void 0:n.get(K.HIGHLIGHT_SHOW_ALL))??!0)!==e&&m(this,D,hi).call(this,[[K.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(r(this,Za)!==t){p(this,Za,t);for(const e of r(this,Kt).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const s of r(this,Nt).values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return r(this,Nt).get(t)}addEditor(t){r(this,Nt).set(t.id,t)}removeEditor(t){var e;t.div.contains(document.activeElement)&&(r(this,ds)&&clearTimeout(r(this,ds)),p(this,ds,setTimeout(()=>{this.focusMainContainer(),p(this,ds,null)},0))),r(this,Nt).delete(t.id),this.unselect(t),(!t.annotationElementId||!r(this,en).has(t.annotationElementId))&&((e=r(this,Is))==null||e.remove(t.id))}addDeletedAnnotationElement(t){r(this,en).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return r(this,en).has(t)}removeDeletedAnnotationElement(t){r(this,en).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){r(this,Ce)!==t&&(p(this,Ce,t),t&&m(this,D,hi).call(this,t.propertiesToUpdate))}updateUI(t){r(this,D,_u)===t&&m(this,D,hi).call(this,t.propertiesToUpdate)}toggleSelected(t){if(r(this,ut).has(t)){r(this,ut).delete(t),t.unselect(),m(this,D,ce).call(this,{hasSelectedEditor:this.hasSelection});return}r(this,ut).add(t),t.select(),m(this,D,hi).call(this,t.propertiesToUpdate),m(this,D,ce).call(this,{hasSelectedEditor:!0})}setSelected(t){for(const e of r(this,ut))e!==t&&e.unselect();r(this,ut).clear(),r(this,ut).add(t),t.select(),m(this,D,hi).call(this,t.propertiesToUpdate),m(this,D,ce).call(this,{hasSelectedEditor:!0})}isSelected(t){return r(this,ut).has(t)}get firstSelectedEditor(){return r(this,ut).values().next().value}unselect(t){t.unselect(),r(this,ut).delete(t),m(this,D,ce).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return r(this,ut).size!==0}get isEnterHandled(){return r(this,ut).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){r(this,Ke).undo(),m(this,D,ce).call(this,{hasSomethingToUndo:r(this,Ke).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:m(this,D,xa).call(this)})}redo(){r(this,Ke).redo(),m(this,D,ce).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:r(this,Ke).hasSomethingToRedo(),isEmpty:m(this,D,xa).call(this)})}addCommands(t){r(this,Ke).add(t),m(this,D,ce).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:m(this,D,xa).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...r(this,ut)],e=()=>{for(const i of t)i.remove()},s=()=>{for(const i of t)m(this,D,tc).call(this,i)};this.addCommands({cmd:e,undo:s,mustExec:!0})}commitOrRemove(){var t;(t=r(this,Ce))==null||t.commitOrRemove()}hasSomethingToControl(){return r(this,Ce)||this.hasSelection}selectAll(){for(const t of r(this,ut))t.commit();m(this,D,ec).call(this,r(this,Nt).values())}unselectAll(){if(!(r(this,Ce)&&(r(this,Ce).commitOrRemove(),r(this,Vt)!==tt.NONE))&&this.hasSelection){for(const t of r(this,ut))t.unselect();r(this,ut).clear(),m(this,D,ce).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;r(this,yi)[0]+=t,r(this,yi)[1]+=e;const[i,n]=r(this,yi),a=[...r(this,ut)],o=1e3;r(this,fs)&&clearTimeout(r(this,fs)),p(this,fs,setTimeout(()=>{p(this,fs,null),r(this,yi)[0]=r(this,yi)[1]=0,this.addCommands({cmd:()=>{for(const l of a)r(this,Nt).has(l.id)&&l.translateInPage(i,n)},undo:()=>{for(const l of a)r(this,Nt).has(l.id)&&l.translateInPage(-i,-n)},mustExec:!1})},o));for(const l of a)l.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),p(this,cs,new Map);for(const t of r(this,ut))r(this,cs).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!r(this,cs))return!1;this.disableUserSelect(!1);const t=r(this,cs);p(this,cs,null);let e=!1;for(const[{x:i,y:n,pageIndex:a},o]of t)o.newX=i,o.newY=n,o.newPageIndex=a,e||(e=i!==o.savedX||n!==o.savedY||a!==o.savedPageIndex);if(!e)return!1;const s=(i,n,a,o)=>{if(r(this,Nt).has(i.id)){const l=r(this,Kt).get(o);l?i._setParentAndPosition(l,n,a):(i.pageIndex=o,i.x=n,i.y=a)}};return this.addCommands({cmd:()=>{for(const[i,{newX:n,newY:a,newPageIndex:o}]of t)s(i,n,a,o)},undo:()=>{for(const[i,{savedX:n,savedY:a,savedPageIndex:o}]of t)s(i,n,a,o)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(r(this,cs))for(const s of r(this,cs).keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||r(this,ut).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return r(this,Ce)===t}getActive(){return r(this,Ce)}getMode(){return r(this,Vt)}get imageManager(){return ot(this,"imageManager",new Xh)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let h=0,d=e.rangeCount;h({x:(d-i)/a,y:1-(h+u-s)/n,width:f/a,height:u/n});break;case"180":o=(h,d,u,f)=>({x:1-(h+u-s)/n,y:1-(d+f-i)/a,width:u/n,height:f/a});break;case"270":o=(h,d,u,f)=>({x:1-(d+f-i)/a,y:(h-s)/n,width:f/a,height:u/n});break;default:o=(h,d,u,f)=>({x:(h-s)/n,y:(d-i)/a,width:u/n,height:f/a});break}const l=[];for(let h=0,d=e.rangeCount;h{f.type==="pointerup"&&f.button!==0||(h.abort(),l==null||l.toggleDrawing(!0),f.type==="pointerup"&&m(this,D,xl).call(this,"main_toolbar"))};window.addEventListener("pointerup",u,{signal:d}),window.addEventListener("blur",u,{signal:d})}},xl=function(t=""){r(this,Vt)===tt.HIGHLIGHT?this.highlightSelection(t):r(this,Ka)&&m(this,D,fu).call(this)},gu=function(){document.addEventListener("selectionchange",m(this,D,pu).bind(this),{signal:this._signal})},mu=function(){if(r(this,gi))return;p(this,gi,new AbortController);const t=this.combinedSignal(r(this,gi));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},bu=function(){var t;(t=r(this,gi))==null||t.abort(),p(this,gi,null)},Qh=function(){if(r(this,Ai))return;p(this,Ai,new AbortController);const t=this.combinedSignal(r(this,Ai));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},Au=function(){var t;(t=r(this,Ai))==null||t.abort(),p(this,Ai,null)},Jh=function(){if(r(this,pi))return;p(this,pi,new AbortController);const t=this.combinedSignal(r(this,pi));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})},Zh=function(){var t;(t=r(this,pi))==null||t.abort(),p(this,pi,null)},yu=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},ce=function(t){Object.entries(t).some(([s,i])=>r(this,io)[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(r(this,io),t)}),r(this,Vt)===tt.HIGHLIGHT&&t.hasSelectedEditor===!1&&m(this,D,hi).call(this,[[K.HIGHLIGHT_FREE,!0]]))},hi=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},vu=async function(){if(!r(this,bi)){p(this,bi,!0);const t=[];for(const e of r(this,Kt).values())t.push(e.enable());await Promise.all(t);for(const e of r(this,Nt).values())e.enable()}},wu=function(){if(this.unselectAll(),r(this,bi)){p(this,bi,!1);for(const t of r(this,Kt).values())t.disable();for(const t of r(this,Nt).values())t.disable()}},tc=function(t){const e=r(this,Kt).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},_u=function(){let t=null;for(t of r(this,ut));return t},xa=function(){if(r(this,Nt).size===0)return!0;if(r(this,Nt).size===1)for(const t of r(this,Nt).values())return t.isEmpty();return!1},ec=function(t){for(const e of r(this,ut))e.unselect();r(this,ut).clear();for(const e of t)e.isEmpty()||(r(this,ut).add(e),e.select());m(this,D,ce).call(this,{hasSelectedEditor:this.hasSelection})},Y(pr,"TRANSLATE_SMALL",1),Y(pr,"TRANSLATE_BIG",10);let Yn=pr;var qt,ps,Je,Tr,gs,Te,Rr,ms,ve,Os,an,bs,vi,ls,Ca,Cl;const de=class de{constructor(t){b(this,ls);b(this,qt,null);b(this,ps,!1);b(this,Je,null);b(this,Tr,null);b(this,gs,null);b(this,Te,null);b(this,Rr,!1);b(this,ms,null);b(this,ve,null);b(this,Os,null);b(this,an,null);b(this,bs,!1);p(this,ve,t),p(this,bs,t._uiManager.useNewAltTextFlow),r(de,vi)||p(de,vi,Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(t){de._l10n??(de._l10n=t)}async render(){const t=p(this,Je,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=p(this,Tr,document.createElement("span"));t.append(e),r(this,bs)?(t.classList.add("new"),t.setAttribute("data-l10n-id",r(de,vi).missing),e.setAttribute("data-l10n-id",r(de,vi)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=r(this,ve)._uiManager._signal;t.addEventListener("contextmenu",Ve,{signal:s}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),r(this,ve)._uiManager.editAltText(r(this,ve)),r(this,bs)&&r(this,ve)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:r(this,ls,Ca)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(p(this,Rr,!0),i(n))},{signal:s}),await m(this,ls,Cl).call(this),t}finish(){r(this,Je)&&(r(this,Je).focus({focusVisible:r(this,Rr)}),p(this,Rr,!1))}isEmpty(){return r(this,bs)?r(this,qt)===null:!r(this,qt)&&!r(this,ps)}hasData(){return r(this,bs)?r(this,qt)!==null||!!r(this,Os):this.isEmpty()}get guessedText(){return r(this,Os)}async setGuessedText(t){r(this,qt)===null&&(p(this,Os,t),p(this,an,await de._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),m(this,ls,Cl).call(this))}toggleAltTextBadge(t=!1){var e;if(!r(this,bs)||r(this,qt)){(e=r(this,ms))==null||e.remove(),p(this,ms,null);return}if(!r(this,ms)){const s=p(this,ms,document.createElement("div"));s.className="noAltTextBadge",r(this,ve).div.append(s)}r(this,ms).classList.toggle("hidden",!t)}serialize(t){let e=r(this,qt);return!t&&r(this,Os)===e&&(e=r(this,an)),{altText:e,decorative:r(this,ps),guessedText:r(this,Os),textWithDisclaimer:r(this,an)}}get data(){return{altText:r(this,qt),decorative:r(this,ps)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:n=!1}){s&&(p(this,Os,s),p(this,an,i)),!(r(this,qt)===t&&r(this,ps)===e)&&(n||(p(this,qt,t),p(this,ps,e)),m(this,ls,Cl).call(this))}toggle(t=!1){r(this,Je)&&(!t&&r(this,Te)&&(clearTimeout(r(this,Te)),p(this,Te,null)),r(this,Je).disabled=!t)}shown(){r(this,ve)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:r(this,ls,Ca)}})}destroy(){var t,e;(t=r(this,Je))==null||t.remove(),p(this,Je,null),p(this,Tr,null),p(this,gs,null),(e=r(this,ms))==null||e.remove(),p(this,ms,null)}};qt=new WeakMap,ps=new WeakMap,Je=new WeakMap,Tr=new WeakMap,gs=new WeakMap,Te=new WeakMap,Rr=new WeakMap,ms=new WeakMap,ve=new WeakMap,Os=new WeakMap,an=new WeakMap,bs=new WeakMap,vi=new WeakMap,ls=new WeakSet,Ca=function(){return r(this,qt)&&"added"||r(this,qt)===null&&this.guessedText&&"review"||"missing"},Cl=async function(){var i,n,a;const t=r(this,Je);if(!t)return;if(r(this,bs)){if(t.classList.toggle("done",!!r(this,qt)),t.setAttribute("data-l10n-id",r(de,vi)[r(this,ls,Ca)]),(i=r(this,Tr))==null||i.setAttribute("data-l10n-id",r(de,vi)[`${r(this,ls,Ca)}-label`]),!r(this,qt)){(n=r(this,gs))==null||n.remove();return}}else{if(!r(this,qt)&&!r(this,ps)){t.classList.remove("done"),(a=r(this,gs))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=r(this,gs);if(!e){p(this,gs,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${r(this,ve).id}`;const o=100,l=r(this,ve)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(r(this,Te)),p(this,Te,null)},{once:!0}),t.addEventListener("mouseenter",()=>{p(this,Te,setTimeout(()=>{p(this,Te,null),r(this,gs).classList.add("show"),r(this,ve)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var h;r(this,Te)&&(clearTimeout(r(this,Te)),p(this,Te,null)),(h=r(this,gs))==null||h.classList.remove("show")},{signal:l})}r(this,ps)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=r(this,qt)),e.parentNode||t.append(e);const s=r(this,ve).getImageForAltText();s==null||s.setAttribute("aria-describedby",e.id)},b(de,vi,null),Y(de,"_l10n",null);let Ql=de;var on,Ze,xt,Pr,ln,Qt,hn,wi,ro,cn,_i,ao,dn,Ns,As,kr,Lr,Be,oo,ah,et,sc,lo,ic,nc,Eu,Su,rc,ac,oc,xu,lc,Cu,Tu,Ru,hc,Ta;const ct=class ct{constructor(t){b(this,et);b(this,on,null);b(this,Ze,null);b(this,xt,null);b(this,Pr,!1);b(this,ln,!1);b(this,Qt,null);b(this,hn,null);b(this,wi,null);b(this,ro,"");b(this,cn,!1);b(this,_i,null);b(this,ao,!1);b(this,dn,!1);b(this,Ns,!1);b(this,As,null);b(this,kr,0);b(this,Lr,0);b(this,Be,null);Y(this,"_editToolbar",null);Y(this,"_initialOptions",Object.create(null));Y(this,"_initialData",null);Y(this,"_isVisible",!0);Y(this,"_uiManager",null);Y(this,"_focusEventsAllowed",!0);b(this,oo,!1);b(this,ah,ct._zIndex++);this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[n,a];const[o,l]=this.parentDimensions;this.x=t.x/o,this.y=t.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=ct.prototype._resizeWithKeyboard,e=Yn.TRANSLATE_SMALL,s=Yn.TRANSLATE_BIG;return ot(this,"_resizerKeyboardManager",new ol([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape","mac+Escape"],ct.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return ot(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new mg({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(ct._l10n??(ct._l10n=t),ct._l10nResizer||(ct._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"})),ct._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);ct._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){wt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return r(this,oo)}set _isDraggable(t){var e;p(this,oo,t),(e=this.div)==null||e.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=r(this,ah)}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):m(this,et,Ta).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(r(this,cn)?p(this,cn,!1):this.parent.setSelected(this))}focusout(t){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const e=t.relatedTarget;e!=null&&e.closest(`#${this.id}`)||(t.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[n,a]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/a,this.fixAndSetPosition()}translate(t,e){m(this,et,sc).call(this,this.parentDimensions,t,e)}translateInPage(t,e){r(this,_i)||p(this,_i,[this.x,this.y]),m(this,et,sc).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){r(this,_i)||p(this,_i,[this.x,this.y]);const[s,i]=this.parentDimensions;if(this.x+=t/s,this.y+=e/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:h,y:d}=this.div.getBoundingClientRect();this.parent.findNewParent(this,h,d)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:a}=this;const[o,l]=this.getBaseTranslation();n+=o,a+=l,this.div.style.left=`${(100*n).toFixed(2)}%`,this.div.style.top=`${(100*a).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!r(this,_i)&&(r(this,_i)[0]!==this.x||r(this,_i)[1]!==this.y)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=ct,i=s/t,n=s/e;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const[e,s]=this.pageDimensions;let{x:i,y:n,width:a,height:o}=this;if(a*=e,o*=s,i*=e,n*=s,this._mustFixPosition)switch(t){case 0:i=Math.max(0,Math.min(e-a,i)),n=Math.max(0,Math.min(s-o,n));break;case 90:i=Math.max(0,Math.min(e-o,i)),n=Math.min(s,Math.max(a,n));break;case 180:i=Math.min(e,Math.max(a,i)),n=Math.min(s,Math.max(o,n));break;case 270:i=Math.min(e,Math.max(o,i)),n=Math.max(0,Math.min(s-a,n));break}this.x=i/=e,this.y=n/=s;const[l,h]=this.getBaseTranslation();i+=l,n+=h;const{style:d}=this.div;d.left=`${(100*i).toFixed(2)}%`,d.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var s;return m(s=ct,lo,ic).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return m(s=ct,lo,ic).call(s,t,e,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,s]}=this;return[e*t,s*t]}setDims(t,e){const[s,i]=this.parentDimensions;this.div.style.width=`${(100*t/s).toFixed(2)}%`,r(this,ln)||(this.div.style.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),n=!r(this,ln)&&e.endsWith("%");if(i&&n)return;const[a,o]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/a).toFixed(2)}%`),!r(this,ln)&&!n&&(t.height=`${(100*parseFloat(e)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}altTextFinish(){var t;(t=r(this,xt))==null||t.finish()}async addEditToolbar(){return this._editToolbar||r(this,dn)?this._editToolbar:(this._editToolbar=new Vh(this),this.div.append(this._editToolbar.render()),r(this,xt)&&await this._editToolbar.addAltText(r(this,xt)),this._editToolbar)}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,(t=r(this,xt))==null||t.destroy())}addContainer(t){var s;const e=(s=this._editToolbar)==null?void 0:s.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){r(this,xt)||(Ql.initialize(ct._l10n),p(this,xt,new Ql(this)),r(this,on)&&(r(this,xt).data=r(this,on),p(this,on,null)),await this.addEditToolbar())}get altTextData(){var t;return(t=r(this,xt))==null?void 0:t.data}set altTextData(t){r(this,xt)&&(r(this,xt).data=t)}get guessedAltText(){var t;return(t=r(this,xt))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=r(this,xt))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=r(this,xt))==null?void 0:e.serialize(t)}hasAltText(){return!!r(this,xt)&&!r(this,xt).isEmpty()}hasAltTextData(){var t;return((t=r(this,xt))==null?void 0:t.hasData())??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=r(this,Pr)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),m(this,et,lc).call(this);const[t,e]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);const[s,i]=this.getInitialTranslation();return this.translate(s,i),Kl(this,this.div,["pointerdown"]),this.div}pointerdown(t){const{isMac:e}=fe.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(p(this,cn,!0),this._isDraggable){m(this,et,xu).call(this,t);return}m(this,et,oc).call(this,t)}get isSelected(){return this._uiManager.isSelected(this)}moveInDOM(){r(this,As)&&clearTimeout(r(this,As)),p(this,As,setTimeout(()=>{var t;p(this,As,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition()}getRect(t,e,s=this.rotation){const i=this.parentScale,[n,a]=this.pageDimensions,[o,l]=this.pageTranslation,h=t/i,d=e/i,u=this.x*n,f=this.y*a,g=this.width*n,A=this.height*a;switch(s){case 0:return[u+h+o,a-f-d-A+l,u+h+g+o,a-f-d+l];case 90:return[u+d+o,a-f+h+l,u+d+A+o,a-f+h+g+l];case 180:return[u-h-g+o,a-f+d+l,u-h+o,a-f+d+A+l];case 270:return[u-d-A+o,a-f-h-g+l,u-d+o,a-f-h+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,a]=t,o=n-s,l=a-i;switch(this.rotation){case 0:return[s,e-a,o,l];case 90:return[s,e-i,l,o];case 180:return[n,e-i,o,l];case 270:return[n,e-a,l,o];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){p(this,dn,!0)}disableEditMode(){p(this,dn,!1)}isInEditMode(){return r(this,dn)}shouldGetKeyboardEvents(){return r(this,Ns)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){m(this,et,lc).call(this)}rotate(t){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((t=this._initialData)==null?void 0:t.popupRef)||""}}serialize(t=!1,e=null){wt("An editor must be serializable")}static async deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s});i.rotation=t.rotation,p(i,on,t.accessibilityData);const[n,a]=i.pageDimensions,[o,l,h,d]=i.getRectInCurrentCoords(t.rect,a);return i.x=o/n,i.y=l/a,i.width=h/n,i.height=d/a,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t;if((t=r(this,wi))==null||t.abort(),p(this,wi,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),r(this,As)&&(clearTimeout(r(this,As)),p(this,As,null)),m(this,et,Ta).call(this),this.removeEditToolbar(),r(this,Be)){for(const e of r(this,Be).values())clearTimeout(e);p(this,Be,null)}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(m(this,et,Eu).call(this),r(this,Qt).classList.remove("hidden"),Kl(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),p(this,hn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=r(this,Qt).children;if(!r(this,Ze)){p(this,Ze,Array.from(e));const a=m(this,et,Cu).bind(this),o=m(this,et,Tu).bind(this),l=this._uiManager._signal;for(const h of r(this,Ze)){const d=h.getAttribute("data-resizer-name");h.setAttribute("role","spinbutton"),h.addEventListener("keydown",a,{signal:l}),h.addEventListener("blur",o,{signal:l}),h.addEventListener("focus",m(this,et,Ru).bind(this,d),{signal:l}),h.setAttribute("data-l10n-id",ct._l10nResizer[d])}}const s=r(this,Ze)[0];let i=0;for(const a of e){if(a===s)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(r(this,Ze).length/4);if(n!==i){if(ni)for(let o=0;o{var i,n;(i=this.div)!=null&&i.classList.contains("selectedEditor")&&((n=this._editToolbar)==null||n.show())});return}(e=this._editToolbar)==null||e.show(),(s=r(this,xt))==null||s.toggleAltTextBadge(!1)}unselect(){var t,e,s,i,n;(t=r(this,Qt))==null||t.classList.add("hidden"),(e=this.div)==null||e.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(i=this._editToolbar)==null||i.hide(),(n=r(this,xt))==null||n.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return r(this,ao)}set isEditing(t){p(this,ao,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){p(this,ln,!0);const s=t/e,{style:i}=this.div;i.aspectRatio=s,i.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){r(this,Be)||p(this,Be,new Map);const{action:s}=t;let i=r(this,Be).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),r(this,Be).delete(s),r(this,Be).size===0&&p(this,Be,null)},ct._telemetryTimeout),r(this,Be).set(s,i);return}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),p(this,Pr,!1)}disable(){this.div&&(this.div.tabIndex=-1),p(this,Pr,!0)}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstChild:e}=t.container;(e==null?void 0:e.nodeName)==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};on=new WeakMap,Ze=new WeakMap,xt=new WeakMap,Pr=new WeakMap,ln=new WeakMap,Qt=new WeakMap,hn=new WeakMap,wi=new WeakMap,ro=new WeakMap,cn=new WeakMap,_i=new WeakMap,ao=new WeakMap,dn=new WeakMap,Ns=new WeakMap,As=new WeakMap,kr=new WeakMap,Lr=new WeakMap,Be=new WeakMap,oo=new WeakMap,ah=new WeakMap,et=new WeakSet,sc=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this.fixAndSetPosition()},lo=new WeakSet,ic=function(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},nc=function(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}},Eu=function(){if(r(this,Qt))return;p(this,Qt,document.createElement("div")),r(this,Qt).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const s of t){const i=document.createElement("div");r(this,Qt).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",m(this,et,Su).bind(this,s),{signal:e}),i.addEventListener("contextmenu",Ve,{signal:e}),i.tabIndex=-1}this.div.prepend(r(this,Qt))},Su=function(t,e){var A;e.preventDefault();const{isMac:s}=fe.platform;if(e.button!==0||e.ctrlKey&&s)return;(A=r(this,xt))==null||A.toggle(!1);const i=this._isDraggable;this._isDraggable=!1;const n=new AbortController,a=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",m(this,et,ac).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("contextmenu",Ve,{signal:a});const o=this.x,l=this.y,h=this.width,d=this.height,u=this.parent.div.style.cursor,f=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const g=()=>{var y;n.abort(),this.parent.togglePointerEvents(!0),(y=r(this,xt))==null||y.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=u,this.div.style.cursor=f,m(this,et,rc).call(this,o,l,h,d)};window.addEventListener("pointerup",g,{signal:a}),window.addEventListener("blur",g,{signal:a})},rc=function(t,e,s,i){const n=this.x,a=this.y,o=this.width,l=this.height;n===t&&a===e&&o===s&&l===i||this.addCommands({cmd:()=>{this.width=o,this.height=l,this.x=n,this.y=a;const[h,d]=this.parentDimensions;this.setDims(h*o,d*l),this.fixAndSetPosition()},undo:()=>{this.width=s,this.height=i,this.x=t,this.y=e;const[h,d]=this.parentDimensions;this.setDims(h*s,d*i),this.fixAndSetPosition()},mustExec:!0})},ac=function(t,e){const[s,i]=this.parentDimensions,n=this.x,a=this.y,o=this.width,l=this.height,h=ct.MIN_SIZE/s,d=ct.MIN_SIZE/i,u=H=>Math.round(H*1e4)/1e4,f=m(this,et,nc).call(this,this.rotation),g=(H,$)=>[f[0]*H+f[2]*$,f[1]*H+f[3]*$],A=m(this,et,nc).call(this,360-this.rotation),y=(H,$)=>[A[0]*H+A[2]*$,A[1]*H+A[3]*$];let w,v,_=!1,S=!1;switch(t){case"topLeft":_=!0,w=(H,$)=>[0,0],v=(H,$)=>[H,$];break;case"topMiddle":w=(H,$)=>[H/2,0],v=(H,$)=>[H/2,$];break;case"topRight":_=!0,w=(H,$)=>[H,0],v=(H,$)=>[0,$];break;case"middleRight":S=!0,w=(H,$)=>[H,$/2],v=(H,$)=>[0,$/2];break;case"bottomRight":_=!0,w=(H,$)=>[H,$],v=(H,$)=>[0,0];break;case"bottomMiddle":w=(H,$)=>[H/2,$],v=(H,$)=>[H/2,0];break;case"bottomLeft":_=!0,w=(H,$)=>[0,$],v=(H,$)=>[H,0];break;case"middleLeft":S=!0,w=(H,$)=>[0,$/2],v=(H,$)=>[H,$/2];break}const E=w(o,l),C=v(o,l);let x=g(...C);const T=u(n+x[0]),P=u(a+x[1]);let L=1,O=1,[F,J]=this.screenToPageTranslation(e.movementX,e.movementY);if([F,J]=y(F/s,J/i),_){const H=Math.hypot(o,l);L=O=Math.max(Math.min(Math.hypot(C[0]-E[0]-F,C[1]-E[1]-J)/H,1/o,1/l),h/o,d/l)}else S?L=Math.max(h,Math.min(1,Math.abs(C[0]-E[0]-F)))/o:O=Math.max(d,Math.min(1,Math.abs(C[1]-E[1]-J)))/l;const U=u(o*L),z=u(l*O);x=g(...v(U,z));const X=T-x[0],q=P-x[1];this.width=U,this.height=z,this.x=X,this.y=q,this.setDims(s*U,i*z),this.fixAndSetPosition()},oc=function(t){const{isMac:e}=fe.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},xu=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();const s=new AbortController,i=this._uiManager.combinedSignal(s);if(e){this.div.classList.add("moving"),p(this,kr,t.clientX),p(this,Lr,t.clientY);const a=o=>{const{clientX:l,clientY:h}=o,[d,u]=this.screenToPageTranslation(l-r(this,kr),h-r(this,Lr));p(this,kr,l),p(this,Lr,h),this._uiManager.dragSelectedEditors(d,u)};window.addEventListener("pointermove",a,{passive:!0,capture:!0,signal:i})}const n=()=>{s.abort(),e&&this.div.classList.remove("moving"),p(this,cn,!1),this._uiManager.endDragSession()||m(this,et,oc).call(this,t)};window.addEventListener("pointerup",n,{signal:i}),window.addEventListener("blur",n,{signal:i})},lc=function(){if(r(this,wi)||!this.div)return;p(this,wi,new AbortController);const t=this._uiManager.combinedSignal(r(this,wi));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Cu=function(t){ct._resizerKeyboardManager.exec(this,t)},Tu=function(t){var e;r(this,Ns)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==r(this,Qt)&&m(this,et,Ta).call(this)},Ru=function(t){p(this,ro,r(this,Ns)?t:"")},hc=function(t){if(r(this,Ze))for(const e of r(this,Ze))e.tabIndex=t},Ta=function(){if(p(this,Ns,!1),m(this,et,hc).call(this,-1),r(this,hn)){const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=r(this,hn);m(this,et,rc).call(this,t,e,s,i),p(this,hn,null)}},b(ct,lo),Y(ct,"_l10n",null),Y(ct,"_l10nResizer",null),Y(ct,"_borderLineWidth",-1),Y(ct,"_colorManager",new Yh),Y(ct,"_zIndex",1),Y(ct,"_telemetryTimeout",1e3);let pt=ct;class mg extends pt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Pd=3285377520,Ne=4294901760,hs=65535;class Pu{constructor(t){this.h1=t?t&4294967295:Pd,this.h2=t?t&4294967295:Pd}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let y=0,w=t.length;y>>8,e[s++]=v&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,n=s-i*4,a=new Uint32Array(e.buffer,0,i);let o=0,l=0,h=this.h1,d=this.h2;const u=3432918353,f=461845907,g=u&hs,A=f&hs;for(let y=0;y>>17,o=o*f&Ne|o*A&hs,h^=o,h=h<<13|h>>>19,h=h*5+3864292196):(l=a[y],l=l*u&Ne|l*g&hs,l=l<<15|l>>>17,l=l*f&Ne|l*A&hs,d^=l,d=d<<13|d>>>19,d=d*5+3864292196);switch(o=0,n){case 3:o^=e[i*4+2]<<16;case 2:o^=e[i*4+1]<<8;case 1:o^=e[i*4],o=o*u&Ne|o*g&hs,o=o<<15|o>>>17,o=o*f&Ne|o*A&hs,i&1?h^=o:d^=o}this.h1=h,this.h2=d}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Ne|t*36045&hs,e=e*4283543511&Ne|((e<<16|t>>>16)*2950163797&Ne)>>>16,t^=e>>>1,t=t*444984403&Ne|t*60499&hs,e=e*3301882366&Ne|((e<<16|t>>>16)*3120437893&Ne)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const cc=Object.freeze({map:null,hash:"",transfer:void 0});var un,fn,Xt,oh,ku;class gd{constructor(){b(this,oh);b(this,un,!1);b(this,fn,null);b(this,Xt,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=r(this,Xt).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return r(this,Xt).get(t)}remove(t){if(r(this,Xt).delete(t),r(this,Xt).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of r(this,Xt).values())if(e instanceof pt)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=r(this,Xt).get(t);let i=!1;if(s!==void 0)for(const[n,a]of Object.entries(e))s[n]!==a&&(i=!0,s[n]=a);else i=!0,r(this,Xt).set(t,e);i&&m(this,oh,ku).call(this),e instanceof pt&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return r(this,Xt).has(t)}getAll(){return r(this,Xt).size>0?hd(r(this,Xt)):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return r(this,Xt).size}resetModified(){r(this,un)&&(p(this,un,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Lu(this)}get serializable(){if(r(this,Xt).size===0)return cc;const t=new Map,e=new Pu,s=[],i=Object.create(null);let n=!1;for(const[a,o]of r(this,Xt)){const l=o instanceof pt?o.serialize(!1,i):o;l&&(t.set(a,l),e.update(`${a}:${JSON.stringify(l)}`),n||(n=!!l.bitmap))}if(n)for(const a of t.values())a.bitmap&&s.push(a.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:cc}get editorStats(){let t=null;const e=new Map;for(const s of r(this,Xt).values()){if(!(s instanceof pt))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:n}=i;e.has(n)||e.set(n,Object.getPrototypeOf(s).constructor),t||(t=Object.create(null));const a=t[n]||(t[n]=new Map);for(const[o,l]of Object.entries(i)){if(o==="type")continue;let h=a.get(o);h||(h=new Map,a.set(o,h));const d=h.get(l)??0;h.set(l,d+1)}}for(const[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}resetModifiedIds(){p(this,fn,null)}get modifiedIds(){if(r(this,fn))return r(this,fn);const t=[];for(const e of r(this,Xt).values())!(e instanceof pt)||!e.annotationElementId||!e.serialize()||t.push(e.annotationElementId);return p(this,fn,{ids:new Set(t),hash:t.join(",")})}}un=new WeakMap,fn=new WeakMap,Xt=new WeakMap,oh=new WeakSet,ku=function(){r(this,un)||(p(this,un,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var ho;class Lu extends gd{constructor(e){super();b(this,ho);const{map:s,hash:i,transfer:n}=e.serializable,a=structuredClone(s,n?{transfer:n}:null);p(this,ho,{map:a,hash:i,transfer:n})}get print(){wt("Should not call PrintAnnotationStorage.print")}get serializable(){return r(this,ho)}get modifiedIds(){return ot(this,"modifiedIds",{ids:new Set,hash:""})}}ho=new WeakMap;var Mr;class bg{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){b(this,Mr,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(),r(this,Mr).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||r(this,Mr).has(t.loadedName))){if(jt(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:i,style:n}=t,a=new FontFace(s,i,n);this.addNativeFontFace(a);try{await a.load(),r(this,Mr).add(s),e==null||e(t)}catch{st(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}wt("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw st(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){var e;const t=!!((e=this._document)!=null&&e.fonts);return ot(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(le||typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.userAgent)=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),ot(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(jt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const n=s.shift();setTimeout(n.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return ot(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(E,C){return E.charCodeAt(C)<<24|E.charCodeAt(C+1)<<16|E.charCodeAt(C+2)<<8|E.charCodeAt(C+3)&255}function i(E,C,x,T){const P=E.substring(0,C),L=E.substring(C+x);return P+T+L}let n,a;const o=this._document.createElement("canvas");o.width=1,o.height=1;const l=o.getContext("2d");let h=0;function d(E,C){if(++h>30){st("Load test font never loaded."),C();return}if(l.font="30px "+E,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){C();return}setTimeout(d.bind(null,E,C))}const u=`lt${Date.now()}${this.loadTestFontId++}`;let f=this._loadTestFont;f=i(f,976,u.length,u);const A=16,y=1482184792;let w=s(f,A);for(n=0,a=u.length-3;n{S.remove(),e.complete()})}}Mr=new WeakMap;class Ag{constructor(t,{disableFontFace:e=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const i in t)this[i]=t[i];this.disableFontFace=e===!0,this._inspectFont=s}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,s)}return(e=this._inspectFont)==null||e.call(this,this),t}createFontFaceRule(){var s;if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${og(this.data)});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`}return(s=this._inspectFont)==null||s.call(this,this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];let s;try{s=t.get(this.loadedName+"_path_"+e)}catch(n){st(`getPathGenerator - ignoring character: "${n}".`)}if(!Array.isArray(s)||s.length===0)return this.compiledGlyphs[e]=function(n,a){};const i=[];for(let n=0,a=s.length;ng.bezierCurveTo(o,l,h,d,u,f)),n+=6}break;case Rs.MOVE_TO:{const[o,l]=s.slice(n,n+2);i.push(h=>h.moveTo(o,l)),n+=2}break;case Rs.LINE_TO:{const[o,l]=s.slice(n,n+2);i.push(h=>h.lineTo(o,l)),n+=2}break;case Rs.QUADRATIC_CURVE_TO:{const[o,l,h,d]=s.slice(n,n+4);i.push(u=>u.quadraticCurveTo(o,l,h,d)),n+=4}break;case Rs.RESTORE:i.push(o=>o.restore());break;case Rs.SAVE:i.push(o=>o.save());break;case Rs.SCALE:jt(i.length===2,"Scale command is only valid at the third position.");break;case Rs.TRANSFORM:{const[o,l,h,d,u,f]=s.slice(n,n+6);i.push(g=>g.transform(o,l,h,d,u,f)),n+=6}break;case Rs.TRANSLATE:{const[o,l]=s.slice(n,n+2);i.push(h=>h.translate(o,l)),n+=2}break}return this.compiledGlyphs[e]=function(a,o){i[0](a),i[1](a),a.scale(o,-o);for(let l=2,h=i.length;l({cMapData:s,isCompressed:this.isCompressed})).catch(s=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){wt("Abstract method `_fetch` called.")}}class Fu extends Iu{async _fetch(t){const e=await Sh(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):Eh(e)}}class Du{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,n){return"none"}destroy(t=!1){}}var pn,gn,ys,Hs,ne,lh,mn,N,se,ar,or,Tl,lr,Ou,dc,hr,Ra,Pa,uc,ka;class vg extends Du{constructor({docId:e,ownerDocument:s=globalThis.document}){super();b(this,N);b(this,pn);b(this,gn);b(this,ys);b(this,Hs);b(this,ne);b(this,lh);b(this,mn,0);p(this,Hs,e),p(this,ne,s)}addFilter(e){if(!e)return"none";let s=r(this,N,se).get(e);if(s)return s;const[i,n,a]=m(this,N,Tl).call(this,e),o=e.length===1?i:`${i}${n}${a}`;if(s=r(this,N,se).get(o),s)return r(this,N,se).set(e,s),s;const l=`g_${r(this,Hs)}_transfer_map_${he(this,mn)._++}`,h=m(this,N,lr).call(this,l);r(this,N,se).set(e,h),r(this,N,se).set(o,h);const d=m(this,N,hr).call(this,l);return m(this,N,Pa).call(this,i,n,a,d),h}addHCMFilter(e,s){var A;const i=`${e}-${s}`,n="base";let a=r(this,N,ar).get(n);if((a==null?void 0:a.key)===i||(a?((A=a.filter)==null||A.remove(),a.key=i,a.url="none",a.filter=null):(a={key:i,url:"none",filter:null},r(this,N,ar).set(n,a)),!e||!s))return a.url;const o=m(this,N,ka).call(this,e);e=j.makeHexColor(...o);const l=m(this,N,ka).call(this,s);if(s=j.makeHexColor(...l),r(this,N,or).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return a.url;const h=new Array(256);for(let y=0;y<=255;y++){const w=y/255;h[y]=w<=.03928?w/12.92:((w+.055)/1.055)**2.4}const d=h.join(","),u=`g_${r(this,Hs)}_hcm_filter`,f=a.filter=m(this,N,hr).call(this,u);m(this,N,Pa).call(this,d,d,d,f),m(this,N,dc).call(this,f);const g=(y,w)=>{const v=o[y]/255,_=l[y]/255,S=new Array(w+1);for(let E=0;E<=w;E++)S[E]=v+E/w*(_-v);return S.join(",")};return m(this,N,Pa).call(this,g(0,5),g(1,5),g(2,5),f),a.url=m(this,N,lr).call(this,u),a.url}addAlphaFilter(e){let s=r(this,N,se).get(e);if(s)return s;const[i]=m(this,N,Tl).call(this,[e]),n=`alpha_${i}`;if(s=r(this,N,se).get(n),s)return r(this,N,se).set(e,s),s;const a=`g_${r(this,Hs)}_alpha_map_${he(this,mn)._++}`,o=m(this,N,lr).call(this,a);r(this,N,se).set(e,o),r(this,N,se).set(n,o);const l=m(this,N,hr).call(this,a);return m(this,N,uc).call(this,i,l),o}addLuminosityFilter(e){let s=r(this,N,se).get(e||"luminosity");if(s)return s;let i,n;if(e?([i]=m(this,N,Tl).call(this,[e]),n=`luminosity_${i}`):n="luminosity",s=r(this,N,se).get(n),s)return r(this,N,se).set(e,s),s;const a=`g_${r(this,Hs)}_luminosity_map_${he(this,mn)._++}`,o=m(this,N,lr).call(this,a);r(this,N,se).set(e,o),r(this,N,se).set(n,o);const l=m(this,N,hr).call(this,a);return m(this,N,Ou).call(this,l),e&&m(this,N,uc).call(this,i,l),o}addHighlightHCMFilter(e,s,i,n,a){var _;const o=`${s}-${i}-${n}-${a}`;let l=r(this,N,ar).get(e);if((l==null?void 0:l.key)===o||(l?((_=l.filter)==null||_.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},r(this,N,ar).set(e,l)),!s||!i))return l.url;const[h,d]=[s,i].map(m(this,N,ka).bind(this));let u=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),f=Math.round(.2126*d[0]+.7152*d[1]+.0722*d[2]),[g,A]=[n,a].map(m(this,N,ka).bind(this));f{const x=new Array(256),T=(f-u)/C,P=S/255,L=(E-S)/(255*C);let O=0;for(let F=0;F<=C;F++){const J=Math.round(u+F*T),U=P+F*L;for(let z=O;z<=J;z++)x[z]=U;O=J+1}for(let F=O;F<256;F++)x[F]=x[O-1];return x.join(",")},w=`g_${r(this,Hs)}_hcm_${e}_filter`,v=l.filter=m(this,N,hr).call(this,w);return m(this,N,dc).call(this,v),m(this,N,Pa).call(this,y(g[0],A[0],5),y(g[1],A[1],5),y(g[2],A[2],5),v),l.url=m(this,N,lr).call(this,w),l.url}destroy(e=!1){e&&r(this,N,ar).size!==0||(r(this,ys)&&(r(this,ys).parentNode.parentNode.remove(),p(this,ys,null)),r(this,gn)&&(r(this,gn).clear(),p(this,gn,null)),p(this,mn,0))}}pn=new WeakMap,gn=new WeakMap,ys=new WeakMap,Hs=new WeakMap,ne=new WeakMap,lh=new WeakMap,mn=new WeakMap,N=new WeakSet,se=function(){return r(this,gn)||p(this,gn,new Map)},ar=function(){return r(this,lh)||p(this,lh,new Map)},or=function(){if(!r(this,ys)){const e=r(this,ne).createElement("div"),{style:s}=e;s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const i=r(this,ne).createElementNS(ks,"svg");i.setAttribute("width",0),i.setAttribute("height",0),p(this,ys,r(this,ne).createElementNS(ks,"defs")),e.append(i),i.append(r(this,ys)),r(this,ne).body.append(e)}return r(this,ys)},Tl=function(e){if(e.length===1){const h=e[0],d=new Array(256);for(let f=0;f<256;f++)d[f]=h[f]/255;const u=d.join(",");return[u,u,u]}const[s,i,n]=e,a=new Array(256),o=new Array(256),l=new Array(256);for(let h=0;h<256;h++)a[h]=s[h]/255,o[h]=i[h]/255,l[h]=n[h]/255;return[a.join(","),o.join(","),l.join(",")]},lr=function(e){if(r(this,pn)===void 0){p(this,pn,"");const s=r(this,ne).URL;s!==r(this,ne).baseURI&&(xh(s)?st('#createUrl: ignore "data:"-URL for performance reasons.'):p(this,pn,s.split("#",1)[0]))}return`url(${r(this,pn)}#${e})`},Ou=function(e){const s=r(this,ne).createElementNS(ks,"feColorMatrix");s.setAttribute("type","matrix"),s.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"),e.append(s)},dc=function(e){const s=r(this,ne).createElementNS(ks,"feColorMatrix");s.setAttribute("type","matrix"),s.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"),e.append(s)},hr=function(e){const s=r(this,ne).createElementNS(ks,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),r(this,N,or).append(s),s},Ra=function(e,s,i){const n=r(this,ne).createElementNS(ks,s);n.setAttribute("type","discrete"),n.setAttribute("tableValues",i),e.append(n)},Pa=function(e,s,i,n){const a=r(this,ne).createElementNS(ks,"feComponentTransfer");n.append(a),m(this,N,Ra).call(this,a,"feFuncR",e),m(this,N,Ra).call(this,a,"feFuncG",s),m(this,N,Ra).call(this,a,"feFuncB",i)},uc=function(e,s){const i=r(this,ne).createElementNS(ks,"feComponentTransfer");s.append(i),m(this,N,Ra).call(this,i,"feFuncA",e)},ka=function(e){return r(this,N,or).style.color=e,pd(getComputedStyle(r(this,N,or)).getPropertyValue("color"))};class Nu{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(s=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){wt("Abstract method `_fetch` called.")}}class Hu extends Nu{async _fetch(t){const e=await Sh(t,"arraybuffer");return new Uint8Array(e)}}if(le){var fc=Promise.withResolvers(),$a=null;(async()=>{const t=await fl(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),e=await fl(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),s=await fl(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),i=await fl(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]);let n,a;return new Map(Object.entries({fs:t,http:e,https:s,url:i,canvas:n,path2d:a}))})().then(t=>{$a=t,fc.resolve()},t=>{st(`loadPackages: ${t}`),$a=new Map,fc.resolve()})}class ji{static get promise(){return fc.promise}static get(t){return $a==null?void 0:$a.get(t)}}async function Bu(c){const e=await ji.get("fs").promises.readFile(c);return new Uint8Array(e)}class wg extends Du{}class _g extends Mu{_createCanvas(t,e){return ji.get("canvas").createCanvas(t,e)}}class Eg extends Iu{async _fetch(t){return Bu(t)}}class Sg extends Nu{async _fetch(t){return Bu(t)}}const ue={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function pc(c,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),c.clip(i)}class md{getPattern(){wt("Abstract method `getPattern` called.")}}class xg extends md{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)e.addColorStop(s[0],s[1]);return e}getPattern(t,e,s,i){let n;if(i===ue.STROKE||i===ue.FILL){const a=e.current.getClippedPathBoundingBox(i,Tt(t))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,l=Math.ceil(a[3]-a[1])||1,h=e.cachedCanvases.getCanvas("pattern",o,l),d=h.context;d.clearRect(0,0,d.canvas.width,d.canvas.height),d.beginPath(),d.rect(0,0,d.canvas.width,d.canvas.height),d.translate(-a[0],-a[1]),s=j.transform(s,[1,0,0,1,a[0],a[1]]),d.transform(...e.baseTransform),this.matrix&&d.transform(...this.matrix),pc(d,this._bbox),d.fillStyle=this._createGradient(d),d.fill(),n=t.createPattern(h.canvas,"no-repeat");const u=new DOMMatrix(s);n.setTransform(u)}else pc(t,this._bbox),n=this._createGradient(t);return n}}function Oh(c,t,e,s,i,n,a,o){const l=t.coords,h=t.colors,d=c.data,u=c.width*4;let f;l[e+1]>l[s+1]&&(f=e,e=s,s=f,f=n,n=a,a=f),l[s+1]>l[i+1]&&(f=s,s=i,i=f,f=a,a=o,o=f),l[e+1]>l[s+1]&&(f=e,e=s,s=f,f=n,n=a,a=f);const g=(l[e]+t.offsetX)*t.scaleX,A=(l[e+1]+t.offsetY)*t.scaleY,y=(l[s]+t.offsetX)*t.scaleX,w=(l[s+1]+t.offsetY)*t.scaleY,v=(l[i]+t.offsetX)*t.scaleX,_=(l[i+1]+t.offsetY)*t.scaleY;if(A>=_)return;const S=h[n],E=h[n+1],C=h[n+2],x=h[a],T=h[a+1],P=h[a+2],L=h[o],O=h[o+1],F=h[o+2],J=Math.round(A),U=Math.round(_);let z,X,q,H,$,B,V,rt;for(let M=J;M<=U;M++){if(M_?nt=1:w===_?nt=0:nt=(w-M)/(w-_),z=y-(y-v)*nt,X=x-(x-L)*nt,q=T-(T-O)*nt,H=P-(P-F)*nt}let W;M_?W=1:W=(A-M)/(A-_),$=g-(g-v)*W,B=S-(S-L)*W,V=E-(E-O)*W,rt=C-(C-F)*W;const lt=Math.round(Math.min(z,$)),gt=Math.round(Math.max(z,$));let dt=u*M+lt*4;for(let nt=lt;nt<=gt;nt++)W=(z-nt)/(z-$),W<0?W=0:W>1&&(W=1),d[dt++]=X-(X-B)*W|0,d[dt++]=q-(q-V)*W|0,d[dt++]=H-(H-rt)*W|0,d[dt++]=255}}function Cg(c,t,e){const s=t.coords,i=t.colors;let n,a;switch(t.type){case"lattice":const o=t.verticesPerRow,l=Math.floor(s.length/o)-1,h=o-1;for(n=0;n=O?E=l:x=!0,L>=F?C=h:T=!0;const J=this.getSizeAndScale(E,this.ctx.canvas.width,_),U=this.getSizeAndScale(C,this.ctx.canvas.height,S),z=t.cachedCanvases.getCanvas("pattern",J.size,U.size),X=z.context,q=o.createCanvasGraphics(X);if(q.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(q,i,a),X.translate(-J.scale*d,-U.scale*u),q.transform(J.scale,0,0,U.scale,0,0),X.save(),this.clipBbox(q,d,u,f,g),q.baseTransform=Tt(q.ctx),q.executeOperatorList(s),q.endDrawing(),X.restore(),x||T){const H=z.canvas;x&&(E=l),T&&(C=h);const $=this.getSizeAndScale(E,this.ctx.canvas.width,_),B=this.getSizeAndScale(C,this.ctx.canvas.height,S),V=$.size,rt=B.size,M=t.cachedCanvases.getCanvas("pattern-workaround",V,rt),W=M.context,lt=x?Math.floor(A/l):0,gt=T?Math.floor(y/h):0;for(let dt=0;dt<=lt;dt++)for(let nt=0;nt<=gt;nt++)W.drawImage(H,V*dt,rt*nt,V,rt,0,0,V,rt);return{canvas:M.canvas,scaleX:$.scale,scaleY:B.scale,offsetX:d,offsetY:u}}return{canvas:z.canvas,scaleX:J.scale,scaleY:U.scale,offsetX:d,offsetY:u}}getSizeAndScale(t,e,s){const i=Math.max(hh.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*s);return n>=i?n=i:s=n/t,{scale:s,size:n}}clipBbox(t,e,s,i,n){const a=i-e,o=n-s;t.ctx.rect(e,s,a,o),t.current.updateRectMinMax(Tt(t.ctx),[e,s,i,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,n=t.current;switch(e){case kd.COLORED:const a=this.ctx;i.fillStyle=a.fillStyle,i.strokeStyle=a.strokeStyle,n.fillColor=a.fillStyle,n.strokeColor=a.strokeStyle;break;case kd.UNCOLORED:const o=j.makeHexColor(s[0],s[1],s[2]);i.fillStyle=o,i.strokeStyle=o,n.fillColor=o,n.strokeColor=o;break;default:throw new tg(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,i){let n=s;i!==ue.SHADING&&(n=j.transform(n,e.baseTransform),this.matrix&&(n=j.transform(n,this.matrix)));const a=this.createPatternCanvas(e);let o=new DOMMatrix(n);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}};Y(hh,"MAX_PATTERN_SIZE",3e3);let gc=hh;function kg({src:c,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:a=!1}){const o=fe.isLittleEndian?4278190080:255,[l,h]=a?[n,o]:[o,n],d=s>>3,u=s&7,f=c.length;e=new Uint32Array(e.buffer);let g=0;for(let A=0;A{c.save=c.__originalSave,c.restore=c.__originalRestore,c.rotate=c.__originalRotate,c.scale=c.__originalScale,c.translate=c.__originalTranslate,c.transform=c.__originalTransform,c.setTransform=c.__originalSetTransform,c.resetTransform=c.__originalResetTransform,c.clip=c.__originalClip,c.moveTo=c.__originalMoveTo,c.lineTo=c.__originalLineTo,c.bezierCurveTo=c.__originalBezierCurveTo,c.rect=c.__originalRect,c.closePath=c.__originalClosePath,c.beginPath=c.__originalBeginPath,delete c._removeMirroring},c.save=function(){t.save(),this.__originalSave()},c.restore=function(){t.restore(),this.__originalRestore()},c.translate=function(s,i){t.translate(s,i),this.__originalTranslate(s,i)},c.scale=function(s,i){t.scale(s,i),this.__originalScale(s,i)},c.transform=function(s,i,n,a,o,l){t.transform(s,i,n,a,o,l),this.__originalTransform(s,i,n,a,o,l)},c.setTransform=function(s,i,n,a,o,l){t.setTransform(s,i,n,a,o,l),this.__originalSetTransform(s,i,n,a,o,l)},c.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},c.rotate=function(s){t.rotate(s),this.__originalRotate(s)},c.clip=function(s){t.clip(s),this.__originalClip(s)},c.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},c.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},c.bezierCurveTo=function(e,s,i,n,a,o){t.bezierCurveTo(e,s,i,n,a,o),this.__originalBezierCurveTo(e,s,i,n,a,o)},c.rect=function(e,s,i,n){t.rect(e,s,i,n),this.__originalRect(e,s,i,n)},c.closePath=function(){t.closePath(),this.__originalClosePath()},c.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class Ig{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s){let i;return this.cache[t]!==void 0?(i=this.cache[t],this.canvasFactory.reset(i,e,s)):(i=this.canvasFactory.create(e,s),this.cache[t]=i),i}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function pl(c,t,e,s,i,n,a,o,l,h){const[d,u,f,g,A,y]=Tt(c);if(u===0&&f===0){const _=a*d+A,S=Math.round(_),E=o*g+y,C=Math.round(E),x=(a+l)*d+A,T=Math.abs(Math.round(x)-S)||1,P=(o+h)*g+y,L=Math.abs(Math.round(P)-C)||1;return c.setTransform(Math.sign(d),0,0,Math.sign(g),S,C),c.drawImage(t,e,s,i,n,0,0,T,L),c.setTransform(d,u,f,g,A,y),[T,L]}if(d===0&&g===0){const _=o*f+A,S=Math.round(_),E=a*u+y,C=Math.round(E),x=(o+h)*f+A,T=Math.abs(Math.round(x)-S)||1,P=(a+l)*u+y,L=Math.abs(Math.round(P)-C)||1;return c.setTransform(0,Math.sign(u),Math.sign(f),0,S,C),c.drawImage(t,e,s,i,n,0,0,L,T),c.setTransform(d,u,f,g,A,y),[L,T]}c.drawImage(t,e,s,i,n,a,o,l,h);const w=Math.hypot(d,u),v=Math.hypot(f,g);return[w*l,v*h]}function Fg(c){const{width:t,height:e}=c;if(t>Fd||e>Fd)return null;const s=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=t+1;let a=new Uint8Array(n*(e+1)),o,l,h;const d=t+7&-8;let u=new Uint8Array(d*e),f=0;for(const v of c.data){let _=128;for(;_>0;)u[f++]=v&_?0:255,_>>=1}let g=0;for(f=0,u[f]!==0&&(a[0]=1,++g),l=1;l>2)+(u[f+1]?4:0)+(u[f-d+1]?8:0),i[v]&&(a[h+l]=i[v],++g),f++;if(u[f-d]!==u[f]&&(a[h+l]=u[f]?2:4,++g),g>s)return null}for(f=d*(e-1),h=o*n,u[f]!==0&&(a[h]=8,++g),l=1;ls)return null;const A=new Int32Array([0,n,-1,0,-n,0,0,0,1]),y=new Path2D;for(o=0;g&&o<=e;o++){let v=o*n;const _=v+t;for(;v<_&&!a[v];)v++;if(v===_)continue;y.moveTo(v%n,o);const S=v;let E=a[v];do{const C=A[E];do v+=C;while(!a[v]);const x=a[v];x!==5&&x!==10?(E=x,a[v]=0):(E=x&51*E>>4,a[v]&=E>>2|E<<2),y.lineTo(v%n,v/n|0),a[v]||--g}while(S!==v);--o}return u=null,a=null,function(v){v.save(),v.scale(1/t,-1/e),v.translate(0,-e),v.fill(y),v.beginPath(),v.restore()}}class Dd{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=su,this.textMatrixScale=1,this.fontMatrix=$h,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=ee.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,s){[e,s]=j.applyTransform([e,s],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,s)}updateRectMinMax(t,e){const s=j.applyTransform(e,t),i=j.applyTransform(e.slice(2),t),n=j.applyTransform([e[0],e[3]],t),a=j.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,s[0],i[0],n[0],a[0]),this.minY=Math.min(this.minY,s[1],i[1],n[1],a[1]),this.maxX=Math.max(this.maxX,s[0],i[0],n[0],a[0]),this.maxY=Math.max(this.maxY,s[1],i[1],n[1],a[1])}updateScalingPathMinMax(t,e){j.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,s,i,n,a,o,l,h,d){const u=j.bezierBoundingBox(e,s,i,n,a,o,l,h,d);d||this.updateRectMinMax(t,u)}getPathBoundingBox(t=ue.FILL,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===ue.STROKE){e||wt("Stroke bounding box must include transform.");const i=j.singularValueDecompose2dScale(e),n=i[0]*this.lineWidth/2,a=i[1]*this.lineWidth/2;s[0]-=n,s[1]-=a,s[2]+=n,s[3]+=a}return s}updateClipFromPath(){const t=j.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=ue.FILL,e=null){return j.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Od(c,t){if(typeof ImageData<"u"&&t instanceof ImageData){c.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%Ee,n=(e-i)/Ee,a=i===0?n:n+1,o=c.createImageData(s,Ee);let l=0,h;const d=t.data,u=o.data;let f,g,A,y;if(t.kind===vl.GRAYSCALE_1BPP){const w=d.byteLength,v=new Uint32Array(u.buffer,0,u.byteLength>>2),_=v.length,S=s+7>>3,E=4294967295,C=fe.isLittleEndian?4278190080:255;for(f=0;fS?s:x*8-7,L=P&-8;let O=0,F=0;for(;T>=1}for(;h<_;)v[h++]=0;c.putImageData(o,0,f*Ee)}}else if(t.kind===vl.RGBA_32BPP){for(g=0,y=s*Ee*4,f=0;f=n&&(A=i,y=s*A),h=0,g=y;g--;)u[h++]=d[l++],u[h++]=d[l++],u[h++]=d[l++],u[h++]=255;c.putImageData(o,0,f*Ee)}else throw new Error(`bad image kind: ${t.kind}`)}function Nd(c,t){if(t.bitmap){c.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%Ee,n=(e-i)/Ee,a=i===0?n:n+1,o=c.createImageData(s,Ee);let l=0;const h=t.data,d=o.data;for(let u=0;uId&&typeof s=="function",d=h?Date.now()+Lg:0;let u=0;const f=this.commonObjs,g=this.objs;let A;for(;;){if(i!==void 0&&o===i.nextBreakPoint)return i.breakIt(o,s),o;if(A=a[o],A!==Xe.dependency)this[A].apply(this,n[o]);else for(const y of n[o]){const w=y.startsWith("g_")?f:g;if(!w.has(y))return w.get(y,s),o}if(o++,o===l)return o;if(h&&++u>Id){if(Date.now()>d)return s(),o;u=0}}}endDrawing(){m(this,zi,mc).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),m(this,zi,bc).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,i=t.height??t.displayHeight;let n=Math.max(Math.hypot(e[0],e[1]),1),a=Math.max(Math.hypot(e[2],e[3]),1),o=s,l=i,h="prescale1",d,u;for(;n>2&&o>1||a>2&&l>1;){let f=o,g=l;n>2&&o>1&&(f=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o/2),n/=o/f),a>2&&l>1&&(g=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,a/=l/g),d=this.cachedCanvases.getCanvas(h,f,g),u=d.context,u.clearRect(0,0,f,g),u.drawImage(t,0,0,o,l,0,0,f,g),t=d.canvas,o=f,l=g,h=h==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:o,paintHeight:l}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:i}=t,n=this.current.fillColor,a=this.current.patternFill,o=Tt(e);let l,h,d,u;if((t.bitmap||t.data)&&t.count>1){const P=t.bitmap||t.data.buffer;h=JSON.stringify(a?o:[o.slice(0,4),n]),l=this._cachedBitmapsMap.get(P),l||(l=new Map,this._cachedBitmapsMap.set(P,l));const L=l.get(h);if(L&&!a){const O=Math.round(Math.min(o[0],o[2])+o[4]),F=Math.round(Math.min(o[1],o[3])+o[5]);return{canvas:L,offsetX:O,offsetY:F}}d=L}d||(u=this.cachedCanvases.getCanvas("maskCanvas",s,i),Nd(u.context,t));let f=j.transform(o,[1/s,0,0,-1/i,0,0]);f=j.transform(f,[1,0,0,1,0,-i]);const[g,A,y,w]=j.getAxialAlignedBoundingBox([0,0,s,i],f),v=Math.round(y-g)||1,_=Math.round(w-A)||1,S=this.cachedCanvases.getCanvas("fillCanvas",v,_),E=S.context,C=g,x=A;E.translate(-C,-x),E.transform(...f),d||(d=this._scaleImage(u.canvas,Ps(E)),d=d.img,l&&a&&l.set(h,d)),E.imageSmoothingEnabled=Hd(Tt(E),t.interpolate),pl(E,d,0,0,d.width,d.height,0,0,s,i),E.globalCompositeOperation="source-in";const T=j.transform(Ps(E),[1,0,0,1,-C,-x]);return E.fillStyle=a?n.getPattern(e,this,T,ue.FILL):n,E.fillRect(0,0,s,i),l&&!a&&(this.cachedCanvases.delete("fillCanvas"),l.set(h,S.canvas)),{canvas:S.canvas,offsetX:Math.round(C),offsetY:Math.round(x)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Dg[t]}setLineJoin(t){this.ctx.lineJoin=Og[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(t),s.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,s]of t)switch(e){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s[0],s[1]);break;case"CA":this.current.strokeAlpha=s;break;case"ca":this.current.fillAlpha=s,this.ctx.globalAlpha=s;break;case"BM":this.ctx.globalCompositeOperation=s;break;case"SMask":this.current.activeSMask=s?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(s,t,e);this.suspendedCtx=this.ctx,this.ctx=i.context;const n=this.ctx;n.setTransform(...Tt(this.suspendedCtx)),_a(this.suspendedCtx,n),Mg(n,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),_a(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,s,i){const n=i[0],a=i[1],o=i[2]-n,l=i[3]-a;o===0||l===0||(this.genericComposeSMask(e.context,s,o,l,e.subtype,e.backdrop,e.transferMap,n,a,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,n,a,o,l,h,d,u){let f=t.canvas,g=l-d,A=h-u;if(a){const w=j.makeHexColor(...a);if(g<0||A<0||g+s>f.width||A+i>f.height){const v=this.cachedCanvases.getCanvas("maskExtension",s,i),_=v.context;_.drawImage(f,-g,-A),_.globalCompositeOperation="destination-atop",_.fillStyle=w,_.fillRect(0,0,s,i),_.globalCompositeOperation="source-over",f=v.canvas,g=A=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const v=new Path2D;v.rect(g,A,s,i),t.clip(v),t.globalCompositeOperation="destination-atop",t.fillStyle=w,t.fillRect(g,A,s,i),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),n==="Alpha"&&o?e.filter=this.filterFactory.addAlphaFilter(o):n==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(o));const y=new Path2D;y.rect(l,h,s,i),e.clip(y),e.globalCompositeOperation="destination-in",e.drawImage(f,g,A,s,i,l,h,s,i),e.restore()}save(){this.inSMaskMode?(_a(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),_a(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,s,i,n,a){this.ctx.transform(t,e,s,i,n,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){const i=this.ctx,n=this.current;let a=n.x,o=n.y,l,h;const d=Tt(i),u=d[0]===0&&d[3]===0||d[1]===0&&d[2]===0,f=u?s.slice(0):null;for(let g=0,A=0,y=t.length;gMd&&(h=Md),this.current.fontSizeScale=e/h,this.ctx.font=`${l} ${o} ${h}px ${a}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,s,i,n,a){this.current.textMatrix=[t,e,s,i,n,a],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,s,i){const n=this.ctx,a=this.current,o=a.font,l=a.textRenderingMode,h=a.fontSize/a.fontSizeScale,d=l&ee.FILL_STROKE_MASK,u=!!(l&ee.ADD_TO_PATH_FLAG),f=a.patternFill&&!o.missingFile;let g;(o.disableFontFace||u||f)&&(g=o.getPathGenerator(this.commonObjs,t)),o.disableFontFace||f?(n.save(),n.translate(e,s),n.beginPath(),g(n,h),i&&n.setTransform(...i),(d===ee.FILL||d===ee.FILL_STROKE)&&n.fill(),(d===ee.STROKE||d===ee.FILL_STROKE)&&n.stroke(),n.restore()):((d===ee.FILL||d===ee.FILL_STROKE)&&n.fillText(t,e,s),(d===ee.STROKE||d===ee.FILL_STROKE)&&n.strokeText(t,e,s)),u&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Tt(n),x:e,y:s,fontSize:h,addToPath:g})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let s=!1;for(let i=3;i0&&e[i]<255){s=!0;break}return ot(this,"isFontSubpixelAAEnabled",s)}showText(t){const e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);const i=e.fontSize;if(i===0)return;const n=this.ctx,a=e.fontSizeScale,o=e.charSpacing,l=e.wordSpacing,h=e.fontDirection,d=e.textHScale*h,u=t.length,f=s.vertical,g=f?1:-1,A=s.defaultVMetrics,y=i*e.fontMatrix[0],w=e.textRenderingMode===ee.FILL&&!s.disableFontFace&&!e.patternFill;n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),h>0?n.scale(d,-1):n.scale(d,1);let v;if(e.patternFill){n.save();const x=e.fillColor.getPattern(n,this,Ps(n),ue.FILL);v=Tt(n),n.restore(),n.fillStyle=x}let _=e.lineWidth;const S=e.textMatrixScale;if(S===0||_===0){const x=e.textRenderingMode&ee.FILL_STROKE_MASK;(x===ee.STROKE||x===ee.FILL_STROKE)&&(_=this.getSinglePixelWidth())}else _/=S;if(a!==1&&(n.scale(a,a),_/=a),n.lineWidth=_,s.isInvalidPDFjsFont){const x=[];let T=0;for(const P of t)x.push(P.unicode),T+=P.width;n.fillText(x.join(""),0,0),e.x+=T*y*d,n.restore(),this.compose();return}let E=0,C;for(C=0;C0){const X=n.measureText(L).width*1e3/i*a;if(Unew Ed(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new gc(t,s,this.ctx,n,i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,s){this.ctx.strokeStyle=this.current.strokeColor=j.makeHexColor(t,e,s)}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent"}setFillRGBColor(t,e,s){this.ctx.fillStyle=this.current.fillColor=j.makeHexColor(t,e,s),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let s;return this.cachedPatterns.has(t)?s=this.cachedPatterns.get(t):(s=Pg(this.getObject(t)),this.cachedPatterns.set(t,s)),e&&(s.matrix=e),s}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const s=this._getPattern(t);e.fillStyle=s.getPattern(e,this,Ps(e),ue.SHADING);const i=Ps(e);if(i){const{width:n,height:a}=e.canvas,[o,l,h,d]=j.getAxialAlignedBoundingBox([0,0,n,a],i);this.ctx.fillRect(o,l,h-o,d-l)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){wt("Should not call beginInlineImage")}beginImageData(){wt("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Tt(this.ctx),e)){const s=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],s,i),this.current.updateRectMinMax(Tt(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||wh("TODO: Support non-isolated groups."),t.knockout&&st("Knockout groups not supported.");const s=Tt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=j.getAxialAlignedBoundingBox(t.bbox,Tt(e));const n=[0,0,e.canvas.width,e.canvas.height];i=j.intersect(i,n)||[0,0,0,0];const a=Math.floor(i[0]),o=Math.floor(i[1]),l=Math.max(Math.ceil(i[2])-a,1),h=Math.max(Math.ceil(i[3])-o,1);this.current.startNewPathAndClipBox([0,0,l,h]);let d="groupAt"+this.groupLevel;t.smask&&(d+="_smask_"+this.smaskCounter++%2);const u=this.cachedCanvases.getCanvas(d,l,h),f=u.context;f.translate(-a,-o),f.transform(...s),t.smask?this.smaskStack.push({canvas:u.canvas,context:f,offsetX:a,offsetY:o,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(a,o),e.save()),_a(e,f),this.ctx=f,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,s=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const i=Tt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const n=j.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],i);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(t,e,s,i,n){if(m(this,zi,mc).call(this),gl(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const a=e[2]-e[0],o=e[3]-e[1];if(n&&this.annotationCanvasMap){s=s.slice(),s[4]-=e[0],s[5]-=e[1],e=e.slice(),e[0]=e[1]=0,e[2]=a,e[3]=o;const[l,h]=j.singularValueDecompose2dScale(Tt(this.ctx)),{viewportScale:d}=this,u=Math.ceil(a*this.outputScaleX*d),f=Math.ceil(o*this.outputScaleY*d);this.annotationCanvas=this.canvasFactory.create(u,f);const{canvas:g,context:A}=this.annotationCanvas;this.annotationCanvasMap.set(t,g),this.annotationCanvas.savedCtx=this.ctx,this.ctx=A,this.ctx.save(),this.ctx.setTransform(l,0,0,-h,0,o*h),gl(this.ctx)}else gl(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],a,o),this.ctx.clip(),this.ctx.beginPath()}this.current=new Dd(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),m(this,zi,bc).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;t=this.getObject(t.data,t),t.count=e;const s=this.ctx,i=this.processingType3;if(i&&(i.compiled===void 0&&(i.compiled=Fg(t)),i.compiled)){i.compiled(s);return}const n=this._createMaskCanvas(t),a=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(a,n.offsetX,n.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,i=0,n,a){if(!this.contentVisible)return;t=this.getObject(t.data,t);const o=this.ctx;o.save();const l=Tt(o);o.transform(e,s,i,n,0,0);const h=this._createMaskCanvas(t);o.setTransform(1,0,0,1,h.offsetX-l[4],h.offsetY-l[5]);for(let d=0,u=a.length;du?d/u:1,o=h>u?h/u:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:s}=this.current,[i,n]=this.getScaleForStroking();if(e.lineWidth=s||1,i===1&&n===1){e.stroke();return}const a=e.getLineDash();if(t&&e.save(),e.scale(i,n),a.length>0){const o=Math.max(i,n);e.setLineDash(a.map(l=>l/o)),e.lineDashOffset/=o}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};zi=new WeakSet,mc=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)},bc=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}};let gr=Ed;for(const c in Xe)gr.prototype[c]!==void 0&&(gr.prototype[Xe[c]]=gr.prototype[c]);var uo,fo;class ii{static get workerPort(){return r(this,uo)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");p(this,uo,t)}static get workerSrc(){return r(this,fo)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");p(this,fo,t)}}uo=new WeakMap,fo=new WeakMap,b(ii,uo,null),b(ii,fo,"");const ml={DATA:1,ERROR:2},It={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function xe(c){switch(c instanceof Error||typeof c=="object"&&c!==null||wt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),c.name){case"AbortException":return new er(c.message);case"MissingPDFException":return new tr(c.message);case"PasswordException":return new zh(c.message,c.code);case"UnexpectedResponseException":return new _h(c.message,c.status);case"UnknownErrorException":return new Gh(c.message,c.details);default:return new Gh(c.message,c.toString())}}var Ir,We,ju,$u,zu,Rl;class La{constructor(t,e,s){b(this,We);b(this,Ir,new AbortController);this.sourceName=t,this.targetName=e,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),s.addEventListener("message",m(this,We,ju).bind(this),{signal:r(this,Ir).signal})}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[i]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(a){n.reject(a)}return n.promise}sendWithStream(t,e,s,i){const n=this.streamId++,a=this.sourceName,o=this.targetName,l=this.comObj;return new ReadableStream({start:h=>{const d=Promise.withResolvers();return this.streamControllers[n]={controller:h,startCall:d,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:a,targetName:o,action:t,streamId:n,data:e,desiredSize:h.desiredSize},i),d.promise},pull:h=>{const d=Promise.withResolvers();return this.streamControllers[n].pullCall=d,l.postMessage({sourceName:a,targetName:o,stream:It.PULL,streamId:n,desiredSize:h.desiredSize}),d.promise},cancel:h=>{jt(h instanceof Error,"cancel must have a valid reason");const d=Promise.withResolvers();return this.streamControllers[n].cancelCall=d,this.streamControllers[n].isClosed=!0,l.postMessage({sourceName:a,targetName:o,stream:It.CANCEL,streamId:n,reason:xe(h)}),d.promise}},s)}destroy(){var t;(t=r(this,Ir))==null||t.abort(),p(this,Ir,null)}}Ir=new WeakMap,We=new WeakSet,ju=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){m(this,We,zu).call(this,t);return}if(t.callback){const s=t.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===ml.DATA)i.resolve(t.data);else if(t.callback===ml.ERROR)i.reject(xe(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.sourceName,i=t.sourceName,n=this.comObj;new Promise(function(a){a(e(t.data))}).then(function(a){n.postMessage({sourceName:s,targetName:i,callback:ml.DATA,callbackId:t.callbackId,data:a})},function(a){n.postMessage({sourceName:s,targetName:i,callback:ml.ERROR,callbackId:t.callbackId,reason:xe(a)})});return}if(t.streamId){m(this,We,$u).call(this,t);return}e(t.data)},$u=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,a=this,o=this.actionHandler[t.action],l={enqueue(h,d=1,u){if(this.isCancelled)return;const f=this.desiredSize;this.desiredSize-=d,f>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:It.ENQUEUE,streamId:e,chunk:h},u)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:It.CLOSE,streamId:e}),delete a.streamSinks[e])},error(h){jt(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:It.ERROR,streamId:e,reason:xe(h)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[e]=l,new Promise(function(h){h(o(t.data,l))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:It.START_COMPLETE,streamId:e,success:!0})},function(h){n.postMessage({sourceName:s,targetName:i,stream:It.START_COMPLETE,streamId:e,reason:xe(h)})})},zu=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,a=this.streamControllers[e],o=this.streamSinks[e];switch(t.stream){case It.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(xe(t.reason));break;case It.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(xe(t.reason));break;case It.PULL:if(!o){n.postMessage({sourceName:s,targetName:i,stream:It.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,new Promise(function(l){var h;l((h=o.onPull)==null?void 0:h.call(o))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:It.PULL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:It.PULL_COMPLETE,streamId:e,reason:xe(l)})});break;case It.ENQUEUE:if(jt(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case It.CLOSE:if(jt(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),m(this,We,Rl).call(this,a,e);break;case It.ERROR:jt(a,"error should have stream controller"),a.controller.error(xe(t.reason)),m(this,We,Rl).call(this,a,e);break;case It.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(xe(t.reason)),m(this,We,Rl).call(this,a,e);break;case It.CANCEL:if(!o)break;new Promise(function(l){var h;l((h=o.onCancel)==null?void 0:h.call(o,xe(t.reason)))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:It.CANCEL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:It.CANCEL_COMPLETE,streamId:e,reason:xe(l)})}),o.sinkCapability.reject(xe(t.reason)),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Rl=async function(t,e){var s,i,n;await Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(i=t.pullCall)==null?void 0:i.promise,(n=t.cancelCall)==null?void 0:n.promise]),delete this.streamControllers[e]};var bn,po;class Hg{constructor({parsedData:t,rawData:e}){b(this,bn);b(this,po);p(this,bn,t),p(this,po,e)}getRaw(){return r(this,po)}get(t){return r(this,bn).get(t)??null}getAll(){return hd(r(this,bn))}has(t){return r(this,bn).has(t)}}bn=new WeakMap,po=new WeakMap;const cr=Symbol("INTERNAL");var go,mo,bo,Fr;class Bg{constructor(t,{name:e,intent:s,usage:i,rbGroups:n}){b(this,go,!1);b(this,mo,!1);b(this,bo,!1);b(this,Fr,!0);p(this,go,!!(t&Fe.DISPLAY)),p(this,mo,!!(t&Fe.PRINT)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=n}get visible(){if(r(this,bo))return r(this,Fr);if(!r(this,Fr))return!1;const{print:t,view:e}=this.usage;return r(this,go)?(e==null?void 0:e.viewState)!=="OFF":r(this,mo)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==cr&&wt("Internal method `_setVisible` called."),p(this,bo,s),p(this,Fr,e)}}go=new WeakMap,mo=new WeakMap,bo=new WeakMap,Fr=new WeakMap;var Ei,ft,Dr,Or,Ao,Ac;class jg{constructor(t,e=Fe.DISPLAY){b(this,Ao);b(this,Ei,null);b(this,ft,new Map);b(this,Dr,null);b(this,Or,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,p(this,Or,t.order);for(const s of t.groups)r(this,ft).set(s.id,new Bg(e,s));if(t.baseState==="OFF")for(const s of r(this,ft).values())s._setVisible(cr,!1);for(const s of t.on)r(this,ft).get(s)._setVisible(cr,!0);for(const s of t.off)r(this,ft).get(s)._setVisible(cr,!1);p(this,Dr,this.getHash())}}isVisible(t){if(r(this,ft).size===0)return!0;if(!t)return wh("Optional content group not defined."),!0;if(t.type==="OCG")return r(this,ft).has(t.id)?r(this,ft).get(t.id).visible:(st(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return m(this,Ao,Ac).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!r(this,ft).has(e))return st(`Optional content group not found: ${e}`),!0;if(r(this,ft).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!r(this,ft).has(e))return st(`Optional content group not found: ${e}`),!0;if(!r(this,ft).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!r(this,ft).has(e))return st(`Optional content group not found: ${e}`),!0;if(!r(this,ft).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!r(this,ft).has(e))return st(`Optional content group not found: ${e}`),!0;if(r(this,ft).get(e).visible)return!1}return!0}return st(`Unknown optional content policy ${t.policy}.`),!0}return st(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var n;const i=r(this,ft).get(t);if(!i){st(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length)for(const a of i.rbGroups)for(const o of a)o!==t&&((n=r(this,ft).get(o))==null||n._setVisible(cr,!1,!0));i._setVisible(cr,!!e,!0),p(this,Ei,null)}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const n=r(this,ft).get(i);if(n)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!n.visible,e);break}}p(this,Ei,null)}get hasInitialVisibility(){return r(this,Dr)===null||this.getHash()===r(this,Dr)}getOrder(){return r(this,ft).size?r(this,Or)?r(this,Or).slice():[...r(this,ft).keys()]:null}getGroups(){return r(this,ft).size>0?hd(r(this,ft)):null}getGroup(t){return r(this,ft).get(t)||null}getHash(){if(r(this,Ei)!==null)return r(this,Ei);const t=new Pu;for(const[e,s]of r(this,ft))t.update(`${e}:${s.visible}`);return p(this,Ei,t.hexdigest())}}Ei=new WeakMap,ft=new WeakMap,Dr=new WeakMap,Or=new WeakMap,Ao=new WeakSet,Ac=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i0){const l=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((l,h)=>{this._onReceiveData({begin:l,chunk:h})}),t.addProgressListener((l,h)=>{this._onProgress({loaded:l,total:h})}),t.addProgressiveReadListener(l=>{this._onReceiveData({chunk:l})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{const i=this._rangeReaders.some(function(n){return n._begin!==t?!1:(n._enqueue(s),!0)});jt(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}_onProgress(t){var e,s,i,n;t.total===void 0?(s=(e=this._rangeReaders[0])==null?void 0:e.onProgress)==null||s.call(e,{loaded:t.loaded}):(n=(i=this._fullRequestReader)==null?void 0:i.onProgress)==null||n.call(i,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;(t=this._fullRequestReader)==null||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){jt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new zg(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Gg(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeReaders.slice(0))s.cancel(t);this._pdfDataRangeTransport.abort()}}class zg{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=ud(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const n of this._queuedChunks)this._loaded+=n.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Gg{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Ug(c){let t=!0,e=s("filename\\*","i").exec(c);if(e){e=e[1];let d=o(e);return d=unescape(d),d=l(d),d=h(d),n(d)}if(e=a(c),e){const d=h(e);return n(d)}if(e=s("filename","i").exec(c),e){e=e[1];let d=o(e);return d=h(d),n(d)}function s(d,u){return new RegExp("(?:^|;)\\s*"+d+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',u)}function i(d,u){if(d){if(!/^[\x00-\xFF]+$/.test(u))return u;try{const f=new TextDecoder(d,{fatal:!0}),g=Eh(u);u=f.decode(g),t=!1}catch{}}return u}function n(d){return t&&/[\x80-\xff]/.test(d)&&(d=i("utf-8",d),t&&(d=i("iso-8859-1",d))),d}function a(d){const u=[];let f;const g=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(f=g.exec(d))!==null;){let[,y,w,v]=f;if(y=parseInt(y,10),y in u){if(y===0)break;continue}u[y]=[w,v]}const A=[];for(let y=0;y{if(!Gu(n.status))throw Ch(n.status,i);this._reader=n.body.getReader(),this._headersCapability.resolve();const a=n.headers,{allowRangeRequests:o,suggestedLength:l}=Ad({responseHeaders:a,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=o,this._contentLength=l||this._contentLength,this._filename=yd(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new er("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 s;await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:Wu(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}class Vg{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;const i=t.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController;const n=new Headers(t.headers);n.append("Range",`bytes=${e}-${s-1}`);const a=i.url;fetch(a,Uu(n,this._withCredentials,this._abortController)).then(o=>{if(!Gu(o.status))throw Ch(o.status,a);this._readCapability.resolve(),this._reader=o.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:Wu(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}const Nh=200,Hh=206;function qg(c){const t=c.response;return typeof t!="string"?t:Eh(t).buffer}class Xg{constructor({url:t,httpHeaders:e,withCredentials:s}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=bd(this.isHttp,e),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(t,e,s){const i={begin:t,end:e};for(const n in s)i[n]=s[n];return this.request(i)}requestFull(t){return this.request(t)}request(t){const e=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[n,a]of this.headers)e.setRequestHeader(n,a);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=Hh):i.expectedStatus=Nh,e.responseType="arraybuffer",t.onError&&(e.onerror=function(n){t.onError(e.status)}),e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){var i;const s=this.pendingRequests[t];s&&((i=s.onProgress)==null||i.call(s,e))}onStateChange(t,e){var l,h,d;const s=this.pendingRequests[t];if(!s)return;const i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),i.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],i.status===0&&this.isHttp){(l=s.onError)==null||l.call(s,i.status);return}const n=i.status||Nh;if(!(n===Nh&&s.expectedStatus===Hh)&&n!==s.expectedStatus){(h=s.onError)==null||h.call(s,i.status);return}const o=qg(i);if(n===Hh){const u=i.getResponseHeader("Content-Range"),f=/bytes (\d+)-(\d+)\/(\d+)/.exec(u);s.onDone({begin:parseInt(f[1],10),chunk:o})}else o?s.onDone({begin:0,chunk:o}):(d=s.onError)==null||d.call(s,i.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class Yg{constructor(t){this._source=t,this._manager=new Xg(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 jt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Kg(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new Qg(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class Kg{constructor(t,e){this._manager=t;const s={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._fullRequestId=t.requestFull(s),this._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),s=new Headers(e.getAllResponseHeaders().trim().split(/[\r\n]+/).map(a=>{const[o,...l]=a.split(": ");return[o,l.join(": ")]})),{allowRangeRequests:i,suggestedLength:n}=Ad({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=yd(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Ch(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;(e=this.onProgress)==null||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(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 Qg{constructor(t,e,s){this._manager=t;const i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._requestId=t.requestRange(e,s,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){var t;(t=this.onClosed)==null||t.call(this,this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError=Ch(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||(e=this.onProgress)==null||e.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const Jg=/^[a-z][a-z0-9\-+.]+:/i;function Zg(c){if(Jg.test(c))return new URL(c);const t=ji.get("url");return new URL(t.pathToFileURL(c))}function Vu(c,t,e){return c.protocol==="http:"?ji.get("http").request(c,{headers:t},e):ji.get("https").request(c,{headers:t},e)}class tm{constructor(t){this.source=t,this.url=Zg(t.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.headers=bd(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return jt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new im(this):new em(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=this.isFsUrl?new nm(this,t,e):new sm(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class qu{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new er("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Xu{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const e=t.source;this._isStreamingSupported=!e.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}class em extends qu{constructor(t){super(t);const e=Object.fromEntries(t.headers),s=i=>{if(i.statusCode===404){const l=new tr(`Missing PDF "${this._url}".`);this._storedError=l,this._headersCapability.reject(l);return}this._headersCapability.resolve(),this._setReadableStream(i);const n=new Headers(this._readableStream.headers),{allowRangeRequests:a,suggestedLength:o}=Ad({responseHeaders:n,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=o||this._contentLength,this._filename=yd(n)};this._request=Vu(this._url,e,s),this._request.on("error",i=>{this._storedError=i,this._headersCapability.reject(i)}),this._request.end()}}class sm extends Xu{constructor(t,e,s){super(t);const i=Object.fromEntries(t.headers);i.Range=`bytes=${e}-${s-1}`;const n=a=>{if(a.statusCode===404){const o=new tr(`Missing PDF "${this._url}".`);this._storedError=o;return}this._setReadableStream(a)};this._request=Vu(this._url,i,n),this._request.on("error",a=>{this._storedError=a}),this._request.end()}}class im extends qu{constructor(t){super(t);const e=ji.get("fs");e.promises.lstat(this._url).then(s=>{this._contentLength=s.size,this._setReadableStream(e.createReadStream(this._url)),this._headersCapability.resolve()},s=>{s.code==="ENOENT"&&(s=new tr(`Missing PDF "${this._url}".`)),this._storedError=s,this._headersCapability.reject(s)})}}class nm extends Xu{constructor(t,e,s){super(t);const i=ji.get("fs");this._setReadableStream(i.createReadStream(this._url,{start:e,end:s-1}))}}const rm=1e5,Ae=30,am=.8;var tu,Si,we,yo,vo,An,Bs,wo,_o,yn,Nr,Hr,xi,Br,Eo,jr,vn,So,xo,Pt,wn,_n,Co,Ci,$r,oi,Yu,Ku,vc,Oe,Pl,wc,Qu,Ju;let yc=(Pt=class{constructor({textContentSource:t,container:e,viewport:s}){b(this,oi);b(this,Si,Promise.withResolvers());b(this,we,null);b(this,yo,!1);b(this,vo,!!((tu=globalThis.FontInspector)!=null&&tu.enabled));b(this,An,null);b(this,Bs,null);b(this,wo,0);b(this,_o,0);b(this,yn,null);b(this,Nr,null);b(this,Hr,0);b(this,xi,0);b(this,Br,Object.create(null));b(this,Eo,[]);b(this,jr,null);b(this,vn,[]);b(this,So,new WeakMap);b(this,xo,null);var l;if(t instanceof ReadableStream)p(this,jr,t);else if(typeof t=="object")p(this,jr,new ReadableStream({start(h){h.enqueue(t),h.close()}}));else throw new Error('No "textContentSource" parameter specified.');p(this,we,p(this,Nr,e)),p(this,xi,s.scale*(globalThis.devicePixelRatio||1)),p(this,Hr,s.rotation),p(this,Bs,{div:null,properties:null,ctx:null});const{pageWidth:i,pageHeight:n,pageX:a,pageY:o}=s.rawDims;p(this,xo,[1,0,0,-1,-a,o+n]),p(this,_o,i),p(this,wo,n),m(l=Pt,Oe,Qu).call(l),Xn(e,s),r(this,Si).promise.finally(()=>{r(Pt,$r).delete(this),p(this,Bs,null),p(this,Br,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=fe.platform;return ot(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{r(this,yn).read().then(({value:e,done:s})=>{if(s){r(this,Si).resolve();return}r(this,An)??p(this,An,e.lang),Object.assign(r(this,Br),e.styles),m(this,oi,Yu).call(this,e.items),t()},r(this,Si).reject)};return p(this,yn,r(this,jr).getReader()),r(Pt,$r).add(this),t(),r(this,Si).promise}update({viewport:t,onBefore:e=null}){var n;const s=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==r(this,Hr)&&(e==null||e(),p(this,Hr,i),Xn(r(this,Nr),{rotation:i})),s!==r(this,xi)){e==null||e(),p(this,xi,s);const a={div:null,properties:null,ctx:m(n=Pt,Oe,Pl).call(n,r(this,An))};for(const o of r(this,vn))a.properties=r(this,So).get(o),a.div=o,m(this,oi,vc).call(this,a)}}cancel(){var e;const t=new er("TextLayer task cancelled.");(e=r(this,yn))==null||e.cancel(t).catch(()=>{}),p(this,yn,null),r(this,Si).reject(t)}get textDivs(){return r(this,vn)}get textContentItemsStr(){return r(this,Eo)}static cleanup(){if(!(r(this,$r).size>0)){r(this,wn).clear();for(const{canvas:t}of r(this,_n).values())t.remove();r(this,_n).clear()}}},Si=new WeakMap,we=new WeakMap,yo=new WeakMap,vo=new WeakMap,An=new WeakMap,Bs=new WeakMap,wo=new WeakMap,_o=new WeakMap,yn=new WeakMap,Nr=new WeakMap,Hr=new WeakMap,xi=new WeakMap,Br=new WeakMap,Eo=new WeakMap,jr=new WeakMap,vn=new WeakMap,So=new WeakMap,xo=new WeakMap,wn=new WeakMap,_n=new WeakMap,Co=new WeakMap,Ci=new WeakMap,$r=new WeakMap,oi=new WeakSet,Yu=function(t){var i,n;if(r(this,yo))return;(n=r(this,Bs)).ctx??(n.ctx=m(i=Pt,Oe,Pl).call(i,r(this,An)));const e=r(this,vn),s=r(this,Eo);for(const a of t){if(e.length>rm){st("Ignoring additional textDivs for performance reasons."),p(this,yo,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=r(this,we);p(this,we,document.createElement("span")),r(this,we).classList.add("markedContent"),a.id!==null&&r(this,we).setAttribute("id",`${a.id}`),o.append(r(this,we))}else a.type==="endMarkedContent"&&p(this,we,r(this,we).parentNode);continue}s.push(a.str),m(this,oi,Ku).call(this,a)}},Ku=function(t){var y;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};r(this,vn).push(e);const i=j.transform(r(this,xo),t.transform);let n=Math.atan2(i[1],i[0]);const a=r(this,Br)[t.fontName];a.vertical&&(n+=Math.PI/2);let o=r(this,vo)&&a.fontSubstitution||a.fontFamily;o=Pt.fontFamilyMap.get(o)||o;const l=Math.hypot(i[2],i[3]),h=l*m(y=Pt,Oe,Ju).call(y,o,r(this,An));let d,u;n===0?(d=i[4],u=i[5]-h):(d=i[4]+h*Math.sin(n),u=i[5]-h*Math.cos(n));const f="calc(var(--scale-factor)*",g=e.style;r(this,we)===r(this,Nr)?(g.left=`${(100*d/r(this,_o)).toFixed(2)}%`,g.top=`${(100*u/r(this,wo)).toFixed(2)}%`):(g.left=`${f}${d.toFixed(2)}px)`,g.top=`${f}${u.toFixed(2)}px)`),g.fontSize=`${f}${(r(Pt,Ci)*l).toFixed(2)}px)`,g.fontFamily=o,s.fontSize=l,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,r(this,vo)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),n!==0&&(s.angle=n*(180/Math.PI));let A=!1;if(t.str.length>1)A=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const w=Math.abs(t.transform[0]),v=Math.abs(t.transform[3]);w!==v&&Math.max(w,v)/Math.min(w,v)>1.5&&(A=!0)}if(A&&(s.canvasWidth=a.vertical?t.height:t.width),r(this,So).set(e,s),r(this,Bs).div=e,r(this,Bs).properties=s,m(this,oi,vc).call(this,r(this,Bs)),s.hasText&&r(this,we).append(e),s.hasEOL){const w=document.createElement("br");w.setAttribute("role","presentation"),r(this,we).append(w)}},vc=function(t){var o;const{div:e,properties:s,ctx:i}=t,{style:n}=e;let a="";if(r(Pt,Ci)>1&&(a=`scale(${1/r(Pt,Ci)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:l}=n,{canvasWidth:h,fontSize:d}=s;m(o=Pt,Oe,wc).call(o,i,d*r(this,xi),l);const{width:u}=i.measureText(e.textContent);u>0&&(a=`scaleX(${h*r(this,xi)/u}) ${a}`)}s.angle!==0&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(n.transform=a)},Oe=new WeakSet,Pl=function(t=null){let e=r(this,_n).get(t||(t=""));if(!e){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),r(this,_n).set(t,e),r(this,Co).set(e,{size:0,family:""})}return e},wc=function(t,e,s){const i=r(this,Co).get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)},Qu=function(){if(r(this,Ci)!==null)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),p(this,Ci,t.getBoundingClientRect().height),t.remove()},Ju=function(t,e){const s=r(this,wn).get(t);if(s)return s;const i=m(this,Oe,Pl).call(this,e);i.canvas.width=i.canvas.height=Ae,m(this,Oe,wc).call(this,i,Ae,t);const n=i.measureText("");let a=n.fontBoundingBoxAscent,o=Math.abs(n.fontBoundingBoxDescent);if(a){const d=a/(a+o);return r(this,wn).set(t,d),i.canvas.width=i.canvas.height=0,d}i.strokeStyle="red",i.clearRect(0,0,Ae,Ae),i.strokeText("g",0,0);let l=i.getImageData(0,0,Ae,Ae).data;o=0;for(let d=l.length-1-3;d>=0;d-=4)if(l[d]>0){o=Math.ceil(d/4/Ae);break}i.clearRect(0,0,Ae,Ae),i.strokeText("A",0,Ae),l=i.getImageData(0,0,Ae,Ae).data,a=0;for(let d=0,u=l.length;d0){a=Ae-Math.floor(d/4/Ae);break}i.canvas.width=i.canvas.height=0;const h=a?a/(a+o):am;return r(this,wn).set(t,h),h},b(Pt,Oe),b(Pt,wn,new Map),b(Pt,_n,new Map),b(Pt,Co,new WeakMap),b(Pt,Ci,null),b(Pt,$r,new Set),Pt);class Ga{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(n){var l;if(!n)return;let a=null;const o=n.name;if(o==="#text")a=n.value;else if(Ga.shouldBuildText(o))(l=n==null?void 0:n.attributes)!=null&&l.textContent?a=n.attributes.textContent:n.value&&(a=n.value);else return;if(a!==null&&e.push({str:a}),!!n.children)for(const h of n.children)i(h)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const om=65536,lm=100,hm=5e3,cm=le?_g:yg,dm=le?Eg:Fu,um=le?wg:vg,fm=le?Sg:Hu;function pm(c={}){typeof c=="string"||c instanceof URL?c={url:c}:(c instanceof ArrayBuffer||ArrayBuffer.isView(c))&&(c={data:c});const t=new _c,{docId:e}=t,s=c.url?gm(c.url):null,i=c.data?mm(c.data):null,n=c.httpHeaders||null,a=c.withCredentials===!0,o=c.password??null,l=c.range instanceof Zu?c.range:null,h=Number.isInteger(c.rangeChunkSize)&&c.rangeChunkSize>0?c.rangeChunkSize:om;let d=c.worker instanceof mr?c.worker:null;const u=c.verbosity,f=typeof c.docBaseUrl=="string"&&!xh(c.docBaseUrl)?c.docBaseUrl:null,g=typeof c.cMapUrl=="string"?c.cMapUrl:null,A=c.cMapPacked!==!1,y=c.CMapReaderFactory||dm,w=typeof c.standardFontDataUrl=="string"?c.standardFontDataUrl:null,v=c.StandardFontDataFactory||fm,_=c.stopAtErrors!==!0,S=Number.isInteger(c.maxImageSize)&&c.maxImageSize>-1?c.maxImageSize:-1,E=c.isEvalSupported!==!1,C=typeof c.isOffscreenCanvasSupported=="boolean"?c.isOffscreenCanvasSupported:!le,x=typeof c.isChrome=="boolean"?c.isChrome:!fe.platform.isFirefox&&typeof window<"u"&&!!(window!=null&&window.chrome),T=Number.isInteger(c.canvasMaxAreaInBytes)?c.canvasMaxAreaInBytes:-1,P=typeof c.disableFontFace=="boolean"?c.disableFontFace:le,L=c.fontExtraProperties===!0,O=c.enableXfa===!0,F=c.ownerDocument||globalThis.document,J=c.disableRange===!0,U=c.disableStream===!0,z=c.disableAutoFetch===!0,X=c.pdfBug===!0,q=c.CanvasFactory||cm,H=c.FilterFactory||um,$=c.enableHWA===!0,B=l?l.length:c.length??NaN,V=typeof c.useSystemFonts=="boolean"?c.useSystemFonts:!le&&!P,rt=typeof c.useWorkerFetch=="boolean"?c.useWorkerFetch:y===Fu&&v===Hu&&g&&w&&Sa(g,document.baseURI)&&Sa(w,document.baseURI);c.canvasFactory&&Rd("`canvasFactory`-instance option, please use `CanvasFactory` instead."),c.filterFactory&&Rd("`filterFactory`-instance option, please use `FilterFactory` instead.");const M=null;Kp(u);const W={canvasFactory:new q({ownerDocument:F,enableHWA:$}),filterFactory:new H({docId:e,ownerDocument:F}),cMapReaderFactory:rt?null:new y({baseUrl:g,isCompressed:A}),standardFontDataFactory:rt?null:new v({baseUrl:w})};if(!d){const dt={verbosity:u,port:ii.workerPort};d=dt.port?mr.fromPort(dt):new mr(dt),t._worker=d}const lt={docId:e,apiVersion:"4.8.69",data:i,password:o,disableAutoFetch:z,rangeChunkSize:h,length:B,docBaseUrl:f,enableXfa:O,evaluatorOptions:{maxImageSize:S,disableFontFace:P,ignoreErrors:_,isEvalSupported:E,isOffscreenCanvasSupported:C,isChrome:x,canvasMaxAreaInBytes:T,fontExtraProperties:L,useSystemFonts:V,cMapUrl:rt?g:null,standardFontDataUrl:rt?w:null}},gt={disableFontFace:P,fontExtraProperties:L,ownerDocument:F,pdfBug:X,styleElement:M,loadingParams:{disableAutoFetch:z,enableXfa:O}};return d.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const dt=d.messageHandler.sendWithPromise("GetDocRequest",lt,i?[i.buffer]:null);let nt;if(l)nt=new $g(l,{disableRange:J,disableStream:U});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");let me;le?me=typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype&&Sa(s)?jd:tm:me=Sa(s)?jd:Yg,nt=new me({url:s,length:B,httpHeaders:n,withCredentials:a,rangeChunkSize:h,disableRange:J,disableStream:U})}return dt.then(me=>{if(t.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const be=new La(e,me,d.port),_t=new vm(be,t,nt,gt,W);t._transport=_t,be.send("Ready",null)})}).catch(t._capability.reject),t}function gm(c){if(c instanceof URL)return c.href;try{return new URL(c,window.location).href}catch{if(le&&typeof c=="string")return c}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function mm(c){if(le&&typeof Buffer<"u"&&c instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(c instanceof Uint8Array&&c.byteLength===c.buffer.byteLength)return c;if(typeof c=="string")return Eh(c);if(c instanceof ArrayBuffer||ArrayBuffer.isView(c)||typeof c=="object"&&!isNaN(c==null?void 0:c.length))return new Uint8Array(c);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function $d(c){return typeof c=="object"&&Number.isInteger(c==null?void 0:c.num)&&c.num>=0&&Number.isInteger(c==null?void 0:c.gen)&&c.gen>=0}var ch;const dh=class dh{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${he(dh,ch)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var t,e,s;this.destroyed=!0;try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await((e=this._transport)==null?void 0:e.destroy())}catch(i){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,i}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}};ch=new WeakMap,b(dh,ch,0);let _c=dh,Zu=class{constructor(t,e,s=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(const s of this._rangeListeners)s(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(const s of this._progressListeners)s(t,e)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(const e of this._progressiveReadListeners)e(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){wt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class bm{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 ot(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var Ti,js,Ge,dr,kl;class Am{constructor(t,e,s,i=!1){b(this,Ge);b(this,Ti,null);b(this,js,!1);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new Td:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new tf,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:n=!1}={}){return new al({viewBox:this.view,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return ot(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,viewport:e,intent:s="display",annotationMode:i=di.ENABLE,transform:n=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:h=null,printAnnotationStorage:d=null,isEditing:u=!1}){var E,C;(E=this._stats)==null||E.time("Overall");const f=this._transport.getRenderingIntent(s,i,d,u),{renderingIntent:g,cacheKey:A}=f;p(this,js,!1),m(this,Ge,kl).call(this),o||(o=this._transport.getOptionalContentConfig(g));let y=this._intentStates.get(A);y||(y=Object.create(null),this._intentStates.set(A,y)),y.streamReaderCancelTimeout&&(clearTimeout(y.streamReaderCancelTimeout),y.streamReaderCancelTimeout=null);const w=!!(g&Fe.PRINT);y.displayReadyCapability||(y.displayReadyCapability=Promise.withResolvers(),y.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(C=this._stats)==null||C.time("Page Request"),this._pumpOperatorList(f));const v=x=>{var T;y.renderTasks.delete(_),(this._maybeCleanupAfterRender||w)&&p(this,js,!0),m(this,Ge,dr).call(this,!w),x?(_.capability.reject(x),this._abortOperatorList({intentState:y,reason:x instanceof Error?x:new Error(x)})):_.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(T=globalThis.Stats)!=null&&T.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},_=new Sc({callback:v,params:{canvasContext:t,viewport:e,transform:n,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:!w,pdfBug:this._pdfBug,pageColors:h});(y.renderTasks||(y.renderTasks=new Set)).add(_);const S=_.task;return Promise.all([y.displayReadyCapability.promise,o]).then(([x,T])=>{var P;if(this.destroyed){v();return}if((P=this._stats)==null||P.time("Rendering"),!(T.renderingIntent&g))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");_.initializeGraphics({transparency:x,optionalContentConfig:T}),_.operatorListChanged()}).catch(v),S}getOperatorList({intent:t="display",annotationMode:e=di.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){var h;function n(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(l))}const a=this._transport.getRenderingIntent(t,e,s,i,!0);let o=this._intentStates.get(a.cacheKey);o||(o=Object.create(null),this._intentStates.set(a.cacheKey,o));let l;return o.opListReadCapability||(l=Object.create(null),l.operatorListChanged=n,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(l),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(h=this._stats)==null||h.time("Page Request"),this._pumpOperatorList(a)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(i){return i.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>Ga.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){function n(){a.read().then(function({value:l,done:h}){if(h){s(o);return}o.lang??(o.lang=l.lang),Object.assign(o.styles,l.styles),o.items.push(...l.items),n()},i)}const a=e.getReader(),o={items:[],styles:Object.create(null),lang:null};n()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),p(this,js,!1),m(this,Ge,kl).call(this),Promise.all(t)}cleanup(t=!1){p(this,js,!0);const e=m(this,Ge,dr).call(this,!1);return t&&e&&this._stats&&(this._stats=new Td),e}_startRenderPage(t,e){var i,n;const s=this._intentStates.get(e);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(n=s.displayReadyCapability)==null||n.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s{l.read().then(({value:u,done:f})=>{if(f){h.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(u,h),d())},u=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(const f of h.renderTasks)f.operatorListChanged();m(this,Ge,dr).call(this,!0)}if(h.displayReadyCapability)h.displayReadyCapability.reject(u);else if(h.opListReadCapability)h.opListReadCapability.reject(u);else throw u}})};d()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof dd){let i=lm;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new er(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,n]of this._intentStates)if(n===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}Ti=new WeakMap,js=new WeakMap,Ge=new WeakSet,dr=function(t=!1){if(m(this,Ge,kl).call(this),!r(this,js)||this.destroyed)return!1;if(t)return p(this,Ti,setTimeout(()=>{p(this,Ti,null),m(this,Ge,dr).call(this,!1)},hm)),!1;for(const{renderTasks:e,operatorList:s}of this._intentStates.values())if(e.size>0||!s.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),p(this,js,!1),!0},kl=function(){r(this,Ti)&&(clearTimeout(r(this,Ti)),p(this,Ti,null))};var $s,uh;class ym{constructor(){b(this,$s,new Map);b(this,uh,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};r(this,uh).then(()=>{for(const[i]of r(this,$s))i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:n}=s;if(n.aborted){st("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(t,e);i=()=>n.removeEventListener("abort",a),n.addEventListener("abort",a)}r(this,$s).set(e,i)}removeEventListener(t,e){const s=r(this,$s).get(e);s==null||s(),r(this,$s).delete(e)}terminate(){for(const[,t]of r(this,$s))t==null||t();r(this,$s).clear()}}$s=new WeakMap,uh=new WeakMap;var fh,En,Sn,zr,Ll,Gr,Ml;const Et=class Et{constructor({name:t=null,port:e=null,verbosity:s=Qp()}={}){b(this,zr);var i;if(this.name=t,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if((i=r(Et,Sn))!=null&&i.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(r(Et,Sn)||p(Et,Sn,new WeakMap)).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return le?Promise.all([ji.promise,this._readyCapability.promise]):this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new La("main","worker",t),this._messageHandler.on("ready",function(){}),m(this,zr,Ll).call(this)}_initialize(){if(r(Et,En)||r(Et,Gr,Ml)){this._setupFakeWorker();return}let{workerSrc:t}=Et;try{Et._isSameOrigin(window.location.href,t)||(t=Et._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new La("main","worker",e),i=()=>{n.abort(),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=new AbortController;e.addEventListener("error",()=>{this._webWorker||i()},{signal:n.signal}),s.on("test",o=>{if(n.abort(),this.destroyed||!o){i();return}this._messageHandler=s,this._port=e,this._webWorker=e,m(this,zr,Ll).call(this)}),s.on("ready",o=>{if(n.abort(),this.destroyed){i();return}try{a()}catch{this._setupFakeWorker()}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{wh("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){r(Et,En)||(st("Setting up fake worker."),p(Et,En,!0)),Et._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new ym;this._port=e;const s=`fake${he(Et,fh)._++}`,i=new La(s+"_worker",s,e);t.setup(i,e),this._messageHandler=new La(s,s+"_worker",e),m(this,zr,Ll).call(this)}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){var t;this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),(t=r(Et,Sn))==null||t.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(t){var s;if(!(t!=null&&t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");const e=(s=r(this,Sn))==null?void 0:s.get(t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new Et(t)}static get workerSrc(){if(ii.workerSrc)return ii.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return ot(this,"_setupFakeWorkerGlobal",(async()=>r(this,Gr,Ml)?r(this,Gr,Ml):(await import(this.workerSrc)).WorkerMessageHandler)())}};fh=new WeakMap,En=new WeakMap,Sn=new WeakMap,zr=new WeakSet,Ll=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},Gr=new WeakSet,Ml=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},b(Et,Gr),b(Et,fh,0),b(Et,En,!1),b(Et,Sn),le&&(p(Et,En,!0),ii.workerSrc||(ii.workerSrc="./pdf.worker.mjs")),Et._isSameOrigin=(t,e)=>{let s;try{if(s=new URL(t),!s.origin||s.origin==="null")return!1}catch{return!1}const i=new URL(e,s);return s.origin===i.origin},Et._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let mr=Et;var zs,vs,Ur,Wr,ws,xn,Ma;class vm{constructor(t,e,s,i,n){b(this,xn);b(this,zs,new Map);b(this,vs,new Map);b(this,Ur,new Map);b(this,Wr,new Map);b(this,ws,null);this.messageHandler=t,this.loadingTask=e,this.commonObjs=new tf,this.fontLoader=new bg({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return ot(this,"annotationStorage",new gd)}getRenderingIntent(t,e=di.ENABLE,s=null,i=!1,n=!1){let a=Fe.DISPLAY,o=cc;switch(t){case"any":a=Fe.ANY;break;case"display":break;case"print":a=Fe.PRINT;break;default:st(`getRenderingIntent - invalid intent: ${t}`)}const l=a&Fe.PRINT&&s instanceof Lu?s:this.annotationStorage;switch(e){case di.DISABLE:a+=Fe.ANNOTATIONS_DISABLE;break;case di.ENABLE:break;case di.ENABLE_FORMS:a+=Fe.ANNOTATIONS_FORMS;break;case di.ENABLE_STORAGE:a+=Fe.ANNOTATIONS_STORAGE,o=l.serializable;break;default:st(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(a+=Fe.IS_EDITING),n&&(a+=Fe.OPLIST);const{ids:h,hash:d}=l.modifiedIds,u=[a,o.hash,d];return{renderingIntent:a,cacheKey:u.join("_"),annotationStorageSerializable:o,modifiedIds:h}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=r(this,ws))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of r(this,vs).values())t.push(i._destroy());r(this,vs).clear(),r(this,Ur).clear(),r(this,Wr).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var i;this.commonObjs.clear(),this.fontLoader.clear(),r(this,zs).clear(),this.filterFactory.destroy(),yc.cleanup(),(i=this._networkStream)==null||i.cancelAllRequests(new er("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{jt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=n=>{this._lastProgress={loaded:n.loaded,total:n.total}},i.onPull=()=>{this._fullReader.read().then(function({value:n,done:a}){if(a){i.close();return}jt(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(n),1,[n])}).catch(n=>{i.error(n)})},i.onCancel=n=>{this._fullReader.cancel(n),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("ReaderHeadersReady",async s=>{var o;await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:n,contentLength:a}=this._fullReader;return(!i||!n)&&(this._lastProgress&&((o=e.onProgress)==null||o.call(e,this._lastProgress)),this._fullReader.onProgress=l=>{var h;(h=e.onProgress)==null||h.call(e,{loaded:l.loaded,total:l.total})}),{isStreamingSupported:i,isRangeSupported:n,contentLength:a}}),t.on("GetRangeReader",(s,i)=>{jt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(s.begin,s.end);if(!n){i.close();return}i.onPull=()=>{n.read().then(function({value:a,done:o}){if(o){i.close();return}jt(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{i.error(a)})},i.onCancel=a=>{n.cancel(a),i.ready.catch(o=>{if(!this.destroyed)throw o})}}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new bm(s,this))}),t.on("DocException",function(s){let i;switch(s.name){case"PasswordException":i=new zh(s.message,s.code);break;case"InvalidPDFException":i=new iu(s.message);break;case"MissingPDFException":i=new tr(s.message);break;case"UnexpectedResponseException":i=new _h(s.message,s.status);break;case"UnknownErrorException":i=new Gh(s.message,s.details);break;default:wt("DocException - expected a valid Error.")}e._capability.reject(i)}),t.on("PasswordRequest",s=>{if(p(this,ws,Promise.withResolvers()),e.onPassword){const i=n=>{n instanceof Error?r(this,ws).reject(n):r(this,ws).resolve({password:n})};try{e.onPassword(i,s.code)}catch(n){r(this,ws).reject(n)}}else r(this,ws).reject(new zh(s.message,s.code));return r(this,ws).promise}),t.on("DataLoaded",s=>{var i;(i=e.onProgress)==null||i.call(e,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;r(this,vs).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,n])=>{var a;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":const{disableFontFace:o,fontExtraProperties:l,pdfBug:h}=this._params;if("error"in n){const g=n.error;st(`Error during font loading: ${g}`),this.commonObjs.resolve(s,g);break}const d=h&&((a=globalThis.FontInspector)!=null&&a.enabled)?(g,A)=>globalThis.FontInspector.fontAdded(g,A):null,u=new Ag(n,{disableFontFace:o,inspectFont:d});this.fontLoader.bind(u).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!l&&u.data&&(u.data=null),this.commonObjs.resolve(s,u)});break;case"CopyLocalImage":const{imageRef:f}=n;jt(f,"The imageRef must be defined.");for(const g of r(this,vs).values())for(const[,A]of g.objs)if((A==null?void 0:A.ref)===f)return A.dataLen?(this.commonObjs.resolve(s,structuredClone(A)),A.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,n);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,n,a])=>{var l;if(this.destroyed)return;const o=r(this,vs).get(i);if(!o.objs.has(s)){if(o._intentStates.size===0){(l=a==null?void 0:a.bitmap)==null||l.close();return}switch(n){case"Image":o.objs.resolve(s,a),(a==null?void 0:a.dataLen)>Vp&&(o._maybeCleanupAfterRender=!0);break;case"Pattern":o.objs.resolve(s,a);break;default:throw new Error(`Got unknown object type ${n}`)}}}),t.on("DocProgress",s=>{var i;this.destroyed||(i=e.onProgress)==null||i.call(e,{loaded:s.loaded,total:s.total})}),t.on("FetchBuiltInCMap",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(s)}),t.on("FetchStandardFontData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var s;this.annotationStorage.size<=0&&st("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:((s=this._fullReader)==null?void 0:s.filename)??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=r(this,Ur).get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&r(this,Wr).set(n.refStr,t);const a=new Am(e,n,this,this._params.pdfBug);return r(this,vs).set(e,a),a});return r(this,Ur).set(e,i),i}getPageIndex(t){return $d(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 m(this,xn,Ma).call(this,"GetFieldObjects")}hasJSActions(){return m(this,xn,Ma).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return m(this,xn,Ma).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 m(this,xn,Ma).call(this,"GetOptionalContentConfig").then(e=>new jg(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=r(this,zs).get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(i=>{var n,a;return{info:i[0],metadata:i[1]?new Hg(i[1]):null,contentDispositionFilename:((n=this._fullReader)==null?void 0:n.filename)??null,contentLength:((a=this._fullReader)==null?void 0:a.contentLength)??null}});return r(this,zs).set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of r(this,vs).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),r(this,zs).clear(),this.filterFactory.destroy(!0),yc.cleanup()}}cachedPageNumber(t){if(!$d(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return r(this,Wr).get(e)??null}}zs=new WeakMap,vs=new WeakMap,Ur=new WeakMap,Wr=new WeakMap,ws=new WeakMap,xn=new WeakSet,Ma=function(t,e=null){const s=r(this,zs).get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return r(this,zs).set(t,i),i};const bl=Symbol("INITIAL_DATA");var ts,To,Ec;class tf{constructor(){b(this,To);b(this,ts,Object.create(null))}get(t,e=null){if(e){const i=m(this,To,Ec).call(this,t);return i.promise.then(()=>e(i.data)),null}const s=r(this,ts)[t];if(!s||s.data===bl)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=r(this,ts)[t];return!!e&&e.data!==bl}resolve(t,e=null){const s=m(this,To,Ec).call(this,t);s.data=e,s.resolve()}clear(){var t;for(const e in r(this,ts)){const{data:s}=r(this,ts)[e];(t=s==null?void 0:s.bitmap)==null||t.close()}p(this,ts,Object.create(null))}*[Symbol.iterator](){for(const t in r(this,ts)){const{data:e}=r(this,ts)[t];e!==bl&&(yield[t,e])}}}ts=new WeakMap,To=new WeakSet,Ec=function(t){var e;return(e=r(this,ts))[t]||(e[t]={...Promise.withResolvers(),data:bl})};var Ri;class wm{constructor(t){b(this,Ri,null);p(this,Ri,t),this.onContinue=null}get promise(){return r(this,Ri).capability.promise}cancel(t=0){r(this,Ri).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=r(this,Ri).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=r(this,Ri);return t.form||t.canvas&&(e==null?void 0:e.size)>0}}Ri=new WeakMap;var Pi,Cn;const Ki=class Ki{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:h,useRequestAnimationFrame:d=!1,pdfBug:u=!1,pageColors:f=null}){b(this,Pi,null);this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=h,this._pdfBug=u,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=d===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new wm(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){var o,l;if(this.cancelled)return;if(this._canvas){if(r(Ki,Cn).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.");r(Ki,Cn).add(this._canvas)}this._pdfBug&&((o=globalThis.StepperManager)!=null&&o.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:s,viewport:i,transform:n,background:a}=this.params;this.gfx=new gr(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:i,transparency:t,background:a}),this.operatorListIdx=0,this.graphicsReady=!0,(l=this.graphicsReadyCallback)==null||l.call(this)}cancel(t=null,e=0){var s;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),r(this,Pi)&&(window.cancelAnimationFrame(r(this,Pi)),p(this,Pi,null)),r(Ki,Cn).delete(this._canvas),this.callback(t||new dd(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){var t;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(t=this.stepper)==null||t.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?p(this,Pi,window.requestAnimationFrame(()=>{p(this,Pi,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),r(Ki,Cn).delete(this._canvas),this.callback())))}};Pi=new WeakMap,Cn=new WeakMap,b(Ki,Cn,new WeakSet);let Sc=Ki;const _m="4.8.69",Em="3634dab10";function zd(c){return Math.floor(Math.max(0,Math.min(1,c))*255).toString(16).padStart(2,"0")}function Ea(c){return Math.max(0,Math.min(255,255*c))}class Gd{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=Ea(t),[t,t,t]}static G_HTML([t]){const e=zd(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(Ea)}static RGB_HTML(t){return`#${t.map(zd).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[Ea(1-Math.min(1,t+i)),Ea(1-Math.min(1,s+i)),Ea(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,n=1-e,a=1-s,o=Math.min(i,n,a);return["CMYK",i,n,a,o]}}class Sm{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){wt("Abstract method `_createSVG` called.")}}class vd extends Sm{_createSVG(t){return document.createElementNS(ks,t)}}class ef{static setupStorage(t,e,s,i,n){const a=i.getValue(e,{value:null});switch(s.name){case"textarea":if(a.value!==null&&(t.textContent=a.value),n==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(a.value===s.attributes.xfaOn?t.setAttribute("checked",!0):a.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",o=>{i.setValue(e,{value:o.target.checked?o.target.getAttribute("xfaOn"):o.target.getAttribute("xfaOff")})})}else{if(a.value!==null&&t.setAttribute("value",a.value),n==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})})}break;case"select":if(a.value!==null){t.setAttribute("value",a.value);for(const o of s.children)o.attributes.value===a.value?o.attributes.selected=!0:o.attributes.hasOwnProperty("selected")&&delete o.attributes.selected}t.addEventListener("input",o=>{const l=o.target.options,h=l.selectedIndex===-1?"":l[l.selectedIndex].value;i.setValue(e,{value:h})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:a}=e,o=t instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${i}`);for(const[l,h]of Object.entries(a))if(h!=null)switch(l){case"class":h.length&&t.setAttribute(l,h.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",h);break;case"style":Object.assign(t.style,h);break;case"textContent":t.textContent=h;break;default:(!o||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,h)}o&&n.addLinkAttributes(t,a.href,a.newWindow),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){var u,f;const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",a=document.createElement(i.name);i.attributes&&this.setAttributes({html:a,element:i,intent:n,linkService:s});const o=n!=="richText",l=t.div;if(l.append(a),t.viewport){const g=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=g}o&&l.setAttribute("class","xfaLayer xfaFont");const h=[];if(i.children.length===0){if(i.value){const g=document.createTextNode(i.value);a.append(g),o&&Ga.shouldBuildText(i.name)&&h.push(g)}return{textDivs:h}}const d=[[i,-1,a]];for(;d.length>0;){const[g,A,y]=d.at(-1);if(A+1===g.children.length){d.pop();continue}const w=g.children[++d.at(-1)[1]];if(w===null)continue;const{name:v}=w;if(v==="#text"){const S=document.createTextNode(w.value);h.push(S),y.append(S);continue}const _=(u=w==null?void 0:w.attributes)!=null&&u.xmlns?document.createElementNS(w.attributes.xmlns,v):document.createElement(v);if(y.append(_),w.attributes&&this.setAttributes({html:_,element:w,storage:e,intent:n,linkService:s}),((f=w.children)==null?void 0:f.length)>0)d.push([w,-1,_]);else if(w.value){const S=document.createTextNode(w.value);o&&Ga.shouldBuildText(v)&&h.push(S),_.append(S)}}for(const g of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))g.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const ll=1e3,xm=9,Kn=new WeakSet;function ni(c){return{width:c[2]-c[0],height:c[3]-c[1]}}class Cm{static create(t){switch(t.data.annotationType){case Ot.LINK:return new sf(t);case Ot.TEXT:return new Tm(t);case Ot.WIDGET:switch(t.data.fieldType){case"Tx":return new Rm(t);case"Btn":return t.data.radioButton?new af(t):t.data.checkBox?new km(t):new Lm(t);case"Ch":return new Mm(t);case"Sig":return new Pm(t)}return new sr(t);case Ot.POPUP:return new Cc(t);case Ot.FREETEXT:return new df(t);case Ot.LINE:return new Fm(t);case Ot.SQUARE:return new Dm(t);case Ot.CIRCLE:return new Om(t);case Ot.POLYLINE:return new uf(t);case Ot.CARET:return new Hm(t);case Ot.INK:return new wd(t);case Ot.POLYGON:return new Nm(t);case Ot.HIGHLIGHT:return new ff(t);case Ot.UNDERLINE:return new Bm(t);case Ot.SQUIGGLY:return new jm(t);case Ot.STRIKEOUT:return new $m(t);case Ot.STAMP:return new pf(t);case Ot.FILEATTACHMENT:return new zm(t);default:return new Lt(t)}}}var Tn,Vr,qr,Ro,xc;const Sd=class Sd{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){b(this,Ro);b(this,Tn,null);b(this,Vr,!1);b(this,qr,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.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:s}){return!!(t!=null&&t.str||e!=null&&e.str||s!=null&&s.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Sd._hasPopupData(this.data)}updateEdited(t){var s;if(!this.container)return;r(this,Tn)||p(this,Tn,{rect:this.data.rect.slice(0)});const{rect:e}=t;e&&m(this,Ro,xc).call(this,e),(s=r(this,qr))==null||s.popup.updateEdited(t)}resetEdited(){var t;r(this,Tn)&&(m(this,Ro,xc).call(this,r(this,Tn).rect),(t=r(this,qr))==null||t.popup.resetEdited(),p(this,Tn,null))}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof sr||(n.tabIndex=ll);const{style:a}=n;if(a.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Cc){const{rotation:y}=e;return!e.hasOwnCanvas&&y!==0&&this.setRotation(y,n),n}const{width:o,height:l}=ni(e.rect);if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const y=e.borderStyle.horizontalCornerRadius,w=e.borderStyle.verticalCornerRadius;if(y>0||w>0){const _=`calc(${y}px * var(--scale-factor)) / calc(${w}px * var(--scale-factor))`;a.borderRadius=_}else if(this instanceof af){const _=`calc(${o}px * var(--scale-factor)) / calc(${l}px * var(--scale-factor))`;a.borderRadius=_}switch(e.borderStyle.style){case wa.SOLID:a.borderStyle="solid";break;case wa.DASHED:a.borderStyle="dashed";break;case wa.BEVELED:st("Unimplemented border style: beveled");break;case wa.INSET:st("Unimplemented border style: inset");break;case wa.UNDERLINE:a.borderBottomStyle="solid";break}const v=e.borderColor||null;v?(p(this,Vr,!0),a.borderColor=j.makeHexColor(v[0]|0,v[1]|0,v[2]|0)):a.borderWidth=0}const h=j.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:d,pageHeight:u,pageX:f,pageY:g}=i.rawDims;a.left=`${100*(h[0]-f)/d}%`,a.top=`${100*(h[1]-g)/u}%`;const{rotation:A}=e;return e.hasOwnCanvas||A===0?(a.width=`${100*o/d}%`,a.height=`${100*l/u}%`):this.setRotation(A,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:n,height:a}=ni(this.data.rect);let o,l;t%180===0?(o=100*n/s,l=100*a/i):(o=100*a/s,l=100*n/i),e.style.width=`${o}%`,e.style.height=`${l}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const n=i.detail[e],a=n[0],o=n.slice(1);i.target.style[s]=Gd[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:Gd[`${a}_rgb`](o)})};return ot(this,"_commonActions",{display:e=>{const{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail)){const n=t[i]||s[i];n==null||n(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,n]of Object.entries(e)){const a=s[i];if(a){const o={detail:{[i]:n},target:t};a(o),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,n]=this.data.rect.map(y=>Math.fround(y));if(t.length===8){const[y,w,v,_]=t.subarray(2,6);if(i===y&&n===w&&e===v&&s===_)return}const{style:a}=this.container;let o;if(r(this,Vr)){const{borderColor:y,borderWidth:w}=a;a.borderWidth=0,o=["url('data:image/svg+xml;utf8,",'',``],this.container.classList.add("hasBorder")}const l=i-e,h=n-s,{svgFactory:d}=this,u=d.createElement("svg");u.classList.add("quadrilateralsContainer"),u.setAttribute("width",0),u.setAttribute("height",0);const f=d.createElement("defs");u.append(f);const g=d.createElement("clipPath"),A=`clippath_${this.data.id}`;g.setAttribute("id",A),g.setAttribute("clipPathUnits","objectBoundingBox"),f.append(g);for(let y=2,w=t.length;y`)}r(this,Vr)&&(o.push("')"),a.backgroundImage=o.join("")),this.container.append(u),this.container.style.clipPath=`url(#${A})`}_createPopup(){const{data:t}=this,e=p(this,qr,new Cc({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(e.render())}render(){wt("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:n,id:a,exportValues:o}of i){if(n===-1||a===e)continue;const l=typeof o=="string"?o:null,h=document.querySelector(`[data-element-id="${a}"]`);if(h&&!Kn.has(h)){st(`_getElementsByName - element not allowed: ${a}`);continue}s.push({id:a,exportValue:l,domElement:h})}return s}for(const i of document.getElementsByName(t)){const{exportValue:n}=i,a=i.getAttribute("data-element-id");a!==e&&Kn.has(i)&&s.push({id:a,exportValue:n,domElement:i})}return s}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||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 s;(s=this.linkService.eventBus)==null||s.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})})}};Tn=new WeakMap,Vr=new WeakMap,qr=new WeakMap,Ro=new WeakSet,xc=function(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:a,pageX:o,pageY:l}}}}=this;s==null||s.splice(0,4,...t);const{width:h,height:d}=ni(t);e.left=`${100*(t[0]-o)/n}%`,e.top=`${100*(a-t[3]+l)/a}%`,i===0?(e.width=`${100*h/n}%`,e.height=`${100*d/a}%`):this.setRotation(i)};let Lt=Sd;var De,Wi,nf,rf;class sf extends Lt{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});b(this,De);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let n=!1;return e.url?(s.addLinkAttributes(i,e.url,e.newWindow),n=!0):e.action?(this._bindNamedAction(i,e.action),n=!0):e.attachment?(m(this,De,nf).call(this,i,e.attachment,e.attachmentDest),n=!0):e.setOCGState?(m(this,De,rf).call(this,i,e.setOCGState),n=!0):e.dest?(this._bindLink(i,e.dest),n=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,e),n=!0),e.resetForm?(this._bindResetFormAction(i,e.resetForm),n=!0):this.isTooltipOnly&&!n&&(this._bindLink(i,""),n=!0)),this.container.classList.add("linkAnnotation"),n&&this.container.append(i),this.container}_bindLink(e,s){e.href=this.linkService.getDestinationHash(s),e.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&m(this,De,Wi).call(this)}_bindNamedAction(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),m(this,De,Wi).call(this)}_bindJSAction(e,s){e.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const n of Object.keys(s.actions)){const a=i.get(n);a&&(e[a]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:n}}),!1})}e.onclick||(e.onclick=()=>!1),m(this,De,Wi).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),m(this,De,Wi).call(this),!this._fieldObjects){st('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(e.onclick=()=>!1);return}e.onclick=()=>{var u;i==null||i();const{fields:n,refs:a,include:o}=s,l=[];if(n.length!==0||a.length!==0){const f=new Set(a);for(const g of n){const A=this._fieldObjects[g]||[];for(const{id:y}of A)f.add(y)}for(const g of Object.values(this._fieldObjects))for(const A of g)f.has(A.id)===o&&l.push(A)}else for(const f of Object.values(this._fieldObjects))l.push(...f);const h=this.annotationStorage,d=[];for(const f of l){const{id:g}=f;switch(d.push(g),f.type){case"text":{const y=f.defaultValue||"";h.setValue(g,{value:y});break}case"checkbox":case"radiobutton":{const y=f.defaultValue===f.exportValues;h.setValue(g,{value:y});break}case"combobox":case"listbox":{const y=f.defaultValue||"";h.setValue(g,{value:y});break}default:continue}const A=document.querySelector(`[data-element-id="${g}"]`);if(A){if(!Kn.has(A)){st(`_bindResetFormAction - element not allowed: ${g}`);continue}}else continue;A.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((u=this.linkService.eventBus)==null||u.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:d,name:"ResetForm"}})),!1}}}De=new WeakSet,Wi=function(){this.container.setAttribute("data-internal-link","")},nf=function(e,s,i=null){e.href=this.linkService.getAnchorUrl(""),s.description&&(e.title=s.description),e.onclick=()=>{var n;return(n=this.downloadManager)==null||n.openOrDownloadData(s.content,s.filename,i),!1},m(this,De,Wi).call(this)},rf=function(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),m(this,De,Wi).call(this)};class Tm extends Lt{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 sr extends Lt{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&(((e=t.previousSibling)==null?void 0:e.nodeName)==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return fe.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){s.includes("mouse")?t.addEventListener(s,a=>{var o;(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(a),shift:a.shiftKey,modifier:this._getKeyModifier(a)}})}):t.addEventListener(s,a=>{var o;if(s==="blur"){if(!e.focused||!a.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}n&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(a)}}))})}_setEventListeners(t,e,s,i){var n,a,o;for(const[l,h]of s)(h==="Action"||(n=this.data.actions)!=null&&n[h])&&((h==="Focus"||h==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,l,h,i),h==="Focus"&&!((a=this.data.actions)!=null&&a.Blur)?this._setEventListener(t,e,"blur","Blur",null):h==="Blur"&&!((o=this.data.actions)!=null&&o.Focus)&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":j.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||xm,n=t.style;let a;const o=2,l=h=>Math.round(10*h)/10;if(this.data.multiLine){const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o),d=Math.round(h/(Ih*i))||1,u=h/d;a=Math.min(i,l(u/Ih))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(i,l(h/Ih))}n.fontSize=`calc(${a}px * var(--scale-factor))`,n.color=j.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Rm extends sr{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){const n=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=s),n.setValue(a.id,{[i]:s})}render(){var i,n;const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const a=t.getValue(e,{value:this.data.fieldValue});let o=a.value||"";const l=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;l&&o.length>l&&(o=o.slice(0,l));let h=a.formattedValue||((i=this.data.textContent)==null?void 0:i.join(` +`))||null;h&&this.data.comb&&(h=h.replaceAll(/\s+/g,""));const d={userValue:o,formattedValue:h,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=h??o,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",h??o),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),Kn.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=ll,this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",f=>{t.setValue(e,{value:f.target.value}),this.setPropertyOnSiblings(s,"value",f.target.value,"value"),d.formattedValue=null}),s.addEventListener("resetform",f=>{const g=this.data.defaultFieldValue??"";s.value=d.userValue=g,d.formattedValue=null});let u=f=>{const{formattedValue:g}=d;g!=null&&(f.target.value=g),f.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",g=>{var y;if(d.focused)return;const{target:A}=g;d.userValue&&(A.value=d.userValue),d.lastCommittedValue=A.value,d.commitKey=1,(y=this.data.actions)!=null&&y.Focus||(d.focused=!0)}),s.addEventListener("updatefromsandbox",g=>{this.showElementAndHideCanvas(g.target);const A={value(y){d.userValue=y.detail.value??"",t.setValue(e,{value:d.userValue.toString()}),y.target.value=d.userValue},formattedValue(y){const{formattedValue:w}=y.detail;d.formattedValue=w,w!=null&&y.target!==document.activeElement&&(y.target.value=w),t.setValue(e,{formattedValue:w})},selRange(y){y.target.setSelectionRange(...y.detail.selRange)},charLimit:y=>{var S;const{charLimit:w}=y.detail,{target:v}=y;if(w===0){v.removeAttribute("maxLength");return}v.setAttribute("maxLength",w);let _=d.userValue;!_||_.length<=w||(_=_.slice(0,w),v.value=d.userValue=_,t.setValue(e,{value:_}),(S=this.linkService.eventBus)==null||S.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,willCommit:!0,commitKey:1,selStart:v.selectionStart,selEnd:v.selectionEnd}}))}};this._dispatchEventFromSandbox(A,g)}),s.addEventListener("keydown",g=>{var w;d.commitKey=1;let A=-1;if(g.key==="Escape"?A=0:g.key==="Enter"&&!this.data.multiLine?A=2:g.key==="Tab"&&(d.commitKey=3),A===-1)return;const{value:y}=g.target;d.lastCommittedValue!==y&&(d.lastCommittedValue=y,d.userValue=y,(w=this.linkService.eventBus)==null||w.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:y,willCommit:!0,commitKey:A,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}}))});const f=u;u=null,s.addEventListener("blur",g=>{var y,w;if(!d.focused||!g.relatedTarget)return;(y=this.data.actions)!=null&&y.Blur||(d.focused=!1);const{value:A}=g.target;d.userValue=A,d.lastCommittedValue!==A&&((w=this.linkService.eventBus)==null||w.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:A,willCommit:!0,commitKey:d.commitKey,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}})),f(g)}),(n=this.data.actions)!=null&&n.Keystroke&&s.addEventListener("beforeinput",g=>{var C;d.lastCommittedValue=null;const{data:A,target:y}=g,{value:w,selectionStart:v,selectionEnd:_}=y;let S=v,E=_;switch(g.inputType){case"deleteWordBackward":{const x=w.substring(0,v).match(/\w*[^\w]*$/);x&&(S-=x[0].length);break}case"deleteWordForward":{const x=w.substring(v).match(/^[^\w]*\w*/);x&&(E+=x[0].length);break}case"deleteContentBackward":v===_&&(S-=1);break;case"deleteContentForward":v===_&&(E+=1);break}g.preventDefault(),(C=this.linkService.eventBus)==null||C.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:w,change:A||"",willCommit:!1,selStart:S,selEnd:E}})}),this._setEventListeners(s,d,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],g=>g.target.value)}if(u&&s.addEventListener("blur",u),this.data.comb){const g=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.letterSpacing=`calc(${g}px * var(--scale-factor) - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Pm extends sr{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class km extends sr{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",t.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return Kn.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=ll,n.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const h of this._getElementsByName(o,s)){const d=l&&h.exportValue===e.exportValue;h.domElement&&(h.domElement.checked=d),t.setValue(h.id,{value:d})}t.setValue(s,{value:l})}),n.addEventListener("resetform",a=>{const o=e.defaultFieldValue||"Off";a.target.checked=o===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",a=>{const o={value(l){l.target.checked=l.detail.value!=="Off",t.setValue(s,{value:l.target.checked})}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class af extends sr{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.fieldValue===e.buttonValue}).value;if(typeof i=="string"&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(const a of this._getElementsByName(e.fieldName,s))t.setValue(a.id,{value:!1});const n=document.createElement("input");if(Kn.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.tabIndex=ll,n.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const h of this._getElementsByName(o,s))t.setValue(h.id,{value:!1});t.setValue(s,{value:l})}),n.addEventListener("resetform",a=>{const o=e.defaultFieldValue;a.target.checked=o!=null&&o===e.buttonValue}),this.enableScripting&&this.hasJSActions){const a=e.buttonValue;n.addEventListener("updatefromsandbox",o=>{const l={value:h=>{const d=a===h.detail.value;for(const u of this._getElementsByName(h.target.name)){const f=d&&u.id===s;u.domElement&&(u.domElement.checked=f),t.setValue(u.id,{value:f})}}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Lm extends sf{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),t}}class Mm extends sr{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");Kn.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=ll;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",d=>{const u=this.data.defaultFieldValue;for(const f of i.options)f.selected=f.value===u});for(const d of this.data.options){const u=document.createElement("option");u.textContent=d.displayValue,u.value=d.exportValue,s.value.includes(d.exportValue)&&(u.setAttribute("selected",!0),n=!1),i.append(u)}let a=null;if(n){const d=document.createElement("option");d.value=" ",d.setAttribute("hidden",!0),d.setAttribute("selected",!0),i.prepend(d),a=()=>{d.remove(),i.removeEventListener("input",a),a=null},i.addEventListener("input",a)}const o=d=>{const u=d?"value":"textContent",{options:f,multiple:g}=i;return g?Array.prototype.filter.call(f,A=>A.selected).map(A=>A[u]):f.selectedIndex===-1?null:f[f.selectedIndex][u]};let l=o(!1);const h=d=>{const u=d.target.options;return Array.prototype.map.call(u,f=>({displayValue:f.textContent,exportValue:f.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",d=>{const u={value(f){a==null||a();const g=f.detail.value,A=new Set(Array.isArray(g)?g:[g]);for(const y of i.options)y.selected=A.has(y.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(f){i.multiple=!0},remove(f){const g=i.options,A=f.detail.remove;g[A].selected=!1,i.remove(A),g.length>0&&Array.prototype.findIndex.call(g,w=>w.selected)===-1&&(g[0].selected=!0),t.setValue(e,{value:o(!0),items:h(f)}),l=o(!1)},clear(f){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),l=o(!1)},insert(f){const{index:g,displayValue:A,exportValue:y}=f.detail.insert,w=i.children[g],v=document.createElement("option");v.textContent=A,v.value=y,w?w.before(v):i.append(v),t.setValue(e,{value:o(!0),items:h(f)}),l=o(!1)},items(f){const{items:g}=f.detail;for(;i.length!==0;)i.remove(0);for(const A of g){const{displayValue:y,exportValue:w}=A,v=document.createElement("option");v.textContent=y,v.value=w,i.append(v)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:o(!0),items:h(f)}),l=o(!1)},indices(f){const g=new Set(f.detail.indices);for(const A of f.target.options)A.selected=g.has(A.index);t.setValue(e,{value:o(!0)}),l=o(!1)},editable(f){f.target.disabled=!f.detail.editable}};this._dispatchEventFromSandbox(u,d)}),i.addEventListener("input",d=>{var g;const u=o(!0),f=o(!1);t.setValue(e,{value:u}),d.preventDefault(),(g=this.linkService.eventBus)==null||g.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:f,changeEx:u,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],d=>d.target.value)):i.addEventListener("input",function(d){t.setValue(e,{value:o(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Cc extends Lt{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:Lt._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Im({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(const s of this.elements)s.popup=t,s.container.ariaHasPopup="dialog",e.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(s=>`${cd}${s}`).join(",")),this.container}}var Xr,ph,gh,Yr,Rn,Rt,Gs,Kr,Po,ko,Qr,Us,es,Ws,Lo,Vs,Mo,Pn,kn,bt,Il,Tc,of,lf,hf,cf,Fl,Dl,Rc;class Im{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:a,richText:o,parent:l,rect:h,parentRect:d,open:u}){b(this,bt);b(this,Xr,m(this,bt,hf).bind(this));b(this,ph,m(this,bt,Rc).bind(this));b(this,gh,m(this,bt,Dl).bind(this));b(this,Yr,m(this,bt,Fl).bind(this));b(this,Rn,null);b(this,Rt,null);b(this,Gs,null);b(this,Kr,null);b(this,Po,null);b(this,ko,null);b(this,Qr,null);b(this,Us,!1);b(this,es,null);b(this,Ws,null);b(this,Lo,null);b(this,Vs,null);b(this,Mo,null);b(this,Pn,null);b(this,kn,!1);var f;p(this,Rt,t),p(this,Mo,i),p(this,Gs,a),p(this,Vs,o),p(this,ko,l),p(this,Rn,e),p(this,Lo,h),p(this,Qr,d),p(this,Po,s),p(this,Kr,fd.toDateObject(n)),this.trigger=s.flatMap(g=>g.getElementsToTriggerPopup());for(const g of this.trigger)g.addEventListener("click",r(this,Yr)),g.addEventListener("mouseenter",r(this,gh)),g.addEventListener("mouseleave",r(this,ph)),g.classList.add("popupTriggerArea");for(const g of s)(f=g.container)==null||f.addEventListener("keydown",r(this,Xr));r(this,Rt).hidden=!0,u&&m(this,bt,Fl).call(this)}render(){if(r(this,es))return;const t=p(this,es,document.createElement("div"));if(t.className="popup",r(this,Rn)){const n=t.style.outlineColor=j.makeHexColor(...r(this,Rn));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${n} 30%, white)`:t.style.backgroundColor=j.makeHexColor(...r(this,Rn).map(o=>Math.floor(.7*(255-o)+o)))}const e=document.createElement("span");e.className="header";const s=document.createElement("h1");if(e.append(s),{dir:s.dir,str:s.textContent}=r(this,Mo),t.append(e),r(this,Kr)){const n=document.createElement("span");n.classList.add("popupDate"),n.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),n.setAttribute("data-l10n-args",JSON.stringify({dateObj:r(this,Kr).valueOf()})),e.append(n)}const i=r(this,bt,Il);if(i)ef.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const n=this._formatContents(r(this,Gs));t.append(n)}r(this,Rt).append(t)}_formatContents({str:t,dir:e}){const s=document.createElement("p");s.classList.add("popupContent"),s.dir=e;const i=t.split(/(?:\r\n?|\n)/);for(let n=0,a=i.length;n{a.key==="Enter"&&(n?a.metaKey:a.ctrlKey)&&m(this,Bo,Pc).call(this)}),!s.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return r(this,Ho)}addHighlightArea(){this.container.classList.add("highlightArea")}}Ho=new WeakMap,Bo=new WeakSet,Pc=function(){var e;(e=this.downloadManager)==null||e.openOrDownloadData(this.content,this.filename)};var jo,Ln,Mn,$o,Jn,gf,kc,eu;let Gm=(eu=class{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:a,structTreeLayer:o}){b(this,Jn);b(this,jo,null);b(this,Ln,null);b(this,Mn,new Map);b(this,$o,null);this.div=t,p(this,jo,e),p(this,Ln,s),p(this,$o,o||null),this.page=n,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return r(this,Mn).size>0}async render(t){var a;const{annotations:e}=t,s=this.div;Xn(s,this.viewport);const i=new Map,n={data:null,layer:s,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new vd,annotationStorage:t.annotationStorage||new gd,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const o of e){if(o.noHTML)continue;const l=o.annotationType===Ot.POPUP;if(l){const u=i.get(o.id);if(!u)continue;n.elements=u}else{const{width:u,height:f}=ni(o.rect);if(u<=0||f<=0)continue}n.data=o;const h=Cm.create(n);if(!h.isRenderable)continue;if(!l&&o.popupRef){const u=i.get(o.popupRef);u?u.push(h):i.set(o.popupRef,[h])}const d=h.render();o.hidden&&(d.style.visibility="hidden"),await m(this,Jn,gf).call(this,d,o.id),h._isEditable&&(r(this,Mn).set(h.data.id,h),(a=this._annotationEditorUIManager)==null||a.renderAnnotationElement(h))}m(this,Jn,kc).call(this)}update({viewport:t}){const e=this.div;this.viewport=t,Xn(e,{rotation:t.rotation}),m(this,Jn,kc).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(r(this,Mn).values())}getEditableAnnotation(t){return r(this,Mn).get(t)}},jo=new WeakMap,Ln=new WeakMap,Mn=new WeakMap,$o=new WeakMap,Jn=new WeakSet,gf=async function(t,e){var a,o;const s=t.firstChild||t,i=s.id=`${cd}${e}`,n=await((a=r(this,$o))==null?void 0:a.getAriaAttributes(i));if(n)for(const[l,h]of n)s.setAttribute(l,h);this.div.append(t),(o=r(this,jo))==null||o.moveElementInDOM(this.div,t,s,!1)},kc=function(){if(!r(this,Ln))return;const t=this.div;for(const[e,s]of r(this,Ln)){const i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;s.className="annotationContent";const{firstChild:n}=i;n?n.nodeName==="CANVAS"?n.replaceWith(s):n.classList.contains("annotationContent")?n.after(s):n.before(s):i.append(s)}r(this,Ln).clear()},eu);const Al=/\r\n?|\n/g;var ss,Re,zo,In,Pe,Dt,mf,bf,Af,Ol,ai,Nl,Hl,yf,Mc,vf;const vt=class vt extends pt{constructor(e){super({...e,name:"freeTextEditor"});b(this,Dt);b(this,ss);b(this,Re,"");b(this,zo,`${this.id}-editor`);b(this,In,null);b(this,Pe);p(this,ss,e.color||vt._defaultColor||pt._defaultLineColor),p(this,Pe,e.fontSize||vt._defaultFontSize)}static get _keyboardManager(){const e=vt.prototype,s=a=>a.isEmpty(),i=Yn.TRANSLATE_SMALL,n=Yn.TRANSLATE_BIG;return ot(this,"_keyboardManager",new ol([[["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:[-i,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-n,0],checker:s}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[i,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[n,0],checker:s}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-n],checker:s}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,i],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,n],checker:s}]]))}static initialize(e,s){pt.initialize(e,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,s){switch(e){case K.FREETEXT_SIZE:vt._defaultFontSize=s;break;case K.FREETEXT_COLOR:vt._defaultColor=s;break}}updateParams(e,s){switch(e){case K.FREETEXT_SIZE:m(this,Dt,mf).call(this,s);break;case K.FREETEXT_COLOR:m(this,Dt,bf).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[K.FREETEXT_SIZE,vt._defaultFontSize],[K.FREETEXT_COLOR,vt._defaultColor||pt._defaultLineColor]]}get propertiesToUpdate(){return[[K.FREETEXT_SIZE,r(this,Pe)],[K.FREETEXT_COLOR,r(this,ss)]]}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-vt._internalPadding*e,-(vt._internalPadding+r(this,Pe))*e]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(tt.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),p(this,In,new AbortController);const e=this._uiManager.combinedSignal(r(this,In));this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e})}disableEditMode(){var e;this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",r(this,zo)),this._isDraggable=!0,(e=r(this,In))==null||e.abort(),p(this,In,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){var e;this.width||(this.enableEditMode(),this.editorDiv.focus(),(e=this._initialOptions)!=null&&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 e=r(this,Re),s=p(this,Re,m(this,Dt,Af).call(this).trimEnd());if(e===s)return;const i=n=>{if(p(this,Re,n),!n){this.remove();return}m(this,Dt,Hl).call(this),this._uiManager.rebuild(this),m(this,Dt,Ol).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),m(this,Dt,Ol).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(e){this.enterInEditMode()}keydown(e){e.target===this.div&&e.key==="Enter"&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){vt._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let e,s;this.width&&(e=this.x,s=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",r(this,zo)),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(${r(this,Pe)}px * var(--scale-factor))`,i.color=r(this,ss),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Kl(this,this.div,["dblclick","keydown"]),this.width){const[n,a]=this.parentDimensions;if(this.annotationElementId){const{position:o}=this._initialData;let[l,h]=this.getInitialTranslation();[l,h]=this.pageTranslationToScreen(l,h);const[d,u]=this.pageDimensions,[f,g]=this.pageTranslation;let A,y;switch(this.rotation){case 0:A=e+(o[0]-f)/d,y=s+this.height-(o[1]-g)/u;break;case 90:A=e+(o[0]-f)/d,y=s-(o[1]-g)/u,[l,h]=[h,-l];break;case 180:A=e-this.width+(o[0]-f)/d,y=s-(o[1]-g)/u,[l,h]=[-l,-h];break;case 270:A=e+(o[0]-f-this.height*u)/d,y=s+(o[1]-g-this.width*d)/u,[l,h]=[-h,l];break}this.setAt(A*n,y*a,l,h)}else this.setAt(e*n,s*a,this.width*n,this.height*a);m(this,Dt,Hl).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var A,y,w;const s=e.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();const n=m(A=vt,ai,Mc).call(A,s.getData("text")||"").replaceAll(Al,` +`);if(!n)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!n.includes(` +`)){o.insertNode(document.createTextNode(n)),this.editorDiv.normalize(),a.collapseToStart();return}const{startContainer:l,startOffset:h}=o,d=[],u=[];if(l.nodeType===Node.TEXT_NODE){const v=l.parentElement;if(u.push(l.nodeValue.slice(h).replaceAll(Al,"")),v!==this.editorDiv){let _=d;for(const S of this.editorDiv.childNodes){if(S===v){_=u;continue}_.push(m(y=vt,ai,Nl).call(y,S))}}d.push(l.nodeValue.slice(0,h).replaceAll(Al,""))}else if(l===this.editorDiv){let v=d,_=0;for(const S of this.editorDiv.childNodes)_++===h&&(v=u),v.push(m(w=vt,ai,Nl).call(w,S))}p(this,Re,`${d.join(` +`)}${n}${u.join(` +`)}`),m(this,Dt,Hl).call(this);const f=new Range;let g=d.reduce((v,_)=>v+_.length,0);for(const{firstChild:v}of this.editorDiv.childNodes)if(v.nodeType===Node.TEXT_NODE){const _=v.nodeValue.length;if(g<=_){f.setStart(v,g),f.setEnd(v,g);break}g-=_}a.removeAllRanges(),a.addRange(f)}get contentDiv(){return this.editorDiv}static async deserialize(e,s,i){var o;let n=null;if(e instanceof df){const{data:{defaultAppearanceData:{fontSize:l,fontColor:h},rect:d,rotation:u,id:f,popupRef:g},textContent:A,textPosition:y,parent:{page:{pageNumber:w}}}=e;if(!A||A.length===0)return null;n=e={annotationType:tt.FREETEXT,color:Array.from(h),fontSize:l,value:A.join(` +`),position:y,pageIndex:w-1,rect:d.slice(0),rotation:u,id:f,deleted:!1,popupRef:g}}const a=await super.deserialize(e,s,i);return p(a,Pe,e.fontSize),p(a,ss,j.makeHexColor(...e.color)),p(a,Re,m(o=vt,ai,Mc).call(o,e.value)),a.annotationElementId=e.id||null,a._initialData=n,a}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=vt._internalPadding*this.parentScale,i=this.getRect(s,s),n=pt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:r(this,ss)),a={annotationType:tt.FREETEXT,color:n,fontSize:r(this,Pe),value:m(this,Dt,yf).call(this),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?a:this.annotationElementId&&!m(this,Dt,vf).call(this,a)?null:(a.id=this.annotationElementId,a)}renderAnnotationElement(e){const s=super.renderAnnotationElement(e);if(this.deleted)return s;const{style:i}=s;i.fontSize=`calc(${r(this,Pe)}px * var(--scale-factor))`,i.color=r(this,ss),s.replaceChildren();for(const a of r(this,Re).split(` +`)){const o=document.createElement("div");o.append(a?document.createTextNode(a):document.createElement("br")),s.append(o)}const n=vt._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(n,n),popupContent:r(this,Re)}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};ss=new WeakMap,Re=new WeakMap,zo=new WeakMap,In=new WeakMap,Pe=new WeakMap,Dt=new WeakSet,mf=function(e){const s=n=>{this.editorDiv.style.fontSize=`calc(${n}px * var(--scale-factor))`,this.translate(0,-(n-r(this,Pe))*this.parentScale),p(this,Pe,n),m(this,Dt,Ol).call(this)},i=r(this,Pe);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:K.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},bf=function(e){const s=n=>{p(this,ss,this.editorDiv.style.color=n)},i=r(this,ss);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:K.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Af=function(){var i;const e=[];this.editorDiv.normalize();let s=null;for(const n of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&n.nodeName==="BR"||(e.push(m(i=vt,ai,Nl).call(i,n)),s=n);return e.join(` +`)},Ol=function(){const[e,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:n,div:a}=this,o=a.style.display,l=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",n.div.append(this.div),i=a.getBoundingClientRect(),a.remove(),a.style.display=o,a.classList.toggle("hidden",l)}this.rotation%180===this.parentRotation%180?(this.width=i.width/e,this.height=i.height/s):(this.width=i.height/e,this.height=i.width/s),this.fixAndSetPosition()},ai=new WeakSet,Nl=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(Al,"")},Hl=function(){if(this.editorDiv.replaceChildren(),!!r(this,Re))for(const e of r(this,Re).split(` +`)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},yf=function(){return r(this,Re).replaceAll(" "," ")},Mc=function(e){return e.replaceAll(" "," ")},vf=function(e){const{value:s,fontSize:i,color:n,pageIndex:a}=this._initialData;return this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((o,l)=>o!==n[l])||e.pageIndex!==a},b(vt,ai),Y(vt,"_freeTextDefaultContent",""),Y(vt,"_internalPadding",0),Y(vt,"_defaultColor",null),Y(vt,"_defaultFontSize",10),Y(vt,"_type","freetext"),Y(vt,"_editorType",tt.FREETEXT);let Lc=vt;class wf{toSVGPath(){wt("Abstract method `toSVGPath` must be implemented.")}get box(){wt("Abstract getter `box` must be implemented.")}serialize(t,e){wt("Abstract method `serialize` must be implemented.")}get classNamesForDrawing(){wt("Abstract getter `classNamesForDrawing` must be implemented.")}get classNamesForOutlining(){wt("Abstract getter `classNamesForOutlining` must be implemented.")}get mustRemoveSelfIntersections(){return!1}}var ke,is,Jr,Zr,_s,it,Fn,Dn,Go,Uo,ta,ea,ki,Wo,mh,bh,$t,Ia,_f,Ef,Sf,xf,Cf,Tf;const Ms=class Ms{constructor({x:t,y:e},s,i,n,a,o=0){b(this,$t);b(this,ke);b(this,is,[]);b(this,Jr);b(this,Zr);b(this,_s,[]);b(this,it,new Float64Array(18));b(this,Fn);b(this,Dn);b(this,Go);b(this,Uo);b(this,ta);b(this,ea);b(this,ki,[]);p(this,ke,s),p(this,ea,n*i),p(this,Zr,a),r(this,it).set([NaN,NaN,NaN,NaN,t,e],6),p(this,Jr,o),p(this,Uo,r(Ms,Wo)*i),p(this,Go,r(Ms,bh)*i),p(this,ta,i),r(this,ki).push(t,e)}isEmpty(){return isNaN(r(this,it)[8])}add({x:t,y:e}){var L;p(this,Fn,t),p(this,Dn,e);const[s,i,n,a]=r(this,ke);let[o,l,h,d]=r(this,it).subarray(8,12);const u=t-h,f=e-d,g=Math.hypot(u,f);if(g=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return m(this,$t,Ef).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,n,a){return new Rf(t,e,s,i,n,a)}getOutlines(){var u;const t=r(this,_s),e=r(this,is),s=r(this,it),[i,n,a,o]=r(this,ke),l=new Float64Array((((u=r(this,ki))==null?void 0:u.length)??0)+2);for(let f=0,g=l.length-2;f=6;f-=6)for(let g=0;g<6;g+=2){if(isNaN(e[f+g])){h[d]=h[d+1]=NaN,d+=2;continue}h[d]=e[f+g],h[d+1]=e[f+g+1],d+=2}return m(this,$t,Cf).call(this,h,d),this.newFreeDrawOutline(h,l,r(this,ke),r(this,ta),r(this,Jr),r(this,Zr))}};ke=new WeakMap,is=new WeakMap,Jr=new WeakMap,Zr=new WeakMap,_s=new WeakMap,it=new WeakMap,Fn=new WeakMap,Dn=new WeakMap,Go=new WeakMap,Uo=new WeakMap,ta=new WeakMap,ea=new WeakMap,ki=new WeakMap,Wo=new WeakMap,mh=new WeakMap,bh=new WeakMap,$t=new WeakSet,Ia=function(){const t=r(this,it).subarray(4,6),e=r(this,it).subarray(16,18),[s,i,n,a]=r(this,ke);return[(r(this,Fn)+(t[0]-e[0])/2-s)/n,(r(this,Dn)+(t[1]-e[1])/2-i)/a,(r(this,Fn)+(e[0]-t[0])/2-s)/n,(r(this,Dn)+(e[1]-t[1])/2-i)/a]},_f=function(){const[t,e,s,i]=r(this,ke),[n,a,o,l]=m(this,$t,Ia).call(this);return`M${(r(this,it)[2]-t)/s} ${(r(this,it)[3]-e)/i} L${(r(this,it)[4]-t)/s} ${(r(this,it)[5]-e)/i} L${n} ${a} L${o} ${l} L${(r(this,it)[16]-t)/s} ${(r(this,it)[17]-e)/i} L${(r(this,it)[14]-t)/s} ${(r(this,it)[15]-e)/i} Z`},Ef=function(t){const e=r(this,is);t.push(`L${e[4]} ${e[5]} Z`)},Sf=function(t){const[e,s,i,n]=r(this,ke),a=r(this,it).subarray(4,6),o=r(this,it).subarray(16,18),[l,h,d,u]=m(this,$t,Ia).call(this);t.push(`L${(a[0]-e)/i} ${(a[1]-s)/n} L${l} ${h} L${d} ${u} L${(o[0]-e)/i} ${(o[1]-s)/n}`)},xf=function(t){const e=r(this,it),[s,i,n,a]=r(this,ke),[o,l,h,d]=m(this,$t,Ia).call(this),u=new Float64Array(36);return u.set([NaN,NaN,NaN,NaN,(e[2]-s)/n,(e[3]-i)/a,NaN,NaN,NaN,NaN,(e[4]-s)/n,(e[5]-i)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,h,d,NaN,NaN,NaN,NaN,(e[16]-s)/n,(e[17]-i)/a,NaN,NaN,NaN,NaN,(e[14]-s)/n,(e[15]-i)/a],0),this.newFreeDrawOutline(u,t,r(this,ke),r(this,ta),r(this,Jr),r(this,Zr))},Cf=function(t,e){const s=r(this,is);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},Tf=function(t,e){const s=r(this,it).subarray(4,6),i=r(this,it).subarray(16,18),[n,a,o,l]=r(this,ke),[h,d,u,f]=m(this,$t,Ia).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-n)/o,(s[1]-a)/l,NaN,NaN,NaN,NaN,h,d,NaN,NaN,NaN,NaN,u,f,NaN,NaN,NaN,NaN,(i[0]-n)/o,(i[1]-a)/l],e),e+=24},b(Ms,Wo,8),b(Ms,mh,2),b(Ms,bh,r(Ms,Wo)+r(Ms,mh));let Jl=Ms;var sa,On,qs,Vo,Le,qo,kt,Se,Fa,Da,Pf;class Rf extends wf{constructor(e,s,i,n,a,o){super();b(this,Se);b(this,sa);b(this,On,null);b(this,qs);b(this,Vo);b(this,Le);b(this,qo);b(this,kt);p(this,kt,e),p(this,Le,s),p(this,sa,i),p(this,qo,n),p(this,qs,a),p(this,Vo,o),m(this,Se,Pf).call(this,o);const{x:l,y:h,width:d,height:u}=r(this,On);for(let f=0,g=e.length;fe[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of r(this,Li))e[3]?(t.push(...m(this,ge,Ic).call(this,e)),m(this,ge,Lf).call(this,e)):(m(this,ge,Mf).call(this,e),t.push(...m(this,ge,Ic).call(this,e)));return m(this,ge,kf).call(this,t)}}Xo=new WeakMap,Li=new WeakMap,ns=new WeakMap,ge=new WeakSet,kf=function(t){const e=[],s=new Set;for(const a of t){const[o,l,h]=a;e.push([o,l,a],[o,h,a])}e.sort((a,o)=>a[1]-o[1]||a[0]-o[0]);for(let a=0,o=e.length;a0;){const a=s.values().next().value;let[o,l,h,d,u]=a;s.delete(a);let f=o,g=l;for(n=[o,h],i.push(n);;){let A;if(s.has(d))A=d;else if(s.has(u))A=u;else break;s.delete(A),[o,l,h,d,u]=A,f!==o&&(n.push(f,g,o,g===l?l:h),f=o),g=g===l?h:l}n.push(f,g)}return new Um(i,r(this,Xo))},Bl=function(t){const e=r(this,ns);let s=0,i=e.length-1;for(;s<=i;){const n=s+i>>1,a=e[n][0];if(a===t)return n;a=0;i--){const[n,a]=r(this,ns)[i];if(n!==t)break;if(n===t&&a===e){r(this,ns).splice(i,1);return}}},Ic=function(t){const[e,s,i]=t,n=[[e,s,i]],a=m(this,ge,Bl).call(this,i);for(let o=0;o=l){if(g>h)n[d][1]=h;else{if(u===1)return[];n.splice(d,1),d--,u--}continue}n[d][2]=l,g>h&&n.push([e,h,g])}}}return n};var Yo,ia;class Um extends wf{constructor(e,s){super();b(this,Yo);b(this,ia);p(this,ia,e),p(this,Yo,s)}toSVGPath(){const e=[];for(const s of r(this,ia)){let[i,n]=s;e.push(`M${i} ${n}`);for(let a=2;a-1?(p(this,_e,!0),m(this,Z,jl).call(this,e),m(this,Z,qi).call(this)):r(this,Xs)&&(p(this,oa,e.anchorNode),p(this,tl,e.anchorOffset),p(this,el,e.focusNode),p(this,sl,e.focusOffset),m(this,Z,Hc).call(this),m(this,Z,qi).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const e=ht.prototype;return ot(this,"_keyboardManager",new ol([[["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:r(this,_e)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:r(this,$e),methodOfCreation:r(this,il)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}static initialize(e,s){var i;pt.initialize(e,s),ht._defaultColor||(ht._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case K.HIGHLIGHT_DEFAULT_COLOR:ht._defaultColor=s;break;case K.HIGHLIGHT_THICKNESS:ht._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return r(this,ha)}updateParams(e,s){switch(e){case K.HIGHLIGHT_COLOR:m(this,Z,Ff).call(this,s);break;case K.HIGHLIGHT_THICKNESS:m(this,Z,Df).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[K.HIGHLIGHT_DEFAULT_COLOR,ht._defaultColor],[K.HIGHLIGHT_THICKNESS,ht._defaultThickness]]}get propertiesToUpdate(){return[[K.HIGHLIGHT_COLOR,this.color||ht._defaultColor],[K.HIGHLIGHT_THICKNESS,r(this,$e)||ht._defaultThickness],[K.HIGHLIGHT_FREE,r(this,_e)]]}async addEditToolbar(){const e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(p(this,la,new Zl({editor:this})),e.addColorPicker(r(this,la))),e):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(m(this,Z,Oa).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,m(this,Z,Oa).call(this))}onceAdded(){this.annotationElementId||this.parent.addUndoableEditor(this),this.div.focus()}remove(){m(this,Z,Bc).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(m(this,Z,qi).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?m(this,Z,Bc).call(this):e&&(m(this,Z,qi).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),s&&this.select()}rotate(e){var n,a,o;const{drawLayer:s}=this.parent;let i;r(this,_e)?(e=(e-this.rotation+360)%360,i=m(n=ht,Ue,ur).call(n,r(this,os).box,e)):i=m(a=ht,Ue,ur).call(a,this,e),s.rotate(r(this,re),e),s.rotate(r(this,Bt),e),s.updateBox(r(this,re),i),s.updateBox(r(this,Bt),m(o=ht,Ue,ur).call(o,r(this,je).box,e))}render(){if(this.div)return this.div;const e=super.render();r(this,ca)&&(e.setAttribute("aria-label",r(this,ca)),e.setAttribute("role","mark")),r(this,_e)?e.classList.add("free"):this.div.addEventListener("keydown",m(this,Z,Nf).bind(this),{signal:this._uiManager._signal});const s=p(this,Bn,document.createElement("div"));e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=r(this,Hn);const[i,n]=this.parentDimensions;return this.setDims(this.width*i,this.height*n),Kl(this,r(this,Bn),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){this.isSelected||this.parent.drawLayer.addClass(r(this,Bt),"hovered")}pointerleave(){this.isSelected||this.parent.drawLayer.removeClass(r(this,Bt),"hovered")}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:m(this,Z,$l).call(this,!0);break;case 1:case 3:m(this,Z,$l).call(this,!1);break}}select(){var e,s;super.select(),r(this,Bt)&&((e=this.parent)==null||e.drawLayer.removeClass(r(this,Bt),"hovered"),(s=this.parent)==null||s.drawLayer.addClass(r(this,Bt),"selected"))}unselect(){var e;super.unselect(),r(this,Bt)&&((e=this.parent)==null||e.drawLayer.removeClass(r(this,Bt),"selected"),r(this,_e)||m(this,Z,$l).call(this,!1))}get _mustFixPosition(){return!r(this,_e)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.show(r(this,re),e),this.parent.drawLayer.show(r(this,Bt),e))}static startHighlighting(e,s,{target:i,x:n,y:a}){const{x:o,y:l,width:h,height:d}=i.getBoundingClientRect(),u=new AbortController,f=e.combinedSignal(u),g=y=>{y.preventDefault(),y.stopPropagation()},A=y=>{u.abort(),m(this,Ue,$f).call(this,e,y)};window.addEventListener("blur",A,{signal:f}),window.addEventListener("pointerup",A,{signal:f}),window.addEventListener("pointerdown",g,{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",Ve,{signal:f}),i.addEventListener("pointermove",m(this,Ue,jf).bind(this,e),{signal:f}),this._freeHighlight=new Fc({x:n,y:a},[o,l,h,d],e.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static async deserialize(e,s,i){var y,w,v,_;let n=null;if(e instanceof ff){const{data:{quadPoints:S,rect:E,rotation:C,id:x,color:T,opacity:P,popupRef:L},parent:{page:{pageNumber:O}}}=e;n=e={annotationType:tt.HIGHLIGHT,color:Array.from(T),opacity:P,quadPoints:S,boxes:null,pageIndex:O-1,rect:E.slice(0),rotation:C,id:x,deleted:!1,popupRef:L}}else if(e instanceof wd){const{data:{inkLists:S,rect:E,rotation:C,id:x,color:T,borderStyle:{rawWidth:P},popupRef:L},parent:{page:{pageNumber:O}}}=e;n=e={annotationType:tt.HIGHLIGHT,color:Array.from(T),thickness:P,inkLists:S,boxes:null,pageIndex:O-1,rect:E.slice(0),rotation:C,id:x,deleted:!1,popupRef:L}}const{color:a,quadPoints:o,inkLists:l,opacity:h}=e,d=await super.deserialize(e,s,i);d.color=j.makeHexColor(...a),p(d,Ys,h||1),l&&p(d,$e,e.thickness),d.annotationElementId=e.id||null,d._initialData=n;const[u,f]=d.pageDimensions,[g,A]=d.pageTranslation;if(o){const S=p(d,Xs,[]);for(let E=0;E=0)p(this,re,s),p(this,Hn,i),this.parent.drawLayer.finalizeLine(s,e),p(this,Bt,this.parent.drawLayer.drawOutline(r(this,je)));else if(this.parent){const g=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(r(this,re),e),this.parent.drawLayer.updateBox(r(this,re),m(u=ht,Ue,ur).call(u,r(this,os).box,(g-this.rotation+360)%360)),this.parent.drawLayer.updateLine(r(this,Bt),r(this,je)),this.parent.drawLayer.updateBox(r(this,Bt),m(f=ht,Ue,ur).call(f,r(this,je).box,g))}const{x:a,y:o,width:l,height:h}=e.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=l,this.height=h;break;case 90:{const[g,A]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*A/g,this.height=h*g/A;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=h;break;case 270:{const[g,A]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*A/g,this.height=h*g/A;break}}const{lastPoint:d}=r(this,je).box;p(this,ha,[(d[0]-a)/l,(d[1]-o)/h])},Ff=function(e){const s=(a,o)=>{var l,h,d;this.color=a,(l=this.parent)==null||l.drawLayer.changeColor(r(this,re),a),(h=r(this,la))==null||h.updateColor(a),p(this,Ys,o),(d=this.parent)==null||d.drawLayer.changeOpacity(r(this,re),o)},i=this.color,n=r(this,Ys);this.addCommands({cmd:s.bind(this,e,ht._defaultOpacity),undo:s.bind(this,i,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:K.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)},Df=function(e){const s=r(this,$e),i=n=>{p(this,$e,n),m(this,Z,Of).call(this,n)};this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:K.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},Of=function(e){if(!r(this,_e))return;m(this,Z,jl).call(this,{highlightOutlines:r(this,os).getNewOutline(e/2)}),this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)},Bc=function(){r(this,re)===null||!this.parent||(this.parent.drawLayer.remove(r(this,re)),p(this,re,null),this.parent.drawLayer.remove(r(this,Bt)),p(this,Bt,null))},qi=function(e=this.parent){r(this,re)===null&&({id:he(this,re)._,clipPathId:he(this,Hn)._}=e.drawLayer.draw(r(this,os),this.color,r(this,Ys)),p(this,Bt,e.drawLayer.drawOutline(r(this,je))),r(this,Bn)&&(r(this,Bn).style.clipPath=r(this,Hn)))},Ue=new WeakSet,ur=function({x:e,y:s,width:i,height:n},a){switch(a){case 90:return{x:1-s-n,y:e,width:n,height:i};case 180:return{x:1-e-i,y:1-s-n,width:i,height:n};case 270:return{x:s,y:1-e-i,width:n,height:i}}return{x:e,y:s,width:i,height:n}},Nf=function(e){ht._keyboardManager.exec(this,e)},$l=function(e){if(!r(this,oa))return;const s=window.getSelection();e?s.setPosition(r(this,oa),r(this,tl)):s.setPosition(r(this,el),r(this,sl))},Oa=function(){return r(this,_e)?this.rotation:0},Hf=function(){if(r(this,_e))return null;const[e,s]=this.pageDimensions,[i,n]=this.pageTranslation,a=r(this,Xs),o=new Float32Array(a.length*8);let l=0;for(const{x:h,y:d,width:u,height:f}of a){const g=h*e+i,A=(1-d-f)*s+n;o[l]=o[l+4]=g,o[l+1]=o[l+3]=A,o[l+2]=o[l+6]=g+u*e,o[l+5]=o[l+7]=A+f*s,l+=8}return o},Bf=function(e){return r(this,os).serialize(e,m(this,Z,Oa).call(this))},jf=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},$f=function(e,s){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},zf=function(e){const{color:s}=this._initialData;return e.color.some((i,n)=>i!==s[n])},b(ht,Ue),Y(ht,"_defaultColor",null),Y(ht,"_defaultOpacity",1),Y(ht,"_defaultThickness",12),Y(ht,"_type","highlight"),Y(ht,"_editorType",tt.HIGHLIGHT),Y(ht,"_freeHighlightId",-1),Y(ht,"_freeHighlight",null),Y(ht,"_freeHighlightClipId","");let th=ht;var jn,$n,Es,Ks,ze,zn,Gn,Un,Qs,da,Wn,Vn,Ii,I,Gf,Uf,Wf,Vf,$c,qf,zc,Xf,Yf,Kf,Qf,Jf,Xi,Gc,Uc,Wc,zl,Gl,fr,Vc,Ul,li,Zf,qc,tp,ep,Xc,Wl,Na;const St=class St extends pt{constructor(e){super({...e,name:"inkEditor"});b(this,I);b(this,jn,0);b(this,$n,0);b(this,Es,null);b(this,Ks,new Path2D);b(this,ze,!1);b(this,zn,null);b(this,Gn,!1);b(this,Un,!1);b(this,Qs,null);b(this,da,null);b(this,Wn,0);b(this,Vn,0);b(this,Ii,null);this.color=e.color||null,this.thickness=e.thickness||null,this.opacity=e.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(e,s){pt.initialize(e,s)}static updateDefaultParams(e,s){switch(e){case K.INK_THICKNESS:St._defaultThickness=s;break;case K.INK_COLOR:St._defaultColor=s;break;case K.INK_OPACITY:St._defaultOpacity=s/100;break}}updateParams(e,s){switch(e){case K.INK_THICKNESS:m(this,I,Gf).call(this,s);break;case K.INK_COLOR:m(this,I,Uf).call(this,s);break;case K.INK_OPACITY:m(this,I,Wf).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[K.INK_THICKNESS,St._defaultThickness],[K.INK_COLOR,St._defaultColor||pt._defaultLineColor],[K.INK_OPACITY,Math.round(St._defaultOpacity*100)]]}get propertiesToUpdate(){return[[K.INK_THICKNESS,this.thickness||St._defaultThickness],[K.INK_COLOR,this.color||St._defaultColor||pt._defaultLineColor],[K.INK_OPACITY,Math.round(100*(this.opacity??St._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(m(this,I,zl).call(this),m(this,I,Gl).call(this)),this.isAttachedToDOM||(this.parent.add(this),m(this,I,fr).call(this)),m(this,I,Na).call(this)))}remove(){var e;this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,r(this,Es)&&(clearTimeout(r(this,Es)),p(this,Es,null)),(e=r(this,Qs))==null||e.disconnect(),p(this,Qs,null),super.remove())}setParent(e){!this.parent&&e?this._uiManager.removeShouldRescale(this):this.parent&&e===null&&this._uiManager.addShouldRescale(this),super.setParent(e)}onScaleChanging(){const[e,s]=this.parentDimensions,i=this.width*e,n=this.height*s;this.setDimensions(i,n)}enableEditMode(){r(this,ze)||this.canvas===null||(super.enableEditMode(),this._isDraggable=!1,m(this,I,Gc).call(this))}disableEditMode(){!this.isInEditMode()||this.canvas===null||(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),m(this,I,Uc).call(this))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}commit(){r(this,ze)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),p(this,ze,!0),this.div.classList.add("disabled"),m(this,I,Na).call(this,!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),this.enableEditMode())}canvasPointerdown(e){e.button!==0||!this.isInEditMode()||r(this,ze)||(this.setInForeground(),e.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),m(this,I,qf).call(this,e.offsetX,e.offsetY))}canvasPointermove(e){e.preventDefault(),m(this,I,zc).call(this,e.offsetX,e.offsetY)}canvasPointerup(e){e.preventDefault(),m(this,I,Wc).call(this,e)}canvasPointerleave(e){m(this,I,Wc).call(this,e)}get isResizable(){return!this.isEmpty()&&r(this,ze)}render(){if(this.div)return this.div;let e,s;this.width&&(e=this.x,s=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[i,n,a,o]=m(this,I,Vf).call(this);if(this.setAt(i,n,0,0),this.setDims(a,o),m(this,I,zl).call(this),this.width){const[l,h]=this.parentDimensions;this.setAspectRatio(this.width*l,this.height*h),this.setAt(e*l,s*h,this.width*l,this.height*h),p(this,Un,!0),m(this,I,fr).call(this),this.setDims(this.width*l,this.height*h),m(this,I,Xi).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return m(this,I,Gl).call(this),this.div}setDimensions(e,s){const i=Math.round(e),n=Math.round(s);if(r(this,Wn)===i&&r(this,Vn)===n)return;p(this,Wn,i),p(this,Vn,n),this.canvas.style.visibility="hidden";const[a,o]=this.parentDimensions;this.width=e/a,this.height=s/o,this.fixAndSetPosition(),r(this,ze)&&m(this,I,Vc).call(this,e,s),m(this,I,fr).call(this),m(this,I,Xi).call(this),this.canvas.style.visibility="visible",this.fixDims()}static async deserialize(e,s,i){var w,v,_;if(e instanceof wd)return null;const n=await super.deserialize(e,s,i);n.thickness=e.thickness,n.color=j.makeHexColor(...e.color),n.opacity=e.opacity;const[a,o]=n.pageDimensions,l=n.width*a,h=n.height*o,d=n.parentScale,u=e.thickness/2;p(n,ze,!0),p(n,Wn,Math.round(l)),p(n,Vn,Math.round(h));const{paths:f,rect:g,rotation:A}=e;for(let{bezier:S}of f){S=m(w=St,li,tp).call(w,S,g,A);const E=[];n.paths.push(E);let C=d*(S[0]-u),x=d*(S[1]-u);for(let P=2,L=S.length;P{this.thickness=n,m(this,I,Na).call(this)},i=this.thickness;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:K.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},Uf=function(e){const s=n=>{this.color=n,m(this,I,Xi).call(this)},i=this.color;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:K.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Wf=function(e){const s=n=>{this.opacity=n,m(this,I,Xi).call(this)};e/=100;const i=this.opacity;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:K.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},Vf=function(){const{parentRotation:e,parentDimensions:[s,i]}=this;switch(e){case 90:return[0,i,i,s];case 180:return[s,i,s,i];case 270:return[s,0,i,s];default:return[0,0,s,i]}},$c=function(){const{ctx:e,color:s,opacity:i,thickness:n,parentScale:a,scaleFactor:o}=this;e.lineWidth=n*a/o,e.lineCap="round",e.lineJoin="round",e.miterLimit=10,e.strokeStyle=`${s}${fg(i)}`},qf=function(e,s){this.canvas.addEventListener("contextmenu",Ve,{signal:this._uiManager._signal}),m(this,I,Uc).call(this),p(this,zn,new AbortController);const i=this._uiManager.combinedSignal(r(this,zn));this.canvas.addEventListener("pointerleave",this.canvasPointerleave.bind(this),{signal:i}),this.canvas.addEventListener("pointermove",this.canvasPointermove.bind(this),{signal:i}),this.canvas.addEventListener("pointerup",this.canvasPointerup.bind(this),{signal:i}),this.isEditing=!0,r(this,Un)||(p(this,Un,!0),m(this,I,fr).call(this),this.thickness||(this.thickness=St._defaultThickness),this.color||(this.color=St._defaultColor||pt._defaultLineColor),this.opacity??(this.opacity=St._defaultOpacity)),this.currentPath.push([e,s]),p(this,Gn,!1),m(this,I,$c).call(this),p(this,Ii,()=>{m(this,I,Kf).call(this),r(this,Ii)&&window.requestAnimationFrame(r(this,Ii))}),window.requestAnimationFrame(r(this,Ii))},zc=function(e,s){const[i,n]=this.currentPath.at(-1);if(this.currentPath.length>1&&e===i&&s===n)return;const a=this.currentPath;let o=r(this,Ks);if(a.push([e,s]),p(this,Gn,!0),a.length<=2){o.moveTo(...a[0]),o.lineTo(e,s);return}a.length===3&&(p(this,Ks,o=new Path2D),o.moveTo(...a[0])),m(this,I,Qf).call(this,o,...a.at(-3),...a.at(-2),e,s)},Xf=function(){if(this.currentPath.length===0)return;const e=this.currentPath.at(-1);r(this,Ks).lineTo(...e)},Yf=function(e,s){p(this,Ii,null),e=Math.min(Math.max(e,0),this.canvas.width),s=Math.min(Math.max(s,0),this.canvas.height),m(this,I,zc).call(this,e,s),m(this,I,Xf).call(this);let i;if(this.currentPath.length!==1)i=m(this,I,Jf).call(this);else{const h=[e,s];i=[[h,h.slice(),h.slice(),h]]}const n=r(this,Ks),a=this.currentPath;this.currentPath=[],p(this,Ks,new Path2D);const o=()=>{this.allRawPaths.push(a),this.paths.push(i),this.bezierPath2D.push(n),this._uiManager.rebuild(this)},l=()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(m(this,I,zl).call(this),m(this,I,Gl).call(this)),m(this,I,Na).call(this))};this.addCommands({cmd:o,undo:l,mustExec:!0})},Kf=function(){if(!r(this,Gn))return;p(this,Gn,!1);const e=Math.ceil(this.thickness*this.parentScale),s=this.currentPath.slice(-3),i=s.map(o=>o[0]),n=s.map(o=>o[1]);Math.min(...i)-e,Math.max(...i)+e,Math.min(...n)-e,Math.max(...n)+e;const{ctx:a}=this;a.save(),a.clearRect(0,0,this.canvas.width,this.canvas.height);for(const o of this.bezierPath2D)a.stroke(o);a.stroke(r(this,Ks)),a.restore()},Qf=function(e,s,i,n,a,o,l){const h=(s+n)/2,d=(i+a)/2,u=(n+o)/2,f=(a+l)/2;e.bezierCurveTo(h+2*(n-h)/3,d+2*(a-d)/3,u+2*(n-u)/3,f+2*(a-f)/3,u,f)},Jf=function(){const e=this.currentPath;if(e.length<=2)return[[e[0],e[0],e.at(-1),e.at(-1)]];const s=[];let i,[n,a]=e[0];for(i=1;i{p(this,Es,null),this.canvas.removeEventListener("contextmenu",Ve)},10)),m(this,I,Yf).call(this,e.offsetX,e.offsetY),this.addToAnnotationStorage(),this.setInBackground()},zl=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},Gl=function(){p(this,Qs,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&this.setDimensions(s.width,s.height)})),r(this,Qs).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var e;(e=r(this,Qs))==null||e.disconnect(),p(this,Qs,null)},{once:!0})},fr=function(){if(!r(this,Un))return;const[e,s]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*e),this.canvas.height=Math.ceil(this.height*s),m(this,I,Ul).call(this)},Vc=function(e,s){const i=m(this,I,Wl).call(this),n=(e-i)/r(this,$n),a=(s-i)/r(this,jn);this.scaleFactor=Math.min(n,a)},Ul=function(){const e=m(this,I,Wl).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+e,this.translationY*this.scaleFactor+e)},li=new WeakSet,Zf=function(e){const s=new Path2D;for(let i=0,n=e.length;i`image/${s}`))}static get supportedTypesStr(){return ot(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,s){s.pasteEditor(tt.STAMP,{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:"stamp",hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){const s=e.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(e=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:n,width:a,height:o}=e||this.copyCanvas(null,null,!0).imageData,l=await i.guess({name:"altText",request:{data:n,width:a,height:o,channels:n.length/(a*o)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const h=l.output;return await this.setGuessedAltText(h),s&&!this.hasAltTextData()&&(this.altTextData={alt:h,decorative:!1}),h}remove(){var e,s;r(this,Jt)&&(p(this,Ct,null),this._uiManager.imageManager.deleteId(r(this,Jt)),(e=r(this,Ss))==null||e.remove(),p(this,Ss,null),(s=r(this,Zs))==null||s.disconnect(),p(this,Zs,null),r(this,xs)&&(clearTimeout(r(this,xs)),p(this,xs,null))),super.remove()}rebuild(){if(!this.parent){r(this,Jt)&&m(this,at,Vl).call(this);return}super.rebuild(),this.div!==null&&(r(this,Jt)&&r(this,Ss)===null&&m(this,at,Vl).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(r(this,Fi)||r(this,Ct)||r(this,Js)||r(this,Di)||r(this,Jt))}get isResizable(){return!0}render(){if(this.div)return this.div;let e,s;if(this.width&&(e=this.x,s=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),r(this,Ct)?m(this,at,Kc).call(this):m(this,at,Vl).call(this),this.width&&!this.annotationElementId){const[i,n]=this.parentDimensions;this.setAt(e*i,s*n,this.width*i,this.height*n)}return this.div}copyCanvas(e,s,i=!1){var g;e||(e=224);const{width:n,height:a}=r(this,Ct),o=new Wh;let l=r(this,Ct),h=n,d=a,u=null;if(s){if(n>s||a>s){const P=Math.min(s/n,s/a);h=Math.floor(n*P),d=Math.floor(a*P)}u=document.createElement("canvas");const A=u.width=Math.ceil(h*o.sx),y=u.height=Math.ceil(d*o.sy);r(this,Me)||(l=m(this,at,ql).call(this,A,y));const w=u.getContext("2d");w.filter=this._uiManager.hcmFilter;let v="white",_="#cfcfd8";this._uiManager.hcmFilter!=="none"?_="black":(g=window.matchMedia)!=null&&g.call(window,"(prefers-color-scheme: dark)").matches&&(v="#8f8f9d",_="#42414d");const S=15,E=S*o.sx,C=S*o.sy,x=new OffscreenCanvas(E*2,C*2),T=x.getContext("2d");T.fillStyle=v,T.fillRect(0,0,E*2,C*2),T.fillStyle=_,T.fillRect(0,0,E,C),T.fillRect(E,C,E,C),w.fillStyle=w.createPattern(x,"repeat"),w.fillRect(0,0,A,y),w.drawImage(l,0,0,l.width,l.height,0,0,A,y)}let f=null;if(i){let A,y;if(o.symmetric&&l.widthe||a>e){const _=Math.min(e/n,e/a);A=Math.floor(n*_),y=Math.floor(a*_),r(this,Me)||(l=m(this,at,ql).call(this,A,y))}const v=new OffscreenCanvas(A,y).getContext("2d",{willReadFrequently:!0});v.drawImage(l,0,0,l.width,l.height,0,0,A,y),f={width:A,height:y,data:v.getImageData(0,0,A,y).data}}return{canvas:u,width:h,height:d,imageData:f}}getImageForAltText(){return r(this,Ss)}static async deserialize(e,s,i){var y;let n=null;if(e instanceof pf){const{data:{rect:w,rotation:v,id:_,structParent:S,popupRef:E},container:C,parent:{page:{pageNumber:x}}}=e,T=C.querySelector("canvas"),P=i.imageManager.getFromCanvas(C.id,T);T.remove();const L=((y=await s._structTree.getAriaAttributes(`${cd}${_}`))==null?void 0:y.get("aria-label"))||"";n=e={annotationType:tt.STAMP,bitmapId:P.id,bitmap:P.bitmap,pageIndex:x-1,rect:w.slice(0),rotation:v,id:_,deleted:!1,accessibilityData:{decorative:!1,altText:L},isSvg:!1,structParent:S,popupRef:E}}const a=await super.deserialize(e,s,i),{rect:o,bitmap:l,bitmapUrl:h,bitmapId:d,isSvg:u,accessibilityData:f}=e;d&&i.imageManager.isValidId(d)?(p(a,Jt,d),l&&p(a,Ct,l)):p(a,Js,h),p(a,Me,u);const[g,A]=a.pageDimensions;return a.width=(o[2]-o[0])/g,a.height=(o[3]-o[1])/A,a.annotationElementId=e.id||null,f&&(a.altTextData=f),a._initialData=n,p(a,fa,!!n),a}serialize(e=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:tt.STAMP,bitmapId:r(this,Jt),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:r(this,Me),structTreeParentId:this._structTreeParentId};if(e)return i.bitmapUrl=m(this,at,Xl).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:n,altText:a}=this.serializeAltText(!1);if(!n&&a&&(i.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const l=m(this,at,np).call(this,i);if(l.isSame)return null;l.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,s===null)return i;s.stamps||(s.stamps=new Map);const o=r(this,Me)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(r(this,Jt)))s.stamps.set(r(this,Jt),{area:o,serialized:i}),i.bitmap=m(this,at,Xl).call(this,!1);else if(r(this,Me)){const l=s.stamps.get(r(this,Jt));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=m(this,at,Xl).call(this,!1))}return i}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}};Ct=new WeakMap,Jt=new WeakMap,Fi=new WeakMap,Js=new WeakMap,Di=new WeakMap,ua=new WeakMap,Ss=new WeakMap,Zs=new WeakMap,xs=new WeakMap,Me=new WeakMap,fa=new WeakMap,at=new WeakSet,Ha=function(e,s=!1){if(!e){this.remove();return}p(this,Ct,e.bitmap),s||(p(this,Jt,e.id),p(this,Me,e.isSvg)),e.file&&p(this,ua,e.file.name),m(this,at,Kc).call(this)},Ba=function(){if(p(this,Fi,null),this._uiManager.enableWaiting(!1),!!r(this,Ss)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&r(this,Ct)){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&r(this,Ct)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Vl=function(){if(r(this,Jt)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(r(this,Jt)).then(i=>m(this,at,Ha).call(this,i,!0)).finally(()=>m(this,at,Ba).call(this));return}if(r(this,Js)){const i=r(this,Js);p(this,Js,null),this._uiManager.enableWaiting(!0),p(this,Fi,this._uiManager.imageManager.getFromUrl(i).then(n=>m(this,at,Ha).call(this,n)).finally(()=>m(this,at,Ba).call(this)));return}if(r(this,Di)){const i=r(this,Di);p(this,Di,null),this._uiManager.enableWaiting(!0),p(this,Fi,this._uiManager.imageManager.getFromFile(i).then(n=>m(this,at,Ha).call(this,n)).finally(()=>m(this,at,Ba).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=za.supportedTypesStr;const s=this._uiManager._signal;p(this,Fi,new Promise(i=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const n=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),m(this,at,Ha).call(this,n)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>m(this,at,Ba).call(this))),e.click()},Kc=function(){const{div:e}=this;let{width:s,height:i}=r(this,Ct);const[n,a]=this.pageDimensions,o=.75;if(this.width)s=this.width*n,i=this.height*a;else if(s>o*n||i>o*a){const u=Math.min(o*n/s,o*a/i);s*=u,i*=u}const[l,h]=this.parentDimensions;this.setDims(s*l/n,i*h/a),this._uiManager.enableWaiting(!1);const d=p(this,Ss,document.createElement("canvas"));d.setAttribute("role","img"),this.addContainer(d),(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),m(this,at,Qc).call(this,s,i),m(this,at,ip).call(this),r(this,fa)||(this.parent.addUndoableEditor(this),p(this,fa,!0)),this._reportTelemetry({action:"inserted_image"}),r(this,ua)&&d.setAttribute("aria-label",r(this,ua))},sp=function(e,s){var o;const[i,n]=this.parentDimensions;this.width=e/i,this.height=s/n,(o=this._initialOptions)!=null&&o.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,r(this,xs)!==null&&clearTimeout(r(this,xs)),p(this,xs,setTimeout(()=>{p(this,xs,null),m(this,at,Qc).call(this,e,s)},200))},ql=function(e,s){const{width:i,height:n}=r(this,Ct);let a=i,o=n,l=r(this,Ct);for(;a>2*e||o>2*s;){const h=a,d=o;a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2)),o>2*s&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2));const u=new OffscreenCanvas(a,o);u.getContext("2d").drawImage(l,0,0,h,d,0,0,a,o),l=u.transferToImageBitmap()}return l},Qc=function(e,s){const i=new Wh,n=Math.ceil(e*i.sx),a=Math.ceil(s*i.sy),o=r(this,Ss);if(!o||o.width===n&&o.height===a)return;o.width=n,o.height=a;const l=r(this,Me)?r(this,Ct):m(this,at,ql).call(this,n,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,n,a)},Xl=function(e){if(e){if(r(this,Me)){const n=this._uiManager.imageManager.getSvgUrl(r(this,Jt));if(n)return n}const s=document.createElement("canvas");return{width:s.width,height:s.height}=r(this,Ct),s.getContext("2d").drawImage(r(this,Ct),0,0),s.toDataURL()}if(r(this,Me)){const[s,i]=this.pageDimensions,n=Math.round(this.width*s*Bi.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*Bi.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(n,a);return o.getContext("2d").drawImage(r(this,Ct),0,0,r(this,Ct).width,r(this,Ct).height,0,0,n,a),o.transferToImageBitmap()}return structuredClone(r(this,Ct))},ip=function(){this._uiManager._signal&&(p(this,Zs,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&m(this,at,sp).call(this,s.width,s.height)})),r(this,Zs).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var e;(e=r(this,Zs))==null||e.disconnect(),p(this,Zs,null)},{once:!0}))},np=function(e){var h;const{rect:s,pageIndex:i,accessibilityData:{altText:n}}=this._initialData,a=e.rect.every((d,u)=>Math.abs(d-s[u])<1),o=e.pageIndex===i,l=(((h=e.accessibilityData)==null?void 0:h.alt)||"")===n;return{isSame:a&&o&&l,isSameAltText:l}},Y(za,"_type","stamp"),Y(za,"_editorType",tt.STAMP);let Yc=za;var qn,pa,Cs,Oi,ti,Ie,Ni,ga,ma,ae,ei,G,Hi,Zt,rp,Zc,td,ed,Yl;const qe=class qe{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:n,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:d}){b(this,Zt);b(this,qn);b(this,pa,!1);b(this,Cs,null);b(this,Oi,null);b(this,ti,null);b(this,Ie,new Map);b(this,Ni,!1);b(this,ga,!1);b(this,ma,!1);b(this,ae,null);b(this,ei,null);b(this,G);const u=[...r(qe,Hi).values()];if(!qe._initialized){qe._initialized=!0;for(const f of u)f.initialize(d,t)}t.registerEditorTypes(u),p(this,G,t),this.pageIndex=e,this.div=s,p(this,qn,n),p(this,Cs,a),this.viewport=h,p(this,ae,l),this.drawLayer=o,this._structTree=i,r(this,G).addLayer(this)}get isEmpty(){return r(this,Ie).size===0}get isInvisible(){return this.isEmpty&&r(this,G).getMode()===tt.NONE}updateToolbar(t){r(this,G).updateToolbar(t)}updateMode(t=r(this,G).getMode()){switch(m(this,Zt,Yl).call(this),t){case tt.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case tt.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case tt.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const s of r(qe,Hi).values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=r(this,ae))==null?void 0:e.div)}addInkEditorIfNeeded(t){if(r(this,G).getMode()!==tt.INK)return;if(!t){for(const s of r(this,Ie).values())if(s.isEmpty()){s.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}setEditingState(t){r(this,G).setEditingState(t)}addCommands(t){r(this,G).addCommands(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=r(this,Cs))==null||e.div.classList.toggle("disabled",!t)}async enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const s of r(this,Ie).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(r(this,G).removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!r(this,Cs))return;const e=r(this,Cs).getEditableAnnotations();for(const s of e){if(s.hide(),r(this,G).isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const i=await this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}}disable(){var i;p(this,ma,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const n of r(this,Ie).values())if(n.disableEditing(),!!n.annotationElementId){if(n.serialize()!==null){t.set(n.annotationElementId,n);continue}else e.set(n.annotationElementId,n);(i=this.getEditableAnnotation(n.annotationElementId))==null||i.show(),n.remove()}if(r(this,Cs)){const n=r(this,Cs).getEditableAnnotations();for(const a of n){const{id:o}=a.data;if(r(this,G).isDeletedAnnotationElement(o))continue;let l=e.get(o);if(l){l.resetAnnotationElement(a),l.show(!1),a.show();continue}l=t.get(o),l&&(r(this,G).addChangedExistingAnnotation(l),l.renderAnnotationElement(a)&&l.show(!1)),a.show()}}m(this,Zt,Yl).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const n of r(qe,Hi).values())s.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),p(this,ma,!1)}getEditableAnnotation(t){var e;return((e=r(this,Cs))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){r(this,G).getActive()!==t&&r(this,G).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=r(this,ae))!=null&&t.div&&!r(this,ei)){p(this,ei,new AbortController);const e=r(this,G).combinedSignal(r(this,ei));r(this,ae).div.addEventListener("pointerdown",m(this,Zt,rp).bind(this),{signal:e}),r(this,ae).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=r(this,ae))!=null&&t.div&&r(this,ei)&&(r(this,ei).abort(),p(this,ei,null),r(this,ae).div.classList.remove("highlighting"))}enableClick(){if(r(this,Oi))return;p(this,Oi,new AbortController);const t=r(this,G).combinedSignal(r(this,Oi));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t}),this.div.addEventListener("pointerup",this.pointerup.bind(this),{signal:t})}disableClick(){var t;(t=r(this,Oi))==null||t.abort(),p(this,Oi,null)}attach(t){r(this,Ie).set(t.id,t);const{annotationElementId:e}=t;e&&r(this,G).isDeletedAnnotationElement(e)&&r(this,G).removeDeletedAnnotationElement(t)}detach(t){var e;r(this,Ie).delete(t.id),(e=r(this,qn))==null||e.removePointerInTextLayer(t.contentDiv),!r(this,ma)&&t.annotationElementId&&r(this,G).addDeletedAnnotationElement(t)}remove(t){this.detach(t),r(this,G).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1,r(this,ga)||this.addInkEditorIfNeeded(!1)}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(r(this,G).addDeletedAnnotationElement(t.annotationElementId),pt.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||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),r(this,G).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),r(this,G).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!r(this,ti)&&(t._focusEventsAllowed=!1,p(this,ti,setTimeout(()=>{p(this,ti,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:r(this,G)._signal}),e.focus())},0))),t._structTreeParentId=(s=r(this,qn))==null?void 0:s.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){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getNextId(){return r(this,G).getId()}combinedSignal(t){return r(this,G).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=r(this,Zt,Zc))==null?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){r(this,G).updateToolbar(t),r(this,G).updateMode(t);const{offsetX:s,offsetY:i}=m(this,Zt,ed).call(this),n=this.getNextId(),a=m(this,Zt,td).call(this,{parent:this,id:n,x:s,y:i,uiManager:r(this,G),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){var e;return await((e=r(qe,Hi).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,r(this,G)))||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),n=m(this,Zt,td).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:r(this,G),isCentered:e,...s});return n&&this.add(n),n}addNewEditor(){this.createAndAddNewEditor(m(this,Zt,ed).call(this),!0)}setSelected(t){r(this,G).setSelected(t)}toggleSelected(t){r(this,G).toggleSelected(t)}unselect(t){r(this,G).unselect(t)}pointerup(t){const{isMac:e}=fe.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&r(this,Ni)){if(p(this,Ni,!1),!r(this,pa)){p(this,pa,!0);return}if(r(this,G).getMode()===tt.STAMP){r(this,G).unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(r(this,G).getMode()===tt.HIGHLIGHT&&this.enableTextSelection(),r(this,Ni)){p(this,Ni,!1);return}const{isMac:e}=fe.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;p(this,Ni,!0);const s=r(this,G).getActive();p(this,pa,!s||s.isEmpty())}findNewParent(t,e,s){const i=r(this,G).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}destroy(){var t,e;((t=r(this,G).getActive())==null?void 0:t.parent)===this&&(r(this,G).commitOrRemove(),r(this,G).setActiveEditor(null)),r(this,ti)&&(clearTimeout(r(this,ti)),p(this,ti,null));for(const s of r(this,Ie).values())(e=r(this,qn))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,r(this,Ie).clear(),r(this,G).removeLayer(this)}render({viewport:t}){this.viewport=t,Xn(this.div,t);for(const e of r(this,G).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){r(this,G).commitOrRemove(),m(this,Zt,Yl).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,Xn(this.div,{rotation:s}),e!==s)for(const i of r(this,Ie).values())i.rotate(s);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return r(this,G).viewParameters.realScale}};qn=new WeakMap,pa=new WeakMap,Cs=new WeakMap,Oi=new WeakMap,ti=new WeakMap,Ie=new WeakMap,Ni=new WeakMap,ga=new WeakMap,ma=new WeakMap,ae=new WeakMap,ei=new WeakMap,G=new WeakMap,Hi=new WeakMap,Zt=new WeakSet,rp=function(t){r(this,G).unselectAll();const{target:e}=t;if(e===r(this,ae).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&r(this,ae).div.contains(e)){const{isMac:s}=fe.platform;if(t.button!==0||t.ctrlKey&&s)return;r(this,G).showAllEditors("highlight",!0,!0),r(this,ae).div.classList.add("free"),this.toggleDrawing(),th.startHighlighting(this,r(this,G).direction==="ltr",{target:r(this,ae).div,x:t.x,y:t.y}),r(this,ae).div.addEventListener("pointerup",()=>{r(this,ae).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:r(this,G)._signal}),t.preventDefault()}},Zc=function(){return r(qe,Hi).get(r(this,G).getMode())},td=function(t){const e=r(this,Zt,Zc);return e?new e.prototype.constructor(t):null},ed=function(){const{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),n=Math.max(0,t),a=Math.max(0,e),o=Math.min(window.innerWidth,t+s),l=Math.min(window.innerHeight,e+i),h=(n+o)/2-t,d=(a+l)/2-e,[u,f]=this.viewport.rotation%180===0?[h,d]:[d,h];return{offsetX:u,offsetY:f}},Yl=function(){p(this,ga,!0);for(const t of r(this,Ie).values())t.isEmpty()&&t.remove();p(this,ga,!1)},Y(qe,"_initialized",!1),b(qe,Hi,new Map([Lc,jc,Yc,th].map(t=>[t._editorType,t])));let Jc=qe;var Ts,nl,Ft,si,rl,id,Zn,nd,ap;const Yt=class Yt{constructor({pageIndex:t}){b(this,Zn);b(this,Ts,null);b(this,nl,0);b(this,Ft,new Map);b(this,si,new Map);this.pageIndex=t}setParent(t){if(!r(this,Ts)){p(this,Ts,t);return}if(r(this,Ts)!==t){if(r(this,Ft).size>0)for(const e of r(this,Ft).values())e.remove(),t.append(e);p(this,Ts,t)}}static get _svgFactory(){return ot(this,"_svgFactory",new vd)}draw(t,e,s,i=!1){const n=he(this,nl)._++,a=m(this,Zn,nd).call(this,t.box);a.classList.add(...t.classNamesForDrawing);const o=Yt._svgFactory.createElement("defs");a.append(o);const l=Yt._svgFactory.createElement("path");o.append(l);const h=`path_p${this.pageIndex}_${n}`;l.setAttribute("id",h),l.setAttribute("d",t.toSVGPath()),i&&r(this,si).set(n,l);const d=m(this,Zn,ap).call(this,o,h),u=Yt._svgFactory.createElement("use");return a.append(u),a.setAttribute("fill",e),a.setAttribute("fill-opacity",s),u.setAttribute("href",`#${h}`),r(this,Ft).set(n,a),{id:n,clipPathId:`url(#${d})`}}drawOutline(t){const e=he(this,nl)._++,s=m(this,Zn,nd).call(this,t.box);s.classList.add(...t.classNamesForOutlining);const i=Yt._svgFactory.createElement("defs");s.append(i);const n=Yt._svgFactory.createElement("path");i.append(n);const a=`path_p${this.pageIndex}_${e}`;n.setAttribute("id",a),n.setAttribute("d",t.toSVGPath()),n.setAttribute("vector-effect","non-scaling-stroke");let o;if(t.mustRemoveSelfIntersections){const d=Yt._svgFactory.createElement("mask");i.append(d),o=`mask_p${this.pageIndex}_${e}`,d.setAttribute("id",o),d.setAttribute("maskUnits","objectBoundingBox");const u=Yt._svgFactory.createElement("rect");d.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");const f=Yt._svgFactory.createElement("use");d.append(f),f.setAttribute("href",`#${a}`),f.setAttribute("stroke","none"),f.setAttribute("fill","black"),f.setAttribute("fill-rule","nonzero"),f.classList.add("mask")}const l=Yt._svgFactory.createElement("use");s.append(l),l.setAttribute("href",`#${a}`),o&&l.setAttribute("mask",`url(#${o})`);const h=l.cloneNode();return s.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),r(this,Ft).set(e,s),e}finalizeLine(t,e){const s=r(this,si).get(t);r(this,si).delete(t),this.updateBox(t,e.box),s.setAttribute("d",e.toSVGPath())}updateLine(t,e){r(this,Ft).get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}updatePath(t,e){r(this,si).get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){var s;m(s=Yt,rl,id).call(s,r(this,Ft).get(t),e)}show(t,e){r(this,Ft).get(t).classList.toggle("hidden",!e)}rotate(t,e){r(this,Ft).get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){r(this,Ft).get(t).setAttribute("fill",e)}changeOpacity(t,e){r(this,Ft).get(t).setAttribute("fill-opacity",e)}addClass(t,e){r(this,Ft).get(t).classList.add(e)}removeClass(t,e){r(this,Ft).get(t).classList.remove(e)}getSVGRoot(t){return r(this,Ft).get(t)}remove(t){r(this,si).delete(t),r(this,Ts)!==null&&(r(this,Ft).get(t).remove(),r(this,Ft).delete(t))}destroy(){p(this,Ts,null);for(const t of r(this,Ft).values())t.remove();r(this,Ft).clear(),r(this,si).clear()}};Ts=new WeakMap,nl=new WeakMap,Ft=new WeakMap,si=new WeakMap,rl=new WeakSet,id=function(t,{x:e=0,y:s=0,width:i=1,height:n=1}={}){const{style:a}=t;a.top=`${100*s}%`,a.left=`${100*e}%`,a.width=`${100*i}%`,a.height=`${100*n}%`},Zn=new WeakSet,nd=function(t){var s;const e=Yt._svgFactory.create(1,1,!0);return r(this,Ts).append(e),e.setAttribute("aria-hidden",!0),m(s=Yt,rl,id).call(s,e,t),e},ap=function(t,e){const s=Yt._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=Yt._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i},b(Yt,rl);let sd=Yt;Q.AbortException;Q.AnnotationEditorLayer;Q.AnnotationEditorParamsType;Q.AnnotationEditorType;Q.AnnotationEditorUIManager;var op=Q.AnnotationLayer,lp=Q.AnnotationMode;Q.ColorPicker;Q.DOMSVGFactory;Q.DrawLayer;Q.FeatureTest;var Th=Q.GlobalWorkerOptions;Q.ImageKind;Q.InvalidPDFException;Q.MissingPDFException;Q.OPS;Q.OutputScale;var Vm=Q.PDFDataRangeTransport;Q.PDFDateString;Q.PDFWorker;Q.PasswordResponses;Q.PermissionFlag;Q.PixelsPerInch;Q.RenderingCancelledException;var hp=Q.TextLayer;Q.UnexpectedResponseException;Q.Util;Q.VerbosityLevel;Q.XfaLayer;Q.build;Q.createValidAbsoluteUrl;Q.fetchData;var cp=Q.getDocument;Q.getFilenameFromUrl;Q.getPdfFilenameFromUrl;Q.getXfaPageViewport;Q.isDataScheme;Q.isPdfFile;Q.noContextMenu;Q.normalizeUnicode;Q.setLayerDimensions;Q.shadow;var rd=Q.version;const qm=Object.freeze(Object.defineProperty({__proto__:null,AnnotationLayer:op,AnnotationMode:lp,GlobalWorkerOptions:Th,PDFDataRangeTransport:Vm,TextLayer:hp,getDocument:cp,version:rd},Symbol.toStringTag,{value:"Module"}));var Gt=function(c,t,e){if(e||arguments.length===2)for(var s=0,i=t.length,n;s{At(this.pdfDocument),At(t),typeof t=="string"?this.pdfDocument.getDestination(t).then(e):Array.isArray(t)?e(t):t.then(e)}).then(e=>{At(Array.isArray(e));const s=e[0];new Promise(i=>{At(this.pdfDocument),s instanceof Object?this.pdfDocument.getPageIndex(s).then(n=>{i(n)}).catch(()=>{At(!1)}):typeof s=="number"?i(s):At(!1)}).then(i=>{const n=i+1;At(this.pdfViewer),At(n>=1&&n<=this.pagesCount),this.pdfViewer.scrollPageIntoView({dest:e,pageIndex:i,pageNumber:n})})})}navigateTo(t){this.goToDestination(t)}goToPage(t){const e=t-1;At(this.pdfViewer),At(t>=1&&t<=this.pagesCount),this.pdfViewer.scrollPageIntoView({pageIndex:e,pageNumber:t})}addLinkAttributes(t,e,s){t.href=e,t.rel=this.externalLinkRel||mb,t.target=s?"_blank":this.externalLinkTarget||""}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}setHash(){}executeNamedAction(){}cachePageRef(){}isPageVisible(){return!0}isPageCached(){return!0}executeSetOCGState(){}}const qd={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},Rh=typeof window<"u",fp=Rh&&window.location.protocol==="file:";function Ab(c){return typeof c<"u"}function Ui(c){return Ab(c)&&c!==null}function yb(c){return typeof c=="string"}function vb(c){return c instanceof ArrayBuffer}function wb(c){return At(Rh),c instanceof Blob}function ad(c){return yb(c)&&/^data:/.test(c)}function Xd(c){At(ad(c));const[t="",e=""]=c.split(",");return t.split(";").indexOf("base64")!==-1?atob(e):unescape(e)}function _b(){return Rh&&window.devicePixelRatio||1}const pp="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function Yd(){oe(!fp,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${pp}`)}function Eb(){oe(!fp,`Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${pp}`)}function Qn(c){c!=null&&c.cancel&&c.cancel()}function od(c,t){return Object.defineProperty(c,"width",{get(){return this.view[2]*t},configurable:!0}),Object.defineProperty(c,"height",{get(){return this.view[3]*t},configurable:!0}),Object.defineProperty(c,"originalWidth",{get(){return this.view[2]},configurable:!0}),Object.defineProperty(c,"originalHeight",{get(){return this.view[3]},configurable:!0}),c}function Sb(c){return c.name==="RenderingCancelledException"}function xb(c){return new Promise((t,e)=>{const s=new FileReader;s.onload=()=>{if(!s.result)return e(new Error("Error while reading a file."));t(s.result)},s.onerror=i=>{if(!i.target)return e(new Error("Error while reading a file."));const{error:n}=i.target;if(!n)return e(new Error("Error while reading a file."));switch(n.code){case n.NOT_FOUND_ERR:return e(new Error("Error while reading a file: File not found."));case n.SECURITY_ERR:return e(new Error("Error while reading a file: Security error."));case n.ABORT_ERR:return e(new Error("Error while reading a file: Aborted."));default:return e(new Error("Error while reading a file."))}},s.readAsArrayBuffer(c)})}function Cb(c,t){switch(t.type){case"RESOLVE":return{value:t.value,error:void 0};case"REJECT":return{value:!1,error:t.error};case"RESET":return{value:void 0,error:void 0};default:return c}}function ba(){return R.useReducer(Cb,{value:void 0,error:void 0})}var Tb=function(c,t,e,s){function i(n){return n instanceof e?n:new e(function(a){a(n)})}return new(e||(e=Promise))(function(n,a){function o(d){try{h(s.next(d))}catch(u){a(u)}}function l(d){try{h(s.throw(d))}catch(u){a(u)}}function h(d){d.done?n(d.value):i(d.value).then(o,l)}h((s=s.apply(c,t||[])).next())})},Kd=function(c,t){var e={};for(var s in c)Object.prototype.hasOwnProperty.call(c,s)&&t.indexOf(s)<0&&(e[s]=c[s]);if(c!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(c);i{switch(t){case qd.NEED_PASSWORD:{const e=prompt("Enter the password to open this PDF file.");c(e);break}case qd.INCORRECT_PASSWORD:{const e=prompt("Invalid password. Please try again.");c(e);break}}};function Qd(c){return typeof c=="object"&&c!==null&&("data"in c||"range"in c||"url"in c)}const kb=R.forwardRef(function(t,e){var{children:s,className:i,error:n="Failed to load PDF file.",externalLinkRel:a,externalLinkTarget:o,file:l,inputRef:h,imageResourcesPath:d,loading:u="Loading PDF…",noData:f="No PDF file specified.",onItemClick:g,onLoadError:A,onLoadProgress:y,onLoadSuccess:w,onPassword:v=Pb,onSourceError:_,onSourceSuccess:S,options:E,renderMode:C,rotate:x}=t,T=Kd(t,["children","className","error","externalLinkRel","externalLinkTarget","file","inputRef","imageResourcesPath","loading","noData","onItemClick","onLoadError","onLoadProgress","onLoadSuccess","onPassword","onSourceError","onSourceSuccess","options","renderMode","rotate"]);const[P,L]=ba(),{value:O,error:F}=P,[J,U]=ba(),{value:z,error:X}=J,q=R.useRef(new bb),H=R.useRef([]),$=R.useRef(void 0),B=R.useRef(void 0);l&&l!==$.current&&Qd(l)&&(oe(!br(l,$.current),`File prop passed to changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "file" prop.`),$.current=l),E&&E!==B.current&&(oe(!br(E,B.current),`Options prop passed to changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "options" prop.`),B.current=E);const V=R.useRef({scrollPageIntoView:yt=>{const{dest:Mt,pageNumber:te,pageIndex:zt=te-1}=yt;if(g){g({dest:Mt,pageIndex:zt,pageNumber:te});return}const ir=H.current[zt];if(ir){ir.scrollIntoView();return}oe(!1,`An internal link leading to page ${te} was clicked, but neither was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to and handle navigating by yourself or ensure that all pages are rendered within .`)}});R.useImperativeHandle(e,()=>({linkService:q,pages:H,viewer:V}),[]);function rt(){S&&S()}function M(){F&&(oe(!1,F.toString()),_&&_(F))}function W(){L({type:"RESET"})}R.useEffect(W,[l,L]);const lt=R.useCallback(()=>Tb(this,void 0,void 0,function*(){if(!l)return null;if(typeof l=="string")return ad(l)?{data:Xd(l)}:(Yd(),{url:l});if(l instanceof Rb)return{range:l};if(vb(l))return{data:l};if(Rh&&wb(l))return{data:yield xb(l)};if(At(typeof l=="object"),At(Qd(l)),"url"in l&&typeof l.url=="string"){if(ad(l.url)){const{url:yt}=l,Mt=Kd(l,["url"]),te=Xd(yt);return Object.assign({data:te},Mt)}Yd()}return l}),[l]);R.useEffect(()=>{const yt=hl(lt());return yt.promise.then(Mt=>{L({type:"RESOLVE",value:Mt})}).catch(Mt=>{L({type:"REJECT",error:Mt})}),()=>{Qn(yt)}},[lt,L]),R.useEffect(()=>{if(!(typeof O>"u")){if(O===!1){M();return}rt()}},[O]);function gt(){z&&(w&&w(z),H.current=new Array(z.numPages),q.current.setDocument(z))}function dt(){X&&(oe(!1,X.toString()),A&&A(X))}R.useEffect(function(){U({type:"RESET"})},[U,O]),R.useEffect(function(){if(!O)return;const Mt=E?Object.assign(Object.assign({},O),E):O,te=cp(Mt);y&&(te.onProgress=y),v&&(te.onPassword=v);const zt=te,ir=zt.promise.then(va=>{U({type:"RESOLVE",value:va})}).catch(va=>{zt.destroyed||U({type:"REJECT",error:va})});return()=>{ir.finally(()=>zt.destroy())}},[E,U,O]),R.useEffect(()=>{if(!(typeof z>"u")){if(z===!1){dt();return}gt()}},[z]),R.useEffect(function(){q.current.setViewer(V.current),q.current.setExternalLinkRel(a),q.current.setExternalLinkTarget(o)},[a,o]);const nt=R.useCallback((yt,Mt)=>{H.current[yt]=Mt},[]),me=R.useCallback(yt=>{delete H.current[yt]},[]),be=R.useMemo(()=>({imageResourcesPath:d,linkService:q.current,onItemClick:g,pdf:z,registerPage:nt,renderMode:C,rotate:x,unregisterPage:me}),[d,g,z,nt,C,x,me]),_t=R.useMemo(()=>dp(T,()=>z),[T,z]);function Aa(){return k.jsx(up.Provider,{value:be,children:s})}function ya(){return l?z==null?k.jsx(Ar,{type:"loading",children:typeof u=="function"?u():u}):z===!1?k.jsx(Ar,{type:"error",children:typeof n=="function"?n():n}):Aa():k.jsx(Ar,{type:"no-data",children:typeof f=="function"?f():f})}return k.jsx("div",Object.assign({className:Ah("react-pdf__Document",i),ref:h,style:{"--scale-factor":"1"}},_t,{children:ya()}))});function gp(){return R.useContext(up)}function mp(){for(var c=[],t=0;tFb(t),[t]),s=R.useMemo(()=>!Ph(t)||yp(t)?null:t.children.map((i,n)=>k.jsx(wp,{node:i},n)),[t]);return k.jsx("span",Object.assign({className:c},e,{children:s}))}function kh(){return R.useContext(bp)}function Db(){const c=kh();At(c);const{onGetStructTreeError:t,onGetStructTreeSuccess:e}=c,[s,i]=ba(),{value:n,error:a}=s,{customTextRenderer:o,page:l}=c;function h(){n&&e&&e(n)}function d(){a&&(oe(!1,a.toString()),t&&t(a))}return R.useEffect(function(){i({type:"RESET"})},[i,l]),R.useEffect(function(){if(o||!l)return;const f=hl(l.getStructTree()),g=f;return f.promise.then(A=>{i({type:"RESOLVE",value:A})}).catch(A=>{i({type:"REJECT",error:A})}),()=>Qn(g)},[o,l,i]),R.useEffect(()=>{if(n!==void 0){if(n===!1){d();return}h()}},[n]),n?k.jsx(wp,{className:"react-pdf__Page__structTree structTree",node:n}):null}const Jd=lp;function Ob(c){const t=kh();At(t);const e=Object.assign(Object.assign({},t),c),{_className:s,canvasBackground:i,devicePixelRatio:n=_b(),onRenderError:a,onRenderSuccess:o,page:l,renderForms:h,renderTextLayer:d,rotate:u,scale:f}=e,{canvasRef:g}=c;At(l);const A=R.useRef(null);function y(){l&&o&&o(od(l,f))}function w(E){Sb(E)||(oe(!1,E.toString()),a&&a(E))}const v=R.useMemo(()=>l.getViewport({scale:f*n,rotation:u}),[n,l,u,f]),_=R.useMemo(()=>l.getViewport({scale:f,rotation:u}),[l,u,f]);R.useEffect(function(){if(!l)return;l.cleanup();const{current:C}=A;if(!C)return;C.width=v.width,C.height=v.height,C.style.width=`${Math.floor(_.width)}px`,C.style.height=`${Math.floor(_.height)}px`,C.style.visibility="hidden";const x={annotationMode:h?Jd.ENABLE_FORMS:Jd.ENABLE,canvasContext:C.getContext("2d",{alpha:!1}),viewport:v};i&&(x.background=i);const T=l.render(x),P=T;return T.promise.then(()=>{C.style.visibility="",y()}).catch(w),()=>Qn(P)},[i,l,h,v,_]);const S=R.useCallback(()=>{const{current:E}=A;E&&(E.width=0,E.height=0)},[]);return R.useEffect(()=>S,[S]),k.jsx("canvas",{className:`${s}__canvas`,dir:"ltr",ref:mp(g,A),style:{display:"block",userSelect:"none"},children:d?k.jsx(Db,{}):null})}function Nb(c){return"str"in c}function Hb(){const c=kh();At(c);const{customTextRenderer:t,onGetTextError:e,onGetTextSuccess:s,onRenderTextLayerError:i,onRenderTextLayerSuccess:n,page:a,pageIndex:o,pageNumber:l,rotate:h,scale:d}=c;At(a);const[u,f]=ba(),{value:g,error:A}=u,y=R.useRef(null);oe(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"),10)===1,"TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer");function w(){g&&s&&s(g)}function v(){A&&(oe(!1,A.toString()),e&&e(A))}R.useEffect(function(){f({type:"RESET"})},[a,f]),R.useEffect(function(){if(!a)return;const P=hl(a.getTextContent()),L=P;return P.promise.then(O=>{f({type:"RESOLVE",value:O})}).catch(O=>{f({type:"REJECT",error:O})}),()=>Qn(L)},[a,f]),R.useEffect(()=>{if(g!==void 0){if(g===!1){v();return}w()}},[g]);const _=R.useCallback(()=>{n&&n()},[n]),S=R.useCallback(T=>{oe(!1,T.toString()),i&&i(T)},[i]);function E(){const T=y.current;T&&T.classList.add("selecting")}function C(){const T=y.current;T&&T.classList.remove("selecting")}const x=R.useMemo(()=>a.getViewport({scale:d,rotation:h}),[a,h,d]);return R.useLayoutEffect(function(){if(!a||!g)return;const{current:P}=y;if(!P)return;P.innerHTML="";const L=a.streamTextContent({includeMarkedContent:!0}),O={container:P,textContentSource:L,viewport:x},F=new hp(O),J=F;return F.render().then(()=>{const U=document.createElement("div");U.className="endOfContent",P.append(U);const z=P.querySelectorAll('[role="presentation"]');if(t){let X=0;g.items.forEach((q,H)=>{if(!Nb(q))return;const $=z[X];if(!$)return;const B=t(Object.assign({pageIndex:o,pageNumber:l,itemIndex:H},q));$.innerHTML=B,X+=q.str&&q.hasEOL?2:1})}_()}).catch(S),()=>Qn(J)},[t,S,_,a,o,l,g,x]),k.jsx("div",{className:Ah("react-pdf__Page__textContent","textLayer"),onMouseUp:C,onMouseDown:E,ref:y})}function Bb(){const c=gp(),t=kh();At(t);const e=Object.assign(Object.assign({},c),t),{imageResourcesPath:s,linkService:i,onGetAnnotationsError:n,onGetAnnotationsSuccess:a,onRenderAnnotationLayerError:o,onRenderAnnotationLayerSuccess:l,page:h,pdf:d,renderForms:u,rotate:f,scale:g=1}=e;At(d),At(h),At(i);const[A,y]=ba(),{value:w,error:v}=A,_=R.useRef(null);oe(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"),10)===1,"AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations");function S(){w&&a&&a(w)}function E(){v&&(oe(!1,v.toString()),n&&n(v))}R.useEffect(function(){y({type:"RESET"})},[y,h]),R.useEffect(function(){if(!h)return;const L=hl(h.getAnnotations()),O=L;return L.promise.then(F=>{y({type:"RESOLVE",value:F})}).catch(F=>{y({type:"REJECT",error:F})}),()=>{Qn(O)}},[y,h]),R.useEffect(()=>{if(w!==void 0){if(w===!1){E();return}S()}},[w]);function C(){l&&l()}function x(P){oe(!1,`${P}`),o&&o(P)}const T=R.useMemo(()=>h.getViewport({scale:g,rotation:f}),[h,f,g]);return R.useEffect(function(){if(!d||!h||!i||!w)return;const{current:L}=_;if(!L)return;const O=T.clone({dontFlip:!0}),F={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,div:L,l10n:null,page:h,structTreeLayer:null,viewport:O},J={annotations:w,annotationStorage:d.annotationStorage,div:L,imageResourcesPath:s,linkService:i,page:h,renderForms:u,viewport:O};L.innerHTML="";try{new op(F).render(J),C()}catch(U){x(U)}return()=>{}},[w,s,i,h,d,u,T]),k.jsx("div",{className:Ah("react-pdf__Page__annotations","annotationLayer"),ref:_})}var jb=function(c,t){var e={};for(var s in c)Object.prototype.hasOwnProperty.call(c,s)&&t.indexOf(s)<0&&(e[s]=c[s]);if(c!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(c);i{if(!_t)return null;let nr=1;const dl=lt??Zd;if(dt||g){const ul=_t.getViewport({scale:1,rotation:te});dt?nr=dt/ul.width:g&&(nr=g/ul.height)}return dl*nr},[g,_t,te,lt,dt]);R.useEffect(function(){return()=>{Ui(yt)&&i&>&>(yt)}},[i,H,yt,gt]);function ir(){if(P){if(!_t||!zt)return;P(od(_t,zt))}if(i&&$){if(!Ui(yt)||!ya.current)return;$(yt,ya.current)}}function va(){Aa&&(oe(!1,Aa.toString()),T&&T(Aa))}R.useEffect(function(){be({type:"RESET"})},[be,H,yt]),R.useEffect(function(){if(!H||!Mt)return;const dl=hl(H.getPage(Mt)),ul=dl;return dl.promise.then(Lh=>{be({type:"RESOLVE",value:Lh})}).catch(Lh=>{be({type:"REJECT",error:Lh})}),()=>Qn(ul)},[be,H,Mt]),R.useEffect(()=>{if(_t!==void 0){if(_t===!1){va();return}ir()}},[_t,zt]);const Sp=R.useMemo(()=>_t&&Ui(yt)&&Mt&&Ui(te)&&Ui(zt)?{_className:s,canvasBackground:n,customTextRenderer:d,devicePixelRatio:u,onGetAnnotationsError:v,onGetAnnotationsSuccess:_,onGetStructTreeError:S,onGetStructTreeSuccess:E,onGetTextError:C,onGetTextSuccess:x,onRenderAnnotationLayerError:L,onRenderAnnotationLayerSuccess:O,onRenderError:F,onRenderSuccess:J,onRenderTextLayerError:U,onRenderTextLayerSuccess:z,page:_t,pageIndex:yt,pageNumber:Mt,renderForms:V,renderTextLayer:M,rotate:te,scale:zt}:null,[s,n,d,u,v,_,S,E,C,x,L,O,F,J,U,z,_t,yt,Mt,V,M,te,zt]),xp=R.useMemo(()=>dp(nt,()=>_t&&(zt?od(_t,zt):void 0)),[nt,_t,zt]),cl=`${yt}@${zt}/${te}`;function Cp(){switch(rt){case"custom":return At(h),k.jsx(h,{},`${cl}_custom`);case"none":return null;case"canvas":default:return k.jsx(Ob,{canvasRef:a},`${cl}_canvas`)}}function Tp(){return M?k.jsx(Hb,{},`${cl}_text`):null}function Rp(){return B?k.jsx(Bb,{},`${cl}_annotations`):null}function Pp(){return k.jsxs(bp.Provider,{value:Sp,children:[Cp(),Tp(),Rp(),o]})}function kp(){return Mt?H===null||_t===void 0||_t===null?k.jsx(Ar,{type:"loading",children:typeof y=="function"?y():y}):H===!1||_t===!1?k.jsx(Ar,{type:"error",children:typeof f=="function"?f():f}):Pp():k.jsx(Ar,{type:"no-data",children:typeof w=="function"?w():w})}return k.jsx("div",Object.assign({className:Ah(s,l),"data-page-number":Mt,ref:mp(A,ya),style:{"--scale-factor":`${zt}`,backgroundColor:n||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"}},xp,{children:kp()}))}Eb();Th.workerSrc="pdf.worker.mjs";const zb="/assets/pdf.worker.min-GB3t0DcA.mjs";Th.workerSrc=zb;function Gb(){if(!Th.workerSrc)throw new Error("The bundled PDF worker is not configured.");if(rd!=="4.8.69")throw new Error(`PDF runtime version mismatch (${rd}).`)}function Ub({page:c,pages:t,zoomPercent:e,searchOpen:s,searchQuery:i,searchMatch:n,searchCount:a,searching:o,originalUrl:l,onPage:h,onZoomIn:d,onZoomOut:u,onFitWidth:f,onToggleSearch:g,onSearchQuery:A,onSearch:y}){const w=v=>{v.preventDefault();const _=Number(new FormData(v.currentTarget).get("page"));Number.isInteger(_)&&h(_)};return k.jsxs("div",{className:"pdf-toolbar","aria-label":"PDF controls",children:[k.jsxs("div",{className:"pdf-toolbar-group",children:[k.jsx("button",{type:"button",onClick:()=>h(c-1),disabled:c<=1,"aria-label":"Previous page",children:"←"}),k.jsxs("form",{onSubmit:w,className:"pdf-page-form",children:[k.jsx("label",{className:"sr-only",htmlFor:"pdf-current-page",children:"Current page"}),k.jsx("input",{id:"pdf-current-page",name:"page",type:"number",min:1,max:t||1,defaultValue:c,"aria-label":`Page ${c} of ${t||"unknown"}`},c),k.jsxs("span",{"aria-hidden":"true",children:["/ ",t||"—"]})]}),k.jsx("button",{type:"button",onClick:()=>h(c+1),disabled:!t||c>=t,"aria-label":"Next page",children:"→"})]}),k.jsxs("div",{className:"pdf-toolbar-group",children:[k.jsx("button",{type:"button",onClick:u,"aria-label":"Zoom out",children:"−"}),k.jsxs("span",{className:"pdf-zoom-value","aria-live":"polite",children:[e,"%"]}),k.jsx("button",{type:"button",onClick:d,"aria-label":"Zoom in",children:"+"}),k.jsx("button",{type:"button",onClick:f,children:"Fit width"}),k.jsx("button",{type:"button",onClick:g,"aria-expanded":s,"aria-controls":"pdf-search-controls",children:"Search"}),k.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",download:!0,children:"Open original"})]}),s&&k.jsxs("div",{id:"pdf-search-controls",className:"pdf-search-controls",children:[k.jsx("label",{className:"sr-only",htmlFor:"pdf-search-input",children:"Search document"}),k.jsx("input",{id:"pdf-search-input",autoFocus:!0,value:i,onChange:v=>A(v.target.value),placeholder:"Search document"}),k.jsx("span",{role:"status",children:o?"Searching…":i?`${a?n+1:0} of ${a}`:""}),k.jsx("button",{type:"button",onClick:()=>y(-1),disabled:!a,"aria-label":"Previous match",children:"↑"}),k.jsx("button",{type:"button",onClick:()=>y(1),disabled:!a,"aria-label":"Next match",children:"↓"})]})]})}function Wb(c){const t=c.message.toLowerCase();return t.includes("password")?"This PDF is encrypted and cannot be opened in the reader.":t.includes("worker")?"The PDF renderer could not start.":t.includes("invalid")||t.includes("format")?"The source returned an invalid or unsupported PDF.":t.includes("cors")||t.includes("fetch")||t.includes("network")?"The PDF source could not be loaded in this browser.":"The PDF could not be loaded from its source."}function Vb({page:c,width:t}){const e=R.useRef(null),[s,i]=R.useState(c<=2);return R.useEffect(()=>{const n=e.current;if(!n)return;const a=new IntersectionObserver(([o])=>i(o.isIntersecting),{rootMargin:"120% 0px"});return a.observe(n),()=>a.disconnect()},[]),k.jsx("div",{ref:e,className:"pdf-page","data-page":c,style:{minHeight:Math.round(t*1.35)},children:s&&k.jsx($b,{pageNumber:c,width:t,devicePixelRatio:Math.min(window.devicePixelRatio||1,2),renderTextLayer:!0,renderAnnotationLayer:!0,loading:null})})}function qb({url:c,paperKey:t,initialPage:e=1,onPageChange:s}){const i=R.useRef(null),n=R.useRef(null),a=R.useRef(null),o=R.useRef(0),[l,h]=R.useState(0),[d,u]=R.useState(0),[f,g]=R.useState(e),[A,y]=R.useState(700),[w,v]=R.useState(1),[_,S]=R.useState(""),[E,C]=R.useState(!1),[x,T]=R.useState(""),[P,L]=R.useState(!1),[O,F]=R.useState([]),[J,U]=R.useState(0),z=Math.max(240,Math.round(A*w));R.useEffect(()=>{Gb()},[]),R.useEffect(()=>{u(0),g(e),v(1),S(""),T(""),F([])},[e,t,l]),R.useEffect(()=>{const B=n.current;if(!B)return;const V=()=>y(Math.max(240,B.clientWidth-10));V();const rt=new ResizeObserver(V);return rt.observe(B),()=>rt.disconnect()},[]);const X=R.useCallback(B=>{const V=Math.max(1,Math.min(d||1,B));g(V),s==null||s(V)},[s,d]);R.useEffect(()=>{const B=n.current;if(!B||!d)return;let V=0;const rt=()=>{cancelAnimationFrame(V),V=requestAnimationFrame(()=>{const M=B.getBoundingClientRect().top+B.clientHeight/2;let W=f,lt=Number.POSITIVE_INFINITY;B.querySelectorAll("[data-page]").forEach(gt=>{const dt=gt.getBoundingClientRect(),nt=M>=dt.top&&M<=dt.bottom?0:Math.min(Math.abs(M-dt.top),Math.abs(M-dt.bottom));nt{B.removeEventListener("scroll",rt),cancelAnimationFrame(V)}},[f,z,d,X]),R.useEffect(()=>{const B=V=>{(V.ctrlKey||V.metaKey)&&V.key.toLowerCase()==="f"&&(V.preventDefault(),C(!0))};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[]),R.useEffect(()=>{const B=a.current,V=x.trim().toLocaleLowerCase(),rt=++o.current;if(!B||!V){F([]),U(0),L(!1);return}L(!0);const M=window.setTimeout(()=>void(async()=>{const W=[];for(let lt=1;lt<=B.numPages;lt+=1){if(o.current!==rt)return;const nt=(await(await B.getPage(lt)).getTextContent()).items.map(be=>"str"in be?be.str:"").join(" ").toLocaleLowerCase();let me=0;for(;(me=nt.indexOf(V,me))>=0;)W.push(lt),me+=Math.max(1,V.length)}o.current===rt&&(F(W),U(0),L(!1),W[0]&&q(W[0]))})().catch(()=>{o.current===rt&&L(!1)}),180);return()=>window.clearTimeout(M)},[x,d]);const q=B=>{var rt,M;const V=Math.max(1,Math.min(d||1,B));(M=(rt=n.current)==null?void 0:rt.querySelector(`[data-page="${V}"]`))==null||M.scrollIntoView({block:"start"}),X(V)},H=B=>{if(!O.length)return;const V=(J+B+O.length)%O.length;U(V),q(O[V])},$=R.useMemo(()=>Array.from({length:d},(B,V)=>V+1),[d]);return k.jsxs("div",{ref:i,className:"pdf-viewer",children:[k.jsx(Ub,{page:f,pages:d,zoomPercent:Math.round(w*100),searchOpen:E,searchQuery:x,searchMatch:J,searchCount:O.length,searching:P,originalUrl:c,onPage:q,onZoomIn:()=>v(B=>Math.min(3,B+.15)),onZoomOut:()=>v(B=>Math.max(.5,B-.15)),onFitWidth:()=>v(1),onToggleSearch:()=>C(B=>!B),onSearchQuery:T,onSearch:H}),k.jsx("div",{ref:n,className:"pdf-scroll",role:"region","aria-label":"Paper PDF",children:_?k.jsxs("div",{className:"pdf-error",role:"alert",children:[k.jsx("p",{children:_}),k.jsxs("div",{children:[k.jsx("button",{type:"button",onClick:()=>h(B=>B+1),children:"Retry"})," ",k.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",children:"Open original PDF"})]})]}):k.jsx(kb,{file:c,loading:k.jsx("div",{className:"pdf-loading",role:"status",children:"Loading paper…"}),onLoadSuccess:B=>{a.current=B,u(B.numPages),S("");const V=Math.max(1,Math.min(B.numPages,e));V>1&&requestAnimationFrame(()=>requestAnimationFrame(()=>{var rt,M;(M=(rt=n.current)==null?void 0:rt.querySelector(`[data-page="${V}"]`))==null||M.scrollIntoView({block:"start"}),g(V),s==null||s(V)}))},onLoadError:B=>S(Wb(B)),externalLinkTarget:"_blank",children:k.jsx("div",{className:"pdf-pages",children:$.map(B=>k.jsx(Vb,{page:B,width:z},B))})},`${t}-${l}`)})]})}const ld=66,_p="pwc:reader:split-ratio",yl=c=>`pwc:reader:session:${c}`,Bh=c=>`pwc:reader:assistant-collapsed:${c}`,Ep=c=>`pwc:reader:page:${c}`;function jh(c){const t=Number(sessionStorage.getItem(Ep(c)));return Number.isInteger(t)&&t>0?t:1}function Xb(){const c=Number(localStorage.getItem(_p));return Number.isFinite(c)&&c>=45&&c<=75?c:ld}function AA(){var B,V,rt;const{arxivId:c}=Fp(),t=Dp(c??"").replace(/v\d+$/i,""),e=Op(),{user:s,logout:i}=Np(),n=zp(t,!!t),a=$p({queryKey:["chatAvailability"],queryFn:()=>Gp.getAvailability(),refetchInterval:3e4,retry:!1}),o=n.data,l=Up(o==null?void 0:o.url_pdf),h=((B=o==null?void 0:o.arxiv_id)==null?void 0:B.replace(/v\d+$/i,""))||t,[d,u]=R.useState(()=>sessionStorage.getItem(yl(t))||void 0),[f,g]=R.useState(Xb),[A,y]=R.useState(()=>sessionStorage.getItem(Bh(t))==="1"),[w,v]=R.useState("paper"),[_,S]=R.useState(()=>jh(t)),[E,C]=R.useState(0),x=R.useRef(null),T=R.useRef(!1),P=R.useRef(jh(t)),L=E>900&&E>=840;R.useEffect(()=>{c&&c!==t&&e(`/pdf/${t}`,{replace:!0})},[e,c,t]),R.useEffect(()=>{const M=sessionStorage.getItem(yl(t));u(M||void 0),y(sessionStorage.getItem(Bh(t))==="1"),v("paper");const W=jh(t);P.current=W,S(W)},[t]),R.useLayoutEffect(()=>{const M=x.current;if(!M)return;const W=()=>C(M.clientWidth);W();const lt=new ResizeObserver(W);return lt.observe(M),()=>lt.disconnect()},[]),R.useEffect(()=>{if(!o)return;document.title=`${o.title} — Papers With Code reader`;let M=document.querySelector('meta[name="robots"]');const W=!M;M||(M=document.createElement("meta"),M.name="robots",document.head.appendChild(M));const lt=M.content;M.content="noindex, nofollow";let gt=document.querySelector('link[rel="canonical"]');const dt=!gt;gt||(gt=document.createElement("link"),gt.rel="canonical",document.head.appendChild(gt));const nt=gt.href;return gt.href=`${window.location.origin}/paper/${h}`,()=>{document.title="Papers With Code",W?M==null||M.remove():M&&(M.content=lt),dt?gt==null||gt.remove():gt&&(gt.href=nt)}},[h,o]);const O=R.useCallback(M=>{if(!E)return Math.max(45,Math.min(75,M));const W=480/E*100,lt=100-360/E*100;return Math.max(W,Math.min(lt,M))},[E]);R.useEffect(()=>g(M=>O(M)),[O]);const F=M=>{const W=O(M);g(W),localStorage.setItem(_p,String(W))},J=M=>{var lt;const W=(lt=x.current)==null?void 0:lt.getBoundingClientRect();W&&F((M-W.left)/W.width*100)},U=M=>{T.current=!0,M.currentTarget.setPointerCapture(M.pointerId),J(M.clientX)},z=M=>{y(M),sessionStorage.setItem(Bh(t),M?"1":"0")},X=M=>{u(M),sessionStorage.setItem(yl(t),M)},q=()=>{u(void 0),sessionStorage.removeItem(yl(t))},H=Hp()&&((V=a.data)==null?void 0:V.paper_reader_chat_enabled)!==!1,$=o&&H?k.jsx(Wp,{mode:"paper",routeSessionId:d,primaryPaper:{id:o.id,routeId:h,title:o.title},currentPage:()=>P.current,onSessionId:X,onReaderSubmit:()=>v("assistant"),onReaderNewChat:q}):k.jsx("div",{className:"reader-chat-unavailable",children:"Assistant is not enabled for this preview."});return n.isLoading?k.jsx("div",{className:"reader-status",role:"status",children:"Loading paper…"}):n.error||!o?k.jsxs("div",{className:"reader-status",role:"alert",children:[k.jsx("p",{children:"Paper not found."}),k.jsx(rr,{to:"/papers",children:"Browse papers"})]}):((rt=a.data)==null?void 0:rt.native_pdf_reader_enabled)===!1?k.jsxs("div",{className:"reader-status",role:"alert",children:[k.jsx("p",{children:"The native reader is currently unavailable."}),k.jsx(rr,{to:`/paper/${h}`,children:"Back to paper"})]}):o.source!=="arxiv"||!l?k.jsxs("div",{className:"reader-status",role:"alert",children:[k.jsx("p",{children:"Native reading is unavailable for this resource."}),k.jsx(rr,{to:`/paper/${h}`,children:"Back to paper"})]}):k.jsxs("div",{className:"paper-reader-shell",children:[k.jsxs("header",{className:"reader-header",children:[k.jsx(rr,{to:`/paper/${h}`,className:"reader-back","aria-label":"Back to paper page",children:"← Back"}),k.jsxs(rr,{to:"/",className:"reader-brand",children:["Papers ",k.jsx("em",{children:"With Code"})]}),k.jsx("div",{className:"reader-header-spacer"}),s?k.jsx(Bp,{user:s,onLogout:i}):k.jsx(jp,{compact:!0,returnTo:`/pdf/${h}`})]}),!L&&k.jsxs("div",{className:"reader-tabs",role:"tablist","aria-label":"Reader panels",children:[k.jsx("button",{type:"button",role:"tab","aria-selected":w==="paper",onClick:()=>v("paper"),children:"Paper"}),k.jsx("button",{type:"button",role:"tab","aria-selected":w==="assistant",onClick:()=>v("assistant"),children:"Assistant"})]}),k.jsxs("div",{ref:x,className:`reader-workspace${L?" is-desktop":" is-tabs"}${A?" is-assistant-collapsed":""}`,children:[k.jsxs("section",{className:`reader-paper-pane${!L&&w!=="paper"?" is-hidden":""}`,style:L?{width:A?"100%":`${f}%`}:void 0,role:"tabpanel","aria-label":"Paper","aria-hidden":!L&&w!=="paper",children:[k.jsxs("div",{className:"reader-paper-titlebar",children:[k.jsx(rr,{to:`/paper/${h}`,title:o.title,"aria-label":`${o.title} — open paper page`,children:o.title}),k.jsxs("span",{children:["arXiv:",h]})]}),k.jsx(qb,{url:l,paperKey:h,initialPage:_,onPageChange:M=>{P.current=M,sessionStorage.setItem(Ep(t),String(M))}})]}),L&&!A&&k.jsx("div",{className:"reader-resize-handle",role:"separator","aria-label":"Resize paper and Assistant panels","aria-orientation":"vertical","aria-valuemin":45,"aria-valuemax":75,"aria-valuenow":Math.round(f),tabIndex:0,onPointerDown:U,onPointerMove:M=>{T.current&&J(M.clientX)},onPointerUp:()=>{T.current=!1},onPointerCancel:()=>{T.current=!1},onDoubleClick:()=>F(ld),onKeyDown:M=>{(M.key==="ArrowLeft"||M.key==="ArrowRight")&&(M.preventDefault(),F(f+(M.key==="ArrowRight"?2:-2))),M.key==="Home"&&F(45),M.key==="End"&&F(75)},children:k.jsx("button",{type:"button",onClick:()=>F(ld),title:"Reset panel sizes","aria-label":"Reset panel sizes",children:"·"})}),k.jsx("aside",{className:`reader-assistant-pane${!L&&w!=="assistant"||A?" is-hidden":""}`,style:L?{width:A?0:`${100-f}%`}:void 0,role:"tabpanel","aria-label":"Assistant","aria-hidden":!L&&w!=="assistant"||A,children:$}),L&&k.jsx("button",{type:"button",className:"reader-collapse-assistant",onClick:()=>z(!A),children:A?"Assistant":"Hide Assistant"})]})]})}export{AA as default};