diff --git "a/assets/PaperReaderView-CV8RWIYF.js" "b/assets/PaperReaderView-CV8RWIYF.js" new file mode 100644--- /dev/null +++ "b/assets/PaperReaderView-CV8RWIYF.js" @@ -0,0 +1,12 @@ +var Lp=Object.defineProperty;var Rd=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),Oh=(c,t,e)=>t.has(c)||Rd("Cannot "+e);var r=(c,t,e)=>(Oh(c,t,"read from private field"),e?e.call(c):t.get(c)),A=(c,t,e)=>t.has(c)?Rd("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(c):t.set(c,e),p=(c,t,e,s)=>(Oh(c,t,"write to private field"),s?s.call(c,e):t.set(c,e),e),m=(c,t,e)=>(Oh(c,t,"access private method"),e);var fe=(c,t,e,s)=>({set _(i){p(c,t,i,e)},get _(){return r(c,t,s)}});import{_ as ml,N as Ip,r as R,j as I,O as _h,L as El,c as Fp,n as Dp,u as Op,Q as Np}from"./index-AN_2S3xs.js";import{u as Hp}from"./useQuery-Br60bgii.js";import{a as Bp}from"./usePapers-CIV2jhcY.js";import{c as jp}from"./chat-g8prW-nZ.js";import{s as $p}from"./safeExternalHref-CkBrsh84.js";import{ChatExperience as zp}from"./ChatView-fZGuCUMA.js";import"./useInfiniteQuery-CawwRwZW.js";import"./papers-J3e9spJb.js";import"./ChatMessage-DictsASi.js";import"./chatSessions-Dtp9P5F4.js";import"./chevron-down-CNsu6rIr.js";import"./katex.min-BSBacQyE.js";import"./hover-card-DXRGCxyi.js";import"./github-DZyjBqcs.js";import"./github-CGIlpP_9.js";import"./PaperPreviewLink-DUjTjcnx.js";import"./index-CIQ8Cpwh.js";import"./file-text-By_30ISB.js";import"./chatPrompts-CDY3UGU1.js";import"./openrouter-DgSRy04X.js";var Ga={};Ga.d=(c,t)=>{for(var e in t)Ga.o(t,e)&&!Ga.o(c,e)&&Object.defineProperty(c,e,{enumerable:!0,get:t[e]})};Ga.o=(c,t)=>Object.prototype.hasOwnProperty.call(c,t);var Q=globalThis.pdfjsLib={};Ga.d(Q,{AbortException:()=>or,AnnotationEditorLayer:()=>sd,AnnotationEditorParamsType:()=>K,AnnotationEditorType:()=>tt,AnnotationEditorUIManager:()=>er,AnnotationLayer:()=>jm,AnnotationMode:()=>pi,ColorPicker:()=>ih,DOMSVGFactory:()=>Ed,DrawLayer:()=>ad,FeatureTest:()=>be,GlobalWorkerOptions:()=>ai,ImageKind:()=>Sl,InvalidPDFException:()=>au,MissingPDFException:()=>ar,OPS:()=>Ke,OutputScale:()=>Yh,PDFDataRangeTransport:()=>sf,PDFDateString:()=>md,PDFWorker:()=>vr,PasswordResponses:()=>Vp,PermissionFlag:()=>Wp,PixelsPerInch:()=>zi,RenderingCancelledException:()=>pd,TextLayer:()=>Ec,UnexpectedResponseException:()=>Ch,Util:()=>$,VerbosityLevel:()=>Eh,XfaLayer:()=>rf,build:()=>vm,createValidAbsoluteUrl:()=>Kp,fetchData:()=>Rh,getDocument:()=>dm,getFilenameFromUrl:()=>rg,getPdfFilenameFromUrl:()=>ag,getXfaPageViewport:()=>og,isDataScheme:()=>Ph,isPdfFile:()=>gd,noContextMenu:()=>Xe,normalizeUnicode:()=>sg,setLayerDimensions:()=>tr,shadow:()=>lt,version:()=>ym});const ce=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),ru=[1,0,0,1,0,0],Wh=[.001,0,0,.001,0,0],Gp=1e7,Nh=1.35,Oe={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},pi={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Up="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},Wp={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},ie={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},Sl={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Bt={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},Sa={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Eh={ERRORS:0,WARNINGS:1,INFOS:5},Ke={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},Vp={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Sh=Eh.WARNINGS;function qp(c){Number.isInteger(c)&&(Sh=c)}function Xp(){return Sh}function xh(c){Sh>=Eh.INFOS&&console.log(`Info: ${c}`)}function st(c){Sh>=Eh.WARNINGS&&console.log(`Warning: ${c}`)}function _t(c){throw new Error(c)}function Gt(c,t){c||_t(t)}function Yp(c){switch(c==null?void 0:c.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Kp(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=eg(c)}catch{}}const s=t?new URL(c,t):new URL(c);if(Yp(s))return s}catch{}return null}function lt(c,t,e,s=!1){return Object.defineProperty(c,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Vi=function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();class Vh extends Vi{constructor(t,e){super(t,"PasswordException"),this.code=e}}class qh extends Vi{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class au extends Vi{constructor(t){super(t,"InvalidPDFException")}}class ar extends Vi{constructor(t){super(t,"MissingPDFException")}}class Ch extends Vi{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class Qp extends Vi{constructor(t){super(t,"FormatError")}}class or extends Vi{constructor(t){super(t,"AbortException")}}function ou(c){(typeof c!="object"||(c==null?void 0:c.length)===void 0)&&_t("Invalid argument for bytesToString");const t=c.length,e=8192;if(t>24&255,c>>16&255,c>>8&255,c&255)}function ud(c){const t=Object.create(null);for(const[e,s]of c)t[e]=s;return t}function Zp(){const c=new Uint8Array(4);return c[0]=1,new Uint32Array(c.buffer,0,1)[0]===1}function tg(){try{return new Function(""),!0}catch{return!1}}class be{static get isLittleEndian(){return lt(this,"isLittleEndian",Zp())}static get isEvalSupported(){return lt(this,"isEvalSupported",tg())}static get isOffscreenCanvasSupported(){return lt(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.platform)=="string"?lt(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")}):lt(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){var t,e;return lt(this,"isCSSRoundSupported",(e=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const Hh=Array.from(Array(256).keys(),c=>c.toString(16).padStart(2,"0"));var li,xl,Xh;class ${static makeHexColor(t,e,s){return`#${Hh[t]}${Hh[e]}${Hh[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,li,Xh).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,li,Xh).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}}li=new WeakSet,xl=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,b=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],b),d[1]=Math.min(d[1],y),d[2]=Math.max(d[2],b),d[3]=Math.max(d[3],y)},Xh=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,li,xl).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 b=Math.sqrt(g),y=2*h;m(this,li,xl).call(this,t,e,s,i,n,a,o,l,(-d+b)/y,f),m(this,li,xl).call(this,t,e,s,i,n,a,o,l,(-d-b)/y,f)},A($,li);function eg(c){return decodeURIComponent(escape(c))}let Bh=null,Pd=null;function sg(c){return Bh||(Bh=/([\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,Pd=new Map([["ſt","ſt"]])),c.replaceAll(Bh,(t,e,s)=>e?e.normalize("NFKC"):Pd.get(s))}function ig(){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 ou(c)}const fd="pdfjs_internal_id_",Ls={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 ng(c){return Uint8Array.prototype.toBase64?c.toBase64():btoa(ou(c))}const Is="http://www.w3.org/2000/svg",en=class en{};Y(en,"CSS",96),Y(en,"PDF",72),Y(en,"PDF_TO_CSS_UNITS",en.CSS/en.PDF);let zi=en;async function Rh(c,t="text"){if(Ta(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 hl{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,b,y,w;h===0?(g=Math.abs(l-t[1])*e+i,b=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,b=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,b-d*e*o-f*e*l],this.width=y,this.height=w}get rawDims(){const{viewBox:t}=this;return lt(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new hl({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){return $.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=$.applyTransform([t[0],t[1]],this.transform),s=$.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return $.applyInverseTransform([t,e],this.transform)}}class pd extends Vi{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Ph(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))}}qa=new WeakMap,A(md,qa);function og(c,{scale:t=1,rotation:e=0}){const{width:s,height:i}=c.attributes.style,n=[0,0,parseInt(s),parseInt(i)];return new hl({viewBox:n,scale:t,rotation:e})}function bd(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 lg(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,bd(s))}t.remove()}function Rt(c){const{a:t,b:e,c:s,d:i,e:n,f:a}=c.getTransform();return[t,e,s,i,n,a]}function Ms(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 tr(c,t,e=!1,s=!0){if(t instanceof hl){const{pageWidth:i,pageHeight:n}=t.rawDims,{style:a}=c,o=be.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 Yh{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 gi,nn,Qe,rn,Xa,Ya,rh,lu,Ae,hu,cu,Cl,du,Qh;const Fs=class Fs{constructor(t){A(this,Ae);A(this,gi,null);A(this,nn,null);A(this,Qe);A(this,rn,null);A(this,Xa,null);p(this,Qe,t),r(Fs,Ya)||p(Fs,Ya,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,gi,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=r(this,Qe)._uiManager._signal;t.addEventListener("contextmenu",Xe,{signal:e}),t.addEventListener("pointerdown",m(Fs,rh,lu),{signal:e});const s=p(this,rn,document.createElement("div"));s.className="buttons",t.append(s);const i=r(this,Qe).toolbarPosition;if(i){const{style:n}=t,a=r(this,Qe)._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,Ae,du).call(this),t}get div(){return r(this,gi)}hide(){var t;r(this,gi).classList.add("hidden"),(t=r(this,nn))==null||t.hideDropdown()}show(){var t;r(this,gi).classList.remove("hidden"),(t=r(this,Xa))==null||t.shown()}async addAltText(t){const e=await t.render();m(this,Ae,Cl).call(this,e),r(this,rn).prepend(e,r(this,Ae,Qh)),p(this,Xa,t)}addColorPicker(t){p(this,nn,t);const e=t.renderButton();m(this,Ae,Cl).call(this,e),r(this,rn).prepend(e,r(this,Ae,Qh))}remove(){var t;r(this,gi).remove(),(t=r(this,nn))==null||t.destroy(),p(this,nn,null)}};gi=new WeakMap,nn=new WeakMap,Qe=new WeakMap,rn=new WeakMap,Xa=new WeakMap,Ya=new WeakMap,rh=new WeakSet,lu=function(t){t.stopPropagation()},Ae=new WeakSet,hu=function(t){r(this,Qe)._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()},cu=function(t){r(this,Qe)._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()},Cl=function(t){const e=r(this,Qe)._uiManager._signal;t.addEventListener("focusin",m(this,Ae,hu).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",m(this,Ae,cu).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Xe,{signal:e})},du=function(){const{editorType:t,_uiManager:e}=r(this,Qe),s=document.createElement("button");s.className="delete",s.tabIndex=0,s.setAttribute("data-l10n-id",r(Fs,Ya)[t]),m(this,Ae,Cl).call(this,s),s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),r(this,rn).append(s)},Qh=function(){const t=document.createElement("div");return t.className="divider",t},A(Fs,rh),A(Fs,Ya,null);let Kh=Fs;var Ka,an,on,Ui,uu,fu,pu;class hg{constructor(t){A(this,Ui);A(this,Ka,null);A(this,an,null);A(this,on);p(this,on,t)}show(t,e,s){const[i,n]=m(this,Ui,fu).call(this,e,s),{style:a}=r(this,an)||p(this,an,m(this,Ui,uu).call(this));t.append(r(this,an)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){r(this,an).remove()}}Ka=new WeakMap,an=new WeakMap,on=new WeakMap,Ui=new WeakSet,uu=function(){const t=p(this,an,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",Xe,{signal:r(this,on)._signal});const e=p(this,Ka,document.createElement("div"));return e.className="buttons",t.append(e),m(this,Ui,pu).call(this),t},fu=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,on).highlightSelection("floating_button")},{signal:s}),r(this,Ka).append(t)};function th(c,t,e){for(const s of e)t.addEventListener(s,c[s].bind(c))}function cg(c){return Math.round(Math.min(255,Math.max(1,255*c))).toString(16).padStart(2,"0")}var ah;class dg{constructor(){A(this,ah,0)}get id(){return`${Up}${fe(this,ah)._++}`}}ah=new WeakMap;var Er,Qa,re,Sr,Tl;const xd=class xd{constructor(){A(this,Sr);A(this,Er,ig());A(this,Qa,0);A(this,re,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 lt(this,"_isSVGFittingCanvas",n)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return m(this,Sr,Tl).call(this,`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return m(this,Sr,Tl).call(this,t,t)}async getFromBlob(t,e){const s=await e;return m(this,Sr,Tl).call(this,t,s)}async getFromId(t){r(this,re)||p(this,re,new Map);const e=r(this,re).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,re)||p(this,re,new Map);let s=r(this,re).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,Er)}_${fe(this,Qa)._++}`,refCounter:1,isSvg:!1},r(this,re).set(t,s),r(this,re).set(s.id,s),s}getSvgUrl(t){const e=r(this,re).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;r(this,re)||p(this,re,new Map);const e=r(this,re).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,Er)}_`)}};Er=new WeakMap,Qa=new WeakMap,re=new WeakMap,Sr=new WeakSet,Tl=async function(t,e){r(this,re)||p(this,re,new Map);let s=r(this,re).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,Er)}_${fe(this,Qa)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await Rh(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const n=xd._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,re).set(t,s),s&&r(this,re).set(s.id,s),s};let Jh=xd;var Vt,mi,Ja,qt;class ug{constructor(t=128){A(this,Vt,[]);A(this,mi,!1);A(this,Ja);A(this,qt,-1);p(this,Ja,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&t(),r(this,mi))return;const l={cmd:t,undo:e,post:s,type:n};if(r(this,qt)===-1){r(this,Vt).length>0&&(r(this,Vt).length=0),p(this,qt,0),r(this,Vt).push(l);return}if(a&&r(this,Vt)[r(this,qt)].type===n){o&&(l.undo=r(this,Vt)[r(this,qt)].undo),r(this,Vt)[r(this,qt)]=l;return}const h=r(this,qt)+1;h===r(this,Ja)?r(this,Vt).splice(0,1):(p(this,qt,h),hn===e[a]))return lh._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?$.makeHexColor(...e):t}};Y(lh,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let Zh=lh;var xr,Re,jt,Jt,Cr,Os,Tr,Je,bi,Rr,ln,us,Ze,hn,Za,to,Pr,eo,fs,Ai,kr,yi,ps,hh,vi,so,wi,cn,io,no,Xt,ft,Ns,dn,ro,ao,_i,gs,Hs,oo,je,D,Rl,tc,mu,bu,Pl,Au,yu,vu,ec,wu,sc,ic,_u,pe,ui,Eu,Su,nc,xu,Ra,rc;const Ar=class Ar{constructor(t,e,s,i,n,a,o,l,h,d,u){A(this,D);A(this,xr,new AbortController);A(this,Re,null);A(this,jt,new Map);A(this,Jt,new Map);A(this,Cr,null);A(this,Os,null);A(this,Tr,null);A(this,Je,new ug);A(this,bi,null);A(this,Rr,0);A(this,ln,new Set);A(this,us,null);A(this,Ze,null);A(this,hn,new Set);A(this,Za,!1);A(this,to,!1);A(this,Pr,!1);A(this,eo,null);A(this,fs,null);A(this,Ai,null);A(this,kr,null);A(this,yi,!1);A(this,ps,null);A(this,hh,new dg);A(this,vi,!1);A(this,so,!1);A(this,wi,null);A(this,cn,null);A(this,io,null);A(this,no,null);A(this,Xt,tt.NONE);A(this,ft,new Set);A(this,Ns,null);A(this,dn,null);A(this,ro,null);A(this,ao,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});A(this,_i,[0,0]);A(this,gs,null);A(this,Hs,null);A(this,oo,null);A(this,je,null);const f=this._signal=r(this,xr).signal;p(this,Hs,t),p(this,oo,e),p(this,Cr,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,Au).call(this),m(this,D,_u).call(this),m(this,D,ec).call(this),p(this,Os,n.annotationStorage),p(this,eo,n.filterFactory),p(this,dn,a),p(this,kr,o||null),p(this,Za,l),p(this,to,h),p(this,Pr,d),p(this,no,u||null),this.viewParameters={realScale:zi.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}static get _keyboardManager(){const t=Ar.prototype,e=a=>r(a,Hs).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 lt(this,"_keyboardManager",new cl([[["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,Hs).contains(o)&&!a.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&r(a,Hs).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,je))==null||t.resolve(),p(this,je,null),(e=r(this,xr))==null||e.abort(),p(this,xr,null),this._signal=null;for(const n of r(this,Jt).values())n.destroy();r(this,Jt).clear(),r(this,jt).clear(),r(this,hn).clear(),p(this,Re,null),r(this,ft).clear(),r(this,Je).destroy(),(s=r(this,Cr))==null||s.destroy(),(i=r(this,ps))==null||i.hide(),p(this,ps,null),r(this,fs)&&(clearTimeout(r(this,fs)),p(this,fs,null)),r(this,gs)&&(clearTimeout(r(this,gs)),p(this,gs,null))}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return r(this,no)}get useNewAltTextFlow(){return r(this,to)}get useNewAltTextWhenAddingImage(){return r(this,Pr)}get hcmFilter(){return lt(this,"hcmFilter",r(this,dn)?r(this,eo).addHCMFilter(r(this,dn).foreground,r(this,dn).background):"none")}get direction(){return lt(this,"direction",getComputedStyle(r(this,Hs)).direction)}get highlightColors(){return lt(this,"highlightColors",r(this,kr)?new Map(r(this,kr).split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return lt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setMainHighlightColorPicker(t){p(this,io,t)}editAltText(t,e=!1){var s;(s=r(this,Cr))==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,Pr,e);break}}onPageChanging({pageNumber:t}){p(this,Rr,t-1)}focusMainContainer(){r(this,Hs).focus()}findParent(t,e){for(const s of r(this,Jt).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,oo).classList.toggle("noUserSelect",t)}addShouldRescale(t){r(this,hn).add(t)}removeShouldRescale(t){r(this,hn).delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*zi.PDF_TO_CSS_UNITS;for(const e of r(this,hn))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,Rl).call(this,e).closest(".textLayer"),d=this.getSelectionBoxes(h);if(!d)return;e.empty();const u=m(this,D,tc).call(this,h),f=r(this,Xt)===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,Os)&&!r(this,Os).has(t.id)&&r(this,Os).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,r(this,yi)&&(p(this,yi,!1),m(this,D,Pl).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of r(this,ft))if(e.div.contains(t)){p(this,cn,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!r(this,cn))return;const[t,e]=r(this,cn);p(this,cn,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){m(this,D,ec).call(this),m(this,D,sc).call(this)}removeEditListeners(){m(this,D,wu).call(this),m(this,D,ic).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of r(this,Ze))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,Ze))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=r(this,Re))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of r(this,ft)){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,Ze))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,nc).call(this,l);m(this,D,rc).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,Xt)!==tt.NONE&&!this.isEditorHandlingKeyboard&&Ar._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,r(this,yi)&&(p(this,yi,!1),m(this,D,Pl).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,yu).call(this),m(this,D,sc).call(this),m(this,D,pe).call(this,{isEditing:r(this,Xt)!==tt.NONE,isEmpty:m(this,D,Ra).call(this),hasSomethingToUndo:r(this,Je).hasSomethingToUndo(),hasSomethingToRedo:r(this,Je).hasSomethingToRedo(),hasSelectedEditor:!1})):(m(this,D,vu).call(this),m(this,D,ic).call(this),m(this,D,pe).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!r(this,Ze)){p(this,Ze,t);for(const e of r(this,Ze))m(this,D,ui).call(this,e.defaultPropertiesToUpdate)}}getId(){return r(this,hh).id}get currentLayer(){return r(this,Jt).get(r(this,Rr))}getLayer(t){return r(this,Jt).get(t)}get currentPageIndex(){return r(this,Rr)}addLayer(t){r(this,Jt).set(t.pageIndex,t),r(this,vi)?t.enable():t.disable()}removeLayer(t){r(this,Jt).delete(t.pageIndex)}async updateMode(t,e=null,s=!1){if(r(this,Xt)!==t&&!(r(this,je)&&(await r(this,je).promise,!r(this,je)))){if(p(this,je,Promise.withResolvers()),p(this,Xt,t),t===tt.NONE){this.setEditingState(!1),m(this,D,Su).call(this),r(this,je).resolve();return}this.setEditingState(!0),await m(this,D,Eu).call(this),this.unselectAll();for(const i of r(this,Jt).values())i.updateMode(t);if(!e){s&&this.addNewEditorFromKeyboard(),r(this,je).resolve();return}for(const i of r(this,jt).values())i.annotationElementId===e?(this.setSelected(i),i.enterInEditMode()):i.unselect();r(this,je).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==r(this,Xt)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){var s;if(r(this,Ze)){switch(t){case K.CREATE:this.currentLayer.addNewEditor();return;case K.HIGHLIGHT_DEFAULT_COLOR:(s=r(this,io))==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,ro)||p(this,ro,new Map)).set(t,e),this.showAllEditors("highlight",e);break}for(const i of r(this,ft))i.updateParams(t,e);for(const i of r(this,Ze))i.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var n;for(const a of r(this,jt).values())a.editorType===t&&a.show(e);(((n=r(this,ro))==null?void 0:n.get(K.HIGHLIGHT_SHOW_ALL))??!0)!==e&&m(this,D,ui).call(this,[[K.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(r(this,so)!==t){p(this,so,t);for(const e of r(this,Jt).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const s of r(this,jt).values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return r(this,jt).get(t)}addEditor(t){r(this,jt).set(t.id,t)}removeEditor(t){var e;t.div.contains(document.activeElement)&&(r(this,fs)&&clearTimeout(r(this,fs)),p(this,fs,setTimeout(()=>{this.focusMainContainer(),p(this,fs,null)},0))),r(this,jt).delete(t.id),this.unselect(t),(!t.annotationElementId||!r(this,ln).has(t.annotationElementId))&&((e=r(this,Os))==null||e.remove(t.id))}addDeletedAnnotationElement(t){r(this,ln).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return r(this,ln).has(t)}removeDeletedAnnotationElement(t){r(this,ln).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){r(this,Re)!==t&&(p(this,Re,t),t&&m(this,D,ui).call(this,t.propertiesToUpdate))}updateUI(t){r(this,D,xu)===t&&m(this,D,ui).call(this,t.propertiesToUpdate)}toggleSelected(t){if(r(this,ft).has(t)){r(this,ft).delete(t),t.unselect(),m(this,D,pe).call(this,{hasSelectedEditor:this.hasSelection});return}r(this,ft).add(t),t.select(),m(this,D,ui).call(this,t.propertiesToUpdate),m(this,D,pe).call(this,{hasSelectedEditor:!0})}setSelected(t){for(const e of r(this,ft))e!==t&&e.unselect();r(this,ft).clear(),r(this,ft).add(t),t.select(),m(this,D,ui).call(this,t.propertiesToUpdate),m(this,D,pe).call(this,{hasSelectedEditor:!0})}isSelected(t){return r(this,ft).has(t)}get firstSelectedEditor(){return r(this,ft).values().next().value}unselect(t){t.unselect(),r(this,ft).delete(t),m(this,D,pe).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return r(this,ft).size!==0}get isEnterHandled(){return r(this,ft).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){r(this,Je).undo(),m(this,D,pe).call(this,{hasSomethingToUndo:r(this,Je).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:m(this,D,Ra).call(this)})}redo(){r(this,Je).redo(),m(this,D,pe).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:r(this,Je).hasSomethingToRedo(),isEmpty:m(this,D,Ra).call(this)})}addCommands(t){r(this,Je).add(t),m(this,D,pe).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:m(this,D,Ra).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...r(this,ft)],e=()=>{for(const i of t)i.remove()},s=()=>{for(const i of t)m(this,D,nc).call(this,i)};this.addCommands({cmd:e,undo:s,mustExec:!0})}commitOrRemove(){var t;(t=r(this,Re))==null||t.commitOrRemove()}hasSomethingToControl(){return r(this,Re)||this.hasSelection}selectAll(){for(const t of r(this,ft))t.commit();m(this,D,rc).call(this,r(this,jt).values())}unselectAll(){if(!(r(this,Re)&&(r(this,Re).commitOrRemove(),r(this,Xt)!==tt.NONE))&&this.hasSelection){for(const t of r(this,ft))t.unselect();r(this,ft).clear(),m(this,D,pe).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;r(this,_i)[0]+=t,r(this,_i)[1]+=e;const[i,n]=r(this,_i),a=[...r(this,ft)],o=1e3;r(this,gs)&&clearTimeout(r(this,gs)),p(this,gs,setTimeout(()=>{p(this,gs,null),r(this,_i)[0]=r(this,_i)[1]=0,this.addCommands({cmd:()=>{for(const l of a)r(this,jt).has(l.id)&&l.translateInPage(i,n)},undo:()=>{for(const l of a)r(this,jt).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,us,new Map);for(const t of r(this,ft))r(this,us).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!r(this,us))return!1;this.disableUserSelect(!1);const t=r(this,us);p(this,us,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,jt).has(i.id)){const l=r(this,Jt).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,us))for(const s of r(this,us).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,ft).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return r(this,Re)===t}getActive(){return r(this,Re)}getMode(){return r(this,Xt)}get imageManager(){return lt(this,"imageManager",new Jh)}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,Pl).call(this,"main_toolbar"))};window.addEventListener("pointerup",u,{signal:d}),window.addEventListener("blur",u,{signal:d})}},Pl=function(t=""){r(this,Xt)===tt.HIGHLIGHT?this.highlightSelection(t):r(this,Za)&&m(this,D,mu).call(this)},Au=function(){document.addEventListener("selectionchange",m(this,D,bu).bind(this),{signal:this._signal})},yu=function(){if(r(this,Ai))return;p(this,Ai,new AbortController);const t=this.combinedSignal(r(this,Ai));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},vu=function(){var t;(t=r(this,Ai))==null||t.abort(),p(this,Ai,null)},ec=function(){if(r(this,wi))return;p(this,wi,new AbortController);const t=this.combinedSignal(r(this,wi));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},wu=function(){var t;(t=r(this,wi))==null||t.abort(),p(this,wi,null)},sc=function(){if(r(this,bi))return;p(this,bi,new AbortController);const t=this.combinedSignal(r(this,bi));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})},ic=function(){var t;(t=r(this,bi))==null||t.abort(),p(this,bi,null)},_u=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},pe=function(t){Object.entries(t).some(([s,i])=>r(this,ao)[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(r(this,ao),t)}),r(this,Xt)===tt.HIGHLIGHT&&t.hasSelectedEditor===!1&&m(this,D,ui).call(this,[[K.HIGHLIGHT_FREE,!0]]))},ui=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},Eu=async function(){if(!r(this,vi)){p(this,vi,!0);const t=[];for(const e of r(this,Jt).values())t.push(e.enable());await Promise.all(t);for(const e of r(this,jt).values())e.enable()}},Su=function(){if(this.unselectAll(),r(this,vi)){p(this,vi,!1);for(const t of r(this,Jt).values())t.disable();for(const t of r(this,jt).values())t.disable()}},nc=function(t){const e=r(this,Jt).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},xu=function(){let t=null;for(t of r(this,ft));return t},Ra=function(){if(r(this,jt).size===0)return!0;if(r(this,jt).size===1)for(const t of r(this,jt).values())return t.isEmpty();return!1},rc=function(t){for(const e of r(this,ft))e.unselect();r(this,ft).clear();for(const e of t)e.isEmpty()||(r(this,ft).add(e),e.select());m(this,D,pe).call(this,{hasSelectedEditor:this.hasSelection})},Y(Ar,"TRANSLATE_SMALL",1),Y(Ar,"TRANSLATE_BIG",10);let er=Ar;var Yt,ms,ts,Lr,bs,Pe,Mr,As,_e,Bs,un,ys,Ei,cs,Pa,kl;const ge=class ge{constructor(t){A(this,cs);A(this,Yt,null);A(this,ms,!1);A(this,ts,null);A(this,Lr,null);A(this,bs,null);A(this,Pe,null);A(this,Mr,!1);A(this,As,null);A(this,_e,null);A(this,Bs,null);A(this,un,null);A(this,ys,!1);p(this,_e,t),p(this,ys,t._uiManager.useNewAltTextFlow),r(ge,Ei)||p(ge,Ei,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){ge._l10n??(ge._l10n=t)}async render(){const t=p(this,ts,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=p(this,Lr,document.createElement("span"));t.append(e),r(this,ys)?(t.classList.add("new"),t.setAttribute("data-l10n-id",r(ge,Ei).missing),e.setAttribute("data-l10n-id",r(ge,Ei)["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,_e)._uiManager._signal;t.addEventListener("contextmenu",Xe,{signal:s}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),r(this,_e)._uiManager.editAltText(r(this,_e)),r(this,ys)&&r(this,_e)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:r(this,cs,Pa)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(p(this,Mr,!0),i(n))},{signal:s}),await m(this,cs,kl).call(this),t}finish(){r(this,ts)&&(r(this,ts).focus({focusVisible:r(this,Mr)}),p(this,Mr,!1))}isEmpty(){return r(this,ys)?r(this,Yt)===null:!r(this,Yt)&&!r(this,ms)}hasData(){return r(this,ys)?r(this,Yt)!==null||!!r(this,Bs):this.isEmpty()}get guessedText(){return r(this,Bs)}async setGuessedText(t){r(this,Yt)===null&&(p(this,Bs,t),p(this,un,await ge._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),m(this,cs,kl).call(this))}toggleAltTextBadge(t=!1){var e;if(!r(this,ys)||r(this,Yt)){(e=r(this,As))==null||e.remove(),p(this,As,null);return}if(!r(this,As)){const s=p(this,As,document.createElement("div"));s.className="noAltTextBadge",r(this,_e).div.append(s)}r(this,As).classList.toggle("hidden",!t)}serialize(t){let e=r(this,Yt);return!t&&r(this,Bs)===e&&(e=r(this,un)),{altText:e,decorative:r(this,ms),guessedText:r(this,Bs),textWithDisclaimer:r(this,un)}}get data(){return{altText:r(this,Yt),decorative:r(this,ms)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:n=!1}){s&&(p(this,Bs,s),p(this,un,i)),!(r(this,Yt)===t&&r(this,ms)===e)&&(n||(p(this,Yt,t),p(this,ms,e)),m(this,cs,kl).call(this))}toggle(t=!1){r(this,ts)&&(!t&&r(this,Pe)&&(clearTimeout(r(this,Pe)),p(this,Pe,null)),r(this,ts).disabled=!t)}shown(){r(this,_e)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:r(this,cs,Pa)}})}destroy(){var t,e;(t=r(this,ts))==null||t.remove(),p(this,ts,null),p(this,Lr,null),p(this,bs,null),(e=r(this,As))==null||e.remove(),p(this,As,null)}};Yt=new WeakMap,ms=new WeakMap,ts=new WeakMap,Lr=new WeakMap,bs=new WeakMap,Pe=new WeakMap,Mr=new WeakMap,As=new WeakMap,_e=new WeakMap,Bs=new WeakMap,un=new WeakMap,ys=new WeakMap,Ei=new WeakMap,cs=new WeakSet,Pa=function(){return r(this,Yt)&&"added"||r(this,Yt)===null&&this.guessedText&&"review"||"missing"},kl=async function(){var i,n,a;const t=r(this,ts);if(!t)return;if(r(this,ys)){if(t.classList.toggle("done",!!r(this,Yt)),t.setAttribute("data-l10n-id",r(ge,Ei)[r(this,cs,Pa)]),(i=r(this,Lr))==null||i.setAttribute("data-l10n-id",r(ge,Ei)[`${r(this,cs,Pa)}-label`]),!r(this,Yt)){(n=r(this,bs))==null||n.remove();return}}else{if(!r(this,Yt)&&!r(this,ms)){t.classList.remove("done"),(a=r(this,bs))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=r(this,bs);if(!e){p(this,bs,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${r(this,_e).id}`;const o=100,l=r(this,_e)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(r(this,Pe)),p(this,Pe,null)},{once:!0}),t.addEventListener("mouseenter",()=>{p(this,Pe,setTimeout(()=>{p(this,Pe,null),r(this,bs).classList.add("show"),r(this,_e)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var h;r(this,Pe)&&(clearTimeout(r(this,Pe)),p(this,Pe,null)),(h=r(this,bs))==null||h.classList.remove("show")},{signal:l})}r(this,ms)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=r(this,Yt)),e.parentNode||t.append(e);const s=r(this,_e).getImageForAltText();s==null||s.setAttribute("aria-describedby",e.id)},A(ge,Ei,null),Y(ge,"_l10n",null);let eh=ge;var fn,es,Ct,Ir,pn,Zt,gn,Si,lo,mn,xi,ho,bn,js,vs,Fr,Dr,$e,co,ch,et,ac,uo,oc,lc,Cu,Tu,hc,cc,dc,Ru,uc,Pu,ku,Lu,fc,ka;const ut=class ut{constructor(t){A(this,et);A(this,fn,null);A(this,es,null);A(this,Ct,null);A(this,Ir,!1);A(this,pn,!1);A(this,Zt,null);A(this,gn,null);A(this,Si,null);A(this,lo,"");A(this,mn,!1);A(this,xi,null);A(this,ho,!1);A(this,bn,!1);A(this,js,!1);A(this,vs,null);A(this,Fr,0);A(this,Dr,0);A(this,$e,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);A(this,co,!1);A(this,ch,ut._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=ut.prototype._resizeWithKeyboard,e=er.TRANSLATE_SMALL,s=er.TRANSLATE_BIG;return lt(this,"_resizerKeyboardManager",new cl([[["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"],ut.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return lt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new fg({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(ut._l10n??(ut._l10n=t),ut._l10nResizer||(ut._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"})),ut._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);ut._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){_t("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return r(this,co)}set _isDraggable(t){var e;p(this,co,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,ch)}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):m(this,et,ka).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(r(this,mn)?p(this,mn,!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,ac).call(this,this.parentDimensions,t,e)}translateInPage(t,e){r(this,xi)||p(this,xi,[this.x,this.y]),m(this,et,ac).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){r(this,xi)||p(this,xi,[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,xi)&&(r(this,xi)[0]!==this.x||r(this,xi)[1]!==this.y)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=ut,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=ut,uo,oc).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return m(s=ut,uo,oc).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,pn)||(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,pn)&&e.endsWith("%");if(i&&n)return;const[a,o]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/a).toFixed(2)}%`),!r(this,pn)&&!n&&(t.height=`${(100*parseFloat(e)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}altTextFinish(){var t;(t=r(this,Ct))==null||t.finish()}async addEditToolbar(){return this._editToolbar||r(this,bn)?this._editToolbar:(this._editToolbar=new Kh(this),this.div.append(this._editToolbar.render()),r(this,Ct)&&await this._editToolbar.addAltText(r(this,Ct)),this._editToolbar)}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,(t=r(this,Ct))==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,Ct)||(eh.initialize(ut._l10n),p(this,Ct,new eh(this)),r(this,fn)&&(r(this,Ct).data=r(this,fn),p(this,fn,null)),await this.addEditToolbar())}get altTextData(){var t;return(t=r(this,Ct))==null?void 0:t.data}set altTextData(t){r(this,Ct)&&(r(this,Ct).data=t)}get guessedAltText(){var t;return(t=r(this,Ct))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=r(this,Ct))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=r(this,Ct))==null?void 0:e.serialize(t)}hasAltText(){return!!r(this,Ct)&&!r(this,Ct).isEmpty()}hasAltTextData(){var t;return((t=r(this,Ct))==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,Ir)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),m(this,et,uc).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),th(this,this.div,["pointerdown"]),this.div}pointerdown(t){const{isMac:e}=be.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(p(this,mn,!0),this._isDraggable){m(this,et,Ru).call(this,t);return}m(this,et,dc).call(this,t)}get isSelected(){return this._uiManager.isSelected(this)}moveInDOM(){r(this,vs)&&clearTimeout(r(this,vs)),p(this,vs,setTimeout(()=>{var t;p(this,vs,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,b=this.height*a;switch(s){case 0:return[u+h+o,a-f-d-b+l,u+h+g+o,a-f-d+l];case 90:return[u+d+o,a-f+h+l,u+d+b+o,a-f+h+g+l];case 180:return[u-h-g+o,a-f+d+l,u-h+o,a-f+d+b+l];case 270:return[u-d-b+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,bn,!0)}disableEditMode(){p(this,bn,!1)}isInEditMode(){return r(this,bn)}shouldGetKeyboardEvents(){return r(this,js)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){m(this,et,uc).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){_t("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,fn,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,Si))==null||t.abort(),p(this,Si,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),r(this,vs)&&(clearTimeout(r(this,vs)),p(this,vs,null)),m(this,et,ka).call(this),this.removeEditToolbar(),r(this,$e)){for(const e of r(this,$e).values())clearTimeout(e);p(this,$e,null)}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(m(this,et,Cu).call(this),r(this,Zt).classList.remove("hidden"),th(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,gn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=r(this,Zt).children;if(!r(this,es)){p(this,es,Array.from(e));const a=m(this,et,Pu).bind(this),o=m(this,et,ku).bind(this),l=this._uiManager._signal;for(const h of r(this,es)){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,Lu).bind(this,d),{signal:l}),h.setAttribute("data-l10n-id",ut._l10nResizer[d])}}const s=r(this,es)[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,es).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,Ct))==null||s.toggleAltTextBadge(!1)}unselect(){var t,e,s,i,n;(t=r(this,Zt))==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,Ct))==null||n.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return r(this,ho)}set isEditing(t){p(this,ho,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){p(this,pn,!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,$e)||p(this,$e,new Map);const{action:s}=t;let i=r(this,$e).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),r(this,$e).delete(s),r(this,$e).size===0&&p(this,$e,null)},ut._telemetryTimeout),r(this,$e).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,Ir,!1)}disable(){this.div&&(this.div.tabIndex=-1),p(this,Ir,!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()}};fn=new WeakMap,es=new WeakMap,Ct=new WeakMap,Ir=new WeakMap,pn=new WeakMap,Zt=new WeakMap,gn=new WeakMap,Si=new WeakMap,lo=new WeakMap,mn=new WeakMap,xi=new WeakMap,ho=new WeakMap,bn=new WeakMap,js=new WeakMap,vs=new WeakMap,Fr=new WeakMap,Dr=new WeakMap,$e=new WeakMap,co=new WeakMap,ch=new WeakMap,et=new WeakSet,ac=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this.fixAndSetPosition()},uo=new WeakSet,oc=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]}},lc=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]}},Cu=function(){if(r(this,Zt))return;p(this,Zt,document.createElement("div")),r(this,Zt).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,Zt).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",m(this,et,Tu).bind(this,s),{signal:e}),i.addEventListener("contextmenu",Xe,{signal:e}),i.tabIndex=-1}this.div.prepend(r(this,Zt))},Tu=function(t,e){var b;e.preventDefault();const{isMac:s}=be.platform;if(e.button!==0||e.ctrlKey&&s)return;(b=r(this,Ct))==null||b.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,cc).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("contextmenu",Xe,{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,Ct))==null||y.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=u,this.div.style.cursor=f,m(this,et,hc).call(this,o,l,h,d)};window.addEventListener("pointerup",g,{signal:a}),window.addEventListener("blur",g,{signal:a})},hc=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})},cc=function(t,e){const[s,i]=this.parentDimensions,n=this.x,a=this.y,o=this.width,l=this.height,h=ut.MIN_SIZE/s,d=ut.MIN_SIZE/i,u=H=>Math.round(H*1e4)/1e4,f=m(this,et,lc).call(this,this.rotation),g=(H,z)=>[f[0]*H+f[2]*z,f[1]*H+f[3]*z],b=m(this,et,lc).call(this,360-this.rotation),y=(H,z)=>[b[0]*H+b[2]*z,b[1]*H+b[3]*z];let w,v,_=!1,S=!1;switch(t){case"topLeft":_=!0,w=(H,z)=>[0,0],v=(H,z)=>[H,z];break;case"topMiddle":w=(H,z)=>[H/2,0],v=(H,z)=>[H/2,z];break;case"topRight":_=!0,w=(H,z)=>[H,0],v=(H,z)=>[0,z];break;case"middleRight":S=!0,w=(H,z)=>[H,z/2],v=(H,z)=>[0,z/2];break;case"bottomRight":_=!0,w=(H,z)=>[H,z],v=(H,z)=>[0,0];break;case"bottomMiddle":w=(H,z)=>[H/2,z],v=(H,z)=>[H/2,0];break;case"bottomLeft":_=!0,w=(H,z)=>[0,z],v=(H,z)=>[H,0];break;case"middleLeft":S=!0,w=(H,z)=>[0,z/2],v=(H,z)=>[H,z/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 k=1,B=1,[O,X]=this.screenToPageTranslation(e.movementX,e.movementY);if([O,X]=y(O/s,X/i),_){const H=Math.hypot(o,l);k=B=Math.max(Math.min(Math.hypot(C[0]-E[0]-O,C[1]-E[1]-X)/H,1/o,1/l),h/o,d/l)}else S?k=Math.max(h,Math.min(1,Math.abs(C[0]-E[0]-O)))/o:B=Math.max(d,Math.min(1,Math.abs(C[1]-E[1]-X)))/l;const W=u(o*k),G=u(l*B);x=g(...v(W,G));const V=T-x[0],q=P-x[1];this.width=W,this.height=G,this.x=V,this.y=q,this.setDims(s*W,i*G),this.fixAndSetPosition()},dc=function(t){const{isMac:e}=be.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Ru=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,Fr,t.clientX),p(this,Dr,t.clientY);const a=o=>{const{clientX:l,clientY:h}=o,[d,u]=this.screenToPageTranslation(l-r(this,Fr),h-r(this,Dr));p(this,Fr,l),p(this,Dr,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,mn,!1),this._uiManager.endDragSession()||m(this,et,dc).call(this,t)};window.addEventListener("pointerup",n,{signal:i}),window.addEventListener("blur",n,{signal:i})},uc=function(){if(r(this,Si)||!this.div)return;p(this,Si,new AbortController);const t=this._uiManager.combinedSignal(r(this,Si));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Pu=function(t){ut._resizerKeyboardManager.exec(this,t)},ku=function(t){var e;r(this,js)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==r(this,Zt)&&m(this,et,ka).call(this)},Lu=function(t){p(this,lo,r(this,js)?t:"")},fc=function(t){if(r(this,es))for(const e of r(this,es))e.tabIndex=t},ka=function(){if(p(this,js,!1),m(this,et,fc).call(this,-1),r(this,gn)){const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=r(this,gn);m(this,et,hc).call(this,t,e,s,i),p(this,gn,null)}},A(ut,uo),Y(ut,"_l10n",null),Y(ut,"_l10nResizer",null),Y(ut,"_borderLineWidth",-1),Y(ut,"_colorManager",new Zh),Y(ut,"_zIndex",1),Y(ut,"_telemetryTimeout",1e3);let gt=ut;class fg extends gt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Md=3285377520,Be=4294901760,ds=65535;class Mu{constructor(t){this.h1=t?t&4294967295:Md,this.h2=t?t&4294967295:Md}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&ds,b=f&ds;for(let y=0;y>>17,o=o*f&Be|o*b&ds,h^=o,h=h<<13|h>>>19,h=h*5+3864292196):(l=a[y],l=l*u&Be|l*g&ds,l=l<<15|l>>>17,l=l*f&Be|l*b&ds,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&Be|o*g&ds,o=o<<15|o>>>17,o=o*f&Be|o*b&ds,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&Be|t*36045&ds,e=e*4283543511&Be|((e<<16|t>>>16)*2950163797&Be)>>>16,t^=e>>>1,t=t*444984403&Be|t*60499&ds,e=e*3301882366&Be|((e<<16|t>>>16)*3120437893&Be)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const pc=Object.freeze({map:null,hash:"",transfer:void 0});var An,yn,Kt,dh,Iu;class Ad{constructor(){A(this,dh);A(this,An,!1);A(this,yn,null);A(this,Kt,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=r(this,Kt).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return r(this,Kt).get(t)}remove(t){if(r(this,Kt).delete(t),r(this,Kt).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of r(this,Kt).values())if(e instanceof gt)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=r(this,Kt).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,Kt).set(t,e);i&&m(this,dh,Iu).call(this),e instanceof gt&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return r(this,Kt).has(t)}getAll(){return r(this,Kt).size>0?ud(r(this,Kt)):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return r(this,Kt).size}resetModified(){r(this,An)&&(p(this,An,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Fu(this)}get serializable(){if(r(this,Kt).size===0)return pc;const t=new Map,e=new Mu,s=[],i=Object.create(null);let n=!1;for(const[a,o]of r(this,Kt)){const l=o instanceof gt?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}:pc}get editorStats(){let t=null;const e=new Map;for(const s of r(this,Kt).values()){if(!(s instanceof gt))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,yn,null)}get modifiedIds(){if(r(this,yn))return r(this,yn);const t=[];for(const e of r(this,Kt).values())!(e instanceof gt)||!e.annotationElementId||!e.serialize()||t.push(e.annotationElementId);return p(this,yn,{ids:new Set(t),hash:t.join(",")})}}An=new WeakMap,yn=new WeakMap,Kt=new WeakMap,dh=new WeakSet,Iu=function(){r(this,An)||(p(this,An,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var fo;class Fu extends Ad{constructor(e){super();A(this,fo);const{map:s,hash:i,transfer:n}=e.serializable,a=structuredClone(s,n?{transfer:n}:null);p(this,fo,{map:a,hash:i,transfer:n})}get print(){_t("Should not call PrintAnnotationStorage.print")}get serializable(){return r(this,fo)}get modifiedIds(){return lt(this,"modifiedIds",{ids:new Set,hash:""})}}fo=new WeakMap;var Or;class pg{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){A(this,Or,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,Or).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||r(this,Or).has(t.loadedName))){if(Gt(!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,Or).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}_t("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 lt(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(ce||typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.userAgent)=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),lt(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(Gt(!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 lt(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),k=E.substring(C+x);return P+T+k}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 b=16,y=1482184792;let w=s(f,b);for(n=0,a=u.length-3;n{S.remove(),e.complete()})}}Or=new WeakMap;class gg{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,${ng(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 Ls.MOVE_TO:{const[o,l]=s.slice(n,n+2);i.push(h=>h.moveTo(o,l)),n+=2}break;case Ls.LINE_TO:{const[o,l]=s.slice(n,n+2);i.push(h=>h.lineTo(o,l)),n+=2}break;case Ls.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 Ls.RESTORE:i.push(o=>o.restore());break;case Ls.SAVE:i.push(o=>o.save());break;case Ls.SCALE:Gt(i.length===2,"Scale command is only valid at the third position.");break;case Ls.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 Ls.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){_t("Abstract method `_fetch` called.")}}class Nu extends Ou{async _fetch(t){const e=await Rh(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):Th(e)}}class Hu{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 vn,wn,ws,$s,ae,uh,_n,N,ne,cr,dr,Ll,ur,Bu,gc,fr,La,Ma,mc,Ia;class bg extends Hu{constructor({docId:e,ownerDocument:s=globalThis.document}){super();A(this,N);A(this,vn);A(this,wn);A(this,ws);A(this,$s);A(this,ae);A(this,uh);A(this,_n,0);p(this,$s,e),p(this,ae,s)}addFilter(e){if(!e)return"none";let s=r(this,N,ne).get(e);if(s)return s;const[i,n,a]=m(this,N,Ll).call(this,e),o=e.length===1?i:`${i}${n}${a}`;if(s=r(this,N,ne).get(o),s)return r(this,N,ne).set(e,s),s;const l=`g_${r(this,$s)}_transfer_map_${fe(this,_n)._++}`,h=m(this,N,ur).call(this,l);r(this,N,ne).set(e,h),r(this,N,ne).set(o,h);const d=m(this,N,fr).call(this,l);return m(this,N,Ma).call(this,i,n,a,d),h}addHCMFilter(e,s){var b;const i=`${e}-${s}`,n="base";let a=r(this,N,cr).get(n);if((a==null?void 0:a.key)===i||(a?((b=a.filter)==null||b.remove(),a.key=i,a.url="none",a.filter=null):(a={key:i,url:"none",filter:null},r(this,N,cr).set(n,a)),!e||!s))return a.url;const o=m(this,N,Ia).call(this,e);e=$.makeHexColor(...o);const l=m(this,N,Ia).call(this,s);if(s=$.makeHexColor(...l),r(this,N,dr).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,$s)}_hcm_filter`,f=a.filter=m(this,N,fr).call(this,u);m(this,N,Ma).call(this,d,d,d,f),m(this,N,gc).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,Ma).call(this,g(0,5),g(1,5),g(2,5),f),a.url=m(this,N,ur).call(this,u),a.url}addAlphaFilter(e){let s=r(this,N,ne).get(e);if(s)return s;const[i]=m(this,N,Ll).call(this,[e]),n=`alpha_${i}`;if(s=r(this,N,ne).get(n),s)return r(this,N,ne).set(e,s),s;const a=`g_${r(this,$s)}_alpha_map_${fe(this,_n)._++}`,o=m(this,N,ur).call(this,a);r(this,N,ne).set(e,o),r(this,N,ne).set(n,o);const l=m(this,N,fr).call(this,a);return m(this,N,mc).call(this,i,l),o}addLuminosityFilter(e){let s=r(this,N,ne).get(e||"luminosity");if(s)return s;let i,n;if(e?([i]=m(this,N,Ll).call(this,[e]),n=`luminosity_${i}`):n="luminosity",s=r(this,N,ne).get(n),s)return r(this,N,ne).set(e,s),s;const a=`g_${r(this,$s)}_luminosity_map_${fe(this,_n)._++}`,o=m(this,N,ur).call(this,a);r(this,N,ne).set(e,o),r(this,N,ne).set(n,o);const l=m(this,N,fr).call(this,a);return m(this,N,Bu).call(this,l),e&&m(this,N,mc).call(this,i,l),o}addHighlightHCMFilter(e,s,i,n,a){var _;const o=`${s}-${i}-${n}-${a}`;let l=r(this,N,cr).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,cr).set(e,l)),!s||!i))return l.url;const[h,d]=[s,i].map(m(this,N,Ia).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,b]=[n,a].map(m(this,N,Ia).bind(this));f{const x=new Array(256),T=(f-u)/C,P=S/255,k=(E-S)/(255*C);let B=0;for(let O=0;O<=C;O++){const X=Math.round(u+O*T),W=P+O*k;for(let G=B;G<=X;G++)x[G]=W;B=X+1}for(let O=B;O<256;O++)x[O]=x[B-1];return x.join(",")},w=`g_${r(this,$s)}_hcm_${e}_filter`,v=l.filter=m(this,N,fr).call(this,w);return m(this,N,gc).call(this,v),m(this,N,Ma).call(this,y(g[0],b[0],5),y(g[1],b[1],5),y(g[2],b[2],5),v),l.url=m(this,N,ur).call(this,w),l.url}destroy(e=!1){e&&r(this,N,cr).size!==0||(r(this,ws)&&(r(this,ws).parentNode.parentNode.remove(),p(this,ws,null)),r(this,wn)&&(r(this,wn).clear(),p(this,wn,null)),p(this,_n,0))}}vn=new WeakMap,wn=new WeakMap,ws=new WeakMap,$s=new WeakMap,ae=new WeakMap,uh=new WeakMap,_n=new WeakMap,N=new WeakSet,ne=function(){return r(this,wn)||p(this,wn,new Map)},cr=function(){return r(this,uh)||p(this,uh,new Map)},dr=function(){if(!r(this,ws)){const e=r(this,ae).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,ae).createElementNS(Is,"svg");i.setAttribute("width",0),i.setAttribute("height",0),p(this,ws,r(this,ae).createElementNS(Is,"defs")),e.append(i),i.append(r(this,ws)),r(this,ae).body.append(e)}return r(this,ws)},Ll=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(",")]},ur=function(e){if(r(this,vn)===void 0){p(this,vn,"");const s=r(this,ae).URL;s!==r(this,ae).baseURI&&(Ph(s)?st('#createUrl: ignore "data:"-URL for performance reasons.'):p(this,vn,s.split("#",1)[0]))}return`url(${r(this,vn)}#${e})`},Bu=function(e){const s=r(this,ae).createElementNS(Is,"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)},gc=function(e){const s=r(this,ae).createElementNS(Is,"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)},fr=function(e){const s=r(this,ae).createElementNS(Is,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),r(this,N,dr).append(s),s},La=function(e,s,i){const n=r(this,ae).createElementNS(Is,s);n.setAttribute("type","discrete"),n.setAttribute("tableValues",i),e.append(n)},Ma=function(e,s,i,n){const a=r(this,ae).createElementNS(Is,"feComponentTransfer");n.append(a),m(this,N,La).call(this,a,"feFuncR",e),m(this,N,La).call(this,a,"feFuncG",s),m(this,N,La).call(this,a,"feFuncB",i)},mc=function(e,s){const i=r(this,ae).createElementNS(Is,"feComponentTransfer");s.append(i),m(this,N,La).call(this,i,"feFuncA",e)},Ia=function(e){return r(this,N,dr).style.color=e,bd(getComputedStyle(r(this,N,dr)).getPropertyValue("color"))};class ju{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){_t("Abstract method `_fetch` called.")}}class $u extends ju{async _fetch(t){const e=await Rh(t,"arraybuffer");return new Uint8Array(e)}}if(ce){var bc=Promise.withResolvers(),Ua=null;(async()=>{const t=await ml(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),e=await ml(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),s=await ml(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),i=await ml(()=>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=>{Ua=t,bc.resolve()},t=>{st(`loadPackages: ${t}`),Ua=new Map,bc.resolve()})}class Gi{static get promise(){return bc.promise}static get(t){return Ua==null?void 0:Ua.get(t)}}async function zu(c){const e=await Gi.get("fs").promises.readFile(c);return new Uint8Array(e)}class Ag extends Hu{}class yg extends Du{_createCanvas(t,e){return Gi.get("canvas").createCanvas(t,e)}}class vg extends Ou{async _fetch(t){return zu(t)}}class wg extends ju{async _fetch(t){return zu(t)}}const me={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Ac(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 yd{getPattern(){_t("Abstract method `getPattern` called.")}}class _g extends yd{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===me.STROKE||i===me.FILL){const a=e.current.getClippedPathBoundingBox(i,Rt(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=$.transform(s,[1,0,0,1,a[0],a[1]]),d.transform(...e.baseTransform),this.matrix&&d.transform(...this.matrix),Ac(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 Ac(t,this._bbox),n=this._createGradient(t);return n}}function jh(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,b=(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(b>=_)return;const S=h[n],E=h[n+1],C=h[n+2],x=h[a],T=h[a+1],P=h[a+2],k=h[o],B=h[o+1],O=h[o+2],X=Math.round(b),W=Math.round(_);let G,V,q,H,z,Lt,Ft,Et;for(let ct=X;ct<=W;ct++){if(ct_?nt=1:w===_?nt=0:nt=(w-ct)/(w-_),G=y-(y-v)*nt,V=x-(x-k)*nt,q=T-(T-B)*nt,H=P-(P-O)*nt}let M;ct_?M=1:M=(b-ct)/(b-_),z=g-(g-v)*M,Lt=S-(S-k)*M,Ft=E-(E-B)*M,Et=C-(C-O)*M;const ht=Math.round(Math.min(G,z)),wt=Math.round(Math.max(G,z));let it=u*ct+ht*4;for(let nt=ht;nt<=wt;nt++)M=(G-nt)/(G-z),M<0?M=0:M>1&&(M=1),d[it++]=V-(V-Lt)*M|0,d[it++]=q-(q-Ft)*M|0,d[it++]=H-(H-Et)*M|0,d[it++]=255}}function Eg(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=B?E=l:x=!0,k>=O?C=h:T=!0;const X=this.getSizeAndScale(E,this.ctx.canvas.width,_),W=this.getSizeAndScale(C,this.ctx.canvas.height,S),G=t.cachedCanvases.getCanvas("pattern",X.size,W.size),V=G.context,q=o.createCanvasGraphics(V);if(q.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(q,i,a),V.translate(-X.scale*d,-W.scale*u),q.transform(X.scale,0,0,W.scale,0,0),V.save(),this.clipBbox(q,d,u,f,g),q.baseTransform=Rt(q.ctx),q.executeOperatorList(s),q.endDrawing(),V.restore(),x||T){const H=G.canvas;x&&(E=l),T&&(C=h);const z=this.getSizeAndScale(E,this.ctx.canvas.width,_),Lt=this.getSizeAndScale(C,this.ctx.canvas.height,S),Ft=z.size,Et=Lt.size,ct=t.cachedCanvases.getCanvas("pattern-workaround",Ft,Et),M=ct.context,ht=x?Math.floor(b/l):0,wt=T?Math.floor(y/h):0;for(let it=0;it<=ht;it++)for(let nt=0;nt<=wt;nt++)M.drawImage(H,Ft*it,Et*nt,Ft,Et,0,0,Ft,Et);return{canvas:ct.canvas,scaleX:z.scale,scaleY:Lt.scale,offsetX:d,offsetY:u}}return{canvas:G.canvas,scaleX:X.scale,scaleY:W.scale,offsetX:d,offsetY:u}}getSizeAndScale(t,e,s){const i=Math.max(fh.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(Rt(t.ctx),[e,s,i,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,n=t.current;switch(e){case Id.COLORED:const a=this.ctx;i.fillStyle=a.fillStyle,i.strokeStyle=a.strokeStyle,n.fillColor=a.fillStyle,n.strokeColor=a.strokeStyle;break;case Id.UNCOLORED:const o=$.makeHexColor(s[0],s[1],s[2]);i.fillStyle=o,i.strokeStyle=o,n.fillColor=o,n.strokeColor=o;break;default:throw new Qp(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,i){let n=s;i!==me.SHADING&&(n=$.transform(n,e.baseTransform),this.matrix&&(n=$.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(fh,"MAX_PATTERN_SIZE",3e3);let yc=fh;function Tg({src:c,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:a=!1}){const o=be.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 b=0;b{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 kg{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 bl(c,t,e,s,i,n,a,o,l,h){const[d,u,f,g,b,y]=Rt(c);if(u===0&&f===0){const _=a*d+b,S=Math.round(_),E=o*g+y,C=Math.round(E),x=(a+l)*d+b,T=Math.abs(Math.round(x)-S)||1,P=(o+h)*g+y,k=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,k),c.setTransform(d,u,f,g,b,y),[T,k]}if(d===0&&g===0){const _=o*f+b,S=Math.round(_),E=a*u+y,C=Math.round(E),x=(o+h)*f+b,T=Math.abs(Math.round(x)-S)||1,P=(a+l)*u+y,k=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,k,T),c.setTransform(d,u,f,g,b,y),[k,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 Lg(c){const{width:t,height:e}=c;if(t>Nd||e>Nd)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 b=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=b[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 Hd{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=ru,this.textMatrixScale=1,this.fontMatrix=Wh,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=ie.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]=$.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=$.applyTransform(e,t),i=$.applyTransform(e.slice(2),t),n=$.applyTransform([e[0],e[3]],t),a=$.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){$.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=$.bezierBoundingBox(e,s,i,n,a,o,l,h,d);d||this.updateRectMinMax(t,u)}getPathBoundingBox(t=me.FILL,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===me.STROKE){e||_t("Stroke bounding box must include transform.");const i=$.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=$.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=me.FILL,e=null){return $.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Bd(c,t){if(typeof ImageData<"u"&&t instanceof ImageData){c.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%xe,n=(e-i)/xe,a=i===0?n:n+1,o=c.createImageData(s,xe);let l=0,h;const d=t.data,u=o.data;let f,g,b,y;if(t.kind===Sl.GRAYSCALE_1BPP){const w=d.byteLength,v=new Uint32Array(u.buffer,0,u.byteLength>>2),_=v.length,S=s+7>>3,E=4294967295,C=be.isLittleEndian?4278190080:255;for(f=0;fS?s:x*8-7,k=P&-8;let B=0,O=0;for(;T>=1}for(;h<_;)v[h++]=0;c.putImageData(o,0,f*xe)}}else if(t.kind===Sl.RGBA_32BPP){for(g=0,y=s*xe*4,f=0;f=n&&(b=i,y=s*b),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*xe)}else throw new Error(`bad image kind: ${t.kind}`)}function jd(c,t){if(t.bitmap){c.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%xe,n=(e-i)/xe,a=i===0?n:n+1,o=c.createImageData(s,xe);let l=0;const h=t.data,d=o.data;for(let u=0;uOd&&typeof s=="function",d=h?Date.now()+Rg:0;let u=0;const f=this.commonObjs,g=this.objs;let b;for(;;){if(i!==void 0&&o===i.nextBreakPoint)return i.breakIt(o,s),o;if(b=a[o],b!==Ke.dependency)this[b].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>Od){if(Date.now()>d)return s(),o;u=0}}}endDrawing(){m(this,Wi,vc).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,Wi,wc).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=Rt(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 k=l.get(h);if(k&&!a){const B=Math.round(Math.min(o[0],o[2])+o[4]),O=Math.round(Math.min(o[1],o[3])+o[5]);return{canvas:k,offsetX:B,offsetY:O}}d=k}d||(u=this.cachedCanvases.getCanvas("maskCanvas",s,i),jd(u.context,t));let f=$.transform(o,[1/s,0,0,-1/i,0,0]);f=$.transform(f,[1,0,0,1,0,-i]);const[g,b,y,w]=$.getAxialAlignedBoundingBox([0,0,s,i],f),v=Math.round(y-g)||1,_=Math.round(w-b)||1,S=this.cachedCanvases.getCanvas("fillCanvas",v,_),E=S.context,C=g,x=b;E.translate(-C,-x),E.transform(...f),d||(d=this._scaleImage(u.canvas,Ms(E)),d=d.img,l&&a&&l.set(h,d)),E.imageSmoothingEnabled=$d(Rt(E),t.interpolate),bl(E,d,0,0,d.width,d.height,0,0,s,i),E.globalCompositeOperation="source-in";const T=$.transform(Ms(E),[1,0,0,1,-C,-x]);return E.fillStyle=a?n.getPattern(e,this,T,me.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=Mg[t]}setLineJoin(t){this.ctx.lineJoin=Ig[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(...Rt(this.suspendedCtx)),xa(this.suspendedCtx,n),Pg(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(),xa(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,b=h-u;if(a){const w=$.makeHexColor(...a);if(g<0||b<0||g+s>f.width||b+i>f.height){const v=this.cachedCanvases.getCanvas("maskExtension",s,i),_=v.context;_.drawImage(f,-g,-b),_.globalCompositeOperation="destination-atop",_.fillStyle=w,_.fillRect(0,0,s,i),_.globalCompositeOperation="source-over",f=v.canvas,g=b=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const v=new Path2D;v.rect(g,b,s,i),t.clip(v),t.globalCompositeOperation="destination-atop",t.fillStyle=w,t.fillRect(g,b,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,b,s,i,l,h,s,i),e.restore()}save(){this.inSMaskMode?(xa(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(),xa(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=Rt(i),u=d[0]===0&&d[3]===0||d[1]===0&&d[2]===0,f=u?s.slice(0):null;for(let g=0,b=0,y=t.length;gDd&&(h=Dd),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&ie.FILL_STROKE_MASK,u=!!(l&ie.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===ie.FILL||d===ie.FILL_STROKE)&&n.fill(),(d===ie.STROKE||d===ie.FILL_STROKE)&&n.stroke(),n.restore()):((d===ie.FILL||d===ie.FILL_STROKE)&&n.fillText(t,e,s),(d===ie.STROKE||d===ie.FILL_STROKE)&&n.strokeText(t,e,s)),u&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Rt(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 lt(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,b=s.defaultVMetrics,y=i*e.fontMatrix[0],w=e.textRenderingMode===ie.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,Ms(n),me.FILL);v=Rt(n),n.restore(),n.fillStyle=x}let _=e.lineWidth;const S=e.textMatrixScale;if(S===0||_===0){const x=e.textRenderingMode&ie.FILL_STROKE_MASK;(x===ie.STROKE||x===ie.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 V=n.measureText(k).width*1e3/i*a;if(Wnew Cd(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new yc(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=$.makeHexColor(t,e,s)}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent"}setFillRGBColor(t,e,s){this.ctx.fillStyle=this.current.fillColor=$.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=Cg(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,Ms(e),me.SHADING);const i=Ms(e);if(i){const{width:n,height:a}=e.canvas,[o,l,h,d]=$.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(){_t("Should not call beginInlineImage")}beginImageData(){_t("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Rt(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(Rt(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||xh("TODO: Support non-isolated groups."),t.knockout&&st("Knockout groups not supported.");const s=Rt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=$.getAxialAlignedBoundingBox(t.bbox,Rt(e));const n=[0,0,e.canvas.width,e.canvas.height];i=$.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()),xa(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=Rt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const n=$.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,Wi,vc).call(this),Al(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]=$.singularValueDecompose2dScale(Rt(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:b}=this.annotationCanvas;this.annotationCanvasMap.set(t,g),this.annotationCanvas.savedCtx=this.ctx,this.ctx=b,this.ctx.save(),this.ctx.setTransform(l,0,0,-h,0,o*h),Al(this.ctx)}else Al(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],a,o),this.ctx.clip(),this.ctx.beginPath()}this.current=new Hd(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),m(this,Wi,wc).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=Lg(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=Rt(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}};Wi=new WeakSet,vc=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)},wc=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 yr=Cd;for(const c in Ke)yr.prototype[c]!==void 0&&(yr.prototype[Ke[c]]=yr.prototype[c]);var go,mo;class ai{static get workerPort(){return r(this,go)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");p(this,go,t)}static get workerSrc(){return r(this,mo)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");p(this,mo,t)}}go=new WeakMap,mo=new WeakMap,A(ai,go,null),A(ai,mo,"");const yl={DATA:1,ERROR:2},Dt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Te(c){switch(c instanceof Error||typeof c=="object"&&c!==null||_t('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),c.name){case"AbortException":return new or(c.message);case"MissingPDFException":return new ar(c.message);case"PasswordException":return new Vh(c.message,c.code);case"UnexpectedResponseException":return new Ch(c.message,c.status);case"UnknownErrorException":return new qh(c.message,c.details);default:return new qh(c.message,c.toString())}}var Nr,qe,Gu,Uu,Wu,Ml;class Fa{constructor(t,e,s){A(this,qe);A(this,Nr,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,qe,Gu).bind(this),{signal:r(this,Nr).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:Dt.PULL,streamId:n,desiredSize:h.desiredSize}),d.promise},cancel:h=>{Gt(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:Dt.CANCEL,streamId:n,reason:Te(h)}),d.promise}},s)}destroy(){var t;(t=r(this,Nr))==null||t.abort(),p(this,Nr,null)}}Nr=new WeakMap,qe=new WeakSet,Gu=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){m(this,qe,Wu).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===yl.DATA)i.resolve(t.data);else if(t.callback===yl.ERROR)i.reject(Te(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:yl.DATA,callbackId:t.callbackId,data:a})},function(a){n.postMessage({sourceName:s,targetName:i,callback:yl.ERROR,callbackId:t.callbackId,reason:Te(a)})});return}if(t.streamId){m(this,qe,Uu).call(this,t);return}e(t.data)},Uu=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:Dt.ENQUEUE,streamId:e,chunk:h},u)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Dt.CLOSE,streamId:e}),delete a.streamSinks[e])},error(h){Gt(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Dt.ERROR,streamId:e,reason:Te(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:Dt.START_COMPLETE,streamId:e,success:!0})},function(h){n.postMessage({sourceName:s,targetName:i,stream:Dt.START_COMPLETE,streamId:e,reason:Te(h)})})},Wu=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 Dt.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(Te(t.reason));break;case Dt.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(Te(t.reason));break;case Dt.PULL:if(!o){n.postMessage({sourceName:s,targetName:i,stream:Dt.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:Dt.PULL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:Dt.PULL_COMPLETE,streamId:e,reason:Te(l)})});break;case Dt.ENQUEUE:if(Gt(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Dt.CLOSE:if(Gt(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),m(this,qe,Ml).call(this,a,e);break;case Dt.ERROR:Gt(a,"error should have stream controller"),a.controller.error(Te(t.reason)),m(this,qe,Ml).call(this,a,e);break;case Dt.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(Te(t.reason)),m(this,qe,Ml).call(this,a,e);break;case Dt.CANCEL:if(!o)break;new Promise(function(l){var h;l((h=o.onCancel)==null?void 0:h.call(o,Te(t.reason)))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Dt.CANCEL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:Dt.CANCEL_COMPLETE,streamId:e,reason:Te(l)})}),o.sinkCapability.reject(Te(t.reason)),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Ml=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 En,bo;class Dg{constructor({parsedData:t,rawData:e}){A(this,En);A(this,bo);p(this,En,t),p(this,bo,e)}getRaw(){return r(this,bo)}get(t){return r(this,En).get(t)??null}getAll(){return ud(r(this,En))}has(t){return r(this,En).has(t)}}En=new WeakMap,bo=new WeakMap;const pr=Symbol("INTERNAL");var Ao,yo,vo,Hr;class Og{constructor(t,{name:e,intent:s,usage:i,rbGroups:n}){A(this,Ao,!1);A(this,yo,!1);A(this,vo,!1);A(this,Hr,!0);p(this,Ao,!!(t&Oe.DISPLAY)),p(this,yo,!!(t&Oe.PRINT)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=n}get visible(){if(r(this,vo))return r(this,Hr);if(!r(this,Hr))return!1;const{print:t,view:e}=this.usage;return r(this,Ao)?(e==null?void 0:e.viewState)!=="OFF":r(this,yo)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==pr&&_t("Internal method `_setVisible` called."),p(this,vo,s),p(this,Hr,e)}}Ao=new WeakMap,yo=new WeakMap,vo=new WeakMap,Hr=new WeakMap;var Ci,pt,Br,jr,wo,_c;class Ng{constructor(t,e=Oe.DISPLAY){A(this,wo);A(this,Ci,null);A(this,pt,new Map);A(this,Br,null);A(this,jr,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,p(this,jr,t.order);for(const s of t.groups)r(this,pt).set(s.id,new Og(e,s));if(t.baseState==="OFF")for(const s of r(this,pt).values())s._setVisible(pr,!1);for(const s of t.on)r(this,pt).get(s)._setVisible(pr,!0);for(const s of t.off)r(this,pt).get(s)._setVisible(pr,!1);p(this,Br,this.getHash())}}isVisible(t){if(r(this,pt).size===0)return!0;if(!t)return xh("Optional content group not defined."),!0;if(t.type==="OCG")return r(this,pt).has(t.id)?r(this,pt).get(t.id).visible:(st(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return m(this,wo,_c).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!r(this,pt).has(e))return st(`Optional content group not found: ${e}`),!0;if(r(this,pt).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!r(this,pt).has(e))return st(`Optional content group not found: ${e}`),!0;if(!r(this,pt).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!r(this,pt).has(e))return st(`Optional content group not found: ${e}`),!0;if(!r(this,pt).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!r(this,pt).has(e))return st(`Optional content group not found: ${e}`),!0;if(r(this,pt).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,pt).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,pt).get(o))==null||n._setVisible(pr,!1,!0));i._setVisible(pr,!!e,!0),p(this,Ci,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,pt).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,Ci,null)}get hasInitialVisibility(){return r(this,Br)===null||this.getHash()===r(this,Br)}getOrder(){return r(this,pt).size?r(this,jr)?r(this,jr).slice():[...r(this,pt).keys()]:null}getGroups(){return r(this,pt).size>0?ud(r(this,pt)):null}getGroup(t){return r(this,pt).get(t)||null}getHash(){if(r(this,Ci)!==null)return r(this,Ci);const t=new Mu;for(const[e,s]of r(this,pt))t.update(`${e}:${s.visible}`);return p(this,Ci,t.hexdigest())}}Ci=new WeakMap,pt=new WeakMap,Br=new WeakMap,jr=new WeakMap,wo=new WeakSet,_c=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)});Gt(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(){Gt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Bg(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new jg(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 Bg{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=gd(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 jg{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 $g(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=Th(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 b=[];for(let y=0;y{if(!Vu(n.status))throw kh(n.status,i);this._reader=n.body.getReader(),this._headersCapability.resolve();const a=n.headers,{allowRangeRequests:o,suggestedLength:l}=wd({responseHeaders:a,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=o,this._contentLength=l||this._contentLength,this._filename=_d(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new or("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:Xu(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}class Gg{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,qu(n,this._withCredentials,this._abortController)).then(o=>{if(!Vu(o.status))throw kh(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:Xu(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}const $h=200,zh=206;function Ug(c){const t=c.response;return typeof t!="string"?t:Th(t).buffer}class Wg{constructor({url:t,httpHeaders:e,withCredentials:s}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=vd(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=zh):i.expectedStatus=$h,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||$h;if(!(n===$h&&s.expectedStatus===zh)&&n!==s.expectedStatus){(h=s.onError)==null||h.call(s,i.status);return}const o=Ug(i);if(n===zh){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 Vg{constructor(t){this._source=t,this._manager=new Wg(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 Gt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new qg(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new Xg(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 qg{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}=wd({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=_d(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=kh(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 Xg{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=kh(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 Yg=/^[a-z][a-z0-9\-+.]+:/i;function Kg(c){if(Yg.test(c))return new URL(c);const t=Gi.get("url");return new URL(t.pathToFileURL(c))}function Yu(c,t,e){return c.protocol==="http:"?Gi.get("http").request(c,{headers:t},e):Gi.get("https").request(c,{headers:t},e)}class Qg{constructor(t){this.source=t,this.url=Kg(t.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.headers=vd(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 Gt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new tm(this):new Jg(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=this.isFsUrl?new em(this,t,e):new Zg(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 Ku{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 or("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Qu{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 Jg extends Ku{constructor(t){super(t);const e=Object.fromEntries(t.headers),s=i=>{if(i.statusCode===404){const l=new ar(`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}=wd({responseHeaders:n,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=o||this._contentLength,this._filename=_d(n)};this._request=Yu(this._url,e,s),this._request.on("error",i=>{this._storedError=i,this._headersCapability.reject(i)}),this._request.end()}}class Zg extends Qu{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 ar(`Missing PDF "${this._url}".`);this._storedError=o;return}this._setReadableStream(a)};this._request=Yu(this._url,i,n),this._request.on("error",a=>{this._storedError=a}),this._request.end()}}class tm extends Ku{constructor(t){super(t);const e=Gi.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 ar(`Missing PDF "${this._url}".`)),this._storedError=s,this._headersCapability.reject(s)})}}class em extends Qu{constructor(t,e,s){super(t);const i=Gi.get("fs");this._setReadableStream(i.createReadStream(this._url,{start:e,end:s-1}))}}const sm=1e5,ve=30,im=.8;var iu,Ti,Ee,_o,Eo,Sn,zs,So,xo,xn,$r,zr,Ri,Gr,Co,Ur,Cn,To,Ro,kt,Tn,Rn,Po,Pi,Wr,ci,Ju,Zu,Sc,He,Il,xc,tf,ef;let Ec=(kt=class{constructor({textContentSource:t,container:e,viewport:s}){A(this,ci);A(this,Ti,Promise.withResolvers());A(this,Ee,null);A(this,_o,!1);A(this,Eo,!!((iu=globalThis.FontInspector)!=null&&iu.enabled));A(this,Sn,null);A(this,zs,null);A(this,So,0);A(this,xo,0);A(this,xn,null);A(this,$r,null);A(this,zr,0);A(this,Ri,0);A(this,Gr,Object.create(null));A(this,Co,[]);A(this,Ur,null);A(this,Cn,[]);A(this,To,new WeakMap);A(this,Ro,null);var l;if(t instanceof ReadableStream)p(this,Ur,t);else if(typeof t=="object")p(this,Ur,new ReadableStream({start(h){h.enqueue(t),h.close()}}));else throw new Error('No "textContentSource" parameter specified.');p(this,Ee,p(this,$r,e)),p(this,Ri,s.scale*(globalThis.devicePixelRatio||1)),p(this,zr,s.rotation),p(this,zs,{div:null,properties:null,ctx:null});const{pageWidth:i,pageHeight:n,pageX:a,pageY:o}=s.rawDims;p(this,Ro,[1,0,0,-1,-a,o+n]),p(this,xo,i),p(this,So,n),m(l=kt,He,tf).call(l),tr(e,s),r(this,Ti).promise.finally(()=>{r(kt,Wr).delete(this),p(this,zs,null),p(this,Gr,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=be.platform;return lt(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{r(this,xn).read().then(({value:e,done:s})=>{if(s){r(this,Ti).resolve();return}r(this,Sn)??p(this,Sn,e.lang),Object.assign(r(this,Gr),e.styles),m(this,ci,Ju).call(this,e.items),t()},r(this,Ti).reject)};return p(this,xn,r(this,Ur).getReader()),r(kt,Wr).add(this),t(),r(this,Ti).promise}update({viewport:t,onBefore:e=null}){var n;const s=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==r(this,zr)&&(e==null||e(),p(this,zr,i),tr(r(this,$r),{rotation:i})),s!==r(this,Ri)){e==null||e(),p(this,Ri,s);const a={div:null,properties:null,ctx:m(n=kt,He,Il).call(n,r(this,Sn))};for(const o of r(this,Cn))a.properties=r(this,To).get(o),a.div=o,m(this,ci,Sc).call(this,a)}}cancel(){var e;const t=new or("TextLayer task cancelled.");(e=r(this,xn))==null||e.cancel(t).catch(()=>{}),p(this,xn,null),r(this,Ti).reject(t)}get textDivs(){return r(this,Cn)}get textContentItemsStr(){return r(this,Co)}static cleanup(){if(!(r(this,Wr).size>0)){r(this,Tn).clear();for(const{canvas:t}of r(this,Rn).values())t.remove();r(this,Rn).clear()}}},Ti=new WeakMap,Ee=new WeakMap,_o=new WeakMap,Eo=new WeakMap,Sn=new WeakMap,zs=new WeakMap,So=new WeakMap,xo=new WeakMap,xn=new WeakMap,$r=new WeakMap,zr=new WeakMap,Ri=new WeakMap,Gr=new WeakMap,Co=new WeakMap,Ur=new WeakMap,Cn=new WeakMap,To=new WeakMap,Ro=new WeakMap,Tn=new WeakMap,Rn=new WeakMap,Po=new WeakMap,Pi=new WeakMap,Wr=new WeakMap,ci=new WeakSet,Ju=function(t){var i,n;if(r(this,_o))return;(n=r(this,zs)).ctx??(n.ctx=m(i=kt,He,Il).call(i,r(this,Sn)));const e=r(this,Cn),s=r(this,Co);for(const a of t){if(e.length>sm){st("Ignoring additional textDivs for performance reasons."),p(this,_o,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=r(this,Ee);p(this,Ee,document.createElement("span")),r(this,Ee).classList.add("markedContent"),a.id!==null&&r(this,Ee).setAttribute("id",`${a.id}`),o.append(r(this,Ee))}else a.type==="endMarkedContent"&&p(this,Ee,r(this,Ee).parentNode);continue}s.push(a.str),m(this,ci,Zu).call(this,a)}},Zu=function(t){var y;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};r(this,Cn).push(e);const i=$.transform(r(this,Ro),t.transform);let n=Math.atan2(i[1],i[0]);const a=r(this,Gr)[t.fontName];a.vertical&&(n+=Math.PI/2);let o=r(this,Eo)&&a.fontSubstitution||a.fontFamily;o=kt.fontFamilyMap.get(o)||o;const l=Math.hypot(i[2],i[3]),h=l*m(y=kt,He,ef).call(y,o,r(this,Sn));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,Ee)===r(this,$r)?(g.left=`${(100*d/r(this,xo)).toFixed(2)}%`,g.top=`${(100*u/r(this,So)).toFixed(2)}%`):(g.left=`${f}${d.toFixed(2)}px)`,g.top=`${f}${u.toFixed(2)}px)`),g.fontSize=`${f}${(r(kt,Pi)*l).toFixed(2)}px)`,g.fontFamily=o,s.fontSize=l,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,r(this,Eo)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),n!==0&&(s.angle=n*(180/Math.PI));let b=!1;if(t.str.length>1)b=!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&&(b=!0)}if(b&&(s.canvasWidth=a.vertical?t.height:t.width),r(this,To).set(e,s),r(this,zs).div=e,r(this,zs).properties=s,m(this,ci,Sc).call(this,r(this,zs)),s.hasText&&r(this,Ee).append(e),s.hasEOL){const w=document.createElement("br");w.setAttribute("role","presentation"),r(this,Ee).append(w)}},Sc=function(t){var o;const{div:e,properties:s,ctx:i}=t,{style:n}=e;let a="";if(r(kt,Pi)>1&&(a=`scale(${1/r(kt,Pi)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:l}=n,{canvasWidth:h,fontSize:d}=s;m(o=kt,He,xc).call(o,i,d*r(this,Ri),l);const{width:u}=i.measureText(e.textContent);u>0&&(a=`scaleX(${h*r(this,Ri)/u}) ${a}`)}s.angle!==0&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(n.transform=a)},He=new WeakSet,Il=function(t=null){let e=r(this,Rn).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,Rn).set(t,e),r(this,Po).set(e,{size:0,family:""})}return e},xc=function(t,e,s){const i=r(this,Po).get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)},tf=function(){if(r(this,Pi)!==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,Pi,t.getBoundingClientRect().height),t.remove()},ef=function(t,e){const s=r(this,Tn).get(t);if(s)return s;const i=m(this,He,Il).call(this,e);i.canvas.width=i.canvas.height=ve,m(this,He,xc).call(this,i,ve,t);const n=i.measureText("");let a=n.fontBoundingBoxAscent,o=Math.abs(n.fontBoundingBoxDescent);if(a){const d=a/(a+o);return r(this,Tn).set(t,d),i.canvas.width=i.canvas.height=0,d}i.strokeStyle="red",i.clearRect(0,0,ve,ve),i.strokeText("g",0,0);let l=i.getImageData(0,0,ve,ve).data;o=0;for(let d=l.length-1-3;d>=0;d-=4)if(l[d]>0){o=Math.ceil(d/4/ve);break}i.clearRect(0,0,ve,ve),i.strokeText("A",0,ve),l=i.getImageData(0,0,ve,ve).data,a=0;for(let d=0,u=l.length;d0){a=ve-Math.floor(d/4/ve);break}i.canvas.width=i.canvas.height=0;const h=a?a/(a+o):im;return r(this,Tn).set(t,h),h},A(kt,He),A(kt,Tn,new Map),A(kt,Rn,new Map),A(kt,Po,new WeakMap),A(kt,Pi,null),A(kt,Wr,new Set),kt);class Va{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(Va.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 nm=65536,rm=100,am=5e3,om=ce?yg:mg,lm=ce?vg:Nu,hm=ce?Ag:bg,cm=ce?wg:$u;function dm(c={}){typeof c=="string"||c instanceof URL?c={url:c}:(c instanceof ArrayBuffer||ArrayBuffer.isView(c))&&(c={data:c});const t=new Cc,{docId:e}=t,s=c.url?um(c.url):null,i=c.data?fm(c.data):null,n=c.httpHeaders||null,a=c.withCredentials===!0,o=c.password??null,l=c.range instanceof sf?c.range:null,h=Number.isInteger(c.rangeChunkSize)&&c.rangeChunkSize>0?c.rangeChunkSize:nm;let d=c.worker instanceof vr?c.worker:null;const u=c.verbosity,f=typeof c.docBaseUrl=="string"&&!Ph(c.docBaseUrl)?c.docBaseUrl:null,g=typeof c.cMapUrl=="string"?c.cMapUrl:null,b=c.cMapPacked!==!1,y=c.CMapReaderFactory||lm,w=typeof c.standardFontDataUrl=="string"?c.standardFontDataUrl:null,v=c.StandardFontDataFactory||cm,_=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:!ce,x=typeof c.isChrome=="boolean"?c.isChrome:!be.platform.isFirefox&&typeof window<"u"&&!!(window!=null&&window.chrome),T=Number.isInteger(c.canvasMaxAreaInBytes)?c.canvasMaxAreaInBytes:-1,P=typeof c.disableFontFace=="boolean"?c.disableFontFace:ce,k=c.fontExtraProperties===!0,B=c.enableXfa===!0,O=c.ownerDocument||globalThis.document,X=c.disableRange===!0,W=c.disableStream===!0,G=c.disableAutoFetch===!0,V=c.pdfBug===!0,q=c.CanvasFactory||om,H=c.FilterFactory||hm,z=c.enableHWA===!0,Lt=l?l.length:c.length??NaN,Ft=typeof c.useSystemFonts=="boolean"?c.useSystemFonts:!ce&&!P,Et=typeof c.useWorkerFetch=="boolean"?c.useWorkerFetch:y===Nu&&v===$u&&g&&w&&Ta(g,document.baseURI)&&Ta(w,document.baseURI);c.canvasFactory&&Ld("`canvasFactory`-instance option, please use `CanvasFactory` instead."),c.filterFactory&&Ld("`filterFactory`-instance option, please use `FilterFactory` instead.");const ct=null;qp(u);const M={canvasFactory:new q({ownerDocument:O,enableHWA:z}),filterFactory:new H({docId:e,ownerDocument:O}),cMapReaderFactory:Et?null:new y({baseUrl:g,isCompressed:b}),standardFontDataFactory:Et?null:new v({baseUrl:w})};if(!d){const it={verbosity:u,port:ai.workerPort};d=it.port?vr.fromPort(it):new vr(it),t._worker=d}const ht={docId:e,apiVersion:"4.8.69",data:i,password:o,disableAutoFetch:G,rangeChunkSize:h,length:Lt,docBaseUrl:f,enableXfa:B,evaluatorOptions:{maxImageSize:S,disableFontFace:P,ignoreErrors:_,isEvalSupported:E,isOffscreenCanvasSupported:C,isChrome:x,canvasMaxAreaInBytes:T,fontExtraProperties:k,useSystemFonts:Ft,cMapUrl:Et?g:null,standardFontDataUrl:Et?w:null}},wt={disableFontFace:P,fontExtraProperties:k,ownerDocument:O,pdfBug:V,styleElement:ct,loadingParams:{disableAutoFetch:G,enableXfa:B}};return d.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const it=d.messageHandler.sendWithPromise("GetDocRequest",ht,i?[i.buffer]:null);let nt;if(l)nt=new Hg(l,{disableRange:X,disableStream:W});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");let de;ce?de=typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype&&Ta(s)?Gd:Qg:de=Ta(s)?Gd:Vg,nt=new de({url:s,length:Lt,httpHeaders:n,withCredentials:a,rangeChunkSize:h,disableRange:X,disableStream:W})}return it.then(de=>{if(t.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const ue=new Fa(e,de,d.port),mt=new bm(ue,t,nt,wt,M);t._transport=mt,ue.send("Ready",null)})}).catch(t._capability.reject),t}function um(c){if(c instanceof URL)return c.href;try{return new URL(c,window.location).href}catch{if(ce&&typeof c=="string")return c}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function fm(c){if(ce&&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 Th(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 Ud(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 ph;const gh=class gh{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${fe(gh,ph)._++}`,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)}};ph=new WeakMap,A(gh,ph,0);let Cc=gh,sf=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){_t("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class pm{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return lt(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var ki,Gs,We,gr,Fl;class gm{constructor(t,e,s,i=!1){A(this,We);A(this,ki,null);A(this,Gs,!1);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new kd:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new nf,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 hl({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 lt(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=pi.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:b}=f;p(this,Gs,!1),m(this,We,Fl).call(this),o||(o=this._transport.getOptionalContentConfig(g));let y=this._intentStates.get(b);y||(y=Object.create(null),this._intentStates.set(b,y)),y.streamReaderCancelTimeout&&(clearTimeout(y.streamReaderCancelTimeout),y.streamReaderCancelTimeout=null);const w=!!(g&Oe.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,Gs,!0),m(this,We,gr).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 Rc({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=pi.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=>Va.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,Gs,!1),m(this,We,Fl).call(this),Promise.all(t)}cleanup(t=!1){p(this,Gs,!0);const e=m(this,We,gr).call(this,!1);return t&&e&&this._stats&&(this._stats=new kd),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,We,gr).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 pd){let i=rm;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 or(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}}ki=new WeakMap,Gs=new WeakMap,We=new WeakSet,gr=function(t=!1){if(m(this,We,Fl).call(this),!r(this,Gs)||this.destroyed)return!1;if(t)return p(this,ki,setTimeout(()=>{p(this,ki,null),m(this,We,gr).call(this,!1)},am)),!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,Gs,!1),!0},Fl=function(){r(this,ki)&&(clearTimeout(r(this,ki)),p(this,ki,null))};var Us,mh;class mm{constructor(){A(this,Us,new Map);A(this,mh,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};r(this,mh).then(()=>{for(const[i]of r(this,Us))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,Us).set(e,i)}removeEventListener(t,e){const s=r(this,Us).get(e);s==null||s(),r(this,Us).delete(e)}terminate(){for(const[,t]of r(this,Us))t==null||t();r(this,Us).clear()}}Us=new WeakMap,mh=new WeakMap;var bh,Pn,kn,Vr,Dl,qr,Ol;const St=class St{constructor({name:t=null,port:e=null,verbosity:s=Xp()}={}){A(this,Vr);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(St,kn))!=null&&i.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(r(St,kn)||p(St,kn,new WeakMap)).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return ce?Promise.all([Gi.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 Fa("main","worker",t),this._messageHandler.on("ready",function(){}),m(this,Vr,Dl).call(this)}_initialize(){if(r(St,Pn)||r(St,qr,Ol)){this._setupFakeWorker();return}let{workerSrc:t}=St;try{St._isSameOrigin(window.location.href,t)||(t=St._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new Fa("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,Vr,Dl).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{xh("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){r(St,Pn)||(st("Setting up fake worker."),p(St,Pn,!0)),St._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new mm;this._port=e;const s=`fake${fe(St,bh)._++}`,i=new Fa(s+"_worker",s,e);t.setup(i,e),this._messageHandler=new Fa(s,s+"_worker",e),m(this,Vr,Dl).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(St,kn))==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,kn))==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 St(t)}static get workerSrc(){if(ai.workerSrc)return ai.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return lt(this,"_setupFakeWorkerGlobal",(async()=>r(this,qr,Ol)?r(this,qr,Ol):(await import(this.workerSrc)).WorkerMessageHandler)())}};bh=new WeakMap,Pn=new WeakMap,kn=new WeakMap,Vr=new WeakSet,Dl=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},qr=new WeakSet,Ol=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},A(St,qr),A(St,bh,0),A(St,Pn,!1),A(St,kn),ce&&(p(St,Pn,!0),ai.workerSrc||(ai.workerSrc="./pdf.worker.mjs")),St._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},St._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let vr=St;var Ws,_s,Xr,Yr,Es,Ln,Da;class bm{constructor(t,e,s,i,n){A(this,Ln);A(this,Ws,new Map);A(this,_s,new Map);A(this,Xr,new Map);A(this,Yr,new Map);A(this,Es,null);this.messageHandler=t,this.loadingTask=e,this.commonObjs=new nf,this.fontLoader=new pg({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 lt(this,"annotationStorage",new Ad)}getRenderingIntent(t,e=pi.ENABLE,s=null,i=!1,n=!1){let a=Oe.DISPLAY,o=pc;switch(t){case"any":a=Oe.ANY;break;case"display":break;case"print":a=Oe.PRINT;break;default:st(`getRenderingIntent - invalid intent: ${t}`)}const l=a&Oe.PRINT&&s instanceof Fu?s:this.annotationStorage;switch(e){case pi.DISABLE:a+=Oe.ANNOTATIONS_DISABLE;break;case pi.ENABLE:break;case pi.ENABLE_FORMS:a+=Oe.ANNOTATIONS_FORMS;break;case pi.ENABLE_STORAGE:a+=Oe.ANNOTATIONS_STORAGE,o=l.serializable;break;default:st(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(a+=Oe.IS_EDITING),n&&(a+=Oe.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,Es))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of r(this,_s).values())t.push(i._destroy());r(this,_s).clear(),r(this,Xr).clear(),r(this,Yr).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,Ws).clear(),this.filterFactory.destroy(),Ec.cleanup(),(i=this._networkStream)==null||i.cancelAllRequests(new or("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)=>{Gt(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}Gt(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)=>{Gt(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}Gt(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 pm(s,this))}),t.on("DocException",function(s){let i;switch(s.name){case"PasswordException":i=new Vh(s.message,s.code);break;case"InvalidPDFException":i=new au(s.message);break;case"MissingPDFException":i=new ar(s.message);break;case"UnexpectedResponseException":i=new Ch(s.message,s.status);break;case"UnknownErrorException":i=new qh(s.message,s.details);break;default:_t("DocException - expected a valid Error.")}e._capability.reject(i)}),t.on("PasswordRequest",s=>{if(p(this,Es,Promise.withResolvers()),e.onPassword){const i=n=>{n instanceof Error?r(this,Es).reject(n):r(this,Es).resolve({password:n})};try{e.onPassword(i,s.code)}catch(n){r(this,Es).reject(n)}}else r(this,Es).reject(new Vh(s.message,s.code));return r(this,Es).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,_s).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,b)=>globalThis.FontInspector.fontAdded(g,b):null,u=new gg(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;Gt(f,"The imageRef must be defined.");for(const g of r(this,_s).values())for(const[,b]of g.objs)if((b==null?void 0:b.ref)===f)return b.dataLen?(this.commonObjs.resolve(s,structuredClone(b)),b.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,_s).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)>Gp&&(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,Xr).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,Yr).set(n.refStr,t);const a=new gm(e,n,this,this._params.pdfBug);return r(this,_s).set(e,a),a});return r(this,Xr).set(e,i),i}getPageIndex(t){return Ud(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,Ln,Da).call(this,"GetFieldObjects")}hasJSActions(){return m(this,Ln,Da).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,Ln,Da).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,Ln,Da).call(this,"GetOptionalContentConfig").then(e=>new Ng(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=r(this,Ws).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 Dg(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,Ws).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,_s).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),r(this,Ws).clear(),this.filterFactory.destroy(!0),Ec.cleanup()}}cachedPageNumber(t){if(!Ud(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return r(this,Yr).get(e)??null}}Ws=new WeakMap,_s=new WeakMap,Xr=new WeakMap,Yr=new WeakMap,Es=new WeakMap,Ln=new WeakSet,Da=function(t,e=null){const s=r(this,Ws).get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return r(this,Ws).set(t,i),i};const vl=Symbol("INITIAL_DATA");var ss,ko,Tc;class nf{constructor(){A(this,ko);A(this,ss,Object.create(null))}get(t,e=null){if(e){const i=m(this,ko,Tc).call(this,t);return i.promise.then(()=>e(i.data)),null}const s=r(this,ss)[t];if(!s||s.data===vl)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=r(this,ss)[t];return!!e&&e.data!==vl}resolve(t,e=null){const s=m(this,ko,Tc).call(this,t);s.data=e,s.resolve()}clear(){var t;for(const e in r(this,ss)){const{data:s}=r(this,ss)[e];(t=s==null?void 0:s.bitmap)==null||t.close()}p(this,ss,Object.create(null))}*[Symbol.iterator](){for(const t in r(this,ss)){const{data:e}=r(this,ss)[t];e!==vl&&(yield[t,e])}}}ss=new WeakMap,ko=new WeakSet,Tc=function(t){var e;return(e=r(this,ss))[t]||(e[t]={...Promise.withResolvers(),data:vl})};var Li;class Am{constructor(t){A(this,Li,null);p(this,Li,t),this.onContinue=null}get promise(){return r(this,Li).capability.promise}cancel(t=0){r(this,Li).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=r(this,Li).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=r(this,Li);return t.form||t.canvas&&(e==null?void 0:e.size)>0}}Li=new WeakMap;var Mi,Mn;const sn=class sn{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}){A(this,Mi,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 Am(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(sn,Mn).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(sn,Mn).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 yr(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,Mi)&&(window.cancelAnimationFrame(r(this,Mi)),p(this,Mi,null)),r(sn,Mn).delete(this._canvas),this.callback(t||new pd(`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,Mi,window.requestAnimationFrame(()=>{p(this,Mi,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(sn,Mn).delete(this._canvas),this.callback())))}};Mi=new WeakMap,Mn=new WeakMap,A(sn,Mn,new WeakSet);let Rc=sn;const ym="4.8.69",vm="3634dab10";function Wd(c){return Math.floor(Math.max(0,Math.min(1,c))*255).toString(16).padStart(2,"0")}function Ca(c){return Math.max(0,Math.min(255,255*c))}class Vd{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=Ca(t),[t,t,t]}static G_HTML([t]){const e=Wd(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(Ca)}static RGB_HTML(t){return`#${t.map(Wd).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[Ca(1-Math.min(1,t+i)),Ca(1-Math.min(1,s+i)),Ca(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 wm{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){_t("Abstract method `_createSVG` called.")}}class Ed extends wm{_createSVG(t){return document.createElementNS(Is,t)}}class rf{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&&Va.shouldBuildText(i.name)&&h.push(g)}return{textDivs:h}}const d=[[i,-1,a]];for(;d.length>0;){const[g,b,y]=d.at(-1);if(b+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&&Va.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 dl=1e3,_m=9,sr=new WeakSet;function oi(c){return{width:c[2]-c[0],height:c[3]-c[1]}}class Em{static create(t){switch(t.data.annotationType){case Bt.LINK:return new af(t);case Bt.TEXT:return new Sm(t);case Bt.WIDGET:switch(t.data.fieldType){case"Tx":return new xm(t);case"Btn":return t.data.radioButton?new hf(t):t.data.checkBox?new Tm(t):new Rm(t);case"Ch":return new Pm(t);case"Sig":return new Cm(t)}return new lr(t);case Bt.POPUP:return new kc(t);case Bt.FREETEXT:return new pf(t);case Bt.LINE:return new Lm(t);case Bt.SQUARE:return new Mm(t);case Bt.CIRCLE:return new Im(t);case Bt.POLYLINE:return new gf(t);case Bt.CARET:return new Dm(t);case Bt.INK:return new Sd(t);case Bt.POLYGON:return new Fm(t);case Bt.HIGHLIGHT:return new mf(t);case Bt.UNDERLINE:return new Om(t);case Bt.SQUIGGLY:return new Nm(t);case Bt.STRIKEOUT:return new Hm(t);case Bt.STAMP:return new bf(t);case Bt.FILEATTACHMENT:return new Bm(t);default:return new It(t)}}}var In,Kr,Qr,Lo,Pc;const Td=class Td{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){A(this,Lo);A(this,In,null);A(this,Kr,!1);A(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 Td._hasPopupData(this.data)}updateEdited(t){var s;if(!this.container)return;r(this,In)||p(this,In,{rect:this.data.rect.slice(0)});const{rect:e}=t;e&&m(this,Lo,Pc).call(this,e),(s=r(this,Qr))==null||s.popup.updateEdited(t)}resetEdited(){var t;r(this,In)&&(m(this,Lo,Pc).call(this,r(this,In).rect),(t=r(this,Qr))==null||t.popup.resetEdited(),p(this,In,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 lr||(n.tabIndex=dl);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 kc){const{rotation:y}=e;return!e.hasOwnCanvas&&y!==0&&this.setRotation(y,n),n}const{width:o,height:l}=oi(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 hf){const _=`calc(${o}px * var(--scale-factor)) / calc(${l}px * var(--scale-factor))`;a.borderRadius=_}switch(e.borderStyle.style){case Sa.SOLID:a.borderStyle="solid";break;case Sa.DASHED:a.borderStyle="dashed";break;case Sa.BEVELED:st("Unimplemented border style: beveled");break;case Sa.INSET:st("Unimplemented border style: inset");break;case Sa.UNDERLINE:a.borderBottomStyle="solid";break}const v=e.borderColor||null;v?(p(this,Kr,!0),a.borderColor=$.makeHexColor(v[0]|0,v[1]|0,v[2]|0)):a.borderWidth=0}const h=$.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:b}=e;return e.hasOwnCanvas||b===0?(a.width=`${100*o/d}%`,a.height=`${100*l/u}%`):this.setRotation(b,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}=oi(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]=Vd[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:Vd[`${a}_rgb`](o)})};return lt(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,Kr)){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"),b=`clippath_${this.data.id}`;g.setAttribute("id",b),g.setAttribute("clipPathUnits","objectBoundingBox"),f.append(g);for(let y=2,w=t.length;y`)}r(this,Kr)&&(o.push("')"),a.backgroundImage=o.join("")),this.container.append(u),this.container.style.clipPath=`url(#${b})`}_createPopup(){const{data:t}=this,e=p(this,Qr,new kc({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(){_t("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&&!sr.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&&sr.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})})}};In=new WeakMap,Kr=new WeakMap,Qr=new WeakMap,Lo=new WeakSet,Pc=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}=oi(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 It=Td;var Ne,Qi,of,lf;class af extends It{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});A(this,Ne);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,Ne,of).call(this,i,e.attachment,e.attachmentDest),n=!0):e.setOCGState?(m(this,Ne,lf).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,Ne,Qi).call(this)}_bindNamedAction(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),m(this,Ne,Qi).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,Ne,Qi).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),m(this,Ne,Qi).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 b=this._fieldObjects[g]||[];for(const{id:y}of b)f.add(y)}for(const g of Object.values(this._fieldObjects))for(const b of g)f.has(b.id)===o&&l.push(b)}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 b=document.querySelector(`[data-element-id="${g}"]`);if(b){if(!sr.has(b)){st(`_bindResetFormAction - element not allowed: ${g}`);continue}}else continue;b.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}}}Ne=new WeakSet,Qi=function(){this.container.setAttribute("data-internal-link","")},of=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,Ne,Qi).call(this)},lf=function(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),m(this,Ne,Qi).call(this)};class Sm extends It{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 lr extends It{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 be.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":$.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||_m,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/(Nh*i))||1,u=h/d;a=Math.min(i,l(u/Nh))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(i,l(h/Nh))}n.fontSize=`calc(${a}px * var(--scale-factor))`,n.color=$.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 xm extends lr{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),sr.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=dl,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:b}=g;d.userValue&&(b.value=d.userValue),d.lastCommittedValue=b.value,d.commitKey=1,(y=this.data.actions)!=null&&y.Focus||(d.focused=!0)}),s.addEventListener("updatefromsandbox",g=>{this.showElementAndHideCanvas(g.target);const b={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(b,g)}),s.addEventListener("keydown",g=>{var w;d.commitKey=1;let b=-1;if(g.key==="Escape"?b=0:g.key==="Enter"&&!this.data.multiLine?b=2:g.key==="Tab"&&(d.commitKey=3),b===-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:b,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:b}=g.target;d.userValue=b,d.lastCommittedValue!==b&&((w=this.linkService.eventBus)==null||w.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:b,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:b,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:b||"",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 Cm extends lr{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Tm extends lr{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 sr.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=dl,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 hf extends lr{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(sr.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=dl,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 Rm extends af{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 Pm extends lr{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");sr.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=dl;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,b=>b.selected).map(b=>b[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,b=new Set(Array.isArray(g)?g:[g]);for(const y of i.options)y.selected=b.has(y.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(f){i.multiple=!0},remove(f){const g=i.options,b=f.detail.remove;g[b].selected=!1,i.remove(b),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:b,exportValue:y}=f.detail.insert,w=i.children[g],v=document.createElement("option");v.textContent=b,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 b of g){const{displayValue:y,exportValue:w}=b,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 b of f.target.options)b.selected=g.has(b.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 kc extends It{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:It._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new km({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=>`${fd}${s}`).join(",")),this.container}}var Jr,Ah,yh,Zr,Fn,Pt,Vs,ta,Mo,Io,ea,qs,is,Xs,Fo,Ys,Do,Dn,On,At,Nl,Lc,cf,df,uf,ff,Hl,Bl,Mc;class km{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:a,richText:o,parent:l,rect:h,parentRect:d,open:u}){A(this,At);A(this,Jr,m(this,At,uf).bind(this));A(this,Ah,m(this,At,Mc).bind(this));A(this,yh,m(this,At,Bl).bind(this));A(this,Zr,m(this,At,Hl).bind(this));A(this,Fn,null);A(this,Pt,null);A(this,Vs,null);A(this,ta,null);A(this,Mo,null);A(this,Io,null);A(this,ea,null);A(this,qs,!1);A(this,is,null);A(this,Xs,null);A(this,Fo,null);A(this,Ys,null);A(this,Do,null);A(this,Dn,null);A(this,On,!1);var f;p(this,Pt,t),p(this,Do,i),p(this,Vs,a),p(this,Ys,o),p(this,Io,l),p(this,Fn,e),p(this,Fo,h),p(this,ea,d),p(this,Mo,s),p(this,ta,md.toDateObject(n)),this.trigger=s.flatMap(g=>g.getElementsToTriggerPopup());for(const g of this.trigger)g.addEventListener("click",r(this,Zr)),g.addEventListener("mouseenter",r(this,yh)),g.addEventListener("mouseleave",r(this,Ah)),g.classList.add("popupTriggerArea");for(const g of s)(f=g.container)==null||f.addEventListener("keydown",r(this,Jr));r(this,Pt).hidden=!0,u&&m(this,At,Hl).call(this)}render(){if(r(this,is))return;const t=p(this,is,document.createElement("div"));if(t.className="popup",r(this,Fn)){const n=t.style.outlineColor=$.makeHexColor(...r(this,Fn));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${n} 30%, white)`:t.style.backgroundColor=$.makeHexColor(...r(this,Fn).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,Do),t.append(e),r(this,ta)){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,ta).valueOf()})),e.append(n)}const i=r(this,At,Nl);if(i)rf.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const n=this._formatContents(r(this,Vs));t.append(n)}r(this,Pt).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,zo,Ic).call(this)}),!s.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return r(this,$o)}addHighlightArea(){this.container.classList.add("highlightArea")}}$o=new WeakMap,zo=new WeakSet,Ic=function(){var e;(e=this.downloadManager)==null||e.openOrDownloadData(this.content,this.filename)};var Go,Nn,Hn,Uo,nr,Af,Fc,nu;let jm=(nu=class{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:a,structTreeLayer:o}){A(this,nr);A(this,Go,null);A(this,Nn,null);A(this,Hn,new Map);A(this,Uo,null);this.div=t,p(this,Go,e),p(this,Nn,s),p(this,Uo,o||null),this.page=n,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return r(this,Hn).size>0}async render(t){var a;const{annotations:e}=t,s=this.div;tr(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 Ed,annotationStorage:t.annotationStorage||new Ad,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===Bt.POPUP;if(l){const u=i.get(o.id);if(!u)continue;n.elements=u}else{const{width:u,height:f}=oi(o.rect);if(u<=0||f<=0)continue}n.data=o;const h=Em.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,nr,Af).call(this,d,o.id),h._isEditable&&(r(this,Hn).set(h.data.id,h),(a=this._annotationEditorUIManager)==null||a.renderAnnotationElement(h))}m(this,nr,Fc).call(this)}update({viewport:t}){const e=this.div;this.viewport=t,tr(e,{rotation:t.rotation}),m(this,nr,Fc).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(r(this,Hn).values())}getEditableAnnotation(t){return r(this,Hn).get(t)}},Go=new WeakMap,Nn=new WeakMap,Hn=new WeakMap,Uo=new WeakMap,nr=new WeakSet,Af=async function(t,e){var a,o;const s=t.firstChild||t,i=s.id=`${fd}${e}`,n=await((a=r(this,Uo))==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,Go))==null||o.moveElementInDOM(this.div,t,s,!1)},Fc=function(){if(!r(this,Nn))return;const t=this.div;for(const[e,s]of r(this,Nn)){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,Nn).clear()},nu);const wl=/\r\n?|\n/g;var ns,ke,Wo,Bn,Le,Nt,yf,vf,wf,jl,hi,$l,zl,_f,Oc,Ef;const vt=class vt extends gt{constructor(e){super({...e,name:"freeTextEditor"});A(this,Nt);A(this,ns);A(this,ke,"");A(this,Wo,`${this.id}-editor`);A(this,Bn,null);A(this,Le);p(this,ns,e.color||vt._defaultColor||gt._defaultLineColor),p(this,Le,e.fontSize||vt._defaultFontSize)}static get _keyboardManager(){const e=vt.prototype,s=a=>a.isEmpty(),i=er.TRANSLATE_SMALL,n=er.TRANSLATE_BIG;return lt(this,"_keyboardManager",new cl([[["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){gt.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,Nt,yf).call(this,s);break;case K.FREETEXT_COLOR:m(this,Nt,vf).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[K.FREETEXT_SIZE,vt._defaultFontSize],[K.FREETEXT_COLOR,vt._defaultColor||gt._defaultLineColor]]}get propertiesToUpdate(){return[[K.FREETEXT_SIZE,r(this,Le)],[K.FREETEXT_COLOR,r(this,ns)]]}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-vt._internalPadding*e,-(vt._internalPadding+r(this,Le))*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,Bn,new AbortController);const e=this._uiManager.combinedSignal(r(this,Bn));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,Wo)),this._isDraggable=!0,(e=r(this,Bn))==null||e.abort(),p(this,Bn,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,ke),s=p(this,ke,m(this,Nt,wf).call(this).trimEnd());if(e===s)return;const i=n=>{if(p(this,ke,n),!n){this.remove();return}m(this,Nt,zl).call(this),this._uiManager.rebuild(this),m(this,Nt,jl).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),m(this,Nt,jl).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,Wo)),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,Le)}px * var(--scale-factor))`,i.color=r(this,ns),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),th(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 b,y;switch(this.rotation){case 0:b=e+(o[0]-f)/d,y=s+this.height-(o[1]-g)/u;break;case 90:b=e+(o[0]-f)/d,y=s-(o[1]-g)/u,[l,h]=[h,-l];break;case 180:b=e-this.width+(o[0]-f)/d,y=s-(o[1]-g)/u,[l,h]=[-l,-h];break;case 270:b=e+(o[0]-f-this.height*u)/d,y=s+(o[1]-g-this.width*d)/u,[l,h]=[-h,l];break}this.setAt(b*n,y*a,l,h)}else this.setAt(e*n,s*a,this.width*n,this.height*a);m(this,Nt,zl).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var b,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(b=vt,hi,Oc).call(b,s.getData("text")||"").replaceAll(wl,` +`);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(wl,"")),v!==this.editorDiv){let _=d;for(const S of this.editorDiv.childNodes){if(S===v){_=u;continue}_.push(m(y=vt,hi,$l).call(y,S))}}d.push(l.nodeValue.slice(0,h).replaceAll(wl,""))}else if(l===this.editorDiv){let v=d,_=0;for(const S of this.editorDiv.childNodes)_++===h&&(v=u),v.push(m(w=vt,hi,$l).call(w,S))}p(this,ke,`${d.join(` +`)}${n}${u.join(` +`)}`),m(this,Nt,zl).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 pf){const{data:{defaultAppearanceData:{fontSize:l,fontColor:h},rect:d,rotation:u,id:f,popupRef:g},textContent:b,textPosition:y,parent:{page:{pageNumber:w}}}=e;if(!b||b.length===0)return null;n=e={annotationType:tt.FREETEXT,color:Array.from(h),fontSize:l,value:b.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,Le,e.fontSize),p(a,ns,$.makeHexColor(...e.color)),p(a,ke,m(o=vt,hi,Oc).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=gt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:r(this,ns)),a={annotationType:tt.FREETEXT,color:n,fontSize:r(this,Le),value:m(this,Nt,_f).call(this),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?a:this.annotationElementId&&!m(this,Nt,Ef).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,Le)}px * var(--scale-factor))`,i.color=r(this,ns),s.replaceChildren();for(const a of r(this,ke).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,ke)}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};ns=new WeakMap,ke=new WeakMap,Wo=new WeakMap,Bn=new WeakMap,Le=new WeakMap,Nt=new WeakSet,yf=function(e){const s=n=>{this.editorDiv.style.fontSize=`calc(${n}px * var(--scale-factor))`,this.translate(0,-(n-r(this,Le))*this.parentScale),p(this,Le,n),m(this,Nt,jl).call(this)},i=r(this,Le);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})},vf=function(e){const s=n=>{p(this,ns,this.editorDiv.style.color=n)},i=r(this,ns);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})},wf=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,hi,$l).call(i,n)),s=n);return e.join(` +`)},jl=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()},hi=new WeakSet,$l=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(wl,"")},zl=function(){if(this.editorDiv.replaceChildren(),!!r(this,ke))for(const e of r(this,ke).split(` +`)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},_f=function(){return r(this,ke).replaceAll(" "," ")},Oc=function(e){return e.replaceAll(" "," ")},Ef=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},A(vt,hi),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 Dc=vt;class Sf{toSVGPath(){_t("Abstract method `toSVGPath` must be implemented.")}get box(){_t("Abstract getter `box` must be implemented.")}serialize(t,e){_t("Abstract method `serialize` must be implemented.")}get classNamesForDrawing(){_t("Abstract getter `classNamesForDrawing` must be implemented.")}get classNamesForOutlining(){_t("Abstract getter `classNamesForOutlining` must be implemented.")}get mustRemoveSelfIntersections(){return!1}}var Me,rs,sa,ia,Ss,rt,jn,$n,Vo,qo,na,ra,Ii,Xo,vh,wh,Ut,Oa,xf,Cf,Tf,Rf,Pf,kf;const Ds=class Ds{constructor({x:t,y:e},s,i,n,a,o=0){A(this,Ut);A(this,Me);A(this,rs,[]);A(this,sa);A(this,ia);A(this,Ss,[]);A(this,rt,new Float64Array(18));A(this,jn);A(this,$n);A(this,Vo);A(this,qo);A(this,na);A(this,ra);A(this,Ii,[]);p(this,Me,s),p(this,ra,n*i),p(this,ia,a),r(this,rt).set([NaN,NaN,NaN,NaN,t,e],6),p(this,sa,o),p(this,qo,r(Ds,Xo)*i),p(this,Vo,r(Ds,wh)*i),p(this,na,i),r(this,Ii).push(t,e)}isEmpty(){return isNaN(r(this,rt)[8])}add({x:t,y:e}){var k;p(this,jn,t),p(this,$n,e);const[s,i,n,a]=r(this,Me);let[o,l,h,d]=r(this,rt).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,Ut,Cf).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,n,a){return new Lf(t,e,s,i,n,a)}getOutlines(){var u;const t=r(this,Ss),e=r(this,rs),s=r(this,rt),[i,n,a,o]=r(this,Me),l=new Float64Array((((u=r(this,Ii))==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,Ut,Pf).call(this,h,d),this.newFreeDrawOutline(h,l,r(this,Me),r(this,na),r(this,sa),r(this,ia))}};Me=new WeakMap,rs=new WeakMap,sa=new WeakMap,ia=new WeakMap,Ss=new WeakMap,rt=new WeakMap,jn=new WeakMap,$n=new WeakMap,Vo=new WeakMap,qo=new WeakMap,na=new WeakMap,ra=new WeakMap,Ii=new WeakMap,Xo=new WeakMap,vh=new WeakMap,wh=new WeakMap,Ut=new WeakSet,Oa=function(){const t=r(this,rt).subarray(4,6),e=r(this,rt).subarray(16,18),[s,i,n,a]=r(this,Me);return[(r(this,jn)+(t[0]-e[0])/2-s)/n,(r(this,$n)+(t[1]-e[1])/2-i)/a,(r(this,jn)+(e[0]-t[0])/2-s)/n,(r(this,$n)+(e[1]-t[1])/2-i)/a]},xf=function(){const[t,e,s,i]=r(this,Me),[n,a,o,l]=m(this,Ut,Oa).call(this);return`M${(r(this,rt)[2]-t)/s} ${(r(this,rt)[3]-e)/i} L${(r(this,rt)[4]-t)/s} ${(r(this,rt)[5]-e)/i} L${n} ${a} L${o} ${l} L${(r(this,rt)[16]-t)/s} ${(r(this,rt)[17]-e)/i} L${(r(this,rt)[14]-t)/s} ${(r(this,rt)[15]-e)/i} Z`},Cf=function(t){const e=r(this,rs);t.push(`L${e[4]} ${e[5]} Z`)},Tf=function(t){const[e,s,i,n]=r(this,Me),a=r(this,rt).subarray(4,6),o=r(this,rt).subarray(16,18),[l,h,d,u]=m(this,Ut,Oa).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}`)},Rf=function(t){const e=r(this,rt),[s,i,n,a]=r(this,Me),[o,l,h,d]=m(this,Ut,Oa).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,Me),r(this,na),r(this,sa),r(this,ia))},Pf=function(t,e){const s=r(this,rs);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},kf=function(t,e){const s=r(this,rt).subarray(4,6),i=r(this,rt).subarray(16,18),[n,a,o,l]=r(this,Me),[h,d,u,f]=m(this,Ut,Oa).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},A(Ds,Xo,8),A(Ds,vh,2),A(Ds,wh,r(Ds,Xo)+r(Ds,vh));let sh=Ds;var aa,zn,Ks,Yo,Ie,Ko,Mt,Ce,Na,Ha,Mf;class Lf extends Sf{constructor(e,s,i,n,a,o){super();A(this,Ce);A(this,aa);A(this,zn,null);A(this,Ks);A(this,Yo);A(this,Ie);A(this,Ko);A(this,Mt);p(this,Mt,e),p(this,Ie,s),p(this,aa,i),p(this,Ko,n),p(this,Ks,a),p(this,Yo,o),m(this,Ce,Mf).call(this,o);const{x:l,y:h,width:d,height:u}=r(this,zn);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,Fi))e[3]?(t.push(...m(this,ye,Nc).call(this,e)),m(this,ye,Ff).call(this,e)):(m(this,ye,Df).call(this,e),t.push(...m(this,ye,Nc).call(this,e)));return m(this,ye,If).call(this,t)}}Qo=new WeakMap,Fi=new WeakMap,as=new WeakMap,ye=new WeakSet,If=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 b;if(s.has(d))b=d;else if(s.has(u))b=u;else break;s.delete(b),[o,l,h,d,u]=b,f!==o&&(n.push(f,g,o,g===l?l:h),f=o),g=g===l?h:l}n.push(f,g)}return new $m(i,r(this,Qo))},Gl=function(t){const e=r(this,as);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,as)[i];if(n!==t)break;if(n===t&&a===e){r(this,as).splice(i,1);return}}},Nc=function(t){const[e,s,i]=t,n=[[e,s,i]],a=m(this,ye,Gl).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 Jo,oa;class $m extends Sf{constructor(e,s){super();A(this,Jo);A(this,oa);p(this,oa,e),p(this,Jo,s)}toSVGPath(){const e=[];for(const s of r(this,oa)){let[i,n]=s;e.push(`M${i} ${n}`);for(let a=2;a-1?(p(this,Se,!0),m(this,J,Ul).call(this,e),m(this,J,Zi).call(this)):r(this,Qs)&&(p(this,da,e.anchorNode),p(this,il,e.anchorOffset),p(this,nl,e.focusNode),p(this,rl,e.focusOffset),m(this,J,zc).call(this),m(this,J,Zi).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const e=dt.prototype;return lt(this,"_keyboardManager",new cl([[["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,Se)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:r(this,Ge),methodOfCreation:r(this,al)}}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;gt.initialize(e,s),dt._defaultColor||(dt._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case K.HIGHLIGHT_DEFAULT_COLOR:dt._defaultColor=s;break;case K.HIGHLIGHT_THICKNESS:dt._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return r(this,fa)}updateParams(e,s){switch(e){case K.HIGHLIGHT_COLOR:m(this,J,Nf).call(this,s);break;case K.HIGHLIGHT_THICKNESS:m(this,J,Hf).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[K.HIGHLIGHT_DEFAULT_COLOR,dt._defaultColor],[K.HIGHLIGHT_THICKNESS,dt._defaultThickness]]}get propertiesToUpdate(){return[[K.HIGHLIGHT_COLOR,this.color||dt._defaultColor],[K.HIGHLIGHT_THICKNESS,r(this,Ge)||dt._defaultThickness],[K.HIGHLIGHT_FREE,r(this,Se)]]}async addEditToolbar(){const e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(p(this,ua,new ih({editor:this})),e.addColorPicker(r(this,ua))),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,J,Ba).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,m(this,J,Ba).call(this))}onceAdded(){this.annotationElementId||this.parent.addUndoableEditor(this),this.div.focus()}remove(){m(this,J,Gc).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(m(this,J,Zi).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?m(this,J,Gc).call(this):e&&(m(this,J,Zi).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,Se)?(e=(e-this.rotation+360)%360,i=m(n=dt,Ve,mr).call(n,r(this,hs).box,e)):i=m(a=dt,Ve,mr).call(a,this,e),s.rotate(r(this,oe),e),s.rotate(r(this,zt),e),s.updateBox(r(this,oe),i),s.updateBox(r(this,zt),m(o=dt,Ve,mr).call(o,r(this,ze).box,e))}render(){if(this.div)return this.div;const e=super.render();r(this,pa)&&(e.setAttribute("aria-label",r(this,pa)),e.setAttribute("role","mark")),r(this,Se)?e.classList.add("free"):this.div.addEventListener("keydown",m(this,J,jf).bind(this),{signal:this._uiManager._signal});const s=p(this,Wn,document.createElement("div"));e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=r(this,Un);const[i,n]=this.parentDimensions;return this.setDims(this.width*i,this.height*n),th(this,r(this,Wn),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){this.isSelected||this.parent.drawLayer.addClass(r(this,zt),"hovered")}pointerleave(){this.isSelected||this.parent.drawLayer.removeClass(r(this,zt),"hovered")}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:m(this,J,Wl).call(this,!0);break;case 1:case 3:m(this,J,Wl).call(this,!1);break}}select(){var e,s;super.select(),r(this,zt)&&((e=this.parent)==null||e.drawLayer.removeClass(r(this,zt),"hovered"),(s=this.parent)==null||s.drawLayer.addClass(r(this,zt),"selected"))}unselect(){var e;super.unselect(),r(this,zt)&&((e=this.parent)==null||e.drawLayer.removeClass(r(this,zt),"selected"),r(this,Se)||m(this,J,Wl).call(this,!1))}get _mustFixPosition(){return!r(this,Se)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.show(r(this,oe),e),this.parent.drawLayer.show(r(this,zt),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()},b=y=>{u.abort(),m(this,Ve,Uf).call(this,e,y)};window.addEventListener("blur",b,{signal:f}),window.addEventListener("pointerup",b,{signal:f}),window.addEventListener("pointerdown",g,{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",Xe,{signal:f}),i.addEventListener("pointermove",m(this,Ve,Gf).bind(this,e),{signal:f}),this._freeHighlight=new Hc({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 mf){const{data:{quadPoints:S,rect:E,rotation:C,id:x,color:T,opacity:P,popupRef:k},parent:{page:{pageNumber:B}}}=e;n=e={annotationType:tt.HIGHLIGHT,color:Array.from(T),opacity:P,quadPoints:S,boxes:null,pageIndex:B-1,rect:E.slice(0),rotation:C,id:x,deleted:!1,popupRef:k}}else if(e instanceof Sd){const{data:{inkLists:S,rect:E,rotation:C,id:x,color:T,borderStyle:{rawWidth:P},popupRef:k},parent:{page:{pageNumber:B}}}=e;n=e={annotationType:tt.HIGHLIGHT,color:Array.from(T),thickness:P,inkLists:S,boxes:null,pageIndex:B-1,rect:E.slice(0),rotation:C,id:x,deleted:!1,popupRef:k}}const{color:a,quadPoints:o,inkLists:l,opacity:h}=e,d=await super.deserialize(e,s,i);d.color=$.makeHexColor(...a),p(d,Js,h||1),l&&p(d,Ge,e.thickness),d.annotationElementId=e.id||null,d._initialData=n;const[u,f]=d.pageDimensions,[g,b]=d.pageTranslation;if(o){const S=p(d,Qs,[]);for(let E=0;E=0)p(this,oe,s),p(this,Un,i),this.parent.drawLayer.finalizeLine(s,e),p(this,zt,this.parent.drawLayer.drawOutline(r(this,ze)));else if(this.parent){const g=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(r(this,oe),e),this.parent.drawLayer.updateBox(r(this,oe),m(u=dt,Ve,mr).call(u,r(this,hs).box,(g-this.rotation+360)%360)),this.parent.drawLayer.updateLine(r(this,zt),r(this,ze)),this.parent.drawLayer.updateBox(r(this,zt),m(f=dt,Ve,mr).call(f,r(this,ze).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,b]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*b/g,this.height=h*g/b;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=h;break;case 270:{const[g,b]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*b/g,this.height=h*g/b;break}}const{lastPoint:d}=r(this,ze).box;p(this,fa,[(d[0]-a)/l,(d[1]-o)/h])},Nf=function(e){const s=(a,o)=>{var l,h,d;this.color=a,(l=this.parent)==null||l.drawLayer.changeColor(r(this,oe),a),(h=r(this,ua))==null||h.updateColor(a),p(this,Js,o),(d=this.parent)==null||d.drawLayer.changeOpacity(r(this,oe),o)},i=this.color,n=r(this,Js);this.addCommands({cmd:s.bind(this,e,dt._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)},Hf=function(e){const s=r(this,Ge),i=n=>{p(this,Ge,n),m(this,J,Bf).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)},Bf=function(e){if(!r(this,Se))return;m(this,J,Ul).call(this,{highlightOutlines:r(this,hs).getNewOutline(e/2)}),this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)},Gc=function(){r(this,oe)===null||!this.parent||(this.parent.drawLayer.remove(r(this,oe)),p(this,oe,null),this.parent.drawLayer.remove(r(this,zt)),p(this,zt,null))},Zi=function(e=this.parent){r(this,oe)===null&&({id:fe(this,oe)._,clipPathId:fe(this,Un)._}=e.drawLayer.draw(r(this,hs),this.color,r(this,Js)),p(this,zt,e.drawLayer.drawOutline(r(this,ze))),r(this,Wn)&&(r(this,Wn).style.clipPath=r(this,Un)))},Ve=new WeakSet,mr=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}},jf=function(e){dt._keyboardManager.exec(this,e)},Wl=function(e){if(!r(this,da))return;const s=window.getSelection();e?s.setPosition(r(this,da),r(this,il)):s.setPosition(r(this,nl),r(this,rl))},Ba=function(){return r(this,Se)?this.rotation:0},$f=function(){if(r(this,Se))return null;const[e,s]=this.pageDimensions,[i,n]=this.pageTranslation,a=r(this,Qs),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,b=(1-d-f)*s+n;o[l]=o[l+4]=g,o[l+1]=o[l+3]=b,o[l+2]=o[l+6]=g+u*e,o[l+5]=o[l+7]=b+f*s,l+=8}return o},zf=function(e){return r(this,hs).serialize(e,m(this,J,Ba).call(this))},Gf=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},Uf=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=""},Wf=function(e){const{color:s}=this._initialData;return e.color.some((i,n)=>i!==s[n])},A(dt,Ve),Y(dt,"_defaultColor",null),Y(dt,"_defaultOpacity",1),Y(dt,"_defaultThickness",12),Y(dt,"_type","highlight"),Y(dt,"_editorType",tt.HIGHLIGHT),Y(dt,"_freeHighlightId",-1),Y(dt,"_freeHighlight",null),Y(dt,"_freeHighlightClipId","");let nh=dt;var Vn,qn,xs,Zs,Ue,Xn,Yn,Kn,ti,ga,Qn,Jn,Oi,F,Vf,qf,Xf,Yf,Wc,Kf,Vc,Qf,Jf,Zf,tp,ep,tn,qc,Xc,Yc,Vl,ql,br,Kc,Xl,di,sp,Qc,ip,np,Jc,Yl,ja;const xt=class xt extends gt{constructor(e){super({...e,name:"inkEditor"});A(this,F);A(this,Vn,0);A(this,qn,0);A(this,xs,null);A(this,Zs,new Path2D);A(this,Ue,!1);A(this,Xn,null);A(this,Yn,!1);A(this,Kn,!1);A(this,ti,null);A(this,ga,null);A(this,Qn,0);A(this,Jn,0);A(this,Oi,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){gt.initialize(e,s)}static updateDefaultParams(e,s){switch(e){case K.INK_THICKNESS:xt._defaultThickness=s;break;case K.INK_COLOR:xt._defaultColor=s;break;case K.INK_OPACITY:xt._defaultOpacity=s/100;break}}updateParams(e,s){switch(e){case K.INK_THICKNESS:m(this,F,Vf).call(this,s);break;case K.INK_COLOR:m(this,F,qf).call(this,s);break;case K.INK_OPACITY:m(this,F,Xf).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[K.INK_THICKNESS,xt._defaultThickness],[K.INK_COLOR,xt._defaultColor||gt._defaultLineColor],[K.INK_OPACITY,Math.round(xt._defaultOpacity*100)]]}get propertiesToUpdate(){return[[K.INK_THICKNESS,this.thickness||xt._defaultThickness],[K.INK_COLOR,this.color||xt._defaultColor||gt._defaultLineColor],[K.INK_OPACITY,Math.round(100*(this.opacity??xt._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(m(this,F,Vl).call(this),m(this,F,ql).call(this)),this.isAttachedToDOM||(this.parent.add(this),m(this,F,br).call(this)),m(this,F,ja).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,xs)&&(clearTimeout(r(this,xs)),p(this,xs,null)),(e=r(this,ti))==null||e.disconnect(),p(this,ti,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,Ue)||this.canvas===null||(super.enableEditMode(),this._isDraggable=!1,m(this,F,qc).call(this))}disableEditMode(){!this.isInEditMode()||this.canvas===null||(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),m(this,F,Xc).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,Ue)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),p(this,Ue,!0),this.div.classList.add("disabled"),m(this,F,ja).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,Ue)||(this.setInForeground(),e.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),m(this,F,Kf).call(this,e.offsetX,e.offsetY))}canvasPointermove(e){e.preventDefault(),m(this,F,Vc).call(this,e.offsetX,e.offsetY)}canvasPointerup(e){e.preventDefault(),m(this,F,Yc).call(this,e)}canvasPointerleave(e){m(this,F,Yc).call(this,e)}get isResizable(){return!this.isEmpty()&&r(this,Ue)}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,F,Yf).call(this);if(this.setAt(i,n,0,0),this.setDims(a,o),m(this,F,Vl).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,Kn,!0),m(this,F,br).call(this),this.setDims(this.width*l,this.height*h),m(this,F,tn).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return m(this,F,ql).call(this),this.div}setDimensions(e,s){const i=Math.round(e),n=Math.round(s);if(r(this,Qn)===i&&r(this,Jn)===n)return;p(this,Qn,i),p(this,Jn,n),this.canvas.style.visibility="hidden";const[a,o]=this.parentDimensions;this.width=e/a,this.height=s/o,this.fixAndSetPosition(),r(this,Ue)&&m(this,F,Kc).call(this,e,s),m(this,F,br).call(this),m(this,F,tn).call(this),this.canvas.style.visibility="visible",this.fixDims()}static async deserialize(e,s,i){var w,v,_;if(e instanceof Sd)return null;const n=await super.deserialize(e,s,i);n.thickness=e.thickness,n.color=$.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,Ue,!0),p(n,Qn,Math.round(l)),p(n,Jn,Math.round(h));const{paths:f,rect:g,rotation:b}=e;for(let{bezier:S}of f){S=m(w=xt,di,ip).call(w,S,g,b);const E=[];n.paths.push(E);let C=d*(S[0]-u),x=d*(S[1]-u);for(let P=2,k=S.length;P{this.thickness=n,m(this,F,ja).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})},qf=function(e){const s=n=>{this.color=n,m(this,F,tn).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})},Xf=function(e){const s=n=>{this.opacity=n,m(this,F,tn).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})},Yf=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]}},Wc=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}${cg(i)}`},Kf=function(e,s){this.canvas.addEventListener("contextmenu",Xe,{signal:this._uiManager._signal}),m(this,F,Xc).call(this),p(this,Xn,new AbortController);const i=this._uiManager.combinedSignal(r(this,Xn));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,Kn)||(p(this,Kn,!0),m(this,F,br).call(this),this.thickness||(this.thickness=xt._defaultThickness),this.color||(this.color=xt._defaultColor||gt._defaultLineColor),this.opacity??(this.opacity=xt._defaultOpacity)),this.currentPath.push([e,s]),p(this,Yn,!1),m(this,F,Wc).call(this),p(this,Oi,()=>{m(this,F,Zf).call(this),r(this,Oi)&&window.requestAnimationFrame(r(this,Oi))}),window.requestAnimationFrame(r(this,Oi))},Vc=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,Zs);if(a.push([e,s]),p(this,Yn,!0),a.length<=2){o.moveTo(...a[0]),o.lineTo(e,s);return}a.length===3&&(p(this,Zs,o=new Path2D),o.moveTo(...a[0])),m(this,F,tp).call(this,o,...a.at(-3),...a.at(-2),e,s)},Qf=function(){if(this.currentPath.length===0)return;const e=this.currentPath.at(-1);r(this,Zs).lineTo(...e)},Jf=function(e,s){p(this,Oi,null),e=Math.min(Math.max(e,0),this.canvas.width),s=Math.min(Math.max(s,0),this.canvas.height),m(this,F,Vc).call(this,e,s),m(this,F,Qf).call(this);let i;if(this.currentPath.length!==1)i=m(this,F,ep).call(this);else{const h=[e,s];i=[[h,h.slice(),h.slice(),h]]}const n=r(this,Zs),a=this.currentPath;this.currentPath=[],p(this,Zs,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,F,Vl).call(this),m(this,F,ql).call(this)),m(this,F,ja).call(this))};this.addCommands({cmd:o,undo:l,mustExec:!0})},Zf=function(){if(!r(this,Yn))return;p(this,Yn,!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,Zs)),a.restore()},tp=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)},ep=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,xs,null),this.canvas.removeEventListener("contextmenu",Xe)},10)),m(this,F,Jf).call(this,e.offsetX,e.offsetY),this.addToAnnotationStorage(),this.setInBackground()},Vl=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")},ql=function(){p(this,ti,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&this.setDimensions(s.width,s.height)})),r(this,ti).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var e;(e=r(this,ti))==null||e.disconnect(),p(this,ti,null)},{once:!0})},br=function(){if(!r(this,Kn))return;const[e,s]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*e),this.canvas.height=Math.ceil(this.height*s),m(this,F,Xl).call(this)},Kc=function(e,s){const i=m(this,F,Yl).call(this),n=(e-i)/r(this,qn),a=(s-i)/r(this,Vn);this.scaleFactor=Math.min(n,a)},Xl=function(){const e=m(this,F,Yl).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+e,this.translationY*this.scaleFactor+e)},di=new WeakSet,sp=function(e){const s=new Path2D;for(let i=0,n=e.length;i`image/${s}`))}static get supportedTypesStr(){return lt(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,te)&&(p(this,Tt,null),this._uiManager.imageManager.deleteId(r(this,te)),(e=r(this,Cs))==null||e.remove(),p(this,Cs,null),(s=r(this,si))==null||s.disconnect(),p(this,si,null),r(this,Ts)&&(clearTimeout(r(this,Ts)),p(this,Ts,null))),super.remove()}rebuild(){if(!this.parent){r(this,te)&&m(this,ot,Kl).call(this);return}super.rebuild(),this.div!==null&&(r(this,te)&&r(this,Cs)===null&&m(this,ot,Kl).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(r(this,Ni)||r(this,Tt)||r(this,ei)||r(this,Hi)||r(this,te))}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,Tt)?m(this,ot,td).call(this):m(this,ot,Kl).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,Tt),o=new Yh;let l=r(this,Tt),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 b=u.width=Math.ceil(h*o.sx),y=u.height=Math.ceil(d*o.sy);r(this,Fe)||(l=m(this,ot,Ql).call(this,b,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,b,y),w.drawImage(l,0,0,l.width,l.height,0,0,b,y)}let f=null;if(i){let b,y;if(o.symmetric&&l.widthe||a>e){const _=Math.min(e/n,e/a);b=Math.floor(n*_),y=Math.floor(a*_),r(this,Fe)||(l=m(this,ot,Ql).call(this,b,y))}const v=new OffscreenCanvas(b,y).getContext("2d",{willReadFrequently:!0});v.drawImage(l,0,0,l.width,l.height,0,0,b,y),f={width:b,height:y,data:v.getImageData(0,0,b,y).data}}return{canvas:u,width:h,height:d,imageData:f}}getImageForAltText(){return r(this,Cs)}static async deserialize(e,s,i){var y;let n=null;if(e instanceof bf){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 k=((y=await s._structTree.getAriaAttributes(`${fd}${_}`))==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:k},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,te,d),l&&p(a,Tt,l)):p(a,ei,h),p(a,Fe,u);const[g,b]=a.pageDimensions;return a.width=(o[2]-o[0])/g,a.height=(o[3]-o[1])/b,a.annotationElementId=e.id||null,f&&(a.altTextData=f),a._initialData=n,p(a,ba,!!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,te),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:r(this,Fe),structTreeParentId:this._structTreeParentId};if(e)return i.bitmapUrl=m(this,ot,Jl).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,ot,op).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,Fe)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(r(this,te)))s.stamps.set(r(this,te),{area:o,serialized:i}),i.bitmap=m(this,ot,Jl).call(this,!1);else if(r(this,Fe)){const l=s.stamps.get(r(this,te));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=m(this,ot,Jl).call(this,!1))}return i}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}};Tt=new WeakMap,te=new WeakMap,Ni=new WeakMap,ei=new WeakMap,Hi=new WeakMap,ma=new WeakMap,Cs=new WeakMap,si=new WeakMap,Ts=new WeakMap,Fe=new WeakMap,ba=new WeakMap,ot=new WeakSet,$a=function(e,s=!1){if(!e){this.remove();return}p(this,Tt,e.bitmap),s||(p(this,te,e.id),p(this,Fe,e.isSvg)),e.file&&p(this,ma,e.file.name),m(this,ot,td).call(this)},za=function(){if(p(this,Ni,null),this._uiManager.enableWaiting(!1),!!r(this,Cs)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&r(this,Tt)){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&r(this,Tt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Kl=function(){if(r(this,te)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(r(this,te)).then(i=>m(this,ot,$a).call(this,i,!0)).finally(()=>m(this,ot,za).call(this));return}if(r(this,ei)){const i=r(this,ei);p(this,ei,null),this._uiManager.enableWaiting(!0),p(this,Ni,this._uiManager.imageManager.getFromUrl(i).then(n=>m(this,ot,$a).call(this,n)).finally(()=>m(this,ot,za).call(this)));return}if(r(this,Hi)){const i=r(this,Hi);p(this,Hi,null),this._uiManager.enableWaiting(!0),p(this,Ni,this._uiManager.imageManager.getFromFile(i).then(n=>m(this,ot,$a).call(this,n)).finally(()=>m(this,ot,za).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=Wa.supportedTypesStr;const s=this._uiManager._signal;p(this,Ni,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,ot,$a).call(this,n)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>m(this,ot,za).call(this))),e.click()},td=function(){const{div:e}=this;let{width:s,height:i}=r(this,Tt);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,Cs,document.createElement("canvas"));d.setAttribute("role","img"),this.addContainer(d),(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),m(this,ot,ed).call(this,s,i),m(this,ot,ap).call(this),r(this,ba)||(this.parent.addUndoableEditor(this),p(this,ba,!0)),this._reportTelemetry({action:"inserted_image"}),r(this,ma)&&d.setAttribute("aria-label",r(this,ma))},rp=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,Ts)!==null&&clearTimeout(r(this,Ts)),p(this,Ts,setTimeout(()=>{p(this,Ts,null),m(this,ot,ed).call(this,e,s)},200))},Ql=function(e,s){const{width:i,height:n}=r(this,Tt);let a=i,o=n,l=r(this,Tt);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},ed=function(e,s){const i=new Yh,n=Math.ceil(e*i.sx),a=Math.ceil(s*i.sy),o=r(this,Cs);if(!o||o.width===n&&o.height===a)return;o.width=n,o.height=a;const l=r(this,Fe)?r(this,Tt):m(this,ot,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)},Jl=function(e){if(e){if(r(this,Fe)){const n=this._uiManager.imageManager.getSvgUrl(r(this,te));if(n)return n}const s=document.createElement("canvas");return{width:s.width,height:s.height}=r(this,Tt),s.getContext("2d").drawImage(r(this,Tt),0,0),s.toDataURL()}if(r(this,Fe)){const[s,i]=this.pageDimensions,n=Math.round(this.width*s*zi.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*zi.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(n,a);return o.getContext("2d").drawImage(r(this,Tt),0,0,r(this,Tt).width,r(this,Tt).height,0,0,n,a),o.transferToImageBitmap()}return structuredClone(r(this,Tt))},ap=function(){this._uiManager._signal&&(p(this,si,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&m(this,ot,rp).call(this,s.width,s.height)})),r(this,si).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var e;(e=r(this,si))==null||e.disconnect(),p(this,si,null)},{once:!0}))},op=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(Wa,"_type","stamp"),Y(Wa,"_editorType",tt.STAMP);let Zc=Wa;var Zn,Aa,Rs,Bi,ii,De,ji,ya,va,le,ni,U,$i,ee,lp,id,nd,rd,Zl;const Ye=class Ye{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:n,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:d}){A(this,ee);A(this,Zn);A(this,Aa,!1);A(this,Rs,null);A(this,Bi,null);A(this,ii,null);A(this,De,new Map);A(this,ji,!1);A(this,ya,!1);A(this,va,!1);A(this,le,null);A(this,ni,null);A(this,U);const u=[...r(Ye,$i).values()];if(!Ye._initialized){Ye._initialized=!0;for(const f of u)f.initialize(d,t)}t.registerEditorTypes(u),p(this,U,t),this.pageIndex=e,this.div=s,p(this,Zn,n),p(this,Rs,a),this.viewport=h,p(this,le,l),this.drawLayer=o,this._structTree=i,r(this,U).addLayer(this)}get isEmpty(){return r(this,De).size===0}get isInvisible(){return this.isEmpty&&r(this,U).getMode()===tt.NONE}updateToolbar(t){r(this,U).updateToolbar(t)}updateMode(t=r(this,U).getMode()){switch(m(this,ee,Zl).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(Ye,$i).values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=r(this,le))==null?void 0:e.div)}addInkEditorIfNeeded(t){if(r(this,U).getMode()!==tt.INK)return;if(!t){for(const s of r(this,De).values())if(s.isEmpty()){s.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}setEditingState(t){r(this,U).setEditingState(t)}addCommands(t){r(this,U).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,Rs))==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,De).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(r(this,U).removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!r(this,Rs))return;const e=r(this,Rs).getEditableAnnotations();for(const s of e){if(s.hide(),r(this,U).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,va,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const n of r(this,De).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,Rs)){const n=r(this,Rs).getEditableAnnotations();for(const a of n){const{id:o}=a.data;if(r(this,U).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,U).addChangedExistingAnnotation(l),l.renderAnnotationElement(a)&&l.show(!1)),a.show()}}m(this,ee,Zl).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const n of r(Ye,$i).values())s.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),p(this,va,!1)}getEditableAnnotation(t){var e;return((e=r(this,Rs))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){r(this,U).getActive()!==t&&r(this,U).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=r(this,le))!=null&&t.div&&!r(this,ni)){p(this,ni,new AbortController);const e=r(this,U).combinedSignal(r(this,ni));r(this,le).div.addEventListener("pointerdown",m(this,ee,lp).bind(this),{signal:e}),r(this,le).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=r(this,le))!=null&&t.div&&r(this,ni)&&(r(this,ni).abort(),p(this,ni,null),r(this,le).div.classList.remove("highlighting"))}enableClick(){if(r(this,Bi))return;p(this,Bi,new AbortController);const t=r(this,U).combinedSignal(r(this,Bi));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,Bi))==null||t.abort(),p(this,Bi,null)}attach(t){r(this,De).set(t.id,t);const{annotationElementId:e}=t;e&&r(this,U).isDeletedAnnotationElement(e)&&r(this,U).removeDeletedAnnotationElement(t)}detach(t){var e;r(this,De).delete(t.id),(e=r(this,Zn))==null||e.removePointerInTextLayer(t.contentDiv),!r(this,va)&&t.annotationElementId&&r(this,U).addDeletedAnnotationElement(t)}remove(t){this.detach(t),r(this,U).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1,r(this,ya)||this.addInkEditorIfNeeded(!1)}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(r(this,U).addDeletedAnnotationElement(t.annotationElementId),gt.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,U).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),r(this,U).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!r(this,ii)&&(t._focusEventsAllowed=!1,p(this,ii,setTimeout(()=>{p(this,ii,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:r(this,U)._signal}),e.focus())},0))),t._structTreeParentId=(s=r(this,Zn))==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,U).getId()}combinedSignal(t){return r(this,U).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=r(this,ee,id))==null?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){r(this,U).updateToolbar(t),r(this,U).updateMode(t);const{offsetX:s,offsetY:i}=m(this,ee,rd).call(this),n=this.getNextId(),a=m(this,ee,nd).call(this,{parent:this,id:n,x:s,y:i,uiManager:r(this,U),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){var e;return await((e=r(Ye,$i).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,r(this,U)))||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),n=m(this,ee,nd).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:r(this,U),isCentered:e,...s});return n&&this.add(n),n}addNewEditor(){this.createAndAddNewEditor(m(this,ee,rd).call(this),!0)}setSelected(t){r(this,U).setSelected(t)}toggleSelected(t){r(this,U).toggleSelected(t)}unselect(t){r(this,U).unselect(t)}pointerup(t){const{isMac:e}=be.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&r(this,ji)){if(p(this,ji,!1),!r(this,Aa)){p(this,Aa,!0);return}if(r(this,U).getMode()===tt.STAMP){r(this,U).unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(r(this,U).getMode()===tt.HIGHLIGHT&&this.enableTextSelection(),r(this,ji)){p(this,ji,!1);return}const{isMac:e}=be.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;p(this,ji,!0);const s=r(this,U).getActive();p(this,Aa,!s||s.isEmpty())}findNewParent(t,e,s){const i=r(this,U).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}destroy(){var t,e;((t=r(this,U).getActive())==null?void 0:t.parent)===this&&(r(this,U).commitOrRemove(),r(this,U).setActiveEditor(null)),r(this,ii)&&(clearTimeout(r(this,ii)),p(this,ii,null));for(const s of r(this,De).values())(e=r(this,Zn))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,r(this,De).clear(),r(this,U).removeLayer(this)}render({viewport:t}){this.viewport=t,tr(this.div,t);for(const e of r(this,U).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){r(this,U).commitOrRemove(),m(this,ee,Zl).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,tr(this.div,{rotation:s}),e!==s)for(const i of r(this,De).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,U).viewParameters.realScale}};Zn=new WeakMap,Aa=new WeakMap,Rs=new WeakMap,Bi=new WeakMap,ii=new WeakMap,De=new WeakMap,ji=new WeakMap,ya=new WeakMap,va=new WeakMap,le=new WeakMap,ni=new WeakMap,U=new WeakMap,$i=new WeakMap,ee=new WeakSet,lp=function(t){r(this,U).unselectAll();const{target:e}=t;if(e===r(this,le).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&r(this,le).div.contains(e)){const{isMac:s}=be.platform;if(t.button!==0||t.ctrlKey&&s)return;r(this,U).showAllEditors("highlight",!0,!0),r(this,le).div.classList.add("free"),this.toggleDrawing(),nh.startHighlighting(this,r(this,U).direction==="ltr",{target:r(this,le).div,x:t.x,y:t.y}),r(this,le).div.addEventListener("pointerup",()=>{r(this,le).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:r(this,U)._signal}),t.preventDefault()}},id=function(){return r(Ye,$i).get(r(this,U).getMode())},nd=function(t){const e=r(this,ee,id);return e?new e.prototype.constructor(t):null},rd=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}},Zl=function(){p(this,ya,!0);for(const t of r(this,De).values())t.isEmpty()&&t.remove();p(this,ya,!1)},Y(Ye,"_initialized",!1),A(Ye,$i,new Map([Dc,Uc,Zc,nh].map(t=>[t._editorType,t])));let sd=Ye;var Ps,ol,Ot,ri,ll,od,rr,ld,hp;const Qt=class Qt{constructor({pageIndex:t}){A(this,rr);A(this,Ps,null);A(this,ol,0);A(this,Ot,new Map);A(this,ri,new Map);this.pageIndex=t}setParent(t){if(!r(this,Ps)){p(this,Ps,t);return}if(r(this,Ps)!==t){if(r(this,Ot).size>0)for(const e of r(this,Ot).values())e.remove(),t.append(e);p(this,Ps,t)}}static get _svgFactory(){return lt(this,"_svgFactory",new Ed)}draw(t,e,s,i=!1){const n=fe(this,ol)._++,a=m(this,rr,ld).call(this,t.box);a.classList.add(...t.classNamesForDrawing);const o=Qt._svgFactory.createElement("defs");a.append(o);const l=Qt._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,ri).set(n,l);const d=m(this,rr,hp).call(this,o,h),u=Qt._svgFactory.createElement("use");return a.append(u),a.setAttribute("fill",e),a.setAttribute("fill-opacity",s),u.setAttribute("href",`#${h}`),r(this,Ot).set(n,a),{id:n,clipPathId:`url(#${d})`}}drawOutline(t){const e=fe(this,ol)._++,s=m(this,rr,ld).call(this,t.box);s.classList.add(...t.classNamesForOutlining);const i=Qt._svgFactory.createElement("defs");s.append(i);const n=Qt._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=Qt._svgFactory.createElement("mask");i.append(d),o=`mask_p${this.pageIndex}_${e}`,d.setAttribute("id",o),d.setAttribute("maskUnits","objectBoundingBox");const u=Qt._svgFactory.createElement("rect");d.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");const f=Qt._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=Qt._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,Ot).set(e,s),e}finalizeLine(t,e){const s=r(this,ri).get(t);r(this,ri).delete(t),this.updateBox(t,e.box),s.setAttribute("d",e.toSVGPath())}updateLine(t,e){r(this,Ot).get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}updatePath(t,e){r(this,ri).get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){var s;m(s=Qt,ll,od).call(s,r(this,Ot).get(t),e)}show(t,e){r(this,Ot).get(t).classList.toggle("hidden",!e)}rotate(t,e){r(this,Ot).get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){r(this,Ot).get(t).setAttribute("fill",e)}changeOpacity(t,e){r(this,Ot).get(t).setAttribute("fill-opacity",e)}addClass(t,e){r(this,Ot).get(t).classList.add(e)}removeClass(t,e){r(this,Ot).get(t).classList.remove(e)}getSVGRoot(t){return r(this,Ot).get(t)}remove(t){r(this,ri).delete(t),r(this,Ps)!==null&&(r(this,Ot).get(t).remove(),r(this,Ot).delete(t))}destroy(){p(this,Ps,null);for(const t of r(this,Ot).values())t.remove();r(this,Ot).clear(),r(this,ri).clear()}};Ps=new WeakMap,ol=new WeakMap,Ot=new WeakMap,ri=new WeakMap,ll=new WeakSet,od=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}%`},rr=new WeakSet,ld=function(t){var s;const e=Qt._svgFactory.create(1,1,!0);return r(this,Ps).append(e),e.setAttribute("aria-hidden",!0),m(s=Qt,ll,od).call(s,e,t),e},hp=function(t,e){const s=Qt._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=Qt._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i},A(Qt,ll);let ad=Qt;Q.AbortException;Q.AnnotationEditorLayer;Q.AnnotationEditorParamsType;Q.AnnotationEditorType;Q.AnnotationEditorUIManager;var cp=Q.AnnotationLayer,dp=Q.AnnotationMode;Q.ColorPicker;Q.DOMSVGFactory;Q.DrawLayer;Q.FeatureTest;var Lh=Q.GlobalWorkerOptions;Q.ImageKind;Q.InvalidPDFException;Q.MissingPDFException;Q.OPS;Q.OutputScale;var Gm=Q.PDFDataRangeTransport;Q.PDFDateString;Q.PDFWorker;Q.PasswordResponses;Q.PermissionFlag;Q.PixelsPerInch;Q.RenderingCancelledException;var up=Q.TextLayer;Q.UnexpectedResponseException;Q.Util;Q.VerbosityLevel;Q.XfaLayer;Q.build;Q.createValidAbsoluteUrl;Q.fetchData;var fp=Q.getDocument;Q.getFilenameFromUrl;Q.getPdfFilenameFromUrl;Q.getXfaPageViewport;Q.isDataScheme;Q.isPdfFile;Q.noContextMenu;Q.normalizeUnicode;Q.setLayerDimensions;Q.shadow;var hd=Q.version;const Um=Object.freeze(Object.defineProperty({__proto__:null,AnnotationLayer:cp,AnnotationMode:dp,GlobalWorkerOptions:Lh,PDFDataRangeTransport:Gm,TextLayer:up,getDocument:fp,version:hd},Symbol.toStringTag,{value:"Module"}));var Wt=function(c,t,e){if(e||arguments.length===2)for(var s=0,i=t.length,n;s{yt(this.pdfDocument),yt(t),typeof t=="string"?this.pdfDocument.getDestination(t).then(e):Array.isArray(t)?e(t):t.then(e)}).then(e=>{yt(Array.isArray(e));const s=e[0];new Promise(i=>{yt(this.pdfDocument),s instanceof Object?this.pdfDocument.getPageIndex(s).then(n=>{i(n)}).catch(()=>{yt(!1)}):typeof s=="number"?i(s):yt(!1)}).then(i=>{const n=i+1;yt(this.pdfViewer),yt(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;yt(this.pdfViewer),yt(t>=1&&t<=this.pagesCount),this.pdfViewer.scrollPageIntoView({pageIndex:e,pageNumber:t})}addLinkAttributes(t,e,s){t.href=e,t.rel=this.externalLinkRel||fb,t.target=s?"_blank":this.externalLinkTarget||""}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}setHash(){}executeNamedAction(){}cachePageRef(){}isPageVisible(){return!0}isPageCached(){return!0}executeSetOCGState(){}}const Kd={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},Mh=typeof window<"u",mp=Mh&&window.location.protocol==="file:";function gb(c){return typeof c<"u"}function Ki(c){return gb(c)&&c!==null}function mb(c){return typeof c=="string"}function bb(c){return c instanceof ArrayBuffer}function Ab(c){return yt(Mh),c instanceof Blob}function cd(c){return mb(c)&&/^data:/.test(c)}function Qd(c){yt(cd(c));const[t="",e=""]=c.split(",");return t.split(";").indexOf("base64")!==-1?atob(e):unescape(e)}function yb(){return Mh&&window.devicePixelRatio||1}const bp="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function Jd(){he(!mp,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${bp}`)}function vb(){he(!mp,`Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${bp}`)}function ir(c){c!=null&&c.cancel&&c.cancel()}function dd(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 wb(c){return c.name==="RenderingCancelledException"}function _b(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 Eb(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 wa(){return R.useReducer(Eb,{value:void 0,error:void 0})}var Sb=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())})},Zd=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 Kd.NEED_PASSWORD:{const e=prompt("Enter the password to open this PDF file.");c(e);break}case Kd.INCORRECT_PASSWORD:{const e=prompt("Invalid password. Please try again.");c(e);break}}};function tu(c){return typeof c=="object"&&c!==null&&("data"in c||"range"in c||"url"in c)}const Tb=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:b,onLoadProgress:y,onLoadSuccess:w,onPassword:v=Cb,onSourceError:_,onSourceSuccess:S,options:E,renderMode:C,rotate:x}=t,T=Zd(t,["children","className","error","externalLinkRel","externalLinkTarget","file","inputRef","imageResourcesPath","loading","noData","onItemClick","onLoadError","onLoadProgress","onLoadSuccess","onPassword","onSourceError","onSourceSuccess","options","renderMode","rotate"]);const[P,k]=wa(),{value:B,error:O}=P,[X,W]=wa(),{value:G,error:V}=X,q=R.useRef(new pb),H=R.useRef([]),z=R.useRef(void 0),Lt=R.useRef(void 0);l&&l!==z.current&&tu(l)&&(he(!wr(l,z.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.`),z.current=l),E&&E!==Lt.current&&(he(!wr(E,Lt.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.`),Lt.current=E);const Ft=R.useRef({scrollPageIntoView:L=>{const{dest:j,pageNumber:Z,pageIndex:at=Z-1}=L;if(g){g({dest:j,pageIndex:at,pageNumber:Z});return}const Ht=H.current[at];if(Ht){Ht.scrollIntoView();return}he(!1,`An internal link leading to page ${Z} 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:Ft}),[]);function Et(){S&&S()}function ct(){O&&(he(!1,O.toString()),_&&_(O))}function M(){k({type:"RESET"})}R.useEffect(M,[l,k]);const ht=R.useCallback(()=>Sb(this,void 0,void 0,function*(){if(!l)return null;if(typeof l=="string")return cd(l)?{data:Qd(l)}:(Jd(),{url:l});if(l instanceof xb)return{range:l};if(bb(l))return{data:l};if(Mh&&Ab(l))return{data:yield _b(l)};if(yt(typeof l=="object"),yt(tu(l)),"url"in l&&typeof l.url=="string"){if(cd(l.url)){const{url:L}=l,j=Zd(l,["url"]),Z=Qd(L);return Object.assign({data:Z},j)}Jd()}return l}),[l]);R.useEffect(()=>{const L=ul(ht());return L.promise.then(j=>{k({type:"RESOLVE",value:j})}).catch(j=>{k({type:"REJECT",error:j})}),()=>{ir(L)}},[ht,k]),R.useEffect(()=>{if(!(typeof B>"u")){if(B===!1){ct();return}Et()}},[B]);function wt(){G&&(w&&w(G),H.current=new Array(G.numPages),q.current.setDocument(G))}function it(){V&&(he(!1,V.toString()),b&&b(V))}R.useEffect(function(){W({type:"RESET"})},[W,B]),R.useEffect(function(){if(!B)return;const j=E?Object.assign(Object.assign({},B),E):B,Z=fp(j);y&&(Z.onProgress=y),v&&(Z.onPassword=v);const at=Z,Ht=at.promise.then(se=>{W({type:"RESOLVE",value:se})}).catch(se=>{at.destroyed||W({type:"REJECT",error:se})});return()=>{Ht.finally(()=>at.destroy())}},[E,W,B]),R.useEffect(()=>{if(!(typeof G>"u")){if(G===!1){it();return}wt()}},[G]),R.useEffect(function(){q.current.setViewer(Ft.current),q.current.setExternalLinkRel(a),q.current.setExternalLinkTarget(o)},[a,o]);const nt=R.useCallback((L,j)=>{H.current[L]=j},[]),de=R.useCallback(L=>{delete H.current[L]},[]),ue=R.useMemo(()=>({imageResourcesPath:d,linkService:q.current,onItemClick:g,pdf:G,registerPage:nt,renderMode:C,rotate:x,unregisterPage:de}),[d,g,G,nt,C,x,de]),mt=R.useMemo(()=>pp(T,()=>G),[T,G]);function qi(){return I.jsx(gp.Provider,{value:ue,children:s})}function Xi(){return l?G==null?I.jsx(_r,{type:"loading",children:typeof u=="function"?u():u}):G===!1?I.jsx(_r,{type:"error",children:typeof n=="function"?n():n}):qi():I.jsx(_r,{type:"no-data",children:typeof f=="function"?f():f})}return I.jsx("div",Object.assign({className:_h("react-pdf__Document",i),ref:h,style:{"--scale-factor":"1"}},mt,{children:Xi()}))});function Ap(){return R.useContext(gp)}function yp(){for(var c=[],t=0;tLb(t),[t]),s=R.useMemo(()=>!Ih(t)||_p(t)?null:t.children.map((i,n)=>I.jsx(Sp,{node:i},n)),[t]);return I.jsx("span",Object.assign({className:c},e,{children:s}))}function Fh(){return R.useContext(vp)}function Mb(){const c=Fh();yt(c);const{onGetStructTreeError:t,onGetStructTreeSuccess:e}=c,[s,i]=wa(),{value:n,error:a}=s,{customTextRenderer:o,page:l}=c;function h(){n&&e&&e(n)}function d(){a&&(he(!1,a.toString()),t&&t(a))}return R.useEffect(function(){i({type:"RESET"})},[i,l]),R.useEffect(function(){if(o||!l)return;const f=ul(l.getStructTree()),g=f;return f.promise.then(b=>{i({type:"RESOLVE",value:b})}).catch(b=>{i({type:"REJECT",error:b})}),()=>ir(g)},[o,l,i]),R.useEffect(()=>{if(n!==void 0){if(n===!1){d();return}h()}},[n]),n?I.jsx(Sp,{className:"react-pdf__Page__structTree structTree",node:n}):null}const eu=dp;function Ib(c){const t=Fh();yt(t);const e=Object.assign(Object.assign({},t),c),{_className:s,canvasBackground:i,devicePixelRatio:n=yb(),onRenderError:a,onRenderSuccess:o,page:l,renderForms:h,renderTextLayer:d,rotate:u,scale:f}=e,{canvasRef:g}=c;yt(l);const b=R.useRef(null);function y(){l&&o&&o(dd(l,f))}function w(E){wb(E)||(he(!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}=b;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?eu.ENABLE_FORMS:eu.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),()=>ir(P)},[i,l,h,v,_]);const S=R.useCallback(()=>{const{current:E}=b;E&&(E.width=0,E.height=0)},[]);return R.useEffect(()=>S,[S]),I.jsx("canvas",{className:`${s}__canvas`,dir:"ltr",ref:yp(g,b),style:{display:"block",userSelect:"none"},children:d?I.jsx(Mb,{}):null})}function Fb(c){return"str"in c}function Db(){const c=Fh();yt(c);const{customTextRenderer:t,onGetTextError:e,onGetTextSuccess:s,onRenderTextLayerError:i,onRenderTextLayerSuccess:n,page:a,pageIndex:o,pageNumber:l,rotate:h,scale:d}=c;yt(a);const[u,f]=wa(),{value:g,error:b}=u,y=R.useRef(null);he(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(){b&&(he(!1,b.toString()),e&&e(b))}R.useEffect(function(){f({type:"RESET"})},[a,f]),R.useEffect(function(){if(!a)return;const P=ul(a.getTextContent()),k=P;return P.promise.then(B=>{f({type:"RESOLVE",value:B})}).catch(B=>{f({type:"REJECT",error:B})}),()=>ir(k)},[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=>{he(!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 k=a.streamTextContent({includeMarkedContent:!0}),B={container:P,textContentSource:k,viewport:x},O=new up(B),X=O;return O.render().then(()=>{const W=document.createElement("div");W.className="endOfContent",P.append(W);const G=P.querySelectorAll('[role="presentation"]');if(t){let V=0;g.items.forEach((q,H)=>{if(!Fb(q))return;const z=G[V];if(!z)return;const Lt=t(Object.assign({pageIndex:o,pageNumber:l,itemIndex:H},q));z.innerHTML=Lt,V+=q.str&&q.hasEOL?2:1})}_()}).catch(S),()=>ir(X)},[t,S,_,a,o,l,g,x]),I.jsx("div",{className:_h("react-pdf__Page__textContent","textLayer"),onMouseUp:C,onMouseDown:E,ref:y})}function Ob(){const c=Ap(),t=Fh();yt(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;yt(d),yt(h),yt(i);const[b,y]=wa(),{value:w,error:v}=b,_=R.useRef(null);he(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&&(he(!1,v.toString()),n&&n(v))}R.useEffect(function(){y({type:"RESET"})},[y,h]),R.useEffect(function(){if(!h)return;const k=ul(h.getAnnotations()),B=k;return k.promise.then(O=>{y({type:"RESOLVE",value:O})}).catch(O=>{y({type:"REJECT",error:O})}),()=>{ir(B)}},[y,h]),R.useEffect(()=>{if(w!==void 0){if(w===!1){E();return}S()}},[w]);function C(){l&&l()}function x(P){he(!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:k}=_;if(!k)return;const B=T.clone({dontFlip:!0}),O={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,div:k,l10n:null,page:h,structTreeLayer:null,viewport:B},X={annotations:w,annotationStorage:d.annotationStorage,div:k,imageResourcesPath:s,linkService:i,page:h,renderForms:u,viewport:B};k.innerHTML="";try{new cp(O).render(X),C()}catch(W){x(W)}return()=>{}},[w,s,i,h,d,u,T]),I.jsx("div",{className:_h("react-pdf__Page__annotations","annotationLayer"),ref:_})}var Nb=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(!mt)return null;let hr=1;const pl=ht??su;if(it||g){const gl=mt.getViewport({scale:1,rotation:Z});it?hr=it/gl.width:g&&(hr=g/gl.height)}return pl*hr},[g,mt,Z,ht,it]);R.useEffect(function(){return()=>{Ki(L)&&i&&wt&&wt(L)}},[i,H,L,wt]);function Ht(){if(P){if(!mt||!at)return;P(dd(mt,at))}if(i&&z){if(!Ki(L)||!Xi.current)return;z(L,Xi.current)}}function se(){qi&&(he(!1,qi.toString()),T&&T(qi))}R.useEffect(function(){ue({type:"RESET"})},[ue,H,L]),R.useEffect(function(){if(!H||!j)return;const pl=ul(H.getPage(j)),gl=pl;return pl.promise.then(Dh=>{ue({type:"RESOLVE",value:Dh})}).catch(Dh=>{ue({type:"REJECT",error:Dh})}),()=>ir(gl)},[ue,H,j]),R.useEffect(()=>{if(mt!==void 0){if(mt===!1){se();return}Ht()}},[mt,at]);const _a=R.useMemo(()=>mt&&Ki(L)&&j&&Ki(Z)&&Ki(at)?{_className:s,canvasBackground:n,customTextRenderer:d,devicePixelRatio:u,onGetAnnotationsError:v,onGetAnnotationsSuccess:_,onGetStructTreeError:S,onGetStructTreeSuccess:E,onGetTextError:C,onGetTextSuccess:x,onRenderAnnotationLayerError:k,onRenderAnnotationLayerSuccess:B,onRenderError:O,onRenderSuccess:X,onRenderTextLayerError:W,onRenderTextLayerSuccess:G,page:mt,pageIndex:L,pageNumber:j,renderForms:Ft,renderTextLayer:ct,rotate:Z,scale:at}:null,[s,n,d,u,v,_,S,E,C,x,k,B,O,X,W,G,mt,L,j,Ft,ct,Z,at]),Yi=R.useMemo(()=>pp(nt,()=>mt&&(at?dd(mt,at):void 0)),[nt,mt,at]),ks=`${L}@${at}/${Z}`;function Ea(){switch(Et){case"custom":return yt(h),I.jsx(h,{},`${ks}_custom`);case"none":return null;case"canvas":default:return I.jsx(Ib,{canvasRef:a},`${ks}_canvas`)}}function fl(){return ct?I.jsx(Db,{},`${ks}_text`):null}function Rp(){return Lt?I.jsx(Ob,{},`${ks}_annotations`):null}function Pp(){return I.jsxs(vp.Provider,{value:_a,children:[Ea(),fl(),Rp(),o]})}function kp(){return j?H===null||mt===void 0||mt===null?I.jsx(_r,{type:"loading",children:typeof y=="function"?y():y}):H===!1||mt===!1?I.jsx(_r,{type:"error",children:typeof f=="function"?f():f}):Pp():I.jsx(_r,{type:"no-data",children:typeof w=="function"?w():w})}return I.jsx("div",Object.assign({className:_h(s,l),"data-page-number":j,ref:yp(b,Xi),style:{"--scale-factor":`${at}`,backgroundColor:n||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"}},Yi,{children:kp()}))}vb();Lh.workerSrc="pdf.worker.mjs";const Bb="/assets/pdf.worker.min-GB3t0DcA.js";Lh.workerSrc=Bb;function jb(){if(!Lh.workerSrc)throw new Error("The bundled PDF worker is not configured.");if(hd!=="4.8.69")throw new Error(`PDF runtime version mismatch (${hd}).`)}function $b({paperTitle:c,paperHref:t,page:e,pages:s,zoomPercent:i,searchOpen:n,searchQuery:a,searchMatch:o,searchCount:l,searching:h,onPage:d,onZoomIn:u,onZoomOut:f,onToggleSearch:g,onSearchQuery:b,onSearch:y}){const w=v=>{v.preventDefault();const _=Number(new FormData(v.currentTarget).get("page"));Number.isInteger(_)&&d(_)};return I.jsxs("div",{className:"pdf-toolbar","aria-label":"PDF controls",children:[I.jsx("div",{className:"pdf-toolbar-paper",children:I.jsx(El,{to:t,title:c,"aria-label":`${c} — open paper page`,children:c})}),I.jsxs("div",{className:"pdf-toolbar-controls",children:[I.jsxs("div",{className:"pdf-toolbar-group",children:[I.jsx("button",{type:"button",onClick:()=>d(e-1),disabled:e<=1,"aria-label":"Previous page",children:"←"}),I.jsxs("form",{onSubmit:w,className:"pdf-page-form",children:[I.jsx("label",{className:"sr-only",htmlFor:"pdf-current-page",children:"Current page"}),I.jsx("input",{id:"pdf-current-page",name:"page",type:"number",min:1,max:s||1,defaultValue:e,"aria-label":`Page ${e} of ${s||"unknown"}`},e),I.jsxs("span",{"aria-hidden":"true",children:["/ ",s||"—"]})]}),I.jsx("button",{type:"button",onClick:()=>d(e+1),disabled:!s||e>=s,"aria-label":"Next page",children:"→"})]}),I.jsxs("div",{className:"pdf-toolbar-group",children:[I.jsx("button",{type:"button",onClick:f,"aria-label":"Zoom out",children:"−"}),I.jsxs("span",{className:"pdf-zoom-value","aria-live":"polite",children:[i,"%"]}),I.jsx("button",{type:"button",onClick:u,"aria-label":"Zoom in",children:"+"}),I.jsx("button",{type:"button",onClick:g,"aria-expanded":n,"aria-controls":"pdf-search-controls",children:"Search"})]})]}),n&&I.jsxs("div",{id:"pdf-search-controls",className:"pdf-search-controls",children:[I.jsx("label",{className:"sr-only",htmlFor:"pdf-search-input",children:"Search document"}),I.jsx("input",{id:"pdf-search-input",autoFocus:!0,value:a,onChange:v=>b(v.target.value),placeholder:"Search document"}),I.jsx("span",{role:"status",children:h?"Searching…":a?`${l?o+1:0} of ${l}`:""}),I.jsx("button",{type:"button",onClick:()=>y(-1),disabled:!l,"aria-label":"Previous match",children:"↑"}),I.jsx("button",{type:"button",onClick:()=>y(1),disabled:!l,"aria-label":"Next match",children:"↓"})]})]})}function zb(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 Gb({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()},[]),I.jsx("div",{ref:e,className:"pdf-page","data-page":c,style:{minHeight:Math.round(t*1.35)},children:s&&I.jsx(Hb,{pageNumber:c,width:t,devicePixelRatio:Math.min(window.devicePixelRatio||1,2),renderTextLayer:!0,renderAnnotationLayer:!0,loading:null})})}function Ub({url:c,paperKey:t,paperTitle:e,paperHref:s,initialPage:i=1,resizeActive:n=!1,onPageChange:a}){const o=R.useRef(null),l=R.useRef(null),h=R.useRef(null),d=R.useRef(null),u=R.useRef(0),f=R.useRef(!1),g=R.useRef(0),b=R.useRef(0),y=R.useRef(0),w=R.useRef(1),v=R.useRef(1),[_,S]=R.useState(0),[E,C]=R.useState(0),[x,T]=R.useState(i),[P,k]=R.useState(700),[B,O]=R.useState(700),[X,W]=R.useState(1),[G,V]=R.useState(""),[q,H]=R.useState(!1),[z,Lt]=R.useState(""),[Ft,Et]=R.useState(!1),[ct,M]=R.useState([]),[ht,wt]=R.useState(0),it=Math.max(240,Math.round(P*X));R.useEffect(()=>{jb()},[]),R.useEffect(()=>{var L;cancelAnimationFrame(b.current),window.clearTimeout(y.current),b.current=0,y.current=0,g.current=0,C(0),T(i),W(1),w.current=1,v.current=1,(L=h.current)==null||L.style.setProperty("--pdf-live-scale","1"),V(""),Lt(""),M([])},[i,t,_]),R.useEffect(()=>{const L=l.current;if(!L)return;const j=()=>{const at=Math.max(240,L.clientWidth-10);O(at),n||k(at)};j();const Z=new ResizeObserver(j);return Z.observe(L),()=>Z.disconnect()},[n]);const nt=n?B/P:1;R.useLayoutEffect(()=>{var j;if(w.current=X,(j=h.current)==null||j.style.setProperty("--pdf-live-scale",String(nt)),!f.current)return;const L=l.current;L&&(L.scrollLeft=Math.max(0,(L.scrollWidth-L.clientWidth)/2)),f.current=!1},[nt,it,X]);const de=R.useCallback(L=>{window.clearTimeout(y.current);const j=v.current,Z=L(j);v.current=Z,f.current=Z!==w.current,W(Z)},[]);R.useEffect(()=>{const L=l.current;if(!L)return;const j=Z=>{Z.ctrlKey&&(Z.preventDefault(),g.current+=Z.deltaY,!b.current&&(b.current=requestAnimationFrame(()=>{var se;const at=g.current;g.current=0,b.current=0;const Ht=Math.max(.5,Math.min(3,v.current*Math.exp(-at*.002)));v.current=Ht,(se=h.current)==null||se.style.setProperty("--pdf-live-scale",String(nt*Ht/w.current)),window.clearTimeout(y.current),y.current=window.setTimeout(()=>{f.current=Ht!==w.current,W(v.current)},180)})))};return L.addEventListener("wheel",j,{passive:!1}),()=>{L.removeEventListener("wheel",j),cancelAnimationFrame(b.current),window.clearTimeout(y.current),b.current=0,y.current=0,g.current=0}},[nt]);const ue=R.useCallback(L=>{const j=Math.max(1,Math.min(E||1,L));T(j),a==null||a(j)},[a,E]);R.useEffect(()=>{const L=l.current;if(!L||!E)return;let j=0;const Z=()=>{cancelAnimationFrame(j),j=requestAnimationFrame(()=>{const at=L.getBoundingClientRect().top+L.clientHeight/2;let Ht=x,se=Number.POSITIVE_INFINITY;L.querySelectorAll("[data-page]").forEach(_a=>{const Yi=_a.getBoundingClientRect(),ks=at>=Yi.top&&at<=Yi.bottom?0:Math.min(Math.abs(at-Yi.top),Math.abs(at-Yi.bottom));ks{L.removeEventListener("scroll",Z),cancelAnimationFrame(j)}},[x,it,E,ue]),R.useEffect(()=>{const L=j=>{(j.ctrlKey||j.metaKey)&&j.key.toLowerCase()==="f"&&(j.preventDefault(),H(!0))};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[]),R.useEffect(()=>{const L=d.current,j=z.trim().toLocaleLowerCase(),Z=++u.current;if(!L||!j){M([]),wt(0),Et(!1);return}Et(!0);const at=window.setTimeout(()=>void(async()=>{const Ht=[];for(let se=1;se<=L.numPages;se+=1){if(u.current!==Z)return;const ks=(await(await L.getPage(se)).getTextContent()).items.map(fl=>"str"in fl?fl.str:"").join(" ").toLocaleLowerCase();let Ea=0;for(;(Ea=ks.indexOf(j,Ea))>=0;)Ht.push(se),Ea+=Math.max(1,j.length)}u.current===Z&&(M(Ht),wt(0),Et(!1),Ht[0]&&mt(Ht[0]))})().catch(()=>{u.current===Z&&Et(!1)}),180);return()=>window.clearTimeout(at)},[z,E]);const mt=L=>{var Z,at;const j=Math.max(1,Math.min(E||1,L));(at=(Z=l.current)==null?void 0:Z.querySelector(`[data-page="${j}"]`))==null||at.scrollIntoView({block:"start"}),ue(j)},qi=L=>{if(!ct.length)return;const j=(ht+L+ct.length)%ct.length;wt(j),mt(ct[j])},Xi=R.useMemo(()=>Array.from({length:E},(L,j)=>j+1),[E]);return I.jsxs("div",{ref:o,className:"pdf-viewer",children:[I.jsx($b,{paperTitle:e,paperHref:s,page:x,pages:E,zoomPercent:Math.round(X*100),searchOpen:q,searchQuery:z,searchMatch:ht,searchCount:ct.length,searching:Ft,onPage:mt,onZoomIn:()=>de(L=>Math.min(3,L+.15)),onZoomOut:()=>de(L=>Math.max(.5,L-.15)),onToggleSearch:()=>H(L=>!L),onSearchQuery:Lt,onSearch:qi}),I.jsx("div",{ref:l,className:"pdf-scroll",role:"region","aria-label":"Paper PDF",children:G?I.jsxs("div",{className:"pdf-error",role:"alert",children:[I.jsx("p",{children:G}),I.jsxs("div",{children:[I.jsx("button",{type:"button",onClick:()=>S(L=>L+1),children:"Retry"})," ",I.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",children:"Open original PDF"})]})]}):I.jsx(Tb,{file:c,loading:I.jsx("div",{className:"pdf-loading",role:"status",children:"Loading paper…"}),onLoadSuccess:L=>{d.current=L,C(L.numPages),V("");const j=Math.max(1,Math.min(L.numPages,i));j>1&&requestAnimationFrame(()=>requestAnimationFrame(()=>{var Z,at;(at=(Z=l.current)==null?void 0:Z.querySelector(`[data-page="${j}"]`))==null||at.scrollIntoView({block:"start"}),T(j),a==null||a(j)}))},onLoadError:L=>V(zb(L)),externalLinkTarget:"_blank",children:I.jsx("div",{ref:h,className:"pdf-pages",style:{"--pdf-live-scale":nt},children:Xi.map(L=>I.jsx(Gb,{page:L,width:it},L))})},`${t}-${_}`)})]})}const xp=66,Cp="pwc:reader:split-ratio",_l=c=>`pwc:reader:session:${c}`,Gh=c=>`pwc:reader:assistant-collapsed:${c}`,Tp=c=>`pwc:reader:page:${c}`;function Uh(c){const t=Number(sessionStorage.getItem(Tp(c)));return Number.isInteger(t)&&t>0?t:1}function Wb(){const c=Number(localStorage.getItem(Cp));return Number.isFinite(c)&&c>=45&&c<=75?c:xp}function Vb(c){const t=$p(c);if(!t)return null;const e=new URL(t);return(e.hostname==="arxiv.org"||e.hostname==="www.arxiv.org")&&e.pathname.startsWith("/pdf/")&&e.pathname.endsWith(".pdf")&&(e.pathname=e.pathname.slice(0,-4)),e.href}function mA(){var Ft,Et,ct;const{arxivId:c}=Fp(),t=Dp(c??"").replace(/v\d+$/i,""),e=Op(),s=Bp(t,!!t),i=Hp({queryKey:["chatAvailability"],queryFn:()=>jp.getAvailability(),refetchInterval:3e4,retry:!1}),n=s.data,a=Vb(n==null?void 0:n.url_pdf),o=((Ft=n==null?void 0:n.arxiv_id)==null?void 0:Ft.replace(/v\d+$/i,""))||t,[l,h]=R.useState(()=>sessionStorage.getItem(_l(t))||void 0),[d,u]=R.useState(Wb),[f,g]=R.useState(()=>sessionStorage.getItem(Gh(t))==="1"),[b,y]=R.useState("paper"),[w,v]=R.useState(()=>Uh(t)),[_,S]=R.useState(0),[E,C]=R.useState(!1),x=R.useRef(null),T=R.useRef(!1),P=R.useRef(Uh(t)),k=_>900&&_>=840;R.useEffect(()=>{c&&c!==t&&e(`/pdf/${t}`,{replace:!0})},[e,c,t]),R.useEffect(()=>{const M=sessionStorage.getItem(_l(t));h(M||void 0),g(sessionStorage.getItem(Gh(t))==="1"),y("paper");const ht=Uh(t);P.current=ht,v(ht)},[t]),R.useLayoutEffect(()=>{const M=x.current;if(!M)return;const ht=()=>S(M.clientWidth);ht();const wt=new ResizeObserver(ht);return wt.observe(M),()=>wt.disconnect()},[n]),R.useEffect(()=>{if(!n)return;document.title=`${n.title} — Papers With Code reader`;let M=document.querySelector('meta[name="robots"]');const ht=!M;M||(M=document.createElement("meta"),M.name="robots",document.head.appendChild(M));const wt=M.content;M.content="noindex, nofollow";let it=document.querySelector('link[rel="canonical"]');const nt=!it;it||(it=document.createElement("link"),it.rel="canonical",document.head.appendChild(it));const de=it.href;return it.href=`${window.location.origin}/paper/${o}`,()=>{document.title="Papers With Code",ht?M==null||M.remove():M&&(M.content=wt),nt?it==null||it.remove():it&&(it.href=de)}},[o,n]);const B=R.useCallback(M=>{if(!_)return Math.max(45,Math.min(75,M));const ht=480/_*100,wt=100-360/_*100;return Math.max(ht,Math.min(wt,M))},[_]);R.useEffect(()=>u(M=>B(M)),[B]);const O=M=>{const ht=B(M);u(ht),localStorage.setItem(Cp,String(ht))},X=M=>{var wt;const ht=(wt=x.current)==null?void 0:wt.getBoundingClientRect();ht&&O((M-ht.left)/ht.width*100)},W=M=>{T.current=!0,C(!0),M.currentTarget.setPointerCapture(M.pointerId),X(M.clientX)},G=()=>{T.current=!1,C(!1)},V=M=>{g(M),sessionStorage.setItem(Gh(t),M?"1":"0")},q=M=>{h(M),sessionStorage.setItem(_l(t),M)},H=()=>{h(void 0),sessionStorage.removeItem(_l(t))},z=Np()&&((Et=i.data)==null?void 0:Et.paper_reader_chat_enabled)!==!1,Lt=n&&z?I.jsx(zp,{mode:"paper",routeSessionId:l,primaryPaper:{id:n.id,routeId:o,title:n.title},currentPage:()=>P.current,onSessionId:q,onReaderSubmit:()=>y("assistant"),onReaderNewChat:H}):I.jsx("div",{className:"reader-chat-unavailable",children:"Assistant is not enabled for this preview."});return s.isLoading?I.jsx("div",{className:"reader-status",role:"status",children:"Loading paper…"}):s.error||!n?I.jsxs("div",{className:"reader-status",role:"alert",children:[I.jsx("p",{children:"Paper not found."}),I.jsx(El,{to:"/papers",children:"Browse papers"})]}):((ct=i.data)==null?void 0:ct.native_pdf_reader_enabled)===!1?I.jsxs("div",{className:"reader-status",role:"alert",children:[I.jsx("p",{children:"The native reader is currently unavailable."}),I.jsx(El,{to:`/paper/${o}`,children:"Back to paper"})]}):n.source!=="arxiv"||!a?I.jsxs("div",{className:"reader-status",role:"alert",children:[I.jsx("p",{children:"Native reading is unavailable for this resource."}),I.jsx(El,{to:`/paper/${o}`,children:"Back to paper"})]}):I.jsxs("div",{className:"paper-reader-shell",children:[!k&&I.jsxs("div",{className:"reader-tabs",role:"tablist","aria-label":"Reader panels",children:[I.jsx("button",{type:"button",role:"tab","aria-selected":b==="paper",onClick:()=>y("paper"),children:"Paper"}),I.jsx("button",{type:"button",role:"tab","aria-selected":b==="assistant",onClick:()=>y("assistant"),children:"Assistant"})]}),I.jsxs("div",{ref:x,className:`reader-workspace${k?" is-desktop":" is-tabs"}${f?" is-assistant-collapsed":""}`,children:[I.jsx("section",{className:`reader-paper-pane${!k&&b!=="paper"?" is-hidden":""}`,style:k?{width:f?"100%":`${d}%`}:void 0,role:"tabpanel","aria-label":"Paper","aria-hidden":!k&&b!=="paper",children:I.jsx(Ub,{url:a,paperKey:o,paperTitle:n.title,paperHref:`/paper/${o}`,initialPage:w,resizeActive:E,onPageChange:M=>{P.current=M,sessionStorage.setItem(Tp(t),String(M))}})}),k&&!f&&I.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(d),tabIndex:0,onPointerDown:W,onPointerMove:M=>{T.current&&X(M.clientX)},onPointerUp:G,onPointerCancel:G,onLostPointerCapture:G,onDoubleClick:()=>O(xp),onKeyDown:M=>{(M.key==="ArrowLeft"||M.key==="ArrowRight")&&(M.preventDefault(),O(d+(M.key==="ArrowRight"?2:-2))),M.key==="Home"&&O(45),M.key==="End"&&O(75)}}),I.jsx("aside",{className:`reader-assistant-pane${!k&&b!=="assistant"||f?" is-hidden":""}`,style:k?{width:f?0:`${100-d}%`}:void 0,role:"tabpanel","aria-label":"Assistant","aria-hidden":!k&&b!=="assistant"||f,children:Lt}),k&&I.jsx("button",{type:"button",className:"reader-collapse-assistant",onClick:()=>V(!f),children:f?"Assistant":"Hide Assistant"})]})]})}export{mA as default,Vb as directArxivPdfHref};