pdf.min-B4vzWZ9b.js 338 KB

123456789101112
  1. var vf=Object.defineProperty;var jc=u=>{throw TypeError(u)};var yf=(u,t,e)=>t in u?vf(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e;var N=(u,t,e)=>yf(u,typeof t!="symbol"?t+"":t,e),Yh=(u,t,e)=>t.has(u)||jc("Cannot "+e);var n=(u,t,e)=>(Yh(u,t,"read from private field"),e?e.call(u):t.get(u)),b=(u,t,e)=>t.has(u)?jc("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(u):t.set(u,e),p=(u,t,e,s)=>(Yh(u,t,"write to private field"),s?s.call(u,e):t.set(u,e),e),m=(u,t,e)=>(Yh(u,t,"access private method"),e);var Gt=(u,t,e,s)=>({set _(i){p(u,t,i,e)},get _(){return n(u,t,s)}});import{aa as No}from"./index-CwBB3Vn1.js";import"./vue-vendor-BdC0yijC.js";var nl={d:(u,t)=>{for(var e in t)nl.o(t,e)&&!nl.o(u,e)&&Object.defineProperty(u,e,{enumerable:!0,get:t[e]})},o:(u,t)=>Object.prototype.hasOwnProperty.call(u,t)},z=globalThis.pdfjsLib={};nl.d(z,{AbortException:()=>Nn,AnnotationEditorLayer:()=>mc,AnnotationEditorParamsType:()=>O,AnnotationEditorType:()=>V,AnnotationEditorUIManager:()=>Pn,AnnotationLayer:()=>kg,AnnotationMode:()=>qs,ColorPicker:()=>xh,DOMSVGFactory:()=>Dc,DrawLayer:()=>yc,FeatureTest:()=>Wt,GlobalWorkerOptions:()=>Ns,ImageKind:()=>Vo,InvalidPDFException:()=>md,MissingPDFException:()=>Dn,OPS:()=>ke,OutputScale:()=>cl,PDFDataRangeTransport:()=>cu,PDFDateString:()=>kc,PDFWorker:()=>Xn,PasswordResponses:()=>Jf,PermissionFlag:()=>Mf,PixelsPerInch:()=>yi,RenderingCancelledException:()=>Cc,TextLayer:()=>gr,UnexpectedResponseException:()=>Uh,Util:()=>I,VerbosityLevel:()=>$h,XfaLayer:()=>uu,build:()=>lg,createValidAbsoluteUrl:()=>ep,fetchData:()=>Wh,getDocument:()=>sg,getFilenameFromUrl:()=>fp,getPdfFilenameFromUrl:()=>pp,getXfaPageViewport:()=>gp,isDataScheme:()=>Xh,isPdfFile:()=>Mc,noContextMenu:()=>Ee,normalizeUnicode:()=>ip,setLayerDimensions:()=>Rn,shadow:()=>K,version:()=>hg});const $t=!(typeof process!="object"||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&process.type!=="browser"),pd=[1,0,0,1,0,0],al=[.001,0,0,.001,0,0],Qh=1.35,wf=1,xc=2,vh=4,_f=16,xf=32,Sf=64,Ef=128,Cf=256,qs={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},V={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},O={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},Mf={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},$o=0,Jh=1,Wa=2,kf=3,$c=3,Tf=4,Vo={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Rf=1,Pf=2,If=3,Lf=4,Ff=5,Df=6,Nf=7,Of=8,Bf=9,Hf=10,zf=11,jf=12,$f=13,Vf=14,Gf=15,gd=16,Uf=17,qf=20,Wf=1,Xf=2,Kf=3,Yf=4,Qf=5,$h={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},Jf={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Vh=$h.WARNINGS;function Zf(u){Number.isInteger(u)&&(Vh=u)}function tp(){return Vh}function Gh(u){Vh>=$h.INFOS&&console.log(`Info: ${u}`)}function q(u){Vh>=$h.WARNINGS&&console.log(`Warning: ${u}`)}function ot(u){throw new Error(u)}function St(u,t){u||ot(t)}function ep(u,t=null,e=null){if(!u)return null;try{if(e&&typeof u=="string"){if(e.addDefaultProtocol&&u.startsWith("www.")){const i=u.match(/\./g);(i==null?void 0:i.length)>=2&&(u=`http://${u}`)}if(e.tryConvertEncoding)try{u=function(a){return decodeURIComponent(escape(a))}(u)}catch{}}const s=t?new URL(u,t):new URL(u);if(function(a){switch(a==null?void 0:a.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s))return s}catch{}return null}function K(u,t,e,s=!1){return Object.defineProperty(u,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Si=function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();class rl extends Si{constructor(t,e){super(t,"PasswordException"),this.code=e}}class ol extends Si{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class md extends Si{constructor(t){super(t,"InvalidPDFException")}}class Dn extends Si{constructor(t){super(t,"MissingPDFException")}}class Uh extends Si{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class sp extends Si{constructor(t){super(t,"FormatError")}}class Nn extends Si{constructor(t){super(t,"AbortException")}}function bd(u){typeof u=="object"&&(u==null?void 0:u.length)!==void 0||ot("Invalid argument for bytesToString");const t=u.length,e=8192;if(t<e)return String.fromCharCode.apply(null,u);const s=[];for(let i=0;i<t;i+=e){const a=Math.min(i+e,t),r=u.subarray(i,a);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function qh(u){typeof u!="string"&&ot("Invalid argument for stringToBytes");const t=u.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=255&u.charCodeAt(s);return e}function Sc(u){const t=Object.create(null);for(const[e,s]of u)t[e]=s;return t}class Wt{static get isLittleEndian(){return K(this,"isLittleEndian",function(){const e=new Uint8Array(4);return e[0]=1,new Uint32Array(e.buffer,0,1)[0]===1}())}static get isEvalSupported(){return K(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return K(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.platform)=="string"?K(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")}):K(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){var t,e;return K(this,"isCSSRoundSupported",(e=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const Zh=Array.from(Array(256).keys(),u=>u.toString(16).padStart(2,"0"));var Bs,Go,hl;class I{static makeHexColor(t,e,s){return`#${Zh[t]}${Zh[e]}${Zh[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){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){const s=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/s,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s]}static getAxialAlignedBoundingBox(t,e){const s=this.applyTransform(t,e),i=this.applyTransform(t.slice(2,4),e),a=this.applyTransform([t[0],t[3]],e),r=this.applyTransform([t[2],t[1]],e);return[Math.min(s[0],i[0],a[0],r[0]),Math.min(s[1],i[1],a[1],r[1]),Math.max(s[0],i[0],a[0],r[0]),Math.max(s[1],i[1],a[1],r[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],s=t[0]*e[0]+t[1]*e[2],i=t[0]*e[1]+t[1]*e[3],a=t[2]*e[0]+t[3]*e[2],r=t[2]*e[1]+t[3]*e[3],o=(s+r)/2,h=Math.sqrt((s+r)**2-4*(s*r-a*i))/2,l=o+h||1,c=o-h||1;return[Math.sqrt(l),Math.sqrt(c)]}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 a=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return a>r?null:[s,a,i,r]}static bezierBoundingBox(t,e,s,i,a,r,o,h,l){return l?(l[0]=Math.min(l[0],t,o),l[1]=Math.min(l[1],e,h),l[2]=Math.max(l[2],t,o),l[3]=Math.max(l[3],e,h)):l=[Math.min(t,o),Math.min(e,h),Math.max(t,o),Math.max(e,h)],m(this,Bs,hl).call(this,t,s,a,o,e,i,r,h,3*(3*(s-a)-t+o),6*(t-2*s+a),3*(s-t),l),m(this,Bs,hl).call(this,t,s,a,o,e,i,r,h,3*(3*(i-r)-e+h),6*(e-2*i+r),3*(i-e),l),l}}Bs=new WeakSet,Go=function(t,e,s,i,a,r,o,h,l,c){if(l<=0||l>=1)return;const d=1-l,f=l*l,g=f*l,A=d*(d*(d*t+3*l*e)+3*f*s)+g*i,v=d*(d*(d*a+3*l*r)+3*f*o)+g*h;c[0]=Math.min(c[0],A),c[1]=Math.min(c[1],v),c[2]=Math.max(c[2],A),c[3]=Math.max(c[3],v)},hl=function(t,e,s,i,a,r,o,h,l,c,d,f){if(Math.abs(l)<1e-12){Math.abs(c)>=1e-12&&m(this,Bs,Go).call(this,t,e,s,i,a,r,o,h,-d/c,f);return}const g=c**2-4*d*l;if(g<0)return;const A=Math.sqrt(g),v=2*l;m(this,Bs,Go).call(this,t,e,s,i,a,r,o,h,(-c+A)/v,f),m(this,Bs,Go).call(this,t,e,s,i,a,r,o,h,(-c-A)/v,f)},b(I,Bs);let tl=null,Vc=null;function ip(u){return tl||(tl=/([\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,Vc=new Map([["ſt","ſt"]])),u.replaceAll(tl,(t,e,s)=>e?e.normalize("NFKC"):Vc.get(s))}const Ec="pdfjs_internal_id_",np=0,ap=1,rp=2,op=3,hp=4,lp=5,cp=6,dp=7,up=8,ls="http://www.w3.org/2000/svg",Ri=class Ri{};N(Ri,"CSS",96),N(Ri,"PDF",72),N(Ri,"PDF_TO_CSS_UNITS",Ri.CSS/Ri.PDF);let yi=Ri;async function Wh(u,t="text"){if(Ya(u,document.baseURI)){const e=await fetch(u);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",u,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE)if(i.status!==200&&i.status!==0)s(new Error(i.statusText));else{switch(t){case"arraybuffer":case"blob":case"json":e(i.response);return}e(i.responseText)}},i.send(null)})}class Lo{constructor({viewBox:t,scale:e,rotation:s,offsetX:i=0,offsetY:a=0,dontFlip:r=!1}){this.viewBox=t,this.scale=e,this.rotation=s,this.offsetX=i,this.offsetY=a;const o=(t[2]+t[0])/2,h=(t[3]+t[1])/2;let l,c,d,f,g,A,v,w;switch((s%=360)<0&&(s+=360),s){case 180:l=-1,c=0,d=0,f=1;break;case 90:l=0,c=1,d=1,f=0;break;case 270:l=0,c=-1,d=-1,f=0;break;case 0:l=1,c=0,d=0,f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}r&&(d=-d,f=-f),l===0?(g=Math.abs(h-t[1])*e+i,A=Math.abs(o-t[0])*e+a,v=(t[3]-t[1])*e,w=(t[2]-t[0])*e):(g=Math.abs(o-t[0])*e+i,A=Math.abs(h-t[1])*e+a,v=(t[2]-t[0])*e,w=(t[3]-t[1])*e),this.transform=[l*e,c*e,d*e,f*e,g-l*e*o-d*e*h,A-c*e*o-f*e*h],this.width=v,this.height=w}get rawDims(){const{viewBox:t}=this;return K(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:a=!1}={}){return new Lo({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:a})}convertToViewportPoint(t,e){return I.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=I.applyTransform([t[0],t[1]],this.transform),s=I.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return I.applyInverseTransform([t,e],this.transform)}}class Cc extends Si{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Xh(u){const t=u.length;let e=0;for(;e<t&&u[e].trim()==="";)e++;return u.substring(e,e+5).toLowerCase()==="data:"}function Mc(u){return typeof u=="string"&&/\.pdf$/i.test(u)}function fp(u){return[u]=u.split(/[#?]/,1),u.substring(u.lastIndexOf("/")+1)}function pp(u,t="document.pdf"){if(typeof u!="string")return t;if(Xh(u))return q('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const e=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(u);let i=e.exec(s[1])||e.exec(s[2])||e.exec(s[3]);if(i&&(i=i[0],i.includes("%")))try{i=e.exec(decodeURIComponent(i))[0]}catch{}return i||t}class Gc{constructor(){N(this,"started",Object.create(null));N(this,"times",[])}time(t){t in this.started&&q(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||q(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:s}of this.times)e=Math.max(s.length,e);for(const{name:s,start:i,end:a}of this.times)t.push(`${s.padEnd(e)} ${a-i}ms
  2. `);return t.join("")}}function Ya(u,t){try{const{protocol:e}=t?new URL(u,t):new URL(u);return e==="http:"||e==="https:"}catch{return!1}}function Ee(u){u.preventDefault()}function Uc(u){console.log("Deprecated API usage: "+u)}var br;class kc{static toDateObject(t){if(!t||typeof t!="string")return null;n(this,br)||p(this,br,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=n(this,br).exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let a=parseInt(e[3],10);a=a>=1&&a<=31?a:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let h=parseInt(e[6],10);h=h>=0&&h<=59?h:0;const l=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,l==="-"?(r+=c,o+=d):l==="+"&&(r-=c,o-=d),new Date(Date.UTC(s,i,a,r,o,h))}}br=new WeakMap,b(kc,br);function gp(u,{scale:t=1,rotation:e=0}){const{width:s,height:i}=u.attributes.style,a=[0,0,parseInt(s),parseInt(i)];return new Lo({viewBox:a,scale:t,rotation:e})}function ll(u){if(u.startsWith("#")){const t=parseInt(u.slice(1),16);return[(16711680&t)>>16,(65280&t)>>8,255&t]}return u.startsWith("rgb(")?u.slice(4,-1).split(",").map(t=>parseInt(t)):u.startsWith("rgba(")?u.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(q(`Not a valid color format: "${u}"`),[0,0,0])}function ut(u){const{a:t,b:e,c:s,d:i,e:a,f:r}=u.getTransform();return[t,e,s,i,a,r]}function hs(u){const{a:t,b:e,c:s,d:i,e:a,f:r}=u.getTransform().invertSelf();return[t,e,s,i,a,r]}function Rn(u,t,e=!1,s=!0){if(t instanceof Lo){const{pageWidth:i,pageHeight:a}=t.rawDims,{style:r}=u,o=Wt.isCSSRoundSupported,h=`var(--scale-factor) * ${i}px`,l=`var(--scale-factor) * ${a}px`,c=o?`round(down, ${h}, var(--scale-round-x, 1px))`:`calc(${h})`,d=o?`round(down, ${l}, var(--scale-round-y, 1px))`:`calc(${l})`;e&&t.rotation%180!=0?(r.width=d,r.height=c):(r.width=c,r.height=d)}s&&u.setAttribute("data-main-rotation",t.rotation)}class cl{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 Ws,Li,Te,Fi,Ar,vr,Eh,Ad,Xt,vd,yd,Uo,wd,ul;const cs=class cs{constructor(t){b(this,Xt);b(this,Ws,null);b(this,Li,null);b(this,Te);b(this,Fi,null);b(this,Ar,null);p(this,Te,t),n(cs,vr)||p(cs,vr,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,Ws,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=n(this,Te)._uiManager._signal;t.addEventListener("contextmenu",Ee,{signal:e}),t.addEventListener("pointerdown",m(cs,Eh,Ad),{signal:e});const s=p(this,Fi,document.createElement("div"));s.className="buttons",t.append(s);const i=n(this,Te).toolbarPosition;if(i){const{style:a}=t,r=n(this,Te)._uiManager.direction==="ltr"?1-i[0]:i[0];a.insetInlineEnd=100*r+"%",a.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return m(this,Xt,wd).call(this),t}get div(){return n(this,Ws)}hide(){var t;n(this,Ws).classList.add("hidden"),(t=n(this,Li))==null||t.hideDropdown()}show(){var t;n(this,Ws).classList.remove("hidden"),(t=n(this,Ar))==null||t.shown()}async addAltText(t){const e=await t.render();m(this,Xt,Uo).call(this,e),n(this,Fi).prepend(e,n(this,Xt,ul)),p(this,Ar,t)}addColorPicker(t){p(this,Li,t);const e=t.renderButton();m(this,Xt,Uo).call(this,e),n(this,Fi).prepend(e,n(this,Xt,ul))}remove(){var t;n(this,Ws).remove(),(t=n(this,Li))==null||t.destroy(),p(this,Li,null)}};Ws=new WeakMap,Li=new WeakMap,Te=new WeakMap,Fi=new WeakMap,Ar=new WeakMap,vr=new WeakMap,Eh=new WeakSet,Ad=function(t){t.stopPropagation()},Xt=new WeakSet,vd=function(t){n(this,Te)._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()},yd=function(t){n(this,Te)._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()},Uo=function(t){const e=n(this,Te)._uiManager._signal;t.addEventListener("focusin",m(this,Xt,vd).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",m(this,Xt,yd).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Ee,{signal:e})},wd=function(){const{editorType:t,_uiManager:e}=n(this,Te),s=document.createElement("button");s.className="delete",s.tabIndex=0,s.setAttribute("data-l10n-id",n(cs,vr)[t]),m(this,Xt,Uo).call(this,s),s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),n(this,Fi).append(s)},ul=function(){const t=document.createElement("div");return t.className="divider",t},b(cs,Eh),b(cs,vr,null);let dl=cs;var yr,Di,Ni,_i,_d,xd,Sd;class mp{constructor(t){b(this,_i);b(this,yr,null);b(this,Di,null);b(this,Ni);p(this,Ni,t)}show(t,e,s){const[i,a]=m(this,_i,xd).call(this,e,s),{style:r}=n(this,Di)||p(this,Di,m(this,_i,_d).call(this));t.append(n(this,Di)),r.insetInlineEnd=100*i+"%",r.top=`calc(${100*a}% + var(--editor-toolbar-vert-offset))`}hide(){n(this,Di).remove()}}yr=new WeakMap,Di=new WeakMap,Ni=new WeakMap,_i=new WeakSet,_d=function(){const t=p(this,Di,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",Ee,{signal:n(this,Ni)._signal});const e=p(this,yr,document.createElement("div"));return e.className="buttons",t.append(e),m(this,_i,Sd).call(this),t},xd=function(t,e){let s=0,i=0;for(const a of t){const r=a.y+a.height;if(r<s)continue;const o=a.x+(e?a.width:0);r>s?(i=o,s=r):e?o>i&&(i=o):o<i&&(i=o)}return[e?1-i:i,s]},Sd=function(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const s=n(this,Ni)._signal;t.addEventListener("contextmenu",Ee,{signal:s}),t.addEventListener("click",()=>{n(this,Ni).highlightSelection("floating_button")},{signal:s}),n(this,yr).append(t)};function yh(u,t,e){for(const s of e)t.addEventListener(s,u[s].bind(u))}var Ch;class bp{constructor(){b(this,Ch,0)}get id(){return"pdfjs_internal_editor_"+Gt(this,Ch)._++}}Ch=new WeakMap;var Kn,wr,Bt,Yn,qo;const Oc=class Oc{constructor(){b(this,Yn);b(this,Kn,function(){if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.randomUUID)=="function")return crypto.randomUUID();const e=new Uint8Array(32);if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.getRandomValues)=="function")crypto.getRandomValues(e);else for(let s=0;s<32;s++)e[s]=Math.floor(255*Math.random());return bd(e)}());b(this,wr,0);b(this,Bt,null)}static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;return e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',K(this,"_isSVGFittingCanvas",e.decode().then(()=>(t.drawImage(e,0,0,1,1,0,0,1,3),new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]===0)))}async getFromFile(t){const{lastModified:e,name:s,size:i,type:a}=t;return m(this,Yn,qo).call(this,`${e}_${s}_${i}_${a}`,t)}async getFromUrl(t){return m(this,Yn,qo).call(this,t,t)}async getFromBlob(t,e){const s=await e;return m(this,Yn,qo).call(this,t,s)}async getFromId(t){n(this,Bt)||p(this,Bt,new Map);const e=n(this,Bt).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){n(this,Bt)||p(this,Bt,new Map);let s=n(this,Bt).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_${n(this,Kn)}_${Gt(this,wr)._++}`,refCounter:1,isSvg:!1},n(this,Bt).set(t,s),n(this,Bt).set(s.id,s),s}getSvgUrl(t){const e=n(this,Bt).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;n(this,Bt)||p(this,Bt,new Map);const e=n(this,Bt).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const a=new OffscreenCanvas(s.width,s.height);a.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=a.convertToBlob()}(i=s.close)==null||i.call(s),e.bitmap=null}isValidId(t){return t.startsWith(`image_${n(this,Kn)}_`)}};Kn=new WeakMap,wr=new WeakMap,Bt=new WeakMap,Yn=new WeakSet,qo=async function(t,e){n(this,Bt)||p(this,Bt,new Map);let s=n(this,Bt).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${n(this,Kn)}_${Gt(this,wr)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await Wh(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const a=Oc._isSVGFittingCanvas,r=new FileReader,o=new Image,h=new Promise((l,c)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,l()},r.onload=async()=>{const d=s.svgUrl=r.result;o.src=await a?`${d}#svgView(preserveAspectRatio(none))`:d},o.onerror=r.onerror=c});r.readAsDataURL(i),await h}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){console.error(i),s=null}return n(this,Bt).set(t,s),s&&n(this,Bt).set(s.id,s),s};let fl=Oc;var Ct,Xs,_r,Mt;class Ap{constructor(t=128){b(this,Ct,[]);b(this,Xs,!1);b(this,_r);b(this,Mt,-1);p(this,_r,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:a=NaN,overwriteIfSameType:r=!1,keepUndo:o=!1}){if(i&&t(),n(this,Xs))return;const h={cmd:t,undo:e,post:s,type:a};if(n(this,Mt)===-1){n(this,Ct).length>0&&(n(this,Ct).length=0),p(this,Mt,0),n(this,Ct).push(h);return}if(r&&n(this,Ct)[n(this,Mt)].type===a){o&&(h.undo=n(this,Ct)[n(this,Mt)].undo),n(this,Ct)[n(this,Mt)]=h;return}const l=n(this,Mt)+1;l===n(this,_r)?n(this,Ct).splice(0,1):(p(this,Mt,l),l<n(this,Ct).length&&n(this,Ct).splice(l)),n(this,Ct).push(h)}undo(){if(n(this,Mt)===-1)return;p(this,Xs,!0);const{undo:t,post:e}=n(this,Ct)[n(this,Mt)];t(),e==null||e(),p(this,Xs,!1),p(this,Mt,n(this,Mt)-1)}redo(){if(n(this,Mt)<n(this,Ct).length-1){p(this,Mt,n(this,Mt)+1),p(this,Xs,!0);const{cmd:t,post:e}=n(this,Ct)[n(this,Mt)];t(),e==null||e(),p(this,Xs,!1)}}hasSomethingToUndo(){return n(this,Mt)!==-1}hasSomethingToRedo(){return n(this,Mt)<n(this,Ct).length-1}destroy(){p(this,Ct,null)}}Ct=new WeakMap,Xs=new WeakMap,_r=new WeakMap,Mt=new WeakMap;var Mh,Ed;class Fo{constructor(t){b(this,Mh);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=Wt.platform;for(const[s,i,a={}]of t)for(const r of s){const o=r.startsWith("mac+");e&&o?(this.callbacks.set(r.slice(4),{callback:i,options:a}),this.allKeys.add(r.split("+").at(-1))):!e&&!o&&(this.callbacks.set(r,{callback:i,options:a}),this.allKeys.add(r.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(m(this,Mh,Ed).call(this,e));if(!s)return;const{callback:i,options:{bubbles:a=!1,args:r=[],checker:o=null}}=s;(!o||o(t,e))&&(i.bind(t,...r,e)(),a||(e.stopPropagation(),e.preventDefault()))}}Mh=new WeakSet,Ed=function(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e};const kh=class kh{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(s){const i=document.createElement("span");i.style.visibility="hidden",document.body.append(i);for(const a of s.keys()){i.style.color=a;const r=window.getComputedStyle(i).color;s.set(a,ll(r))}i.remove()}(t),K(this,"_colors",t)}convert(t){const e=ll(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((a,r)=>a===e[r]))return kh._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?I.makeHexColor(...e):t}};N(kh,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let pl=kh;var Qn,re,wt,Lt,Jn,us,Zn,Re,Ks,ta,Oi,Ve,Pe,Bi,xr,Sr,ea,Er,Ge,Ys,sa,Qs,Ue,Th,Js,Cr,Zs,Hi,Mr,kr,kt,et,fs,zi,Tr,Rr,ti,qe,ps,Pr,be,T,Wo,gl,Cd,Md,Xo,kd,Td,Rd,ml,Pd,bl,Al,Id,Ut,Gs,Ld,Fd,vl,Dd,Qa,yl;const qn=class qn{constructor(t,e,s,i,a,r,o,h,l,c,d){b(this,T);b(this,Qn,new AbortController);b(this,re,null);b(this,wt,new Map);b(this,Lt,new Map);b(this,Jn,null);b(this,us,null);b(this,Zn,null);b(this,Re,new Ap);b(this,Ks,null);b(this,ta,0);b(this,Oi,new Set);b(this,Ve,null);b(this,Pe,null);b(this,Bi,new Set);b(this,xr,!1);b(this,Sr,!1);b(this,ea,!1);b(this,Er,null);b(this,Ge,null);b(this,Ys,null);b(this,sa,null);b(this,Qs,!1);b(this,Ue,null);b(this,Th,new bp);b(this,Js,!1);b(this,Cr,!1);b(this,Zs,null);b(this,Hi,null);b(this,Mr,null);b(this,kr,null);b(this,kt,V.NONE);b(this,et,new Set);b(this,fs,null);b(this,zi,null);b(this,Tr,null);b(this,Rr,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});b(this,ti,[0,0]);b(this,qe,null);b(this,ps,null);b(this,Pr,null);b(this,be,null);const f=this._signal=n(this,Qn).signal;p(this,ps,t),p(this,Pr,e),p(this,Jn,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,T,kd).call(this),m(this,T,Id).call(this),m(this,T,ml).call(this),p(this,us,a.annotationStorage),p(this,Er,a.filterFactory),p(this,zi,r),p(this,sa,o||null),p(this,xr,h),p(this,Sr,l),p(this,ea,c),p(this,kr,d||null),this.viewParameters={realScale:yi.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}static get _keyboardManager(){const t=qn.prototype,e=r=>n(r,ps).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),s=(r,{target:o})=>{if(o instanceof HTMLInputElement){const{type:h}=o;return h!=="text"&&h!=="number"}return!0},i=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return K(this,"_keyboardManager",new Fo([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(r,{target:o})=>!(o instanceof HTMLButtonElement)&&n(r,ps).contains(o)&&!r.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(r,{target:o})=>!(o instanceof HTMLButtonElement)&&n(r,ps).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:[-a,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[a,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-a],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,a],checker:e}]]))}destroy(){var t,e,s,i;(t=n(this,be))==null||t.resolve(),p(this,be,null),(e=n(this,Qn))==null||e.abort(),p(this,Qn,null),this._signal=null;for(const a of n(this,Lt).values())a.destroy();n(this,Lt).clear(),n(this,wt).clear(),n(this,Bi).clear(),p(this,re,null),n(this,et).clear(),n(this,Re).destroy(),(s=n(this,Jn))==null||s.destroy(),(i=n(this,Ue))==null||i.hide(),p(this,Ue,null),n(this,Ge)&&(clearTimeout(n(this,Ge)),p(this,Ge,null)),n(this,qe)&&(clearTimeout(n(this,qe)),p(this,qe,null))}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return n(this,kr)}get useNewAltTextFlow(){return n(this,Sr)}get useNewAltTextWhenAddingImage(){return n(this,ea)}get hcmFilter(){return K(this,"hcmFilter",n(this,zi)?n(this,Er).addHCMFilter(n(this,zi).foreground,n(this,zi).background):"none")}get direction(){return K(this,"direction",getComputedStyle(n(this,ps)).direction)}get highlightColors(){return K(this,"highlightColors",n(this,sa)?new Map(n(this,sa).split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return K(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setMainHighlightColorPicker(t){p(this,Mr,t)}editAltText(t,e=!1){var s;(s=n(this,Jn))==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}){t==="enableNewAltTextWhenAddingImage"&&p(this,ea,e)}onPageChanging({pageNumber:t}){p(this,ta,t-1)}focusMainContainer(){n(this,ps).focus()}findParent(t,e){for(const s of n(this,Lt).values()){const{x:i,y:a,width:r,height:o}=s.div.getBoundingClientRect();if(t>=i&&t<=i+r&&e>=a&&e<=a+o)return s}return null}disableUserSelect(t=!1){n(this,Pr).classList.toggle("noUserSelect",t)}addShouldRescale(t){n(this,Bi).add(t)}removeShouldRescale(t){n(this,Bi).delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*yi.PDF_TO_CSS_UNITS;for(const e of n(this,Bi))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:a,focusOffset:r}=e,o=e.toString(),h=m(this,T,Wo).call(this,e).closest(".textLayer"),l=this.getSelectionBoxes(h);if(!l)return;e.empty();const c=m(this,T,gl).call(this,h),d=n(this,kt)===V.NONE,f=()=>{c==null||c.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:l,anchorNode:s,anchorOffset:i,focusNode:a,focusOffset:r,text:o}),d&&this.showAllEditors("highlight",!0,!0)};d?this.switchToMode(V.HIGHLIGHT,f):f()}addToAnnotationStorage(t){t.isEmpty()||!n(this,us)||n(this,us).has(t.id)||n(this,us).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,n(this,Qs)&&(p(this,Qs,!1),m(this,T,Xo).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of n(this,et))if(e.div.contains(t)){p(this,Hi,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!n(this,Hi))return;const[t,e]=n(this,Hi);p(this,Hi,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){m(this,T,ml).call(this),m(this,T,bl).call(this)}removeEditListeners(){m(this,T,Pd).call(this),m(this,T,Al).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of n(this,Pe))if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of n(this,Pe))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=n(this,re))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of n(this,et)){const a=i.serialize(!0);a&&e.push(a)}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 a of e.items)for(const r of n(this,Pe))if(r.isHandlingMimeForPasting(a.type)){r.paste(a,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(a){q(`paste: "${a.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const a=[];for(const h of s){const l=await i.deserialize(h);if(!l)return;a.push(l)}const r=()=>{for(const h of a)m(this,T,vl).call(this,h);m(this,T,yl).call(this,a)},o=()=>{for(const h of a)h.remove()};this.addCommands({cmd:r,undo:o,mustExec:!0})}catch(a){q(`paste: "${a.message}".`)}}keydown(t){this.isShiftKeyDown||t.key!=="Shift"||(this.isShiftKeyDown=!0),n(this,kt)===V.NONE||this.isEditorHandlingKeyboard||qn._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,n(this,Qs)&&(p(this,Qs,!1),m(this,T,Xo).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")}}setEditingState(t){t?(m(this,T,Td).call(this),m(this,T,bl).call(this),m(this,T,Ut).call(this,{isEditing:n(this,kt)!==V.NONE,isEmpty:m(this,T,Qa).call(this),hasSomethingToUndo:n(this,Re).hasSomethingToUndo(),hasSomethingToRedo:n(this,Re).hasSomethingToRedo(),hasSelectedEditor:!1})):(m(this,T,Rd).call(this),m(this,T,Al).call(this),m(this,T,Ut).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!n(this,Pe)){p(this,Pe,t);for(const e of n(this,Pe))m(this,T,Gs).call(this,e.defaultPropertiesToUpdate)}}getId(){return n(this,Th).id}get currentLayer(){return n(this,Lt).get(n(this,ta))}getLayer(t){return n(this,Lt).get(t)}get currentPageIndex(){return n(this,ta)}addLayer(t){n(this,Lt).set(t.pageIndex,t),n(this,Js)?t.enable():t.disable()}removeLayer(t){n(this,Lt).delete(t.pageIndex)}async updateMode(t,e=null,s=!1){if(n(this,kt)!==t){if(n(this,be)&&(await n(this,be).promise,!n(this,be)))return;if(p(this,be,Promise.withResolvers()),p(this,kt,t),t!==V.NONE){this.setEditingState(!0),await m(this,T,Ld).call(this),this.unselectAll();for(const i of n(this,Lt).values())i.updateMode(t);if(e){for(const i of n(this,wt).values())i.annotationElementId===e?(this.setSelected(i),i.enterInEditMode()):i.unselect();n(this,be).resolve()}else s&&this.addNewEditorFromKeyboard(),n(this,be).resolve()}else this.setEditingState(!1),m(this,T,Fd).call(this),n(this,be).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==n(this,kt)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){var s;if(n(this,Pe)){switch(t){case O.CREATE:this.currentLayer.addNewEditor();return;case O.HIGHLIGHT_DEFAULT_COLOR:(s=n(this,Mr))==null||s.updateColor(e);break;case O.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(n(this,Tr)||p(this,Tr,new Map)).set(t,e),this.showAllEditors("highlight",e)}for(const i of n(this,et))i.updateParams(t,e);for(const i of n(this,Pe))i.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var i;for(const a of n(this,wt).values())a.editorType===t&&a.show(e);(((i=n(this,Tr))==null?void 0:i.get(O.HIGHLIGHT_SHOW_ALL))??!0)!==e&&m(this,T,Gs).call(this,[[O.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(n(this,Cr)!==t){p(this,Cr,t);for(const e of n(this,Lt).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const s of n(this,wt).values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return n(this,wt).get(t)}addEditor(t){n(this,wt).set(t.id,t)}removeEditor(t){var e;t.div.contains(document.activeElement)&&(n(this,Ge)&&clearTimeout(n(this,Ge)),p(this,Ge,setTimeout(()=>{this.focusMainContainer(),p(this,Ge,null)},0))),n(this,wt).delete(t.id),this.unselect(t),t.annotationElementId&&n(this,Oi).has(t.annotationElementId)||((e=n(this,us))==null||e.remove(t.id))}addDeletedAnnotationElement(t){n(this,Oi).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return n(this,Oi).has(t)}removeDeletedAnnotationElement(t){n(this,Oi).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){n(this,re)!==t&&(p(this,re,t),t&&m(this,T,Gs).call(this,t.propertiesToUpdate))}updateUI(t){n(this,T,Dd)===t&&m(this,T,Gs).call(this,t.propertiesToUpdate)}toggleSelected(t){n(this,et).has(t)?(n(this,et).delete(t),t.unselect(),m(this,T,Ut).call(this,{hasSelectedEditor:this.hasSelection})):(n(this,et).add(t),t.select(),m(this,T,Gs).call(this,t.propertiesToUpdate),m(this,T,Ut).call(this,{hasSelectedEditor:!0}))}setSelected(t){for(const e of n(this,et))e!==t&&e.unselect();n(this,et).clear(),n(this,et).add(t),t.select(),m(this,T,Gs).call(this,t.propertiesToUpdate),m(this,T,Ut).call(this,{hasSelectedEditor:!0})}isSelected(t){return n(this,et).has(t)}get firstSelectedEditor(){return n(this,et).values().next().value}unselect(t){t.unselect(),n(this,et).delete(t),m(this,T,Ut).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return n(this,et).size!==0}get isEnterHandled(){return n(this,et).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){n(this,Re).undo(),m(this,T,Ut).call(this,{hasSomethingToUndo:n(this,Re).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:m(this,T,Qa).call(this)})}redo(){n(this,Re).redo(),m(this,T,Ut).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:n(this,Re).hasSomethingToRedo(),isEmpty:m(this,T,Qa).call(this)})}addCommands(t){n(this,Re).add(t),m(this,T,Ut).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:m(this,T,Qa).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...n(this,et)];this.addCommands({cmd:()=>{for(const e of t)e.remove()},undo:()=>{for(const e of t)m(this,T,vl).call(this,e)},mustExec:!0})}commitOrRemove(){var t;(t=n(this,re))==null||t.commitOrRemove()}hasSomethingToControl(){return n(this,re)||this.hasSelection}selectAll(){for(const t of n(this,et))t.commit();m(this,T,yl).call(this,n(this,wt).values())}unselectAll(){if(!(n(this,re)&&(n(this,re).commitOrRemove(),n(this,kt)!==V.NONE))&&this.hasSelection){for(const t of n(this,et))t.unselect();n(this,et).clear(),m(this,T,Ut).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;n(this,ti)[0]+=t,n(this,ti)[1]+=e;const[i,a]=n(this,ti),r=[...n(this,et)];n(this,qe)&&clearTimeout(n(this,qe)),p(this,qe,setTimeout(()=>{p(this,qe,null),n(this,ti)[0]=n(this,ti)[1]=0,this.addCommands({cmd:()=>{for(const o of r)n(this,wt).has(o.id)&&o.translateInPage(i,a)},undo:()=>{for(const o of r)n(this,wt).has(o.id)&&o.translateInPage(-i,-a)},mustExec:!1})},1e3));for(const o of r)o.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),p(this,Ve,new Map);for(const t of n(this,et))n(this,Ve).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!n(this,Ve))return!1;this.disableUserSelect(!1);const t=n(this,Ve);p(this,Ve,null);let e=!1;for(const[{x:i,y:a,pageIndex:r},o]of t)o.newX=i,o.newY=a,o.newPageIndex=r,e||(e=i!==o.savedX||a!==o.savedY||r!==o.savedPageIndex);if(!e)return!1;const s=(i,a,r,o)=>{if(n(this,wt).has(i.id)){const h=n(this,Lt).get(o);h?i._setParentAndPosition(h,a,r):(i.pageIndex=o,i.x=a,i.y=r)}};return this.addCommands({cmd:()=>{for(const[i,{newX:a,newY:r,newPageIndex:o}]of t)s(i,a,r,o)},undo:()=>{for(const[i,{savedX:a,savedY:r,savedPageIndex:o}]of t)s(i,a,r,o)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(n(this,Ve))for(const s of n(this,Ve).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())||n(this,et).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return n(this,re)===t}getActive(){return n(this,re)}getMode(){return n(this,kt)}get imageManager(){return K(this,"imageManager",new fl)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let l=0,c=e.rangeCount;l<c;l++)if(!t.contains(e.getRangeAt(l).commonAncestorContainer))return null;const{x:s,y:i,width:a,height:r}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(l,c,d,f)=>({x:(c-i)/r,y:1-(l+d-s)/a,width:f/r,height:d/a});break;case"180":o=(l,c,d,f)=>({x:1-(l+d-s)/a,y:1-(c+f-i)/r,width:d/a,height:f/r});break;case"270":o=(l,c,d,f)=>({x:1-(c+f-i)/r,y:(l-s)/a,width:f/r,height:d/a});break;default:o=(l,c,d,f)=>({x:(l-s)/a,y:(c-i)/r,width:d/a,height:f/r})}const h=[];for(let l=0,c=e.rangeCount;l<c;l++){const d=e.getRangeAt(l);if(!d.collapsed)for(const{x:f,y:g,width:A,height:v}of d.getClientRects())A!==0&&v!==0&&h.push(o(f,g,A,v))}return h.length===0?null:h}addChangedExistingAnnotation({annotationElementId:t,id:e}){(n(this,Zn)||p(this,Zn,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=n(this,Zn))==null||e.delete(t)}renderAnnotationElement(t){var i;const e=(i=n(this,Zn))==null?void 0:i.get(t.data.id);if(!e)return;const s=n(this,us).getRawValue(e);s&&(n(this,kt)!==V.NONE||s.hasBeenModified)&&s.renderAnnotationElement(t)}};Qn=new WeakMap,re=new WeakMap,wt=new WeakMap,Lt=new WeakMap,Jn=new WeakMap,us=new WeakMap,Zn=new WeakMap,Re=new WeakMap,Ks=new WeakMap,ta=new WeakMap,Oi=new WeakMap,Ve=new WeakMap,Pe=new WeakMap,Bi=new WeakMap,xr=new WeakMap,Sr=new WeakMap,ea=new WeakMap,Er=new WeakMap,Ge=new WeakMap,Ys=new WeakMap,sa=new WeakMap,Qs=new WeakMap,Ue=new WeakMap,Th=new WeakMap,Js=new WeakMap,Cr=new WeakMap,Zs=new WeakMap,Hi=new WeakMap,Mr=new WeakMap,kr=new WeakMap,kt=new WeakMap,et=new WeakMap,fs=new WeakMap,zi=new WeakMap,Tr=new WeakMap,Rr=new WeakMap,ti=new WeakMap,qe=new WeakMap,ps=new WeakMap,Pr=new WeakMap,be=new WeakMap,T=new WeakSet,Wo=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},gl=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of n(this,Lt).values())if(s.hasTextLayer(t))return s;return null},Cd=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=m(this,T,Wo).call(this,t).closest(".textLayer"),s=this.getSelectionBoxes(e);s&&(n(this,Ue)||p(this,Ue,new mp(this)),n(this,Ue).show(e,s,this.direction==="ltr"))},Md=function(){var i,a,r;const t=document.getSelection();if(!t||t.isCollapsed){n(this,fs)&&((i=n(this,Ue))==null||i.hide(),p(this,fs,null),m(this,T,Ut).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===n(this,fs))return;const s=m(this,T,Wo).call(this,t).closest(".textLayer");if(s){if((a=n(this,Ue))==null||a.hide(),p(this,fs,e),m(this,T,Ut).call(this,{hasSelectedText:!0}),(n(this,kt)===V.HIGHLIGHT||n(this,kt)===V.NONE)&&(n(this,kt)===V.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),p(this,Qs,this.isShiftKeyDown),!this.isShiftKeyDown)){const o=n(this,kt)===V.HIGHLIGHT?m(this,T,gl).call(this,s):null;o==null||o.toggleDrawing();const h=new AbortController,l=this.combinedSignal(h),c=d=>{(d.type!=="pointerup"||d.button===0)&&(h.abort(),o==null||o.toggleDrawing(!0),d.type==="pointerup"&&m(this,T,Xo).call(this,"main_toolbar"))};window.addEventListener("pointerup",c,{signal:l}),window.addEventListener("blur",c,{signal:l})}}else n(this,fs)&&((r=n(this,Ue))==null||r.hide(),p(this,fs,null),m(this,T,Ut).call(this,{hasSelectedText:!1}))},Xo=function(t=""){n(this,kt)===V.HIGHLIGHT?this.highlightSelection(t):n(this,xr)&&m(this,T,Cd).call(this)},kd=function(){document.addEventListener("selectionchange",m(this,T,Md).bind(this),{signal:this._signal})},Td=function(){if(n(this,Ys))return;p(this,Ys,new AbortController);const t=this.combinedSignal(n(this,Ys));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},Rd=function(){var t;(t=n(this,Ys))==null||t.abort(),p(this,Ys,null)},ml=function(){if(n(this,Zs))return;p(this,Zs,new AbortController);const t=this.combinedSignal(n(this,Zs));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},Pd=function(){var t;(t=n(this,Zs))==null||t.abort(),p(this,Zs,null)},bl=function(){if(n(this,Ks))return;p(this,Ks,new AbortController);const t=this.combinedSignal(n(this,Ks));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})},Al=function(){var t;(t=n(this,Ks))==null||t.abort(),p(this,Ks,null)},Id=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},Ut=function(t){Object.entries(t).some(([e,s])=>n(this,Rr)[e]!==s)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(n(this,Rr),t)}),n(this,kt)===V.HIGHLIGHT&&t.hasSelectedEditor===!1&&m(this,T,Gs).call(this,[[O.HIGHLIGHT_FREE,!0]]))},Gs=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},Ld=async function(){if(!n(this,Js)){p(this,Js,!0);const t=[];for(const e of n(this,Lt).values())t.push(e.enable());await Promise.all(t);for(const e of n(this,wt).values())e.enable()}},Fd=function(){if(this.unselectAll(),n(this,Js)){p(this,Js,!1);for(const t of n(this,Lt).values())t.disable();for(const t of n(this,wt).values())t.disable()}},vl=function(t){const e=n(this,Lt).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Dd=function(){let t=null;for(t of n(this,et));return t},Qa=function(){if(n(this,wt).size===0)return!0;if(n(this,wt).size===1)for(const t of n(this,wt).values())return t.isEmpty();return!1},yl=function(t){for(const e of n(this,et))e.unselect();n(this,et).clear();for(const e of t)e.isEmpty()||(n(this,et).add(e),e.select());m(this,T,Ut).call(this,{hasSelectedEditor:this.hasSelection})},N(qn,"TRANSLATE_SMALL",1),N(qn,"TRANSLATE_BIG",10);let Pn=qn;var Tt,We,Ie,ia,Xe,oe,na,Ke,Jt,gs,ji,Ye,ei,$e,Ja,Ko;const qt=class qt{constructor(t){b(this,$e);b(this,Tt,null);b(this,We,!1);b(this,Ie,null);b(this,ia,null);b(this,Xe,null);b(this,oe,null);b(this,na,!1);b(this,Ke,null);b(this,Jt,null);b(this,gs,null);b(this,ji,null);b(this,Ye,!1);p(this,Jt,t),p(this,Ye,t._uiManager.useNewAltTextFlow),n(qt,ei)||p(qt,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){qt._l10n??(qt._l10n=t)}async render(){const t=p(this,Ie,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=p(this,ia,document.createElement("span"));t.append(e),n(this,Ye)?(t.classList.add("new"),t.setAttribute("data-l10n-id",n(qt,ei).missing),e.setAttribute("data-l10n-id",n(qt,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=n(this,Jt)._uiManager._signal;t.addEventListener("contextmenu",Ee,{signal:s}),t.addEventListener("pointerdown",a=>a.stopPropagation(),{signal:s});const i=a=>{a.preventDefault(),n(this,Jt)._uiManager.editAltText(n(this,Jt)),n(this,Ye)&&n(this,Jt)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:n(this,$e,Ja)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",a=>{a.target===t&&a.key==="Enter"&&(p(this,na,!0),i(a))},{signal:s}),await m(this,$e,Ko).call(this),t}finish(){n(this,Ie)&&(n(this,Ie).focus({focusVisible:n(this,na)}),p(this,na,!1))}isEmpty(){return n(this,Ye)?n(this,Tt)===null:!n(this,Tt)&&!n(this,We)}hasData(){return n(this,Ye)?n(this,Tt)!==null||!!n(this,gs):this.isEmpty()}get guessedText(){return n(this,gs)}async setGuessedText(t){n(this,Tt)===null&&(p(this,gs,t),p(this,ji,await qt._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),m(this,$e,Ko).call(this))}toggleAltTextBadge(t=!1){var e;if(n(this,Ye)&&!n(this,Tt)){if(!n(this,Ke)){const s=p(this,Ke,document.createElement("div"));s.className="noAltTextBadge",n(this,Jt).div.append(s)}n(this,Ke).classList.toggle("hidden",!t)}else(e=n(this,Ke))==null||e.remove(),p(this,Ke,null)}serialize(t){let e=n(this,Tt);return t||n(this,gs)!==e||(e=n(this,ji)),{altText:e,decorative:n(this,We),guessedText:n(this,gs),textWithDisclaimer:n(this,ji)}}get data(){return{altText:n(this,Tt),decorative:n(this,We)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:a=!1}){s&&(p(this,gs,s),p(this,ji,i)),(n(this,Tt)!==t||n(this,We)!==e)&&(a||(p(this,Tt,t),p(this,We,e)),m(this,$e,Ko).call(this))}toggle(t=!1){n(this,Ie)&&(!t&&n(this,oe)&&(clearTimeout(n(this,oe)),p(this,oe,null)),n(this,Ie).disabled=!t)}shown(){n(this,Jt)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:n(this,$e,Ja)}})}destroy(){var t,e;(t=n(this,Ie))==null||t.remove(),p(this,Ie,null),p(this,ia,null),p(this,Xe,null),(e=n(this,Ke))==null||e.remove(),p(this,Ke,null)}};Tt=new WeakMap,We=new WeakMap,Ie=new WeakMap,ia=new WeakMap,Xe=new WeakMap,oe=new WeakMap,na=new WeakMap,Ke=new WeakMap,Jt=new WeakMap,gs=new WeakMap,ji=new WeakMap,Ye=new WeakMap,ei=new WeakMap,$e=new WeakSet,Ja=function(){return(n(this,Tt)?"added":n(this,Tt)===null&&this.guessedText&&"review")||"missing"},Ko=async function(){var i,a,r;const t=n(this,Ie);if(!t)return;if(n(this,Ye)){if(t.classList.toggle("done",!!n(this,Tt)),t.setAttribute("data-l10n-id",n(qt,ei)[n(this,$e,Ja)]),(i=n(this,ia))==null||i.setAttribute("data-l10n-id",n(qt,ei)[`${n(this,$e,Ja)}-label`]),!n(this,Tt)){(a=n(this,Xe))==null||a.remove();return}}else{if(!n(this,Tt)&&!n(this,We)){t.classList.remove("done"),(r=n(this,Xe))==null||r.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=n(this,Xe);if(!e){p(this,Xe,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${n(this,Jt).id}`;const o=100,h=n(this,Jt)._uiManager._signal;h.addEventListener("abort",()=>{clearTimeout(n(this,oe)),p(this,oe,null)},{once:!0}),t.addEventListener("mouseenter",()=>{p(this,oe,setTimeout(()=>{p(this,oe,null),n(this,Xe).classList.add("show"),n(this,Jt)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:h}),t.addEventListener("mouseleave",()=>{var l;n(this,oe)&&(clearTimeout(n(this,oe)),p(this,oe,null)),(l=n(this,Xe))==null||l.classList.remove("show")},{signal:h})}n(this,We)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=n(this,Tt)),e.parentNode||t.append(e);const s=n(this,Jt).getImageForAltText();s==null||s.setAttribute("aria-describedby",e.id)},b(qt,ei,null),N(qt,"_l10n",null);let wh=qt;var $i,Le,ct,aa,Vi,Ft,Gi,si,Ir,Ui,ii,Lr,qi,ms,Qe,ra,oa,Ae,Fr,Rh,G,wl,Dr,_l,xl,Nd,Od,Sl,El,Cl,Bd,Ml,Hd,zd,jd,kl,Za;const Z=class Z{constructor(t){b(this,G);b(this,$i,null);b(this,Le,null);b(this,ct,null);b(this,aa,!1);b(this,Vi,!1);b(this,Ft,null);b(this,Gi,null);b(this,si,null);b(this,Ir,"");b(this,Ui,!1);b(this,ii,null);b(this,Lr,!1);b(this,qi,!1);b(this,ms,!1);b(this,Qe,null);b(this,ra,0);b(this,oa,0);b(this,Ae,null);N(this,"_editToolbar",null);N(this,"_initialOptions",Object.create(null));N(this,"_initialData",null);N(this,"_isVisible",!0);N(this,"_uiManager",null);N(this,"_focusEventsAllowed",!0);b(this,Fr,!1);b(this,Rh,Z._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:a,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[a,r];const[o,h]=this.parentDimensions;this.x=t.x/o,this.y=t.y/h,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=Z.prototype._resizeWithKeyboard,e=Pn.TRANSLATE_SMALL,s=Pn.TRANSLATE_BIG;return K(this,"_resizerKeyboardManager",new Fo([[["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"],Z.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return K(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new vp({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(Z._l10n??(Z._l10n=t),Z._l10nResizer||(Z._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"})),Z._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);Z._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){ot("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return n(this,Fr)}set _isDraggable(t){var e;p(this,Fr,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/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=n(this,Rh)}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):m(this,G,Za).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(n(this,Ui)?p(this,Ui,!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[a,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/a,this.y=(e+i)/r,this.fixAndSetPosition()}translate(t,e){m(this,G,wl).call(this,this.parentDimensions,t,e)}translateInPage(t,e){n(this,ii)||p(this,ii,[this.x,this.y]),m(this,G,wl).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){n(this,ii)||p(this,ii,[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:l,y:c}=this.div.getBoundingClientRect();this.parent.findNewParent(this,l,c)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:r}=this;const[o,h]=this.getBaseTranslation();a+=o,r+=h,this.div.style.left=`${(100*a).toFixed(2)}%`,this.div.style.top=`${(100*r).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!n(this,ii)&&(n(this,ii)[0]!==this.x||n(this,ii)[1]!==this.y)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=Z,i=s/t,a=s/e;switch(this.rotation){case 90:return[-i,a];case 180:return[i,a];case 270:return[i,-a];default:return[-i,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const[e,s]=this.pageDimensions;let{x:i,y:a,width:r,height:o}=this;if(r*=e,o*=s,i*=e,a*=s,this._mustFixPosition)switch(t){case 0:i=Math.max(0,Math.min(e-r,i)),a=Math.max(0,Math.min(s-o,a));break;case 90:i=Math.max(0,Math.min(e-o,i)),a=Math.min(s,Math.max(r,a));break;case 180:i=Math.min(e,Math.max(r,i)),a=Math.min(s,Math.max(o,a));break;case 270:i=Math.min(e,Math.max(o,i)),a=Math.max(0,Math.min(s-r,a))}this.x=i/=e,this.y=a/=s;const[h,l]=this.getBaseTranslation();i+=h,a+=l;const{style:c}=this.div;c.left=`${(100*i).toFixed(2)}%`,c.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var s;return m(s=Z,Dr,_l).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return m(s=Z,Dr,_l).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)}%`,n(this,Vi)||(this.div.style.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),a=!n(this,Vi)&&e.endsWith("%");if(i&&a)return;const[r,o]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/r).toFixed(2)}%`),n(this,Vi)||a||(t.height=`${(100*parseFloat(e)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}altTextFinish(){var t;(t=n(this,ct))==null||t.finish()}async addEditToolbar(){return this._editToolbar||n(this,qi)?this._editToolbar:(this._editToolbar=new dl(this),this.div.append(this._editToolbar.render()),n(this,ct)&&await this._editToolbar.addAltText(n(this,ct)),this._editToolbar)}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,(t=n(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(){n(this,ct)||(wh.initialize(Z._l10n),p(this,ct,new wh(this)),n(this,$i)&&(n(this,ct).data=n(this,$i),p(this,$i,null)),await this.addEditToolbar())}get altTextData(){var t;return(t=n(this,ct))==null?void 0:t.data}set altTextData(t){n(this,ct)&&(n(this,ct).data=t)}get guessedAltText(){var t;return(t=n(this,ct))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=n(this,ct))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=n(this,ct))==null?void 0:e.serialize(t)}hasAltText(){return!!n(this,ct)&&!n(this,ct).isEmpty()}hasAltTextData(){var t;return((t=n(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=n(this,aa)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),m(this,G,Ml).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),yh(this,this.div,["pointerdown"]),this.div}pointerdown(t){const{isMac:e}=Wt.platform;t.button!==0||t.ctrlKey&&e?t.preventDefault():(p(this,Ui,!0),this._isDraggable?m(this,G,Bd).call(this,t):m(this,G,Cl).call(this,t))}get isSelected(){return this._uiManager.isSelected(this)}moveInDOM(){n(this,Qe)&&clearTimeout(n(this,Qe)),p(this,Qe,setTimeout(()=>{var t;p(this,Qe,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,[a,r]=this.pageDimensions,[o,h]=this.pageTranslation,l=t/i,c=e/i,d=this.x*a,f=this.y*r,g=this.width*a,A=this.height*r;switch(s){case 0:return[d+l+o,r-f-c-A+h,d+l+g+o,r-f-c+h];case 90:return[d+c+o,r-f+l+h,d+c+A+o,r-f+l+g+h];case 180:return[d-l-g+o,r-f+c+h,d-l+o,r-f+c+A+h];case 270:return[d-c-A+o,r-f-l-g+h,d-c+o,r-f-l+h];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,a,r]=t,o=a-s,h=r-i;switch(this.rotation){case 0:return[s,e-r,o,h];case 90:return[s,e-i,h,o];case 180:return[a,e-i,o,h];case 270:return[a,e-r,h,o];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){p(this,qi,!0)}disableEditMode(){p(this,qi,!1)}isInEditMode(){return n(this,qi)}shouldGetKeyboardEvents(){return n(this,ms)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){m(this,G,Ml).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){ot("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,$i,t.accessibilityData);const[a,r]=i.pageDimensions,[o,h,l,c]=i.getRectInCurrentCoords(t.rect,r);return i.x=o/a,i.y=h/r,i.width=l/a,i.height=c/r,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t;if((t=n(this,si))==null||t.abort(),p(this,si,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),n(this,Qe)&&(clearTimeout(n(this,Qe)),p(this,Qe,null)),m(this,G,Za).call(this),this.removeEditToolbar(),n(this,Ae)){for(const e of n(this,Ae).values())clearTimeout(e);p(this,Ae,null)}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(m(this,G,Nd).call(this),n(this,Ft).classList.remove("hidden"),yh(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,Gi,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=n(this,Ft).children;if(!n(this,Le)){p(this,Le,Array.from(e));const r=m(this,G,Hd).bind(this),o=m(this,G,zd).bind(this),h=this._uiManager._signal;for(const l of n(this,Le)){const c=l.getAttribute("data-resizer-name");l.setAttribute("role","spinbutton"),l.addEventListener("keydown",r,{signal:h}),l.addEventListener("blur",o,{signal:h}),l.addEventListener("focus",m(this,G,jd).bind(this,c),{signal:h}),l.setAttribute("data-l10n-id",Z._l10nResizer[c])}}const s=n(this,Le)[0];let i=0;for(const r of e){if(r===s)break;i++}const a=(360-this.rotation+this.parentRotation)%360/90*(n(this,Le).length/4);if(a!==i){if(a<i)for(let o=0;o<i-a;o++)n(this,Ft).append(n(this,Ft).firstChild);else if(a>i)for(let o=0;o<a-i;o++)n(this,Ft).firstChild.before(n(this,Ft).lastChild);let r=0;for(const o of e){const h=n(this,Le)[r++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",Z._l10nResizer[h])}}m(this,G,kl).call(this,0),p(this,ms,!0),n(this,Ft).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){n(this,ms)&&m(this,G,El).call(this,n(this,Ir),{movementX:t,movementY:e})}_stopResizingWithKeyboard(){m(this,G,Za).call(this),this.div.focus()}select(){var t,e,s;this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),this._editToolbar?((e=this._editToolbar)==null||e.show(),(s=n(this,ct))==null||s.toggleAltTextBadge(!1)):this.addEditToolbar().then(()=>{var i,a;(i=this.div)!=null&&i.classList.contains("selectedEditor")&&((a=this._editToolbar)==null||a.show())})}unselect(){var t,e,s,i,a;(t=n(this,Ft))==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(),(a=n(this,ct))==null||a.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return n(this,Lr)}set isEditing(t){p(this,Lr,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){p(this,Vi,!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){n(this,Ae)||p(this,Ae,new Map);const{action:s}=t;let i=n(this,Ae).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),n(this,Ae).delete(s),n(this,Ae).size===0&&p(this,Ae,null)},Z._telemetryTimeout),n(this,Ae).set(s,i)}else 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,aa,!1)}disable(){this.div&&(this.div.tabIndex=-1),p(this,aa,!0)}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;(e==null?void 0:e.nodeName)==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};$i=new WeakMap,Le=new WeakMap,ct=new WeakMap,aa=new WeakMap,Vi=new WeakMap,Ft=new WeakMap,Gi=new WeakMap,si=new WeakMap,Ir=new WeakMap,Ui=new WeakMap,ii=new WeakMap,Lr=new WeakMap,qi=new WeakMap,ms=new WeakMap,Qe=new WeakMap,ra=new WeakMap,oa=new WeakMap,Ae=new WeakMap,Fr=new WeakMap,Rh=new WeakMap,G=new WeakSet,wl=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this.fixAndSetPosition()},Dr=new WeakSet,_l=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]}},xl=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]}},Nd=function(){if(n(this,Ft))return;p(this,Ft,document.createElement("div")),n(this,Ft).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");n(this,Ft).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",m(this,G,Od).bind(this,s),{signal:e}),i.addEventListener("contextmenu",Ee,{signal:e}),i.tabIndex=-1}this.div.prepend(n(this,Ft))},Od=function(t,e){var A;e.preventDefault();const{isMac:s}=Wt.platform;if(e.button!==0||e.ctrlKey&&s)return;(A=n(this,ct))==null||A.toggle(!1);const i=this._isDraggable;this._isDraggable=!1;const a=new AbortController,r=this._uiManager.combinedSignal(a);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",m(this,G,El).bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("contextmenu",Ee,{signal:r});const o=this.x,h=this.y,l=this.width,c=this.height,d=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 v;a.abort(),this.parent.togglePointerEvents(!0),(v=n(this,ct))==null||v.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=d,this.div.style.cursor=f,m(this,G,Sl).call(this,o,h,l,c)};window.addEventListener("pointerup",g,{signal:r}),window.addEventListener("blur",g,{signal:r})},Sl=function(t,e,s,i){const a=this.x,r=this.y,o=this.width,h=this.height;a===t&&r===e&&o===s&&h===i||this.addCommands({cmd:()=>{this.width=o,this.height=h,this.x=a,this.y=r;const[l,c]=this.parentDimensions;this.setDims(l*o,c*h),this.fixAndSetPosition()},undo:()=>{this.width=s,this.height=i,this.x=t,this.y=e;const[l,c]=this.parentDimensions;this.setDims(l*s,c*i),this.fixAndSetPosition()},mustExec:!0})},El=function(t,e){const[s,i]=this.parentDimensions,a=this.x,r=this.y,o=this.width,h=this.height,l=Z.MIN_SIZE/s,c=Z.MIN_SIZE/i,d=H=>Math.round(1e4*H)/1e4,f=m(this,G,xl).call(this,this.rotation),g=(H,U)=>[f[0]*H+f[2]*U,f[1]*H+f[3]*U],A=m(this,G,xl).call(this,360-this.rotation);let v,w,y=!1,x=!1;switch(t){case"topLeft":y=!0,v=(H,U)=>[0,0],w=(H,U)=>[H,U];break;case"topMiddle":v=(H,U)=>[H/2,0],w=(H,U)=>[H/2,U];break;case"topRight":y=!0,v=(H,U)=>[H,0],w=(H,U)=>[0,U];break;case"middleRight":x=!0,v=(H,U)=>[H,U/2],w=(H,U)=>[0,U/2];break;case"bottomRight":y=!0,v=(H,U)=>[H,U],w=(H,U)=>[0,0];break;case"bottomMiddle":v=(H,U)=>[H/2,U],w=(H,U)=>[H/2,0];break;case"bottomLeft":y=!0,v=(H,U)=>[0,U],w=(H,U)=>[H,0];break;case"middleLeft":x=!0,v=(H,U)=>[0,U/2],w=(H,U)=>[H,U/2]}const _=v(o,h),S=w(o,h);let E=g(...S);const M=d(a+E[0]),C=d(r+E[1]);let R=1,j=1,[D,F]=this.screenToPageTranslation(e.movementX,e.movementY);[D,F]=(Y=D/s,Q=F/i,[A[0]*Y+A[2]*Q,A[1]*Y+A[3]*Q]);var Y,Q;if(y){const H=Math.hypot(o,h);R=j=Math.max(Math.min(Math.hypot(S[0]-_[0]-D,S[1]-_[1]-F)/H,1/o,1/h),l/o,c/h)}else x?R=Math.max(l,Math.min(1,Math.abs(S[0]-_[0]-D)))/o:j=Math.max(c,Math.min(1,Math.abs(S[1]-_[1]-F)))/h;const B=d(o*R),ft=d(h*j);E=g(...w(B,ft));const ie=M-E[0],Ce=C-E[1];this.width=B,this.height=ft,this.x=ie,this.y=Ce,this.setDims(s*B,i*ft),this.fixAndSetPosition()},Cl=function(t){const{isMac:e}=Wt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Bd=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,ra,t.clientX),p(this,oa,t.clientY);const r=o=>{const{clientX:h,clientY:l}=o,[c,d]=this.screenToPageTranslation(h-n(this,ra),l-n(this,oa));p(this,ra,h),p(this,oa,l),this._uiManager.dragSelectedEditors(c,d)};window.addEventListener("pointermove",r,{passive:!0,capture:!0,signal:i})}const a=()=>{s.abort(),e&&this.div.classList.remove("moving"),p(this,Ui,!1),this._uiManager.endDragSession()||m(this,G,Cl).call(this,t)};window.addEventListener("pointerup",a,{signal:i}),window.addEventListener("blur",a,{signal:i})},Ml=function(){if(n(this,si)||!this.div)return;p(this,si,new AbortController);const t=this._uiManager.combinedSignal(n(this,si));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Hd=function(t){Z._resizerKeyboardManager.exec(this,t)},zd=function(t){var e;n(this,ms)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==n(this,Ft)&&m(this,G,Za).call(this)},jd=function(t){p(this,Ir,n(this,ms)?t:"")},kl=function(t){if(n(this,Le))for(const e of n(this,Le))e.tabIndex=t},Za=function(){if(p(this,ms,!1),m(this,G,kl).call(this,-1),n(this,Gi)){const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=n(this,Gi);m(this,G,Sl).call(this,t,e,s,i),p(this,Gi,null)}},b(Z,Dr),N(Z,"_l10n",null),N(Z,"_l10nResizer",null),N(Z,"_borderLineWidth",-1),N(Z,"_colorManager",new pl),N(Z,"_zIndex",1),N(Z,"_telemetryTimeout",1e3);let it=Z;class vp extends it{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const qc=3285377520,me=4294901760,Vs=65535;class $d{constructor(t){this.h1=t?4294967295&t:qc,this.h2=t?4294967295&t:qc}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(2*t.length),s=0;for(let v=0,w=t.length;v<w;v++){const y=t.charCodeAt(v);y<=255?e[s++]=y:(e[s++]=y>>>8,e[s++]=255&y)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),s=e.byteLength}const i=s>>2,a=s-4*i,r=new Uint32Array(e.buffer,0,i);let o=0,h=0,l=this.h1,c=this.h2;const d=3432918353,f=461845907,g=11601,A=13715;for(let v=0;v<i;v++)1&v?(o=r[v],o=o*d&me|o*g&Vs,o=o<<15|o>>>17,o=o*f&me|o*A&Vs,l^=o,l=l<<13|l>>>19,l=5*l+3864292196):(h=r[v],h=h*d&me|h*g&Vs,h=h<<15|h>>>17,h=h*f&me|h*A&Vs,c^=h,c=c<<13|c>>>19,c=5*c+3864292196);switch(o=0,a){case 3:o^=e[4*i+2]<<16;case 2:o^=e[4*i+1]<<8;case 1:o^=e[4*i],o=o*d&me|o*g&Vs,o=o<<15|o>>>17,o=o*f&me|o*A&Vs,1&i?l^=o:c^=o}this.h1=l,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&me|36045*t&Vs,e=4283543511*e&me|(2950163797*(e<<16|t>>>16)&me)>>>16,t^=e>>>1,t=444984403*t&me|60499*t&Vs,e=3301882366*e&me|(3120437893*(e<<16|t>>>16)&me)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Tl=Object.freeze({map:null,hash:"",transfer:void 0});var Wi,Xi,Rt,Ph,Vd;class Tc{constructor(){b(this,Ph);b(this,Wi,!1);b(this,Xi,null);b(this,Rt,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=n(this,Rt).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return n(this,Rt).get(t)}remove(t){if(n(this,Rt).delete(t),n(this,Rt).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of n(this,Rt).values())if(e instanceof it)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=n(this,Rt).get(t);let i=!1;if(s!==void 0)for(const[a,r]of Object.entries(e))s[a]!==r&&(i=!0,s[a]=r);else i=!0,n(this,Rt).set(t,e);i&&m(this,Ph,Vd).call(this),e instanceof it&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return n(this,Rt).has(t)}getAll(){return n(this,Rt).size>0?Sc(n(this,Rt)):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return n(this,Rt).size}resetModified(){n(this,Wi)&&(p(this,Wi,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Gd(this)}get serializable(){if(n(this,Rt).size===0)return Tl;const t=new Map,e=new $d,s=[],i=Object.create(null);let a=!1;for(const[r,o]of n(this,Rt)){const h=o instanceof it?o.serialize(!1,i):o;h&&(t.set(r,h),e.update(`${r}:${JSON.stringify(h)}`),a||(a=!!h.bitmap))}if(a)for(const r of t.values())r.bitmap&&s.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:Tl}get editorStats(){let t=null;const e=new Map;for(const s of n(this,Rt).values()){if(!(s instanceof it))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:a}=i;e.has(a)||e.set(a,Object.getPrototypeOf(s).constructor),t||(t=Object.create(null));const r=t[a]||(t[a]=new Map);for(const[o,h]of Object.entries(i)){if(o==="type")continue;let l=r.get(o);l||(l=new Map,r.set(o,l));const c=l.get(h)??0;l.set(h,c+1)}}for(const[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}resetModifiedIds(){p(this,Xi,null)}get modifiedIds(){if(n(this,Xi))return n(this,Xi);const t=[];for(const e of n(this,Rt).values())e instanceof it&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return p(this,Xi,{ids:new Set(t),hash:t.join(",")})}}Wi=new WeakMap,Xi=new WeakMap,Rt=new WeakMap,Ph=new WeakSet,Vd=function(){n(this,Wi)||(p(this,Wi,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var Nr;class Gd extends Tc{constructor(e){super();b(this,Nr);const{map:s,hash:i,transfer:a}=e.serializable,r=structuredClone(s,a?{transfer:a}:null);p(this,Nr,{map:r,hash:i,transfer:a})}get print(){ot("Should not call PrintAnnotationStorage.print")}get serializable(){return n(this,Nr)}get modifiedIds(){return K(this,"modifiedIds",{ids:new Set,hash:""})}}Nr=new WeakMap;var ha;class yp{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){b(this,ha,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(),n(this,ha).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(t&&!n(this,ha).has(t.loadedName))if(St(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:i,style:a}=t,r=new FontFace(s,i,a);this.addNativeFontFace(r);try{await r.load(),n(this,ha).add(s),e==null||e(t)}catch{q(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}}else ot("Not implemented: loadSystemFont without the Font Loading API.")}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw q(`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 t;return K(this,"isFontLoadingAPISupported",!!((t=this._document)!=null&&t.fonts))}get isSyncFontLoadingSupported(){let t=!1;return($t||typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.userAgent)=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),K(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){const{loadingRequests:e}=this,s={done:!1,complete:function(){for(St(!s.done,"completeRequest() cannot be called twice."),s.done=!0;e.length>0&&e[0].done;){const a=e.shift();setTimeout(a.callback,0)}},callback:t};return e.push(s),s}get _loadTestFont(){return K(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function s(w,y){return w.charCodeAt(y)<<24|w.charCodeAt(y+1)<<16|w.charCodeAt(y+2)<<8|255&w.charCodeAt(y+3)}function i(w,y,x,_){return w.substring(0,y)+_+w.substring(y+x)}let a,r;const o=this._document.createElement("canvas");o.width=1,o.height=1;const h=o.getContext("2d");let l=0;const c=`lt${Date.now()}${this.loadTestFontId++}`;let d=this._loadTestFont;d=i(d,976,c.length,c);const f=1482184792;let g=s(d,16);for(a=0,r=c.length-3;a<r;a+=4)g=g-f+s(c,a)|0;a<c.length&&(g=g-f+s(c+"XXX",a)|0),d=i(d,16,4,function(y){return String.fromCharCode(y>>24&255,y>>16&255,y>>8&255,255&y)}(g));const A=`@font-face {font-family:"${c}";src:${`url(data:font/opentype;base64,${btoa(d)});`}}`;this.insertRule(A);const v=this._document.createElement("div");v.style.visibility="hidden",v.style.width=v.style.height="10px",v.style.position="absolute",v.style.top=v.style.left="0px";for(const w of[t.loadedName,c]){const y=this._document.createElement("span");y.textContent="Hi",y.style.fontFamily=w,v.append(y)}this._document.body.append(v),function w(y,x){if(++l>30){q("Load test font never loaded."),x();return}h.font="30px "+y,h.fillText(".",0,20),h.getImageData(0,0,1,1).data[3]>0?x():setTimeout(w.bind(null,y,x))}(c,()=>{v.remove(),e.complete()})}}ha=new WeakMap;class wp{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){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)}else t=new FontFace(this.loadedName,this.data,{});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,${function(a){return Uint8Array.prototype.toBase64?a.toBase64():btoa(bd(a))}(this.data)});`;let e;if(this.cssFontInfo){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}}`}else e=`@font-face {font-family:"${this.loadedName}";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(a){q(`getPathGenerator - ignoring character: "${a}".`)}if(!Array.isArray(s)||s.length===0)return this.compiledGlyphs[e]=function(a,r){};const i=[];for(let a=0,r=s.length;a<r;)switch(s[a++]){case np:{const[o,h,l,c,d,f]=s.slice(a,a+6);i.push(g=>g.bezierCurveTo(o,h,l,c,d,f)),a+=6}break;case ap:{const[o,h]=s.slice(a,a+2);i.push(l=>l.moveTo(o,h)),a+=2}break;case rp:{const[o,h]=s.slice(a,a+2);i.push(l=>l.lineTo(o,h)),a+=2}break;case op:{const[o,h,l,c]=s.slice(a,a+4);i.push(d=>d.quadraticCurveTo(o,h,l,c)),a+=4}break;case hp:i.push(o=>o.restore());break;case lp:i.push(o=>o.save());break;case cp:St(i.length===2,"Scale command is only valid at the third position.");break;case dp:{const[o,h,l,c,d,f]=s.slice(a,a+6);i.push(g=>g.transform(o,h,l,c,d,f)),a+=6}break;case up:{const[o,h]=s.slice(a,a+2);i.push(l=>l.translate(o,h)),a+=2}}return this.compiledGlyphs[e]=function(r,o){i[0](r),i[1](r),r.scale(o,-o);for(let h=2,l=i.length;h<l;h++)i[h](r)}}}var Or;class Wc{constructor({enableHWA:t=!1}){b(this,Or,!1);p(this,Or,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!n(this,Or)})}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){ot("Abstract method `_createCanvas` called.")}}Or=new WeakMap;class Ud{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(s=>({cMapData:s,isCompressed:this.isCompressed})).catch(s=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){ot("Abstract method `_fetch` called.")}}class qd extends Ud{async _fetch(t){const e=await Wh(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):qh(e)}}class Xc{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,a){return"none"}destroy(t=!1){}}class Wd{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){ot("Abstract method `_fetch` called.")}}class Xd extends Wd{async _fetch(t){const e=await Wh(t,"arraybuffer");return new Uint8Array(e)}}if($t){var Rl=Promise.withResolvers(),ur=null;(async()=>{const u=await No(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),t=await No(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),e=await No(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),s=await No(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]);return new Map(Object.entries({fs:u,http:t,https:e,url:s,canvas:void 0,path2d:void 0}))})().then(u=>{ur=u,Rl.resolve()},u=>{q(`loadPackages: ${u}`),ur=new Map,Rl.resolve()})}class wi{static get promise(){return Rl.promise}static get(t){return ur==null?void 0:ur.get(t)}}async function Kd(u){const t=wi.get("fs"),e=await t.promises.readFile(u);return new Uint8Array(e)}const Ii="Fill",Rc="Stroke",fr="Shading";function Pl(u,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),u.clip(i)}class Pc{getPattern(){ot("Abstract method `getPattern` called.")}}class _p extends Pc{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 a;if(i===Rc||i===Ii){const r=e.current.getClippedPathBoundingBox(i,ut(t))||[0,0,0,0],o=Math.ceil(r[2]-r[0])||1,h=Math.ceil(r[3]-r[1])||1,l=e.cachedCanvases.getCanvas("pattern",o,h),c=l.context;c.clearRect(0,0,c.canvas.width,c.canvas.height),c.beginPath(),c.rect(0,0,c.canvas.width,c.canvas.height),c.translate(-r[0],-r[1]),s=I.transform(s,[1,0,0,1,r[0],r[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),Pl(c,this._bbox),c.fillStyle=this._createGradient(c),c.fill(),a=t.createPattern(l.canvas,"no-repeat");const d=new DOMMatrix(s);a.setTransform(d)}else Pl(t,this._bbox),a=this._createGradient(t);return a}}function el(u,t,e,s,i,a,r,o){const h=t.coords,l=t.colors,c=u.data,d=4*u.width;let f;h[e+1]>h[s+1]&&(f=e,e=s,s=f,f=a,a=r,r=f),h[s+1]>h[i+1]&&(f=s,s=i,i=f,f=r,r=o,o=f),h[e+1]>h[s+1]&&(f=e,e=s,s=f,f=a,a=r,r=f);const g=(h[e]+t.offsetX)*t.scaleX,A=(h[e+1]+t.offsetY)*t.scaleY,v=(h[s]+t.offsetX)*t.scaleX,w=(h[s+1]+t.offsetY)*t.scaleY,y=(h[i]+t.offsetX)*t.scaleX,x=(h[i+1]+t.offsetY)*t.scaleY;if(A>=x)return;const _=l[a],S=l[a+1],E=l[a+2],M=l[r],C=l[r+1],R=l[r+2],j=l[o],D=l[o+1],F=l[o+2],Y=Math.round(A),Q=Math.round(x);let B,ft,ie,Ce,H,U,Ei,os;for(let Vt=Y;Vt<=Q;Vt++){if(Vt<w){const bt=Vt<A?0:(A-Vt)/(A-w);B=g-(g-v)*bt,ft=_-(_-M)*bt,ie=S-(S-C)*bt,Ce=E-(E-R)*bt}else{let bt;bt=Vt>x?1:w===x?0:(w-Vt)/(w-x),B=v-(v-y)*bt,ft=M-(M-j)*bt,ie=C-(C-D)*bt,Ce=R-(R-F)*bt}let Pt;Pt=Vt<A?0:Vt>x?1:(A-Vt)/(A-x),H=g-(g-y)*Pt,U=_-(_-j)*Pt,Ei=S-(S-D)*Pt,os=E-(E-F)*Pt;const $s=Math.round(Math.min(B,H)),ne=Math.round(Math.max(B,H));let tt=d*Vt+4*$s;for(let bt=$s;bt<=ne;bt++)Pt=(B-bt)/(B-H),Pt<0?Pt=0:Pt>1&&(Pt=1),c[tt++]=ft-(ft-U)*Pt|0,c[tt++]=ie-(ie-Ei)*Pt|0,c[tt++]=Ce-(Ce-os)*Pt|0,c[tt++]=255}}function xp(u,t,e){const s=t.coords,i=t.colors;let a,r;switch(t.type){case"lattice":const o=t.verticesPerRow,h=Math.floor(s.length/o)-1,l=o-1;for(a=0;a<h;a++){let c=a*o;for(let d=0;d<l;d++,c++)el(u,e,s[c],s[c+1],s[c+o],i[c],i[c+1],i[c+o]),el(u,e,s[c+o+1],s[c+1],s[c+o],i[c+o+1],i[c+1],i[c+o])}break;case"triangles":for(a=0,r=s.length;a<r;a+=3)el(u,e,s[a],s[a+1],s[a+2],i[a],i[a+1],i[a+2]);break;default:throw new Error("illegal figure")}}class Sp extends Pc{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,s){const i=Math.floor(this._bounds[0]),a=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-i,o=Math.ceil(this._bounds[3])-a,h=Math.min(Math.ceil(Math.abs(r*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(o*t[1]*1.1)),3e3),c=r/h,d=o/l,f={coords:this._coords,colors:this._colors,offsetX:-i,offsetY:-a,scaleX:1/c,scaleY:1/d},g=h+4,A=l+4,v=s.getCanvas("mesh",g,A),w=v.context,y=w.createImageData(h,l);if(e){const x=y.data;for(let _=0,S=x.length;_<S;_+=4)x[_]=e[0],x[_+1]=e[1],x[_+2]=e[2],x[_+3]=255}for(const x of this._figures)xp(y,x,f);return w.putImageData(y,2,2),{canvas:v.canvas,offsetX:i-2*c,offsetY:a-2*d,scaleX:c,scaleY:d}}getPattern(t,e,s,i){Pl(t,this._bbox);let a;if(i===fr)a=I.singularValueDecompose2dScale(ut(t));else if(a=I.singularValueDecompose2dScale(e.baseTransform),this.matrix){const o=I.singularValueDecompose2dScale(this.matrix);a=[a[0]*o[0],a[1]*o[1]]}const r=this._createMeshCanvas(a,i===fr?null:this._background,e.cachedCanvases);return i!==fr&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class Ep extends Pc{getPattern(){return"hotpink"}}const Cp=1,Mp=2,Ih=class Ih{constructor(t,e,s,i,a){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=s,this.canvasGraphicsFactory=i,this.baseTransform=a}createPatternCanvas(t){const{bbox:e,operatorList:s,paintType:i,tilingType:a,color:r,canvasGraphicsFactory:o}=this;let{xstep:h,ystep:l}=this;h=Math.abs(h),l=Math.abs(l),Gh("TilingType: "+a);const c=e[0],d=e[1],f=e[2],g=e[3],A=f-c,v=g-d,w=I.singularValueDecompose2dScale(this.matrix),y=I.singularValueDecompose2dScale(this.baseTransform),x=w[0]*y[0],_=w[1]*y[1];let S=A,E=v,M=!1,C=!1;const R=Math.ceil(h*x),j=Math.ceil(l*_);R>=Math.ceil(A*x)?S=h:M=!0,j>=Math.ceil(v*_)?E=l:C=!0;const D=this.getSizeAndScale(S,this.ctx.canvas.width,x),F=this.getSizeAndScale(E,this.ctx.canvas.height,_),Y=t.cachedCanvases.getCanvas("pattern",D.size,F.size),Q=Y.context,B=o.createCanvasGraphics(Q);if(B.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(B,i,r),Q.translate(-D.scale*c,-F.scale*d),B.transform(D.scale,0,0,F.scale,0,0),Q.save(),this.clipBbox(B,c,d,f,g),B.baseTransform=ut(B.ctx),B.executeOperatorList(s),B.endDrawing(),Q.restore(),M||C){const ft=Y.canvas;M&&(S=h),C&&(E=l);const ie=this.getSizeAndScale(S,this.ctx.canvas.width,x),Ce=this.getSizeAndScale(E,this.ctx.canvas.height,_),H=ie.size,U=Ce.size,Ei=t.cachedCanvases.getCanvas("pattern-workaround",H,U),os=Ei.context,Vt=M?Math.floor(A/h):0,Pt=C?Math.floor(v/l):0;for(let $s=0;$s<=Vt;$s++)for(let ne=0;ne<=Pt;ne++)os.drawImage(ft,H*$s,U*ne,H,U,0,0,H,U);return{canvas:Ei.canvas,scaleX:ie.scale,scaleY:Ce.scale,offsetX:c,offsetY:d}}return{canvas:Y.canvas,scaleX:D.scale,scaleY:F.scale,offsetX:c,offsetY:d}}getSizeAndScale(t,e,s){const i=Math.max(Ih.MAX_PATTERN_SIZE,e);let a=Math.ceil(t*s);return a>=i?a=i:s=a/t,{scale:s,size:a}}clipBbox(t,e,s,i,a){const r=i-e,o=a-s;t.ctx.rect(e,s,r,o),t.current.updateRectMinMax(ut(t.ctx),[e,s,i,a]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,a=t.current;switch(e){case Cp:const r=this.ctx;i.fillStyle=r.fillStyle,i.strokeStyle=r.strokeStyle,a.fillColor=r.fillStyle,a.strokeColor=r.strokeStyle;break;case Mp:const o=I.makeHexColor(s[0],s[1],s[2]);i.fillStyle=o,i.strokeStyle=o,a.fillColor=o,a.strokeColor=o;break;default:throw new sp(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,i){let a=s;i!==fr&&(a=I.transform(a,e.baseTransform),this.matrix&&(a=I.transform(a,this.matrix)));const r=this.createPatternCanvas(e);let o=new DOMMatrix(a);o=o.translate(r.offsetX,r.offsetY),o=o.scale(1/r.scaleX,1/r.scaleY);const h=t.createPattern(r.canvas,"repeat");return h.setTransform(o),h}};N(Ih,"MAX_PATTERN_SIZE",3e3);let Il=Ih;function kp({src:u,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:a=4294967295,inverseDecode:r=!1}){const o=Wt.isLittleEndian?4278190080:255,[h,l]=r?[a,o]:[o,a],c=s>>3,d=7&s,f=u.length;e=new Uint32Array(e.buffer);let g=0;for(let A=0;A<i;A++){for(const w=t+c;t<w;t++){const y=t<f?u[t]:255;e[g++]=128&y?l:h,e[g++]=64&y?l:h,e[g++]=32&y?l:h,e[g++]=16&y?l:h,e[g++]=8&y?l:h,e[g++]=4&y?l:h,e[g++]=2&y?l:h,e[g++]=1&y?l:h}if(d===0)continue;const v=t<f?u[t++]:255;for(let w=0;w<d;w++)e[g++]=v&1<<7-w?l:h}return{srcPos:t,destPos:g}}const ee=16;class Tp{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 Oo(u,t,e,s,i,a,r,o,h,l){const[c,d,f,g,A,v]=ut(u);if(d===0&&f===0){const w=r*c+A,y=Math.round(w),x=o*g+v,_=Math.round(x),S=(r+h)*c+A,E=Math.abs(Math.round(S)-y)||1,M=(o+l)*g+v,C=Math.abs(Math.round(M)-_)||1;return u.setTransform(Math.sign(c),0,0,Math.sign(g),y,_),u.drawImage(t,e,s,i,a,0,0,E,C),u.setTransform(c,d,f,g,A,v),[E,C]}if(c===0&&g===0){const w=o*f+A,y=Math.round(w),x=r*d+v,_=Math.round(x),S=(o+l)*f+A,E=Math.abs(Math.round(S)-y)||1,M=(r+h)*d+v,C=Math.abs(Math.round(M)-_)||1;return u.setTransform(0,Math.sign(d),Math.sign(f),0,y,_),u.drawImage(t,e,s,i,a,0,0,C,E),u.setTransform(c,d,f,g,A,v),[C,E]}return u.drawImage(t,e,s,i,a,r,o,h,l),[Math.hypot(c,d)*h,Math.hypot(f,g)*l]}class Kc{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=pd,this.textMatrixScale=1,this.fontMatrix=al,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=$o,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]=I.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=I.applyTransform(e,t),i=I.applyTransform(e.slice(2),t),a=I.applyTransform([e[0],e[3]],t),r=I.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,s[0],i[0],a[0],r[0]),this.minY=Math.min(this.minY,s[1],i[1],a[1],r[1]),this.maxX=Math.max(this.maxX,s[0],i[0],a[0],r[0]),this.maxY=Math.max(this.maxY,s[1],i[1],a[1],r[1])}updateScalingPathMinMax(t,e){I.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,a,r,o,h,l,c){const d=I.bezierBoundingBox(e,s,i,a,r,o,h,l,c);c||this.updateRectMinMax(t,d)}getPathBoundingBox(t=Ii,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===Rc){e||ot("Stroke bounding box must include transform.");const i=I.singularValueDecompose2dScale(e),a=i[0]*this.lineWidth/2,r=i[1]*this.lineWidth/2;s[0]-=a,s[1]-=r,s[2]+=a,s[3]+=r}return s}updateClipFromPath(){const t=I.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=Ii,e=null){return I.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Yc(u,t){if(typeof ImageData<"u"&&t instanceof ImageData){u.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%ee,a=(e-i)/ee,r=i===0?a:a+1,o=u.createImageData(s,ee);let h,l=0;const c=t.data,d=o.data;let f,g,A,v;if(t.kind===Vo.GRAYSCALE_1BPP){const w=c.byteLength,y=new Uint32Array(d.buffer,0,d.byteLength>>2),x=y.length,_=s+7>>3,S=4294967295,E=Wt.isLittleEndian?4278190080:255;for(f=0;f<r;f++){for(A=f<a?ee:i,h=0,g=0;g<A;g++){const M=w-l;let C=0;const R=M>_?s:8*M-7,j=-8&R;let D=0,F=0;for(;C<j;C+=8)F=c[l++],y[h++]=128&F?S:E,y[h++]=64&F?S:E,y[h++]=32&F?S:E,y[h++]=16&F?S:E,y[h++]=8&F?S:E,y[h++]=4&F?S:E,y[h++]=2&F?S:E,y[h++]=1&F?S:E;for(;C<R;C++)D===0&&(F=c[l++],D=128),y[h++]=F&D?S:E,D>>=1}for(;h<x;)y[h++]=0;u.putImageData(o,0,f*ee)}}else if(t.kind===Vo.RGBA_32BPP){for(g=0,v=s*ee*4,f=0;f<a;f++)d.set(c.subarray(l,l+v)),l+=v,u.putImageData(o,0,g),g+=ee;f<r&&(v=s*i*4,d.set(c.subarray(l,l+v)),u.putImageData(o,0,g))}else{if(t.kind!==Vo.RGB_24BPP)throw new Error(`bad image kind: ${t.kind}`);for(A=ee,v=s*A,f=0;f<r;f++){for(f>=a&&(A=i,v=s*A),h=0,g=v;g--;)d[h++]=c[l++],d[h++]=c[l++],d[h++]=c[l++],d[h++]=255;u.putImageData(o,0,f*ee)}}}function Qc(u,t){if(t.bitmap){u.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%ee,a=(e-i)/ee,r=i===0?a:a+1,o=u.createImageData(s,ee);let h=0;const l=t.data,c=o.data;for(let d=0;d<r;d++){const f=d<a?ee:i;({srcPos:h}=kp({src:l,srcPos:h,dest:c,width:s,height:f,nonBlackColor:0})),u.putImageData(o,0,d*ee)}}function Xa(u,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)u[s]!==void 0&&(t[s]=u[s]);u.setLineDash!==void 0&&(t.setLineDash(u.getLineDash()),t.lineDashOffset=u.lineDashOffset)}function Bo(u){if(u.strokeStyle=u.fillStyle="#000000",u.fillRule="nonzero",u.globalAlpha=1,u.lineWidth=1,u.lineCap="butt",u.lineJoin="miter",u.miterLimit=10,u.globalCompositeOperation="source-over",u.font="10px sans-serif",u.setLineDash!==void 0&&(u.setLineDash([]),u.lineDashOffset=0),!$t){const{filter:t}=u;t!=="none"&&t!==""&&(u.filter="none")}}function Jc(u,t){if(t)return!0;const e=I.singularValueDecompose2dScale(u);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*yi.PDF_TO_CSS_UNITS);return e[0]<=s&&e[1]<=s}const Rp=["butt","round","square"],Pp=["miter","round","bevel"],Ip={},Zc={};var xi,Ll,Fl;const Bc=class Bc{constructor(t,e,s,i,a,{optionalContentConfig:r,markedContentStack:o=null},h,l){b(this,xi);this.ctx=t,this.current=new Kc(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=s,this.canvasFactory=i,this.filterFactory=a,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=r,this.cachedCanvases=new Tp(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=h,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const a=this.ctx.canvas.width,r=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,a,r),this.ctx.fillStyle=o,s){const h=this.cachedCanvases.getCanvas("transparent",a,r);this.compositeCtx=this.ctx,this.transparentCanvas=h.canvas,this.ctx=h.context,this.ctx.save(),this.ctx.transform(...ut(this.compositeCtx))}this.ctx.save(),Bo(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=ut(this.ctx)}executeOperatorList(t,e,s,i){const a=t.argsArray,r=t.fnArray;let o=e||0;const h=a.length;if(h===o)return o;const l=h-o>10&&typeof s=="function",c=l?Date.now()+15:0;let d=0;const f=this.commonObjs,g=this.objs;let A;for(;;){if(i!==void 0&&o===i.nextBreakPoint)return i.breakIt(o,s),o;if(A=r[o],A!==ke.dependency)this[A].apply(this,a[o]);else for(const v of a[o]){const w=v.startsWith("g_")?f:g;if(!w.has(v))return w.get(v,s),o}if(o++,o===h)return o;if(l&&++d>10){if(Date.now()>c)return s(),o;d=0}}}endDrawing(){m(this,xi,Ll).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,xi,Fl).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,i=t.height??t.displayHeight;let a,r,o=Math.max(Math.hypot(e[0],e[1]),1),h=Math.max(Math.hypot(e[2],e[3]),1),l=s,c=i,d="prescale1";for(;o>2&&l>1||h>2&&c>1;){let f=l,g=c;o>2&&l>1&&(f=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),o/=l/f),h>2&&c>1&&(g=c>=16384?Math.floor(c/2)-1||1:Math.ceil(c)/2,h/=c/g),a=this.cachedCanvases.getCanvas(d,f,g),r=a.context,r.clearRect(0,0,f,g),r.drawImage(t,0,0,l,c,0,0,f,g),t=a.canvas,l=f,c=g,d=d==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:c}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:i}=t,a=this.current.fillColor,r=this.current.patternFill,o=ut(e);let h,l,c,d;if((t.bitmap||t.data)&&t.count>1){const R=t.bitmap||t.data.buffer;l=JSON.stringify(r?o:[o.slice(0,4),a]),h=this._cachedBitmapsMap.get(R),h||(h=new Map,this._cachedBitmapsMap.set(R,h));const j=h.get(l);if(j&&!r)return{canvas:j,offsetX:Math.round(Math.min(o[0],o[2])+o[4]),offsetY:Math.round(Math.min(o[1],o[3])+o[5])};c=j}c||(d=this.cachedCanvases.getCanvas("maskCanvas",s,i),Qc(d.context,t));let f=I.transform(o,[1/s,0,0,-1/i,0,0]);f=I.transform(f,[1,0,0,1,0,-i]);const[g,A,v,w]=I.getAxialAlignedBoundingBox([0,0,s,i],f),y=Math.round(v-g)||1,x=Math.round(w-A)||1,_=this.cachedCanvases.getCanvas("fillCanvas",y,x),S=_.context,E=g,M=A;S.translate(-E,-M),S.transform(...f),c||(c=this._scaleImage(d.canvas,hs(S)),c=c.img,h&&r&&h.set(l,c)),S.imageSmoothingEnabled=Jc(ut(S),t.interpolate),Oo(S,c,0,0,c.width,c.height,0,0,s,i),S.globalCompositeOperation="source-in";const C=I.transform(hs(S),[1,0,0,1,-E,-M]);return S.fillStyle=r?a.getPattern(e,this,C,Ii):a,S.fillRect(0,0,s,i),h&&!r&&(this.cachedCanvases.delete("fillCanvas"),h.set(l,_.canvas)),{canvas:_.canvas,offsetX:Math.round(E),offsetY:Math.round(M)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Rp[t]}setLineJoin(t){this.ctx.lineJoin=Pp[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)}}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 a=this.ctx;a.setTransform(...ut(this.suspendedCtx)),Xa(this.suspendedCtx,a),function(o,h){if(o._removeMirroring)throw new Error("Context is already forwarding operations.");o.__originalSave=o.save,o.__originalRestore=o.restore,o.__originalRotate=o.rotate,o.__originalScale=o.scale,o.__originalTranslate=o.translate,o.__originalTransform=o.transform,o.__originalSetTransform=o.setTransform,o.__originalResetTransform=o.resetTransform,o.__originalClip=o.clip,o.__originalMoveTo=o.moveTo,o.__originalLineTo=o.lineTo,o.__originalBezierCurveTo=o.bezierCurveTo,o.__originalRect=o.rect,o.__originalClosePath=o.closePath,o.__originalBeginPath=o.beginPath,o._removeMirroring=()=>{o.save=o.__originalSave,o.restore=o.__originalRestore,o.rotate=o.__originalRotate,o.scale=o.__originalScale,o.translate=o.__originalTranslate,o.transform=o.__originalTransform,o.setTransform=o.__originalSetTransform,o.resetTransform=o.__originalResetTransform,o.clip=o.__originalClip,o.moveTo=o.__originalMoveTo,o.lineTo=o.__originalLineTo,o.bezierCurveTo=o.__originalBezierCurveTo,o.rect=o.__originalRect,o.closePath=o.__originalClosePath,o.beginPath=o.__originalBeginPath,delete o._removeMirroring},o.save=function(){h.save(),this.__originalSave()},o.restore=function(){h.restore(),this.__originalRestore()},o.translate=function(c,d){h.translate(c,d),this.__originalTranslate(c,d)},o.scale=function(c,d){h.scale(c,d),this.__originalScale(c,d)},o.transform=function(c,d,f,g,A,v){h.transform(c,d,f,g,A,v),this.__originalTransform(c,d,f,g,A,v)},o.setTransform=function(c,d,f,g,A,v){h.setTransform(c,d,f,g,A,v),this.__originalSetTransform(c,d,f,g,A,v)},o.resetTransform=function(){h.resetTransform(),this.__originalResetTransform()},o.rotate=function(c){h.rotate(c),this.__originalRotate(c)},o.clip=function(c){h.clip(c),this.__originalClip(c)},o.moveTo=function(l,c){h.moveTo(l,c),this.__originalMoveTo(l,c)},o.lineTo=function(l,c){h.lineTo(l,c),this.__originalLineTo(l,c)},o.bezierCurveTo=function(l,c,d,f,g,A){h.bezierCurveTo(l,c,d,f,g,A),this.__originalBezierCurveTo(l,c,d,f,g,A)},o.rect=function(l,c,d,f){h.rect(l,c,d,f),this.__originalRect(l,c,d,f)},o.closePath=function(){h.closePath(),this.__originalClosePath()},o.beginPath=function(){h.beginPath(),this.__originalBeginPath()}}(a,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 a=i[0],r=i[1],o=i[2]-a,h=i[3]-r;o!==0&&h!==0&&(this.genericComposeSMask(e.context,s,o,h,e.subtype,e.backdrop,e.transferMap,a,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,a,r,o,h,l,c,d){let f=t.canvas,g=h-c,A=l-d;if(r){const w=I.makeHexColor(...r);if(g<0||A<0||g+s>f.width||A+i>f.height){const y=this.cachedCanvases.getCanvas("maskExtension",s,i),x=y.context;x.drawImage(f,-g,-A),x.globalCompositeOperation="destination-atop",x.fillStyle=w,x.fillRect(0,0,s,i),x.globalCompositeOperation="source-over",f=y.canvas,g=A=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const y=new Path2D;y.rect(g,A,s,i),t.clip(y),t.globalCompositeOperation="destination-atop",t.fillStyle=w,t.fillRect(g,A,s,i),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),a==="Alpha"&&o?e.filter=this.filterFactory.addAlphaFilter(o):a==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(o));const v=new Path2D;v.rect(h,l,s,i),e.clip(v),e.globalCompositeOperation="destination-in",e.drawImage(f,g,A,s,i,h,l,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,a,r){this.ctx.transform(t,e,s,i,a,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){const i=this.ctx,a=this.current;let r,o,h=a.x,l=a.y;const c=ut(i),d=c[0]===0&&c[3]===0||c[1]===0&&c[2]===0,f=d?s.slice(0):null;for(let g=0,A=0,v=t.length;g<v;g++)switch(0|t[g]){case ke.rectangle:h=e[A++],l=e[A++];const w=e[A++],y=e[A++],x=h+w,_=l+y;i.moveTo(h,l),w===0||y===0?i.lineTo(x,_):(i.lineTo(x,l),i.lineTo(x,_),i.lineTo(h,_)),d||a.updateRectMinMax(c,[h,l,x,_]),i.closePath();break;case ke.moveTo:h=e[A++],l=e[A++],i.moveTo(h,l),d||a.updatePathMinMax(c,h,l);break;case ke.lineTo:h=e[A++],l=e[A++],i.lineTo(h,l),d||a.updatePathMinMax(c,h,l);break;case ke.curveTo:r=h,o=l,h=e[A+4],l=e[A+5],i.bezierCurveTo(e[A],e[A+1],e[A+2],e[A+3],h,l),a.updateCurvePathMinMax(c,r,o,e[A],e[A+1],e[A+2],e[A+3],h,l,f),A+=6;break;case ke.curveTo2:r=h,o=l,i.bezierCurveTo(h,l,e[A],e[A+1],e[A+2],e[A+3]),a.updateCurvePathMinMax(c,r,o,h,l,e[A],e[A+1],e[A+2],e[A+3],f),h=e[A+2],l=e[A+3],A+=4;break;case ke.curveTo3:r=h,o=l,h=e[A+2],l=e[A+3],i.bezierCurveTo(e[A],e[A+1],h,l,h,l),a.updateCurvePathMinMax(c,r,o,e[A],e[A+1],h,l,h,l,f),A+=4;break;case ke.closePath:i.closePath()}d&&a.updateScalingPathMinMax(c,f),a.setCurrentPoint(h,l)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,s=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof s=="object"&&(s!=null&&s.getPattern)?(e.save(),e.strokeStyle=s.getPattern(e,this,hs(e),Rc),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){const e=this.ctx,s=this.current.fillColor;let i=!1;this.current.patternFill&&(e.save(),e.fillStyle=s.getPattern(e,this,hs(e),Ii),i=!0);const a=this.current.getClippedPathBoundingBox();this.contentVisible&&a!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),i&&e.restore(),t&&this.consumePath(a)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Ip}eoClip(){this.pendingClip=Zc}beginText(){this.current.textMatrix=pd,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(t!==void 0){e.save(),e.beginPath();for(const s of t)e.setTransform(...s.transform),e.translate(s.x,s.y),s.addToPath(e,s.fontSize);e.restore(),e.clip(),e.beginPath(),delete this.pendingTextPaths}else e.beginPath()}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){var c;const s=this.commonObjs.get(t),i=this.current;if(!s)throw new Error(`Can't find font for ${t}`);if(i.fontMatrix=s.fontMatrix||al,i.fontMatrix[0]!==0&&i.fontMatrix[3]!==0||q("Invalid font matrix for font "+t),e<0?(e=-e,i.fontDirection=-1):i.fontDirection=1,this.current.font=s,this.current.fontSize=e,s.isType3Font)return;const a=s.loadedName||"sans-serif",r=((c=s.systemFontInfo)==null?void 0:c.css)||`"${a}", ${s.fallbackName}`;let o="normal";s.black?o="900":s.bold&&(o="bold");const h=s.italic?"italic":"normal";let l=e;e<16?l=16:e>100&&(l=100),this.current.fontSizeScale=e/l,this.ctx.font=`${h} ${o} ${l}px ${r}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,s,i,a,r){this.current.textMatrix=[t,e,s,i,a,r],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,s,i){const a=this.ctx,r=this.current,o=r.font,h=r.textRenderingMode,l=r.fontSize/r.fontSizeScale,c=h&$c,d=!!(h&Tf),f=r.patternFill&&!o.missingFile;let g;(o.disableFontFace||d||f)&&(g=o.getPathGenerator(this.commonObjs,t)),o.disableFontFace||f?(a.save(),a.translate(e,s),a.beginPath(),g(a,l),i&&a.setTransform(...i),c!==$o&&c!==Wa||a.fill(),c!==Jh&&c!==Wa||a.stroke(),a.restore()):(c!==$o&&c!==Wa||a.fillText(t,e,s),c!==Jh&&c!==Wa||a.strokeText(t,e,s)),d&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:ut(a),x:e,y:s,fontSize:l,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;i<e.length;i+=4)if(e[i]>0&&e[i]<255){s=!0;break}return K(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 a=this.ctx,r=e.fontSizeScale,o=e.charSpacing,h=e.wordSpacing,l=e.fontDirection,c=e.textHScale*l,d=t.length,f=s.vertical,g=f?1:-1,A=s.defaultVMetrics,v=i*e.fontMatrix[0],w=e.textRenderingMode===$o&&!s.disableFontFace&&!e.patternFill;a.save(),a.transform(...e.textMatrix),a.translate(e.x,e.y+e.textRise),l>0?a.scale(c,-1):a.scale(c,1);let y;if(e.patternFill){a.save();const M=e.fillColor.getPattern(a,this,hs(a),Ii);y=ut(a),a.restore(),a.fillStyle=M}let x=e.lineWidth;const _=e.textMatrixScale;if(_===0||x===0){const M=e.textRenderingMode&$c;M!==Jh&&M!==Wa||(x=this.getSinglePixelWidth())}else x/=_;if(r!==1&&(a.scale(r,r),x/=r),a.lineWidth=x,s.isInvalidPDFjsFont){const M=[];let C=0;for(const R of t)M.push(R.unicode),C+=R.width;a.fillText(M.join(""),0,0),e.x+=C*v*c,a.restore(),this.compose();return}let S,E=0;for(S=0;S<d;++S){const M=t[S];if(typeof M=="number"){E+=g*M*i/1e3;continue}let C=!1;const R=(M.isSpace?h:0)+o,j=M.fontChar,D=M.accent;let F,Y,Q=M.width;if(f){const B=M.vmetric||A,ft=-(M.vmetric?B[1]:.5*Q)*v,ie=B[2]*v;Q=B?-B[0]:Q,F=ft/r,Y=(E+ie)/r}else F=E/r,Y=0;if(s.remeasure&&Q>0){const B=1e3*a.measureText(j).width/i*r;if(Q<B&&this.isFontSubpixelAAEnabled){const ft=Q/B;C=!0,a.save(),a.scale(ft,1),F/=ft}else Q!==B&&(F+=(Q-B)/2e3*i/r)}if(this.contentVisible&&(M.isInFont||s.missingFile)){if(w&&!D)a.fillText(j,F,Y);else if(this.paintChar(j,F,Y,y),D){const B=F+i*D.offset.x/r,ft=Y-i*D.offset.y/r;this.paintChar(D.fontChar,B,ft,y)}}E+=f?Q*v-R*l:Q*v+R*l,C&&a.restore()}f?e.y-=E:e.x+=E*c,a.restore(),this.compose()}showType3Text(t){const e=this.ctx,s=this.current,i=s.font,a=s.fontSize,r=s.fontDirection,o=i.vertical?1:-1,h=s.charSpacing,l=s.wordSpacing,c=s.textHScale*r,d=s.fontMatrix||al,f=t.length;let g,A,v,w;if(s.textRenderingMode!==kf&&a!==0){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...s.textMatrix),e.translate(s.x,s.y),e.scale(c,r),g=0;g<f;++g){if(A=t[g],typeof A=="number"){w=o*A*a/1e3,this.ctx.translate(w,0),s.x+=w*c;continue}const y=(A.isSpace?l:0)+h,x=i.charProcOperatorList[A.operatorListId];if(!x){q(`Type3 character "${A.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=A,this.save(),e.scale(a,a),e.transform(...d),this.executeOperatorList(x),this.restore()),v=I.applyTransform([A.width,0],d)[0]*a+y,e.translate(v,0),s.x+=v*c}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,a,r){this.ctx.rect(s,i,a-s,r-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){const s=t[1],i=this.baseTransform||ut(this.ctx),a={createCanvasGraphics:r=>new Bc(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Il(t,s,this.ctx,a,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=I.makeHexColor(t,e,s)}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent"}setFillRGBColor(t,e,s){this.ctx.fillStyle=this.current.fillColor=I.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=function(a){switch(a[0]){case"RadialAxial":return new _p(a);case"Mesh":return new Sp(a);case"Dummy":return new Ep}throw new Error(`Unknown IR type: ${a[0]}`)}(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,hs(e),fr);const i=hs(e);if(i){const{width:a,height:r}=e.canvas,[o,h,l,c]=I.getAxialAlignedBoundingBox([0,0,a,r],i);this.ctx.fillRect(o,h,l-o,c-h)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){ot("Should not call beginInlineImage")}beginImageData(){ot("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=ut(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(ut(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||Gh("TODO: Support non-isolated groups."),t.knockout&&q("Knockout groups not supported.");const s=ut(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=I.getAxialAlignedBoundingBox(t.bbox,ut(e));const a=[0,0,e.canvas.width,e.canvas.height];i=I.intersect(i,a)||[0,0,0,0];const r=Math.floor(i[0]),o=Math.floor(i[1]),h=Math.max(Math.ceil(i[2])-r,1),l=Math.max(Math.ceil(i[3])-o,1);this.current.startNewPathAndClipBox([0,0,h,l]);let c="groupAt"+this.groupLevel;t.smask&&(c+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(c,h,l),f=d.context;f.translate(-r,-o),f.transform(...s),t.smask?this.smaskStack.push({canvas:d.canvas,context:f,offsetX:r,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(r,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=ut(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const a=I.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],i);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(a)}}beginAnnotation(t,e,s,i,a){if(m(this,xi,Ll).call(this),Bo(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const r=e[2]-e[0],o=e[3]-e[1];if(a&&this.annotationCanvasMap){(s=s.slice())[4]-=e[0],s[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=r,e[3]=o;const[h,l]=I.singularValueDecompose2dScale(ut(this.ctx)),{viewportScale:c}=this,d=Math.ceil(r*this.outputScaleX*c),f=Math.ceil(o*this.outputScaleY*c);this.annotationCanvas=this.canvasFactory.create(d,f);const{canvas:g,context:A}=this.annotationCanvas;this.annotationCanvasMap.set(t,g),this.annotationCanvas.savedCtx=this.ctx,this.ctx=A,this.ctx.save(),this.ctx.setTransform(h,0,0,-l,0,o*l),Bo(this.ctx)}else Bo(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],r,o),this.ctx.clip(),this.ctx.beginPath()}this.current=new Kc(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),m(this,xi,Fl).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)).count=e;const s=this.ctx,i=this.processingType3;if(i&&(i.compiled===void 0&&(i.compiled=function(h){const{width:l,height:c}=h;if(l>1e3||c>1e3)return null;const d=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),f=l+1;let g,A,v,w=new Uint8Array(f*(c+1));const y=l+7&-8;let x=new Uint8Array(y*c),_=0;for(const C of h.data){let R=128;for(;R>0;)x[_++]=C&R?0:255,R>>=1}let S=0;for(_=0,x[_]!==0&&(w[0]=1,++S),A=1;A<l;A++)x[_]!==x[_+1]&&(w[A]=x[_]?2:1,++S),_++;for(x[_]!==0&&(w[A]=2,++S),g=1;g<c;g++){_=g*y,v=g*f,x[_-y]!==x[_]&&(w[v]=x[_]?1:8,++S);let C=(x[_]?4:0)+(x[_-y]?8:0);for(A=1;A<l;A++)C=(C>>2)+(x[_+1]?4:0)+(x[_-y+1]?8:0),d[C]&&(w[v+A]=d[C],++S),_++;if(x[_-y]!==x[_]&&(w[v+A]=x[_]?2:4,++S),S>1e3)return null}for(_=y*(c-1),v=g*f,x[_]!==0&&(w[v]=8,++S),A=1;A<l;A++)x[_]!==x[_+1]&&(w[v+A]=x[_]?4:8,++S),_++;if(x[_]!==0&&(w[v+A]=4,++S),S>1e3)return null;const E=new Int32Array([0,f,-1,0,-f,0,0,0,1]),M=new Path2D;for(g=0;S&&g<=c;g++){let C=g*f;const R=C+l;for(;C<R&&!w[C];)C++;if(C===R)continue;M.moveTo(C%f,g);const j=C;let D=w[C];do{const F=E[D];do C+=F;while(!w[C]);const Y=w[C];Y!==5&&Y!==10?(D=Y,w[C]=0):(D=Y&51*D>>4,w[C]&=D>>2|D<<2),M.lineTo(C%f,C/f|0),w[C]||--S}while(j!==C);--g}return x=null,w=null,function(C){C.save(),C.scale(1/l,-1/c),C.translate(0,-c),C.fill(M),C.beginPath(),C.restore()}}(t)),i.compiled)){i.compiled(s);return}const a=this._createMaskCanvas(t),r=a.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(r,a.offsetX,a.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,i=0,a,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);const o=this.ctx;o.save();const h=ut(o);o.transform(e,s,i,a,0,0);const l=this._createMaskCanvas(t);o.setTransform(1,0,0,1,l.offsetX-h[4],l.offsetY-h[5]);for(let c=0,d=r.length;c<d;c+=2){const f=I.transform(h,[e,s,i,a,r[c],r[c+1]]),[g,A]=I.applyTransform([0,0],f);o.drawImage(l.canvas,g,A)}o.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;for(const a of t){const{data:r,width:o,height:h,transform:l}=a,c=this.cachedCanvases.getCanvas("maskCanvas",o,h),d=c.context;d.save(),Qc(d,this.getObject(r,a)),d.globalCompositeOperation="source-in",d.fillStyle=i?s.getPattern(d,this,hs(e),Ii):s,d.fillRect(0,0,o,h),d.restore(),e.save(),e.transform(...l),e.scale(1,-1),Oo(e,c.canvas,0,0,o,h,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):q("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,s,i){if(!this.contentVisible)return;const a=this.getObject(t);if(!a){q("Dependent image isn't ready yet");return}const r=a.width,o=a.height,h=[];for(let l=0,c=i.length;l<c;l+=2)h.push({transform:[e,0,0,s,i[l],i[l+1]],x:0,y:0,w:r,h:o});this.paintInlineImageXObjectGroup(a,h)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:e,width:s,height:i}=t,a=this.cachedCanvases.getCanvas("inlineImage",s,i),r=a.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",a.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,s=t.height,i=this.ctx;if(this.save(),!$t){const{filter:o}=i;o!=="none"&&o!==""&&(i.filter="none")}i.scale(1/e,-1/s);let a;if(t.bitmap)a=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)a=t;else{const o=this.cachedCanvases.getCanvas("inlineImage",e,s).context;Yc(o,t),a=this.applyTransferMapsToCanvas(o)}const r=this._scaleImage(a,hs(i));i.imageSmoothingEnabled=Jc(ut(i),t.interpolate),Oo(i,r.img,0,0,r.paintWidth,r.paintHeight,0,-s,e,s),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.ctx;let i;if(t.bitmap)i=t.bitmap;else{const a=t.width,r=t.height,o=this.cachedCanvases.getCanvas("inlineImage",a,r).context;Yc(o,t),i=this.applyTransferMapsToCanvas(o)}for(const a of e)s.save(),s.transform(...a.transform),s.scale(1,-1),Oo(s,i,a.x,a.y,a.w,a.h,0,-1,1,1),s.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){t==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const s=this.ctx;this.pendingClip&&(e||(this.pendingClip===Zc?s.clip("evenodd"):s.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),s.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=ut(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:a}=this.ctx.getTransform();let r,o;if(s===0&&i===0){const h=Math.abs(e),l=Math.abs(a);if(h===l)if(t===0)r=o=1/h;else{const c=h*t;r=o=c<1?1/c:1}else if(t===0)r=1/h,o=1/l;else{const c=h*t,d=l*t;r=c<1?1/c:1,o=d<1?1/d:1}}else{const h=Math.abs(e*a-s*i),l=Math.hypot(e,s),c=Math.hypot(i,a);if(t===0)r=c/h,o=l/h;else{const d=t*h;r=c>d?c/d:1,o=l>d?l/d:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:s}=this.current,[i,a]=this.getScaleForStroking();if(e.lineWidth=s||1,i===1&&a===1){e.stroke();return}const r=e.getLineDash();if(t&&e.save(),e.scale(i,a),r.length>0){const o=Math.max(i,a);e.setLineDash(r.map(h=>h/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}};xi=new WeakSet,Ll=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)},Fl=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 Wn=Bc;for(const u in ke)Wn.prototype[u]!==void 0&&(Wn.prototype[ke[u]]=Wn.prototype[u]);var Br,Hr;class Ns{static get workerPort(){return n(this,Br)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");p(this,Br,t)}static get workerSrc(){return n(this,Hr)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");p(this,Hr,t)}}Br=new WeakMap,Hr=new WeakMap,b(Ns,Br,null),b(Ns,Hr,"");const td=1,ed=2,sd=1,sl=2,id=3,nd=4,ad=5,rd=6,Ho=7,il=8;function ae(u){switch(u instanceof Error||typeof u=="object"&&u!==null||ot('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),u.name){case"AbortException":return new Nn(u.message);case"MissingPDFException":return new Dn(u.message);case"PasswordException":return new rl(u.message,u.code);case"UnexpectedResponseException":return new Uh(u.message,u.status);case"UnknownErrorException":return new ol(u.message,u.details);default:return new ol(u.message,u.toString())}}var la,Se,Yd,Qd,Jd,Yo;class tr{constructor(t,e,s){b(this,Se);b(this,la,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,Se,Yd).bind(this),{signal:n(this,la).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++,a=Promise.withResolvers();this.callbackCapabilities[i]=a;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(r){a.reject(r)}return a.promise}sendWithStream(t,e,s,i){const a=this.streamId++,r=this.sourceName,o=this.targetName,h=this.comObj;return new ReadableStream({start:l=>{const c=Promise.withResolvers();return this.streamControllers[a]={controller:l,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},h.postMessage({sourceName:r,targetName:o,action:t,streamId:a,data:e,desiredSize:l.desiredSize},i),c.promise},pull:l=>{const c=Promise.withResolvers();return this.streamControllers[a].pullCall=c,h.postMessage({sourceName:r,targetName:o,stream:rd,streamId:a,desiredSize:l.desiredSize}),c.promise},cancel:l=>{St(l instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[a].cancelCall=c,this.streamControllers[a].isClosed=!0,h.postMessage({sourceName:r,targetName:o,stream:sd,streamId:a,reason:ae(l)}),c.promise}},s)}destroy(){var t;(t=n(this,la))==null||t.abort(),p(this,la,null)}}la=new WeakMap,Se=new WeakSet,Yd=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){m(this,Se,Jd).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===td)i.resolve(t.data);else{if(t.callback!==ed)throw new Error("Unexpected callback case");i.reject(ae(t.reason))}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,a=this.comObj;new Promise(function(r){r(e(t.data))}).then(function(r){a.postMessage({sourceName:s,targetName:i,callback:td,callbackId:t.callbackId,data:r})},function(r){a.postMessage({sourceName:s,targetName:i,callback:ed,callbackId:t.callbackId,reason:ae(r)})})}else t.streamId?m(this,Se,Qd).call(this,t):e(t.data)},Qd=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,a=this.comObj,r=this,o=this.actionHandler[t.action],h={enqueue(l,c=1,d){if(this.isCancelled)return;const f=this.desiredSize;this.desiredSize-=c,f>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),a.postMessage({sourceName:s,targetName:i,stream:nd,streamId:e,chunk:l},d)},close(){this.isCancelled||(this.isCancelled=!0,a.postMessage({sourceName:s,targetName:i,stream:id,streamId:e}),delete r.streamSinks[e])},error(l){St(l instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,a.postMessage({sourceName:s,targetName:i,stream:ad,streamId:e,reason:ae(l)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};h.sinkCapability.resolve(),h.ready=h.sinkCapability.promise,this.streamSinks[e]=h,new Promise(function(l){l(o(t.data,h))}).then(function(){a.postMessage({sourceName:s,targetName:i,stream:il,streamId:e,success:!0})},function(l){a.postMessage({sourceName:s,targetName:i,stream:il,streamId:e,reason:ae(l)})})},Jd=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,a=this.comObj,r=this.streamControllers[e],o=this.streamSinks[e];switch(t.stream){case il:t.success?r.startCall.resolve():r.startCall.reject(ae(t.reason));break;case Ho:t.success?r.pullCall.resolve():r.pullCall.reject(ae(t.reason));break;case rd:if(!o){a.postMessage({sourceName:s,targetName:i,stream:Ho,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,new Promise(function(h){var l;h((l=o.onPull)==null?void 0:l.call(o))}).then(function(){a.postMessage({sourceName:s,targetName:i,stream:Ho,streamId:e,success:!0})},function(h){a.postMessage({sourceName:s,targetName:i,stream:Ho,streamId:e,reason:ae(h)})});break;case nd:if(St(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case id:if(St(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),m(this,Se,Yo).call(this,r,e);break;case ad:St(r,"error should have stream controller"),r.controller.error(ae(t.reason)),m(this,Se,Yo).call(this,r,e);break;case sl:t.success?r.cancelCall.resolve():r.cancelCall.reject(ae(t.reason)),m(this,Se,Yo).call(this,r,e);break;case sd:if(!o)break;new Promise(function(h){var l;h((l=o.onCancel)==null?void 0:l.call(o,ae(t.reason)))}).then(function(){a.postMessage({sourceName:s,targetName:i,stream:sl,streamId:e,success:!0})},function(h){a.postMessage({sourceName:s,targetName:i,stream:sl,streamId:e,reason:ae(h)})}),o.sinkCapability.reject(ae(t.reason)),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Yo=async function(t,e){var s,i,a;await Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(i=t.pullCall)==null?void 0:i.promise,(a=t.cancelCall)==null?void 0:a.promise]),delete this.streamControllers[e]};var Ki,zr;class Lp{constructor({parsedData:t,rawData:e}){b(this,Ki);b(this,zr);p(this,Ki,t),p(this,zr,e)}getRaw(){return n(this,zr)}get(t){return n(this,Ki).get(t)??null}getAll(){return Sc(n(this,Ki))}has(t){return n(this,Ki).has(t)}}Ki=new WeakMap,zr=new WeakMap;const Bn=Symbol("INTERNAL");var jr,$r,Vr,ca;class Fp{constructor(t,{name:e,intent:s,usage:i,rbGroups:a}){b(this,jr,!1);b(this,$r,!1);b(this,Vr,!1);b(this,ca,!0);p(this,jr,!!(t&xc)),p(this,$r,!!(t&vh)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=a}get visible(){if(n(this,Vr))return n(this,ca);if(!n(this,ca))return!1;const{print:t,view:e}=this.usage;return n(this,jr)?(e==null?void 0:e.viewState)!=="OFF":!n(this,$r)||(t==null?void 0:t.printState)!=="OFF"}_setVisible(t,e,s=!1){t!==Bn&&ot("Internal method `_setVisible` called."),p(this,Vr,s),p(this,ca,e)}}jr=new WeakMap,$r=new WeakMap,Vr=new WeakMap,ca=new WeakMap;var ni,st,da,ua,Gr,Dl;class Dp{constructor(t,e=xc){b(this,Gr);b(this,ni,null);b(this,st,new Map);b(this,da,null);b(this,ua,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,p(this,ua,t.order);for(const s of t.groups)n(this,st).set(s.id,new Fp(e,s));if(t.baseState==="OFF")for(const s of n(this,st).values())s._setVisible(Bn,!1);for(const s of t.on)n(this,st).get(s)._setVisible(Bn,!0);for(const s of t.off)n(this,st).get(s)._setVisible(Bn,!1);p(this,da,this.getHash())}}isVisible(t){if(n(this,st).size===0)return!0;if(!t)return Gh("Optional content group not defined."),!0;if(t.type==="OCG")return n(this,st).has(t.id)?n(this,st).get(t.id).visible:(q(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return m(this,Gr,Dl).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!n(this,st).has(e))return q(`Optional content group not found: ${e}`),!0;if(n(this,st).get(e).visible)return!0}return!1}if(t.policy==="AllOn"){for(const e of t.ids){if(!n(this,st).has(e))return q(`Optional content group not found: ${e}`),!0;if(!n(this,st).get(e).visible)return!1}return!0}if(t.policy==="AnyOff"){for(const e of t.ids){if(!n(this,st).has(e))return q(`Optional content group not found: ${e}`),!0;if(!n(this,st).get(e).visible)return!0}return!1}if(t.policy==="AllOff"){for(const e of t.ids){if(!n(this,st).has(e))return q(`Optional content group not found: ${e}`),!0;if(n(this,st).get(e).visible)return!1}return!0}return q(`Unknown optional content policy ${t.policy}.`),!0}return q(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var a;const i=n(this,st).get(t);if(i){if(s&&e&&i.rbGroups.length)for(const r of i.rbGroups)for(const o of r)o!==t&&((a=n(this,st).get(o))==null||a._setVisible(Bn,!1,!0));i._setVisible(Bn,!!e,!0),p(this,ni,null)}else q(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const a=n(this,st).get(i);if(a)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!a.visible,e)}}p(this,ni,null)}get hasInitialVisibility(){return n(this,da)===null||this.getHash()===n(this,da)}getOrder(){return n(this,st).size?n(this,ua)?n(this,ua).slice():[...n(this,st).keys()]:null}getGroups(){return n(this,st).size>0?Sc(n(this,st)):null}getGroup(t){return n(this,st).get(t)||null}getHash(){if(n(this,ni)!==null)return n(this,ni);const t=new $d;for(const[e,s]of n(this,st))t.update(`${e}:${s.visible}`);return p(this,ni,t.hexdigest())}}ni=new WeakMap,st=new WeakMap,da=new WeakMap,ua=new WeakMap,Gr=new WeakSet,Dl=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const a=t[i];let r;if(Array.isArray(a))r=m(this,Gr,Dl).call(this,a);else{if(!n(this,st).has(a))return q(`Optional content group not found: ${a}`),!0;r=n(this,st).get(a).visible}switch(s){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return s==="And"};class Np{constructor(t,{disableRange:e=!1,disableStream:s=!1}){St(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:a,progressiveDone:r,contentDispositionFilename:o}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=o,(a==null?void 0:a.length)>0){const h=a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer;this._queuedChunks.push(h)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((h,l)=>{this._onReceiveData({begin:h,chunk:l})}),t.addProgressListener((h,l)=>{this._onProgress({loaded:h,total:l})}),t.addProgressiveReadListener(h=>{this._onReceiveData({chunk:h})}),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;t===void 0?this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s):St(this._rangeReaders.some(function(i){return i._begin!==t?!1:(i._enqueue(s),!0)}),"_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,a;t.total===void 0?(s=(e=this._rangeReaders[0])==null?void 0:e.onProgress)==null||s.call(e,{loaded:t.loaded}):(a=(i=this._fullRequestReader)==null?void 0:i.onProgress)==null||a.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(){St(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Op(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Bp(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 Op{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=Mc(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const a of this._queuedChunks)this._loaded+=a.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 Bp{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 e of this._requests)e.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 Ic(u,t){const e=new Headers;if(!u||!t||typeof t!="object")return e;for(const s in t){const i=t[s];i!==void 0&&e.append(s,i)}return e}function Lc({responseHeaders:u,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(u.get("Content-Length"),10);return!Number.isInteger(a)||(i.suggestedLength=a,a<=2*e)||s||!t||u.get("Accept-Ranges")!=="bytes"||(u.get("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function Fc(u){const t=u.get("Content-Disposition");if(t){let e=function(i){let a=!0,r=o("filename\\*","i").exec(i);if(r){r=r[1];let g=c(r);return g=unescape(g),g=d(g),g=f(g),l(g)}if(r=function(A){const v=[];let w;const y=o("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(w=y.exec(A))!==null;){let[,_,S,E]=w;if(_=parseInt(_,10),_ in v){if(_===0)break}else v[_]=[S,E]}const x=[];for(let _=0;_<v.length&&_ in v;++_){let[S,E]=v[_];E=c(E),S&&(E=unescape(E),_===0&&(E=d(E))),x.push(E)}return x.join("")}(i),r)return l(f(r));if(r=o("filename","i").exec(i),r){r=r[1];let g=c(r);return g=f(g),l(g)}function o(g,A){return new RegExp("(?:^|;)\\s*"+g+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',A)}function h(g,A){if(g){if(!/^[\x00-\xFF]+$/.test(A))return A;try{const v=new TextDecoder(g,{fatal:!0}),w=qh(A);A=v.decode(w),a=!1}catch{}}return A}function l(g){return a&&/[\x80-\xff]/.test(g)&&(g=h("utf-8",g),a&&(g=h("iso-8859-1",g))),g}function c(g){if(g.startsWith('"')){const A=g.slice(1).split('\\"');for(let v=0;v<A.length;++v){const w=A[v].indexOf('"');w!==-1&&(A[v]=A[v].slice(0,w),A.length=v+1),A[v]=A[v].replaceAll(/\\(.)/g,"$1")}g=A.join('"')}return g}function d(g){const A=g.indexOf("'");return A===-1?g:h(g.slice(0,A),g.slice(A+1).replace(/^[^']*'/,""))}function f(g){return!g.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(g)?g:g.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(A,v,w,y){if(w==="q"||w==="Q")return h(v,y=(y=y.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(x,_){return String.fromCharCode(parseInt(_,16))}));try{y=atob(y)}catch{}return h(v,y)})}return""}(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Mc(e))return e}return null}function Kh(u,t){return u===404||u===0&&t.startsWith("file:")?new Dn('Missing PDF "'+t+'".'):new Uh(`Unexpected server response (${u}) while retrieving PDF "${t}".`,u)}function Zd(u){return u===200||u===206}function tu(u,t,e){return{method:"GET",headers:u,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function eu(u){return u instanceof Uint8Array?u.buffer:u instanceof ArrayBuffer?u:(q(`getArrayBuffer - unexpected data format: ${u}`),new Uint8Array(u).buffer)}class od{constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=Ic(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 St(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Hp(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new zp(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 Hp{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const s=new Headers(t.headers),i=e.url;fetch(i,tu(s,this._withCredentials,this._abortController)).then(a=>{if(!Zd(a.status))throw Kh(a.status,i);this._reader=a.body.getReader(),this._headersCapability.resolve();const r=a.headers,{allowRangeRequests:o,suggestedLength:h}=Lc({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=o,this._contentLength=h||this._contentLength,this._filename=Fc(r),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Nn("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:eu(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}class zp{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 a=new Headers(t.headers);a.append("Range",`bytes=${e}-${s-1}`);const r=i.url;fetch(r,tu(a,this._withCredentials,this._abortController)).then(o=>{if(!Zd(o.status))throw Kh(o.status,r);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:eu(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}class jp{constructor({url:t,httpHeaders:e,withCredentials:s}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Ic(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 a in s)i[a]=s[a];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[a,r]of this.headers)e.setRequestHeader(a,r);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=206):i.expectedStatus=200,e.responseType="arraybuffer",t.onError&&(e.onerror=function(a){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 o,h,l;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){(o=s.onError)==null||o.call(s,i.status);return}const a=i.status||200;if(!(a===200&&s.expectedStatus===206)&&a!==s.expectedStatus){(h=s.onError)==null||h.call(s,i.status);return}const r=function(d){const f=d.response;return typeof f!="string"?f:qh(f).buffer}(i);if(a===206){const c=i.getResponseHeader("Content-Range"),d=/bytes (\d+)-(\d+)\/(\d+)/.exec(c);s.onDone({begin:parseInt(d[1],10),chunk:r})}else r?s.onDone({begin:0,chunk:r}):(l=s.onError)==null||l.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 $p{constructor(t){this._source=t,this._manager=new jp(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 St(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Vp(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new Gp(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 Vp{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(r=>{const[o,...h]=r.split(": ");return[o,h.join(": ")]})),{allowRangeRequests:i,suggestedLength:a}=Lc({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=Fc(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 Gp{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 Up=/^[a-z][a-z0-9\-+.]+:/i;function su(u,t,e){return u.protocol==="http:"?wi.get("http").request(u,{headers:t},e):wi.get("https").request(u,{headers:t},e)}class qp{constructor(t){this.source=t,this.url=function(s){if(Up.test(s))return new URL(s);const i=wi.get("url");return new URL(i.pathToFileURL(s))}(t.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.headers=Ic(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 St(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new Kp(this):new Wp(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=this.isFsUrl?new Yp(this,t,e):new Xp(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 iu{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 e;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,(e=this.onProgress)==null||e.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Nn("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class nu{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 e;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,(e=this.onProgress)==null||e.call(this,{loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}class Wp extends iu{constructor(t){super(t);const e=Object.fromEntries(t.headers);this._request=su(this._url,e,s=>{if(s.statusCode===404){const o=new Dn(`Missing PDF "${this._url}".`);this._storedError=o,this._headersCapability.reject(o);return}this._headersCapability.resolve(),this._setReadableStream(s);const i=new Headers(this._readableStream.headers),{allowRangeRequests:a,suggestedLength:r}=Lc({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=r||this._contentLength,this._filename=Fc(i)}),this._request.on("error",s=>{this._storedError=s,this._headersCapability.reject(s)}),this._request.end()}}class Xp extends nu{constructor(t,e,s){super(t);const i=Object.fromEntries(t.headers);i.Range=`bytes=${e}-${s-1}`,this._request=su(this._url,i,a=>{if(a.statusCode!==404)this._setReadableStream(a);else{const r=new Dn(`Missing PDF "${this._url}".`);this._storedError=r}}),this._request.on("error",a=>{this._storedError=a}),this._request.end()}}class Kp extends iu{constructor(t){super(t);const e=wi.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 Dn(`Missing PDF "${this._url}".`)),this._storedError=s,this._headersCapability.reject(s)})}}class Yp extends nu{constructor(t,e,s){super(t);const i=wi.get("fs");this._setReadableStream(i.createReadStream(this._url,{start:e,end:s-1}))}}const Yt=30;var ud,ai,Zt,Ur,qr,Yi,bs,Wr,Xr,Qi,fa,pa,ri,ga,Kr,ma,Ji,Yr,Qr,Zi,tn,Jr,oi,ba,zs,au,ru,Nl,ge,Qo,Ol,ou,hu;const yt=class yt{constructor({textContentSource:t,container:e,viewport:s}){b(this,zs);b(this,ai,Promise.withResolvers());b(this,Zt,null);b(this,Ur,!1);b(this,qr,!!((ud=globalThis.FontInspector)!=null&&ud.enabled));b(this,Yi,null);b(this,bs,null);b(this,Wr,0);b(this,Xr,0);b(this,Qi,null);b(this,fa,null);b(this,pa,0);b(this,ri,0);b(this,ga,Object.create(null));b(this,Kr,[]);b(this,ma,null);b(this,Ji,[]);b(this,Yr,new WeakMap);b(this,Qr,null);var h;if(t instanceof ReadableStream)p(this,ma,t);else{if(typeof t!="object")throw new Error('No "textContentSource" parameter specified.');p(this,ma,new ReadableStream({start(l){l.enqueue(t),l.close()}}))}p(this,Zt,p(this,fa,e)),p(this,ri,s.scale*(globalThis.devicePixelRatio||1)),p(this,pa,s.rotation),p(this,bs,{div:null,properties:null,ctx:null});const{pageWidth:i,pageHeight:a,pageX:r,pageY:o}=s.rawDims;p(this,Qr,[1,0,0,-1,-r,o+a]),p(this,Xr,i),p(this,Wr,a),m(h=yt,ge,ou).call(h),Rn(e,s),n(this,ai).promise.finally(()=>{n(yt,ba).delete(this),p(this,bs,null),p(this,ga,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=Wt.platform;return K(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const t=()=>{n(this,Qi).read().then(({value:e,done:s})=>{s?n(this,ai).resolve():(n(this,Yi)??p(this,Yi,e.lang),Object.assign(n(this,ga),e.styles),m(this,zs,au).call(this,e.items),t())},n(this,ai).reject)};return p(this,Qi,n(this,ma).getReader()),n(yt,ba).add(this),t(),n(this,ai).promise}update({viewport:t,onBefore:e=null}){var a;const s=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==n(this,pa)&&(e==null||e(),p(this,pa,i),Rn(n(this,fa),{rotation:i})),s!==n(this,ri)){e==null||e(),p(this,ri,s);const r={div:null,properties:null,ctx:m(a=yt,ge,Qo).call(a,n(this,Yi))};for(const o of n(this,Ji))r.properties=n(this,Yr).get(o),r.div=o,m(this,zs,Nl).call(this,r)}}cancel(){var e;const t=new Nn("TextLayer task cancelled.");(e=n(this,Qi))==null||e.cancel(t).catch(()=>{}),p(this,Qi,null),n(this,ai).reject(t)}get textDivs(){return n(this,Ji)}get textContentItemsStr(){return n(this,Kr)}static cleanup(){if(!(n(this,ba).size>0)){n(this,Zi).clear();for(const{canvas:t}of n(this,tn).values())t.remove();n(this,tn).clear()}}};ai=new WeakMap,Zt=new WeakMap,Ur=new WeakMap,qr=new WeakMap,Yi=new WeakMap,bs=new WeakMap,Wr=new WeakMap,Xr=new WeakMap,Qi=new WeakMap,fa=new WeakMap,pa=new WeakMap,ri=new WeakMap,ga=new WeakMap,Kr=new WeakMap,ma=new WeakMap,Ji=new WeakMap,Yr=new WeakMap,Qr=new WeakMap,Zi=new WeakMap,tn=new WeakMap,Jr=new WeakMap,oi=new WeakMap,ba=new WeakMap,zs=new WeakSet,au=function(t){var i,a;if(n(this,Ur))return;(a=n(this,bs)).ctx??(a.ctx=m(i=yt,ge,Qo).call(i,n(this,Yi)));const e=n(this,Ji),s=n(this,Kr);for(const r of t){if(e.length>1e5){q("Ignoring additional textDivs for performance reasons."),p(this,Ur,!0);return}if(r.str!==void 0)s.push(r.str),m(this,zs,ru).call(this,r);else if(r.type==="beginMarkedContentProps"||r.type==="beginMarkedContent"){const o=n(this,Zt);p(this,Zt,document.createElement("span")),n(this,Zt).classList.add("markedContent"),r.id!==null&&n(this,Zt).setAttribute("id",`${r.id}`),o.append(n(this,Zt))}else r.type==="endMarkedContent"&&p(this,Zt,n(this,Zt).parentNode)}},ru=function(t){var v;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};n(this,Ji).push(e);const i=I.transform(n(this,Qr),t.transform);let a=Math.atan2(i[1],i[0]);const r=n(this,ga)[t.fontName];r.vertical&&(a+=Math.PI/2);let o=n(this,qr)&&r.fontSubstitution||r.fontFamily;o=yt.fontFamilyMap.get(o)||o;const h=Math.hypot(i[2],i[3]),l=h*m(v=yt,ge,hu).call(v,o,n(this,Yi));let c,d;a===0?(c=i[4],d=i[5]-l):(c=i[4]+l*Math.sin(a),d=i[5]-l*Math.cos(a));const f="calc(var(--scale-factor)*",g=e.style;n(this,Zt)===n(this,fa)?(g.left=`${(100*c/n(this,Xr)).toFixed(2)}%`,g.top=`${(100*d/n(this,Wr)).toFixed(2)}%`):(g.left=`${f}${c.toFixed(2)}px)`,g.top=`${f}${d.toFixed(2)}px)`),g.fontSize=`${f}${(n(yt,oi)*h).toFixed(2)}px)`,g.fontFamily=o,s.fontSize=h,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,n(this,qr)&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),a!==0&&(s.angle=a*(180/Math.PI));let A=!1;if(t.str.length>1)A=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const w=Math.abs(t.transform[0]),y=Math.abs(t.transform[3]);w!==y&&Math.max(w,y)/Math.min(w,y)>1.5&&(A=!0)}if(A&&(s.canvasWidth=r.vertical?t.height:t.width),n(this,Yr).set(e,s),n(this,bs).div=e,n(this,bs).properties=s,m(this,zs,Nl).call(this,n(this,bs)),s.hasText&&n(this,Zt).append(e),s.hasEOL){const w=document.createElement("br");w.setAttribute("role","presentation"),n(this,Zt).append(w)}},Nl=function(t){var o;const{div:e,properties:s,ctx:i}=t,{style:a}=e;let r="";if(n(yt,oi)>1&&(r=`scale(${1/n(yt,oi)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:h}=a,{canvasWidth:l,fontSize:c}=s;m(o=yt,ge,Ol).call(o,i,c*n(this,ri),h);const{width:d}=i.measureText(e.textContent);d>0&&(r=`scaleX(${l*n(this,ri)/d}) ${r}`)}s.angle!==0&&(r=`rotate(${s.angle}deg) ${r}`),r.length>0&&(a.transform=r)},ge=new WeakSet,Qo=function(t=null){let e=n(this,tn).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}),n(this,tn).set(t,e),n(this,Jr).set(e,{size:0,family:""})}return e},Ol=function(t,e,s){const i=n(this,Jr).get(t);(e!==i.size||s!==i.family)&&(t.font=`${e}px ${s}`,i.size=e,i.family=s)},ou=function(){if(n(this,oi)!==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,oi,t.getBoundingClientRect().height),t.remove()},hu=function(t,e){const s=n(this,Zi).get(t);if(s)return s;const i=m(this,ge,Qo).call(this,e);i.canvas.width=i.canvas.height=Yt,m(this,ge,Ol).call(this,i,Yt,t);const a=i.measureText("");let r=a.fontBoundingBoxAscent,o=Math.abs(a.fontBoundingBoxDescent);if(r){const c=r/(r+o);return n(this,Zi).set(t,c),i.canvas.width=i.canvas.height=0,c}i.strokeStyle="red",i.clearRect(0,0,Yt,Yt),i.strokeText("g",0,0);let h=i.getImageData(0,0,Yt,Yt).data;o=0;for(let c=h.length-1-3;c>=0;c-=4)if(h[c]>0){o=Math.ceil(c/4/Yt);break}i.clearRect(0,0,Yt,Yt),i.strokeText("A",0,Yt),h=i.getImageData(0,0,Yt,Yt).data,r=0;for(let c=0,d=h.length;c<d;c+=4)if(h[c]>0){r=Yt-Math.floor(c/4/Yt);break}i.canvas.width=i.canvas.height=0;const l=r?r/(r+o):.8;return n(this,Zi).set(t,l),l},b(yt,ge),b(yt,Zi,new Map),b(yt,tn,new Map),b(yt,Jr,new WeakMap),b(yt,oi,null),b(yt,ba,new Set);let gr=yt;class mr{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};return function i(a){var h;if(!a)return;let r=null;const o=a.name;if(o==="#text")r=a.value;else{if(!mr.shouldBuildText(o))return;(h=a==null?void 0:a.attributes)!=null&&h.textContent?r=a.attributes.textContent:a.value&&(r=a.value)}if(r!==null&&e.push({str:r}),a.children)for(const l of a.children)i(l)}(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const Qp=65536,Jp=$t?class extends Wc{_createCanvas(t,e){return wi.get("canvas").createCanvas(t,e)}}:class extends Wc{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}},Zp=$t?class extends Ud{async _fetch(t){return Kd(t)}}:qd;var en,sn,Je,As,Ht,Lh,nn,P,Ot,Hn,zn,Jo,jn,lu,Bl,$n,er,sr,Hl,ir,fd;const tg=$t?class extends Xc{}:(fd=class extends Xc{constructor({docId:e,ownerDocument:s=globalThis.document}){super();b(this,P);b(this,en);b(this,sn);b(this,Je);b(this,As);b(this,Ht);b(this,Lh);b(this,nn,0);p(this,As,e),p(this,Ht,s)}addFilter(e){if(!e)return"none";let s=n(this,P,Ot).get(e);if(s)return s;const[i,a,r]=m(this,P,Jo).call(this,e),o=e.length===1?i:`${i}${a}${r}`;if(s=n(this,P,Ot).get(o),s)return n(this,P,Ot).set(e,s),s;const h=`g_${n(this,As)}_transfer_map_${Gt(this,nn)._++}`,l=m(this,P,jn).call(this,h);n(this,P,Ot).set(e,l),n(this,P,Ot).set(o,l);const c=m(this,P,$n).call(this,h);return m(this,P,sr).call(this,i,a,r,c),l}addHCMFilter(e,s){var A;const i=`${e}-${s}`,a="base";let r=n(this,P,Hn).get(a);if((r==null?void 0:r.key)===i||(r?((A=r.filter)==null||A.remove(),r.key=i,r.url="none",r.filter=null):(r={key:i,url:"none",filter:null},n(this,P,Hn).set(a,r)),!e||!s))return r.url;const o=m(this,P,ir).call(this,e);e=I.makeHexColor(...o);const h=m(this,P,ir).call(this,s);if(s=I.makeHexColor(...h),n(this,P,zn).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return r.url;const l=new Array(256);for(let v=0;v<=255;v++){const w=v/255;l[v]=w<=.03928?w/12.92:((w+.055)/1.055)**2.4}const c=l.join(","),d=`g_${n(this,As)}_hcm_filter`,f=r.filter=m(this,P,$n).call(this,d);m(this,P,sr).call(this,c,c,c,f),m(this,P,Bl).call(this,f);const g=(v,w)=>{const y=o[v]/255,x=h[v]/255,_=new Array(w+1);for(let S=0;S<=w;S++)_[S]=y+S/w*(x-y);return _.join(",")};return m(this,P,sr).call(this,g(0,5),g(1,5),g(2,5),f),r.url=m(this,P,jn).call(this,d),r.url}addAlphaFilter(e){let s=n(this,P,Ot).get(e);if(s)return s;const[i]=m(this,P,Jo).call(this,[e]),a=`alpha_${i}`;if(s=n(this,P,Ot).get(a),s)return n(this,P,Ot).set(e,s),s;const r=`g_${n(this,As)}_alpha_map_${Gt(this,nn)._++}`,o=m(this,P,jn).call(this,r);n(this,P,Ot).set(e,o),n(this,P,Ot).set(a,o);const h=m(this,P,$n).call(this,r);return m(this,P,Hl).call(this,i,h),o}addLuminosityFilter(e){let s,i,a=n(this,P,Ot).get(e||"luminosity");if(a)return a;if(e?([s]=m(this,P,Jo).call(this,[e]),i=`luminosity_${s}`):i="luminosity",a=n(this,P,Ot).get(i),a)return n(this,P,Ot).set(e,a),a;const r=`g_${n(this,As)}_luminosity_map_${Gt(this,nn)._++}`,o=m(this,P,jn).call(this,r);n(this,P,Ot).set(e,o),n(this,P,Ot).set(i,o);const h=m(this,P,$n).call(this,r);return m(this,P,lu).call(this,h),e&&m(this,P,Hl).call(this,s,h),o}addHighlightHCMFilter(e,s,i,a,r){var x;const o=`${s}-${i}-${a}-${r}`;let h=n(this,P,Hn).get(e);if((h==null?void 0:h.key)===o||(h?((x=h.filter)==null||x.remove(),h.key=o,h.url="none",h.filter=null):(h={key:o,url:"none",filter:null},n(this,P,Hn).set(e,h)),!s||!i))return h.url;const[l,c]=[s,i].map(m(this,P,ir).bind(this));let d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),f=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[g,A]=[a,r].map(m(this,P,ir).bind(this));f<d&&([d,f,g,A]=[f,d,A,g]),n(this,P,zn).style.color="";const v=(_,S,E)=>{const M=new Array(256),C=(f-d)/E,R=_/255,j=(S-_)/(255*E);let D=0;for(let F=0;F<=E;F++){const Y=Math.round(d+F*C),Q=R+F*j;for(let B=D;B<=Y;B++)M[B]=Q;D=Y+1}for(let F=D;F<256;F++)M[F]=M[D-1];return M.join(",")},w=`g_${n(this,As)}_hcm_${e}_filter`,y=h.filter=m(this,P,$n).call(this,w);return m(this,P,Bl).call(this,y),m(this,P,sr).call(this,v(g[0],A[0],5),v(g[1],A[1],5),v(g[2],A[2],5),y),h.url=m(this,P,jn).call(this,w),h.url}destroy(e=!1){(!e||n(this,P,Hn).size===0)&&(n(this,Je)&&(n(this,Je).parentNode.parentNode.remove(),p(this,Je,null)),n(this,sn)&&(n(this,sn).clear(),p(this,sn,null)),p(this,nn,0))}},en=new WeakMap,sn=new WeakMap,Je=new WeakMap,As=new WeakMap,Ht=new WeakMap,Lh=new WeakMap,nn=new WeakMap,P=new WeakSet,Ot=function(){return n(this,sn)||p(this,sn,new Map)},Hn=function(){return n(this,Lh)||p(this,Lh,new Map)},zn=function(){if(!n(this,Je)){const e=n(this,Ht).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=n(this,Ht).createElementNS(ls,"svg");i.setAttribute("width",0),i.setAttribute("height",0),p(this,Je,n(this,Ht).createElementNS(ls,"defs")),e.append(i),i.append(n(this,Je)),n(this,Ht).body.append(e)}return n(this,Je)},Jo=function(e){if(e.length===1){const l=e[0],c=new Array(256);for(let f=0;f<256;f++)c[f]=l[f]/255;const d=c.join(",");return[d,d,d]}const[s,i,a]=e,r=new Array(256),o=new Array(256),h=new Array(256);for(let l=0;l<256;l++)r[l]=s[l]/255,o[l]=i[l]/255,h[l]=a[l]/255;return[r.join(","),o.join(","),h.join(",")]},jn=function(e){if(n(this,en)===void 0){p(this,en,"");const s=n(this,Ht).URL;s!==n(this,Ht).baseURI&&(Xh(s)?q('#createUrl: ignore "data:"-URL for performance reasons.'):p(this,en,s.split("#",1)[0]))}return`url(${n(this,en)}#${e})`},lu=function(e){const s=n(this,Ht).createElementNS(ls,"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)},Bl=function(e){const s=n(this,Ht).createElementNS(ls,"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)},$n=function(e){const s=n(this,Ht).createElementNS(ls,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),n(this,P,zn).append(s),s},er=function(e,s,i){const a=n(this,Ht).createElementNS(ls,s);a.setAttribute("type","discrete"),a.setAttribute("tableValues",i),e.append(a)},sr=function(e,s,i,a){const r=n(this,Ht).createElementNS(ls,"feComponentTransfer");a.append(r),m(this,P,er).call(this,r,"feFuncR",e),m(this,P,er).call(this,r,"feFuncG",s),m(this,P,er).call(this,r,"feFuncB",i)},Hl=function(e,s){const i=n(this,Ht).createElementNS(ls,"feComponentTransfer");s.append(i),m(this,P,er).call(this,i,"feFuncA",e)},ir=function(e){return n(this,P,zn).style.color=e,ll(getComputedStyle(n(this,P,zn)).getPropertyValue("color"))},fd),eg=$t?class extends Wd{async _fetch(t){return Kd(t)}}:Xd;function sg(u={}){typeof u=="string"||u instanceof URL?u={url:u}:(u instanceof ArrayBuffer||ArrayBuffer.isView(u))&&(u={data:u});const t=new zl,{docId:e}=t,s=u.url?function(tt){if(tt instanceof URL)return tt.href;try{return new URL(tt,window.location).href}catch{if($t&&typeof tt=="string")return tt}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(u.url):null,i=u.data?function(tt){if($t&&typeof Buffer<"u"&&tt instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(tt instanceof Uint8Array&&tt.byteLength===tt.buffer.byteLength)return tt;if(typeof tt=="string")return qh(tt);if(tt instanceof ArrayBuffer||ArrayBuffer.isView(tt)||typeof tt=="object"&&!isNaN(tt==null?void 0:tt.length))return new Uint8Array(tt);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(u.data):null,a=u.httpHeaders||null,r=u.withCredentials===!0,o=u.password??null,h=u.range instanceof cu?u.range:null,l=Number.isInteger(u.rangeChunkSize)&&u.rangeChunkSize>0?u.rangeChunkSize:Qp;let c=u.worker instanceof Xn?u.worker:null;const d=u.verbosity,f=typeof u.docBaseUrl!="string"||Xh(u.docBaseUrl)?null:u.docBaseUrl,g=typeof u.cMapUrl=="string"?u.cMapUrl:null,A=u.cMapPacked!==!1,v=u.CMapReaderFactory||Zp,w=typeof u.standardFontDataUrl=="string"?u.standardFontDataUrl:null,y=u.StandardFontDataFactory||eg,x=u.stopAtErrors!==!0,_=Number.isInteger(u.maxImageSize)&&u.maxImageSize>-1?u.maxImageSize:-1,S=u.isEvalSupported!==!1,E=typeof u.isOffscreenCanvasSupported=="boolean"?u.isOffscreenCanvasSupported:!$t,M=typeof u.isChrome=="boolean"?u.isChrome:!Wt.platform.isFirefox&&typeof window<"u"&&!!(window!=null&&window.chrome),C=Number.isInteger(u.canvasMaxAreaInBytes)?u.canvasMaxAreaInBytes:-1,R=typeof u.disableFontFace=="boolean"?u.disableFontFace:$t,j=u.fontExtraProperties===!0,D=u.enableXfa===!0,F=u.ownerDocument||globalThis.document,Y=u.disableRange===!0,Q=u.disableStream===!0,B=u.disableAutoFetch===!0,ft=u.pdfBug===!0,ie=u.CanvasFactory||Jp,Ce=u.FilterFactory||tg,H=u.enableHWA===!0,U=h?h.length:u.length??NaN,Ei=typeof u.useSystemFonts=="boolean"?u.useSystemFonts:!$t&&!R,os=typeof u.useWorkerFetch=="boolean"?u.useWorkerFetch:v===qd&&y===Xd&&g&&w&&Ya(g,document.baseURI)&&Ya(w,document.baseURI);u.canvasFactory&&Uc("`canvasFactory`-instance option, please use `CanvasFactory` instead."),u.filterFactory&&Uc("`filterFactory`-instance option, please use `FilterFactory` instead."),Zf(d);const Vt={canvasFactory:new ie({ownerDocument:F,enableHWA:H}),filterFactory:new Ce({docId:e,ownerDocument:F}),cMapReaderFactory:os?null:new v({baseUrl:g,isCompressed:A}),standardFontDataFactory:os?null:new y({baseUrl:w})};if(!c){const ne={verbosity:d,port:Ns.workerPort};c=ne.port?Xn.fromPort(ne):new Xn(ne),t._worker=c}const Pt={docId:e,apiVersion:"4.8.69",data:i,password:o,disableAutoFetch:B,rangeChunkSize:l,length:U,docBaseUrl:f,enableXfa:D,evaluatorOptions:{maxImageSize:_,disableFontFace:R,ignoreErrors:x,isEvalSupported:S,isOffscreenCanvasSupported:E,isChrome:M,canvasMaxAreaInBytes:C,fontExtraProperties:j,useSystemFonts:Ei,cMapUrl:os?g:null,standardFontDataUrl:os?w:null}},$s={disableFontFace:R,fontExtraProperties:j,ownerDocument:F,pdfBug:ft,styleElement:null,loadingParams:{disableAutoFetch:B,enableXfa:D}};return c.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const ne=c.messageHandler.sendWithPromise("GetDocRequest",Pt,i?[i.buffer]:null);let tt;if(h)tt=new Np(h,{disableRange:Y,disableStream:Q});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");let bt;$t?bt=typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype&&Ya(s)?od:qp:bt=Ya(s)?od:$p,tt=new bt({url:s,length:U,httpHeaders:a,withCredentials:r,rangeChunkSize:l,disableRange:Y,disableStream:Q})}return ne.then(bt=>{if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const zc=new tr(e,bt,c.port),Af=new rg(zc,t,tt,$s,Vt);t._transport=Af,zc.send("Ready",null)})}).catch(t._capability.reject),t}function hd(u){return typeof u=="object"&&Number.isInteger(u==null?void 0:u.num)&&u.num>=0&&Number.isInteger(u==null?void 0:u.gen)&&u.gen>=0}var Fh;const Dh=class Dh{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+Gt(Dh,Fh)._++,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)}};Fh=new WeakMap,b(Dh,Fh,0);let zl=Dh;class cu{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){ot("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class ig{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 K(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 hi,vs,_e,Vn,Zo;class ng{constructor(t,e,s,i=!1){b(this,_e);b(this,hi,null);b(this,vs,!1);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new Gc:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new du,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:a=!1}={}){return new Lo({viewBox:this.view,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:a})}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 K(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=qs.ENABLE,transform:a=null,background:r=null,optionalContentConfigPromise:o=null,annotationCanvasMap:h=null,pageColors:l=null,printAnnotationStorage:c=null,isEditing:d=!1}){var S,E;(S=this._stats)==null||S.time("Overall");const f=this._transport.getRenderingIntent(s,i,c,d),{renderingIntent:g,cacheKey:A}=f;p(this,vs,!1),m(this,_e,Zo).call(this),o||(o=this._transport.getOptionalContentConfig(g));let v=this._intentStates.get(A);v||(v=Object.create(null),this._intentStates.set(A,v)),v.streamReaderCancelTimeout&&(clearTimeout(v.streamReaderCancelTimeout),v.streamReaderCancelTimeout=null);const w=!!(g&vh);v.displayReadyCapability||(v.displayReadyCapability=Promise.withResolvers(),v.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(E=this._stats)==null||E.time("Page Request"),this._pumpOperatorList(f));const y=M=>{var C;v.renderTasks.delete(x),(this._maybeCleanupAfterRender||w)&&p(this,vs,!0),m(this,_e,Vn).call(this,!w),M?(x.capability.reject(M),this._abortOperatorList({intentState:v,reason:M instanceof Error?M:new Error(M)})):x.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(C=globalThis.Stats)!=null&&C.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},x=new $l({callback:y,params:{canvasContext:t,viewport:e,transform:a,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:v.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!w,pdfBug:this._pdfBug,pageColors:l});(v.renderTasks||(v.renderTasks=new Set)).add(x);const _=x.task;return Promise.all([v.displayReadyCapability.promise,o]).then(([M,C])=>{var R;if(this.destroyed)y();else{if((R=this._stats)==null||R.time("Rendering"),!(C.renderingIntent&g))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");x.initializeGraphics({transparency:M,optionalContentConfig:C}),x.operatorListChanged()}}).catch(y),_}getOperatorList({intent:t="display",annotationMode:e=qs.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){var h;const a=this._transport.getRenderingIntent(t,e,s,i,!0);let r,o=this._intentStates.get(a.cacheKey);return o||(o=Object.create(null),this._intentStates.set(a.cacheKey,o)),o.opListReadCapability||(r=Object.create(null),r.operatorListChanged=function(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(r))},o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(r),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:s=>s.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>mr.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){const a=e.getReader(),r={items:[],styles:Object.create(null),lang:null};(function o(){a.read().then(function({value:h,done:l}){l?s(r):(r.lang??(r.lang=h.lang),Object.assign(r.styles,h.styles),r.items.push(...h.items),o())},i)})()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),p(this,vs,!1),m(this,_e,Zo).call(this),Promise.all(t)}cleanup(t=!1){p(this,vs,!0);const e=m(this,_e,Vn).call(this,!1);return t&&e&&this._stats&&(this._stats=new Gc),e}_startRenderPage(t,e){var i,a;const s=this._intentStates.get(e);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(a=s.displayReadyCapability)==null||a.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&m(this,_e,Vn).call(this,!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){const{map:a,transfer:r}=s,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:a,modifiedIds:i},r).getReader(),h=this._intentStates.get(e);h.streamReader=o;const l=()=>{o.read().then(({value:c,done:d})=>{d?h.streamReader=null:this._transport.destroyed||(this._renderPageChunk(c,h),l())},c=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(const d of h.renderTasks)d.operatorListChanged();m(this,_e,Vn).call(this,!0)}if(h.displayReadyCapability)h.displayReadyCapability.reject(c);else{if(!h.opListReadCapability)throw c;h.opListReadCapability.reject(c)}}})};l()}_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 Cc){let i=100;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 Nn(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,a]of this._intentStates)if(a===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}hi=new WeakMap,vs=new WeakMap,_e=new WeakSet,Vn=function(t=!1){if(m(this,_e,Zo).call(this),!n(this,vs)||this.destroyed)return!1;if(t)return p(this,hi,setTimeout(()=>{p(this,hi,null),m(this,_e,Vn).call(this,!1)},5e3)),!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,vs,!1),!0},Zo=function(){n(this,hi)&&(clearTimeout(n(this,hi)),p(this,hi,null))};var ys,Nh;class ag{constructor(){b(this,ys,new Map);b(this,Nh,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};n(this,Nh).then(()=>{for(const[i]of n(this,ys))i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:a}=s;if(a.aborted){q("LoopbackPort - cannot use an `aborted` signal.");return}const r=()=>this.removeEventListener(t,e);i=()=>a.removeEventListener("abort",r),a.addEventListener("abort",r)}n(this,ys).set(e,i)}removeEventListener(t,e){const s=n(this,ys).get(e);s==null||s(),n(this,ys).delete(e)}terminate(){for(const[,t]of n(this,ys))t==null||t();n(this,ys).clear()}}ys=new WeakMap,Nh=new WeakMap;var Oh,an,rn,Aa,th,va,eh;const ht=class ht{constructor({name:t=null,port:e=null,verbosity:s=tp()}={}){b(this,Aa);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=n(ht,rn))!=null&&i.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(n(ht,rn)||p(ht,rn,new WeakMap)).set(e,this),this._initializeFromPort(e)}else this._initialize()}get promise(){return $t?Promise.all([wi.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 tr("main","worker",t),this._messageHandler.on("ready",function(){}),m(this,Aa,th).call(this)}_initialize(){if(n(ht,an)||n(ht,va,eh)){this._setupFakeWorker();return}let{workerSrc:t}=ht;try{ht._isSameOrigin(window.location.href,t)||(t=ht._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new tr("main","worker",e),i=()=>{a.abort(),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},a=new AbortController;e.addEventListener("error",()=>{this._webWorker||i()},{signal:a.signal}),s.on("test",o=>{a.abort(),!this.destroyed&&o?(this._messageHandler=s,this._port=e,this._webWorker=e,m(this,Aa,th).call(this)):i()}),s.on("ready",o=>{if(a.abort(),this.destroyed)i();else try{r()}catch{this._setupFakeWorker()}});const r=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};r();return}catch{Gh("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){n(ht,an)||(q("Setting up fake worker."),p(ht,an,!0)),ht._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new ag;this._port=e;const s="fake"+Gt(ht,Oh)._++,i=new tr(s+"_worker",s,e);t.setup(i,e),this._messageHandler=new tr(s,s+"_worker",e),m(this,Aa,th).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=n(ht,rn))==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=n(this,rn))==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 ht(t)}static get workerSrc(){if(Ns.workerSrc)return Ns.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return K(this,"_setupFakeWorkerGlobal",(async()=>n(this,va,eh)?n(this,va,eh):(await import(this.workerSrc)).WorkerMessageHandler)())}};Oh=new WeakMap,an=new WeakMap,rn=new WeakMap,Aa=new WeakSet,th=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},va=new WeakSet,eh=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},b(ht,va),b(ht,Oh,0),b(ht,an,!1),b(ht,rn),$t&&(p(ht,an,!0),Ns.workerSrc||(Ns.workerSrc="./pdf.worker.mjs")),ht._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},ht._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let Xn=ht;var ws,Ze,ya,wa,ts,on,nr;class rg{constructor(t,e,s,i,a){b(this,on);b(this,ws,new Map);b(this,Ze,new Map);b(this,ya,new Map);b(this,wa,new Map);b(this,ts,null);this.messageHandler=t,this.loadingTask=e,this.commonObjs=new du,this.fontLoader=new yp({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=a.canvasFactory,this.filterFactory=a.filterFactory,this.cMapReaderFactory=a.cMapReaderFactory,this.standardFontDataFactory=a.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 K(this,"annotationStorage",new Tc)}getRenderingIntent(t,e=qs.ENABLE,s=null,i=!1,a=!1){let r=xc,o=Tl;switch(t){case"any":r=wf;break;case"display":break;case"print":r=vh;break;default:q(`getRenderingIntent - invalid intent: ${t}`)}const h=r&vh&&s instanceof Gd?s:this.annotationStorage;switch(e){case qs.DISABLE:r+=Sf;break;case qs.ENABLE:break;case qs.ENABLE_FORMS:r+=_f;break;case qs.ENABLE_STORAGE:r+=xf,o=h.serializable;break;default:q(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(r+=Ef),a&&(r+=Cf);const{ids:l,hash:c}=h.modifiedIds;return{renderingIntent:r,cacheKey:[r,o.hash,c].join("_"),annotationStorageSerializable:o,modifiedIds:l}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=n(this,ts))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of n(this,Ze).values())t.push(i._destroy());n(this,Ze).clear(),n(this,ya).clear(),n(this,wa).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(),n(this,ws).clear(),this.filterFactory.destroy(),gr.cleanup(),(i=this._networkStream)==null||i.cancelAllRequests(new Nn("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)=>{St(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=a=>{this._lastProgress={loaded:a.loaded,total:a.total}},i.onPull=()=>{this._fullReader.read().then(function({value:a,done:r}){r?i.close():(St(a instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(a),1,[a]))}).catch(a=>{i.error(a)})},i.onCancel=a=>{this._fullReader.cancel(a),i.ready.catch(r=>{if(!this.destroyed)throw r})}}),t.on("ReaderHeadersReady",async s=>{var o;await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:a,contentLength:r}=this._fullReader;return(!i||!a)&&(this._lastProgress&&((o=e.onProgress)==null||o.call(e,this._lastProgress)),this._fullReader.onProgress=h=>{var l;(l=e.onProgress)==null||l.call(e,{loaded:h.loaded,total:h.total})}),{isStreamingSupported:i,isRangeSupported:a,contentLength:r}}),t.on("GetRangeReader",(s,i)=>{St(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const a=this._networkStream.getRangeReader(s.begin,s.end);a?(i.onPull=()=>{a.read().then(function({value:r,done:o}){o?i.close():(St(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r]))}).catch(r=>{i.error(r)})},i.onCancel=r=>{a.cancel(r),i.ready.catch(o=>{if(!this.destroyed)throw o})}):i.close()}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new ig(s,this))}),t.on("DocException",function(s){let i;switch(s.name){case"PasswordException":i=new rl(s.message,s.code);break;case"InvalidPDFException":i=new md(s.message);break;case"MissingPDFException":i=new Dn(s.message);break;case"UnexpectedResponseException":i=new Uh(s.message,s.status);break;case"UnknownErrorException":i=new ol(s.message,s.details);break;default:ot("DocException - expected a valid Error.")}e._capability.reject(i)}),t.on("PasswordRequest",s=>{if(p(this,ts,Promise.withResolvers()),e.onPassword){const i=a=>{a instanceof Error?n(this,ts).reject(a):n(this,ts).resolve({password:a})};try{e.onPassword(i,s.code)}catch(a){n(this,ts).reject(a)}}else n(this,ts).reject(new rl(s.message,s.code));return n(this,ts).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=>{this.destroyed||n(this,Ze).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,a])=>{var r;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":const{disableFontFace:o,fontExtraProperties:h,pdfBug:l}=this._params;if("error"in a){const g=a.error;q(`Error during font loading: ${g}`),this.commonObjs.resolve(s,g);break}const c=l&&((r=globalThis.FontInspector)!=null&&r.enabled)?(g,A)=>globalThis.FontInspector.fontAdded(g,A):null,d=new wp(a,{disableFontFace:o,inspectFont:c});this.fontLoader.bind(d).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!h&&d.data&&(d.data=null),this.commonObjs.resolve(s,d)});break;case"CopyLocalImage":const{imageRef:f}=a;St(f,"The imageRef must be defined.");for(const g of n(this,Ze).values())for(const[,A]of g.objs)if((A==null?void 0:A.ref)===f)return A.dataLen?(this.commonObjs.resolve(s,structuredClone(A)),A.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,a);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,a,r])=>{var h;if(this.destroyed)return;const o=n(this,Ze).get(i);if(!o.objs.has(s))if(o._intentStates.size!==0)switch(a){case"Image":o.objs.resolve(s,r),(r==null?void 0:r.dataLen)>1e7&&(o._maybeCleanupAfterRender=!0);break;case"Pattern":o.objs.resolve(s,r);break;default:throw new Error(`Got unknown object type ${a}`)}else(h=r==null?void 0:r.bitmap)==null||h.close()}),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&&q("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=n(this,ya).get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(a=>{if(this.destroyed)throw new Error("Transport destroyed");a.refStr&&n(this,wa).set(a.refStr,t);const r=new ng(e,a,this,this._params.pdfBug);return n(this,Ze).set(e,r),r});return n(this,ya).set(e,i),i}getPageIndex(t){return hd(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,on,nr).call(this,"GetFieldObjects")}hasJSActions(){return m(this,on,nr).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,on,nr).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,on,nr).call(this,"GetOptionalContentConfig").then(e=>new Dp(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=n(this,ws).get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(i=>{var a,r;return{info:i[0],metadata:i[1]?new Lp(i[1]):null,contentDispositionFilename:((a=this._fullReader)==null?void 0:a.filename)??null,contentLength:((r=this._fullReader)==null?void 0:r.contentLength)??null}});return n(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 n(this,Ze).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),n(this,ws).clear(),this.filterFactory.destroy(!0),gr.cleanup()}}cachedPageNumber(t){if(!hd(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return n(this,wa).get(e)??null}}ws=new WeakMap,Ze=new WeakMap,ya=new WeakMap,wa=new WeakMap,ts=new WeakMap,on=new WeakSet,nr=function(t,e=null){const s=n(this,ws).get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return n(this,ws).set(t,i),i};const zo=Symbol("INITIAL_DATA");var Fe,Zr,jl;class du{constructor(){b(this,Zr);b(this,Fe,Object.create(null))}get(t,e=null){if(e){const i=m(this,Zr,jl).call(this,t);return i.promise.then(()=>e(i.data)),null}const s=n(this,Fe)[t];if(!s||s.data===zo)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=n(this,Fe)[t];return!!e&&e.data!==zo}resolve(t,e=null){const s=m(this,Zr,jl).call(this,t);s.data=e,s.resolve()}clear(){var t;for(const e in n(this,Fe)){const{data:s}=n(this,Fe)[e];(t=s==null?void 0:s.bitmap)==null||t.close()}p(this,Fe,Object.create(null))}*[Symbol.iterator](){for(const t in n(this,Fe)){const{data:e}=n(this,Fe)[t];e!==zo&&(yield[t,e])}}}Fe=new WeakMap,Zr=new WeakSet,jl=function(t){var e;return(e=n(this,Fe))[t]||(e[t]={...Promise.withResolvers(),data:zo})};var li;class og{constructor(t){b(this,li,null);p(this,li,t),this.onContinue=null}get promise(){return n(this,li).capability.promise}cancel(t=0){n(this,li).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=n(this,li).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=n(this,li);return t.form||t.canvas&&(e==null?void 0:e.size)>0}}li=new WeakMap;var ci,hn;const Pi=class Pi{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:a,operatorList:r,pageIndex:o,canvasFactory:h,filterFactory:l,useRequestAnimationFrame:c=!1,pdfBug:d=!1,pageColors:f=null}){b(this,ci,null);this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=a,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=o,this.canvasFactory=h,this.filterFactory=l,this._pdfBug=d,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=c===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new og(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,h;if(this.cancelled)return;if(this._canvas){if(n(Pi,hn).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.");n(Pi,hn).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:a,background:r}=this.params;this.gfx=new Wn(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:a,viewport:i,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,(h=this.graphicsReadyCallback)==null||h.call(this)}cancel(t=null,e=0){var s;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),n(this,ci)&&(window.cancelAnimationFrame(n(this,ci)),p(this,ci,null)),n(Pi,hn).delete(this._canvas),this.callback(t||new Cc(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){var t;this.graphicsReady?((t=this.stepper)==null||t.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound)}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?p(this,ci,window.requestAnimationFrame(()=>{p(this,ci,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(),n(Pi,hn).delete(this._canvas),this.callback())))}};ci=new WeakMap,hn=new WeakMap,b(Pi,hn,new WeakSet);let $l=Pi;const hg="4.8.69",lg="3634dab10";function ld(u){return Math.floor(255*Math.max(0,Math.min(1,u))).toString(16).padStart(2,"0")}function Ka(u){return Math.max(0,Math.min(255,255*u))}class cd{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=Ka(t),t,t]}static G_HTML([t]){const e=ld(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(Ka)}static RGB_HTML(t){return`#${t.map(ld).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[Ka(1-Math.min(1,t+i)),Ka(1-Math.min(1,s+i)),Ka(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,a=1-e,r=1-s;return["CMYK",i,a,r,Math.min(i,a,r)]}}class cg{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){ot("Abstract method `_createSVG` called.")}}class Dc extends cg{_createSVG(t){return document.createElementNS(ls,t)}}class uu{static setupStorage(t,e,s,i,a){const r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),a==="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(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),a==="print")break;t.addEventListener("change",o=>{i.setValue(e,{value:o.target.checked?o.target.getAttribute("xfaOn"):o.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),a==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(const o of s.children)o.attributes.value===r.value?o.attributes.selected=!0:o.attributes.hasOwnProperty("selected")&&delete o.attributes.selected}t.addEventListener("input",o=>{const h=o.target.options,l=h.selectedIndex===-1?"":h[h.selectedIndex].value;i.setValue(e,{value:l})})}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:a}){const{attributes:r}=e,o=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${i}`);for(const[h,l]of Object.entries(r))if(l!=null)switch(h){case"class":l.length&&t.setAttribute(h,l.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",l);break;case"style":Object.assign(t.style,l);break;case"textContent":t.textContent=l;break;default:(!o||h!=="href"&&h!=="newWindow")&&t.setAttribute(h,l)}o&&a.addLinkAttributes(t,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(t,r.dataId,e,s)}static render(t){var d,f;const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,a=t.intent||"display",r=document.createElement(i.name);i.attributes&&this.setAttributes({html:r,element:i,intent:a,linkService:s});const o=a!=="richText",h=t.div;if(h.append(r),t.viewport){const g=`matrix(${t.viewport.transform.join(",")})`;h.style.transform=g}o&&h.setAttribute("class","xfaLayer xfaFont");const l=[];if(i.children.length===0){if(i.value){const g=document.createTextNode(i.value);r.append(g),o&&mr.shouldBuildText(i.name)&&l.push(g)}return{textDivs:l}}const c=[[i,-1,r]];for(;c.length>0;){const[g,A,v]=c.at(-1);if(A+1===g.children.length){c.pop();continue}const w=g.children[++c.at(-1)[1]];if(w===null)continue;const{name:y}=w;if(y==="#text"){const _=document.createTextNode(w.value);l.push(_),v.append(_);continue}const x=(d=w==null?void 0:w.attributes)!=null&&d.xmlns?document.createElementNS(w.attributes.xmlns,y):document.createElement(y);if(v.append(x),w.attributes&&this.setAttributes({html:x,element:w,storage:e,intent:a,linkService:s}),((f=w.children)==null?void 0:f.length)>0)c.push([w,-1,x]);else if(w.value){const _=document.createTextNode(w.value);o&&mr.shouldBuildText(y)&&l.push(_),x.append(_)}}for(const g of h.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))g.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const Do=1e3,In=new WeakSet;function Os(u){return{width:u[2]-u[0],height:u[3]-u[1]}}class dg{static create(t){switch(t.data.annotationType){case Pf:return new fu(t);case Rf:return new ug(t);case qf:switch(t.data.fieldType){case"Tx":return new fg(t);case"Btn":return t.data.radioButton?new mu(t):t.data.checkBox?new gg(t):new mg(t);case"Ch":return new bg(t);case"Sig":return new pg(t)}return new On(t);case gd:return new Gl(t);case If:return new wu(t);case Lf:return new vg(t);case Ff:return new yg(t);case Df:return new wg(t);case Of:return new _u(t);case Vf:return new xg(t);case Gf:return new Nc(t);case Nf:return new _g(t);case Bf:return new xu(t);case Hf:return new Sg(t);case zf:return new Eg(t);case jf:return new Cg(t);case $f:return new Su(t);case Uf:return new Mg(t);default:return new mt(t)}}}var ln,_a,xa,to,Vl;const Hc=class Hc{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){b(this,to);b(this,ln,null);b(this,_a,!1);b(this,xa,null);this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.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 Hc._hasPopupData(this.data)}updateEdited(t){var s;if(!this.container)return;n(this,ln)||p(this,ln,{rect:this.data.rect.slice(0)});const{rect:e}=t;e&&m(this,to,Vl).call(this,e),(s=n(this,xa))==null||s.popup.updateEdited(t)}resetEdited(){var t;n(this,ln)&&(m(this,to,Vl).call(this,n(this,ln).rect),(t=n(this,xa))==null||t.popup.resetEdited(),p(this,ln,null))}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,a=document.createElement("section");a.setAttribute("data-annotation-id",e.id),this instanceof On||(a.tabIndex=Do);const{style:r}=a;if(r.zIndex=this.parent.zIndex++,e.alternativeText&&(a.title=e.alternativeText),e.noRotate&&a.classList.add("norotate"),!e.rect||this instanceof Gl){const{rotation:v}=e;return e.hasOwnCanvas||v===0||this.setRotation(v,a),a}const{width:o,height:h}=Os(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const v=e.borderStyle.horizontalCornerRadius,w=e.borderStyle.verticalCornerRadius;if(v>0||w>0){const x=`calc(${v}px * var(--scale-factor)) / calc(${w}px * var(--scale-factor))`;r.borderRadius=x}else if(this instanceof mu){const x=`calc(${o}px * var(--scale-factor)) / calc(${h}px * var(--scale-factor))`;r.borderRadius=x}switch(e.borderStyle.style){case Wf:r.borderStyle="solid";break;case Xf:r.borderStyle="dashed";break;case Kf:q("Unimplemented border style: beveled");break;case Yf:q("Unimplemented border style: inset");break;case Qf:r.borderBottomStyle="solid"}const y=e.borderColor||null;y?(p(this,_a,!0),r.borderColor=I.makeHexColor(0|y[0],0|y[1],0|y[2])):r.borderWidth=0}const l=I.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:c,pageHeight:d,pageX:f,pageY:g}=i.rawDims;r.left=100*(l[0]-f)/c+"%",r.top=100*(l[1]-g)/d+"%";const{rotation:A}=e;return e.hasOwnCanvas||A===0?(r.width=100*o/c+"%",r.height=100*h/d+"%"):this.setRotation(A,a),a}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:a,height:r}=Os(this.data.rect);let o,h;t%180==0?(o=100*a/s,h=100*r/i):(o=100*r/s,h=100*a/i),e.style.width=`${o}%`,e.style.height=`${h}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const a=i.detail[e],r=a[0],o=a.slice(1);i.target.style[s]=cd[`${r}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:cd[`${r}_rgb`](o)})};return K(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 a=t[i]||s[i];a==null||a(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,a]of Object.entries(e)){const r=s[i];r&&(r({detail:{[i]:a},target:t}),delete e[i])}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,a]=this.data.rect.map(v=>Math.fround(v));if(t.length===8){const[v,w,y,x]=t.subarray(2,6);if(i===v&&a===w&&e===y&&s===x)return}const{style:r}=this.container;let o;if(n(this,_a)){const{borderColor:v,borderWidth:w}=r;r.borderWidth=0,o=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${v}" stroke-width="${w}">`],this.container.classList.add("hasBorder")}const h=i-e,l=a-s,{svgFactory:c}=this,d=c.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);const f=c.createElement("defs");d.append(f);const g=c.createElement("clipPath"),A=`clippath_${this.data.id}`;g.setAttribute("id",A),g.setAttribute("clipPathUnits","objectBoundingBox"),f.append(g);for(let v=2,w=t.length;v<w;v+=8){const y=t[v],x=t[v+1],_=t[v+2],S=t[v+3],E=c.createElement("rect"),M=(_-e)/h,C=(a-x)/l,R=(y-_)/h,j=(x-S)/l;E.setAttribute("x",M),E.setAttribute("y",C),E.setAttribute("width",R),E.setAttribute("height",j),g.append(E),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${M}" y="${C}" width="${R}" height="${j}"/>`)}n(this,_a)&&(o.push("</g></svg>')"),r.backgroundImage=o.join("")),this.container.append(d),this.container.style.clipPath=`url(#${A})`}_createPopup(){const{data:t}=this,e=p(this,xa,new Gl({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(e.render())}render(){ot("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:a,id:r,exportValues:o}of i){if(a===-1||r===e)continue;const h=typeof o=="string"?o:null,l=document.querySelector(`[data-element-id="${r}"]`);!l||In.has(l)?s.push({id:r,exportValue:h,domElement:l}):q(`_getElementsByName - element not allowed: ${r}`)}return s}for(const i of document.getElementsByName(t)){const{exportValue:a}=i,r=i.getAttribute("data-element-id");r!==e&&In.has(i)&&s.push({id:r,exportValue:a,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})})}};ln=new WeakMap,_a=new WeakMap,xa=new WeakMap,to=new WeakSet,Vl=function(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:a,pageHeight:r,pageX:o,pageY:h}}}}=this;s==null||s.splice(0,4,...t);const{width:l,height:c}=Os(t);e.left=100*(t[0]-o)/a+"%",e.top=100*(r-t[3]+h)/r+"%",i===0?(e.width=100*l/a+"%",e.height=100*c/r+"%"):this.setRotation(i)};let mt=Hc;var pe,Ci,pu,gu;class fu extends mt{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});b(this,pe);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let a=!1;return e.url?(s.addLinkAttributes(i,e.url,e.newWindow),a=!0):e.action?(this._bindNamedAction(i,e.action),a=!0):e.attachment?(m(this,pe,pu).call(this,i,e.attachment,e.attachmentDest),a=!0):e.setOCGState?(m(this,pe,gu).call(this,i,e.setOCGState),a=!0):e.dest?(this._bindLink(i,e.dest),a=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,e),a=!0),e.resetForm?(this._bindResetFormAction(i,e.resetForm),a=!0):this.isTooltipOnly&&!a&&(this._bindLink(i,""),a=!0)),this.container.classList.add("linkAnnotation"),a&&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,pe,Ci).call(this)}_bindNamedAction(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),m(this,pe,Ci).call(this)}_bindJSAction(e,s){e.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const a of Object.keys(s.actions)){const r=i.get(a);r&&(e[r]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:a}}),!1})}e.onclick||(e.onclick=()=>!1),m(this,pe,Ci).call(this)}_bindResetFormAction(e,s){const i=e.onclick;i||(e.href=this.linkService.getAnchorUrl("")),m(this,pe,Ci).call(this),this._fieldObjects?e.onclick=()=>{var d;i==null||i();const{fields:a,refs:r,include:o}=s,h=[];if(a.length!==0||r.length!==0){const f=new Set(r);for(const g of a){const A=this._fieldObjects[g]||[];for(const{id:v}of A)f.add(v)}for(const g of Object.values(this._fieldObjects))for(const A of g)f.has(A.id)===o&&h.push(A)}else for(const f of Object.values(this._fieldObjects))h.push(...f);const l=this.annotationStorage,c=[];for(const f of h){const{id:g}=f;switch(c.push(g),f.type){case"text":{const v=f.defaultValue||"";l.setValue(g,{value:v});break}case"checkbox":case"radiobutton":{const v=f.defaultValue===f.exportValues;l.setValue(g,{value:v});break}case"combobox":case"listbox":{const v=f.defaultValue||"";l.setValue(g,{value:v});break}default:continue}const A=document.querySelector(`[data-element-id="${g}"]`);A&&(In.has(A)?A.dispatchEvent(new Event("resetform")):q(`_bindResetFormAction - element not allowed: ${g}`))}return this.enableScripting&&((d=this.linkService.eventBus)==null||d.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:c,name:"ResetForm"}})),!1}:(q('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(e.onclick=()=>!1))}}pe=new WeakSet,Ci=function(){this.container.setAttribute("data-internal-link","")},pu=function(e,s,i=null){e.href=this.linkService.getAnchorUrl(""),s.description&&(e.title=s.description),e.onclick=()=>{var a;return(a=this.downloadManager)==null||a.openOrDownloadData(s.content,s.filename,i),!1},m(this,pe,Ci).call(this)},gu=function(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),m(this,pe,Ci).call(this)};class ug extends mt{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 On extends mt{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 Wt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,a){s.includes("mouse")?t.addEventListener(s,r=>{var o;(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:a(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})}):t.addEventListener(s,r=>{var o;if(s==="blur"){if(!e.focused||!r.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}a&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:a(r)}}))})}_setEventListeners(t,e,s,i){var a,r,o;for(const[h,l]of s)(l==="Action"||(a=this.data.actions)!=null&&a[l])&&(l!=="Focus"&&l!=="Blur"||e||(e={focused:!1}),this._setEventListener(t,e,h,l,i),l!=="Focus"||(r=this.data.actions)!=null&&r.Blur?l!=="Blur"||(o=this.data.actions)!=null&&o.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":I.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||9,a=t.style;let r;const o=h=>Math.round(10*h)/10;if(this.data.multiLine){const h=Math.abs(this.data.rect[3]-this.data.rect[1]-2),l=h/(Math.round(h/(Qh*i))||1);r=Math.min(i,o(l/Qh))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(i,o(h/Qh))}a.fontSize=`calc(${r}px * var(--scale-factor))`,a.color=I.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(a.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class fg extends On{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,s,i){const a=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=s),a.setValue(r.id,{[i]:s})}render(){var i,a;const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const r=t.getValue(e,{value:this.data.fieldValue});let o=r.value||"";const h=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;h&&o.length>h&&(o=o.slice(0,h));let l=r.formattedValue||((i=this.data.textContent)==null?void 0:i.join(`
  3. `))||null;l&&this.data.comb&&(l=l.replaceAll(/\s+/g,""));const c={userValue:o,formattedValue:l,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=l??o,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",l??o),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),In.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=Do,this._setRequired(s,this.data.required),h&&(s.maxLength=h),s.addEventListener("input",f=>{t.setValue(e,{value:f.target.value}),this.setPropertyOnSiblings(s,"value",f.target.value,"value"),c.formattedValue=null}),s.addEventListener("resetform",f=>{const g=this.data.defaultFieldValue??"";s.value=c.userValue=g,c.formattedValue=null});let d=f=>{const{formattedValue:g}=c;g!=null&&(f.target.value=g),f.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",g=>{var v;if(c.focused)return;const{target:A}=g;c.userValue&&(A.value=c.userValue),c.lastCommittedValue=A.value,c.commitKey=1,(v=this.data.actions)!=null&&v.Focus||(c.focused=!0)}),s.addEventListener("updatefromsandbox",g=>{this.showElementAndHideCanvas(g.target);const A={value(v){c.userValue=v.detail.value??"",t.setValue(e,{value:c.userValue.toString()}),v.target.value=c.userValue},formattedValue(v){const{formattedValue:w}=v.detail;c.formattedValue=w,w!=null&&v.target!==document.activeElement&&(v.target.value=w),t.setValue(e,{formattedValue:w})},selRange(v){v.target.setSelectionRange(...v.detail.selRange)},charLimit:v=>{var _;const{charLimit:w}=v.detail,{target:y}=v;if(w===0){y.removeAttribute("maxLength");return}y.setAttribute("maxLength",w);let x=c.userValue;x&&!(x.length<=w)&&(x=x.slice(0,w),y.value=c.userValue=x,t.setValue(e,{value:x}),(_=this.linkService.eventBus)==null||_.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:x,willCommit:!0,commitKey:1,selStart:y.selectionStart,selEnd:y.selectionEnd}}))}};this._dispatchEventFromSandbox(A,g)}),s.addEventListener("keydown",g=>{var w;c.commitKey=1;let A=-1;if(g.key==="Escape"?A=0:g.key!=="Enter"||this.data.multiLine?g.key==="Tab"&&(c.commitKey=3):A=2,A===-1)return;const{value:v}=g.target;c.lastCommittedValue!==v&&(c.lastCommittedValue=v,c.userValue=v,(w=this.linkService.eventBus)==null||w.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,willCommit:!0,commitKey:A,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}}))});const f=d;d=null,s.addEventListener("blur",g=>{var v,w;if(!c.focused||!g.relatedTarget)return;(v=this.data.actions)!=null&&v.Blur||(c.focused=!1);const{value:A}=g.target;c.userValue=A,c.lastCommittedValue!==A&&((w=this.linkService.eventBus)==null||w.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:A,willCommit:!0,commitKey:c.commitKey,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}})),f(g)}),(a=this.data.actions)!=null&&a.Keystroke&&s.addEventListener("beforeinput",g=>{var E;c.lastCommittedValue=null;const{data:A,target:v}=g,{value:w,selectionStart:y,selectionEnd:x}=v;let _=y,S=x;switch(g.inputType){case"deleteWordBackward":{const M=w.substring(0,y).match(/\w*[^\w]*$/);M&&(_-=M[0].length);break}case"deleteWordForward":{const M=w.substring(y).match(/^[^\w]*\w*/);M&&(S+=M[0].length);break}case"deleteContentBackward":y===x&&(_-=1);break;case"deleteContentForward":y===x&&(S+=1)}g.preventDefault(),(E=this.linkService.eventBus)==null||E.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:w,change:A||"",willCommit:!1,selStart:_,selEnd:S}})}),this._setEventListeners(s,c,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],g=>g.target.value)}if(d&&s.addEventListener("blur",d),this.data.comb){const f=(this.data.rect[2]-this.data.rect[0])/h;s.classList.add("comb"),s.style.letterSpacing=`calc(${f}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 pg extends On{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class gg extends On{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 a=document.createElement("input");return In.add(a),a.setAttribute("data-element-id",s),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="checkbox",a.name=e.fieldName,i&&a.setAttribute("checked",!0),a.setAttribute("exportValue",e.exportValue),a.tabIndex=Do,a.addEventListener("change",r=>{const{name:o,checked:h}=r.target;for(const l of this._getElementsByName(o,s)){const c=h&&l.exportValue===e.exportValue;l.domElement&&(l.domElement.checked=c),t.setValue(l.id,{value:c})}t.setValue(s,{value:h})}),a.addEventListener("resetform",r=>{const o=e.defaultFieldValue||"Off";r.target.checked=o===e.exportValue}),this.enableScripting&&this.hasJSActions&&(a.addEventListener("updatefromsandbox",r=>{const o={value(h){h.target.checked=h.detail.value!=="Off",t.setValue(s,{value:h.target.checked})}};this._dispatchEventFromSandbox(o,r)}),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],r=>r.target.checked)),this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class mu extends On{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.fieldValue===e.buttonValue}).value;if(typeof i=="string"&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(const r of this._getElementsByName(e.fieldName,s))t.setValue(r.id,{value:!1});const a=document.createElement("input");if(In.add(a),a.setAttribute("data-element-id",s),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="radio",a.name=e.fieldName,i&&a.setAttribute("checked",!0),a.tabIndex=Do,a.addEventListener("change",r=>{const{name:o,checked:h}=r.target;for(const l of this._getElementsByName(o,s))t.setValue(l.id,{value:!1});t.setValue(s,{value:h})}),a.addEventListener("resetform",r=>{const o=e.defaultFieldValue;r.target.checked=o!=null&&o===e.buttonValue}),this.enableScripting&&this.hasJSActions){const r=e.buttonValue;a.addEventListener("updatefromsandbox",o=>{const h={value:l=>{const c=r===l.detail.value;for(const d of this._getElementsByName(l.target.name)){const f=c&&d.id===s;d.domElement&&(d.domElement.checked=f),t.setValue(d.id,{value:f})}}};this._dispatchEventFromSandbox(h,o)}),this._setEventListeners(a,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(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class mg extends fu{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 bg extends On{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");In.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=Do;let a=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",c=>{const d=this.data.defaultFieldValue;for(const f of i.options)f.selected=f.value===d});for(const c of this.data.options){const d=document.createElement("option");d.textContent=c.displayValue,d.value=c.exportValue,s.value.includes(c.exportValue)&&(d.setAttribute("selected",!0),a=!1),i.append(d)}let r=null;if(a){const c=document.createElement("option");c.value=" ",c.setAttribute("hidden",!0),c.setAttribute("selected",!0),i.prepend(c),r=()=>{c.remove(),i.removeEventListener("input",r),r=null},i.addEventListener("input",r)}const o=c=>{const d=c?"value":"textContent",{options:f,multiple:g}=i;return g?Array.prototype.filter.call(f,A=>A.selected).map(A=>A[d]):f.selectedIndex===-1?null:f[f.selectedIndex][d]};let h=o(!1);const l=c=>{const d=c.target.options;return Array.prototype.map.call(d,f=>({displayValue:f.textContent,exportValue:f.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",c=>{const d={value(f){r==null||r();const g=f.detail.value,A=new Set(Array.isArray(g)?g:[g]);for(const v of i.options)v.selected=A.has(v.value);t.setValue(e,{value:o(!0)}),h=o(!1)},multipleSelection(f){i.multiple=!0},remove(f){const g=i.options,A=f.detail.remove;g[A].selected=!1,i.remove(A),g.length>0&&Array.prototype.findIndex.call(g,v=>v.selected)===-1&&(g[0].selected=!0),t.setValue(e,{value:o(!0),items:l(f)}),h=o(!1)},clear(f){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),h=o(!1)},insert(f){const{index:g,displayValue:A,exportValue:v}=f.detail.insert,w=i.children[g],y=document.createElement("option");y.textContent=A,y.value=v,w?w.before(y):i.append(y),t.setValue(e,{value:o(!0),items:l(f)}),h=o(!1)},items(f){const{items:g}=f.detail;for(;i.length!==0;)i.remove(0);for(const A of g){const{displayValue:v,exportValue:w}=A,y=document.createElement("option");y.textContent=v,y.value=w,i.append(y)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:o(!0),items:l(f)}),h=o(!1)},indices(f){const g=new Set(f.detail.indices);for(const A of f.target.options)A.selected=g.has(A.index);t.setValue(e,{value:o(!0)}),h=o(!1)},editable(f){f.target.disabled=!f.detail.editable}};this._dispatchEventFromSandbox(d,c)}),i.addEventListener("input",c=>{var g;const d=o(!0),f=o(!1);t.setValue(e,{value:d}),c.preventDefault(),(g=this.linkService.eventBus)==null||g.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:h,change:f,changeEx:d,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],c=>c.target.value)):i.addEventListener("input",function(c){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 Gl extends mt{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:mt._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Ag({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=>`${Ec}${s}`).join(",")),this.container}}var Sa,Bh,Hh,Ea,cn,pt,_s,Ca,eo,so,Ma,xs,De,Ss,io,Es,no,dn,un,at,sh,Ul,bu,Au,vu,yu,ih,nh,ql;class Ag{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:a,contentsObj:r,richText:o,parent:h,rect:l,parentRect:c,open:d}){b(this,at);b(this,Sa,m(this,at,vu).bind(this));b(this,Bh,m(this,at,ql).bind(this));b(this,Hh,m(this,at,nh).bind(this));b(this,Ea,m(this,at,ih).bind(this));b(this,cn,null);b(this,pt,null);b(this,_s,null);b(this,Ca,null);b(this,eo,null);b(this,so,null);b(this,Ma,null);b(this,xs,!1);b(this,De,null);b(this,Ss,null);b(this,io,null);b(this,Es,null);b(this,no,null);b(this,dn,null);b(this,un,!1);var f;p(this,pt,t),p(this,no,i),p(this,_s,r),p(this,Es,o),p(this,so,h),p(this,cn,e),p(this,io,l),p(this,Ma,c),p(this,eo,s),p(this,Ca,kc.toDateObject(a)),this.trigger=s.flatMap(g=>g.getElementsToTriggerPopup());for(const g of this.trigger)g.addEventListener("click",n(this,Ea)),g.addEventListener("mouseenter",n(this,Hh)),g.addEventListener("mouseleave",n(this,Bh)),g.classList.add("popupTriggerArea");for(const g of s)(f=g.container)==null||f.addEventListener("keydown",n(this,Sa));n(this,pt).hidden=!0,d&&m(this,at,ih).call(this)}render(){if(n(this,De))return;const t=p(this,De,document.createElement("div"));if(t.className="popup",n(this,cn)){const a=t.style.outlineColor=I.makeHexColor(...n(this,cn));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${a} 30%, white)`:t.style.backgroundColor=I.makeHexColor(...n(this,cn).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}=n(this,no),t.append(e),n(this,Ca)){const a=document.createElement("span");a.classList.add("popupDate"),a.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),a.setAttribute("data-l10n-args",JSON.stringify({dateObj:n(this,Ca).valueOf()})),e.append(a)}const i=n(this,at,sh);if(i)uu.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const a=this._formatContents(n(this,_s));t.append(a)}n(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 a=0,r=i.length;a<r;++a){const o=i[a];s.append(document.createTextNode(o)),a<r-1&&s.append(document.createElement("br"))}return s}updateEdited({rect:t,popupContent:e}){var s;n(this,dn)||p(this,dn,{contentsObj:n(this,_s),richText:n(this,Es)}),t&&p(this,Ss,null),e&&(p(this,Es,m(this,at,Au).call(this,e)),p(this,_s,null)),(s=n(this,De))==null||s.remove(),p(this,De,null)}resetEdited(){var t;n(this,dn)&&({contentsObj:Gt(this,_s)._,richText:Gt(this,Es)._}=n(this,dn),p(this,dn,null),(t=n(this,De))==null||t.remove(),p(this,De,null),p(this,Ss,null))}forceHide(){p(this,un,this.isVisible),n(this,un)&&(n(this,pt).hidden=!0)}maybeShow(){n(this,un)&&(n(this,De)||m(this,at,nh).call(this),p(this,un,!1),n(this,pt).hidden=!1)}get isVisible(){return n(this,pt).hidden===!1}}Sa=new WeakMap,Bh=new WeakMap,Hh=new WeakMap,Ea=new WeakMap,cn=new WeakMap,pt=new WeakMap,_s=new WeakMap,Ca=new WeakMap,eo=new WeakMap,so=new WeakMap,Ma=new WeakMap,xs=new WeakMap,De=new WeakMap,Ss=new WeakMap,io=new WeakMap,Es=new WeakMap,no=new WeakMap,dn=new WeakMap,un=new WeakMap,at=new WeakSet,sh=function(){const t=n(this,Es),e=n(this,_s);return!(t!=null&&t.str)||e!=null&&e.str&&e.str!==t.str?null:n(this,Es).html||null},Ul=function(){var t,e,s;return((s=(e=(t=n(this,at,sh))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.fontSize)||0},bu=function(){var t,e,s;return((s=(e=(t=n(this,at,sh))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.color)||null},Au=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:n(this,at,bu),fontSize:n(this,at,Ul)?`calc(${n(this,at,Ul)}px * var(--scale-factor))`:""}};for(const a of t.split(`
  4. `))e.push({name:"span",value:a,attributes:i});return s},vu=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&n(this,xs))&&m(this,at,ih).call(this)},yu=function(){if(n(this,Ss)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:a}}}=n(this,so);let r=!!n(this,Ma),o=r?n(this,Ma):n(this,io);for(const g of n(this,eo))if(!o||I.intersect(g.data.rect,o)!==null){o=g.data.rect,r=!0;break}const h=I.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]),l=r?o[2]-o[0]+5:0,c=h[0]+l,d=h[1];p(this,Ss,[100*(c-i)/e,100*(d-a)/s]);const{style:f}=n(this,pt);f.left=`${n(this,Ss)[0]}%`,f.top=`${n(this,Ss)[1]}%`},ih=function(){p(this,xs,!n(this,xs)),n(this,xs)?(m(this,at,nh).call(this),n(this,pt).addEventListener("click",n(this,Ea)),n(this,pt).addEventListener("keydown",n(this,Sa))):(m(this,at,ql).call(this),n(this,pt).removeEventListener("click",n(this,Ea)),n(this,pt).removeEventListener("keydown",n(this,Sa)))},nh=function(){n(this,De)||this.render(),this.isVisible?n(this,xs)&&n(this,pt).classList.add("focused"):(m(this,at,yu).call(this),n(this,pt).hidden=!1,n(this,pt).style.zIndex=parseInt(n(this,pt).style.zIndex)+1e3)},ql=function(){n(this,pt).classList.remove("focused"),!n(this,xs)&&this.isVisible&&(n(this,pt).hidden=!0,n(this,pt).style.zIndex=parseInt(n(this,pt).style.zIndex)-1e3)};class wu extends mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=V.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var ao;class vg extends mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});b(this,ao,null)}render(){this.container.classList.add("lineAnnotation");const e=this.data,{width:s,height:i}=Os(e.rect),a=this.svgFactory.create(s,i,!0),r=p(this,ao,this.svgFactory.createElement("svg:line"));return r.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),r.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),r.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),r.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),r.setAttribute("stroke-width",e.borderStyle.width||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),a.append(r),this.container.append(a),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,ao)}addHighlightArea(){this.container.classList.add("highlightArea")}}ao=new WeakMap;var ro;class yg extends mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});b(this,ro,null)}render(){this.container.classList.add("squareAnnotation");const e=this.data,{width:s,height:i}=Os(e.rect),a=this.svgFactory.create(s,i,!0),r=e.borderStyle.width,o=p(this,ro,this.svgFactory.createElement("svg:rect"));return o.setAttribute("x",r/2),o.setAttribute("y",r/2),o.setAttribute("width",s-r),o.setAttribute("height",i-r),o.setAttribute("stroke-width",r||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),a.append(o),this.container.append(a),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,ro)}addHighlightArea(){this.container.classList.add("highlightArea")}}ro=new WeakMap;var oo;class wg extends mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});b(this,oo,null)}render(){this.container.classList.add("circleAnnotation");const e=this.data,{width:s,height:i}=Os(e.rect),a=this.svgFactory.create(s,i,!0),r=e.borderStyle.width,o=p(this,oo,this.svgFactory.createElement("svg:ellipse"));return o.setAttribute("cx",s/2),o.setAttribute("cy",i/2),o.setAttribute("rx",s/2-r/2),o.setAttribute("ry",i/2-r/2),o.setAttribute("stroke-width",r||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),a.append(o),this.container.append(a),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,oo)}addHighlightArea(){this.container.classList.add("highlightArea")}}oo=new WeakMap;var ho;class _u extends mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});b(this,ho,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:s,borderStyle:i,popupRef:a}}=this;if(!s)return this.container;const{width:r,height:o}=Os(e),h=this.svgFactory.create(r,o,!0);let l=[];for(let d=0,f=s.length;d<f;d+=2){const g=s[d]-e[0],A=e[3]-s[d+1];l.push(`${g},${A}`)}l=l.join(" ");const c=p(this,ho,this.svgFactory.createElement(this.svgElementName));return c.setAttribute("points",l),c.setAttribute("stroke-width",i.width||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),h.append(c),this.container.append(h),!a&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,ho)}addHighlightArea(){this.container.classList.add("highlightArea")}}ho=new WeakMap;class _g extends _u{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class xg extends mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}var lo;class Nc extends mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});b(this,lo,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?V.HIGHLIGHT:V.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,inkLists:s,borderStyle:i,popupRef:a}}=this,{width:r,height:o}=Os(e),h=this.svgFactory.create(r,o,!0);for(const l of s){let c=[];for(let f=0,g=l.length;f<g;f+=2){const A=l[f]-e[0],v=e[3]-l[f+1];c.push(`${A},${v}`)}c=c.join(" ");const d=this.svgFactory.createElement(this.svgElementName);n(this,lo).push(d),d.setAttribute("points",c),d.setAttribute("stroke-width",i.width||1),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),h.append(d)}return!a&&this.hasPopupData&&this._createPopup(),this.container.append(h),this._editOnDoubleClick(),this.container}getElementsToTriggerPopup(){return n(this,lo)}addHighlightArea(){this.container.classList.add("highlightArea")}}lo=new WeakMap;class xu extends mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=V.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Sg extends mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class Eg extends mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class Cg extends mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class Su extends mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=V.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var co,uo,Wl;class Mg extends mt{constructor(e){var i;super(e,{isRenderable:!0});b(this,uo);b(this,co,null);const{file:s}=this.data;this.filename=s.filename,this.content=s.content,(i=this.linkService.eventBus)==null||i.dispatch("fileattachmentannotation",{source:this,...s})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:s}=this;let i;s.hasAppearance||s.fillAlpha===0?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(s.name)?"paperclip":"pushpin"}.svg`,s.fillAlpha&&s.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*s.fillAlpha)}%);`)),i.addEventListener("dblclick",m(this,uo,Wl).bind(this)),p(this,co,i);const{isMac:a}=Wt.platform;return e.addEventListener("keydown",r=>{r.key==="Enter"&&(a?r.metaKey:r.ctrlKey)&&m(this,uo,Wl).call(this)}),!s.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return n(this,co)}addHighlightArea(){this.container.classList.add("highlightArea")}}co=new WeakMap,uo=new WeakSet,Wl=function(){var e;(e=this.downloadManager)==null||e.openOrDownloadData(this.content,this.filename)};var fo,fn,pn,po,Ln,Eu,Xl;class kg{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:a,viewport:r,structTreeLayer:o}){b(this,Ln);b(this,fo,null);b(this,fn,null);b(this,pn,new Map);b(this,po,null);this.div=t,p(this,fo,e),p(this,fn,s),p(this,po,o||null),this.page=a,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return n(this,pn).size>0}async render(t){var r;const{annotations:e}=t,s=this.div;Rn(s,this.viewport);const i=new Map,a={data:null,layer:s,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Dc,annotationStorage:t.annotationStorage||new Tc,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const o of e){if(o.noHTML)continue;const h=o.annotationType===gd;if(h){const d=i.get(o.id);if(!d)continue;a.elements=d}else{const{width:d,height:f}=Os(o.rect);if(d<=0||f<=0)continue}a.data=o;const l=dg.create(a);if(!l.isRenderable)continue;if(!h&&o.popupRef){const d=i.get(o.popupRef);d?d.push(l):i.set(o.popupRef,[l])}const c=l.render();o.hidden&&(c.style.visibility="hidden"),await m(this,Ln,Eu).call(this,c,o.id),l._isEditable&&(n(this,pn).set(l.data.id,l),(r=this._annotationEditorUIManager)==null||r.renderAnnotationElement(l))}m(this,Ln,Xl).call(this)}update({viewport:t}){const e=this.div;this.viewport=t,Rn(e,{rotation:t.rotation}),m(this,Ln,Xl).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(n(this,pn).values())}getEditableAnnotation(t){return n(this,pn).get(t)}}fo=new WeakMap,fn=new WeakMap,pn=new WeakMap,po=new WeakMap,Ln=new WeakSet,Eu=async function(t,e){var r,o;const s=t.firstChild||t,i=s.id=`${Ec}${e}`,a=await((r=n(this,po))==null?void 0:r.getAriaAttributes(i));if(a)for(const[h,l]of a)s.setAttribute(h,l);this.div.append(t),(o=n(this,fo))==null||o.moveElementInDOM(this.div,t,s,!1)},Xl=function(){if(!n(this,fn))return;const t=this.div;for(const[e,s]of n(this,fn)){const i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;s.className="annotationContent";const{firstChild:a}=i;a?a.nodeName==="CANVAS"?a.replaceWith(s):a.classList.contains("annotationContent")?a.after(s):a.before(s):i.append(s)}n(this,fn).clear()};const jo=/\r\n?|\n/g;var Ne,he,go,gn,le,vt,Cu,Mu,ku,ah,Hs,rh,oh,Tu,Yl,Ru;const rt=class rt extends it{constructor(e){super({...e,name:"freeTextEditor"});b(this,vt);b(this,Ne);b(this,he,"");b(this,go,`${this.id}-editor`);b(this,gn,null);b(this,le);p(this,Ne,e.color||rt._defaultColor||it._defaultLineColor),p(this,le,e.fontSize||rt._defaultFontSize)}static get _keyboardManager(){const e=rt.prototype,s=r=>r.isEmpty(),i=Pn.TRANSLATE_SMALL,a=Pn.TRANSLATE_BIG;return K(this,"_keyboardManager",new Fo([[["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:[-a,0],checker:s}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[i,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[a,0],checker:s}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-a],checker:s}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,i],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,a],checker:s}]]))}static initialize(e,s){it.initialize(e,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,s){switch(e){case O.FREETEXT_SIZE:rt._defaultFontSize=s;break;case O.FREETEXT_COLOR:rt._defaultColor=s}}updateParams(e,s){switch(e){case O.FREETEXT_SIZE:m(this,vt,Cu).call(this,s);break;case O.FREETEXT_COLOR:m(this,vt,Mu).call(this,s)}}static get defaultPropertiesToUpdate(){return[[O.FREETEXT_SIZE,rt._defaultFontSize],[O.FREETEXT_COLOR,rt._defaultColor||it._defaultLineColor]]}get propertiesToUpdate(){return[[O.FREETEXT_SIZE,n(this,le)],[O.FREETEXT_COLOR,n(this,Ne)]]}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-rt._internalPadding*e,-(rt._internalPadding+n(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(V.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),p(this,gn,new AbortController);const e=this._uiManager.combinedSignal(n(this,gn));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",n(this,go)),this._isDraggable=!0,(e=n(this,gn))==null||e.abort(),p(this,gn,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=n(this,he),s=p(this,he,m(this,vt,ku).call(this).trimEnd());if(e===s)return;const i=a=>{p(this,he,a),a?(m(this,vt,oh).call(this),this._uiManager.rebuild(this),m(this,vt,ah).call(this)):this.remove()};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),m(this,vt,ah).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){rt._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",n(this,go)),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(${n(this,le)}px * var(--scale-factor))`,i.color=n(this,Ne),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),yh(this,this.div,["dblclick","keydown"]),this.width){const[a,r]=this.parentDimensions;if(this.annotationElementId){const{position:o}=this._initialData;let[h,l]=this.getInitialTranslation();[h,l]=this.pageTranslationToScreen(h,l);const[c,d]=this.pageDimensions,[f,g]=this.pageTranslation;let A,v;switch(this.rotation){case 0:A=e+(o[0]-f)/c,v=s+this.height-(o[1]-g)/d;break;case 90:A=e+(o[0]-f)/c,v=s-(o[1]-g)/d,[h,l]=[l,-h];break;case 180:A=e-this.width+(o[0]-f)/c,v=s-(o[1]-g)/d,[h,l]=[-h,-l];break;case 270:A=e+(o[0]-f-this.height*d)/c,v=s+(o[1]-g-this.width*c)/d,[h,l]=[-l,h]}this.setAt(A*a,v*r,h,l)}else this.setAt(e*a,s*r,this.width*a,this.height*r);m(this,vt,oh).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var A,v,w;const s=e.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();const a=m(A=rt,Hs,Yl).call(A,s.getData("text")||"").replaceAll(jo,`
  5. `);if(!a)return;const r=window.getSelection();if(!r.rangeCount)return;this.editorDiv.normalize(),r.deleteFromDocument();const o=r.getRangeAt(0);if(!a.includes(`
  6. `)){o.insertNode(document.createTextNode(a)),this.editorDiv.normalize(),r.collapseToStart();return}const{startContainer:h,startOffset:l}=o,c=[],d=[];if(h.nodeType===Node.TEXT_NODE){const y=h.parentElement;if(d.push(h.nodeValue.slice(l).replaceAll(jo,"")),y!==this.editorDiv){let x=c;for(const _ of this.editorDiv.childNodes)_!==y?x.push(m(v=rt,Hs,rh).call(v,_)):x=d}c.push(h.nodeValue.slice(0,l).replaceAll(jo,""))}else if(h===this.editorDiv){let y=c,x=0;for(const _ of this.editorDiv.childNodes)x++===l&&(y=d),y.push(m(w=rt,Hs,rh).call(w,_))}p(this,he,`${c.join(`
  7. `)}${a}${d.join(`
  8. `)}`),m(this,vt,oh).call(this);const f=new Range;let g=c.reduce((y,x)=>y+x.length,0);for(const{firstChild:y}of this.editorDiv.childNodes)if(y.nodeType===Node.TEXT_NODE){const x=y.nodeValue.length;if(g<=x){f.setStart(y,g),f.setEnd(y,g);break}g-=x}r.removeAllRanges(),r.addRange(f)}get contentDiv(){return this.editorDiv}static async deserialize(e,s,i){var o;let a=null;if(e instanceof wu){const{data:{defaultAppearanceData:{fontSize:h,fontColor:l},rect:c,rotation:d,id:f,popupRef:g},textContent:A,textPosition:v,parent:{page:{pageNumber:w}}}=e;if(!A||A.length===0)return null;a=e={annotationType:V.FREETEXT,color:Array.from(l),fontSize:h,value:A.join(`
  9. `),position:v,pageIndex:w-1,rect:c.slice(0),rotation:d,id:f,deleted:!1,popupRef:g}}const r=await super.deserialize(e,s,i);return p(r,le,e.fontSize),p(r,Ne,I.makeHexColor(...e.color)),p(r,he,m(o=rt,Hs,Yl).call(o,e.value)),r.annotationElementId=e.id||null,r._initialData=a,r}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=rt._internalPadding*this.parentScale,i=this.getRect(s,s),a=it._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:n(this,Ne)),r={annotationType:V.FREETEXT,color:a,fontSize:n(this,le),value:m(this,vt,Tu).call(this),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?r:this.annotationElementId&&!m(this,vt,Ru).call(this,r)?null:(r.id=this.annotationElementId,r)}renderAnnotationElement(e){const s=super.renderAnnotationElement(e);if(this.deleted)return s;const{style:i}=s;i.fontSize=`calc(${n(this,le)}px * var(--scale-factor))`,i.color=n(this,Ne),s.replaceChildren();for(const r of n(this,he).split(`
  10. `)){const o=document.createElement("div");o.append(r?document.createTextNode(r):document.createElement("br")),s.append(o)}const a=rt._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(a,a),popupContent:n(this,he)}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};Ne=new WeakMap,he=new WeakMap,go=new WeakMap,gn=new WeakMap,le=new WeakMap,vt=new WeakSet,Cu=function(e){const s=a=>{this.editorDiv.style.fontSize=`calc(${a}px * var(--scale-factor))`,this.translate(0,-(a-n(this,le))*this.parentScale),p(this,le,a),m(this,vt,ah).call(this)},i=n(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:O.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},Mu=function(e){const s=a=>{p(this,Ne,this.editorDiv.style.color=a)},i=n(this,Ne);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:O.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},ku=function(){var i;const e=[];this.editorDiv.normalize();let s=null;for(const a of this.editorDiv.childNodes)((s==null?void 0:s.nodeType)!==Node.TEXT_NODE||a.nodeName!=="BR")&&(e.push(m(i=rt,Hs,rh).call(i,a)),s=a);return e.join(`
  11. `)},ah=function(){const[e,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:a,div:r}=this,o=r.style.display,h=r.classList.contains("hidden");r.classList.remove("hidden"),r.style.display="hidden",a.div.append(this.div),i=r.getBoundingClientRect(),r.remove(),r.style.display=o,r.classList.toggle("hidden",h)}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()},Hs=new WeakSet,rh=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(jo,"")},oh=function(){if(this.editorDiv.replaceChildren(),n(this,he))for(const e of n(this,he).split(`
  12. `)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},Tu=function(){return n(this,he).replaceAll(" "," ")},Yl=function(e){return e.replaceAll(" "," ")},Ru=function(e){const{value:s,fontSize:i,color:a,pageIndex:r}=this._initialData;return this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((o,h)=>o!==a[h])||e.pageIndex!==r},b(rt,Hs),N(rt,"_freeTextDefaultContent",""),N(rt,"_internalPadding",0),N(rt,"_defaultColor",null),N(rt,"_defaultFontSize",10),N(rt,"_type","freetext"),N(rt,"_editorType",V.FREETEXT);let Kl=rt;class Pu{toSVGPath(){ot("Abstract method `toSVGPath` must be implemented.")}get box(){ot("Abstract getter `box` must be implemented.")}serialize(t,e){ot("Abstract method `serialize` must be implemented.")}get classNamesForDrawing(){ot("Abstract getter `classNamesForDrawing` must be implemented.")}get classNamesForOutlining(){ot("Abstract getter `classNamesForOutlining` must be implemented.")}get mustRemoveSelfIntersections(){return!1}}var ce,Oe,ka,Ta,es,W,mn,bn,mo,bo,Ra,Pa,di,Ao,zh,jh,Et,ar,Iu,Lu,Fu,Du,Nu,Ou;const ds=class ds{constructor({x:t,y:e},s,i,a,r,o=0){b(this,Et);b(this,ce);b(this,Oe,[]);b(this,ka);b(this,Ta);b(this,es,[]);b(this,W,new Float64Array(18));b(this,mn);b(this,bn);b(this,mo);b(this,bo);b(this,Ra);b(this,Pa);b(this,di,[]);p(this,ce,s),p(this,Pa,a*i),p(this,Ta,r),n(this,W).set([NaN,NaN,NaN,NaN,t,e],6),p(this,ka,o),p(this,bo,n(ds,Ao)*i),p(this,mo,n(ds,jh)*i),p(this,Ra,i),n(this,di).push(t,e)}isEmpty(){return isNaN(n(this,W)[8])}add({x:t,y:e}){var C;p(this,mn,t),p(this,bn,e);const[s,i,a,r]=n(this,ce);let[o,h,l,c]=n(this,W).subarray(8,12);const d=t-l,f=e-c,g=Math.hypot(d,f);if(g<n(this,mo))return!1;const A=g-n(this,bo),v=A/g,w=v*d,y=v*f;let x=o,_=h;o=l,h=c,l+=w,c+=y,(C=n(this,di))==null||C.push(t,e);const S=w/A,E=-y/A*n(this,Pa),M=S*n(this,Pa);return n(this,W).set(n(this,W).subarray(2,8),0),n(this,W).set([l+E,c+M],4),n(this,W).set(n(this,W).subarray(14,18),12),n(this,W).set([l-E,c-M],16),isNaN(n(this,W)[6])?(n(this,es).length===0&&(n(this,W).set([o+E,h+M],2),n(this,es).push(NaN,NaN,NaN,NaN,(o+E-s)/a,(h+M-i)/r),n(this,W).set([o-E,h-M],14),n(this,Oe).push(NaN,NaN,NaN,NaN,(o-E-s)/a,(h-M-i)/r)),n(this,W).set([x,_,o,h,l,c],6),!this.isEmpty()):(n(this,W).set([x,_,o,h,l,c],6),Math.abs(Math.atan2(_-h,x-o)-Math.atan2(y,w))<Math.PI/2?([o,h,l,c]=n(this,W).subarray(2,6),n(this,es).push(NaN,NaN,NaN,NaN,((o+l)/2-s)/a,((h+c)/2-i)/r),[o,h,x,_]=n(this,W).subarray(14,18),n(this,Oe).push(NaN,NaN,NaN,NaN,((x+o)/2-s)/a,((_+h)/2-i)/r),!0):([x,_,o,h,l,c]=n(this,W).subarray(0,6),n(this,es).push(((x+5*o)/6-s)/a,((_+5*h)/6-i)/r,((5*o+l)/6-s)/a,((5*h+c)/6-i)/r,((o+l)/2-s)/a,((h+c)/2-i)/r),[l,c,o,h,x,_]=n(this,W).subarray(12,18),n(this,Oe).push(((x+5*o)/6-s)/a,((_+5*h)/6-i)/r,((5*o+l)/6-s)/a,((5*h+c)/6-i)/r,((o+l)/2-s)/a,((h+c)/2-i)/r),!0))}toSVGPath(){if(this.isEmpty())return"";const t=n(this,es),e=n(this,Oe);if(isNaN(n(this,W)[6])&&!this.isEmpty())return m(this,Et,Iu).call(this);const s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);m(this,Et,Fu).call(this,s);for(let i=e.length-6;i>=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,Et,Lu).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,a,r){return new Bu(t,e,s,i,a,r)}getOutlines(){var d;const t=n(this,es),e=n(this,Oe),s=n(this,W),[i,a,r,o]=n(this,ce),h=new Float64Array((((d=n(this,di))==null?void 0:d.length)??0)+2);for(let f=0,g=h.length-2;f<g;f+=2)h[f]=(n(this,di)[f]-i)/r,h[f+1]=(n(this,di)[f+1]-a)/o;if(h[h.length-2]=(n(this,mn)-i)/r,h[h.length-1]=(n(this,bn)-a)/o,isNaN(s[6])&&!this.isEmpty())return m(this,Et,Du).call(this,h);const l=new Float64Array(n(this,es).length+24+n(this,Oe).length);let c=t.length;for(let f=0;f<c;f+=2)isNaN(t[f])?l[f]=l[f+1]=NaN:(l[f]=t[f],l[f+1]=t[f+1]);c=m(this,Et,Ou).call(this,l,c);for(let f=e.length-6;f>=6;f-=6)for(let g=0;g<6;g+=2)isNaN(e[f+g])?(l[c]=l[c+1]=NaN,c+=2):(l[c]=e[f+g],l[c+1]=e[f+g+1],c+=2);return m(this,Et,Nu).call(this,l,c),this.newFreeDrawOutline(l,h,n(this,ce),n(this,Ra),n(this,ka),n(this,Ta))}};ce=new WeakMap,Oe=new WeakMap,ka=new WeakMap,Ta=new WeakMap,es=new WeakMap,W=new WeakMap,mn=new WeakMap,bn=new WeakMap,mo=new WeakMap,bo=new WeakMap,Ra=new WeakMap,Pa=new WeakMap,di=new WeakMap,Ao=new WeakMap,zh=new WeakMap,jh=new WeakMap,Et=new WeakSet,ar=function(){const t=n(this,W).subarray(4,6),e=n(this,W).subarray(16,18),[s,i,a,r]=n(this,ce);return[(n(this,mn)+(t[0]-e[0])/2-s)/a,(n(this,bn)+(t[1]-e[1])/2-i)/r,(n(this,mn)+(e[0]-t[0])/2-s)/a,(n(this,bn)+(e[1]-t[1])/2-i)/r]},Iu=function(){const[t,e,s,i]=n(this,ce),[a,r,o,h]=m(this,Et,ar).call(this);return`M${(n(this,W)[2]-t)/s} ${(n(this,W)[3]-e)/i} L${(n(this,W)[4]-t)/s} ${(n(this,W)[5]-e)/i} L${a} ${r} L${o} ${h} L${(n(this,W)[16]-t)/s} ${(n(this,W)[17]-e)/i} L${(n(this,W)[14]-t)/s} ${(n(this,W)[15]-e)/i} Z`},Lu=function(t){const e=n(this,Oe);t.push(`L${e[4]} ${e[5]} Z`)},Fu=function(t){const[e,s,i,a]=n(this,ce),r=n(this,W).subarray(4,6),o=n(this,W).subarray(16,18),[h,l,c,d]=m(this,Et,ar).call(this);t.push(`L${(r[0]-e)/i} ${(r[1]-s)/a} L${h} ${l} L${c} ${d} L${(o[0]-e)/i} ${(o[1]-s)/a}`)},Du=function(t){const e=n(this,W),[s,i,a,r]=n(this,ce),[o,h,l,c]=m(this,Et,ar).call(this),d=new Float64Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-s)/a,(e[3]-i)/r,NaN,NaN,NaN,NaN,(e[4]-s)/a,(e[5]-i)/r,NaN,NaN,NaN,NaN,o,h,NaN,NaN,NaN,NaN,l,c,NaN,NaN,NaN,NaN,(e[16]-s)/a,(e[17]-i)/r,NaN,NaN,NaN,NaN,(e[14]-s)/a,(e[15]-i)/r],0),this.newFreeDrawOutline(d,t,n(this,ce),n(this,Ra),n(this,ka),n(this,Ta))},Nu=function(t,e){const s=n(this,Oe);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+6},Ou=function(t,e){const s=n(this,W).subarray(4,6),i=n(this,W).subarray(16,18),[a,r,o,h]=n(this,ce),[l,c,d,f]=m(this,Et,ar).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-a)/o,(s[1]-r)/h,NaN,NaN,NaN,NaN,l,c,NaN,NaN,NaN,NaN,d,f,NaN,NaN,NaN,NaN,(i[0]-a)/o,(i[1]-r)/h],e),e+24},b(ds,Ao,8),b(ds,zh,2),b(ds,jh,n(ds,Ao)+n(ds,zh));let _h=ds;var Ia,An,Cs,vo,de,yo,gt,se,rr,or,Hu;class Bu extends Pu{constructor(e,s,i,a,r,o){super();b(this,se);b(this,Ia);b(this,An,null);b(this,Cs);b(this,vo);b(this,de);b(this,yo);b(this,gt);p(this,gt,e),p(this,de,s),p(this,Ia,i),p(this,yo,a),p(this,Cs,r),p(this,vo,o),m(this,se,Hu).call(this,o);const{x:h,y:l,width:c,height:d}=n(this,An);for(let f=0,g=e.length;f<g;f+=2)e[f]=(e[f]-h)/c,e[f+1]=(e[f+1]-l)/d;for(let f=0,g=s.length;f<g;f+=2)s[f]=(s[f]-h)/c,s[f+1]=(s[f+1]-l)/d}toSVGPath(){const e=[`M${n(this,gt)[4]} ${n(this,gt)[5]}`];for(let s=6,i=n(this,gt).length;s<i;s+=6)isNaN(n(this,gt)[s])?e.push(`L${n(this,gt)[s+4]} ${n(this,gt)[s+5]}`):e.push(`C${n(this,gt)[s]} ${n(this,gt)[s+1]} ${n(this,gt)[s+2]} ${n(this,gt)[s+3]} ${n(this,gt)[s+4]} ${n(this,gt)[s+5]}`);return e.push("Z"),e.join(" ")}serialize([e,s,i,a],r){const o=i-e,h=a-s;let l,c;switch(r){case 0:l=m(this,se,rr).call(this,n(this,gt),e,a,o,-h),c=m(this,se,rr).call(this,n(this,de),e,a,o,-h);break;case 90:l=m(this,se,or).call(this,n(this,gt),e,s,o,h),c=m(this,se,or).call(this,n(this,de),e,s,o,h);break;case 180:l=m(this,se,rr).call(this,n(this,gt),i,s,-o,h),c=m(this,se,rr).call(this,n(this,de),i,s,-o,h);break;case 270:l=m(this,se,or).call(this,n(this,gt),i,a,-o,-h),c=m(this,se,or).call(this,n(this,de),i,a,-o,-h)}return{outline:Array.from(l),points:[Array.from(c)]}}get box(){return n(this,An)}newOutliner(e,s,i,a,r,o=0){return new _h(e,s,i,a,r,o)}getNewOutline(e,s){const{x:i,y:a,width:r,height:o}=n(this,An),[h,l,c,d]=n(this,Ia),f=r*c,g=o*d,A=i*c+h,v=a*d+l,w=this.newOutliner({x:n(this,de)[0]*f+A,y:n(this,de)[1]*g+v},n(this,Ia),n(this,yo),e,n(this,vo),s??n(this,Cs));for(let y=2;y<n(this,de).length;y+=2)w.add({x:n(this,de)[y]*f+A,y:n(this,de)[y+1]*g+v});return w.getOutlines()}get mustRemoveSelfIntersections(){return!0}}Ia=new WeakMap,An=new WeakMap,Cs=new WeakMap,vo=new WeakMap,de=new WeakMap,yo=new WeakMap,gt=new WeakMap,se=new WeakSet,rr=function(e,s,i,a,r){const o=new Float64Array(e.length);for(let h=0,l=e.length;h<l;h+=2)o[h]=s+e[h]*a,o[h+1]=i+e[h+1]*r;return o},or=function(e,s,i,a,r){const o=new Float64Array(e.length);for(let h=0,l=e.length;h<l;h+=2)o[h]=s+e[h+1]*a,o[h+1]=i+e[h]*r;return o},Hu=function(e){const s=n(this,gt);let i=s[4],a=s[5],r=i,o=a,h=i,l=a,c=i,d=a;const f=e?Math.max:Math.min;for(let y=6,x=s.length;y<x;y+=6){if(isNaN(s[y]))r=Math.min(r,s[y+4]),o=Math.min(o,s[y+5]),h=Math.max(h,s[y+4]),l=Math.max(l,s[y+5]),d<s[y+5]?(c=s[y+4],d=s[y+5]):d===s[y+5]&&(c=f(c,s[y+4]));else{const _=I.bezierBoundingBox(i,a,...s.slice(y,y+6));r=Math.min(r,_[0]),o=Math.min(o,_[1]),h=Math.max(h,_[2]),l=Math.max(l,_[3]),d<_[3]?(c=_[2],d=_[3]):d===_[3]&&(c=f(c,_[2]))}i=s[y+4],a=s[y+5]}const g=r-n(this,Cs),A=o-n(this,Cs),v=h-r+2*n(this,Cs),w=l-o+2*n(this,Cs);p(this,An,{x:g,y:A,width:v,height:w,lastPoint:[c,d]})};var wo,ui,Be,Kt,zu,hh,ju,$u,Ql;class dd{constructor(t,e=0,s=0,i=!0){b(this,Kt);b(this,wo);b(this,ui,[]);b(this,Be,[]);let a=1/0,r=-1/0,o=1/0,h=-1/0;const l=10**-4;for(const{x:w,y,width:x,height:_}of t){const S=Math.floor((w-e)/l)*l,E=Math.ceil((w+x+e)/l)*l,M=Math.floor((y-e)/l)*l,C=Math.ceil((y+_+e)/l)*l,R=[S,M,C,!0],j=[E,M,C,!1];n(this,ui).push(R,j),a=Math.min(a,S),r=Math.max(r,E),o=Math.min(o,M),h=Math.max(h,C)}const c=r-a+2*s,d=h-o+2*s,f=a-s,g=o-s,A=n(this,ui).at(i?-1:-2),v=[A[0],A[2]];for(const w of n(this,ui)){const[y,x,_]=w;w[0]=(y-f)/c,w[1]=(x-g)/d,w[2]=(_-g)/d}p(this,wo,{x:f,y:g,width:c,height:d,lastPoint:v})}getOutlines(){n(this,ui).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of n(this,ui))e[3]?(t.push(...m(this,Kt,Ql).call(this,e)),m(this,Kt,ju).call(this,e)):(m(this,Kt,$u).call(this,e),t.push(...m(this,Kt,Ql).call(this,e)));return m(this,Kt,zu).call(this,t)}}wo=new WeakMap,ui=new WeakMap,Be=new WeakMap,Kt=new WeakSet,zu=function(t){const e=[],s=new Set;for(const r of t){const[o,h,l]=r;e.push([o,h,r],[o,l,r])}e.sort((r,o)=>r[1]-o[1]||r[0]-o[0]);for(let r=0,o=e.length;r<o;r+=2){const h=e[r][2],l=e[r+1][2];h.push(l),l.push(h),s.add(h),s.add(l)}const i=[];let a;for(;s.size>0;){const r=s.values().next().value;let[o,h,l,c,d]=r;s.delete(r);let f=o,g=h;for(a=[o,l],i.push(a);;){let A;if(s.has(c))A=c;else{if(!s.has(d))break;A=d}s.delete(A),[o,h,l,c,d]=A,f!==o&&(a.push(f,g,o,g===h?h:l),f=o),g=g===h?l:h}a.push(f,g)}return new Tg(i,n(this,wo))},hh=function(t){const e=n(this,Be);let s=0,i=e.length-1;for(;s<=i;){const a=s+i>>1,r=e[a][0];if(r===t)return a;r<t?s=a+1:i=a-1}return i+1},ju=function([,t,e]){const s=m(this,Kt,hh).call(this,t);n(this,Be).splice(s,0,[t,e])},$u=function([,t,e]){const s=m(this,Kt,hh).call(this,t);for(let i=s;i<n(this,Be).length;i++){const[a,r]=n(this,Be)[i];if(a!==t)break;if(a===t&&r===e){n(this,Be).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[a,r]=n(this,Be)[i];if(a!==t)break;if(a===t&&r===e){n(this,Be).splice(i,1);return}}},Ql=function(t){const[e,s,i]=t,a=[[e,s,i]],r=m(this,Kt,hh).call(this,i);for(let o=0;o<r;o++){const[h,l]=n(this,Be)[o];for(let c=0,d=a.length;c<d;c++){const[,f,g]=a[c];if(!(l<=f||g<=h))if(f>=h)if(g>l)a[c][1]=l;else{if(d===1)return[];a.splice(c,1),c--,d--}else a[c][2]=h,g>l&&a.push([e,l,g])}}return a};var _o,La;class Tg extends Pu{constructor(e,s){super();b(this,_o);b(this,La);p(this,La,e),p(this,_o,s)}toSVGPath(){const e=[];for(const s of n(this,La)){let[i,a]=s;e.push(`M${i} ${a}`);for(let r=2;r<s.length;r+=2){const o=s[r],h=s[r+1];o===i?(e.push(`V${h}`),a=h):h===a&&(e.push(`H${o}`),i=o)}e.push("Z")}return e.join(" ")}serialize([e,s,i,a],r){const o=[],h=i-e,l=a-s;for(const c of n(this,La)){const d=new Array(c.length);for(let f=0;f<c.length;f+=2)d[f]=e+c[f]*h,d[f+1]=a-c[f+1]*l;o.push(d)}return o}get box(){return n(this,_o)}get classNamesForDrawing(){return["highlight"]}get classNamesForOutlining(){return["highlightOutline"]}}_o=new WeakMap,La=new WeakMap;class Jl extends _h{newFreeDrawOutline(t,e,s,i,a,r){return new Rg(t,e,s,i,a,r)}get classNamesForDrawing(){return["highlight","free"]}}class Rg extends Bu{get classNamesForDrawing(){return["highlight","free"]}get classNamesForOutlining(){return["highlightOutline","free"]}newOutliner(t,e,s,i,a,r=0){return new Jl(t,e,s,i,a,r)}}var He,vn,Fa,_t,xo,Da,So,Eo,fi,ze,Na,Co,nt,Zl,tc,ec,Mi,Vu,Us;const Qt=class Qt{constructor({editor:t=null,uiManager:e=null}){b(this,nt);b(this,He,null);b(this,vn,null);b(this,Fa);b(this,_t,null);b(this,xo,!1);b(this,Da,!1);b(this,So,null);b(this,Eo);b(this,fi,null);b(this,ze,null);b(this,Na);var s;t?(p(this,Da,!1),p(this,Na,O.HIGHLIGHT_COLOR),p(this,So,t)):(p(this,Da,!0),p(this,Na,O.HIGHLIGHT_DEFAULT_COLOR)),p(this,ze,(t==null?void 0:t._uiManager)||e),p(this,Eo,n(this,ze)._eventBus),p(this,Fa,(t==null?void 0:t.color)||((s=n(this,ze))==null?void 0:s.highlightColors.values().next().value)||"#FFFF98"),n(Qt,Co)||p(Qt,Co,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return K(this,"_keyboardManager",new Fo([[["Escape","mac+Escape"],Qt.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Qt.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Qt.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Qt.prototype._moveToPrevious],[["Home","mac+Home"],Qt.prototype._moveToBeginning],[["End","mac+End"],Qt.prototype._moveToEnd]]))}renderButton(){const t=p(this,He,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=n(this,ze)._signal;t.addEventListener("click",m(this,nt,Mi).bind(this),{signal:e}),t.addEventListener("keydown",m(this,nt,ec).bind(this),{signal:e});const s=p(this,vn,document.createElement("span"));return s.className="swatch",s.setAttribute("aria-hidden",!0),s.style.backgroundColor=n(this,Fa),t.append(s),t}renderMainDropdown(){const t=p(this,_t,m(this,nt,Zl).call(this));return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}_colorSelectFromKeyboard(t){if(t.target===n(this,He)){m(this,nt,Mi).call(this,t);return}const e=t.target.getAttribute("data-color");e&&m(this,nt,tc).call(this,e,t)}_moveToNext(t){var e,s;n(this,nt,Us)?t.target!==n(this,He)?(e=t.target.nextSibling)==null||e.focus():(s=n(this,_t).firstChild)==null||s.focus():m(this,nt,Mi).call(this,t)}_moveToPrevious(t){var e,s;t.target!==((e=n(this,_t))==null?void 0:e.firstChild)&&t.target!==n(this,He)?(n(this,nt,Us)||m(this,nt,Mi).call(this,t),(s=t.target.previousSibling)==null||s.focus()):n(this,nt,Us)&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){var e;n(this,nt,Us)?(e=n(this,_t).firstChild)==null||e.focus():m(this,nt,Mi).call(this,t)}_moveToEnd(t){var e;n(this,nt,Us)?(e=n(this,_t).lastChild)==null||e.focus():m(this,nt,Mi).call(this,t)}hideDropdown(){var t,e;(t=n(this,_t))==null||t.classList.add("hidden"),(e=n(this,fi))==null||e.abort(),p(this,fi,null)}_hideDropdownFromKeyboard(){var t;n(this,Da)||(n(this,nt,Us)?(this.hideDropdown(),n(this,He).focus({preventScroll:!0,focusVisible:n(this,xo)})):(t=n(this,So))==null||t.unselect())}updateColor(t){if(n(this,vn)&&(n(this,vn).style.backgroundColor=t),!n(this,_t))return;const e=n(this,ze).highlightColors.values();for(const s of n(this,_t).children)s.setAttribute("aria-selected",e.next().value===t)}destroy(){var t,e;(t=n(this,He))==null||t.remove(),p(this,He,null),p(this,vn,null),(e=n(this,_t))==null||e.remove(),p(this,_t,null)}};He=new WeakMap,vn=new WeakMap,Fa=new WeakMap,_t=new WeakMap,xo=new WeakMap,Da=new WeakMap,So=new WeakMap,Eo=new WeakMap,fi=new WeakMap,ze=new WeakMap,Na=new WeakMap,Co=new WeakMap,nt=new WeakSet,Zl=function(){const t=document.createElement("div"),e=n(this,ze)._signal;t.addEventListener("contextmenu",Ee,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[s,i]of n(this,ze).highlightColors){const a=document.createElement("button");a.tabIndex="0",a.role="option",a.setAttribute("data-color",i),a.title=s,a.setAttribute("data-l10n-id",n(Qt,Co)[s]);const r=document.createElement("span");a.append(r),r.className="swatch",r.style.backgroundColor=i,a.setAttribute("aria-selected",i===n(this,Fa)),a.addEventListener("click",m(this,nt,tc).bind(this,i),{signal:e}),t.append(a)}return t.addEventListener("keydown",m(this,nt,ec).bind(this),{signal:e}),t},tc=function(t,e){e.stopPropagation(),n(this,Eo).dispatch("switchannotationeditorparams",{source:this,type:n(this,Na),value:t})},ec=function(t){Qt._keyboardManager.exec(this,t)},Mi=function(t){if(n(this,nt,Us)){this.hideDropdown();return}if(p(this,xo,t.detail===0),n(this,fi)||(p(this,fi,new AbortController),window.addEventListener("pointerdown",m(this,nt,Vu).bind(this),{signal:n(this,ze).combinedSignal(n(this,fi))})),n(this,_t)){n(this,_t).classList.remove("hidden");return}const e=p(this,_t,m(this,nt,Zl).call(this));n(this,He).append(e)},Vu=function(t){var e;(e=n(this,_t))!=null&&e.contains(t.target)||this.hideDropdown()},Us=function(){return n(this,_t)&&!n(this,_t).classList.contains("hidden")},b(Qt,Co,null);let xh=Qt;var Oa,Mo,Ms,yn,Ba,ve,ko,To,wn,je,zt,te,Ha,ks,xt,za,ye,Ro,$,sc,lh,Gu,Uu,qu,ic,ki,xe,Gn,Wu,ch,hr,Xu,Ku,Yu,Qu,Ju;const J=class J extends it{constructor(e){super({...e,name:"highlightEditor"});b(this,$);b(this,Oa,null);b(this,Mo,0);b(this,Ms);b(this,yn,null);b(this,Ba,null);b(this,ve,null);b(this,ko,null);b(this,To,0);b(this,wn,null);b(this,je,null);b(this,zt,null);b(this,te,!1);b(this,Ha,null);b(this,ks);b(this,xt,null);b(this,za,"");b(this,ye);b(this,Ro,"");this.color=e.color||J._defaultColor,p(this,ye,e.thickness||J._defaultThickness),p(this,ks,e.opacity||J._defaultOpacity),p(this,Ms,e.boxes||null),p(this,Ro,e.methodOfCreation||""),p(this,za,e.text||""),this._isDraggable=!1,e.highlightId>-1?(p(this,te,!0),m(this,$,lh).call(this,e),m(this,$,ki).call(this)):n(this,Ms)&&(p(this,Oa,e.anchorNode),p(this,Mo,e.anchorOffset),p(this,ko,e.focusNode),p(this,To,e.focusOffset),m(this,$,sc).call(this),m(this,$,ki).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const e=J.prototype;return K(this,"_keyboardManager",new Fo([[["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:n(this,te)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:n(this,ye),methodOfCreation:n(this,Ro)}}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;it.initialize(e,s),J._defaultColor||(J._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case O.HIGHLIGHT_DEFAULT_COLOR:J._defaultColor=s;break;case O.HIGHLIGHT_THICKNESS:J._defaultThickness=s}}translateInPage(e,s){}get toolbarPosition(){return n(this,Ha)}updateParams(e,s){switch(e){case O.HIGHLIGHT_COLOR:m(this,$,Gu).call(this,s);break;case O.HIGHLIGHT_THICKNESS:m(this,$,Uu).call(this,s)}}static get defaultPropertiesToUpdate(){return[[O.HIGHLIGHT_DEFAULT_COLOR,J._defaultColor],[O.HIGHLIGHT_THICKNESS,J._defaultThickness]]}get propertiesToUpdate(){return[[O.HIGHLIGHT_COLOR,this.color||J._defaultColor],[O.HIGHLIGHT_THICKNESS,n(this,ye)||J._defaultThickness],[O.HIGHLIGHT_FREE,n(this,te)]]}async addEditToolbar(){const e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(p(this,Ba,new xh({editor:this})),e.addColorPicker(n(this,Ba))),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,$,hr).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,m(this,$,hr).call(this))}onceAdded(){this.annotationElementId||this.parent.addUndoableEditor(this),this.div.focus()}remove(){m(this,$,ic).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(m(this,$,ki).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?m(this,$,ic).call(this):e&&(m(this,$,ki).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 a,r,o;const{drawLayer:s}=this.parent;let i;n(this,te)?(e=(e-this.rotation+360)%360,i=m(a=J,xe,Gn).call(a,n(this,je).box,e)):i=m(r=J,xe,Gn).call(r,this,e),s.rotate(n(this,zt),e),s.rotate(n(this,xt),e),s.updateBox(n(this,zt),i),s.updateBox(n(this,xt),m(o=J,xe,Gn).call(o,n(this,ve).box,e))}render(){if(this.div)return this.div;const e=super.render();n(this,za)&&(e.setAttribute("aria-label",n(this,za)),e.setAttribute("role","mark")),n(this,te)?e.classList.add("free"):this.div.addEventListener("keydown",m(this,$,Wu).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=n(this,yn);const[i,a]=this.parentDimensions;return this.setDims(this.width*i,this.height*a),yh(this,n(this,wn),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){this.isSelected||this.parent.drawLayer.addClass(n(this,xt),"hovered")}pointerleave(){this.isSelected||this.parent.drawLayer.removeClass(n(this,xt),"hovered")}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:m(this,$,ch).call(this,!0);break;case 1:case 3:m(this,$,ch).call(this,!1)}}select(){var e,s;super.select(),n(this,xt)&&((e=this.parent)==null||e.drawLayer.removeClass(n(this,xt),"hovered"),(s=this.parent)==null||s.drawLayer.addClass(n(this,xt),"selected"))}unselect(){var e;super.unselect(),n(this,xt)&&((e=this.parent)==null||e.drawLayer.removeClass(n(this,xt),"selected"),n(this,te)||m(this,$,ch).call(this,!1))}get _mustFixPosition(){return!n(this,te)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.show(n(this,zt),e),this.parent.drawLayer.show(n(this,xt),e))}static startHighlighting(e,s,{target:i,x:a,y:r}){const{x:o,y:h,width:l,height:c}=i.getBoundingClientRect(),d=new AbortController,f=e.combinedSignal(d),g=A=>{d.abort(),m(this,xe,Qu).call(this,e,A)};window.addEventListener("blur",g,{signal:f}),window.addEventListener("pointerup",g,{signal:f}),window.addEventListener("pointerdown",A=>{A.preventDefault(),A.stopPropagation()},{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",Ee,{signal:f}),i.addEventListener("pointermove",m(this,xe,Yu).bind(this,e),{signal:f}),this._freeHighlight=new Jl({x:a,y:r},[o,h,l,c],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 v,w,y,x;let a=null;if(e instanceof xu){const{data:{quadPoints:_,rect:S,rotation:E,id:M,color:C,opacity:R,popupRef:j},parent:{page:{pageNumber:D}}}=e;a=e={annotationType:V.HIGHLIGHT,color:Array.from(C),opacity:R,quadPoints:_,boxes:null,pageIndex:D-1,rect:S.slice(0),rotation:E,id:M,deleted:!1,popupRef:j}}else if(e instanceof Nc){const{data:{inkLists:_,rect:S,rotation:E,id:M,color:C,borderStyle:{rawWidth:R},popupRef:j},parent:{page:{pageNumber:D}}}=e;a=e={annotationType:V.HIGHLIGHT,color:Array.from(C),thickness:R,inkLists:_,boxes:null,pageIndex:D-1,rect:S.slice(0),rotation:E,id:M,deleted:!1,popupRef:j}}const{color:r,quadPoints:o,inkLists:h,opacity:l}=e,c=await super.deserialize(e,s,i);c.color=I.makeHexColor(...r),p(c,ks,l||1),h&&p(c,ye,e.thickness),c.annotationElementId=e.id||null,c._initialData=a;const[d,f]=c.pageDimensions,[g,A]=c.pageTranslation;if(o){const _=p(c,Ms,[]);for(let S=0;S<o.length;S+=8)_.push({x:(o[S]-g)/d,y:1-(o[S+1]-A)/f,width:(o[S+2]-o[S])/d,height:(o[S+1]-o[S+5])/f});m(v=c,$,sc).call(v),m(w=c,$,ki).call(w),c.rotate(c.rotation)}else if(h){p(c,te,!0);const _=h[0],S={x:_[0]-g,y:f-(_[1]-A)},E=new Jl(S,[0,0,d,f],1,n(c,ye)/2,!0,.001);for(let R=0,j=_.length;R<j;R+=2)S.x=_[R]-g,S.y=f-(_[R+1]-A),E.add(S);const{id:M,clipPathId:C}=s.drawLayer.draw(E,c.color,c._defaultOpacity,!0);m(y=c,$,lh).call(y,{highlightOutlines:E.getOutlines(),highlightId:M,clipPathId:C}),m(x=c,$,ki).call(x)}return c}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=this.getRect(0,0),i=it._colorManager.convert(this.color),a={annotationType:V.HIGHLIGHT,color:i,opacity:n(this,ks),thickness:n(this,ye),quadPoints:m(this,$,Xu).call(this),outlines:m(this,$,Ku).call(this,s),pageIndex:this.pageIndex,rect:s,rotation:m(this,$,hr).call(this),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!m(this,$,Ju).call(this,a)?null:(a.id=this.annotationElementId,a)}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};Oa=new WeakMap,Mo=new WeakMap,Ms=new WeakMap,yn=new WeakMap,Ba=new WeakMap,ve=new WeakMap,ko=new WeakMap,To=new WeakMap,wn=new WeakMap,je=new WeakMap,zt=new WeakMap,te=new WeakMap,Ha=new WeakMap,ks=new WeakMap,xt=new WeakMap,za=new WeakMap,ye=new WeakMap,Ro=new WeakMap,$=new WeakSet,sc=function(){const e=new dd(n(this,Ms),.001);p(this,je,e.getOutlines()),{x:this.x,y:this.y,width:this.width,height:this.height}=n(this,je).box;const s=new dd(n(this,Ms),.0025,.001,this._uiManager.direction==="ltr");p(this,ve,s.getOutlines());const{lastPoint:i}=n(this,ve).box;p(this,Ha,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height])},lh=function({highlightOutlines:e,highlightId:s,clipPathId:i}){var c,d;if(p(this,je,e),p(this,ve,e.getNewOutline(n(this,ye)/2+1.5,.0025)),s>=0)p(this,zt,s),p(this,yn,i),this.parent.drawLayer.finalizeLine(s,e),p(this,xt,this.parent.drawLayer.drawOutline(n(this,ve)));else if(this.parent){const f=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(n(this,zt),e),this.parent.drawLayer.updateBox(n(this,zt),m(c=J,xe,Gn).call(c,n(this,je).box,(f-this.rotation+360)%360)),this.parent.drawLayer.updateLine(n(this,xt),n(this,ve)),this.parent.drawLayer.updateBox(n(this,xt),m(d=J,xe,Gn).call(d,n(this,ve).box,f))}const{x:a,y:r,width:o,height:h}=e.box;switch(this.rotation){case 0:this.x=a,this.y=r,this.width=o,this.height=h;break;case 90:{const[f,g]=this.parentDimensions;this.x=r,this.y=1-a,this.width=o*g/f,this.height=h*f/g;break}case 180:this.x=1-a,this.y=1-r,this.width=o,this.height=h;break;case 270:{const[f,g]=this.parentDimensions;this.x=1-r,this.y=a,this.width=o*g/f,this.height=h*f/g;break}}const{lastPoint:l}=n(this,ve).box;p(this,Ha,[(l[0]-a)/o,(l[1]-r)/h])},Gu=function(e){const s=(r,o)=>{var h,l,c;this.color=r,(h=this.parent)==null||h.drawLayer.changeColor(n(this,zt),r),(l=n(this,Ba))==null||l.updateColor(r),p(this,ks,o),(c=this.parent)==null||c.drawLayer.changeOpacity(n(this,zt),o)},i=this.color,a=n(this,ks);this.addCommands({cmd:s.bind(this,e,J._defaultOpacity),undo:s.bind(this,i,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:O.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)},Uu=function(e){const s=n(this,ye),i=a=>{p(this,ye,a),m(this,$,qu).call(this,a)};this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:O.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},qu=function(e){if(!n(this,te))return;m(this,$,lh).call(this,{highlightOutlines:n(this,je).getNewOutline(e/2)}),this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)},ic=function(){n(this,zt)!==null&&this.parent&&(this.parent.drawLayer.remove(n(this,zt)),p(this,zt,null),this.parent.drawLayer.remove(n(this,xt)),p(this,xt,null))},ki=function(e=this.parent){n(this,zt)===null&&({id:Gt(this,zt)._,clipPathId:Gt(this,yn)._}=e.drawLayer.draw(n(this,je),this.color,n(this,ks)),p(this,xt,e.drawLayer.drawOutline(n(this,ve))),n(this,wn)&&(n(this,wn).style.clipPath=n(this,yn)))},xe=new WeakSet,Gn=function({x:e,y:s,width:i,height:a},r){switch(r){case 90:return{x:1-s-a,y:e,width:a,height:i};case 180:return{x:1-e-i,y:1-s-a,width:i,height:a};case 270:return{x:s,y:1-e-i,width:a,height:i}}return{x:e,y:s,width:i,height:a}},Wu=function(e){J._keyboardManager.exec(this,e)},ch=function(e){if(!n(this,Oa))return;const s=window.getSelection();e?s.setPosition(n(this,Oa),n(this,Mo)):s.setPosition(n(this,ko),n(this,To))},hr=function(){return n(this,te)?this.rotation:0},Xu=function(){if(n(this,te))return null;const[e,s]=this.pageDimensions,[i,a]=this.pageTranslation,r=n(this,Ms),o=new Float32Array(8*r.length);let h=0;for(const{x:l,y:c,width:d,height:f}of r){const g=l*e+i,A=(1-c-f)*s+a;o[h]=o[h+4]=g,o[h+1]=o[h+3]=A,o[h+2]=o[h+6]=g+d*e,o[h+5]=o[h+7]=A+f*s,h+=8}return o},Ku=function(e){return n(this,je).serialize(e,m(this,$,hr).call(this))},Yu=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},Qu=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=""},Ju=function(e){const{color:s}=this._initialData;return e.color.some((i,a)=>i!==s[a])},b(J,xe),N(J,"_defaultColor",null),N(J,"_defaultOpacity",1),N(J,"_defaultThickness",12),N(J,"_type","highlight"),N(J,"_editorType",V.HIGHLIGHT),N(J,"_freeHighlightId",-1),N(J,"_freeHighlight",null),N(J,"_freeHighlightClipId","");let Sh=J;var _n,xn,ss,Ts,we,Sn,En,Cn,Rs,ja,Mn,kn,pi,k,Zu,tf,ef,sf,ac,nf,rc,af,rf,of,hf,lf,Ti,oc,hc,lc,dh,uh,Un,cc,fh,js,cf,dc,df,uf,uc,ph,lr;const lt=class lt extends it{constructor(e){super({...e,name:"inkEditor"});b(this,k);b(this,_n,0);b(this,xn,0);b(this,ss,null);b(this,Ts,new Path2D);b(this,we,!1);b(this,Sn,null);b(this,En,!1);b(this,Cn,!1);b(this,Rs,null);b(this,ja,null);b(this,Mn,0);b(this,kn,0);b(this,pi,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){it.initialize(e,s)}static updateDefaultParams(e,s){switch(e){case O.INK_THICKNESS:lt._defaultThickness=s;break;case O.INK_COLOR:lt._defaultColor=s;break;case O.INK_OPACITY:lt._defaultOpacity=s/100}}updateParams(e,s){switch(e){case O.INK_THICKNESS:m(this,k,Zu).call(this,s);break;case O.INK_COLOR:m(this,k,tf).call(this,s);break;case O.INK_OPACITY:m(this,k,ef).call(this,s)}}static get defaultPropertiesToUpdate(){return[[O.INK_THICKNESS,lt._defaultThickness],[O.INK_COLOR,lt._defaultColor||it._defaultLineColor],[O.INK_OPACITY,Math.round(100*lt._defaultOpacity)]]}get propertiesToUpdate(){return[[O.INK_THICKNESS,this.thickness||lt._defaultThickness],[O.INK_COLOR,this.color||lt._defaultColor||it._defaultLineColor],[O.INK_OPACITY,Math.round(100*(this.opacity??lt._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(m(this,k,dh).call(this),m(this,k,uh).call(this)),this.isAttachedToDOM||(this.parent.add(this),m(this,k,Un).call(this)),m(this,k,lr).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,n(this,ss)&&(clearTimeout(n(this,ss)),p(this,ss,null)),(e=n(this,Rs))==null||e.disconnect(),p(this,Rs,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,a=this.height*s;this.setDimensions(i,a)}enableEditMode(){!n(this,we)&&this.canvas!==null&&(super.enableEditMode(),this._isDraggable=!1,m(this,k,oc).call(this))}disableEditMode(){this.isInEditMode()&&this.canvas!==null&&(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),m(this,k,hc).call(this))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}commit(){n(this,we)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),p(this,we,!0),this.div.classList.add("disabled"),m(this,k,lr).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()&&!n(this,we)&&(this.setInForeground(),e.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),m(this,k,nf).call(this,e.offsetX,e.offsetY))}canvasPointermove(e){e.preventDefault(),m(this,k,rc).call(this,e.offsetX,e.offsetY)}canvasPointerup(e){e.preventDefault(),m(this,k,lc).call(this,e)}canvasPointerleave(e){m(this,k,lc).call(this,e)}get isResizable(){return!this.isEmpty()&&n(this,we)}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,a,r,o]=m(this,k,sf).call(this);if(this.setAt(i,a,0,0),this.setDims(r,o),m(this,k,dh).call(this),this.width){const[h,l]=this.parentDimensions;this.setAspectRatio(this.width*h,this.height*l),this.setAt(e*h,s*l,this.width*h,this.height*l),p(this,Cn,!0),m(this,k,Un).call(this),this.setDims(this.width*h,this.height*l),m(this,k,Ti).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return m(this,k,uh).call(this),this.div}setDimensions(e,s){const i=Math.round(e),a=Math.round(s);if(n(this,Mn)===i&&n(this,kn)===a)return;p(this,Mn,i),p(this,kn,a),this.canvas.style.visibility="hidden";const[r,o]=this.parentDimensions;this.width=e/r,this.height=s/o,this.fixAndSetPosition(),n(this,we)&&m(this,k,cc).call(this,e,s),m(this,k,Un).call(this),m(this,k,Ti).call(this),this.canvas.style.visibility="visible",this.fixDims()}static async deserialize(e,s,i){var w,y,x;if(e instanceof Nc)return null;const a=await super.deserialize(e,s,i);a.thickness=e.thickness,a.color=I.makeHexColor(...e.color),a.opacity=e.opacity;const[r,o]=a.pageDimensions,h=a.width*r,l=a.height*o,c=a.parentScale,d=e.thickness/2;p(a,we,!0),p(a,Mn,Math.round(h)),p(a,kn,Math.round(l));const{paths:f,rect:g,rotation:A}=e;for(let{bezier:_}of f){_=m(w=lt,js,df).call(w,_,g,A);const S=[];a.paths.push(S);let E=c*(_[0]-d),M=c*(_[1]-d);for(let R=2,j=_.length;R<j;R+=6){const D=c*(_[R]-d),F=c*(_[R+1]-d),Y=c*(_[R+2]-d),Q=c*(_[R+3]-d),B=c*(_[R+4]-d),ft=c*(_[R+5]-d);S.push([[E,M],[D,F],[Y,Q],[B,ft]]),E=B,M=ft}const C=m(this,js,cf).call(this,S);a.bezierPath2D.push(C)}const v=m(y=a,k,uc).call(y);return p(a,xn,Math.max(it.MIN_SIZE,v[2]-v[0])),p(a,_n,Math.max(it.MIN_SIZE,v[3]-v[1])),m(x=a,k,cc).call(x,h,l),a}serialize(){if(this.isEmpty())return null;const e=this.getRect(0,0),s=it._colorManager.convert(this.ctx.strokeStyle);return{annotationType:V.INK,color:s,thickness:this.thickness,opacity:this.opacity,paths:m(this,k,uf).call(this,this.scaleFactor/this.parentScale,this.translationX,this.translationY,e),pageIndex:this.pageIndex,rect:e,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}};_n=new WeakMap,xn=new WeakMap,ss=new WeakMap,Ts=new WeakMap,we=new WeakMap,Sn=new WeakMap,En=new WeakMap,Cn=new WeakMap,Rs=new WeakMap,ja=new WeakMap,Mn=new WeakMap,kn=new WeakMap,pi=new WeakMap,k=new WeakSet,Zu=function(e){const s=a=>{this.thickness=a,m(this,k,lr).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:O.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},tf=function(e){const s=a=>{this.color=a,m(this,k,Ti).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:O.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},ef=function(e){const s=a=>{this.opacity=a,m(this,k,Ti).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:O.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},sf=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]}},ac=function(){const{ctx:e,color:s,opacity:i,thickness:a,parentScale:r,scaleFactor:o}=this;e.lineWidth=a*r/o,e.lineCap="round",e.lineJoin="round",e.miterLimit=10,e.strokeStyle=`${s}${function(l){return Math.round(Math.min(255,Math.max(1,255*l))).toString(16).padStart(2,"0")}(i)}`},nf=function(e,s){this.canvas.addEventListener("contextmenu",Ee,{signal:this._uiManager._signal}),m(this,k,hc).call(this),p(this,Sn,new AbortController);const i=this._uiManager.combinedSignal(n(this,Sn));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,n(this,Cn)||(p(this,Cn,!0),m(this,k,Un).call(this),this.thickness||(this.thickness=lt._defaultThickness),this.color||(this.color=lt._defaultColor||it._defaultLineColor),this.opacity??(this.opacity=lt._defaultOpacity)),this.currentPath.push([e,s]),p(this,En,!1),m(this,k,ac).call(this),p(this,pi,()=>{m(this,k,of).call(this),n(this,pi)&&window.requestAnimationFrame(n(this,pi))}),window.requestAnimationFrame(n(this,pi))},rc=function(e,s){const[i,a]=this.currentPath.at(-1);if(this.currentPath.length>1&&e===i&&s===a)return;const r=this.currentPath;let o=n(this,Ts);r.push([e,s]),p(this,En,!0),r.length<=2?(o.moveTo(...r[0]),o.lineTo(e,s)):(r.length===3&&(p(this,Ts,o=new Path2D),o.moveTo(...r[0])),m(this,k,hf).call(this,o,...r.at(-3),...r.at(-2),e,s))},af=function(){if(this.currentPath.length===0)return;const e=this.currentPath.at(-1);n(this,Ts).lineTo(...e)},rf=function(e,s){p(this,pi,null),e=Math.min(Math.max(e,0),this.canvas.width),s=Math.min(Math.max(s,0),this.canvas.height),m(this,k,rc).call(this,e,s),m(this,k,af).call(this);let i;if(this.currentPath.length!==1)i=m(this,k,lf).call(this);else{const o=[e,s];i=[[o,o.slice(),o.slice(),o]]}const a=n(this,Ts),r=this.currentPath;this.currentPath=[],p(this,Ts,new Path2D),this.addCommands({cmd:()=>{this.allRawPaths.push(r),this.paths.push(i),this.bezierPath2D.push(a),this._uiManager.rebuild(this)},undo:()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(m(this,k,dh).call(this),m(this,k,uh).call(this)),m(this,k,lr).call(this))},mustExec:!0})},of=function(){if(!n(this,En))return;p(this,En,!1),Math.ceil(this.thickness*this.parentScale);const e=this.currentPath.slice(-3),s=e.map(r=>r[0]),i=e.map(r=>r[1]),{ctx:a}=(Math.min(...s),Math.max(...s),Math.min(...i),Math.max(...i),this);a.save(),a.clearRect(0,0,this.canvas.width,this.canvas.height);for(const r of this.bezierPath2D)a.stroke(r);a.stroke(n(this,Ts)),a.restore()},hf=function(e,s,i,a,r,o,h){const l=(s+a)/2,c=(i+r)/2,d=(a+o)/2,f=(r+h)/2;e.bezierCurveTo(l+2*(a-l)/3,c+2*(r-c)/3,d+2*(a-d)/3,f+2*(r-f)/3,d,f)},lf=function(){const e=this.currentPath;if(e.length<=2)return[[e[0],e[0],e.at(-1),e.at(-1)]];const s=[];let i,[a,r]=e[0];for(i=1;i<e.length-2;i++){const[g,A]=e[i],[v,w]=e[i+1],y=(g+v)/2,x=(A+w)/2,_=[a+2*(g-a)/3,r+2*(A-r)/3],S=[y+2*(g-y)/3,x+2*(A-x)/3];s.push([[a,r],_,S,[y,x]]),[a,r]=[y,x]}const[o,h]=e[i],[l,c]=e[i+1],d=[a+2*(o-a)/3,r+2*(h-r)/3],f=[l+2*(o-l)/3,c+2*(h-c)/3];return s.push([[a,r],d,f,[l,c]]),s},Ti=function(){if(this.isEmpty()){m(this,k,fh).call(this);return}m(this,k,ac).call(this);const{canvas:e,ctx:s}=this;s.setTransform(1,0,0,1,0,0),s.clearRect(0,0,e.width,e.height),m(this,k,fh).call(this);for(const i of this.bezierPath2D)s.stroke(i)},oc=function(){if(n(this,ja))return;p(this,ja,new AbortController);const e=this._uiManager.combinedSignal(n(this,ja));this.canvas.addEventListener("pointerdown",this.canvasPointerdown.bind(this),{signal:e})},hc=function(){var e;(e=this.pointerdownAC)==null||e.abort(),this.pointerdownAC=null},lc=function(e){var s;(s=n(this,Sn))==null||s.abort(),p(this,Sn,null),m(this,k,oc).call(this),n(this,ss)&&clearTimeout(n(this,ss)),p(this,ss,setTimeout(()=>{p(this,ss,null),this.canvas.removeEventListener("contextmenu",Ee)},10)),m(this,k,rf).call(this,e.offsetX,e.offsetY),this.addToAnnotationStorage(),this.setInBackground()},dh=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")},uh=function(){p(this,Rs,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&this.setDimensions(s.width,s.height)})),n(this,Rs).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var e;(e=n(this,Rs))==null||e.disconnect(),p(this,Rs,null)},{once:!0})},Un=function(){if(!n(this,Cn))return;const[e,s]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*e),this.canvas.height=Math.ceil(this.height*s),m(this,k,fh).call(this)},cc=function(e,s){const i=m(this,k,ph).call(this),a=(e-i)/n(this,xn),r=(s-i)/n(this,_n);this.scaleFactor=Math.min(a,r)},fh=function(){const e=m(this,k,ph).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+e,this.translationY*this.scaleFactor+e)},js=new WeakSet,cf=function(e){const s=new Path2D;for(let i=0,a=e.length;i<a;i++){const[r,o,h,l]=e[i];i===0&&s.moveTo(...r),s.bezierCurveTo(o[0],o[1],h[0],h[1],l[0],l[1])}return s},dc=function(e,s,i){const[a,r,o,h]=s;switch(i){case 0:for(let l=0,c=e.length;l<c;l+=2)e[l]+=a,e[l+1]=h-e[l+1];break;case 90:for(let l=0,c=e.length;l<c;l+=2){const d=e[l];e[l]=e[l+1]+a,e[l+1]=d+r}break;case 180:for(let l=0,c=e.length;l<c;l+=2)e[l]=o-e[l],e[l+1]+=r;break;case 270:for(let l=0,c=e.length;l<c;l+=2){const d=e[l];e[l]=o-e[l+1],e[l+1]=h-d}break;default:throw new Error("Invalid rotation")}return e},df=function(e,s,i){const[a,r,o,h]=s;switch(i){case 0:for(let l=0,c=e.length;l<c;l+=2)e[l]-=a,e[l+1]=h-e[l+1];break;case 90:for(let l=0,c=e.length;l<c;l+=2){const d=e[l];e[l]=e[l+1]-r,e[l+1]=d-a}break;case 180:for(let l=0,c=e.length;l<c;l+=2)e[l]=o-e[l],e[l+1]-=r;break;case 270:for(let l=0,c=e.length;l<c;l+=2){const d=e[l];e[l]=h-e[l+1],e[l+1]=o-d}break;default:throw new Error("Invalid rotation")}return e},uf=function(e,s,i,a){var c,d;const r=[],o=this.thickness/2,h=e*s+o,l=e*i+o;for(const f of this.paths){const g=[],A=[];for(let v=0,w=f.length;v<w;v++){const[y,x,_,S]=f[v];if(y[0]===S[0]&&y[1]===S[1]&&w===1){const Q=e*y[0]+h,B=e*y[1]+l;g.push(Q,B),A.push(Q,B);break}const E=e*y[0]+h,M=e*y[1]+l,C=e*x[0]+h,R=e*x[1]+l,j=e*_[0]+h,D=e*_[1]+l,F=e*S[0]+h,Y=e*S[1]+l;v===0&&(g.push(E,M),A.push(E,M)),g.push(C,R,j,D,F,Y),A.push(C,R),v===w-1&&A.push(F,Y)}r.push({bezier:m(c=lt,js,dc).call(c,g,a,this.rotation),points:m(d=lt,js,dc).call(d,A,a,this.rotation)})}return r},uc=function(){let e=1/0,s=-1/0,i=1/0,a=-1/0;for(const r of this.paths)for(const[o,h,l,c]of r){const d=I.bezierBoundingBox(...o,...h,...l,...c);e=Math.min(e,d[0]),i=Math.min(i,d[1]),s=Math.max(s,d[2]),a=Math.max(a,d[3])}return[e,i,s,a]},ph=function(){return n(this,we)?Math.ceil(this.thickness*this.parentScale):0},lr=function(e=!1){if(this.isEmpty())return;if(!n(this,we)){m(this,k,Ti).call(this);return}const s=m(this,k,uc).call(this),i=m(this,k,ph).call(this);p(this,xn,Math.max(it.MIN_SIZE,s[2]-s[0])),p(this,_n,Math.max(it.MIN_SIZE,s[3]-s[1]));const a=Math.ceil(i+n(this,xn)*this.scaleFactor),r=Math.ceil(i+n(this,_n)*this.scaleFactor),[o,h]=this.parentDimensions;this.width=a/o,this.height=r/h,this.setAspectRatio(a,r);const l=this.translationX,c=this.translationY;this.translationX=-s[0],this.translationY=-s[1],m(this,k,Un).call(this),m(this,k,Ti).call(this),p(this,Mn,a),p(this,kn,r),this.setDims(a,r);const d=e?i/this.scaleFactor/2:0;this.translate(l-this.translationX-d,c-this.translationY-d)},b(lt,js),N(lt,"_defaultColor",null),N(lt,"_defaultOpacity",1),N(lt,"_defaultThickness",1),N(lt,"_type","ink"),N(lt,"_editorType",V.INK);let nc=lt;var dt,Dt,gi,Ps,mi,$a,is,Is,ns,ue,Va,X,cr,dr,gh,pc,ff,mh,gc,bh,pf,gf;const pr=class pr extends it{constructor(e){super({...e,name:"stampEditor"});b(this,X);b(this,dt,null);b(this,Dt,null);b(this,gi,null);b(this,Ps,null);b(this,mi,null);b(this,$a,"");b(this,is,null);b(this,Is,null);b(this,ns,null);b(this,ue,!1);b(this,Va,!1);p(this,Ps,e.bitmapUrl),p(this,mi,e.bitmapFile)}static initialize(e,s){it.initialize(e,s)}static get supportedTypes(){return K(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(e=>`image/${e}`))}static get supportedTypesStr(){return K(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,s){s.pasteEditor(V.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:a,width:r,height:o}=e||this.copyCanvas(null,null,!0).imageData,h=await i.guess({name:"altText",request:{data:a,width:r,height:o,channels:a.length/(r*o)}});if(!h)throw new Error("No response from the AI service.");if(h.error)throw new Error("Error from the AI service.");if(h.cancel)return null;if(!h.output)throw new Error("No valid response from the AI service.");const l=h.output;return await this.setGuessedAltText(l),s&&!this.hasAltTextData()&&(this.altTextData={alt:l,decorative:!1}),l}remove(){var e,s;n(this,Dt)&&(p(this,dt,null),this._uiManager.imageManager.deleteId(n(this,Dt)),(e=n(this,is))==null||e.remove(),p(this,is,null),(s=n(this,Is))==null||s.disconnect(),p(this,Is,null),n(this,ns)&&(clearTimeout(n(this,ns)),p(this,ns,null))),super.remove()}rebuild(){this.parent?(super.rebuild(),this.div!==null&&(n(this,Dt)&&n(this,is)===null&&m(this,X,gh).call(this),this.isAttachedToDOM||this.parent.add(this))):n(this,Dt)&&m(this,X,gh).call(this)}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(n(this,gi)||n(this,dt)||n(this,Ps)||n(this,mi)||n(this,Dt))}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(),n(this,dt)?m(this,X,pc).call(this):m(this,X,gh).call(this),this.width&&!this.annotationElementId){const[i,a]=this.parentDimensions;this.setAt(e*i,s*a,this.width*i,this.height*a)}return this.div}copyCanvas(e,s,i=!1){var g;e||(e=224);const{width:a,height:r}=n(this,dt),o=new cl;let h=n(this,dt),l=a,c=r,d=null;if(s){if(a>s||r>s){const R=Math.min(s/a,s/r);l=Math.floor(a*R),c=Math.floor(r*R)}d=document.createElement("canvas");const A=d.width=Math.ceil(l*o.sx),v=d.height=Math.ceil(c*o.sy);n(this,ue)||(h=m(this,X,mh).call(this,A,v));const w=d.getContext("2d");w.filter=this._uiManager.hcmFilter;let y="white",x="#cfcfd8";this._uiManager.hcmFilter!=="none"?x="black":(g=window.matchMedia)!=null&&g.call(window,"(prefers-color-scheme: dark)").matches&&(y="#8f8f9d",x="#42414d");const _=15,S=_*o.sx,E=_*o.sy,M=new OffscreenCanvas(2*S,2*E),C=M.getContext("2d");C.fillStyle=y,C.fillRect(0,0,2*S,2*E),C.fillStyle=x,C.fillRect(0,0,S,E),C.fillRect(S,E,S,E),w.fillStyle=w.createPattern(M,"repeat"),w.fillRect(0,0,A,v),w.drawImage(h,0,0,h.width,h.height,0,0,A,v)}let f=null;if(i){let A,v;if(o.symmetric&&h.width<e&&h.height<e)A=h.width,v=h.height;else if(h=n(this,dt),a>e||r>e){const y=Math.min(e/a,e/r);A=Math.floor(a*y),v=Math.floor(r*y),n(this,ue)||(h=m(this,X,mh).call(this,A,v))}const w=new OffscreenCanvas(A,v).getContext("2d",{willReadFrequently:!0});w.drawImage(h,0,0,h.width,h.height,0,0,A,v),f={width:A,height:v,data:w.getImageData(0,0,A,v).data}}return{canvas:d,width:l,height:c,imageData:f}}getImageForAltText(){return n(this,is)}static async deserialize(e,s,i){var v;let a=null;if(e instanceof Su){const{data:{rect:w,rotation:y,id:x,structParent:_,popupRef:S},container:E,parent:{page:{pageNumber:M}}}=e,C=E.querySelector("canvas"),R=i.imageManager.getFromCanvas(E.id,C);C.remove();const j=((v=await s._structTree.getAriaAttributes(`${Ec}${x}`))==null?void 0:v.get("aria-label"))||"";a=e={annotationType:V.STAMP,bitmapId:R.id,bitmap:R.bitmap,pageIndex:M-1,rect:w.slice(0),rotation:y,id:x,deleted:!1,accessibilityData:{decorative:!1,altText:j},isSvg:!1,structParent:_,popupRef:S}}const r=await super.deserialize(e,s,i),{rect:o,bitmap:h,bitmapUrl:l,bitmapId:c,isSvg:d,accessibilityData:f}=e;c&&i.imageManager.isValidId(c)?(p(r,Dt,c),h&&p(r,dt,h)):p(r,Ps,l),p(r,ue,d);const[g,A]=r.pageDimensions;return r.width=(o[2]-o[0])/g,r.height=(o[3]-o[1])/A,r.annotationElementId=e.id||null,f&&(r.altTextData=f),r._initialData=a,p(r,Va,!!a),r}serialize(e=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:V.STAMP,bitmapId:n(this,Dt),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:n(this,ue),structTreeParentId:this._structTreeParentId};if(e)return i.bitmapUrl=m(this,X,bh).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:a,altText:r}=this.serializeAltText(!1);if(!a&&r&&(i.accessibilityData={type:"Figure",alt:r}),this.annotationElementId){const h=m(this,X,gf).call(this,i);if(h.isSame)return null;h.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=n(this,ue)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(s.stamps.has(n(this,Dt))){if(n(this,ue)){const h=s.stamps.get(n(this,Dt));o>h.area&&(h.area=o,h.serialized.bitmap.close(),h.serialized.bitmap=m(this,X,bh).call(this,!1))}}else s.stamps.set(n(this,Dt),{area:o,serialized:i}),i.bitmap=m(this,X,bh).call(this,!1);return i}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}};dt=new WeakMap,Dt=new WeakMap,gi=new WeakMap,Ps=new WeakMap,mi=new WeakMap,$a=new WeakMap,is=new WeakMap,Is=new WeakMap,ns=new WeakMap,ue=new WeakMap,Va=new WeakMap,X=new WeakSet,cr=function(e,s=!1){e?(p(this,dt,e.bitmap),s||(p(this,Dt,e.id),p(this,ue,e.isSvg)),e.file&&p(this,$a,e.file.name),m(this,X,pc).call(this)):this.remove()},dr=function(){if(p(this,gi,null),this._uiManager.enableWaiting(!1),n(this,is))if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,dt))this._editToolbar.hide(),this._uiManager.editAltText(this,!0);else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,dt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},gh=function(){if(n(this,Dt)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(n(this,Dt)).then(i=>m(this,X,cr).call(this,i,!0)).finally(()=>m(this,X,dr).call(this));return}if(n(this,Ps)){const i=n(this,Ps);p(this,Ps,null),this._uiManager.enableWaiting(!0),p(this,gi,this._uiManager.imageManager.getFromUrl(i).then(a=>m(this,X,cr).call(this,a)).finally(()=>m(this,X,dr).call(this)));return}if(n(this,mi)){const i=n(this,mi);p(this,mi,null),this._uiManager.enableWaiting(!0),p(this,gi,this._uiManager.imageManager.getFromFile(i).then(a=>m(this,X,cr).call(this,a)).finally(()=>m(this,X,dr).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=pr.supportedTypesStr;const s=this._uiManager._signal;p(this,gi,new Promise(i=>{e.addEventListener("change",async()=>{if(e.files&&e.files.length!==0){this._uiManager.enableWaiting(!0);const a=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),m(this,X,cr).call(this,a)}else this.remove();i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>m(this,X,dr).call(this))),e.click()},pc=function(){const{div:e}=this;let{width:s,height:i}=n(this,dt);const[a,r]=this.pageDimensions,o=.75;if(this.width)s=this.width*a,i=this.height*r;else if(s>o*a||i>o*r){const d=Math.min(o*a/s,o*r/i);s*=d,i*=d}const[h,l]=this.parentDimensions;this.setDims(s*h/a,i*l/r),this._uiManager.enableWaiting(!1);const c=p(this,is,document.createElement("canvas"));c.setAttribute("role","img"),this.addContainer(c),this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1),m(this,X,gc).call(this,s,i),m(this,X,pf).call(this),n(this,Va)||(this.parent.addUndoableEditor(this),p(this,Va,!0)),this._reportTelemetry({action:"inserted_image"}),n(this,$a)&&c.setAttribute("aria-label",n(this,$a))},ff=function(e,s){var r;const[i,a]=this.parentDimensions;this.width=e/i,this.height=s/a,(r=this._initialOptions)!=null&&r.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,n(this,ns)!==null&&clearTimeout(n(this,ns)),p(this,ns,setTimeout(()=>{p(this,ns,null),m(this,X,gc).call(this,e,s)},200))},mh=function(e,s){const{width:i,height:a}=n(this,dt);let r=i,o=a,h=n(this,dt);for(;r>2*e||o>2*s;){const l=r,c=o;r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2)),o>2*s&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2));const d=new OffscreenCanvas(r,o);d.getContext("2d").drawImage(h,0,0,l,c,0,0,r,o),h=d.transferToImageBitmap()}return h},gc=function(e,s){const i=new cl,a=Math.ceil(e*i.sx),r=Math.ceil(s*i.sy),o=n(this,is);if(!o||o.width===a&&o.height===r)return;o.width=a,o.height=r;const h=n(this,ue)?n(this,dt):m(this,X,mh).call(this,a,r),l=o.getContext("2d");l.filter=this._uiManager.hcmFilter,l.drawImage(h,0,0,h.width,h.height,0,0,a,r)},bh=function(e){if(e){if(n(this,ue)){const i=this._uiManager.imageManager.getSvgUrl(n(this,Dt));if(i)return i}const s=document.createElement("canvas");return{width:s.width,height:s.height}=n(this,dt),s.getContext("2d").drawImage(n(this,dt),0,0),s.toDataURL()}if(n(this,ue)){const[s,i]=this.pageDimensions,a=Math.round(this.width*s*yi.PDF_TO_CSS_UNITS),r=Math.round(this.height*i*yi.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(a,r);return o.getContext("2d").drawImage(n(this,dt),0,0,n(this,dt).width,n(this,dt).height,0,0,a,r),o.transferToImageBitmap()}return structuredClone(n(this,dt))},pf=function(){this._uiManager._signal&&(p(this,Is,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&m(this,X,ff).call(this,s.width,s.height)})),n(this,Is).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var e;(e=n(this,Is))==null||e.disconnect(),p(this,Is,null)},{once:!0}))},gf=function(e){var l;const{rect:s,pageIndex:i,accessibilityData:{altText:a}}=this._initialData,r=e.rect.every((c,d)=>Math.abs(c-s[d])<1),o=e.pageIndex===i,h=(((l=e.accessibilityData)==null?void 0:l.alt)||"")===a;return{isSame:r&&o&&h,isSameAltText:h}},N(pr,"_type","stamp"),N(pr,"_editorType",V.STAMP);let fc=pr;var Tn,Ga,as,bi,Ls,fe,Ai,Ua,qa,jt,Fs,L,vi,Nt,mf,bc,Ac,vc,Ah;const Me=class Me{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:a,annotationLayer:r,drawLayer:o,textLayer:h,viewport:l,l10n:c}){b(this,Nt);b(this,Tn);b(this,Ga,!1);b(this,as,null);b(this,bi,null);b(this,Ls,null);b(this,fe,new Map);b(this,Ai,!1);b(this,Ua,!1);b(this,qa,!1);b(this,jt,null);b(this,Fs,null);b(this,L);const d=[...n(Me,vi).values()];if(!Me._initialized){Me._initialized=!0;for(const f of d)f.initialize(c,t)}t.registerEditorTypes(d),p(this,L,t),this.pageIndex=e,this.div=s,p(this,Tn,a),p(this,as,r),this.viewport=l,p(this,jt,h),this.drawLayer=o,this._structTree=i,n(this,L).addLayer(this)}get isEmpty(){return n(this,fe).size===0}get isInvisible(){return this.isEmpty&&n(this,L).getMode()===V.NONE}updateToolbar(t){n(this,L).updateToolbar(t)}updateMode(t=n(this,L).getMode()){switch(m(this,Nt,Ah).call(this),t){case V.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case V.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case V.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 n(Me,vi).values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=n(this,jt))==null?void 0:e.div)}addInkEditorIfNeeded(t){if(n(this,L).getMode()===V.INK){if(!t){for(const e of n(this,fe).values())if(e.isEmpty()){e.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}}setEditingState(t){n(this,L).setEditingState(t)}addCommands(t){n(this,L).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=n(this,as))==null||e.div.classList.toggle("disabled",!t)}async enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const s of n(this,fe).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(n(this,L).removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!n(this,as))return;const e=n(this,as).getEditableAnnotations();for(const s of e){if(s.hide(),n(this,L).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,qa,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const a of n(this,fe).values())a.disableEditing(),a.annotationElementId&&(a.serialize()===null?(e.set(a.annotationElementId,a),(i=this.getEditableAnnotation(a.annotationElementId))==null||i.show(),a.remove()):t.set(a.annotationElementId,a));if(n(this,as)){const a=n(this,as).getEditableAnnotations();for(const r of a){const{id:o}=r.data;if(n(this,L).isDeletedAnnotationElement(o))continue;let h=e.get(o);h?(h.resetAnnotationElement(r),h.show(!1),r.show()):(h=t.get(o),h&&(n(this,L).addChangedExistingAnnotation(h),h.renderAnnotationElement(r)&&h.show(!1)),r.show())}}m(this,Nt,Ah).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const a of n(Me,vi).values())s.remove(`${a._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),p(this,qa,!1)}getEditableAnnotation(t){var e;return((e=n(this,as))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){n(this,L).getActive()!==t&&n(this,L).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=n(this,jt))!=null&&t.div&&!n(this,Fs)){p(this,Fs,new AbortController);const e=n(this,L).combinedSignal(n(this,Fs));n(this,jt).div.addEventListener("pointerdown",m(this,Nt,mf).bind(this),{signal:e}),n(this,jt).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=n(this,jt))!=null&&t.div&&n(this,Fs)&&(n(this,Fs).abort(),p(this,Fs,null),n(this,jt).div.classList.remove("highlighting"))}enableClick(){if(n(this,bi))return;p(this,bi,new AbortController);const t=n(this,L).combinedSignal(n(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=n(this,bi))==null||t.abort(),p(this,bi,null)}attach(t){n(this,fe).set(t.id,t);const{annotationElementId:e}=t;e&&n(this,L).isDeletedAnnotationElement(e)&&n(this,L).removeDeletedAnnotationElement(t)}detach(t){var e;n(this,fe).delete(t.id),(e=n(this,Tn))==null||e.removePointerInTextLayer(t.contentDiv),!n(this,qa)&&t.annotationElementId&&n(this,L).addDeletedAnnotationElement(t)}remove(t){this.detach(t),n(this,L).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1,n(this,Ua)||this.addInkEditorIfNeeded(!1)}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(n(this,L).addDeletedAnnotationElement(t.annotationElementId),it.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),n(this,L).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),n(this,L).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!n(this,Ls)&&(t._focusEventsAllowed=!1,p(this,Ls,setTimeout(()=>{p(this,Ls,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:n(this,L)._signal}),e.focus())},0))),t._structTreeParentId=(s=n(this,Tn))==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){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return n(this,L).getId()}combinedSignal(t){return n(this,L).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=n(this,Nt,bc))==null?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){n(this,L).updateToolbar(t),n(this,L).updateMode(t);const{offsetX:s,offsetY:i}=m(this,Nt,vc).call(this),a=this.getNextId(),r=m(this,Nt,Ac).call(this,{parent:this,id:a,x:s,y:i,uiManager:n(this,L),isCentered:!0,...e});r&&this.add(r)}async deserialize(t){var e;return await((e=n(Me,vi).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,n(this,L)))||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),a=m(this,Nt,Ac).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:n(this,L),isCentered:e,...s});return a&&this.add(a),a}addNewEditor(){this.createAndAddNewEditor(m(this,Nt,vc).call(this),!0)}setSelected(t){n(this,L).setSelected(t)}toggleSelected(t){n(this,L).toggleSelected(t)}unselect(t){n(this,L).unselect(t)}pointerup(t){const{isMac:e}=Wt.platform;!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&n(this,Ai)&&(p(this,Ai,!1),n(this,Ga)?n(this,L).getMode()!==V.STAMP?this.createAndAddNewEditor(t,!1):n(this,L).unselectAll():p(this,Ga,!0))}pointerdown(t){if(n(this,L).getMode()===V.HIGHLIGHT&&this.enableTextSelection(),n(this,Ai)){p(this,Ai,!1);return}const{isMac:e}=Wt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;p(this,Ai,!0);const s=n(this,L).getActive();p(this,Ga,!s||s.isEmpty())}findNewParent(t,e,s){const i=n(this,L).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}destroy(){var t,e;((t=n(this,L).getActive())==null?void 0:t.parent)===this&&(n(this,L).commitOrRemove(),n(this,L).setActiveEditor(null)),n(this,Ls)&&(clearTimeout(n(this,Ls)),p(this,Ls,null));for(const s of n(this,fe).values())(e=n(this,Tn))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,n(this,fe).clear(),n(this,L).removeLayer(this)}render({viewport:t}){this.viewport=t,Rn(this.div,t);for(const e of n(this,L).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){n(this,L).commitOrRemove(),m(this,Nt,Ah).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,Rn(this.div,{rotation:s}),e!==s)for(const i of n(this,fe).values())i.rotate(s);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return n(this,L).viewParameters.realScale}};Tn=new WeakMap,Ga=new WeakMap,as=new WeakMap,bi=new WeakMap,Ls=new WeakMap,fe=new WeakMap,Ai=new WeakMap,Ua=new WeakMap,qa=new WeakMap,jt=new WeakMap,Fs=new WeakMap,L=new WeakMap,vi=new WeakMap,Nt=new WeakSet,mf=function(t){n(this,L).unselectAll();const{target:e}=t;if(e===n(this,jt).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&n(this,jt).div.contains(e)){const{isMac:s}=Wt.platform;if(t.button!==0||t.ctrlKey&&s)return;n(this,L).showAllEditors("highlight",!0,!0),n(this,jt).div.classList.add("free"),this.toggleDrawing(),Sh.startHighlighting(this,n(this,L).direction==="ltr",{target:n(this,jt).div,x:t.x,y:t.y}),n(this,jt).div.addEventListener("pointerup",()=>{n(this,jt).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:n(this,L)._signal}),t.preventDefault()}},bc=function(){return n(Me,vi).get(n(this,L).getMode())},Ac=function(t){const e=n(this,Nt,bc);return e?new e.prototype.constructor(t):null},vc=function(){const{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),a=Math.max(0,t),r=Math.max(0,e),o=(a+Math.min(window.innerWidth,t+s))/2-t,h=(r+Math.min(window.innerHeight,e+i))/2-e,[l,c]=this.viewport.rotation%180==0?[o,h]:[h,o];return{offsetX:l,offsetY:c}},Ah=function(){p(this,Ua,!0);for(const t of n(this,fe).values())t.isEmpty()&&t.remove();p(this,Ua,!1)},N(Me,"_initialized",!1),b(Me,vi,new Map([Kl,nc,fc,Sh].map(t=>[t._editorType,t])));let mc=Me;var rs,Po,At,Ds,Io,wc,Fn,_c,bf;const It=class It{constructor({pageIndex:t}){b(this,Fn);b(this,rs,null);b(this,Po,0);b(this,At,new Map);b(this,Ds,new Map);this.pageIndex=t}setParent(t){if(n(this,rs)){if(n(this,rs)!==t){if(n(this,At).size>0)for(const e of n(this,At).values())e.remove(),t.append(e);p(this,rs,t)}}else p(this,rs,t)}static get _svgFactory(){return K(this,"_svgFactory",new Dc)}draw(t,e,s,i=!1){const a=Gt(this,Po)._++,r=m(this,Fn,_c).call(this,t.box);r.classList.add(...t.classNamesForDrawing);const o=It._svgFactory.createElement("defs");r.append(o);const h=It._svgFactory.createElement("path");o.append(h);const l=`path_p${this.pageIndex}_${a}`;h.setAttribute("id",l),h.setAttribute("d",t.toSVGPath()),i&&n(this,Ds).set(a,h);const c=m(this,Fn,bf).call(this,o,l),d=It._svgFactory.createElement("use");return r.append(d),r.setAttribute("fill",e),r.setAttribute("fill-opacity",s),d.setAttribute("href",`#${l}`),n(this,At).set(a,r),{id:a,clipPathId:`url(#${c})`}}drawOutline(t){const e=Gt(this,Po)._++,s=m(this,Fn,_c).call(this,t.box);s.classList.add(...t.classNamesForOutlining);const i=It._svgFactory.createElement("defs");s.append(i);const a=It._svgFactory.createElement("path");i.append(a);const r=`path_p${this.pageIndex}_${e}`;a.setAttribute("id",r),a.setAttribute("d",t.toSVGPath()),a.setAttribute("vector-effect","non-scaling-stroke");let o;if(t.mustRemoveSelfIntersections){const c=It._svgFactory.createElement("mask");i.append(c),o=`mask_p${this.pageIndex}_${e}`,c.setAttribute("id",o),c.setAttribute("maskUnits","objectBoundingBox");const d=It._svgFactory.createElement("rect");c.append(d),d.setAttribute("width","1"),d.setAttribute("height","1"),d.setAttribute("fill","white");const f=It._svgFactory.createElement("use");c.append(f),f.setAttribute("href",`#${r}`),f.setAttribute("stroke","none"),f.setAttribute("fill","black"),f.setAttribute("fill-rule","nonzero"),f.classList.add("mask")}const h=It._svgFactory.createElement("use");s.append(h),h.setAttribute("href",`#${r}`),o&&h.setAttribute("mask",`url(#${o})`);const l=h.cloneNode();return s.append(l),h.classList.add("mainOutline"),l.classList.add("secondaryOutline"),n(this,At).set(e,s),e}finalizeLine(t,e){const s=n(this,Ds).get(t);n(this,Ds).delete(t),this.updateBox(t,e.box),s.setAttribute("d",e.toSVGPath())}updateLine(t,e){n(this,At).get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}updatePath(t,e){n(this,Ds).get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){var s;m(s=It,Io,wc).call(s,n(this,At).get(t),e)}show(t,e){n(this,At).get(t).classList.toggle("hidden",!e)}rotate(t,e){n(this,At).get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){n(this,At).get(t).setAttribute("fill",e)}changeOpacity(t,e){n(this,At).get(t).setAttribute("fill-opacity",e)}addClass(t,e){n(this,At).get(t).classList.add(e)}removeClass(t,e){n(this,At).get(t).classList.remove(e)}getSVGRoot(t){return n(this,At).get(t)}remove(t){n(this,Ds).delete(t),n(this,rs)!==null&&(n(this,At).get(t).remove(),n(this,At).delete(t))}destroy(){p(this,rs,null);for(const t of n(this,At).values())t.remove();n(this,At).clear(),n(this,Ds).clear()}};rs=new WeakMap,Po=new WeakMap,At=new WeakMap,Ds=new WeakMap,Io=new WeakSet,wc=function(t,{x:e=0,y:s=0,width:i=1,height:a=1}={}){const{style:r}=t;r.top=100*s+"%",r.left=100*e+"%",r.width=100*i+"%",r.height=100*a+"%"},Fn=new WeakSet,_c=function(t){var s;const e=It._svgFactory.create(1,1,!0);return n(this,rs).append(e),e.setAttribute("aria-hidden",!0),m(s=It,Io,wc).call(s,e,t),e},bf=function(t,e){const s=It._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const a=It._svgFactory.createElement("use");return s.append(a),a.setAttribute("href",`#${e}`),a.classList.add("clip"),i},b(It,Io);let yc=It;var zg=z.AbortException,jg=z.AnnotationEditorLayer,$g=z.AnnotationEditorParamsType,Vg=z.AnnotationEditorType,Gg=z.AnnotationEditorUIManager,Ug=z.AnnotationLayer,qg=z.AnnotationMode,Wg=z.ColorPicker,Xg=z.DOMSVGFactory,Kg=z.DrawLayer,Yg=z.FeatureTest,Qg=z.GlobalWorkerOptions,Jg=z.ImageKind,Zg=z.InvalidPDFException,tm=z.MissingPDFException,em=z.OPS,sm=z.OutputScale,im=z.PDFDataRangeTransport,nm=z.PDFDateString,am=z.PDFWorker,rm=z.PasswordResponses,om=z.PermissionFlag,hm=z.PixelsPerInch,lm=z.RenderingCancelledException,cm=z.TextLayer,dm=z.UnexpectedResponseException,um=z.Util,fm=z.VerbosityLevel,pm=z.XfaLayer,gm=z.build,mm=z.createValidAbsoluteUrl,bm=z.fetchData,Am=z.getDocument,vm=z.getFilenameFromUrl,ym=z.getPdfFilenameFromUrl,wm=z.getXfaPageViewport,_m=z.isDataScheme,xm=z.isPdfFile,Sm=z.noContextMenu,Em=z.normalizeUnicode,Cm=z.setLayerDimensions,Mm=z.shadow,km=z.version;export{zg as AbortException,jg as AnnotationEditorLayer,$g as AnnotationEditorParamsType,Vg as AnnotationEditorType,Gg as AnnotationEditorUIManager,Ug as AnnotationLayer,qg as AnnotationMode,Wg as ColorPicker,Xg as DOMSVGFactory,Kg as DrawLayer,Yg as FeatureTest,Qg as GlobalWorkerOptions,Jg as ImageKind,Zg as InvalidPDFException,tm as MissingPDFException,em as OPS,sm as OutputScale,im as PDFDataRangeTransport,nm as PDFDateString,am as PDFWorker,rm as PasswordResponses,om as PermissionFlag,hm as PixelsPerInch,lm as RenderingCancelledException,cm as TextLayer,dm as UnexpectedResponseException,um as Util,fm as VerbosityLevel,pm as XfaLayer,gm as build,mm as createValidAbsoluteUrl,bm as fetchData,Am as getDocument,vm as getFilenameFromUrl,ym as getPdfFilenameFromUrl,wm as getXfaPageViewport,_m as isDataScheme,xm as isPdfFile,Sm as noContextMenu,Em as normalizeUnicode,Cm as setLayerDimensions,Mm as shadow,km as version};