@imgly/pdf-importer 0.1.0-rc.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/node.cjs ADDED
@@ -0,0 +1,16 @@
1
+ var __import_meta_url__ = require('url').pathToFileURL(__filename).href;
2
+ "use strict";var sb=Object.create;var vr=Object.defineProperty;var rb=Object.getOwnPropertyDescriptor;var ib=Object.getOwnPropertyNames;var ob=Object.getPrototypeOf,ab=Object.prototype.hasOwnProperty;var lb=(i,t)=>()=>(i&&(t=i(i=0)),t);var cb=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),su=(i,t)=>{for(var e in t)vr(i,e,{get:t[e],enumerable:!0})},ru=(i,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ib(t))!ab.call(i,r)&&r!==e&&vr(i,r,{get:()=>t[r],enumerable:!(n=rb(t,r))||n.enumerable});return i};var iu=(i,t,e)=>(e=i!=null?sb(ob(i)):{},ru(t||!i||!i.__esModule?vr(e,"default",{value:i,enumerable:!0}):e,i)),ub=i=>ru(vr({},"__esModule",{value:!0}),i);var Lu={};su(Lu,{AbortException:()=>p0,AnnotationEditorLayer:()=>g0,AnnotationEditorParamsType:()=>m0,AnnotationEditorType:()=>y0,AnnotationEditorUIManager:()=>b0,AnnotationLayer:()=>v0,AnnotationMode:()=>Wa,ColorPicker:()=>x0,DOMSVGFactory:()=>S0,DrawLayer:()=>A0,FeatureTest:()=>T0,GlobalWorkerOptions:()=>C0,ImageKind:()=>E0,InvalidPDFException:()=>w0,MissingPDFException:()=>k0,OPS:()=>I0,OutputScale:()=>R0,PDFDataRangeTransport:()=>P0,PDFDateString:()=>O0,PDFWorker:()=>M0,PasswordResponses:()=>L0,PermissionFlag:()=>F0,PixelsPerInch:()=>D0,RenderingCancelledException:()=>_0,TextLayer:()=>N0,TouchManager:()=>U0,UnexpectedResponseException:()=>B0,Util:()=>G0,VerbosityLevel:()=>H0,XfaLayer:()=>j0,build:()=>V0,createValidAbsoluteUrl:()=>W0,fetchData:()=>$0,getDocument:()=>z0,getFilenameFromUrl:()=>X0,getPdfFilenameFromUrl:()=>Y0,getXfaPageViewport:()=>K0,isDataScheme:()=>Z0,isPdfFile:()=>Q0,noContextMenu:()=>J0,normalizeUnicode:()=>q0,setLayerDimensions:()=>tv,shadow:()=>ev,stopEvent:()=>nv,version:()=>sv});function Ft(i){var t=cu[i];if(t!==void 0)return t.exports;var e=cu[i]={exports:{}};return vb[i].call(e.exports,e,e.exports,Ft),e.exports}function Eb(i){Number.isInteger(i)&&(ii=i)}function wb(){return ii}function oi(i){ii>=ri.INFOS&&console.log(`Info: ${i}`)}function wt(i){ii>=ri.WARNINGS&&console.log(`Warning: ${i}`)}function $t(i){throw new Error(i)}function te(i,t){i||$t(t)}function kb(i){switch(i?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Ib(i,t=null,e=null){if(!i)return null;try{if(e&&typeof i=="string"&&(e.addDefaultProtocol&&i.startsWith("www.")&&i.match(/\./g)?.length>=2&&(i=`http://${i}`),e.tryConvertEncoding))try{i=Mb(i)}catch{}let n=t?new URL(i,t):new URL(i);if(kb(n))return n}catch{}return null}function Ot(i,t,e,n=!1){return Object.defineProperty(i,t,{value:e,enumerable:!n,configurable:!0,writable:!1}),e}function Eu(i){(typeof i!="object"||i?.length===void 0)&&$t("Invalid argument for bytesToString");let t=i.length,e=8192;if(t<e)return String.fromCharCode.apply(null,i);let n=[];for(let r=0;r<t;r+=e){let a=Math.min(r+e,t),l=i.subarray(r,a);n.push(String.fromCharCode.apply(null,l))}return n.join("")}function ai(i){typeof i!="string"&&$t("Invalid argument for stringToBytes");let t=i.length,e=new Uint8Array(t);for(let n=0;n<t;++n)e[n]=i.charCodeAt(n)&255;return e}function Rb(i){return String.fromCharCode(i>>24&255,i>>16&255,i>>8&255,i&255)}function Ga(i){let t=Object.create(null);for(let[e,n]of i)t[e]=n;return t}function Pb(){let i=new Uint8Array(4);return i[0]=1,new Uint32Array(i.buffer,0,1)[0]===1}function Ob(){try{return new Function(""),!0}catch{return!1}}function Mb(i){return decodeURIComponent(escape(i))}function Lb(i){return po||(po=/([\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,uu=new Map([["\uFB05","\u017Ft"]])),i.replaceAll(po,(t,e,n)=>e?e.normalize("NFKC"):uu.get(n))}function Fb(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();let i=new Uint8Array(32);return crypto.getRandomValues(i),Eu(i)}function Db(i){return Uint8Array.prototype.toBase64?i.toBase64():btoa(Eu(i))}async function li(i,t="text"){if(Ts(i,document.baseURI)){let e=await fetch(i);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,n)=>{let r=new XMLHttpRequest;r.open("GET",i,!0),r.responseType=t,r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){if(r.status===200||r.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(r.response);return}e(r.responseText);return}n(new Error(r.statusText))}},r.send(null)})}function ci(i){let t=i.length,e=0;for(;e<t&&i[e].trim()==="";)e++;return i.substring(e,e+5).toLowerCase()==="data:"}function ja(i){return typeof i=="string"&&/\.pdf$/i.test(i)}function _b(i){return[i]=i.split(/[#?]/,1),i.substring(i.lastIndexOf("/")+1)}function Nb(i,t="document.pdf"){if(typeof i!="string")return t;if(ci(i))return wt('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;let e=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,n=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,r=e.exec(i),a=n.exec(r[1])||n.exec(r[2])||n.exec(r[3]);if(a&&(a=a[0],a.includes("%")))try{a=n.exec(decodeURIComponent(a))[0]}catch{}return a||t}function Ts(i,t){try{let{protocol:e}=t?new URL(i,t):new URL(i);return e==="http:"||e==="https:"}catch{return!1}}function He(i){i.preventDefault()}function we(i){i.preventDefault(),i.stopPropagation()}function Ub(i,{scale:t=1,rotation:e=0}){let{width:n,height:r}=i.attributes.style,a=[0,0,parseInt(n),parseInt(r)];return new ws({viewBox:a,userUnit:1,scale:t,rotation:e})}function Va(i){if(i.startsWith("#")){let t=parseInt(i.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return i.startsWith("rgb(")?i.slice(4,-1).split(",").map(t=>parseInt(t)):i.startsWith("rgba(")?i.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(wt(`Not a valid color format: "${i}"`),[0,0,0])}function Bb(i){let t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(let e of i.keys()){t.style.color=e;let n=window.getComputedStyle(t).color;i.set(e,Va(n))}t.remove()}function zt(i){let{a:t,b:e,c:n,d:r,e:a,f:l}=i.getTransform();return[t,e,n,r,a,l]}function Ye(i){let{a:t,b:e,c:n,d:r,e:a,f:l}=i.getTransform().invertSelf();return[t,e,n,r,a,l]}function Ln(i,t,e=!1,n=!0){if(t instanceof ws){let{pageWidth:r,pageHeight:a}=t.rawDims,{style:l}=i,u=se.isCSSRoundSupported,f=`var(--scale-factor) * ${r}px`,g=`var(--scale-factor) * ${a}px`,m=u?`round(down, ${f}, var(--scale-round-x, 1px))`:`calc(${f})`,y=u?`round(down, ${g}, var(--scale-round-y, 1px))`:`calc(${g})`;!e||t.rotation%180===0?(l.width=m,l.height=y):(l.width=y,l.height=m)}n&&i.setAttribute("data-main-rotation",t.rotation)}function Pr(i,t,e){for(let n of e)t.addEventListener(n,i[n].bind(i))}function du(){}function ve(i){if(i instanceof Ze||i instanceof Es||i instanceof Mn||i instanceof kr||i instanceof es||i instanceof Cs)return i;switch(i instanceof Error||typeof i=="object"&&i!==null||$t('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),i.name){case"AbortException":return new Ze(i.message);case"InvalidPDFException":return new Es(i.message);case"MissingPDFException":return new Mn(i.message);case"PasswordException":return new kr(i.message,i.code);case"UnexpectedResponseException":return new es(i.message,i.status);case"UnknownErrorException":return new Cs(i.message,i.details)}return new Cs(i.message,i.toString())}async function wu(i){let e=await process.getBuiltinModule("fs").promises.readFile(i);return new Uint8Array(e)}function _o(i,t){if(!t)return;let e=t[2]-t[0],n=t[3]-t[1],r=new Path2D;r.rect(t[0],t[1],e,n),i.clip(r)}function go(i,t,e,n,r,a,l,u){let f=t.coords,g=t.colors,m=i.data,y=i.width*4,v;f[e+1]>f[n+1]&&(v=e,e=n,n=v,v=a,a=l,l=v),f[n+1]>f[r+1]&&(v=n,n=r,r=v,v=l,l=u,u=v),f[e+1]>f[n+1]&&(v=e,e=n,n=v,v=a,a=l,l=v);let S=(f[e]+t.offsetX)*t.scaleX,T=(f[e+1]+t.offsetY)*t.scaleY,C=(f[n]+t.offsetX)*t.scaleX,k=(f[n+1]+t.offsetY)*t.scaleY,I=(f[r]+t.offsetX)*t.scaleX,O=(f[r+1]+t.offsetY)*t.scaleY;if(T>=O)return;let D=g[a],_=g[a+1],M=g[a+2],B=g[l],H=g[l+1],z=g[l+2],W=g[u],Q=g[u+1],q=g[u+2],bt=Math.round(T),et=Math.round(O),Tt,dt,Y,Z,yt,it,kt,X;for(let at=bt;at<=et;at++){if(at<k){let j=at<T?0:(T-at)/(T-k);Tt=S-(S-C)*j,dt=D-(D-B)*j,Y=_-(_-H)*j,Z=M-(M-z)*j}else{let j;at>O?j=1:k===O?j=0:j=(k-at)/(k-O),Tt=C-(C-I)*j,dt=B-(B-W)*j,Y=H-(H-Q)*j,Z=z-(z-q)*j}let K;at<T?K=0:at>O?K=1:K=(T-at)/(T-O),yt=S-(S-I)*K,it=D-(D-W)*K,kt=_-(_-Q)*K,X=M-(M-q)*K;let nt=Math.round(Math.min(Tt,yt)),ot=Math.round(Math.max(Tt,yt)),V=y*at+nt*4;for(let j=nt;j<=ot;j++)K=(Tt-j)/(Tt-yt),K<0?K=0:K>1&&(K=1),m[V++]=dt-(dt-it)*K|0,m[V++]=Y-(Y-kt)*K|0,m[V++]=Z-(Z-X)*K|0,m[V++]=255}}function Gb(i,t,e){let n=t.coords,r=t.colors,a,l;switch(t.type){case"lattice":let u=t.verticesPerRow,f=Math.floor(n.length/u)-1,g=u-1;for(a=0;a<f;a++){let m=a*u;for(let y=0;y<g;y++,m++)go(i,e,n[m],n[m+1],n[m+u],r[m],r[m+1],r[m+u]),go(i,e,n[m+u+1],n[m+1],n[m+u],r[m+u+1],r[m+1],r[m+u])}break;case"triangles":for(a=0,l=n.length;a<l;a+=3)go(i,e,n[a],n[a+1],n[a+2],r[a],r[a+1],r[a+2]);break;default:throw new Error("illegal figure")}}function Hb(i){switch(i[0]){case"RadialAxial":return new No(i);case"Mesh":return new Uo(i);case"Dummy":return new Bo}throw new Error(`Unknown IR type: ${i[0]}`)}function jb({src:i,srcPos:t=0,dest:e,width:n,height:r,nonBlackColor:a=4294967295,inverseDecode:l=!1}){let u=se.isLittleEndian?4278190080:255,[f,g]=l?[a,u]:[u,a],m=n>>3,y=n&7,v=i.length;e=new Uint32Array(e.buffer);let S=0;for(let T=0;T<r;T++){for(let k=t+m;t<k;t++){let I=t<v?i[t]:255;e[S++]=I&128?g:f,e[S++]=I&64?g:f,e[S++]=I&32?g:f,e[S++]=I&16?g:f,e[S++]=I&8?g:f,e[S++]=I&4?g:f,e[S++]=I&2?g:f,e[S++]=I&1?g:f}if(y===0)continue;let C=t<v?i[t++]:255;for(let k=0;k<y;k++)e[S++]=C&1<<7-k?g:f}return{srcPos:t,destPos:S}}function Wb(i,t){if(i._removeMirroring)throw new Error("Context is already forwarding operations.");i.__originalSave=i.save,i.__originalRestore=i.restore,i.__originalRotate=i.rotate,i.__originalScale=i.scale,i.__originalTranslate=i.translate,i.__originalTransform=i.transform,i.__originalSetTransform=i.setTransform,i.__originalResetTransform=i.resetTransform,i.__originalClip=i.clip,i.__originalMoveTo=i.moveTo,i.__originalLineTo=i.lineTo,i.__originalBezierCurveTo=i.bezierCurveTo,i.__originalRect=i.rect,i.__originalClosePath=i.closePath,i.__originalBeginPath=i.beginPath,i._removeMirroring=()=>{i.save=i.__originalSave,i.restore=i.__originalRestore,i.rotate=i.__originalRotate,i.scale=i.__originalScale,i.translate=i.__originalTranslate,i.transform=i.__originalTransform,i.setTransform=i.__originalSetTransform,i.resetTransform=i.__originalResetTransform,i.clip=i.__originalClip,i.moveTo=i.__originalMoveTo,i.lineTo=i.__originalLineTo,i.bezierCurveTo=i.__originalBezierCurveTo,i.rect=i.__originalRect,i.closePath=i.__originalClosePath,i.beginPath=i.__originalBeginPath,delete i._removeMirroring},i.save=function(){t.save(),this.__originalSave()},i.restore=function(){t.restore(),this.__originalRestore()},i.translate=function(n,r){t.translate(n,r),this.__originalTranslate(n,r)},i.scale=function(n,r){t.scale(n,r),this.__originalScale(n,r)},i.transform=function(n,r,a,l,u,f){t.transform(n,r,a,l,u,f),this.__originalTransform(n,r,a,l,u,f)},i.setTransform=function(n,r,a,l,u,f){t.setTransform(n,r,a,l,u,f),this.__originalSetTransform(n,r,a,l,u,f)},i.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},i.rotate=function(n){t.rotate(n),this.__originalRotate(n)},i.clip=function(n){t.clip(n),this.__originalClip(n)},i.moveTo=function(e,n){t.moveTo(e,n),this.__originalMoveTo(e,n)},i.lineTo=function(e,n){t.lineTo(e,n),this.__originalLineTo(e,n)},i.bezierCurveTo=function(e,n,r,a,l,u){t.bezierCurveTo(e,n,r,a,l,u),this.__originalBezierCurveTo(e,n,r,a,l,u)},i.rect=function(e,n,r,a){t.rect(e,n,r,a),this.__originalRect(e,n,r,a)},i.closePath=function(){t.closePath(),this.__originalClosePath()},i.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}function Ar(i,t,e,n,r,a,l,u,f,g){let[m,y,v,S,T,C]=zt(i);if(y===0&&v===0){let O=l*m+T,D=Math.round(O),_=u*S+C,M=Math.round(_),B=(l+f)*m+T,H=Math.abs(Math.round(B)-D)||1,z=(u+g)*S+C,W=Math.abs(Math.round(z)-M)||1;return i.setTransform(Math.sign(m),0,0,Math.sign(S),D,M),i.drawImage(t,e,n,r,a,0,0,H,W),i.setTransform(m,y,v,S,T,C),[H,W]}if(m===0&&S===0){let O=u*v+T,D=Math.round(O),_=l*y+C,M=Math.round(_),B=(u+g)*v+T,H=Math.abs(Math.round(B)-D)||1,z=(l+f)*y+C,W=Math.abs(Math.round(z)-M)||1;return i.setTransform(0,Math.sign(y),Math.sign(v),0,D,M),i.drawImage(t,e,n,r,a,0,0,W,H),i.setTransform(m,y,v,S,T,C),[W,H]}i.drawImage(t,e,n,r,a,l,u,f,g);let k=Math.hypot(m,y),I=Math.hypot(v,S);return[k*f,I*g]}function $b(i){let{width:t,height:e}=i;if(t>yu||e>yu)return null;let n=1e3,r=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),a=t+1,l=new Uint8Array(a*(e+1)),u,f,g,m=t+7&-8,y=new Uint8Array(m*e),v=0;for(let I of i.data){let O=128;for(;O>0;)y[v++]=I&O?0:255,O>>=1}let S=0;for(v=0,y[v]!==0&&(l[0]=1,++S),f=1;f<t;f++)y[v]!==y[v+1]&&(l[f]=y[v]?2:1,++S),v++;for(y[v]!==0&&(l[f]=2,++S),u=1;u<e;u++){v=u*m,g=u*a,y[v-m]!==y[v]&&(l[g]=y[v]?1:8,++S);let I=(y[v]?4:0)+(y[v-m]?8:0);for(f=1;f<t;f++)I=(I>>2)+(y[v+1]?4:0)+(y[v-m+1]?8:0),r[I]&&(l[g+f]=r[I],++S),v++;if(y[v-m]!==y[v]&&(l[g+f]=y[v]?2:4,++S),S>n)return null}for(v=m*(e-1),g=u*a,y[v]!==0&&(l[g]=8,++S),f=1;f<t;f++)y[v]!==y[v+1]&&(l[g+f]=y[v]?4:8,++S),v++;if(y[v]!==0&&(l[g+f]=4,++S),S>n)return null;let T=new Int32Array([0,a,-1,0,-a,0,0,0,1]),C=new Path2D;for(u=0;S&&u<=e;u++){let I=u*a,O=I+t;for(;I<O&&!l[I];)I++;if(I===O)continue;C.moveTo(I%a,u);let D=I,_=l[I];do{let M=T[_];do I+=M;while(!l[I]);let B=l[I];B!==5&&B!==10?(_=B,l[I]=0):(_=B&51*_>>4,l[I]&=_>>2|_<<2),C.lineTo(I%a,I/a|0),l[I]||--S}while(D!==I);--u}return y=null,l=null,function(I){I.save(),I.scale(1/t,-1/e),I.translate(0,-e),I.fill(C),I.beginPath(),I.restore()}}function bu(i,t){if(t instanceof ImageData){i.putImageData(t,0,0);return}let e=t.height,n=t.width,r=e%xe,a=(e-r)/xe,l=r===0?a:a+1,u=i.createImageData(n,xe),f=0,g,m=t.data,y=u.data,v,S,T,C;if(t.kind===wr.GRAYSCALE_1BPP){let k=m.byteLength,I=new Uint32Array(y.buffer,0,y.byteLength>>2),O=I.length,D=n+7>>3,_=4294967295,M=se.isLittleEndian?4278190080:255;for(v=0;v<l;v++){for(T=v<a?xe:r,g=0,S=0;S<T;S++){let B=k-f,H=0,z=B>D?n:B*8-7,W=z&-8,Q=0,q=0;for(;H<W;H+=8)q=m[f++],I[g++]=q&128?_:M,I[g++]=q&64?_:M,I[g++]=q&32?_:M,I[g++]=q&16?_:M,I[g++]=q&8?_:M,I[g++]=q&4?_:M,I[g++]=q&2?_:M,I[g++]=q&1?_:M;for(;H<z;H++)Q===0&&(q=m[f++],Q=128),I[g++]=q&Q?_:M,Q>>=1}for(;g<O;)I[g++]=0;i.putImageData(u,0,v*xe)}}else if(t.kind===wr.RGBA_32BPP){for(S=0,C=n*xe*4,v=0;v<a;v++)y.set(m.subarray(f,f+C)),f+=C,i.putImageData(u,0,S),S+=xe;v<l&&(C=n*r*4,y.set(m.subarray(f,f+C)),i.putImageData(u,0,S))}else if(t.kind===wr.RGB_24BPP)for(T=xe,C=n*T,v=0;v<l;v++){for(v>=a&&(T=r,C=n*T),g=0,S=C;S--;)y[g++]=m[f++],y[g++]=m[f++],y[g++]=m[f++],y[g++]=255;i.putImageData(u,0,v*xe)}else throw new Error(`bad image kind: ${t.kind}`)}function vu(i,t){if(t.bitmap){i.drawImage(t.bitmap,0,0);return}let e=t.height,n=t.width,r=e%xe,a=(e-r)/xe,l=r===0?a:a+1,u=i.createImageData(n,xe),f=0,g=t.data,m=u.data;for(let y=0;y<l;y++){let v=y<a?xe:r;({srcPos:f}=jb({src:g,srcPos:f,dest:m,width:n,height:v,nonBlackColor:0})),i.putImageData(u,0,y*xe)}}function xs(i,t){let e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(let n of e)i[n]!==void 0&&(t[n]=i[n]);i.setLineDash!==void 0&&(t.setLineDash(i.getLineDash()),t.lineDashOffset=i.lineDashOffset)}function Tr(i){if(i.strokeStyle=i.fillStyle="#000000",i.fillRule="nonzero",i.globalAlpha=1,i.lineWidth=1,i.lineCap="butt",i.lineJoin="miter",i.miterLimit=10,i.globalCompositeOperation="source-over",i.font="10px sans-serif",i.setLineDash!==void 0&&(i.setLineDash([]),i.lineDashOffset=0),!ue){let{filter:t}=i;t!=="none"&&t!==""&&(i.filter="none")}}function xu(i,t){if(t)return!0;let e=St.singularValueDecompose2dScale(i);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);let n=Math.fround((globalThis.devicePixelRatio||1)*yn.PDF_TO_CSS_UNITS);return e[0]<=n&&e[1]<=n}function Kb(i){let t=!0,e=n("filename\\*","i").exec(i);if(e){e=e[1];let m=u(e);return m=unescape(m),m=f(m),m=g(m),a(m)}if(e=l(i),e){let m=g(e);return a(m)}if(e=n("filename","i").exec(i),e){e=e[1];let m=u(e);return m=g(m),a(m)}function n(m,y){return new RegExp("(?:^|;)\\s*"+m+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',y)}function r(m,y){if(m){if(!/^[\x00-\xFF]+$/.test(y))return y;try{let v=new TextDecoder(m,{fatal:!0}),S=ai(y);y=v.decode(S),t=!1}catch{}}return y}function a(m){return t&&/[\x80-\xff]/.test(m)&&(m=r("utf-8",m),t&&(m=r("iso-8859-1",m))),m}function l(m){let y=[],v,S=n("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(v=S.exec(m))!==null;){let[,C,k,I]=v;if(C=parseInt(C,10),C in y){if(C===0)break;continue}y[C]=[k,I]}let T=[];for(let C=0;C<y.length&&C in y;++C){let[k,I]=y[C];I=u(I),k&&(I=unescape(I),C===0&&(I=f(I))),T.push(I)}return T.join("")}function u(m){if(m.startsWith('"')){let y=m.slice(1).split('\\"');for(let v=0;v<y.length;++v){let S=y[v].indexOf('"');S!==-1&&(y[v]=y[v].slice(0,S),y.length=v+1),y[v]=y[v].replaceAll(/\\(.)/g,"$1")}m=y.join('"')}return m}function f(m){let y=m.indexOf("'");if(y===-1)return m;let v=m.slice(0,y),T=m.slice(y+1).replace(/^[^']*'/,"");return r(v,T)}function g(m){return!m.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(m)?m:m.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(y,v,S,T){if(S==="q"||S==="Q")return T=T.replaceAll("_"," "),T=T.replaceAll(/=([0-9a-fA-F]{2})/g,function(C,k){return String.fromCharCode(parseInt(k,16))}),r(v,T);try{T=atob(T)}catch{}return r(v,T)})}return""}function ku(i,t){let e=new Headers;if(!i||!t||typeof t!="object")return e;for(let n in t){let r=t[n];r!==void 0&&e.append(n,r)}return e}function ui(i){try{return new URL(i).origin}catch{}return null}function Iu({responseHeaders:i,isHttp:t,rangeChunkSize:e,disableRange:n}){let r={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(i.get("Content-Length"),10);return!Number.isInteger(a)||(r.suggestedLength=a,a<=2*e)||n||!t||i.get("Accept-Ranges")!=="bytes"||(i.get("Content-Encoding")||"identity")!=="identity"||(r.allowRangeRequests=!0),r}function Ru(i){let t=i.get("Content-Disposition");if(t){let e=Kb(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(ja(e))return e}return null}function hi(i,t){return i===404||i===0&&t.startsWith("file:")?new Mn('Missing PDF "'+t+'".'):new es(`Unexpected server response (${i}) while retrieving PDF "${t}".`,i)}function Pu(i){return i===200||i===206}function Ou(i,t,e){return{method:"GET",headers:i,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function Mu(i){return i instanceof Uint8Array?i.buffer:i instanceof ArrayBuffer?i:(wt(`getArrayBuffer - unexpected data format: ${i}`),new Uint8Array(i).buffer)}function Zb(i){let t=i.response;return typeof t!="string"?t:ai(t).buffer}function Jb(i){if(Qb.test(i))return new URL(i);let t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(i))}function l0(i={}){typeof i=="string"||i instanceof URL?i={url:i}:(i instanceof ArrayBuffer||ArrayBuffer.isView(i))&&(i={data:i});let t=new sa,{docId:e}=t,n=i.url?c0(i.url):null,r=i.data?u0(i.data):null,a=i.httpHeaders||null,l=i.withCredentials===!0,u=i.password??null,f=i.range instanceof Vr?i.range:null,g=Number.isInteger(i.rangeChunkSize)&&i.rangeChunkSize>0?i.rangeChunkSize:e0,m=i.worker instanceof ts?i.worker:null,y=i.verbosity,v=typeof i.docBaseUrl=="string"&&!ci(i.docBaseUrl)?i.docBaseUrl:null,S=typeof i.cMapUrl=="string"?i.cMapUrl:null,T=i.cMapPacked!==!1,C=i.CMapReaderFactory||i0,k=typeof i.standardFontDataUrl=="string"?i.standardFontDataUrl:null,I=i.StandardFontDataFactory||a0,O=i.stopAtErrors!==!0,D=Number.isInteger(i.maxImageSize)&&i.maxImageSize>-1?i.maxImageSize:-1,_=i.isEvalSupported!==!1,M=typeof i.isOffscreenCanvasSupported=="boolean"?i.isOffscreenCanvasSupported:!ue,B=typeof i.isImageDecoderSupported=="boolean"?i.isImageDecoderSupported:!ue&&(se.platform.isFirefox||!globalThis.chrome),H=Number.isInteger(i.canvasMaxAreaInBytes)?i.canvasMaxAreaInBytes:-1,z=typeof i.disableFontFace=="boolean"?i.disableFontFace:ue,W=i.fontExtraProperties===!0,Q=i.enableXfa===!0,q=i.ownerDocument||globalThis.document,bt=i.disableRange===!0,et=i.disableStream===!0,Tt=i.disableAutoFetch===!0,dt=i.pdfBug===!0,Y=i.CanvasFactory||r0,Z=i.FilterFactory||o0,yt=i.enableHWA===!0,it=f?f.length:i.length??NaN,kt=typeof i.useSystemFonts=="boolean"?i.useSystemFonts:!ue&&!z,X=typeof i.useWorkerFetch=="boolean"?i.useWorkerFetch:C===Nr&&I===Gr&&S&&k&&Ts(S,document.baseURI)&&Ts(k,document.baseURI),at=null;Eb(y);let K={canvasFactory:new Y({ownerDocument:q,enableHWA:yt}),filterFactory:new Z({docId:e,ownerDocument:q}),cMapReaderFactory:X?null:new C({baseUrl:S,isCompressed:T}),standardFontDataFactory:X?null:new I({baseUrl:k})};if(!m){let V={verbosity:y,port:On.workerPort};m=V.port?ts.fromPort(V):new ts(V),t._worker=m}let nt={docId:e,apiVersion:"4.10.45",data:r,password:u,disableAutoFetch:Tt,rangeChunkSize:g,length:it,docBaseUrl:v,enableXfa:Q,evaluatorOptions:{maxImageSize:D,disableFontFace:z,ignoreErrors:O,isEvalSupported:_,isOffscreenCanvasSupported:M,isImageDecoderSupported:B,canvasMaxAreaInBytes:H,fontExtraProperties:W,useSystemFonts:kt,cMapUrl:X?S:null,standardFontDataUrl:X?k:null}},ot={disableFontFace:z,fontExtraProperties:W,ownerDocument:q,pdfBug:dt,styleElement:at,loadingParams:{disableAutoFetch:Tt,enableXfa:Q}};return m.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(m.destroyed)throw new Error("Worker was destroyed");let V=m.messageHandler.sendWithPromise("GetDocRequest",nt,r?[r.buffer]:null),j;if(f)j=new $o(f,{disableRange:bt,disableStream:et});else if(!r){if(!n)throw new Error("getDocument - no `url` parameter provided.");let U;if(ue)if(Ts(n)){if(typeof fetch>"u"||typeof Response>"u"||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");U=jr}else U=ta;else U=Ts(n)?jr:Qo;j=new U({url:n,length:it,httpHeaders:a,withCredentials:l,rangeChunkSize:g,disableRange:bt,disableStream:et})}return V.then(U=>{if(t.destroyed)throw new Error("Loading aborted");if(m.destroyed)throw new Error("Worker was destroyed");let lt=new Pn(e,U,m.port),Ct=new aa(lt,t,j,ot,K);t._transport=Ct,lt.send("Ready",null)})}).catch(t._capability.reject),t}function c0(i){if(i instanceof URL)return i.href;try{return new URL(i,window.location).href}catch{if(ue&&typeof i=="string")return i}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function u0(i){if(ue&&typeof Buffer<"u"&&i instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(i instanceof Uint8Array&&i.byteLength===i.buffer.byteLength)return i;if(typeof i=="string")return ai(i);if(i instanceof ArrayBuffer||ArrayBuffer.isView(i)||typeof i=="object"&&!isNaN(i?.length))return new Uint8Array(i);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Au(i){return typeof i=="object"&&Number.isInteger(i?.num)&&i.num>=0&&Number.isInteger(i?.gen)&&i.gen>=0}function Tu(i){return Math.floor(Math.max(0,Math.min(1,i))*255).toString(16).padStart(2,"0")}function As(i){return Math.max(0,Math.min(255,255*i))}function mn(i){return{width:i[2]-i[0],height:i[3]-i[1]}}var vb,cu,Et,tS,eS,nS,sS,rS,iS,oS,aS,lS,cS,uS,hS,ue,Cu,bo,xb,Er,Sb,dS,Ee,gn,Ab,Pt,Mt,Tb,le,wr,ee,vs,ri,Ge,Cb,ii,bn,kr,Cs,Es,Mn,es,vo,Ze,se,fo,St,po,uu,Ha,fS,pS,gS,mS,yS,bS,vS,xS,SS,AS,TS,CS,ES,wS,nn,yn,ws,ks,Ir,Rr,Is,xo,So,Ao,To,Co,Fn,Eo,Dn,Or,Mr,Xt,wo,hu,Oe,Ke,Lr,ko,Rs,Fr,Io,Ro,Sr,qt,Pn,Dr,Po,_r,Nr,kS,Ur,Oo,Br,Gr,Mo,Lo,Fo,Do,ce,Ps,No,Uo,Bo,fu,Go,pu,gu,Vb,mu,yu,xe,Ho,Hr,zb,Xb,Yb,Su,qn,On,jo,Jn,Vo,Wo,$o,zo,Xo,jr,Yo,Ko,mo,yo,Zo,Qo,Jo,qo,Qb,ta,ea,na,qb,be,t0,Os,Ms,e0,n0,s0,r0,i0,o0,a0,sa,Vr,ra,ia,oa,ts,aa,Ss,Wr,la,ca,h0,d0,IS,$r,ua,Ls,zr,Us,f0,_n,ha,Qt,Xr,da,sn,fa,pa,ga,Yr,ma,ya,Fs,ba,Kr,va,xa,Sa,Zr,Aa,Ta,Ds,Qr,Ca,Ea,wa,Jr,ka,Ia,Cr,Ra,ht,qr,ti,_s,Pa,Ns,Oa,ei,ni,Ma,La,Fa,si,Da,_a,Na,Ua,Ba,p0,g0,m0,y0,b0,v0,Wa,x0,S0,A0,T0,C0,E0,w0,k0,I0,R0,P0,O0,M0,L0,F0,D0,_0,N0,U0,B0,G0,H0,j0,V0,W0,$0,z0,X0,Y0,K0,Z0,Q0,J0,q0,tv,ev,nv,sv,$a=lb(()=>{vb={9306:((i,t,e)=>{var n=e(4901),r=e(6823),a=TypeError;i.exports=function(l){if(n(l))return l;throw new a(r(l)+" is not a function")}}),3506:((i,t,e)=>{var n=e(3925),r=String,a=TypeError;i.exports=function(l){if(n(l))return l;throw new a("Can't set "+r(l)+" as a prototype")}}),7080:((i,t,e)=>{var n=e(4402).has;i.exports=function(r){return n(r),r}}),679:((i,t,e)=>{var n=e(1625),r=TypeError;i.exports=function(a,l){if(n(l,a))return a;throw new r("Incorrect invocation")}}),8551:((i,t,e)=>{var n=e(34),r=String,a=TypeError;i.exports=function(l){if(n(l))return l;throw new a(r(l)+" is not an object")}}),7811:(i=>{i.exports=typeof ArrayBuffer<"u"&&typeof DataView<"u"}),7394:((i,t,e)=>{var n=e(4576),r=e(6706),a=e(2195),l=n.ArrayBuffer,u=n.TypeError;i.exports=l&&r(l.prototype,"byteLength","get")||function(f){if(a(f)!=="ArrayBuffer")throw new u("ArrayBuffer expected");return f.byteLength}}),3238:((i,t,e)=>{var n=e(4576),r=e(7476),a=e(7394),l=n.ArrayBuffer,u=l&&l.prototype,f=u&&r(u.slice);i.exports=function(g){if(a(g)!==0||!f)return!1;try{return f(g,0,0),!1}catch{return!0}}}),5169:((i,t,e)=>{var n=e(3238),r=TypeError;i.exports=function(a){if(n(a))throw new r("ArrayBuffer is detached");return a}}),5636:((i,t,e)=>{var n=e(4576),r=e(9504),a=e(6706),l=e(7696),u=e(5169),f=e(7394),g=e(4483),m=e(1548),y=n.structuredClone,v=n.ArrayBuffer,S=n.DataView,T=Math.min,C=v.prototype,k=S.prototype,I=r(C.slice),O=a(C,"resizable","get"),D=a(C,"maxByteLength","get"),_=r(k.getInt8),M=r(k.setInt8);i.exports=(m||g)&&function(B,H,z){var W=f(B),Q=H===void 0?W:l(H),q=!O||!O(B),bt;if(u(B),m&&(B=y(B,{transfer:[B]}),W===Q&&(z||q)))return B;if(W>=Q&&(!z||q))bt=I(B,0,Q);else{var et=z&&!q&&D?{maxByteLength:D(B)}:void 0;bt=new v(Q,et);for(var Tt=new S(B),dt=new S(bt),Y=T(Q,W),Z=0;Z<Y;Z++)M(dt,Z,_(Tt,Z))}return m||g(B),bt}}),4644:((i,t,e)=>{var n=e(7811),r=e(3724),a=e(4576),l=e(4901),u=e(34),f=e(9297),g=e(6955),m=e(6823),y=e(6699),v=e(6840),S=e(2106),T=e(1625),C=e(2787),k=e(2967),I=e(8227),O=e(3392),D=e(1181),_=D.enforce,M=D.get,B=a.Int8Array,H=B&&B.prototype,z=a.Uint8ClampedArray,W=z&&z.prototype,Q=B&&C(B),q=H&&C(H),bt=Object.prototype,et=a.TypeError,Tt=I("toStringTag"),dt=O("TYPED_ARRAY_TAG"),Y="TypedArrayConstructor",Z=n&&!!k&&g(a.opera)!=="Opera",yt=!1,it,kt,X,at={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},K={BigInt64Array:8,BigUint64Array:8},nt=function(Vt){if(!u(Vt))return!1;var Dt=g(Vt);return Dt==="DataView"||f(at,Dt)||f(K,Dt)},ot=function(gt){var Vt=C(gt);if(u(Vt)){var Dt=M(Vt);return Dt&&f(Dt,Y)?Dt[Y]:ot(Vt)}},V=function(gt){if(!u(gt))return!1;var Vt=g(gt);return f(at,Vt)||f(K,Vt)},j=function(gt){if(V(gt))return gt;throw new et("Target is not a typed array")},U=function(gt){if(l(gt)&&(!k||T(Q,gt)))return gt;throw new et(m(gt)+" is not a typed array constructor")},lt=function(gt,Vt,Dt,tt){if(r){if(Dt)for(var ut in at){var Nt=a[ut];if(Nt&&f(Nt.prototype,gt))try{delete Nt.prototype[gt]}catch{try{Nt.prototype[gt]=Vt}catch{}}}(!q[gt]||Dt)&&v(q,gt,Dt?Vt:Z&&H[gt]||Vt,tt)}},Ct=function(gt,Vt,Dt){var tt,ut;if(r){if(k){if(Dt){for(tt in at)if(ut=a[tt],ut&&f(ut,gt))try{delete ut[gt]}catch{}}if(!Q[gt]||Dt)try{return v(Q,gt,Dt?Vt:Z&&Q[gt]||Vt)}catch{}else return}for(tt in at)ut=a[tt],ut&&(!ut[gt]||Dt)&&v(ut,gt,Vt)}};for(it in at)kt=a[it],X=kt&&kt.prototype,X?_(X)[Y]=kt:Z=!1;for(it in K)kt=a[it],X=kt&&kt.prototype,X&&(_(X)[Y]=kt);if((!Z||!l(Q)||Q===Function.prototype)&&(Q=function(){throw new et("Incorrect invocation")},Z))for(it in at)a[it]&&k(a[it],Q);if((!Z||!q||q===bt)&&(q=Q.prototype,Z))for(it in at)a[it]&&k(a[it].prototype,q);if(Z&&C(W)!==q&&k(W,q),r&&!f(q,Tt)){yt=!0,S(q,Tt,{configurable:!0,get:function(){return u(this)?this[dt]:void 0}});for(it in at)a[it]&&y(a[it],dt,it)}i.exports={NATIVE_ARRAY_BUFFER_VIEWS:Z,TYPED_ARRAY_TAG:yt&&dt,aTypedArray:j,aTypedArrayConstructor:U,exportTypedArrayMethod:lt,exportTypedArrayStaticMethod:Ct,getTypedArrayConstructor:ot,isView:nt,isTypedArray:V,TypedArray:Q,TypedArrayPrototype:q}}),5370:((i,t,e)=>{var n=e(6198);i.exports=function(r,a,l){for(var u=0,f=arguments.length>2?l:n(a),g=new r(f);f>u;)g[u]=a[u++];return g}}),9617:((i,t,e)=>{var n=e(5397),r=e(5610),a=e(6198),l=function(u){return function(f,g,m){var y=n(f),v=a(y);if(v===0)return!u&&-1;var S=r(m,v),T;if(u&&g!==g){for(;v>S;)if(T=y[S++],T!==T)return!0}else for(;v>S;S++)if((u||S in y)&&y[S]===g)return u||S||0;return!u&&-1}};i.exports={includes:l(!0),indexOf:l(!1)}}),4527:((i,t,e)=>{var n=e(3724),r=e(4376),a=TypeError,l=Object.getOwnPropertyDescriptor,u=n&&!(function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(f){return f instanceof TypeError}})();i.exports=u?function(f,g){if(r(f)&&!l(f,"length").writable)throw new a("Cannot set read only .length");return f.length=g}:function(f,g){return f.length=g}}),7680:((i,t,e)=>{var n=e(9504);i.exports=n([].slice)}),7628:((i,t,e)=>{var n=e(6198);i.exports=function(r,a){for(var l=n(r),u=new a(l),f=0;f<l;f++)u[f]=r[l-f-1];return u}}),9928:((i,t,e)=>{var n=e(6198),r=e(1291),a=RangeError;i.exports=function(l,u,f,g){var m=n(l),y=r(f),v=y<0?m+y:y;if(v>=m||v<0)throw new a("Incorrect index");for(var S=new u(m),T=0;T<m;T++)S[T]=T===v?g:l[T];return S}}),6319:((i,t,e)=>{var n=e(8551),r=e(9539);i.exports=function(a,l,u,f){try{return f?l(n(u)[0],u[1]):l(u)}catch(g){r(a,"throw",g)}}}),2195:((i,t,e)=>{var n=e(9504),r=n({}.toString),a=n("".slice);i.exports=function(l){return a(r(l),8,-1)}}),6955:((i,t,e)=>{var n=e(2140),r=e(4901),a=e(2195),l=e(8227),u=l("toStringTag"),f=Object,g=a((function(){return arguments})())==="Arguments",m=function(y,v){try{return y[v]}catch{}};i.exports=n?a:function(y){var v,S,T;return y===void 0?"Undefined":y===null?"Null":typeof(S=m(v=f(y),u))=="string"?S:g?a(v):(T=a(v))==="Object"&&r(v.callee)?"Arguments":T}}),7740:((i,t,e)=>{var n=e(9297),r=e(5031),a=e(7347),l=e(4913);i.exports=function(u,f,g){for(var m=r(f),y=l.f,v=a.f,S=0;S<m.length;S++){var T=m[S];!n(u,T)&&!(g&&n(g,T))&&y(u,T,v(f,T))}}}),2211:((i,t,e)=>{var n=e(9039);i.exports=!n(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})}),2529:(i=>{i.exports=function(t,e){return{value:t,done:e}}}),6699:((i,t,e)=>{var n=e(3724),r=e(4913),a=e(6980);i.exports=n?function(l,u,f){return r.f(l,u,a(1,f))}:function(l,u,f){return l[u]=f,l}}),6980:(i=>{i.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}}),4659:((i,t,e)=>{var n=e(3724),r=e(4913),a=e(6980);i.exports=function(l,u,f){n?r.f(l,u,a(0,f)):l[u]=f}}),2106:((i,t,e)=>{var n=e(283),r=e(4913);i.exports=function(a,l,u){return u.get&&n(u.get,l,{getter:!0}),u.set&&n(u.set,l,{setter:!0}),r.f(a,l,u)}}),6840:((i,t,e)=>{var n=e(4901),r=e(4913),a=e(283),l=e(9433);i.exports=function(u,f,g,m){m||(m={});var y=m.enumerable,v=m.name!==void 0?m.name:f;if(n(g)&&a(g,v,m),m.global)y?u[f]=g:l(f,g);else{try{m.unsafe?u[f]&&(y=!0):delete u[f]}catch{}y?u[f]=g:r.f(u,f,{value:g,enumerable:!1,configurable:!m.nonConfigurable,writable:!m.nonWritable})}return u}}),6279:((i,t,e)=>{var n=e(6840);i.exports=function(r,a,l){for(var u in a)n(r,u,a[u],l);return r}}),9433:((i,t,e)=>{var n=e(4576),r=Object.defineProperty;i.exports=function(a,l){try{r(n,a,{value:l,configurable:!0,writable:!0})}catch{n[a]=l}return l}}),3724:((i,t,e)=>{var n=e(9039);i.exports=!n(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})}),4483:((i,t,e)=>{var n=e(4576),r=e(9429),a=e(1548),l=n.structuredClone,u=n.ArrayBuffer,f=n.MessageChannel,g=!1,m,y,v,S;if(a)g=function(T){l(T,{transfer:[T]})};else if(u)try{f||(m=r("worker_threads"),m&&(f=m.MessageChannel)),f&&(y=new f,v=new u(2),S=function(T){y.port1.postMessage(null,[T])},v.byteLength===2&&(S(v),v.byteLength===0&&(g=S)))}catch{}i.exports=g}),4055:((i,t,e)=>{var n=e(4576),r=e(34),a=n.document,l=r(a)&&r(a.createElement);i.exports=function(u){return l?a.createElement(u):{}}}),6837:(i=>{var t=TypeError,e=9007199254740991;i.exports=function(n){if(n>e)throw t("Maximum allowed index exceeded");return n}}),5002:(i=>{i.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}}),8727:(i=>{i.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]}),6193:((i,t,e)=>{var n=e(4215);i.exports=n==="NODE"}),2839:((i,t,e)=>{var n=e(4576),r=n.navigator,a=r&&r.userAgent;i.exports=a?String(a):""}),9519:((i,t,e)=>{var n=e(4576),r=e(2839),a=n.process,l=n.Deno,u=a&&a.versions||l&&l.version,f=u&&u.v8,g,m;f&&(g=f.split("."),m=g[0]>0&&g[0]<4?1:+(g[0]+g[1])),!m&&r&&(g=r.match(/Edge\/(\d+)/),(!g||g[1]>=74)&&(g=r.match(/Chrome\/(\d+)/),g&&(m=+g[1]))),i.exports=m}),4215:((i,t,e)=>{var n=e(4576),r=e(2839),a=e(2195),l=function(u){return r.slice(0,u.length)===u};i.exports=(function(){return l("Bun/")?"BUN":l("Cloudflare-Workers")?"CLOUDFLARE":l("Deno/")?"DENO":l("Node.js/")?"NODE":n.Bun&&typeof Bun.version=="string"?"BUN":n.Deno&&typeof Deno.version=="object"?"DENO":a(n.process)==="process"?"NODE":n.window&&n.document?"BROWSER":"REST"})()}),8574:((i,t,e)=>{var n=e(9504),r=Error,a=n("".replace),l=(function(g){return String(new r(g).stack)})("zxcasd"),u=/\n\s*at [^:]*:[^\n]*/,f=u.test(l);i.exports=function(g,m){if(f&&typeof g=="string"&&!r.prepareStackTrace)for(;m--;)g=a(g,u,"");return g}}),6518:((i,t,e)=>{var n=e(4576),r=e(7347).f,a=e(6699),l=e(6840),u=e(9433),f=e(7740),g=e(2796);i.exports=function(m,y){var v=m.target,S=m.global,T=m.stat,C,k,I,O,D,_;if(S?k=n:T?k=n[v]||u(v,{}):k=n[v]&&n[v].prototype,k)for(I in y){if(D=y[I],m.dontCallGetSet?(_=r(k,I),O=_&&_.value):O=k[I],C=g(S?I:v+(T?".":"#")+I,m.forced),!C&&O!==void 0){if(typeof D==typeof O)continue;f(D,O)}(m.sham||O&&O.sham)&&a(D,"sham",!0),l(k,I,D,m)}}}),9039:(i=>{i.exports=function(t){try{return!!t()}catch{return!0}}}),8745:((i,t,e)=>{var n=e(616),r=Function.prototype,a=r.apply,l=r.call;i.exports=typeof Reflect=="object"&&Reflect.apply||(n?l.bind(a):function(){return l.apply(a,arguments)})}),6080:((i,t,e)=>{var n=e(7476),r=e(9306),a=e(616),l=n(n.bind);i.exports=function(u,f){return r(u),f===void 0?u:a?l(u,f):function(){return u.apply(f,arguments)}}}),616:((i,t,e)=>{var n=e(9039);i.exports=!n(function(){var r=(function(){}).bind();return typeof r!="function"||r.hasOwnProperty("prototype")})}),9565:((i,t,e)=>{var n=e(616),r=Function.prototype.call;i.exports=n?r.bind(r):function(){return r.apply(r,arguments)}}),350:((i,t,e)=>{var n=e(3724),r=e(9297),a=Function.prototype,l=n&&Object.getOwnPropertyDescriptor,u=r(a,"name"),f=u&&(function(){}).name==="something",g=u&&(!n||n&&l(a,"name").configurable);i.exports={EXISTS:u,PROPER:f,CONFIGURABLE:g}}),6706:((i,t,e)=>{var n=e(9504),r=e(9306);i.exports=function(a,l,u){try{return n(r(Object.getOwnPropertyDescriptor(a,l)[u]))}catch{}}}),7476:((i,t,e)=>{var n=e(2195),r=e(9504);i.exports=function(a){if(n(a)==="Function")return r(a)}}),9504:((i,t,e)=>{var n=e(616),r=Function.prototype,a=r.call,l=n&&r.bind.bind(a,a);i.exports=n?l:function(u){return function(){return a.apply(u,arguments)}}}),9429:((i,t,e)=>{var n=e(4576),r=e(6193);i.exports=function(a){if(r){try{return n.process.getBuiltinModule(a)}catch{}try{return Function('return require("'+a+'")')()}catch{}}}}),7751:((i,t,e)=>{var n=e(4576),r=e(4901),a=function(l){return r(l)?l:void 0};i.exports=function(l,u){return arguments.length<2?a(n[l]):n[l]&&n[l][u]}}),1767:(i=>{i.exports=function(t){return{iterator:t,next:t.next,done:!1}}}),8646:((i,t,e)=>{var n=e(9565),r=e(8551),a=e(1767),l=e(851);i.exports=function(u,f){(!f||typeof u!="string")&&r(u);var g=l(u);return a(r(g!==void 0?n(g,u):u))}}),851:((i,t,e)=>{var n=e(6955),r=e(5966),a=e(4117),l=e(6269),u=e(8227),f=u("iterator");i.exports=function(g){if(!a(g))return r(g,f)||r(g,"@@iterator")||l[n(g)]}}),81:((i,t,e)=>{var n=e(9565),r=e(9306),a=e(8551),l=e(6823),u=e(851),f=TypeError;i.exports=function(g,m){var y=arguments.length<2?u(g):m;if(r(y))return a(n(y,g));throw new f(l(g)+" is not iterable")}}),5966:((i,t,e)=>{var n=e(9306),r=e(4117);i.exports=function(a,l){var u=a[l];return r(u)?void 0:n(u)}}),3789:((i,t,e)=>{var n=e(9306),r=e(8551),a=e(9565),l=e(1291),u=e(1767),f="Invalid size",g=RangeError,m=TypeError,y=Math.max,v=function(S,T){this.set=S,this.size=y(T,0),this.has=n(S.has),this.keys=n(S.keys)};v.prototype={getIterator:function(){return u(r(a(this.keys,this.set)))},includes:function(S){return a(this.has,this.set,S)}},i.exports=function(S){r(S);var T=+S.size;if(T!==T)throw new m(f);var C=l(T);if(C<0)throw new g(f);return new v(S,C)}}),4576:(function(i){var t=function(e){return e&&e.Math===Math&&e};i.exports=t(typeof globalThis=="object"&&globalThis)||t(typeof window=="object"&&window)||t(typeof self=="object"&&self)||t(typeof global=="object"&&global)||t(typeof this=="object"&&this)||(function(){return this})()||Function("return this")()}),9297:((i,t,e)=>{var n=e(9504),r=e(8981),a=n({}.hasOwnProperty);i.exports=Object.hasOwn||function(u,f){return a(r(u),f)}}),421:(i=>{i.exports={}}),397:((i,t,e)=>{var n=e(7751);i.exports=n("document","documentElement")}),5917:((i,t,e)=>{var n=e(3724),r=e(9039),a=e(4055);i.exports=!n&&!r(function(){return Object.defineProperty(a("div"),"a",{get:function(){return 7}}).a!==7})}),7055:((i,t,e)=>{var n=e(9504),r=e(9039),a=e(2195),l=Object,u=n("".split);i.exports=r(function(){return!l("z").propertyIsEnumerable(0)})?function(f){return a(f)==="String"?u(f,""):l(f)}:l}),3167:((i,t,e)=>{var n=e(4901),r=e(34),a=e(2967);i.exports=function(l,u,f){var g,m;return a&&n(g=u.constructor)&&g!==f&&r(m=g.prototype)&&m!==f.prototype&&a(l,m),l}}),3706:((i,t,e)=>{var n=e(9504),r=e(4901),a=e(7629),l=n(Function.toString);r(a.inspectSource)||(a.inspectSource=function(u){return l(u)}),i.exports=a.inspectSource}),1181:((i,t,e)=>{var n=e(8622),r=e(4576),a=e(34),l=e(6699),u=e(9297),f=e(7629),g=e(6119),m=e(421),y="Object already initialized",v=r.TypeError,S=r.WeakMap,T,C,k,I=function(M){return k(M)?C(M):T(M,{})},O=function(M){return function(B){var H;if(!a(B)||(H=C(B)).type!==M)throw new v("Incompatible receiver, "+M+" required");return H}};if(n||f.state){var D=f.state||(f.state=new S);D.get=D.get,D.has=D.has,D.set=D.set,T=function(M,B){if(D.has(M))throw new v(y);return B.facade=M,D.set(M,B),B},C=function(M){return D.get(M)||{}},k=function(M){return D.has(M)}}else{var _=g("state");m[_]=!0,T=function(M,B){if(u(M,_))throw new v(y);return B.facade=M,l(M,_,B),B},C=function(M){return u(M,_)?M[_]:{}},k=function(M){return u(M,_)}}i.exports={set:T,get:C,has:k,enforce:I,getterFor:O}}),4209:((i,t,e)=>{var n=e(8227),r=e(6269),a=n("iterator"),l=Array.prototype;i.exports=function(u){return u!==void 0&&(r.Array===u||l[a]===u)}}),4376:((i,t,e)=>{var n=e(2195);i.exports=Array.isArray||function(a){return n(a)==="Array"}}),1108:((i,t,e)=>{var n=e(6955);i.exports=function(r){var a=n(r);return a==="BigInt64Array"||a==="BigUint64Array"}}),4901:(i=>{var t=typeof document=="object"&&document.all;i.exports=typeof t>"u"&&t!==void 0?function(e){return typeof e=="function"||e===t}:function(e){return typeof e=="function"}}),2796:((i,t,e)=>{var n=e(9039),r=e(4901),a=/#|\.prototype\./,l=function(y,v){var S=f[u(y)];return S===m?!0:S===g?!1:r(v)?n(v):!!v},u=l.normalize=function(y){return String(y).replace(a,".").toLowerCase()},f=l.data={},g=l.NATIVE="N",m=l.POLYFILL="P";i.exports=l}),4117:(i=>{i.exports=function(t){return t==null}}),34:((i,t,e)=>{var n=e(4901);i.exports=function(r){return typeof r=="object"?r!==null:n(r)}}),3925:((i,t,e)=>{var n=e(34);i.exports=function(r){return n(r)||r===null}}),6395:(i=>{i.exports=!1}),757:((i,t,e)=>{var n=e(7751),r=e(4901),a=e(1625),l=e(7040),u=Object;i.exports=l?function(f){return typeof f=="symbol"}:function(f){var g=n("Symbol");return r(g)&&a(g.prototype,u(f))}}),507:((i,t,e)=>{var n=e(9565);i.exports=function(r,a,l){for(var u=l?r:r.iterator,f=r.next,g,m;!(g=n(f,u)).done;)if(m=a(g.value),m!==void 0)return m}}),2652:((i,t,e)=>{var n=e(6080),r=e(9565),a=e(8551),l=e(6823),u=e(4209),f=e(6198),g=e(1625),m=e(81),y=e(851),v=e(9539),S=TypeError,T=function(k,I){this.stopped=k,this.result=I},C=T.prototype;i.exports=function(k,I,O){var D=O&&O.that,_=!!(O&&O.AS_ENTRIES),M=!!(O&&O.IS_RECORD),B=!!(O&&O.IS_ITERATOR),H=!!(O&&O.INTERRUPTED),z=n(I,D),W,Q,q,bt,et,Tt,dt,Y=function(yt){return W&&v(W,"normal",yt),new T(!0,yt)},Z=function(yt){return _?(a(yt),H?z(yt[0],yt[1],Y):z(yt[0],yt[1])):H?z(yt,Y):z(yt)};if(M)W=k.iterator;else if(B)W=k;else{if(Q=y(k),!Q)throw new S(l(k)+" is not iterable");if(u(Q)){for(q=0,bt=f(k);bt>q;q++)if(et=Z(k[q]),et&&g(C,et))return et;return new T(!1)}W=m(k,Q)}for(Tt=M?k.next:W.next;!(dt=r(Tt,W)).done;){try{et=Z(dt.value)}catch(yt){v(W,"throw",yt)}if(typeof et=="object"&&et&&g(C,et))return et}return new T(!1)}}),9539:((i,t,e)=>{var n=e(9565),r=e(8551),a=e(5966);i.exports=function(l,u,f){var g,m;r(l);try{if(g=a(l,"return"),!g){if(u==="throw")throw f;return f}g=n(g,l)}catch(y){m=!0,g=y}if(u==="throw")throw f;if(m)throw g;return r(g),f}}),9462:((i,t,e)=>{var n=e(9565),r=e(2360),a=e(6699),l=e(6279),u=e(8227),f=e(1181),g=e(5966),m=e(7657).IteratorPrototype,y=e(2529),v=e(9539),S=u("toStringTag"),T="IteratorHelper",C="WrapForValidIterator",k=f.set,I=function(_){var M=f.getterFor(_?C:T);return l(r(m),{next:function(){var H=M(this);if(_)return H.nextHandler();try{var z=H.done?void 0:H.nextHandler();return y(z,H.done)}catch(W){throw H.done=!0,W}},return:function(){var B=M(this),H=B.iterator;if(B.done=!0,_){var z=g(H,"return");return z?n(z,H):y(void 0,!0)}if(B.inner)try{v(B.inner.iterator,"normal")}catch(W){return v(H,"throw",W)}return H&&v(H,"normal"),y(void 0,!0)}})},O=I(!0),D=I(!1);a(D,S,"Iterator Helper"),i.exports=function(_,M){var B=function(z,W){W?(W.iterator=z.iterator,W.next=z.next):W=z,W.type=M?C:T,W.nextHandler=_,W.counter=0,W.done=!1,k(this,W)};return B.prototype=M?O:D,B}}),713:((i,t,e)=>{var n=e(9565),r=e(9306),a=e(8551),l=e(1767),u=e(9462),f=e(6319),g=u(function(){var m=this.iterator,y=a(n(this.next,m)),v=this.done=!!y.done;if(!v)return f(m,this.mapper,[y.value,this.counter++],!0)});i.exports=function(y){return a(this),r(y),new g(l(this),{mapper:y})}}),7657:((i,t,e)=>{var n=e(9039),r=e(4901),a=e(34),l=e(2360),u=e(2787),f=e(6840),g=e(8227),m=e(6395),y=g("iterator"),v=!1,S,T,C;[].keys&&(C=[].keys(),"next"in C?(T=u(u(C)),T!==Object.prototype&&(S=T)):v=!0);var k=!a(S)||n(function(){var I={};return S[y].call(I)!==I});k?S={}:m&&(S=l(S)),r(S[y])||f(S,y,function(){return this}),i.exports={IteratorPrototype:S,BUGGY_SAFARI_ITERATORS:v}}),6269:(i=>{i.exports={}}),6198:((i,t,e)=>{var n=e(8014);i.exports=function(r){return n(r.length)}}),283:((i,t,e)=>{var n=e(9504),r=e(9039),a=e(4901),l=e(9297),u=e(3724),f=e(350).CONFIGURABLE,g=e(3706),m=e(1181),y=m.enforce,v=m.get,S=String,T=Object.defineProperty,C=n("".slice),k=n("".replace),I=n([].join),O=u&&!r(function(){return T(function(){},"length",{value:8}).length!==8}),D=String(String).split("String"),_=i.exports=function(M,B,H){C(S(B),0,7)==="Symbol("&&(B="["+k(S(B),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),H&&H.getter&&(B="get "+B),H&&H.setter&&(B="set "+B),(!l(M,"name")||f&&M.name!==B)&&(u?T(M,"name",{value:B,configurable:!0}):M.name=B),O&&H&&l(H,"arity")&&M.length!==H.arity&&T(M,"length",{value:H.arity});try{H&&l(H,"constructor")&&H.constructor?u&&T(M,"prototype",{writable:!1}):M.prototype&&(M.prototype=void 0)}catch{}var z=y(M);return l(z,"source")||(z.source=I(D,typeof B=="string"?B:"")),M};Function.prototype.toString=_(function(){return a(this)&&v(this).source||g(this)},"toString")}),741:(i=>{var t=Math.ceil,e=Math.floor;i.exports=Math.trunc||function(r){var a=+r;return(a>0?e:t)(a)}}),6043:((i,t,e)=>{var n=e(9306),r=TypeError,a=function(l){var u,f;this.promise=new l(function(g,m){if(u!==void 0||f!==void 0)throw new r("Bad Promise constructor");u=g,f=m}),this.resolve=n(u),this.reject=n(f)};i.exports.f=function(l){return new a(l)}}),2603:((i,t,e)=>{var n=e(655);i.exports=function(r,a){return r===void 0?arguments.length<2?"":a:n(r)}}),4149:(i=>{var t=RangeError;i.exports=function(e){if(e===e)return e;throw new t("NaN is not allowed")}}),2360:((i,t,e)=>{var n=e(8551),r=e(6801),a=e(8727),l=e(421),u=e(397),f=e(4055),g=e(6119),m=">",y="<",v="prototype",S="script",T=g("IE_PROTO"),C=function(){},k=function(M){return y+S+m+M+y+"/"+S+m},I=function(M){M.write(k("")),M.close();var B=M.parentWindow.Object;return M=null,B},O=function(){var M=f("iframe"),B="java"+S+":",H;return M.style.display="none",u.appendChild(M),M.src=String(B),H=M.contentWindow.document,H.open(),H.write(k("document.F=Object")),H.close(),H.F},D,_=function(){try{D=new ActiveXObject("htmlfile")}catch{}_=typeof document<"u"?document.domain&&D?I(D):O():I(D);for(var M=a.length;M--;)delete _[v][a[M]];return _()};l[T]=!0,i.exports=Object.create||function(B,H){var z;return B!==null?(C[v]=n(B),z=new C,C[v]=null,z[T]=B):z=_(),H===void 0?z:r.f(z,H)}}),6801:((i,t,e)=>{var n=e(3724),r=e(8686),a=e(4913),l=e(8551),u=e(5397),f=e(1072);t.f=n&&!r?Object.defineProperties:function(m,y){l(m);for(var v=u(y),S=f(y),T=S.length,C=0,k;T>C;)a.f(m,k=S[C++],v[k]);return m}}),4913:((i,t,e)=>{var n=e(3724),r=e(5917),a=e(8686),l=e(8551),u=e(6969),f=TypeError,g=Object.defineProperty,m=Object.getOwnPropertyDescriptor,y="enumerable",v="configurable",S="writable";t.f=n?a?function(C,k,I){if(l(C),k=u(k),l(I),typeof C=="function"&&k==="prototype"&&"value"in I&&S in I&&!I[S]){var O=m(C,k);O&&O[S]&&(C[k]=I.value,I={configurable:v in I?I[v]:O[v],enumerable:y in I?I[y]:O[y],writable:!1})}return g(C,k,I)}:g:function(C,k,I){if(l(C),k=u(k),l(I),r)try{return g(C,k,I)}catch{}if("get"in I||"set"in I)throw new f("Accessors not supported");return"value"in I&&(C[k]=I.value),C}}),7347:((i,t,e)=>{var n=e(3724),r=e(9565),a=e(8773),l=e(6980),u=e(5397),f=e(6969),g=e(9297),m=e(5917),y=Object.getOwnPropertyDescriptor;t.f=n?y:function(S,T){if(S=u(S),T=f(T),m)try{return y(S,T)}catch{}if(g(S,T))return l(!r(a.f,S,T),S[T])}}),8480:((i,t,e)=>{var n=e(1828),r=e(8727),a=r.concat("length","prototype");t.f=Object.getOwnPropertyNames||function(u){return n(u,a)}}),3717:((i,t)=>{t.f=Object.getOwnPropertySymbols}),2787:((i,t,e)=>{var n=e(9297),r=e(4901),a=e(8981),l=e(6119),u=e(2211),f=l("IE_PROTO"),g=Object,m=g.prototype;i.exports=u?g.getPrototypeOf:function(y){var v=a(y);if(n(v,f))return v[f];var S=v.constructor;return r(S)&&v instanceof S?S.prototype:v instanceof g?m:null}}),1625:((i,t,e)=>{var n=e(9504);i.exports=n({}.isPrototypeOf)}),1828:((i,t,e)=>{var n=e(9504),r=e(9297),a=e(5397),l=e(9617).indexOf,u=e(421),f=n([].push);i.exports=function(g,m){var y=a(g),v=0,S=[],T;for(T in y)!r(u,T)&&r(y,T)&&f(S,T);for(;m.length>v;)r(y,T=m[v++])&&(~l(S,T)||f(S,T));return S}}),1072:((i,t,e)=>{var n=e(1828),r=e(8727);i.exports=Object.keys||function(l){return n(l,r)}}),8773:((i,t)=>{var e={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor,r=n&&!e.call({1:2},1);t.f=r?function(l){var u=n(this,l);return!!u&&u.enumerable}:e}),2967:((i,t,e)=>{var n=e(6706),r=e(34),a=e(7750),l=e(3506);i.exports=Object.setPrototypeOf||("__proto__"in{}?(function(){var u=!1,f={},g;try{g=n(Object.prototype,"__proto__","set"),g(f,[]),u=f instanceof Array}catch{}return function(y,v){return a(y),l(v),r(y)&&(u?g(y,v):y.__proto__=v),y}})():void 0)}),4270:((i,t,e)=>{var n=e(9565),r=e(4901),a=e(34),l=TypeError;i.exports=function(u,f){var g,m;if(f==="string"&&r(g=u.toString)&&!a(m=n(g,u))||r(g=u.valueOf)&&!a(m=n(g,u))||f!=="string"&&r(g=u.toString)&&!a(m=n(g,u)))return m;throw new l("Can't convert object to primitive value")}}),5031:((i,t,e)=>{var n=e(7751),r=e(9504),a=e(8480),l=e(3717),u=e(8551),f=r([].concat);i.exports=n("Reflect","ownKeys")||function(m){var y=a.f(u(m)),v=l.f;return v?f(y,v(m)):y}}),8235:((i,t,e)=>{var n=e(9504),r=e(9297),a=SyntaxError,l=parseInt,u=String.fromCharCode,f=n("".charAt),g=n("".slice),m=n(/./.exec),y={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":`
3
+ `,"\\r":"\r","\\t":" "},v=/^[\da-f]{4}$/i,S=/^[\u0000-\u001F]$/;i.exports=function(T,C){for(var k=!0,I="";C<T.length;){var O=f(T,C);if(O==="\\"){var D=g(T,C,C+2);if(r(y,D))I+=y[D],C+=2;else if(D==="\\u"){C+=2;var _=g(T,C,C+4);if(!m(v,_))throw new a("Bad Unicode escape at: "+C);I+=u(l(_,16)),C+=4}else throw new a('Unknown escape sequence: "'+D+'"')}else if(O==='"'){k=!1,C++;break}else{if(m(S,O))throw new a("Bad control character in string literal at: "+C);I+=O,C++}}if(k)throw new a("Unterminated string at: "+C);return{value:I,end:C}}}),1103:(i=>{i.exports=function(t){try{return{error:!1,value:t()}}catch(e){return{error:!0,value:e}}}}),7750:((i,t,e)=>{var n=e(4117),r=TypeError;i.exports=function(a){if(n(a))throw new r("Can't call method on "+a);return a}}),9286:((i,t,e)=>{var n=e(4402),r=e(8469),a=n.Set,l=n.add;i.exports=function(u){var f=new a;return r(u,function(g){l(f,g)}),f}}),3440:((i,t,e)=>{var n=e(7080),r=e(4402),a=e(9286),l=e(5170),u=e(3789),f=e(8469),g=e(507),m=r.has,y=r.remove;i.exports=function(S){var T=n(this),C=u(S),k=a(T);return l(T)<=C.size?f(T,function(I){C.includes(I)&&y(k,I)}):g(C.getIterator(),function(I){m(T,I)&&y(k,I)}),k}}),4402:((i,t,e)=>{var n=e(9504),r=Set.prototype;i.exports={Set,add:n(r.add),has:n(r.has),remove:n(r.delete),proto:r}}),8750:((i,t,e)=>{var n=e(7080),r=e(4402),a=e(5170),l=e(3789),u=e(8469),f=e(507),g=r.Set,m=r.add,y=r.has;i.exports=function(S){var T=n(this),C=l(S),k=new g;return a(T)>C.size?f(C.getIterator(),function(I){y(T,I)&&m(k,I)}):u(T,function(I){C.includes(I)&&m(k,I)}),k}}),4449:((i,t,e)=>{var n=e(7080),r=e(4402).has,a=e(5170),l=e(3789),u=e(8469),f=e(507),g=e(9539);i.exports=function(y){var v=n(this),S=l(y);if(a(v)<=S.size)return u(v,function(C){if(S.includes(C))return!1},!0)!==!1;var T=S.getIterator();return f(T,function(C){if(r(v,C))return g(T,"normal",!1)})!==!1}}),3838:((i,t,e)=>{var n=e(7080),r=e(5170),a=e(8469),l=e(3789);i.exports=function(f){var g=n(this),m=l(f);return r(g)>m.size?!1:a(g,function(y){if(!m.includes(y))return!1},!0)!==!1}}),8527:((i,t,e)=>{var n=e(7080),r=e(4402).has,a=e(5170),l=e(3789),u=e(507),f=e(9539);i.exports=function(m){var y=n(this),v=l(m);if(a(y)<v.size)return!1;var S=v.getIterator();return u(S,function(T){if(!r(y,T))return f(S,"normal",!1)})!==!1}}),8469:((i,t,e)=>{var n=e(9504),r=e(507),a=e(4402),l=a.Set,u=a.proto,f=n(u.forEach),g=n(u.keys),m=g(new l).next;i.exports=function(y,v,S){return S?r({iterator:g(y),next:m},v):f(y,v)}}),4916:((i,t,e)=>{var n=e(7751),r=function(a){return{size:a,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}};i.exports=function(a){var l=n("Set");try{new l()[a](r(0));try{return new l()[a](r(-1)),!1}catch{return!0}}catch{return!1}}}),5170:((i,t,e)=>{var n=e(6706),r=e(4402);i.exports=n(r.proto,"size","get")||function(a){return a.size}}),3650:((i,t,e)=>{var n=e(7080),r=e(4402),a=e(9286),l=e(3789),u=e(507),f=r.add,g=r.has,m=r.remove;i.exports=function(v){var S=n(this),T=l(v).getIterator(),C=a(S);return u(T,function(k){g(S,k)?m(C,k):f(C,k)}),C}}),4204:((i,t,e)=>{var n=e(7080),r=e(4402).add,a=e(9286),l=e(3789),u=e(507);i.exports=function(g){var m=n(this),y=l(g).getIterator(),v=a(m);return u(y,function(S){r(v,S)}),v}}),6119:((i,t,e)=>{var n=e(5745),r=e(3392),a=n("keys");i.exports=function(l){return a[l]||(a[l]=r(l))}}),7629:((i,t,e)=>{var n=e(6395),r=e(4576),a=e(9433),l="__core-js_shared__",u=i.exports=r[l]||a(l,{});(u.versions||(u.versions=[])).push({version:"3.39.0",mode:n?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.39.0/LICENSE",source:"https://github.com/zloirock/core-js"})}),5745:((i,t,e)=>{var n=e(7629);i.exports=function(r,a){return n[r]||(n[r]=a||{})}}),1548:((i,t,e)=>{var n=e(4576),r=e(9039),a=e(9519),l=e(4215),u=n.structuredClone;i.exports=!!u&&!r(function(){if(l==="DENO"&&a>92||l==="NODE"&&a>94||l==="BROWSER"&&a>97)return!1;var f=new ArrayBuffer(8),g=u(f,{transfer:[f]});return f.byteLength!==0||g.byteLength!==8})}),4495:((i,t,e)=>{var n=e(9519),r=e(9039),a=e(4576),l=a.String;i.exports=!!Object.getOwnPropertySymbols&&!r(function(){var u=Symbol("symbol detection");return!l(u)||!(Object(u)instanceof Symbol)||!Symbol.sham&&n&&n<41})}),5610:((i,t,e)=>{var n=e(1291),r=Math.max,a=Math.min;i.exports=function(l,u){var f=n(l);return f<0?r(f+u,0):a(f,u)}}),5854:((i,t,e)=>{var n=e(2777),r=TypeError;i.exports=function(a){var l=n(a,"number");if(typeof l=="number")throw new r("Can't convert number to bigint");return BigInt(l)}}),7696:((i,t,e)=>{var n=e(1291),r=e(8014),a=RangeError;i.exports=function(l){if(l===void 0)return 0;var u=n(l),f=r(u);if(u!==f)throw new a("Wrong length or index");return f}}),5397:((i,t,e)=>{var n=e(7055),r=e(7750);i.exports=function(a){return n(r(a))}}),1291:((i,t,e)=>{var n=e(741);i.exports=function(r){var a=+r;return a!==a||a===0?0:n(a)}}),8014:((i,t,e)=>{var n=e(1291),r=Math.min;i.exports=function(a){var l=n(a);return l>0?r(l,9007199254740991):0}}),8981:((i,t,e)=>{var n=e(7750),r=Object;i.exports=function(a){return r(n(a))}}),9590:((i,t,e)=>{var n=e(1291),r=RangeError;i.exports=function(a){var l=n(a);if(l<0)throw new r("The argument can't be less than 0");return l}}),2777:((i,t,e)=>{var n=e(9565),r=e(34),a=e(757),l=e(5966),u=e(4270),f=e(8227),g=TypeError,m=f("toPrimitive");i.exports=function(y,v){if(!r(y)||a(y))return y;var S=l(y,m),T;if(S){if(v===void 0&&(v="default"),T=n(S,y,v),!r(T)||a(T))return T;throw new g("Can't convert object to primitive value")}return v===void 0&&(v="number"),u(y,v)}}),6969:((i,t,e)=>{var n=e(2777),r=e(757);i.exports=function(a){var l=n(a,"string");return r(l)?l:l+""}}),2140:((i,t,e)=>{var n=e(8227),r=n("toStringTag"),a={};a[r]="z",i.exports=String(a)==="[object z]"}),655:((i,t,e)=>{var n=e(6955),r=String;i.exports=function(a){if(n(a)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return r(a)}}),6823:(i=>{var t=String;i.exports=function(e){try{return t(e)}catch{return"Object"}}}),3392:((i,t,e)=>{var n=e(9504),r=0,a=Math.random(),l=n(1 .toString);i.exports=function(u){return"Symbol("+(u===void 0?"":u)+")_"+l(++r+a,36)}}),7040:((i,t,e)=>{var n=e(4495);i.exports=n&&!Symbol.sham&&typeof Symbol.iterator=="symbol"}),8686:((i,t,e)=>{var n=e(3724),r=e(9039);i.exports=n&&r(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})}),2812:(i=>{var t=TypeError;i.exports=function(e,n){if(e<n)throw new t("Not enough arguments");return e}}),8622:((i,t,e)=>{var n=e(4576),r=e(4901),a=n.WeakMap;i.exports=r(a)&&/native code/.test(String(a))}),8227:((i,t,e)=>{var n=e(4576),r=e(5745),a=e(9297),l=e(3392),u=e(4495),f=e(7040),g=n.Symbol,m=r("wks"),y=f?g.for||g:g&&g.withoutSetter||l;i.exports=function(v){return a(m,v)||(m[v]=u&&a(g,v)?g[v]:y("Symbol."+v)),m[v]}}),6573:((i,t,e)=>{var n=e(3724),r=e(2106),a=e(3238),l=ArrayBuffer.prototype;n&&!("detached"in l)&&r(l,"detached",{configurable:!0,get:function(){return a(this)}})}),7936:((i,t,e)=>{var n=e(6518),r=e(5636);r&&n({target:"ArrayBuffer",proto:!0},{transferToFixedLength:function(){return r(this,arguments.length?arguments[0]:void 0,!1)}})}),8100:((i,t,e)=>{var n=e(6518),r=e(5636);r&&n({target:"ArrayBuffer",proto:!0},{transfer:function(){return r(this,arguments.length?arguments[0]:void 0,!0)}})}),4114:((i,t,e)=>{var n=e(6518),r=e(8981),a=e(6198),l=e(4527),u=e(6837),f=e(9039),g=f(function(){return[].push.call({length:4294967296},1)!==4294967297}),m=function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(v){return v instanceof TypeError}},y=g||!m();n({target:"Array",proto:!0,arity:1,forced:y},{push:function(S){var T=r(this),C=a(T),k=arguments.length;u(C+k);for(var I=0;I<k;I++)T[C]=arguments[I],C++;return l(T,C),C}})}),8111:((i,t,e)=>{var n=e(6518),r=e(4576),a=e(679),l=e(8551),u=e(4901),f=e(2787),g=e(2106),m=e(4659),y=e(9039),v=e(9297),S=e(8227),T=e(7657).IteratorPrototype,C=e(3724),k=e(6395),I="constructor",O="Iterator",D=S("toStringTag"),_=TypeError,M=r[O],B=k||!u(M)||M.prototype!==T||!y(function(){M({})}),H=function(){if(a(this,T),f(this)===T)throw new _("Abstract class Iterator not directly constructable")},z=function(W,Q){C?g(T,W,{configurable:!0,get:function(){return Q},set:function(q){if(l(this),this===T)throw new _("You can't redefine this property");v(this,W)?this[W]=q:m(this,W,q)}}):T[W]=Q};v(T,D)||z(D,O),(B||!v(T,I)||T[I]===Object)&&z(I,H),H.prototype=T,n({global:!0,constructor:!0,forced:B},{Iterator:H})}),9314:((i,t,e)=>{var n=e(6518),r=e(9565),a=e(8551),l=e(1767),u=e(4149),f=e(9590),g=e(9462),m=e(6395),y=g(function(){for(var v=this.iterator,S=this.next,T,C;this.remaining;)if(this.remaining--,T=a(r(S,v)),C=this.done=!!T.done,C)return;if(T=a(r(S,v)),C=this.done=!!T.done,!C)return T.value});n({target:"Iterator",proto:!0,real:!0,forced:m},{drop:function(S){a(this);var T=f(u(+S));return new y(l(this),{remaining:T})}})}),1148:((i,t,e)=>{var n=e(6518),r=e(2652),a=e(9306),l=e(8551),u=e(1767);n({target:"Iterator",proto:!0,real:!0},{every:function(g){l(this),a(g);var m=u(this),y=0;return!r(m,function(v,S){if(!g(v,y++))return S()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})}),2489:((i,t,e)=>{var n=e(6518),r=e(9565),a=e(9306),l=e(8551),u=e(1767),f=e(9462),g=e(6319),m=e(6395),y=f(function(){for(var v=this.iterator,S=this.predicate,T=this.next,C,k,I;;){if(C=l(r(T,v)),k=this.done=!!C.done,k)return;if(I=C.value,g(v,S,[I,this.counter++],!0))return I}});n({target:"Iterator",proto:!0,real:!0,forced:m},{filter:function(S){return l(this),a(S),new y(u(this),{predicate:S})}})}),531:((i,t,e)=>{var n=e(6518),r=e(9565),a=e(9306),l=e(8551),u=e(1767),f=e(8646),g=e(9462),m=e(9539),y=e(6395),v=g(function(){for(var S=this.iterator,T=this.mapper,C,k;;){if(k=this.inner)try{if(C=l(r(k.next,k.iterator)),!C.done)return C.value;this.inner=null}catch(I){m(S,"throw",I)}if(C=l(r(this.next,S)),this.done=!!C.done)return;try{this.inner=f(T(C.value,this.counter++),!1)}catch(I){m(S,"throw",I)}}});n({target:"Iterator",proto:!0,real:!0,forced:y},{flatMap:function(T){return l(this),a(T),new v(u(this),{mapper:T,inner:null})}})}),1701:((i,t,e)=>{var n=e(6518),r=e(713),a=e(6395);n({target:"Iterator",proto:!0,real:!0,forced:a},{map:r})}),3579:((i,t,e)=>{var n=e(6518),r=e(2652),a=e(9306),l=e(8551),u=e(1767);n({target:"Iterator",proto:!0,real:!0},{some:function(g){l(this),a(g);var m=u(this),y=0;return r(m,function(v,S){if(g(v,y++))return S()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})}),1689:((i,t,e)=>{var n=e(6518),r=e(4576),a=e(8745),l=e(7680),u=e(6043),f=e(9306),g=e(1103),m=r.Promise,y=!1,v=!m||!m.try||g(function(){m.try(function(S){y=S===8},8)}).error||!y;n({target:"Promise",stat:!0,forced:v},{try:function(S){var T=arguments.length>1?l(arguments,1):[],C=u.f(this),k=g(function(){return a(f(S),void 0,T)});return(k.error?C.reject:C.resolve)(k.value),C.promise}})}),4628:((i,t,e)=>{var n=e(6518),r=e(6043);n({target:"Promise",stat:!0},{withResolvers:function(){var l=r.f(this);return{promise:l.promise,resolve:l.resolve,reject:l.reject}}})}),7642:((i,t,e)=>{var n=e(6518),r=e(3440),a=e(4916);n({target:"Set",proto:!0,real:!0,forced:!a("difference")},{difference:r})}),8004:((i,t,e)=>{var n=e(6518),r=e(9039),a=e(8750),l=e(4916),u=!l("intersection")||r(function(){return String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))!=="3,2"});n({target:"Set",proto:!0,real:!0,forced:u},{intersection:a})}),3853:((i,t,e)=>{var n=e(6518),r=e(4449),a=e(4916);n({target:"Set",proto:!0,real:!0,forced:!a("isDisjointFrom")},{isDisjointFrom:r})}),5876:((i,t,e)=>{var n=e(6518),r=e(3838),a=e(4916);n({target:"Set",proto:!0,real:!0,forced:!a("isSubsetOf")},{isSubsetOf:r})}),2475:((i,t,e)=>{var n=e(6518),r=e(8527),a=e(4916);n({target:"Set",proto:!0,real:!0,forced:!a("isSupersetOf")},{isSupersetOf:r})}),5024:((i,t,e)=>{var n=e(6518),r=e(3650),a=e(4916);n({target:"Set",proto:!0,real:!0,forced:!a("symmetricDifference")},{symmetricDifference:r})}),1698:((i,t,e)=>{var n=e(6518),r=e(4204),a=e(4916);n({target:"Set",proto:!0,real:!0,forced:!a("union")},{union:r})}),7467:((i,t,e)=>{var n=e(7628),r=e(4644),a=r.aTypedArray,l=r.exportTypedArrayMethod,u=r.getTypedArrayConstructor;l("toReversed",function(){return n(a(this),u(this))})}),4732:((i,t,e)=>{var n=e(4644),r=e(9504),a=e(9306),l=e(5370),u=n.aTypedArray,f=n.getTypedArrayConstructor,g=n.exportTypedArrayMethod,m=r(n.TypedArrayPrototype.sort);g("toSorted",function(v){v!==void 0&&a(v);var S=u(this),T=l(f(S),S);return m(T,v)})}),9577:((i,t,e)=>{var n=e(9928),r=e(4644),a=e(1108),l=e(1291),u=e(5854),f=r.aTypedArray,g=r.getTypedArrayConstructor,m=r.exportTypedArrayMethod,y=!!(function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(v){return v===8}})();m("with",function(v,S){var T=f(this),C=l(v),k=a(T)?u(S):+S;return n(T,g(T),C,k)},!y)}),8992:((i,t,e)=>{e(8111)}),4743:((i,t,e)=>{e(9314)}),3215:((i,t,e)=>{e(1148)}),4520:((i,t,e)=>{e(2489)}),670:((i,t,e)=>{e(531)}),1454:((i,t,e)=>{e(1701)}),7550:((i,t,e)=>{e(3579)}),8335:((i,t,e)=>{var n=e(6518),r=e(3724),a=e(4576),l=e(7751),u=e(9504),f=e(9565),g=e(4901),m=e(34),y=e(4376),v=e(9297),S=e(655),T=e(6198),C=e(4659),k=e(9039),I=e(8235),O=e(4495),D=a.JSON,_=a.Number,M=a.SyntaxError,B=D&&D.parse,H=l("Object","keys"),z=Object.getOwnPropertyDescriptor,W=u("".charAt),Q=u("".slice),q=u(/./.exec),bt=u([].push),et=/^\d$/,Tt=/^[1-9]$/,dt=/^[\d-]$/,Y=/^[\t\n\r ]$/,Z=0,yt=1,it=function(V,j){V=S(V);var U=new K(V,0,""),lt=U.parse(),Ct=lt.value,gt=U.skip(Y,lt.end);if(gt<V.length)throw new M('Unexpected extra character: "'+W(V,gt)+'" after the parsed data at: '+gt);return g(j)?kt({"":Ct},"",j,lt):Ct},kt=function(V,j,U,lt){var Ct=V[j],gt=lt&&Ct===lt.value,Vt=gt&&typeof lt.source=="string"?{source:lt.source}:{},Dt,tt,ut,Nt,Le;if(m(Ct)){var rn=y(Ct),Je=gt?lt.nodes:rn?[]:{};if(rn)for(Dt=Je.length,ut=T(Ct),Nt=0;Nt<ut;Nt++)X(Ct,Nt,kt(Ct,""+Nt,U,Nt<Dt?Je[Nt]:void 0));else for(tt=H(Ct),ut=T(tt),Nt=0;Nt<ut;Nt++)Le=tt[Nt],X(Ct,Le,kt(Ct,Le,U,v(Je,Le)?Je[Le]:void 0))}return f(U,V,j,Ct,Vt)},X=function(V,j,U){if(r){var lt=z(V,j);if(lt&&!lt.configurable)return}U===void 0?delete V[j]:C(V,j,U)},at=function(V,j,U,lt){this.value=V,this.end=j,this.source=U,this.nodes=lt},K=function(V,j){this.source=V,this.index=j};K.prototype={fork:function(V){return new K(this.source,V)},parse:function(){var V=this.source,j=this.skip(Y,this.index),U=this.fork(j),lt=W(V,j);if(q(dt,lt))return U.number();switch(lt){case"{":return U.object();case"[":return U.array();case'"':return U.string();case"t":return U.keyword(!0);case"f":return U.keyword(!1);case"n":return U.keyword(null)}throw new M('Unexpected character: "'+lt+'" at: '+j)},node:function(V,j,U,lt,Ct){return new at(j,lt,V?null:Q(this.source,U,lt),Ct)},object:function(){for(var V=this.source,j=this.index+1,U=!1,lt={},Ct={};j<V.length;){if(j=this.until(['"',"}"],j),W(V,j)==="}"&&!U){j++;break}var gt=this.fork(j).string(),Vt=gt.value;j=gt.end,j=this.until([":"],j)+1,j=this.skip(Y,j),gt=this.fork(j).parse(),C(Ct,Vt,gt),C(lt,Vt,gt.value),j=this.until([",","}"],gt.end);var Dt=W(V,j);if(Dt===",")U=!0,j++;else if(Dt==="}"){j++;break}}return this.node(yt,lt,this.index,j,Ct)},array:function(){for(var V=this.source,j=this.index+1,U=!1,lt=[],Ct=[];j<V.length;){if(j=this.skip(Y,j),W(V,j)==="]"&&!U){j++;break}var gt=this.fork(j).parse();if(bt(Ct,gt),bt(lt,gt.value),j=this.until([",","]"],gt.end),W(V,j)===",")U=!0,j++;else if(W(V,j)==="]"){j++;break}}return this.node(yt,lt,this.index,j,Ct)},string:function(){var V=this.index,j=I(this.source,this.index+1);return this.node(Z,j.value,V,j.end)},number:function(){var V=this.source,j=this.index,U=j;if(W(V,U)==="-"&&U++,W(V,U)==="0")U++;else if(q(Tt,W(V,U)))U=this.skip(et,U+1);else throw new M("Failed to parse number at: "+U);if(W(V,U)==="."&&(U=this.skip(et,U+1)),W(V,U)==="e"||W(V,U)==="E"){U++,(W(V,U)==="+"||W(V,U)==="-")&&U++;var lt=U;if(U=this.skip(et,U),lt===U)throw new M("Failed to parse number's exponent value at: "+U)}return this.node(Z,_(Q(V,j,U)),j,U)},keyword:function(V){var j=""+V,U=this.index,lt=U+j.length;if(Q(this.source,U,lt)!==j)throw new M("Failed to parse value at: "+U);return this.node(Z,V,U,lt)},skip:function(V,j){for(var U=this.source;j<U.length&&q(V,W(U,j));j++);return j},until:function(V,j){j=this.skip(Y,j);for(var U=W(this.source,j),lt=0;lt<V.length;lt++)if(V[lt]===U)return j;throw new M('Unexpected character: "'+U+'" at: '+j)}};var nt=k(function(){var V="9007199254740993",j;return B(V,function(U,lt,Ct){j=Ct.source}),j!==V}),ot=O&&!k(function(){return 1/B("-0 ")!==-1/0});n({target:"JSON",stat:!0,forced:nt},{parse:function(j,U){return ot&&!g(U)?B(j):it(j,U)}})}),5247:((i,t,e)=>{e(1689)}),4979:((i,t,e)=>{var n=e(6518),r=e(4576),a=e(7751),l=e(6980),u=e(4913).f,f=e(9297),g=e(679),m=e(3167),y=e(2603),v=e(5002),S=e(8574),T=e(3724),C=e(6395),k="DOMException",I=a("Error"),O=a(k),D=function(){g(this,_);var Y=arguments.length,Z=y(Y<1?void 0:arguments[0]),yt=y(Y<2?void 0:arguments[1],"Error"),it=new O(Z,yt),kt=new I(Z);return kt.name=k,u(it,"stack",l(1,S(kt.stack,1))),m(it,this,D),it},_=D.prototype=O.prototype,M="stack"in new I(k),B="stack"in new O(1,2),H=O&&T&&Object.getOwnPropertyDescriptor(r,k),z=!!H&&!(H.writable&&H.configurable),W=M&&!z&&!B;n({global:!0,constructor:!0,forced:C||W},{DOMException:W?D:O});var Q=a(k),q=Q.prototype;if(q.constructor!==Q){C||u(q,"constructor",l(1,Q));for(var bt in v)if(f(v,bt)){var et=v[bt],Tt=et.s;f(Q,Tt)||u(Q,Tt,l(6,et.c))}}}),4603:((i,t,e)=>{var n=e(6840),r=e(9504),a=e(655),l=e(2812),u=URLSearchParams,f=u.prototype,g=r(f.append),m=r(f.delete),y=r(f.forEach),v=r([].push),S=new u("a=1&a=2&b=3");S.delete("a",1),S.delete("b",void 0),S+""!="a=2"&&n(f,"delete",function(T){var C=arguments.length,k=C<2?void 0:arguments[1];if(C&&k===void 0)return m(this,T);var I=[];y(this,function(W,Q){v(I,{key:Q,value:W})}),l(C,1);for(var O=a(T),D=a(k),_=0,M=0,B=!1,H=I.length,z;_<H;)z=I[_++],B||z.key===O?(B=!0,m(this,z.key)):M++;for(;M<H;)z=I[M++],z.key===O&&z.value===D||g(this,z.key,z.value)},{enumerable:!0,unsafe:!0})}),7566:((i,t,e)=>{var n=e(6840),r=e(9504),a=e(655),l=e(2812),u=URLSearchParams,f=u.prototype,g=r(f.getAll),m=r(f.has),y=new u("a=1");(y.has("a",2)||!y.has("a",void 0))&&n(f,"has",function(S){var T=arguments.length,C=T<2?void 0:arguments[1];if(T&&C===void 0)return m(this,S);var k=g(this,S);l(T,1);for(var I=a(C),O=0;O<k.length;)if(k[O++]===I)return!0;return!1},{enumerable:!0,unsafe:!0})}),8721:((i,t,e)=>{var n=e(3724),r=e(9504),a=e(2106),l=URLSearchParams.prototype,u=r(l.forEach);n&&!("size"in l)&&a(l,"size",{get:function(){var g=0;return u(this,function(){g++}),g},configurable:!0,enumerable:!0})})},cu={};Ft.d=(i,t)=>{for(var e in t)Ft.o(t,e)&&!Ft.o(i,e)&&Object.defineProperty(i,e,{enumerable:!0,get:t[e]})};Ft.o=(i,t)=>Object.prototype.hasOwnProperty.call(i,t);Et=globalThis.pdfjsLib={};Ft.d(Et,{AbortException:()=>Ze,AnnotationEditorLayer:()=>Ua,AnnotationEditorParamsType:()=>Mt,AnnotationEditorType:()=>Pt,AnnotationEditorUIManager:()=>Dn,AnnotationLayer:()=>Ia,AnnotationMode:()=>gn,ColorPicker:()=>ei,DOMSVGFactory:()=>Ls,DrawLayer:()=>Ba,FeatureTest:()=>se,GlobalWorkerOptions:()=>On,ImageKind:()=>wr,InvalidPDFException:()=>Es,MissingPDFException:()=>Mn,OPS:()=>Ge,OutputScale:()=>Is,PDFDataRangeTransport:()=>Vr,PDFDateString:()=>Rr,PDFWorker:()=>ts,PasswordResponses:()=>Cb,PermissionFlag:()=>Tb,PixelsPerInch:()=>yn,RenderingCancelledException:()=>ks,TextLayer:()=>Os,TouchManager:()=>Mr,UnexpectedResponseException:()=>es,Util:()=>St,VerbosityLevel:()=>ri,XfaLayer:()=>zr,build:()=>d0,createValidAbsoluteUrl:()=>Ib,fetchData:()=>li,getDocument:()=>l0,getFilenameFromUrl:()=>_b,getPdfFilenameFromUrl:()=>Nb,getXfaPageViewport:()=>Ub,isDataScheme:()=>ci,isPdfFile:()=>ja,noContextMenu:()=>He,normalizeUnicode:()=>Lb,setLayerDimensions:()=>Ln,shadow:()=>Ot,stopEvent:()=>we,version:()=>h0});tS=Ft(4114),eS=Ft(6573),nS=Ft(8100),sS=Ft(7936),rS=Ft(7467),iS=Ft(4732),oS=Ft(9577),aS=Ft(5247),lS=Ft(4979),cS=Ft(4603),uS=Ft(7566),hS=Ft(8721),ue=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Cu=[1,0,0,1,0,0],bo=[.001,0,0,.001,0,0],xb=1e7,Er=1.35,Sb=.35,dS=Sb/Er,Ee={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},gn={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Ab="pdfjs_internal_editor_",Pt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},Mt={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,DRAW_STEP:41},Tb={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},le={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},wr={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},ee={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},vs={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},ri={ERRORS:0,WARNINGS:1,INFOS:5},Ge={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},Cb={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},ii=ri.WARNINGS;bn=(function(){function t(e,n){this.message=e,this.name=n}return t.prototype=new Error,t.constructor=t,t})(),kr=class extends bn{constructor(t,e){super(t,"PasswordException"),this.code=e}},Cs=class extends bn{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}},Es=class extends bn{constructor(t){super(t,"InvalidPDFException")}},Mn=class extends bn{constructor(t){super(t,"MissingPDFException")}},es=class extends bn{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}},vo=class extends bn{constructor(t){super(t,"FormatError")}},Ze=class extends bn{constructor(t){super(t,"AbortException")}};se=class{static get isLittleEndian(){return Ot(this,"isLittleEndian",Pb())}static get isEvalSupported(){return Ot(this,"isEvalSupported",Ob())}static get isOffscreenCanvasSupported(){return Ot(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return Ot(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){return typeof navigator<"u"&&typeof navigator?.platform=="string"?Ot(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof navigator?.userAgent=="string"&&navigator.userAgent.includes("Firefox")}):Ot(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return Ot(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}},fo=Array.from(Array(256).keys(),i=>i.toString(16).padStart(2,"0")),St=class{static makeHexColor(t,e,n){return`#${fo[t]}${fo[e]}${fo[n]}`}static scaleMinMax(t,e){let n;t[0]?(t[0]<0&&(n=e[0],e[0]=e[2],e[2]=n),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(n=e[1],e[1]=e[3],e[3]=n),e[1]*=t[3],e[3]*=t[3]):(n=e[0],e[0]=e[1],e[1]=n,n=e[2],e[2]=e[3],e[3]=n,t[1]<0&&(n=e[1],e[1]=e[3],e[3]=n),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(n=e[0],e[0]=e[2],e[2]=n),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){let n=t[0]*e[0]+t[1]*e[2]+e[4],r=t[0]*e[1]+t[1]*e[3]+e[5];return[n,r]}static applyInverseTransform(t,e){let n=e[0]*e[3]-e[1]*e[2],r=(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/n,a=(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/n;return[r,a]}static getAxialAlignedBoundingBox(t,e){let n=this.applyTransform(t,e),r=this.applyTransform(t.slice(2,4),e),a=this.applyTransform([t[0],t[3]],e),l=this.applyTransform([t[2],t[1]],e);return[Math.min(n[0],r[0],a[0],l[0]),Math.min(n[1],r[1],a[1],l[1]),Math.max(n[0],r[0],a[0],l[0]),Math.max(n[1],r[1],a[1],l[1])]}static inverseTransform(t){let 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){let e=[t[0],t[2],t[1],t[3]],n=t[0]*e[0]+t[1]*e[2],r=t[0]*e[1]+t[1]*e[3],a=t[2]*e[0]+t[3]*e[2],l=t[2]*e[1]+t[3]*e[3],u=(n+l)/2,f=Math.sqrt((n+l)**2-4*(n*l-a*r))/2,g=u+f||1,m=u-f||1;return[Math.sqrt(g),Math.sqrt(m)]}static normalizeRect(t){let 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){let n=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),r=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(n>r)return null;let a=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),l=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return a>l?null:[n,a,r,l]}static#t(t,e,n,r,a,l,u,f,g,m){if(g<=0||g>=1)return;let y=1-g,v=g*g,S=v*g,T=y*(y*(y*t+3*g*e)+3*v*n)+S*r,C=y*(y*(y*a+3*g*l)+3*v*u)+S*f;m[0]=Math.min(m[0],T),m[1]=Math.min(m[1],C),m[2]=Math.max(m[2],T),m[3]=Math.max(m[3],C)}static#e(t,e,n,r,a,l,u,f,g,m,y,v){if(Math.abs(g)<1e-12){Math.abs(m)>=1e-12&&this.#t(t,e,n,r,a,l,u,f,-y/m,v);return}let S=m**2-4*y*g;if(S<0)return;let T=Math.sqrt(S),C=2*g;this.#t(t,e,n,r,a,l,u,f,(-m+T)/C,v),this.#t(t,e,n,r,a,l,u,f,(-m-T)/C,v)}static bezierBoundingBox(t,e,n,r,a,l,u,f,g){return g?(g[0]=Math.min(g[0],t,u),g[1]=Math.min(g[1],e,f),g[2]=Math.max(g[2],t,u),g[3]=Math.max(g[3],e,f)):g=[Math.min(t,u),Math.min(e,f),Math.max(t,u),Math.max(e,f)],this.#e(t,n,a,u,e,r,l,f,3*(-t+3*(n-a)+u),6*(t-2*n+a),3*(n-t),g),this.#e(t,n,a,u,e,r,l,f,3*(-e+3*(r-l)+f),6*(e-2*r+l),3*(r-e),g),g}};po=null,uu=null;Ha="pdfjs_internal_id_";fS=Ft(4628),pS=Ft(7642),gS=Ft(8004),mS=Ft(3853),yS=Ft(5876),bS=Ft(2475),vS=Ft(5024),xS=Ft(1698),SS=Ft(1454),AS=Ft(8992),TS=Ft(4743),CS=Ft(3215),ES=Ft(7550),wS=Ft(8335),nn="http://www.w3.org/2000/svg",yn=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};ws=class i{constructor({viewBox:t,userUnit:e,scale:n,rotation:r,offsetX:a=0,offsetY:l=0,dontFlip:u=!1}){this.viewBox=t,this.userUnit=e,this.scale=n,this.rotation=r,this.offsetX=a,this.offsetY=l,n*=e;let f=(t[2]+t[0])/2,g=(t[3]+t[1])/2,m,y,v,S;switch(r%=360,r<0&&(r+=360),r){case 180:m=-1,y=0,v=0,S=1;break;case 90:m=0,y=1,v=1,S=0;break;case 270:m=0,y=-1,v=-1,S=0;break;case 0:m=1,y=0,v=0,S=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}u&&(v=-v,S=-S);let T,C,k,I;m===0?(T=Math.abs(g-t[1])*n+a,C=Math.abs(f-t[0])*n+l,k=(t[3]-t[1])*n,I=(t[2]-t[0])*n):(T=Math.abs(f-t[0])*n+a,C=Math.abs(g-t[1])*n+l,k=(t[2]-t[0])*n,I=(t[3]-t[1])*n),this.transform=[m*n,y*n,v*n,S*n,T-m*n*f-v*n*g,C-y*n*f-S*n*g],this.width=k,this.height=I}get rawDims(){let{userUnit:t,viewBox:e}=this,n=e.map(r=>r*t);return Ot(this,"rawDims",{pageWidth:n[2]-n[0],pageHeight:n[3]-n[1],pageX:n[0],pageY:n[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:n=this.offsetX,offsetY:r=this.offsetY,dontFlip:a=!1}={}){return new i({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:n,offsetY:r,dontFlip:a})}convertToViewportPoint(t,e){return St.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){let e=St.applyTransform([t[0],t[1]],this.transform),n=St.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],n[0],n[1]]}convertToPdfPoint(t,e){return St.applyInverseTransform([t,e],this.transform)}},ks=class extends bn{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};Ir=class{started=Object.create(null);times=[];time(t){t in this.started&&wt(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||wt(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){let t=[],e=0;for(let{name:n}of this.times)e=Math.max(n.length,e);for(let{name:n,start:r,end:a}of this.times)t.push(`${n.padEnd(e)} ${a-r}ms
4
+ `);return t.join("")}};Rr=class{static#t;static toDateObject(t){if(!t||typeof t!="string")return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");let e=this.#t.exec(t);if(!e)return null;let n=parseInt(e[1],10),r=parseInt(e[2],10);r=r>=1&&r<=12?r-1:0;let a=parseInt(e[3],10);a=a>=1&&a<=31?a:1;let l=parseInt(e[4],10);l=l>=0&&l<=23?l:0;let u=parseInt(e[5],10);u=u>=0&&u<=59?u:0;let f=parseInt(e[6],10);f=f>=0&&f<=59?f:0;let g=e[7]||"Z",m=parseInt(e[8],10);m=m>=0&&m<=23?m:0;let y=parseInt(e[9],10)||0;return y=y>=0&&y<=59?y:0,g==="-"?(l+=m,u+=y):g==="+"&&(l-=m,u-=y),new Date(Date.UTC(n,r,a,l,u,f))}};Is=class{constructor(){let 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}},xo=class i{#t=null;#e=null;#n;#s=null;#i=null;static#r=null;constructor(t){this.#n=t,i.#r||=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(){let t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");let e=this.#n._uiManager._signal;t.addEventListener("contextmenu",He,{signal:e}),t.addEventListener("pointerdown",i.#l,{signal:e});let n=this.#s=document.createElement("div");n.className="buttons",t.append(n);let r=this.#n.toolbarPosition;if(r){let{style:a}=t,l=this.#n._uiManager.direction==="ltr"?1-r[0]:r[0];a.insetInlineEnd=`${100*l}%`,a.top=`calc(${100*r[1]}% + var(--editor-toolbar-vert-offset))`}return this.#d(),t}get div(){return this.#t}static#l(t){t.stopPropagation()}#a(t){this.#n._focusEventsAllowed=!1,we(t)}#u(t){this.#n._focusEventsAllowed=!0,we(t)}#c(t){let e=this.#n._uiManager._signal;t.addEventListener("focusin",this.#a.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",He,{signal:e})}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#i?.shown()}#d(){let{editorType:t,_uiManager:e}=this.#n,n=document.createElement("button");n.className="delete",n.tabIndex=0,n.setAttribute("data-l10n-id",i.#r[t]),this.#c(n),n.addEventListener("click",r=>{e.delete()},{signal:e._signal}),this.#s.append(n)}get#h(){let t=document.createElement("div");return t.className="divider",t}async addAltText(t){let e=await t.render();this.#c(e),this.#s.prepend(e,this.#h),this.#i=t}addColorPicker(t){this.#e=t;let e=t.renderButton();this.#c(e),this.#s.prepend(e,this.#h)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}},So=class{#t=null;#e=null;#n;constructor(t){this.#n=t}#s(){let t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",He,{signal:this.#n._signal});let e=this.#t=document.createElement("div");return e.className="buttons",t.append(e),this.#r(),t}#i(t,e){let n=0,r=0;for(let a of t){let l=a.y+a.height;if(l<n)continue;let u=a.x+(e?a.width:0);if(l>n){r=u,n=l;continue}e?u>r&&(r=u):u<r&&(r=u)}return[e?1-r:r,n]}show(t,e,n){let[r,a]=this.#i(e,n),{style:l}=this.#e||=this.#s();t.append(this.#e),l.insetInlineEnd=`${100*r}%`,l.top=`calc(${100*a}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#r(){let t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");let e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");let n=this.#n._signal;t.addEventListener("contextmenu",He,{signal:n}),t.addEventListener("click",()=>{this.#n.highlightSelection("floating_button")},{signal:n}),this.#t.append(t)}};Ao=class{#t=0;get id(){return`${Ab}${this.#t++}`}},To=class i{#t=Fb();#e=0;#n=null;static get _isSVGFittingCanvas(){let t='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',n=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),r=new Image;r.src=t;let a=r.decode().then(()=>(n.drawImage(r,0,0,1,1,0,0,1,3),new Uint32Array(n.getImageData(0,0,1,1).data.buffer)[0]===0));return Ot(this,"_isSVGFittingCanvas",a)}async#s(t,e){this.#n||=new Map;let n=this.#n.get(t);if(n===null)return null;if(n?.bitmap)return n.refCounter+=1,n;try{n||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let r;if(typeof e=="string"?(n.url=e,r=await li(e,"blob")):e instanceof File?r=n.file=e:e instanceof Blob&&(r=e),r.type==="image/svg+xml"){let a=i._isSVGFittingCanvas,l=new FileReader,u=new Image,f=new Promise((g,m)=>{u.onload=()=>{n.bitmap=u,n.isSvg=!0,g()},l.onload=async()=>{let y=n.svgUrl=l.result;u.src=await a?`${y}#svgView(preserveAspectRatio(none))`:y},u.onerror=l.onerror=m});l.readAsDataURL(r),await f}else n.bitmap=await createImageBitmap(r);n.refCounter=1}catch(r){wt(r),n=null}return this.#n.set(t,n),n&&this.#n.set(n.id,n),n}async getFromFile(t){let{lastModified:e,name:n,size:r,type:a}=t;return this.#s(`${e}_${n}_${r}_${a}`,t)}async getFromUrl(t){return this.#s(t,t)}async getFromBlob(t,e){let n=await e;return this.#s(t,n)}async getFromId(t){this.#n||=new Map;let e=this.#n.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){let{blobPromise:n}=e;return delete e.blobPromise,this.getFromBlob(e.id,n)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#n||=new Map;let n=this.#n.get(t);if(n?.bitmap)return n.refCounter+=1,n;let r=new OffscreenCanvas(e.width,e.height);return r.getContext("2d").drawImage(e,0,0),n={bitmap:r.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#n.set(t,n),this.#n.set(n.id,n),n}getSvgUrl(t){let e=this.#n.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#n||=new Map;let e=this.#n.get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;let{bitmap:n}=e;if(!e.url&&!e.file){let r=new OffscreenCanvas(n.width,n.height);r.getContext("bitmaprenderer").transferFromImageBitmap(n),e.blobPromise=r.convertToBlob()}n.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}},Co=class{#t=[];#e=!1;#n;#s=-1;constructor(t=128){this.#n=t}add({cmd:t,undo:e,post:n,mustExec:r,type:a=NaN,overwriteIfSameType:l=!1,keepUndo:u=!1}){if(r&&t(),this.#e)return;let f={cmd:t,undo:e,post:n,type:a};if(this.#s===-1){this.#t.length>0&&(this.#t.length=0),this.#s=0,this.#t.push(f);return}if(l&&this.#t[this.#s].type===a){u&&(f.undo=this.#t[this.#s].undo),this.#t[this.#s]=f;return}let g=this.#s+1;g===this.#n?this.#t.splice(0,1):(this.#s=g,g<this.#t.length&&this.#t.splice(g)),this.#t.push(f)}undo(){if(this.#s===-1)return;this.#e=!0;let{undo:t,post:e}=this.#t[this.#s];t(),e?.(),this.#e=!1,this.#s-=1}redo(){if(this.#s<this.#t.length-1){this.#s+=1,this.#e=!0;let{cmd:t,post:e}=this.#t[this.#s];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#s!==-1}hasSomethingToRedo(){return this.#s<this.#t.length-1}cleanType(t){if(this.#s!==-1){for(let e=this.#s;e>=0;e--)if(this.#t[e].type!==t){this.#t.splice(e+1,this.#s-e),this.#s=e;return}this.#t.length=0,this.#s=-1}}destroy(){this.#t=null}},Fn=class{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;let{isMac:e}=se.platform;for(let[n,r,a={}]of t)for(let l of n){let u=l.startsWith("mac+");e&&u?(this.callbacks.set(l.slice(4),{callback:r,options:a}),this.allKeys.add(l.split("+").at(-1))):!e&&!u&&(this.callbacks.set(l,{callback:r,options:a}),this.allKeys.add(l.split("+").at(-1)))}}#t(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);let e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;let n=this.callbacks.get(this.#t(e));if(!n)return;let{callback:r,options:{bubbles:a=!1,args:l=[],checker:u=null}}=n;u&&!u(t,e)||(r.bind(t,...l,e)(),a||we(e))}},Eo=class i{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]);return Bb(t),Ot(this,"_colors",t)}convert(t){let e=Va(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[n,r]of this._colors)if(r.every((a,l)=>a===e[l]))return i._colorsMapping.get(n);return e}getHexCode(t){let e=this._colors.get(t);return e?St.makeHexColor(...e):t}},Dn=class i{#t=new AbortController;#e=null;#n=new Map;#s=new Map;#i=null;#r=null;#l=null;#a=new Co;#u=null;#c=null;#d=0;#h=new Set;#f=null;#o=null;#p=new Set;_editorUndoBar=null;#m=!1;#g=!1;#y=!1;#x=null;#b=null;#S=null;#T=null;#E=!1;#k=null;#R=new Ao;#A=!1;#I=!1;#w=null;#O=null;#F=null;#_=null;#C=Pt.NONE;#v=new Set;#L=null;#H=null;#j=null;#V={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#N=[0,0];#D=null;#U=null;#W=null;#M=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=i.prototype,e=l=>l.#U.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&l.hasSomethingToControl(),n=(l,{target:u})=>{if(u instanceof HTMLInputElement){let{type:f}=u;return f!=="text"&&f!=="number"}return!0},r=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return Ot(this,"_keyboardManager",new Fn([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:n}],[["ctrl+z","mac+meta+z"],t.undo,{checker:n}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:n}],[["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:n}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(l,{target:u})=>!(u instanceof HTMLButtonElement)&&l.#U.contains(u)&&!l.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(l,{target:u})=>!(u instanceof HTMLButtonElement)&&l.#U.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-a,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[a,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-a],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,a],checker:e}]]))}constructor(t,e,n,r,a,l,u,f,g,m,y,v,S){let T=this._signal=this.#t.signal;this.#U=t,this.#W=e,this.#i=n,this._eventBus=r,r._on("editingaction",this.onEditingAction.bind(this),{signal:T}),r._on("pagechanging",this.onPageChanging.bind(this),{signal:T}),r._on("scalechanging",this.onScaleChanging.bind(this),{signal:T}),r._on("rotationchanging",this.onRotationChanging.bind(this),{signal:T}),r._on("setpreference",this.onSetPreference.bind(this),{signal:T}),r._on("switchannotationeditorparams",C=>this.updateParams(C.type,C.value),{signal:T}),this.#et(),this.#it(),this.#Y(),this.#r=a.annotationStorage,this.#x=a.filterFactory,this.#H=l,this.#T=u||null,this.#m=f,this.#g=g,this.#y=m,this.#_=y||null,this.viewParameters={realScale:yn.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=v||null,this._supportsPinchToZoom=S!==!1}destroy(){this.#M?.resolve(),this.#M=null,this.#t?.abort(),this.#t=null,this._signal=null;for(let t of this.#s.values())t.destroy();this.#s.clear(),this.#n.clear(),this.#p.clear(),this.#e=null,this.#v.clear(),this.#a.destroy(),this.#i?.destroy(),this.#k?.hide(),this.#k=null,this.#b&&(clearTimeout(this.#b),this.#b=null),this.#D&&(clearTimeout(this.#D),this.#D=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#_}get useNewAltTextFlow(){return this.#g}get useNewAltTextWhenAddingImage(){return this.#y}get hcmFilter(){return Ot(this,"hcmFilter",this.#H?this.#x.addHCMFilter(this.#H.foreground,this.#H.background):"none")}get direction(){return Ot(this,"direction",getComputedStyle(this.#U).direction)}get highlightColors(){return Ot(this,"highlightColors",this.#T?new Map(this.#T.split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return Ot(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#c=t}setMainHighlightColorPicker(t){this.#F=t}editAltText(t,e=!1){this.#i?.editAltText(this,t,e)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":this.#y=e;break}}onPageChanging({pageNumber:t}){this.#d=t-1}focusMainContainer(){this.#U.focus()}findParent(t,e){for(let n of this.#s.values()){let{x:r,y:a,width:l,height:u}=n.div.getBoundingClientRect();if(t>=r&&t<=r+l&&e>=a&&e<=a+u)return n}return null}disableUserSelect(t=!1){this.#W.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#p.add(t)}removeShouldRescale(t){this.#p.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*yn.PDF_TO_CSS_UNITS;for(let e of this.#p)e.onScaleChanging();this.#c?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#B({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#X(t){let{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(let n of this.#s.values())if(n.hasTextLayer(t))return n;return null}highlightSelection(t=""){let e=document.getSelection();if(!e||e.isCollapsed)return;let{anchorNode:n,anchorOffset:r,focusNode:a,focusOffset:l}=e,u=e.toString(),g=this.#B(e).closest(".textLayer"),m=this.getSelectionBoxes(g);if(!m)return;e.empty();let y=this.#X(g),v=this.#C===Pt.NONE,S=()=>{y?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:m,anchorNode:n,anchorOffset:r,focusNode:a,focusOffset:l,text:u}),v&&this.showAllEditors("highlight",!0,!0)};if(v){this.switchToMode(Pt.HIGHLIGHT,S);return}S()}#q(){let t=document.getSelection();if(!t||t.isCollapsed)return;let n=this.#B(t).closest(".textLayer"),r=this.getSelectionBoxes(n);r&&(this.#k||=new So(this),this.#k.show(n,r,this.direction==="ltr"))}addToAnnotationStorage(t){!t.isEmpty()&&this.#r&&!this.#r.has(t.id)&&this.#r.setValue(t.id,t)}#tt(){let t=document.getSelection();if(!t||t.isCollapsed){this.#L&&(this.#k?.hide(),this.#L=null,this.#P({hasSelectedText:!1}));return}let{anchorNode:e}=t;if(e===this.#L)return;let r=this.#B(t).closest(".textLayer");if(!r){this.#L&&(this.#k?.hide(),this.#L=null,this.#P({hasSelectedText:!1}));return}if(this.#k?.hide(),this.#L=e,this.#P({hasSelectedText:!0}),!(this.#C!==Pt.HIGHLIGHT&&this.#C!==Pt.NONE)&&(this.#C===Pt.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#E=this.isShiftKeyDown,!this.isShiftKeyDown)){let a=this.#C===Pt.HIGHLIGHT?this.#X(r):null;a?.toggleDrawing();let l=new AbortController,u=this.combinedSignal(l),f=g=>{g.type==="pointerup"&&g.button!==0||(l.abort(),a?.toggleDrawing(!0),g.type==="pointerup"&&this.#z("main_toolbar"))};window.addEventListener("pointerup",f,{signal:u}),window.addEventListener("blur",f,{signal:u})}}#z(t=""){this.#C===Pt.HIGHLIGHT?this.highlightSelection(t):this.#m&&this.#q()}#et(){document.addEventListener("selectionchange",this.#tt.bind(this),{signal:this._signal})}#nt(){if(this.#S)return;this.#S=new AbortController;let t=this.combinedSignal(this.#S);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#st(){this.#S?.abort(),this.#S=null}blur(){if(this.isShiftKeyDown=!1,this.#E&&(this.#E=!1,this.#z("main_toolbar")),!this.hasSelection)return;let{activeElement:t}=document;for(let e of this.#v)if(e.div.contains(t)){this.#O=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#O)return;let[t,e]=this.#O;this.#O=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#Y(){if(this.#w)return;this.#w=new AbortController;let t=this.combinedSignal(this.#w);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#rt(){this.#w?.abort(),this.#w=null}#K(){if(this.#u)return;this.#u=new AbortController;let t=this.combinedSignal(this.#u);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})}#Z(){this.#u?.abort(),this.#u=null}#it(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#Y(),this.#K()}removeEditListeners(){this.#rt(),this.#Z()}dragOver(t){for(let{type:e}of t.dataTransfer.items)for(let n of this.#o)if(n.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let e of t.dataTransfer.items)for(let n of this.#o)if(n.isHandlingMimeForPasting(e.type)){n.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;let e=[];for(let n of this.#v){let r=n.serialize(!0);r&&e.push(r)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();let{clipboardData:e}=t;for(let a of e.items)for(let l of this.#o)if(l.isHandlingMimeForPasting(a.type)){l.paste(a,this.currentLayer);return}let n=e.getData("application/pdfjs");if(!n)return;try{n=JSON.parse(n)}catch(a){wt(`paste: "${a.message}".`);return}if(!Array.isArray(n))return;this.unselectAll();let r=this.currentLayer;try{let a=[];for(let f of n){let g=await r.deserialize(f);if(!g)return;a.push(g)}let l=()=>{for(let f of a)this.#Q(f);this.#J(a)},u=()=>{for(let f of a)f.remove()};this.addCommands({cmd:l,undo:u,mustExec:!0})}catch(a){wt(`paste: "${a.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#C!==Pt.NONE&&!this.isEditorHandlingKeyboard&&i._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#E&&(this.#E=!1,this.#z("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}#P(t){Object.entries(t).some(([n,r])=>this.#V[n]!==r)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#V,t)}),this.#C===Pt.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#G([[Mt.HIGHLIGHT_FREE,!0]]))}#G(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#nt(),this.#K(),this.#P({isEditing:this.#C!==Pt.NONE,isEmpty:this.#$(),hasSomethingToUndo:this.#a.hasSomethingToUndo(),hasSomethingToRedo:this.#a.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#st(),this.#Z(),this.#P({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#o){this.#o=t;for(let e of this.#o)this.#G(e.defaultPropertiesToUpdate)}}getId(){return this.#R.id}get currentLayer(){return this.#s.get(this.#d)}getLayer(t){return this.#s.get(t)}get currentPageIndex(){return this.#d}addLayer(t){this.#s.set(t.pageIndex,t),this.#A?t.enable():t.disable()}removeLayer(t){this.#s.delete(t.pageIndex)}async updateMode(t,e=null,n=!1){if(this.#C!==t&&!(this.#M&&(await this.#M.promise,!this.#M))){if(this.#M=Promise.withResolvers(),this.#C=t,t===Pt.NONE){this.setEditingState(!1),this.#at(),this._editorUndoBar?.hide(),this.#M.resolve();return}this.setEditingState(!0),await this.#ot(),this.unselectAll();for(let r of this.#s.values())r.updateMode(t);if(!e){n&&this.addNewEditorFromKeyboard(),this.#M.resolve();return}for(let r of this.#n.values())r.annotationElementId===e?(this.setSelected(r),r.enterInEditMode()):r.unselect();this.#M.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#C&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#o){switch(t){case Mt.CREATE:this.currentLayer.addNewEditor();return;case Mt.HIGHLIGHT_DEFAULT_COLOR:this.#F?.updateColor(e);break;case Mt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#j||=new Map).set(t,e),this.showAllEditors("highlight",e);break}for(let n of this.#v)n.updateParams(t,e);for(let n of this.#o)n.updateDefaultParams(t,e)}}showAllEditors(t,e,n=!1){for(let a of this.#n.values())a.editorType===t&&a.show(e);(this.#j?.get(Mt.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#G([[Mt.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#I!==t){this.#I=t;for(let e of this.#s.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#ot(){if(!this.#A){this.#A=!0;let t=[];for(let e of this.#s.values())t.push(e.enable());await Promise.all(t);for(let e of this.#n.values())e.enable()}}#at(){if(this.unselectAll(),this.#A){this.#A=!1;for(let t of this.#s.values())t.disable();for(let t of this.#n.values())t.disable()}}getEditors(t){let e=[];for(let n of this.#n.values())n.pageIndex===t&&e.push(n);return e}getEditor(t){return this.#n.get(t)}addEditor(t){this.#n.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#b&&clearTimeout(this.#b),this.#b=setTimeout(()=>{this.focusMainContainer(),this.#b=null},0)),this.#n.delete(t.id),this.unselect(t),(!t.annotationElementId||!this.#h.has(t.annotationElementId))&&this.#r?.remove(t.id)}addDeletedAnnotationElement(t){this.#h.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#h.has(t)}removeDeletedAnnotationElement(t){this.#h.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#Q(t){let e=this.#s.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#G(t.propertiesToUpdate))}get#lt(){let t=null;for(t of this.#v);return t}updateUI(t){this.#lt===t&&this.#G(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#G(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#v.has(t)){this.#v.delete(t),t.unselect(),this.#P({hasSelectedEditor:this.hasSelection});return}this.#v.add(t),t.select(),this.#G(t.propertiesToUpdate),this.#P({hasSelectedEditor:!0})}setSelected(t){this.#c?.commitOrRemove();for(let e of this.#v)e!==t&&e.unselect();this.#v.clear(),this.#v.add(t),t.select(),this.#G(t.propertiesToUpdate),this.#P({hasSelectedEditor:!0})}isSelected(t){return this.#v.has(t)}get firstSelectedEditor(){return this.#v.values().next().value}unselect(t){t.unselect(),this.#v.delete(t),this.#P({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#v.size!==0}get isEnterHandled(){return this.#v.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#a.undo(),this.#P({hasSomethingToUndo:this.#a.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#$()}),this._editorUndoBar?.hide()}redo(){this.#a.redo(),this.#P({hasSomethingToUndo:!0,hasSomethingToRedo:this.#a.hasSomethingToRedo(),isEmpty:this.#$()})}addCommands(t){this.#a.add(t),this.#P({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#$()})}cleanUndoStack(t){this.#a.cleanType(t)}#$(){if(this.#n.size===0)return!0;if(this.#n.size===1)for(let t of this.#n.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();let t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let e=t?[t]:[...this.#v],n=()=>{this._editorUndoBar?.show(r,e.length===1?e[0].editorType:e.length);for(let a of e)a.remove()},r=()=>{for(let a of e)this.#Q(a)};this.addCommands({cmd:n,undo:r,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#J(t){for(let e of this.#v)e.unselect();this.#v.clear();for(let e of t)e.isEmpty()||(this.#v.add(e),e.select());this.#P({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#v)t.commit();this.#J(this.#n.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#C!==Pt.NONE))&&!this.#c?.commitOrRemove()&&this.hasSelection){for(let t of this.#v)t.unselect();this.#v.clear(),this.#P({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;this.#N[0]+=t,this.#N[1]+=e;let[r,a]=this.#N,l=[...this.#v],u=1e3;this.#D&&clearTimeout(this.#D),this.#D=setTimeout(()=>{this.#D=null,this.#N[0]=this.#N[1]=0,this.addCommands({cmd:()=>{for(let f of l)this.#n.has(f.id)&&f.translateInPage(r,a)},undo:()=>{for(let f of l)this.#n.has(f.id)&&f.translateInPage(-r,-a)},mustExec:!1})},u);for(let f of l)f.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#f=new Map;for(let t of this.#v)this.#f.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#f)return!1;this.disableUserSelect(!1);let t=this.#f;this.#f=null;let e=!1;for(let[{x:r,y:a,pageIndex:l},u]of t)u.newX=r,u.newY=a,u.newPageIndex=l,e||=r!==u.savedX||a!==u.savedY||l!==u.savedPageIndex;if(!e)return!1;let n=(r,a,l,u)=>{if(this.#n.has(r.id)){let f=this.#s.get(u);f?r._setParentAndPosition(f,a,l):(r.pageIndex=u,r.x=a,r.y=l)}};return this.addCommands({cmd:()=>{for(let[r,{newX:a,newY:l,newPageIndex:u}]of t)n(r,a,l,u)},undo:()=>{for(let[r,{savedX:a,savedY:l,savedPageIndex:u}]of t)n(r,a,l,u)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#f)for(let n of this.#f.keys())n.drag(t,e)}rebuild(t){if(t.parent===null){let e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#v.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#C}get imageManager(){return Ot(this,"imageManager",new To)}getSelectionBoxes(t){if(!t)return null;let e=document.getSelection();for(let g=0,m=e.rangeCount;g<m;g++)if(!t.contains(e.getRangeAt(g).commonAncestorContainer))return null;let{x:n,y:r,width:a,height:l}=t.getBoundingClientRect(),u;switch(t.getAttribute("data-main-rotation")){case"90":u=(g,m,y,v)=>({x:(m-r)/l,y:1-(g+y-n)/a,width:v/l,height:y/a});break;case"180":u=(g,m,y,v)=>({x:1-(g+y-n)/a,y:1-(m+v-r)/l,width:y/a,height:v/l});break;case"270":u=(g,m,y,v)=>({x:1-(m+v-r)/l,y:(g-n)/a,width:v/l,height:y/a});break;default:u=(g,m,y,v)=>({x:(g-n)/a,y:(m-r)/l,width:y/a,height:v/l});break}let f=[];for(let g=0,m=e.rangeCount;g<m;g++){let y=e.getRangeAt(g);if(!y.collapsed)for(let{x:v,y:S,width:T,height:C}of y.getClientRects())T===0||C===0||f.push(u(v,S,T,C))}return f.length===0?null:f}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#l||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#l?.delete(t)}renderAnnotationElement(t){let e=this.#l?.get(t.data.id);if(!e)return;let n=this.#r.getRawValue(e);n&&(this.#C===Pt.NONE&&!n.hasBeenModified||n.renderAnnotationElement(t))}},Or=class i{#t=null;#e=!1;#n=null;#s=null;#i=null;#r=null;#l=!1;#a=null;#u=null;#c=null;#d=null;#h=!1;static#f=null;static _l10n=null;constructor(t){this.#u=t,this.#h=t._uiManager.useNewAltTextFlow,i.#f||=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){i._l10n??=t}async render(){let t=this.#n=document.createElement("button");t.className="altText",t.tabIndex="0";let e=this.#s=document.createElement("span");t.append(e),this.#h?(t.classList.add("new"),t.setAttribute("data-l10n-id",i.#f.missing),e.setAttribute("data-l10n-id",i.#f["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));let n=this.#u._uiManager._signal;t.addEventListener("contextmenu",He,{signal:n}),t.addEventListener("pointerdown",a=>a.stopPropagation(),{signal:n});let r=a=>{a.preventDefault(),this.#u._uiManager.editAltText(this.#u),this.#h&&this.#u._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#o}})};return t.addEventListener("click",r,{capture:!0,signal:n}),t.addEventListener("keydown",a=>{a.target===t&&a.key==="Enter"&&(this.#l=!0,r(a))},{signal:n}),await this.#p(),t}get#o(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){this.#n&&(this.#n.focus({focusVisible:this.#l}),this.#l=!1)}isEmpty(){return this.#h?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#h?this.#t!==null||!!this.#c:this.isEmpty()}get guessedText(){return this.#c}async setGuessedText(t){this.#t===null&&(this.#c=t,this.#d=await i._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#p())}toggleAltTextBadge(t=!1){if(!this.#h||this.#t){this.#a?.remove(),this.#a=null;return}if(!this.#a){let e=this.#a=document.createElement("div");e.className="noAltTextBadge",this.#u.div.append(e)}this.#a.classList.toggle("hidden",!t)}serialize(t){let e=this.#t;return!t&&this.#c===e&&(e=this.#d),{altText:e,decorative:this.#e,guessedText:this.#c,textWithDisclaimer:this.#d}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e,guessedText:n,textWithDisclaimer:r,cancel:a=!1}){n&&(this.#c=n,this.#d=r),!(this.#t===t&&this.#e===e)&&(a||(this.#t=t,this.#e=e),this.#p())}toggle(t=!1){this.#n&&(!t&&this.#r&&(clearTimeout(this.#r),this.#r=null),this.#n.disabled=!t)}shown(){this.#u._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#o}})}destroy(){this.#n?.remove(),this.#n=null,this.#s=null,this.#i=null,this.#a?.remove(),this.#a=null}async#p(){let t=this.#n;if(!t)return;if(this.#h){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",i.#f[this.#o]),this.#s?.setAttribute("data-l10n-id",i.#f[`${this.#o}-label`]),!this.#t){this.#i?.remove();return}}else{if(!this.#t&&!this.#e){t.classList.remove("done"),this.#i?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#i;if(!e){this.#i=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#u.id}`;let r=100,a=this.#u._uiManager._signal;a.addEventListener("abort",()=>{clearTimeout(this.#r),this.#r=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#r=setTimeout(()=>{this.#r=null,this.#i.classList.add("show"),this.#u._reportTelemetry({action:"alt_text_tooltip"})},r)},{signal:a}),t.addEventListener("mouseleave",()=>{this.#r&&(clearTimeout(this.#r),this.#r=null),this.#i?.classList.remove("show")},{signal:a})}this.#e?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#t),e.parentNode||t.append(e),this.#u.getImageForAltText()?.setAttribute("aria-describedby",e.id)}},Mr=class i{#t;#e=!1;#n=null;#s;#i;#r;#l;#a;#u=null;#c;#d=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:n=null,onPinchStart:r=null,onPinching:a=null,onPinchEnd:l=null,signal:u}){this.#t=t,this.#n=n,this.#s=e,this.#i=r,this.#r=a,this.#l=l,this.#c=new AbortController,this.#a=AbortSignal.any([u,this.#c.signal]),t.addEventListener("touchstart",this.#h.bind(this),{passive:!1,signal:this.#a})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return Ot(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#h(t){if(this.#s?.()||t.touches.length<2)return;if(!this.#d){this.#d=new AbortController;let r=AbortSignal.any([this.#a,this.#d.signal]),a=this.#t,l={signal:r,passive:!1};a.addEventListener("touchmove",this.#f.bind(this),l),a.addEventListener("touchend",this.#o.bind(this),l),a.addEventListener("touchcancel",this.#o.bind(this),l),this.#i?.()}if(we(t),t.touches.length!==2||this.#n?.()){this.#u=null;return}let[e,n]=t.touches;e.identifier>n.identifier&&([e,n]=[n,e]),this.#u={touch0X:e.screenX,touch0Y:e.screenY,touch1X:n.screenX,touch1Y:n.screenY}}#f(t){if(!this.#u||t.touches.length!==2)return;let[e,n]=t.touches;e.identifier>n.identifier&&([e,n]=[n,e]);let{screenX:r,screenY:a}=e,{screenX:l,screenY:u}=n,f=this.#u,{touch0X:g,touch0Y:m,touch1X:y,touch1Y:v}=f,S=y-g,T=v-m,C=l-r,k=u-a,I=Math.hypot(C,k)||1,O=Math.hypot(S,T)||1;if(!this.#e&&Math.abs(O-I)<=i.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(f.touch0X=r,f.touch0Y=a,f.touch1X=l,f.touch1Y=u,t.preventDefault(),!this.#e){this.#e=!0;return}let D=[(r+l)/2,(a+u)/2];this.#r?.(D,O,I)}#o(t){this.#d.abort(),this.#d=null,this.#l?.(),this.#u&&(t.preventDefault(),this.#u=null,this.#e=!1)}destroy(){this.#c?.abort(),this.#c=null}},Xt=class i{#t=null;#e=null;#n=null;#s=!1;#i=null;#r="";#l=!1;#a=null;#u=null;#c=null;#d=null;#h="";#f=!1;#o=null;#p=!1;#m=!1;#g=!1;#y=null;#x=0;#b=0;#S=null;#T=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#E=!1;#k=i._zIndex++;static _borderLineWidth=-1;static _colorManager=new Eo;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=i.prototype._resizeWithKeyboard,e=Dn.TRANSLATE_SMALL,n=Dn.TRANSLATE_BIG;return Ot(this,"_resizerKeyboardManager",new Fn([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-n,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[n,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-n]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,n]}],[["Escape","mac+Escape"],i.prototype._stopResizingWithKeyboard]]))}constructor(t){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;let{rotation:e,rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:l}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,r],this.pageTranslation=[a,l];let[u,f]=this.parentDimensions;this.x=t.x/u,this.y=t.y/f,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return Ot(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new wo({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(i._l10n??=t,i._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"}),i._borderLineWidth!==-1)return;let n=getComputedStyle(document.documentElement);i._borderLineWidth=parseFloat(n.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){$t("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#E}set _isDraggable(t){this.#E=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){let[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#k}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#B(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#f?this.#f=!1:this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||t.relatedTarget?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,n,r){let[a,l]=this.parentDimensions;[n,r]=this.screenToPageTranslation(n,r),this.x=(t+n)/a,this.y=(e+r)/l,this.fixAndSetPosition()}#R([t,e],n,r){[n,r]=this.screenToPageTranslation(n,r),this.x+=n/t,this.y+=r/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#R(this.parentDimensions,t,e)}translateInPage(t,e){this.#o||=[this.x,this.y,this.width,this.height],this.#R(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#o||=[this.x,this.y,this.width,this.height];let{div:n,parentDimensions:[r,a]}=this;if(this.x+=t/r,this.y+=e/a,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:y,y:v}=this.div.getBoundingClientRect();this.parent.findNewParent(this,y,v)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:l,y:u}=this,[f,g]=this.getBaseTranslation();l+=f,u+=g;let{style:m}=n;m.left=`${(100*l).toFixed(2)}%`,m.top=`${(100*u).toFixed(2)}%`,this._onTranslating(l,u),n.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#o&&(this.#o[0]!==this.x||this.#o[1]!==this.y)}get _hasBeenResized(){return!!this.#o&&(this.#o[2]!==this.width||this.#o[3]!==this.height)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:n}=i,r=n/t,a=n/e;switch(this.rotation){case 90:return[-r,a];case 180:return[r,a];case 270:return[r,-a];default:return[-r,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){let{div:{style:e},pageDimensions:[n,r]}=this,{x:a,y:l,width:u,height:f}=this;if(u*=n,f*=r,a*=n,l*=r,this._mustFixPosition)switch(t){case 0:a=Math.max(0,Math.min(n-u,a)),l=Math.max(0,Math.min(r-f,l));break;case 90:a=Math.max(0,Math.min(n-f,a)),l=Math.min(r,Math.max(u,l));break;case 180:a=Math.min(n,Math.max(u,a)),l=Math.min(r,Math.max(f,l));break;case 270:a=Math.min(n,Math.max(f,a)),l=Math.max(0,Math.min(r-u,l));break}this.x=a/=n,this.y=l/=r;let[g,m]=this.getBaseTranslation();a+=g,l+=m,e.left=`${(100*a).toFixed(2)}%`,e.top=`${(100*l).toFixed(2)}%`,this.moveInDOM()}static#A(t,e,n){switch(n){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return i.#A(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return i.#A(t,e,360-this.parentRotation)}#I(t){switch(t){case 90:{let[e,n]=this.pageDimensions;return[0,-e/n,n/e,0]}case 180:return[-1,0,0,-1];case 270:{let[e,n]=this.pageDimensions;return[0,e/n,-n/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:t,pageDimensions:[e,n]}=this;return[e*t,n*t]}setDims(t,e){let[n,r]=this.parentDimensions,{style:a}=this.div;a.width=`${(100*t/n).toFixed(2)}%`,this.#l||(a.height=`${(100*e/r).toFixed(2)}%`)}fixDims(){let{style:t}=this.div,{height:e,width:n}=t,r=n.endsWith("%"),a=!this.#l&&e.endsWith("%");if(r&&a)return;let[l,u]=this.parentDimensions;r||(t.width=`${(100*parseFloat(n)/l).toFixed(2)}%`),!this.#l&&!a&&(t.height=`${(100*parseFloat(e)/u).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#w(){if(this.#a)return;this.#a=document.createElement("div"),this.#a.classList.add("resizers");let t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(let n of t){let r=document.createElement("div");this.#a.append(r),r.classList.add("resizer",n),r.setAttribute("data-resizer-name",n),r.addEventListener("pointerdown",this.#O.bind(this,n),{signal:e}),r.addEventListener("contextmenu",He,{signal:e}),r.tabIndex=-1}this.div.prepend(this.#a)}#O(t,e){e.preventDefault();let{isMac:n}=se.platform;if(e.button!==0||e.ctrlKey&&n)return;this.#n?.toggle(!1);let r=this._isDraggable;this._isDraggable=!1,this.#u=[e.screenX,e.screenY];let a=new AbortController,l=this._uiManager.combinedSignal(a);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#C.bind(this,t),{passive:!0,capture:!0,signal:l}),window.addEventListener("touchmove",we,{passive:!1,signal:l}),window.addEventListener("contextmenu",He,{signal:l}),this.#c={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let u=this.parent.div.style.cursor,f=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let g=()=>{a.abort(),this.parent.togglePointerEvents(!0),this.#n?.toggle(!0),this._isDraggable=r,this.parent.div.style.cursor=u,this.div.style.cursor=f,this.#_()};window.addEventListener("pointerup",g,{signal:l}),window.addEventListener("blur",g,{signal:l})}#F(t,e,n,r){this.width=n,this.height=r,this.x=t,this.y=e;let[a,l]=this.parentDimensions;this.setDims(a*n,l*r),this.fixAndSetPosition(),this._onResized()}_onResized(){}#_(){if(!this.#c)return;let{savedX:t,savedY:e,savedWidth:n,savedHeight:r}=this.#c;this.#c=null;let a=this.x,l=this.y,u=this.width,f=this.height;a===t&&l===e&&u===n&&f===r||this.addCommands({cmd:this.#F.bind(this,a,l,u,f),undo:this.#F.bind(this,t,e,n,r),mustExec:!0})}static _round(t){return Math.round(t*1e4)/1e4}#C(t,e){let[n,r]=this.parentDimensions,a=this.x,l=this.y,u=this.width,f=this.height,g=i.MIN_SIZE/n,m=i.MIN_SIZE/r,y=this.#I(this.rotation),v=(Y,Z)=>[y[0]*Y+y[2]*Z,y[1]*Y+y[3]*Z],S=this.#I(360-this.rotation),T=(Y,Z)=>[S[0]*Y+S[2]*Z,S[1]*Y+S[3]*Z],C,k,I=!1,O=!1;switch(t){case"topLeft":I=!0,C=(Y,Z)=>[0,0],k=(Y,Z)=>[Y,Z];break;case"topMiddle":C=(Y,Z)=>[Y/2,0],k=(Y,Z)=>[Y/2,Z];break;case"topRight":I=!0,C=(Y,Z)=>[Y,0],k=(Y,Z)=>[0,Z];break;case"middleRight":O=!0,C=(Y,Z)=>[Y,Z/2],k=(Y,Z)=>[0,Z/2];break;case"bottomRight":I=!0,C=(Y,Z)=>[Y,Z],k=(Y,Z)=>[0,0];break;case"bottomMiddle":C=(Y,Z)=>[Y/2,Z],k=(Y,Z)=>[Y/2,0];break;case"bottomLeft":I=!0,C=(Y,Z)=>[0,Z],k=(Y,Z)=>[Y,0];break;case"middleLeft":O=!0,C=(Y,Z)=>[0,Z/2],k=(Y,Z)=>[Y,Z/2];break}let D=C(u,f),_=k(u,f),M=v(..._),B=i._round(a+M[0]),H=i._round(l+M[1]),z=1,W=1,Q,q;if(e.fromKeyboard)({deltaX:Q,deltaY:q}=e);else{let{screenX:Y,screenY:Z}=e,[yt,it]=this.#u;[Q,q]=this.screenToPageTranslation(Y-yt,Z-it),this.#u[0]=Y,this.#u[1]=Z}if([Q,q]=T(Q/n,q/r),I){let Y=Math.hypot(u,f);z=W=Math.max(Math.min(Math.hypot(_[0]-D[0]-Q,_[1]-D[1]-q)/Y,1/u,1/f),g/u,m/f)}else O?z=Math.max(g,Math.min(1,Math.abs(_[0]-D[0]-Q)))/u:W=Math.max(m,Math.min(1,Math.abs(_[1]-D[1]-q)))/f;let bt=i._round(u*z),et=i._round(f*W);M=v(...k(bt,et));let Tt=B-M[0],dt=H-M[1];this.#o||=[this.x,this.y,this.width,this.height],this.width=bt,this.height=et,this.x=Tt,this.y=dt,this.setDims(n*bt,r*et),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#n?.finish()}async addEditToolbar(){return this._editToolbar||this.#m?this._editToolbar:(this._editToolbar=new xo(this),this.div.append(this._editToolbar.render()),this.#n&&await this._editToolbar.addAltText(this.#n),this._editToolbar)}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#n?.destroy())}addContainer(t){let e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#n||(Or.initialize(i._l10n),this.#n=new Or(this),this.#t&&(this.#n.data=this.#t,this.#t=null),await this.addEditToolbar())}get altTextData(){return this.#n?.data}set altTextData(t){this.#n&&(this.#n.data=t)}get guessedAltText(){return this.#n?.guessedText}async setGuessedAltText(t){await this.#n?.setGuessedText(t)}serializeAltText(t){return this.#n?.serialize(t)}hasAltText(){return!!this.#n&&!this.#n.isEmpty()}hasAltTextData(){return this.#n?.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=this.#s?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#N();let[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)}%`);let[n,r]=this.getInitialTranslation();return this.translate(n,r),Pr(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#T||=new Mr({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#v.bind(this),onPinching:this.#L.bind(this),onPinchEnd:this.#H.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#v(){this.#c={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#n?.toggle(!1),this.parent.togglePointerEvents(!1)}#L(t,e,n){let a=.7*(n/e)+1-.7;if(a===1)return;let l=this.#I(this.rotation),u=(B,H)=>[l[0]*B+l[2]*H,l[1]*B+l[3]*H],[f,g]=this.parentDimensions,m=this.x,y=this.y,v=this.width,S=this.height,T=i.MIN_SIZE/f,C=i.MIN_SIZE/g;a=Math.max(Math.min(a,1/v,1/S),T/v,C/S);let k=i._round(v*a),I=i._round(S*a);if(k===v&&I===S)return;this.#o||=[m,y,v,S];let O=u(v/2,S/2),D=i._round(m+O[0]),_=i._round(y+O[1]),M=u(k/2,I/2);this.x=D-M[0],this.y=_-M[1],this.width=k,this.height=I,this.setDims(f*k,g*I),this.fixAndSetPosition(),this._onResizing()}#H(){this.#n?.toggle(!0),this.parent.togglePointerEvents(!0),this.#_()}pointerdown(t){let{isMac:e}=se.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#f=!0,this._isDraggable){this.#V(t);return}this.#j(t)}get isSelected(){return this._uiManager.isSelected(this)}#j(t){let{isMac:e}=se.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#V(t){let{isSelected:e}=this;this._uiManager.setUpDragSession();let n=!1,r=new AbortController,a=this._uiManager.combinedSignal(r),l={capture:!0,passive:!1,signal:a},u=g=>{r.abort(),this.#i=null,this.#f=!1,this._uiManager.endDragSession()||this.#j(g),n&&this._onStopDragging()};e&&(this.#x=t.clientX,this.#b=t.clientY,this.#i=t.pointerId,this.#r=t.pointerType,window.addEventListener("pointermove",g=>{n||(n=!0,this._onStartDragging());let{clientX:m,clientY:y,pointerId:v}=g;if(v!==this.#i){we(g);return}let[S,T]=this.screenToPageTranslation(m-this.#x,y-this.#b);this.#x=m,this.#b=y,this._uiManager.dragSelectedEditors(S,T)},l),window.addEventListener("touchmove",we,l),window.addEventListener("pointerdown",g=>{g.pointerType===this.#r&&(this.#T||g.isPrimary)&&u(g),we(g)},l));let f=g=>{if(!this.#i||this.#i===g.pointerId){u(g);return}we(g)};window.addEventListener("pointerup",f,{signal:a}),window.addEventListener("blur",f,{signal:a})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#y&&clearTimeout(this.#y),this.#y=setTimeout(()=>{this.#y=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,n){t.changeParent(this),this.x=e,this.y=n,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,n=this.rotation){let r=this.parentScale,[a,l]=this.pageDimensions,[u,f]=this.pageTranslation,g=t/r,m=e/r,y=this.x*a,v=this.y*l,S=this.width*a,T=this.height*l;switch(n){case 0:return[y+g+u,l-v-m-T+f,y+g+S+u,l-v-m+f];case 90:return[y+m+u,l-v+g+f,y+m+T+u,l-v+g+S+f];case 180:return[y-g-S+u,l-v+m+f,y-g+u,l-v+m+T+f];case 270:return[y-m-T+u,l-v-g-S+f,y-m+u,l-v-g+f];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[n,r,a,l]=t,u=a-n,f=l-r;switch(this.rotation){case 0:return[n,e-l,u,f];case 90:return[n,e-r,f,u];case 180:return[a,e-r,u,f];case 270:return[a,e-l,f,u];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){this.#m=!0}disableEditMode(){this.#m=!1}isInEditMode(){return this.#m}shouldGetKeyboardEvents(){return this.#g}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:t,left:e,bottom:n,right:r}=this.getClientDimensions(),{innerHeight:a,innerWidth:l}=window;return e<l&&r>0&&t<a&&n>0}#N(){if(this.#d||!this.div)return;this.#d=new AbortController;let t=this._uiManager.combinedSignal(this.#d);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#N()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){$t("An editor must be serializable")}static async deserialize(t,e,n){let r=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:n});r.rotation=t.rotation,r.#t=t.accessibilityData;let[a,l]=r.pageDimensions,[u,f,g,m]=r.getRectInCurrentCoords(t.rect,l);return r.x=u/a,r.y=f/l,r.width=g/a,r.height=m/l,r}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#d?.abort(),this.#d=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#y&&(clearTimeout(this.#y),this.#y=null),this.#B(),this.removeEditToolbar(),this.#S){for(let t of this.#S.values())clearTimeout(t);this.#S=null}this.parent=null,this.#T?.destroy(),this.#T=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#w(),this.#a.classList.remove("hidden"),Pr(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#c={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#a.children;if(!this.#e){this.#e=Array.from(e);let l=this.#D.bind(this),u=this.#U.bind(this),f=this._uiManager._signal;for(let g of this.#e){let m=g.getAttribute("data-resizer-name");g.setAttribute("role","spinbutton"),g.addEventListener("keydown",l,{signal:f}),g.addEventListener("blur",u,{signal:f}),g.addEventListener("focus",this.#W.bind(this,m),{signal:f}),g.setAttribute("data-l10n-id",i._l10nResizer[m])}}let n=this.#e[0],r=0;for(let l of e){if(l===n)break;r++}let a=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(a!==r){if(a<r)for(let u=0;u<r-a;u++)this.#a.append(this.#a.firstChild);else if(a>r)for(let u=0;u<a-r;u++)this.#a.firstChild.before(this.#a.lastChild);let l=0;for(let u of e){let g=this.#e[l++].getAttribute("data-resizer-name");u.setAttribute("data-l10n-id",i._l10nResizer[g])}}this.#M(0),this.#g=!0,this.#a.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#D(t){i._resizerKeyboardManager.exec(this,t)}#U(t){this.#g&&t.relatedTarget?.parentNode!==this.#a&&this.#B()}#W(t){this.#h=this.#g?t:""}#M(t){if(this.#e)for(let e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#g&&this.#C(this.#h,{deltaX:t,deltaY:e,fromKeyboard:!0})}#B(){this.#g=!1,this.#M(-1),this.#_()}_stopResizingWithKeyboard(){this.#B(),this.div.focus()}select(){if(this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#n?.toggleAltTextBadge(!1)}unselect(){this.#a?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#n?.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#p}set isEditing(t){this.#p=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#l=!0;let n=t/e,{style:r}=this.div;r.aspectRatio=n,r.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#S||=new Map;let{action:n}=t,r=this.#S.get(n);r&&clearTimeout(r),r=setTimeout(()=>{this._reportTelemetry(t),this.#S.delete(n),this.#S.size===0&&(this.#S=null)},i._telemetryTimeout),this.#S.set(n,r);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#s=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#s=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){let n=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),n.before(e)}return e}resetAnnotationElement(t){let{firstChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}},wo=class extends Xt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}},hu=3285377520,Oe=4294901760,Ke=65535,Lr=class{constructor(t){this.h1=t?t&4294967295:hu,this.h2=t?t&4294967295:hu}update(t){let e,n;if(typeof t=="string"){e=new Uint8Array(t.length*2),n=0;for(let C=0,k=t.length;C<k;C++){let I=t.charCodeAt(C);I<=255?e[n++]=I:(e[n++]=I>>>8,e[n++]=I&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),n=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");let r=n>>2,a=n-r*4,l=new Uint32Array(e.buffer,0,r),u=0,f=0,g=this.h1,m=this.h2,y=3432918353,v=461845907,S=y&Ke,T=v&Ke;for(let C=0;C<r;C++)C&1?(u=l[C],u=u*y&Oe|u*S&Ke,u=u<<15|u>>>17,u=u*v&Oe|u*T&Ke,g^=u,g=g<<13|g>>>19,g=g*5+3864292196):(f=l[C],f=f*y&Oe|f*S&Ke,f=f<<15|f>>>17,f=f*v&Oe|f*T&Ke,m^=f,m=m<<13|m>>>19,m=m*5+3864292196);switch(u=0,a){case 3:u^=e[r*4+2]<<16;case 2:u^=e[r*4+1]<<8;case 1:u^=e[r*4],u=u*y&Oe|u*S&Ke,u=u<<15|u>>>17,u=u*v&Oe|u*T&Ke,r&1?g^=u:m^=u}this.h1=g,this.h2=m}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Oe|t*36045&Ke,e=e*4283543511&Oe|((e<<16|t>>>16)*2950163797&Oe)>>>16,t^=e>>>1,t=t*444984403&Oe|t*60499&Ke,e=e*3301882366&Oe|((e<<16|t>>>16)*3120437893&Oe)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}},ko=Object.freeze({map:null,hash:"",transfer:void 0}),Rs=class{#t=!1;#e=null;#n=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){let n=this.#n.get(t);return n===void 0?e:Object.assign(e,n)}getRawValue(t){return this.#n.get(t)}remove(t){if(this.#n.delete(t),this.#n.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(let e of this.#n.values())if(e instanceof Xt)return;this.onAnnotationEditor(null)}}setValue(t,e){let n=this.#n.get(t),r=!1;if(n!==void 0)for(let[a,l]of Object.entries(e))n[a]!==l&&(r=!0,n[a]=l);else r=!0,this.#n.set(t,e);r&&this.#s(),e instanceof Xt&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#n.has(t)}getAll(){return this.#n.size>0?Ga(this.#n):null}setAll(t){for(let[e,n]of Object.entries(t))this.setValue(e,n)}get size(){return this.#n.size}#s(){this.#t||(this.#t=!0,typeof this.onSetModified=="function"&&this.onSetModified())}resetModified(){this.#t&&(this.#t=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Fr(this)}get serializable(){if(this.#n.size===0)return ko;let t=new Map,e=new Lr,n=[],r=Object.create(null),a=!1;for(let[l,u]of this.#n){let f=u instanceof Xt?u.serialize(!1,r):u;f&&(t.set(l,f),e.update(`${l}:${JSON.stringify(f)}`),a||=!!f.bitmap)}if(a)for(let l of t.values())l.bitmap&&n.push(l.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:n}:ko}get editorStats(){let t=null,e=new Map;for(let n of this.#n.values()){if(!(n instanceof Xt))continue;let r=n.telemetryFinalData;if(!r)continue;let{type:a}=r;e.has(a)||e.set(a,Object.getPrototypeOf(n).constructor),t||=Object.create(null);let l=t[a]||=new Map;for(let[u,f]of Object.entries(r)){if(u==="type")continue;let g=l.get(u);g||(g=new Map,l.set(u,g));let m=g.get(f)??0;g.set(f,m+1)}}for(let[n,r]of e)t[n]=r.computeTelemetryFinalData(t[n]);return t}resetModifiedIds(){this.#e=null}get modifiedIds(){if(this.#e)return this.#e;let t=[];for(let e of this.#n.values())!(e instanceof Xt)||!e.annotationElementId||!e.serialize()||t.push(e.annotationElementId);return this.#e={ids:new Set(t),hash:t.join(",")}}},Fr=class extends Rs{#t;constructor(t){super();let{map:e,hash:n,transfer:r}=t.serializable,a=structuredClone(e,r?{transfer:r}:null);this.#t={map:a,hash:n,transfer:r}}get print(){$t("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return Ot(this,"modifiedIds",{ids:new Set,hash:""})}},Io=class{#t=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));let e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(let t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#t.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||this.#t.has(t.loadedName))){if(te(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:n,src:r,style:a}=t,l=new FontFace(n,r,a);this.addNativeFontFace(l);try{await l.load(),this.#t.add(n),e?.(t)}catch{wt(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(l)}return}$t("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){let n=t.createNativeFontFace();if(n){this.addNativeFontFace(n);try{await n.loaded}catch(r){throw wt(`Failed to load font '${n.family}': '${r}'.`),t.disableFontFace=!0,r}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(n=>{let r=this._queueLoadingCallback(n);this._prepareFontLoadEvent(t,r)})}}get isFontLoadingAPISupported(){let t=!!this._document?.fonts;return Ot(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(ue||typeof navigator<"u"&&typeof navigator?.userAgent=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),Ot(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(te(!r.done,"completeRequest() cannot be called twice."),r.done=!0;n.length>0&&n[0].done;){let a=n.shift();setTimeout(a.callback,0)}}let{loadingRequests:n}=this,r={done:!1,complete:e,callback:t};return n.push(r),r}get _loadTestFont(){let t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return Ot(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function n(_,M){return _.charCodeAt(M)<<24|_.charCodeAt(M+1)<<16|_.charCodeAt(M+2)<<8|_.charCodeAt(M+3)&255}function r(_,M,B,H){let z=_.substring(0,M),W=_.substring(M+B);return z+H+W}let a,l,u=this._document.createElement("canvas");u.width=1,u.height=1;let f=u.getContext("2d"),g=0;function m(_,M){if(++g>30){wt("Load test font never loaded."),M();return}if(f.font="30px "+_,f.fillText(".",0,20),f.getImageData(0,0,1,1).data[3]>0){M();return}setTimeout(m.bind(null,_,M))}let y=`lt${Date.now()}${this.loadTestFontId++}`,v=this._loadTestFont;v=r(v,976,y.length,y);let T=16,C=1482184792,k=n(v,T);for(a=0,l=y.length-3;a<l;a+=4)k=k-C+n(y,a)|0;a<y.length&&(k=k-C+n(y+"XXX",a)|0),v=r(v,T,4,Rb(k));let I=`url(data:font/opentype;base64,${btoa(v)});`,O=`@font-face {font-family:"${y}";src:${I}}`;this.insertRule(O);let D=this._document.createElement("div");D.style.visibility="hidden",D.style.width=D.style.height="10px",D.style.position="absolute",D.style.top=D.style.left="0px";for(let _ of[t.loadedName,y]){let M=this._document.createElement("span");M.textContent="Hi",M.style.fontFamily=_,D.append(M)}this._document.body.append(D),m(y,()=>{D.remove(),e.complete()})}},Ro=class{constructor(t,{disableFontFace:e=!1,fontExtraProperties:n=!1,inspectFont:r=null}){this.compiledGlyphs=Object.create(null);for(let a in t)this[a]=t[a];this.disableFontFace=e===!0,this.fontExtraProperties=n===!0,this._inspectFont=r}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{let e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;let t=`url(data:${this.mimetype};base64,${Db(this.data)});`,e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let n=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(n+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${n}src:${t}}`}return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];let n=this.loadedName+"_path_"+e,r;try{r=t.get(n)}catch(l){wt(`getPathGenerator - ignoring character: "${l}".`)}let a=new Path2D(r||"");return this.fontExtraProperties||t.delete(n),this.compiledGlyphs[e]=a}},Sr={DATA:1,ERROR:2},qt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};Pn=class{#t=new AbortController;constructor(t,e,n){this.sourceName=t,this.targetName=e,this.comObj=n,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),n.addEventListener("message",this.#e.bind(this),{signal:this.#t.signal})}#e({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){this.#s(t);return}if(t.callback){let n=t.callbackId,r=this.callbackCapabilities[n];if(!r)throw new Error(`Cannot resolve callback ${n}`);if(delete this.callbackCapabilities[n],t.callback===Sr.DATA)r.resolve(t.data);else if(t.callback===Sr.ERROR)r.reject(ve(t.reason));else throw new Error("Unexpected callback case");return}let e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let n=this.sourceName,r=t.sourceName,a=this.comObj;Promise.try(e,t.data).then(function(l){a.postMessage({sourceName:n,targetName:r,callback:Sr.DATA,callbackId:t.callbackId,data:l})},function(l){a.postMessage({sourceName:n,targetName:r,callback:Sr.ERROR,callbackId:t.callbackId,reason:ve(l)})});return}if(t.streamId){this.#n(t);return}e(t.data)}on(t,e){let n=this.actionHandler;if(n[t])throw new Error(`There is already an actionName called "${t}"`);n[t]=e}send(t,e,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},n)}sendWithPromise(t,e,n){let r=this.callbackId++,a=Promise.withResolvers();this.callbackCapabilities[r]=a;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:r,data:e},n)}catch(l){a.reject(l)}return a.promise}sendWithStream(t,e,n,r){let a=this.streamId++,l=this.sourceName,u=this.targetName,f=this.comObj;return new ReadableStream({start:g=>{let m=Promise.withResolvers();return this.streamControllers[a]={controller:g,startCall:m,pullCall:null,cancelCall:null,isClosed:!1},f.postMessage({sourceName:l,targetName:u,action:t,streamId:a,data:e,desiredSize:g.desiredSize},r),m.promise},pull:g=>{let m=Promise.withResolvers();return this.streamControllers[a].pullCall=m,f.postMessage({sourceName:l,targetName:u,stream:qt.PULL,streamId:a,desiredSize:g.desiredSize}),m.promise},cancel:g=>{te(g instanceof Error,"cancel must have a valid reason");let m=Promise.withResolvers();return this.streamControllers[a].cancelCall=m,this.streamControllers[a].isClosed=!0,f.postMessage({sourceName:l,targetName:u,stream:qt.CANCEL,streamId:a,reason:ve(g)}),m.promise}},n)}#n(t){let e=t.streamId,n=this.sourceName,r=t.sourceName,a=this.comObj,l=this,u=this.actionHandler[t.action],f={enqueue(g,m=1,y){if(this.isCancelled)return;let v=this.desiredSize;this.desiredSize-=m,v>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),a.postMessage({sourceName:n,targetName:r,stream:qt.ENQUEUE,streamId:e,chunk:g},y)},close(){this.isCancelled||(this.isCancelled=!0,a.postMessage({sourceName:n,targetName:r,stream:qt.CLOSE,streamId:e}),delete l.streamSinks[e])},error(g){te(g instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,a.postMessage({sourceName:n,targetName:r,stream:qt.ERROR,streamId:e,reason:ve(g)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};f.sinkCapability.resolve(),f.ready=f.sinkCapability.promise,this.streamSinks[e]=f,Promise.try(u,t.data,f).then(function(){a.postMessage({sourceName:n,targetName:r,stream:qt.START_COMPLETE,streamId:e,success:!0})},function(g){a.postMessage({sourceName:n,targetName:r,stream:qt.START_COMPLETE,streamId:e,reason:ve(g)})})}#s(t){let e=t.streamId,n=this.sourceName,r=t.sourceName,a=this.comObj,l=this.streamControllers[e],u=this.streamSinks[e];switch(t.stream){case qt.START_COMPLETE:t.success?l.startCall.resolve():l.startCall.reject(ve(t.reason));break;case qt.PULL_COMPLETE:t.success?l.pullCall.resolve():l.pullCall.reject(ve(t.reason));break;case qt.PULL:if(!u){a.postMessage({sourceName:n,targetName:r,stream:qt.PULL_COMPLETE,streamId:e,success:!0});break}u.desiredSize<=0&&t.desiredSize>0&&u.sinkCapability.resolve(),u.desiredSize=t.desiredSize,Promise.try(u.onPull||du).then(function(){a.postMessage({sourceName:n,targetName:r,stream:qt.PULL_COMPLETE,streamId:e,success:!0})},function(g){a.postMessage({sourceName:n,targetName:r,stream:qt.PULL_COMPLETE,streamId:e,reason:ve(g)})});break;case qt.ENQUEUE:if(te(l,"enqueue should have stream controller"),l.isClosed)break;l.controller.enqueue(t.chunk);break;case qt.CLOSE:if(te(l,"close should have stream controller"),l.isClosed)break;l.isClosed=!0,l.controller.close(),this.#i(l,e);break;case qt.ERROR:te(l,"error should have stream controller"),l.controller.error(ve(t.reason)),this.#i(l,e);break;case qt.CANCEL_COMPLETE:t.success?l.cancelCall.resolve():l.cancelCall.reject(ve(t.reason)),this.#i(l,e);break;case qt.CANCEL:if(!u)break;let f=ve(t.reason);Promise.try(u.onCancel||du,f).then(function(){a.postMessage({sourceName:n,targetName:r,stream:qt.CANCEL_COMPLETE,streamId:e,success:!0})},function(g){a.postMessage({sourceName:n,targetName:r,stream:qt.CANCEL_COMPLETE,streamId:e,reason:ve(g)})}),u.sinkCapability.reject(f),u.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#i(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#t?.abort(),this.#t=null}},Dr=class{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");let n=this._createCanvas(t,e);return{canvas:n,context:n.getContext("2d",{willReadFrequently:!this.#t})}}reset(t,e,n){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||n<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=n}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){$t("Abstract method `_createCanvas` called.")}},Po=class extends Dr{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){let n=this._document.createElement("canvas");return n.width=t,n.height=e,n}},_r=class{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.");let e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(n=>({cMapData:n,isCompressed:this.isCompressed})).catch(n=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){$t("Abstract method `_fetch` called.")}},Nr=class extends _r{async _fetch(t){let e=await li(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):ai(e)}},kS=Ft(4520),Ur=class{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,n,r,a){return"none"}destroy(t=!1){}},Oo=class extends Ur{#t;#e;#n;#s;#i;#r;#l=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#s=t,this.#i=e}get#a(){return this.#e||=new Map}get#u(){return this.#r||=new Map}get#c(){if(!this.#n){let t=this.#i.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;let n=this.#i.createElementNS(nn,"svg");n.setAttribute("width",0),n.setAttribute("height",0),this.#n=this.#i.createElementNS(nn,"defs"),t.append(n),n.append(this.#n),this.#i.body.append(t)}return this.#n}#d(t){if(t.length===1){let f=t[0],g=new Array(256);for(let y=0;y<256;y++)g[y]=f[y]/255;let m=g.join(",");return[m,m,m]}let[e,n,r]=t,a=new Array(256),l=new Array(256),u=new Array(256);for(let f=0;f<256;f++)a[f]=e[f]/255,l[f]=n[f]/255,u[f]=r[f]/255;return[a.join(","),l.join(","),u.join(",")]}#h(t){if(this.#t===void 0){this.#t="";let e=this.#i.URL;e!==this.#i.baseURI&&(ci(e)?wt('#createUrl: ignore "data:"-URL for performance reasons.'):this.#t=e.split("#",1)[0])}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#a.get(t);if(e)return e;let[n,r,a]=this.#d(t),l=t.length===1?n:`${n}${r}${a}`;if(e=this.#a.get(l),e)return this.#a.set(t,e),e;let u=`g_${this.#s}_transfer_map_${this.#l++}`,f=this.#h(u);this.#a.set(t,f),this.#a.set(l,f);let g=this.#p(u);return this.#g(n,r,a,g),f}addHCMFilter(t,e){let n=`${t}-${e}`,r="base",a=this.#u.get(r);if(a?.key===n||(a?(a.filter?.remove(),a.key=n,a.url="none",a.filter=null):(a={key:n,url:"none",filter:null},this.#u.set(r,a)),!t||!e))return a.url;let l=this.#x(t);t=St.makeHexColor(...l);let u=this.#x(e);if(e=St.makeHexColor(...u),this.#c.style.color="",t==="#000000"&&e==="#ffffff"||t===e)return a.url;let f=new Array(256);for(let S=0;S<=255;S++){let T=S/255;f[S]=T<=.03928?T/12.92:((T+.055)/1.055)**2.4}let g=f.join(","),m=`g_${this.#s}_hcm_filter`,y=a.filter=this.#p(m);this.#g(g,g,g,y),this.#o(y);let v=(S,T)=>{let C=l[S]/255,k=u[S]/255,I=new Array(T+1);for(let O=0;O<=T;O++)I[O]=C+O/T*(k-C);return I.join(",")};return this.#g(v(0,5),v(1,5),v(2,5),y),a.url=this.#h(m),a.url}addAlphaFilter(t){let e=this.#a.get(t);if(e)return e;let[n]=this.#d([t]),r=`alpha_${n}`;if(e=this.#a.get(r),e)return this.#a.set(t,e),e;let a=`g_${this.#s}_alpha_map_${this.#l++}`,l=this.#h(a);this.#a.set(t,l),this.#a.set(r,l);let u=this.#p(a);return this.#y(n,u),l}addLuminosityFilter(t){let e=this.#a.get(t||"luminosity");if(e)return e;let n,r;if(t?([n]=this.#d([t]),r=`luminosity_${n}`):r="luminosity",e=this.#a.get(r),e)return this.#a.set(t,e),e;let a=`g_${this.#s}_luminosity_map_${this.#l++}`,l=this.#h(a);this.#a.set(t,l),this.#a.set(r,l);let u=this.#p(a);return this.#f(u),t&&this.#y(n,u),l}addHighlightHCMFilter(t,e,n,r,a){let l=`${e}-${n}-${r}-${a}`,u=this.#u.get(t);if(u?.key===l||(u?(u.filter?.remove(),u.key=l,u.url="none",u.filter=null):(u={key:l,url:"none",filter:null},this.#u.set(t,u)),!e||!n))return u.url;let[f,g]=[e,n].map(this.#x.bind(this)),m=Math.round(.2126*f[0]+.7152*f[1]+.0722*f[2]),y=Math.round(.2126*g[0]+.7152*g[1]+.0722*g[2]),[v,S]=[r,a].map(this.#x.bind(this));y<m&&([m,y,v,S]=[y,m,S,v]),this.#c.style.color="";let T=(I,O,D)=>{let _=new Array(256),M=(y-m)/D,B=I/255,H=(O-I)/(255*D),z=0;for(let W=0;W<=D;W++){let Q=Math.round(m+W*M),q=B+W*H;for(let bt=z;bt<=Q;bt++)_[bt]=q;z=Q+1}for(let W=z;W<256;W++)_[W]=_[z-1];return _.join(",")},C=`g_${this.#s}_hcm_${t}_filter`,k=u.filter=this.#p(C);return this.#o(k),this.#g(T(v[0],S[0],5),T(v[1],S[1],5),T(v[2],S[2],5),k),u.url=this.#h(C),u.url}destroy(t=!1){t&&this.#r?.size||(this.#n?.parentNode.parentNode.remove(),this.#n=null,this.#e?.clear(),this.#e=null,this.#r?.clear(),this.#r=null,this.#l=0)}#f(t){let e=this.#i.createElementNS(nn,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#o(t){let e=this.#i.createElementNS(nn,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#p(t){let e=this.#i.createElementNS(nn,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#c.append(e),e}#m(t,e,n){let r=this.#i.createElementNS(nn,e);r.setAttribute("type","discrete"),r.setAttribute("tableValues",n),t.append(r)}#g(t,e,n,r){let a=this.#i.createElementNS(nn,"feComponentTransfer");r.append(a),this.#m(a,"feFuncR",t),this.#m(a,"feFuncG",e),this.#m(a,"feFuncB",n)}#y(t,e){let n=this.#i.createElementNS(nn,"feComponentTransfer");e.append(n),this.#m(n,"feFuncA",t)}#x(t){return this.#c.style.color=t,Va(getComputedStyle(this.#c).getPropertyValue("color"))}},Br=class{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.");let e=`${this.baseUrl}${t}`;return this._fetch(e).catch(n=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){$t("Abstract method `_fetch` called.")}},Gr=class extends Br{async _fetch(t){let e=await li(t,"arraybuffer");return new Uint8Array(e)}};if(ue){let i;try{let t=process.getBuiltinModule("module").createRequire(__import_meta_url__);try{i=t("@napi-rs/canvas")}catch(e){wt(`Cannot load "@napi-rs/canvas" package: "${e}".`)}}catch(t){wt(`Cannot access the \`require\` function: "${t}".`)}globalThis.DOMMatrix||(i?.DOMMatrix?globalThis.DOMMatrix=i.DOMMatrix:wt("Cannot polyfill `DOMMatrix`, rendering may be broken.")),globalThis.ImageData||(i?.ImageData?globalThis.ImageData=i.ImageData:wt("Cannot polyfill `ImageData`, rendering may be broken.")),globalThis.Path2D||(i?.Path2D?globalThis.Path2D=i.Path2D:wt("Cannot polyfill `Path2D`, rendering may be broken."))}Mo=class extends Ur{},Lo=class extends Dr{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(__import_meta_url__)("@napi-rs/canvas").createCanvas(t,e)}},Fo=class extends _r{async _fetch(t){return wu(t)}},Do=class extends Br{async _fetch(t){return wu(t)}},ce={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};Ps=class{getPattern(){$t("Abstract method `getPattern` called.")}},No=class extends Ps{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(let n of this._colorStops)e.addColorStop(n[0],n[1]);return e}getPattern(t,e,n,r){let a;if(r===ce.STROKE||r===ce.FILL){let l=e.current.getClippedPathBoundingBox(r,zt(t))||[0,0,0,0],u=Math.ceil(l[2]-l[0])||1,f=Math.ceil(l[3]-l[1])||1,g=e.cachedCanvases.getCanvas("pattern",u,f),m=g.context;m.clearRect(0,0,m.canvas.width,m.canvas.height),m.beginPath(),m.rect(0,0,m.canvas.width,m.canvas.height),m.translate(-l[0],-l[1]),n=St.transform(n,[1,0,0,1,l[0],l[1]]),m.transform(...e.baseTransform),this.matrix&&m.transform(...this.matrix),_o(m,this._bbox),m.fillStyle=this._createGradient(m),m.fill(),a=t.createPattern(g.canvas,"no-repeat");let y=new DOMMatrix(n);a.setTransform(y)}else _o(t,this._bbox),a=this._createGradient(t);return a}};Uo=class extends Ps{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,n){let u=Math.floor(this._bounds[0]),f=Math.floor(this._bounds[1]),g=Math.ceil(this._bounds[2])-u,m=Math.ceil(this._bounds[3])-f,y=Math.min(Math.ceil(Math.abs(g*t[0]*1.1)),3e3),v=Math.min(Math.ceil(Math.abs(m*t[1]*1.1)),3e3),S=g/y,T=m/v,C={coords:this._coords,colors:this._colors,offsetX:-u,offsetY:-f,scaleX:1/S,scaleY:1/T},k=y+4,I=v+4,O=n.getCanvas("mesh",k,I),D=O.context,_=D.createImageData(y,v);if(e){let B=_.data;for(let H=0,z=B.length;H<z;H+=4)B[H]=e[0],B[H+1]=e[1],B[H+2]=e[2],B[H+3]=255}for(let B of this._figures)Gb(_,B,C);return D.putImageData(_,2,2),{canvas:O.canvas,offsetX:u-2*S,offsetY:f-2*T,scaleX:S,scaleY:T}}getPattern(t,e,n,r){_o(t,this._bbox);let a;if(r===ce.SHADING)a=St.singularValueDecompose2dScale(zt(t));else if(a=St.singularValueDecompose2dScale(e.baseTransform),this.matrix){let u=St.singularValueDecompose2dScale(this.matrix);a=[a[0]*u[0],a[1]*u[1]]}let l=this._createMeshCanvas(a,r===ce.SHADING?null:this._background,e.cachedCanvases);return r!==ce.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(l.offsetX,l.offsetY),t.scale(l.scaleX,l.scaleY),t.createPattern(l.canvas,"no-repeat")}},Bo=class extends Ps{getPattern(){return"hotpink"}};fu={COLORED:1,UNCOLORED:2},Go=class i{static MAX_PATTERN_SIZE=3e3;constructor(t,e,n,r,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=n,this.canvasGraphicsFactory=r,this.baseTransform=a}createPatternCanvas(t){let{bbox:e,operatorList:n,paintType:r,tilingType:a,color:l,canvasGraphicsFactory:u}=this,{xstep:f,ystep:g}=this;f=Math.abs(f),g=Math.abs(g),oi("TilingType: "+a);let m=e[0],y=e[1],v=e[2],S=e[3],T=v-m,C=S-y,k=St.singularValueDecompose2dScale(this.matrix),I=St.singularValueDecompose2dScale(this.baseTransform),O=k[0]*I[0],D=k[1]*I[1],_=T,M=C,B=!1,H=!1,z=Math.ceil(f*O),W=Math.ceil(g*D),Q=Math.ceil(T*O),q=Math.ceil(C*D);z>=Q?_=f:B=!0,W>=q?M=g:H=!0;let bt=this.getSizeAndScale(_,this.ctx.canvas.width,O),et=this.getSizeAndScale(M,this.ctx.canvas.height,D),Tt=t.cachedCanvases.getCanvas("pattern",bt.size,et.size),dt=Tt.context,Y=u.createCanvasGraphics(dt);if(Y.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(Y,r,l),dt.translate(-bt.scale*m,-et.scale*y),Y.transform(bt.scale,0,0,et.scale,0,0),dt.save(),this.clipBbox(Y,m,y,v,S),Y.baseTransform=zt(Y.ctx),Y.executeOperatorList(n),Y.endDrawing(),dt.restore(),B||H){let Z=Tt.canvas;B&&(_=f),H&&(M=g);let yt=this.getSizeAndScale(_,this.ctx.canvas.width,O),it=this.getSizeAndScale(M,this.ctx.canvas.height,D),kt=yt.size,X=it.size,at=t.cachedCanvases.getCanvas("pattern-workaround",kt,X),K=at.context,nt=B?Math.floor(T/f):0,ot=H?Math.floor(C/g):0;for(let V=0;V<=nt;V++)for(let j=0;j<=ot;j++)K.drawImage(Z,kt*V,X*j,kt,X,0,0,kt,X);return{canvas:at.canvas,scaleX:yt.scale,scaleY:it.scale,offsetX:m,offsetY:y}}return{canvas:Tt.canvas,scaleX:bt.scale,scaleY:et.scale,offsetX:m,offsetY:y}}getSizeAndScale(t,e,n){let r=Math.max(i.MAX_PATTERN_SIZE,e),a=Math.ceil(t*n);return a>=r?a=r:n=a/t,{scale:n,size:a}}clipBbox(t,e,n,r,a){let l=r-e,u=a-n;t.ctx.rect(e,n,l,u),t.current.updateRectMinMax(zt(t.ctx),[e,n,r,a]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,n){let r=t.ctx,a=t.current;switch(e){case fu.COLORED:let l=this.ctx;r.fillStyle=l.fillStyle,r.strokeStyle=l.strokeStyle,a.fillColor=l.fillStyle,a.strokeColor=l.strokeStyle;break;case fu.UNCOLORED:let u=St.makeHexColor(n[0],n[1],n[2]);r.fillStyle=u,r.strokeStyle=u,a.fillColor=u,a.strokeColor=u;break;default:throw new vo(`Unsupported paint type: ${e}`)}}getPattern(t,e,n,r){let a=n;r!==ce.SHADING&&(a=St.transform(a,e.baseTransform),this.matrix&&(a=St.transform(a,this.matrix)));let l=this.createPatternCanvas(e),u=new DOMMatrix(a);u=u.translate(l.offsetX,l.offsetY),u=u.scale(1/l.scaleX,1/l.scaleY);let f=t.createPattern(l.canvas,"repeat");return f.setTransform(u),f}};pu=16,gu=100,Vb=15,mu=10,yu=1e3,xe=16;Ho=class{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,n){let r;return this.cache[t]!==void 0?(r=this.cache[t],this.canvasFactory.reset(r,e,n)):(r=this.canvasFactory.create(e,n),this.cache[t]=r),r}delete(t){delete this.cache[t]}clear(){for(let t in this.cache){let e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}};Hr=class{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Cu,this.textMatrixScale=1,this.fontMatrix=bo,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=le.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,n){[e,n]=St.applyTransform([e,n],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,n)}updateRectMinMax(t,e){let n=St.applyTransform(e,t),r=St.applyTransform(e.slice(2),t),a=St.applyTransform([e[0],e[3]],t),l=St.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,n[0],r[0],a[0],l[0]),this.minY=Math.min(this.minY,n[1],r[1],a[1],l[1]),this.maxX=Math.max(this.maxX,n[0],r[0],a[0],l[0]),this.maxY=Math.max(this.maxY,n[1],r[1],a[1],l[1])}updateScalingPathMinMax(t,e){St.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,n,r,a,l,u,f,g,m){let y=St.bezierBoundingBox(e,n,r,a,l,u,f,g,m);m||this.updateRectMinMax(t,y)}getPathBoundingBox(t=ce.FILL,e=null){let n=[this.minX,this.minY,this.maxX,this.maxY];if(t===ce.STROKE){e||$t("Stroke bounding box must include transform.");let r=St.singularValueDecompose2dScale(e),a=r[0]*this.lineWidth/2,l=r[1]*this.lineWidth/2;n[0]-=a,n[1]-=l,n[2]+=a,n[3]+=l}return n}updateClipFromPath(){let t=St.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=ce.FILL,e=null){return St.intersect(this.clipBox,this.getPathBoundingBox(t,e))}};zb=["butt","round","square"],Xb=["miter","round","bevel"],Yb={},Su={},qn=class i{constructor(t,e,n,r,a,{optionalContentConfig:l,markedContentStack:u=null},f,g){this.ctx=t,this.current=new Hr(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=n,this.canvasFactory=r,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=u||[],this.optionalContentConfig=l,this.cachedCanvases=new Ho(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=f,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=g,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:n=!1,background:r=null}){let a=this.ctx.canvas.width,l=this.ctx.canvas.height,u=this.ctx.fillStyle;if(this.ctx.fillStyle=r||"#ffffff",this.ctx.fillRect(0,0,a,l),this.ctx.fillStyle=u,n){let f=this.cachedCanvases.getCanvas("transparent",a,l);this.compositeCtx=this.ctx,this.transparentCanvas=f.canvas,this.ctx=f.context,this.ctx.save(),this.ctx.transform(...zt(this.compositeCtx))}this.ctx.save(),Tr(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=zt(this.ctx)}executeOperatorList(t,e,n,r){let a=t.argsArray,l=t.fnArray,u=e||0,f=a.length;if(f===u)return u;let g=f-u>mu&&typeof n=="function",m=g?Date.now()+Vb:0,y=0,v=this.commonObjs,S=this.objs,T;for(;;){if(r!==void 0&&u===r.nextBreakPoint)return r.breakIt(u,n),u;if(T=l[u],T!==Ge.dependency)this[T].apply(this,a[u]);else for(let C of a[u]){let k=C.startsWith("g_")?v:S;if(!k.has(C))return k.get(C,n),u}if(u++,u===f)return u;if(g&&++y>mu){if(Date.now()>m)return n(),u;y=0}}}#t(){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)}endDrawing(){this.#t(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(let t of this._cachedBitmapsMap.values()){for(let e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#e()}#e(){if(this.pageColors){let t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){let e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){let n=t.width??t.displayWidth,r=t.height??t.displayHeight,a=Math.max(Math.hypot(e[0],e[1]),1),l=Math.max(Math.hypot(e[2],e[3]),1),u=n,f=r,g="prescale1",m,y;for(;a>2&&u>1||l>2&&f>1;){let v=u,S=f;a>2&&u>1&&(v=u>=16384?Math.floor(u/2)-1||1:Math.ceil(u/2),a/=u/v),l>2&&f>1&&(S=f>=16384?Math.floor(f/2)-1||1:Math.ceil(f)/2,l/=f/S),m=this.cachedCanvases.getCanvas(g,v,S),y=m.context,y.clearRect(0,0,v,S),y.drawImage(t,0,0,u,f,0,0,v,S),t=m.canvas,u=v,f=S,g=g==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:u,paintHeight:f}}_createMaskCanvas(t){let e=this.ctx,{width:n,height:r}=t,a=this.current.fillColor,l=this.current.patternFill,u=zt(e),f,g,m,y;if((t.bitmap||t.data)&&t.count>1){let z=t.bitmap||t.data.buffer;g=JSON.stringify(l?u:[u.slice(0,4),a]),f=this._cachedBitmapsMap.get(z),f||(f=new Map,this._cachedBitmapsMap.set(z,f));let W=f.get(g);if(W&&!l){let Q=Math.round(Math.min(u[0],u[2])+u[4]),q=Math.round(Math.min(u[1],u[3])+u[5]);return{canvas:W,offsetX:Q,offsetY:q}}m=W}m||(y=this.cachedCanvases.getCanvas("maskCanvas",n,r),vu(y.context,t));let v=St.transform(u,[1/n,0,0,-1/r,0,0]);v=St.transform(v,[1,0,0,1,0,-r]);let[S,T,C,k]=St.getAxialAlignedBoundingBox([0,0,n,r],v),I=Math.round(C-S)||1,O=Math.round(k-T)||1,D=this.cachedCanvases.getCanvas("fillCanvas",I,O),_=D.context,M=S,B=T;_.translate(-M,-B),_.transform(...v),m||(m=this._scaleImage(y.canvas,Ye(_)),m=m.img,f&&l&&f.set(g,m)),_.imageSmoothingEnabled=xu(zt(_),t.interpolate),Ar(_,m,0,0,m.width,m.height,0,0,n,r),_.globalCompositeOperation="source-in";let H=St.transform(Ye(_),[1,0,0,1,-M,-B]);return _.fillStyle=l?a.getPattern(e,this,H,ce.FILL):a,_.fillRect(0,0,n,r),f&&!l&&(this.cachedCanvases.delete("fillCanvas"),f.set(g,D.canvas)),{canvas:D.canvas,offsetX:Math.round(M),offsetY:Math.round(B)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=zb[t]}setLineJoin(t){this.ctx.lineJoin=Xb[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){let n=this.ctx;n.setLineDash!==void 0&&(n.setLineDash(t),n.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(let[e,n]of t)switch(e){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n[0],n[1]);break;case"CA":this.current.strokeAlpha=n;break;case"ca":this.current.fillAlpha=n,this.ctx.globalAlpha=n;break;case"BM":this.ctx.globalCompositeOperation=n;break;case"SMask":this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let 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");let t=this.ctx.canvas.width,e=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,r=this.cachedCanvases.getCanvas(n,t,e);this.suspendedCtx=this.ctx,this.ctx=r.context;let a=this.ctx;a.setTransform(...zt(this.suspendedCtx)),xs(this.suspendedCtx,a),Wb(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(),xs(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];let e=this.current.activeSMask,n=this.suspendedCtx;this.composeSMask(n,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,n,r){let a=r[0],l=r[1],u=r[2]-a,f=r[3]-l;u===0||f===0||(this.genericComposeSMask(e.context,n,u,f,e.subtype,e.backdrop,e.transferMap,a,l,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(n.canvas,0,0),t.restore())}genericComposeSMask(t,e,n,r,a,l,u,f,g,m,y){let v=t.canvas,S=f-m,T=g-y;if(l){let k=St.makeHexColor(...l);if(S<0||T<0||S+n>v.width||T+r>v.height){let I=this.cachedCanvases.getCanvas("maskExtension",n,r),O=I.context;O.drawImage(v,-S,-T),O.globalCompositeOperation="destination-atop",O.fillStyle=k,O.fillRect(0,0,n,r),O.globalCompositeOperation="source-over",v=I.canvas,S=T=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);let I=new Path2D;I.rect(S,T,n,r),t.clip(I),t.globalCompositeOperation="destination-atop",t.fillStyle=k,t.fillRect(S,T,n,r),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),a==="Alpha"&&u?e.filter=this.filterFactory.addAlphaFilter(u):a==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(u));let C=new Path2D;C.rect(f,g,n,r),e.clip(C),e.globalCompositeOperation="destination-in",e.drawImage(v,S,T,n,r,f,g,n,r),e.restore()}save(){this.inSMaskMode?(xs(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();let 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(),xs(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,n,r,a,l){this.ctx.transform(t,e,n,r,a,l),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,n){let r=this.ctx,a=this.current,l=a.x,u=a.y,f,g,m=zt(r),y=m[0]===0&&m[3]===0||m[1]===0&&m[2]===0,v=y?n.slice(0):null;for(let S=0,T=0,C=t.length;S<C;S++)switch(t[S]|0){case Ge.rectangle:l=e[T++],u=e[T++];let k=e[T++],I=e[T++],O=l+k,D=u+I;r.moveTo(l,u),k===0||I===0?r.lineTo(O,D):(r.lineTo(O,u),r.lineTo(O,D),r.lineTo(l,D)),y||a.updateRectMinMax(m,[l,u,O,D]),r.closePath();break;case Ge.moveTo:l=e[T++],u=e[T++],r.moveTo(l,u),y||a.updatePathMinMax(m,l,u);break;case Ge.lineTo:l=e[T++],u=e[T++],r.lineTo(l,u),y||a.updatePathMinMax(m,l,u);break;case Ge.curveTo:f=l,g=u,l=e[T+4],u=e[T+5],r.bezierCurveTo(e[T],e[T+1],e[T+2],e[T+3],l,u),a.updateCurvePathMinMax(m,f,g,e[T],e[T+1],e[T+2],e[T+3],l,u,v),T+=6;break;case Ge.curveTo2:f=l,g=u,r.bezierCurveTo(l,u,e[T],e[T+1],e[T+2],e[T+3]),a.updateCurvePathMinMax(m,f,g,l,u,e[T],e[T+1],e[T+2],e[T+3],v),l=e[T+2],u=e[T+3],T+=4;break;case Ge.curveTo3:f=l,g=u,l=e[T+2],u=e[T+3],r.bezierCurveTo(e[T],e[T+1],l,u,l,u),a.updateCurvePathMinMax(m,f,g,e[T],e[T+1],l,u,l,u,v),T+=4;break;case Ge.closePath:r.closePath();break}y&&a.updateScalingPathMinMax(m,v),a.setCurrentPoint(l,u)}closePath(){this.ctx.closePath()}stroke(t=!0){let e=this.ctx,n=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof n=="object"&&n?.getPattern?(e.save(),e.strokeStyle=n.getPattern(e,this,Ye(e),ce.STROKE),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){let e=this.ctx,n=this.current.fillColor,r=this.current.patternFill,a=!1;r&&(e.save(),e.fillStyle=n.getPattern(e,this,Ye(e),ce.FILL),a=!0);let l=this.current.getClippedPathBoundingBox();this.contentVisible&&l!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),a&&e.restore(),t&&this.consumePath(l)}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=Yb}eoClip(){this.pendingClip=Su}beginText(){this.current.textMatrix=Cu,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){let t=this.pendingTextPaths,e=this.ctx;if(t===void 0){e.beginPath();return}let n=new Path2D,r=e.getTransform().invertSelf();for(let{transform:a,x:l,y:u,fontSize:f,path:g}of t)n.addPath(g,new DOMMatrix(a).preMultiplySelf(r).translate(l,u).scale(f,-f));e.clip(n),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){let n=this.commonObjs.get(t),r=this.current;if(!n)throw new Error(`Can't find font for ${t}`);if(r.fontMatrix=n.fontMatrix||bo,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&wt("Invalid font matrix for font "+t),e<0?(e=-e,r.fontDirection=-1):r.fontDirection=1,this.current.font=n,this.current.fontSize=e,n.isType3Font)return;let a=n.loadedName||"sans-serif",l=n.systemFontInfo?.css||`"${a}", ${n.fallbackName}`,u="normal";n.black?u="900":n.bold&&(u="bold");let f=n.italic?"italic":"normal",g=e;e<pu?g=pu:e>gu&&(g=gu),this.current.fontSizeScale=e/g,this.ctx.font=`${f} ${u} ${g}px ${l}`}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,n,r,a,l){this.current.textMatrix=[t,e,n,r,a,l],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)}#n(t,e,n){let r=new Path2D;return r.addPath(t,new DOMMatrix(n).invertSelf().multiplySelf(e)),r}paintChar(t,e,n,r,a){let l=this.ctx,u=this.current,f=u.font,g=u.textRenderingMode,m=u.fontSize/u.fontSizeScale,y=g&le.FILL_STROKE_MASK,v=!!(g&le.ADD_TO_PATH_FLAG),S=u.patternFill&&!f.missingFile,T=u.patternStroke&&!f.missingFile,C;if((f.disableFontFace||v||S||T)&&(C=f.getPathGenerator(this.commonObjs,t)),f.disableFontFace||S||T){if(l.save(),l.translate(e,n),l.scale(m,-m),y===le.FILL||y===le.FILL_STROKE)if(r){let k=l.getTransform();l.setTransform(...r),l.fill(this.#n(C,k,r))}else l.fill(C);if(y===le.STROKE||y===le.FILL_STROKE)if(a){let k=l.getTransform();l.setTransform(...a),l.stroke(this.#n(C,k,a))}else l.lineWidth/=m,l.stroke(C);l.restore()}else(y===le.FILL||y===le.FILL_STROKE)&&l.fillText(t,e,n),(y===le.STROKE||y===le.FILL_STROKE)&&l.strokeText(t,e,n);v&&(this.pendingTextPaths||=[]).push({transform:zt(l),x:e,y:n,fontSize:m,path:C})}get isFontSubpixelAAEnabled(){let{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);let e=t.getImageData(0,0,10,10).data,n=!1;for(let r=3;r<e.length;r+=4)if(e[r]>0&&e[r]<255){n=!0;break}return Ot(this,"isFontSubpixelAAEnabled",n)}showText(t){let e=this.current,n=e.font;if(n.isType3Font)return this.showType3Text(t);let r=e.fontSize;if(r===0)return;let a=this.ctx,l=e.fontSizeScale,u=e.charSpacing,f=e.wordSpacing,g=e.fontDirection,m=e.textHScale*g,y=t.length,v=n.vertical,S=v?1:-1,T=n.defaultVMetrics,C=r*e.fontMatrix[0],k=e.textRenderingMode===le.FILL&&!n.disableFontFace&&!e.patternFill;a.save(),a.transform(...e.textMatrix),a.translate(e.x,e.y+e.textRise),g>0?a.scale(m,-1):a.scale(m,1);let I,O;if(e.patternFill){a.save();let H=e.fillColor.getPattern(a,this,Ye(a),ce.FILL);I=zt(a),a.restore(),a.fillStyle=H}if(e.patternStroke){a.save();let H=e.strokeColor.getPattern(a,this,Ye(a),ce.STROKE);O=zt(a),a.restore(),a.strokeStyle=H}let D=e.lineWidth,_=e.textMatrixScale;if(_===0||D===0){let H=e.textRenderingMode&le.FILL_STROKE_MASK;(H===le.STROKE||H===le.FILL_STROKE)&&(D=this.getSinglePixelWidth())}else D/=_;if(l!==1&&(a.scale(l,l),D/=l),a.lineWidth=D,n.isInvalidPDFjsFont){let H=[],z=0;for(let W of t)H.push(W.unicode),z+=W.width;a.fillText(H.join(""),0,0),e.x+=z*C*m,a.restore(),this.compose();return}let M=0,B;for(B=0;B<y;++B){let H=t[B];if(typeof H=="number"){M+=S*H*r/1e3;continue}let z=!1,W=(H.isSpace?f:0)+u,Q=H.fontChar,q=H.accent,bt,et,Tt=H.width;if(v){let Y=H.vmetric||T,Z=-(H.vmetric?Y[1]:Tt*.5)*C,yt=Y[2]*C;Tt=Y?-Y[0]:Tt,bt=Z/l,et=(M+yt)/l}else bt=M/l,et=0;if(n.remeasure&&Tt>0){let Y=a.measureText(Q).width*1e3/r*l;if(Tt<Y&&this.isFontSubpixelAAEnabled){let Z=Tt/Y;z=!0,a.save(),a.scale(Z,1),bt/=Z}else Tt!==Y&&(bt+=(Tt-Y)/2e3*r/l)}if(this.contentVisible&&(H.isInFont||n.missingFile)){if(k&&!q)a.fillText(Q,bt,et);else if(this.paintChar(Q,bt,et,I,O),q){let Y=bt+r*q.offset.x/l,Z=et-r*q.offset.y/l;this.paintChar(q.fontChar,Y,Z,I,O)}}let dt=v?Tt*C-W*g:Tt*C+W*g;M+=dt,z&&a.restore()}v?e.y-=M:e.x+=M*m,a.restore(),this.compose()}showType3Text(t){let e=this.ctx,n=this.current,r=n.font,a=n.fontSize,l=n.fontDirection,u=r.vertical?1:-1,f=n.charSpacing,g=n.wordSpacing,m=n.textHScale*l,y=n.fontMatrix||bo,v=t.length,S=n.textRenderingMode===le.INVISIBLE,T,C,k,I;if(!(S||a===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...n.textMatrix),e.translate(n.x,n.y),e.scale(m,l),T=0;T<v;++T){if(C=t[T],typeof C=="number"){I=u*C*a/1e3,this.ctx.translate(I,0),n.x+=I*m;continue}let O=(C.isSpace?g:0)+f,D=r.charProcOperatorList[C.operatorListId];if(!D){wt(`Type3 character "${C.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=C,this.save(),e.scale(a,a),e.transform(...y),this.executeOperatorList(D),this.restore()),k=St.applyTransform([C.width,0],y)[0]*a+O,e.translate(k,0),n.x+=k*m}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,n,r,a,l){this.ctx.rect(n,r,a-n,l-r),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){let n=t[1],r=this.baseTransform||zt(this.ctx),a={createCanvasGraphics:l=>new i(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Go(t,n,this.ctx,a,r)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,n){this.ctx.strokeStyle=this.current.strokeColor=St.makeHexColor(t,e,n),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,n){this.ctx.fillStyle=this.current.fillColor=St.makeHexColor(t,e,n),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let n;return this.cachedPatterns.has(t)?n=this.cachedPatterns.get(t):(n=Hb(this.getObject(t)),this.cachedPatterns.set(t,n)),e&&(n.matrix=e),n}shadingFill(t){if(!this.contentVisible)return;let e=this.ctx;this.save();let n=this._getPattern(t);e.fillStyle=n.getPattern(e,this,Ye(e),ce.SHADING);let r=Ye(e);if(r){let{width:a,height:l}=e.canvas,[u,f,g,m]=St.getAxialAlignedBoundingBox([0,0,a,l],r);this.ctx.fillRect(u,f,g-u,m-f)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){$t("Should not call beginInlineImage")}beginImageData(){$t("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=zt(this.ctx),e)){let n=e[2]-e[0],r=e[3]-e[1];this.ctx.rect(e[0],e[1],n,r),this.current.updateRectMinMax(zt(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);let e=this.ctx;t.isolated||oi("TODO: Support non-isolated groups."),t.knockout&&wt("Knockout groups not supported.");let n=zt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let r=St.getAxialAlignedBoundingBox(t.bbox,zt(e)),a=[0,0,e.canvas.width,e.canvas.height];r=St.intersect(r,a)||[0,0,0,0];let l=Math.floor(r[0]),u=Math.floor(r[1]),f=Math.max(Math.ceil(r[2])-l,1),g=Math.max(Math.ceil(r[3])-u,1);this.current.startNewPathAndClipBox([0,0,f,g]);let m="groupAt"+this.groupLevel;t.smask&&(m+="_smask_"+this.smaskCounter++%2);let y=this.cachedCanvases.getCanvas(m,f,g),v=y.context;v.translate(-l,-u),v.transform(...n),t.smask?this.smaskStack.push({canvas:y.canvas,context:v,offsetX:l,offsetY:u,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(l,u),e.save()),xs(e,v),this.ctx=v,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;let e=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let r=zt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...r);let a=St.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],r);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(a)}}beginAnnotation(t,e,n,r,a){if(this.#t(),Tr(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){let l=e[2]-e[0],u=e[3]-e[1];if(a&&this.annotationCanvasMap){n=n.slice(),n[4]-=e[0],n[5]-=e[1],e=e.slice(),e[0]=e[1]=0,e[2]=l,e[3]=u;let[f,g]=St.singularValueDecompose2dScale(zt(this.ctx)),{viewportScale:m}=this,y=Math.ceil(l*this.outputScaleX*m),v=Math.ceil(u*this.outputScaleY*m);this.annotationCanvas=this.canvasFactory.create(y,v);let{canvas:S,context:T}=this.annotationCanvas;this.annotationCanvasMap.set(t,S),this.annotationCanvas.savedCtx=this.ctx,this.ctx=T,this.ctx.save(),this.ctx.setTransform(f,0,0,-g,0,u*g),Tr(this.ctx)}else Tr(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],l,u),this.ctx.clip(),this.ctx.beginPath()}this.current=new Hr(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...r)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#e(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;let e=t.count;t=this.getObject(t.data,t),t.count=e;let n=this.ctx,r=this.processingType3;if(r&&(r.compiled===void 0&&(r.compiled=$b(t)),r.compiled)){r.compiled(n);return}let a=this._createMaskCanvas(t),l=a.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(l,a.offsetX,a.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,n=0,r=0,a,l){if(!this.contentVisible)return;t=this.getObject(t.data,t);let u=this.ctx;u.save();let f=zt(u);u.transform(e,n,r,a,0,0);let g=this._createMaskCanvas(t);u.setTransform(1,0,0,1,g.offsetX-f[4],g.offsetY-f[5]);for(let m=0,y=l.length;m<y;m+=2){let v=St.transform(f,[e,n,r,a,l[m],l[m+1]]),[S,T]=St.applyTransform([0,0],v);u.drawImage(g.canvas,S,T)}u.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;let e=this.ctx,n=this.current.fillColor,r=this.current.patternFill;for(let a of t){let{data:l,width:u,height:f,transform:g}=a,m=this.cachedCanvases.getCanvas("maskCanvas",u,f),y=m.context;y.save();let v=this.getObject(l,a);vu(y,v),y.globalCompositeOperation="source-in",y.fillStyle=r?n.getPattern(y,this,Ye(e),ce.FILL):n,y.fillRect(0,0,u,f),y.restore(),e.save(),e.transform(...g),e.scale(1,-1),Ar(e,m.canvas,0,0,u,f,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;let e=this.getObject(t);if(!e){wt("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,n,r){if(!this.contentVisible)return;let a=this.getObject(t);if(!a){wt("Dependent image isn't ready yet");return}let l=a.width,u=a.height,f=[];for(let g=0,m=r.length;g<m;g+=2)f.push({transform:[e,0,0,n,r[g],r[g+1]],x:0,y:0,w:l,h:u});this.paintInlineImageXObjectGroup(a,f)}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;let{bitmap:e,width:n,height:r}=t,a=this.cachedCanvases.getCanvas("inlineImage",n,r),l=a.context;return l.filter=this.current.transferMaps,l.drawImage(e,0,0),l.filter="none",a.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;let e=t.width,n=t.height,r=this.ctx;if(this.save(),!ue){let{filter:u}=r;u!=="none"&&u!==""&&(r.filter="none")}r.scale(1/e,-1/n);let a;if(t.bitmap)a=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)a=t;else{let f=this.cachedCanvases.getCanvas("inlineImage",e,n).context;bu(f,t),a=this.applyTransferMapsToCanvas(f)}let l=this._scaleImage(a,Ye(r));r.imageSmoothingEnabled=xu(zt(r),t.interpolate),Ar(r,l.img,0,0,l.paintWidth,l.paintHeight,0,-n,e,n),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;let n=this.ctx,r;if(t.bitmap)r=t.bitmap;else{let a=t.width,l=t.height,f=this.cachedCanvases.getCanvas("inlineImage",a,l).context;bu(f,t),r=this.applyTransferMapsToCanvas(f)}for(let a of e)n.save(),n.transform(...a.transform),n.scale(1,-1),Ar(n,r,a.x,a.y,a.w,a.h,0,-1,1,1),n.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){let e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);let n=this.ctx;this.pendingClip&&(e||(this.pendingClip===Su?n.clip("evenodd"):n.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),n.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let t=zt(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{let e=Math.abs(t[0]*t[3]-t[2]*t[1]),n=Math.hypot(t[0],t[2]),r=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(n,r)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:t}=this.current,{a:e,b:n,c:r,d:a}=this.ctx.getTransform(),l,u;if(n===0&&r===0){let f=Math.abs(e),g=Math.abs(a);if(f===g)if(t===0)l=u=1/f;else{let m=f*t;l=u=m<1?1/m:1}else if(t===0)l=1/f,u=1/g;else{let m=f*t,y=g*t;l=m<1?1/m:1,u=y<1?1/y:1}}else{let f=Math.abs(e*a-n*r),g=Math.hypot(e,n),m=Math.hypot(r,a);if(t===0)l=m/f,u=g/f;else{let y=t*f;l=m>y?m/y:1,u=g>y?g/y:1}}this._cachedScaleForStroking[0]=l,this._cachedScaleForStroking[1]=u}return this._cachedScaleForStroking}rescaleAndStroke(t){let{ctx:e}=this,{lineWidth:n}=this.current,[r,a]=this.getScaleForStroking();if(e.lineWidth=n||1,r===1&&a===1){e.stroke();return}let l=e.getLineDash();if(t&&e.save(),e.scale(r,a),l.length>0){let u=Math.max(r,a);e.setLineDash(l.map(f=>f/u)),e.lineDashOffset/=u}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};for(let i in Ge)qn.prototype[i]!==void 0&&(qn.prototype[Ge[i]]=qn.prototype[i]);On=class{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");this.#e=t}},jo=class{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}getAll(){return Ga(this.#t)}has(t){return this.#t.has(t)}},Jn=Symbol("INTERNAL"),Vo=class{#t=!1;#e=!1;#n=!1;#s=!0;constructor(t,{name:e,intent:n,usage:r,rbGroups:a}){this.#t=!!(t&Ee.DISPLAY),this.#e=!!(t&Ee.PRINT),this.name=e,this.intent=n,this.usage=r,this.rbGroups=a}get visible(){if(this.#n)return this.#s;if(!this.#s)return!1;let{print:t,view:e}=this.usage;return this.#t?e?.viewState!=="OFF":this.#e?t?.printState!=="OFF":!0}_setVisible(t,e,n=!1){t!==Jn&&$t("Internal method `_setVisible` called."),this.#n=n,this.#s=e}},Wo=class{#t=null;#e=new Map;#n=null;#s=null;constructor(t,e=Ee.DISPLAY){if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,this.#s=t.order;for(let n of t.groups)this.#e.set(n.id,new Vo(e,n));if(t.baseState==="OFF")for(let n of this.#e.values())n._setVisible(Jn,!1);for(let n of t.on)this.#e.get(n)._setVisible(Jn,!0);for(let n of t.off)this.#e.get(n)._setVisible(Jn,!1);this.#n=this.getHash()}}#i(t){let e=t.length;if(e<2)return!0;let n=t[0];for(let r=1;r<e;r++){let a=t[r],l;if(Array.isArray(a))l=this.#i(a);else if(this.#e.has(a))l=this.#e.get(a).visible;else return wt(`Optional content group not found: ${a}`),!0;switch(n){case"And":if(!l)return!1;break;case"Or":if(l)return!0;break;case"Not":return!l;default:return!0}}return n==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return oi("Optional content group not defined."),!0;if(t.type==="OCG")return this.#e.has(t.id)?this.#e.get(t.id).visible:(wt(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return this.#i(t.expression);if(!t.policy||t.policy==="AnyOn"){for(let e of t.ids){if(!this.#e.has(e))return wt(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(let e of t.ids){if(!this.#e.has(e))return wt(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(let e of t.ids){if(!this.#e.has(e))return wt(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(let e of t.ids){if(!this.#e.has(e))return wt(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return wt(`Unknown optional content policy ${t.policy}.`),!0}return wt(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,n=!0){let r=this.#e.get(t);if(!r){wt(`Optional content group not found: ${t}`);return}if(n&&e&&r.rbGroups.length)for(let a of r.rbGroups)for(let l of a)l!==t&&this.#e.get(l)?._setVisible(Jn,!1,!0);r._setVisible(Jn,!!e,!0),this.#t=null}setOCGState({state:t,preserveRB:e}){let n;for(let r of t){switch(r){case"ON":case"OFF":case"Toggle":n=r;continue}let a=this.#e.get(r);if(a)switch(n){case"ON":this.setVisibility(r,!0,e);break;case"OFF":this.setVisibility(r,!1,e);break;case"Toggle":this.setVisibility(r,!a.visible,e);break}}this.#t=null}get hasInitialVisibility(){return this.#n===null||this.getHash()===this.#n}getOrder(){return this.#e.size?this.#s?this.#s.slice():[...this.#e.keys()]:null}getGroups(){return this.#e.size>0?Ga(this.#e):null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;let t=new Lr;for(let[e,n]of this.#e)t.update(`${e}:${n.visible}`);return this.#t=t.hexdigest()}},$o=class{constructor(t,{disableRange:e=!1,disableStream:n=!1}){te(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');let{length:r,initialData:a,progressiveDone:l,contentDispositionFilename:u}=t;if(this._queuedChunks=[],this._progressiveDone=l,this._contentDispositionFilename=u,a?.length>0){let f=a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer;this._queuedChunks.push(f)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!n,this._isRangeSupported=!e,this._contentLength=r,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((f,g)=>{this._onReceiveData({begin:f,chunk:g})}),t.addProgressListener((f,g)=>{this._onProgress({loaded:f,total:g})}),t.addProgressiveReadListener(f=>{this._onReceiveData({chunk:f})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){let n=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n);else{let r=this._rangeReaders.some(function(a){return a._begin!==t?!1:(a._enqueue(n),!0)});te(r,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){t.total===void 0?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){let e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){te(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let t=this._queuedChunks;return this._queuedChunks=null,new zo(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let n=new Xo(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(n),n}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}},zo=class{constructor(t,e,n=!1,r=null){this._stream=t,this._done=n||!1,this._filename=ja(r)?r:null,this._queuedChunks=e||[],this._loaded=0;for(let 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};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}},Xo=class{constructor(t,e,n){this._stream=t,this._begin=e,this._end=n,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(let n of this._requests)n.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){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}};jr=class{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=ku(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return te(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Yo(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let n=new Ko(this,t,e);return this._rangeRequestReaders.push(n),n}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeRequestReaders.slice(0))e.cancel(t)}},Yo=class{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;let 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;let n=new Headers(t.headers),r=e.url;fetch(r,Ou(n,this._withCredentials,this._abortController)).then(a=>{if(t._responseOrigin=ui(a.url),!Pu(a.status))throw hi(a.status,r);this._reader=a.body.getReader(),this._headersCapability.resolve();let l=a.headers,{allowRangeRequests:u,suggestedLength:f}=Iu({responseHeaders:l,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=u,this._contentLength=f||this._contentLength,this._filename=Ru(l),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Ze("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:Mu(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}},Ko=class{constructor(t,e,n){this._stream=t,this._reader=null,this._loaded=0;let r=t.source;this._withCredentials=r.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!r.disableStream,this._abortController=new AbortController;let a=new Headers(t.headers);a.append("Range",`bytes=${e}-${n-1}`);let l=r.url;fetch(l,Ou(a,this._withCredentials,this._abortController)).then(u=>{let f=ui(u.url);if(f!==t._responseOrigin)throw new Error(`Expected range response-origin "${f}" to match "${t._responseOrigin}".`);if(!Pu(u.status))throw hi(u.status,l);this._readCapability.resolve(),this._reader=u.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:Mu(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}},mo=200,yo=206;Zo=class{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:n}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=ku(this.isHttp,e),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){let e=new XMLHttpRequest,n=this.currXhrId++,r=this.pendingRequests[n]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(let[a,l]of this.headers)e.setRequestHeader(a,l);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),r.expectedStatus=yo):r.expectedStatus=mo,e.responseType="arraybuffer",te(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,n),e.onprogress=this.onProgress.bind(this,n),r.onHeadersReceived=t.onHeadersReceived,r.onDone=t.onDone,r.onError=t.onError,r.onProgress=t.onProgress,e.send(null),n}onProgress(t,e){let n=this.pendingRequests[t];n&&n.onProgress?.(e)}onStateChange(t,e){let n=this.pendingRequests[t];if(!n)return;let r=n.xhr;if(r.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),r.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],r.status===0&&this.isHttp){n.onError(r.status);return}let a=r.status||mo;if(!(a===mo&&n.expectedStatus===yo)&&a!==n.expectedStatus){n.onError(r.status);return}let u=Zb(r);if(a===yo){let f=r.getResponseHeader("Content-Range"),g=/bytes (\d+)-(\d+)\/(\d+)/.exec(f);g?n.onDone({begin:parseInt(g[1],10),chunk:u}):(wt('Missing or invalid "Content-Range" header.'),n.onError(0))}else u?n.onDone({begin:0,chunk:u}):n.onError(r.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){let e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}},Qo=class{constructor(t){this._source=t,this._manager=new Zo(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){let e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return te(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Jo(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){let n=new qo(this._manager,t,e);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeRequestReaders.slice(0))e.cancel(t)}},Jo=class{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){let t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=ui(e.responseURL);let n=e.getAllResponseHeaders(),r=new Headers(n?n.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(u=>{let[f,...g]=u.split(": ");return[f,g.join(": ")]}):[]),{allowRangeRequests:a,suggestedLength:l}=Iu({responseHeaders:r,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});a&&(this._isRangeSupported=!0),this._contentLength=l||this._contentLength,this._filename=Ru(r),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(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=hi(t,this._url),this._headersCapability.reject(this._storedError);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(let 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}},qo=class{constructor(t,e,n){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:n,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){let t=ui(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){let e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(let n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??=hi(t,this._url);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(let 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()}},Qb=/^[a-z][a-z0-9\-+.]+:/i;ta=class{constructor(t){this.source=t,this.url=Jb(t.url),te(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return te(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new ea(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let n=new na(this,t,e);return this._rangeRequestReaders.push(n),n}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeRequestReaders.slice(0))e.cancel(t)}},ea=class{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;let 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();let n=process.getBuiltinModule("fs");n.promises.lstat(this._url).then(r=>{this._contentLength=r.size,this._setReadableStream(n.createReadStream(this._url)),this._headersCapability.resolve()},r=>{r.code==="ENOENT"&&(r=new Mn(`Missing PDF "${this._url}".`)),this._storedError=r,this._headersCapability.reject(r)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Ze("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}},na=class{constructor(t,e,n){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();let r=t.source;this._isStreamingSupported=!r.disableStream;let a=process.getBuiltinModule("fs");this._setReadableStream(a.createReadStream(this._url,{start:e,end:n-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}},qb=1e5,be=30,t0=.8,Os=class i{#t=Promise.withResolvers();#e=null;#n=!1;#s=!!globalThis.FontInspector?.enabled;#i=null;#r=null;#l=0;#a=0;#u=null;#c=null;#d=0;#h=0;#f=Object.create(null);#o=[];#p=null;#m=[];#g=new WeakMap;#y=null;static#x=new Map;static#b=new Map;static#S=new WeakMap;static#T=null;static#E=new Set;constructor({textContentSource:t,container:e,viewport:n}){if(t instanceof ReadableStream)this.#p=t;else if(typeof t=="object")this.#p=new ReadableStream({start(f){f.enqueue(t),f.close()}});else throw new Error('No "textContentSource" parameter specified.');this.#e=this.#c=e,this.#h=n.scale*(globalThis.devicePixelRatio||1),this.#d=n.rotation,this.#r={div:null,properties:null,ctx:null};let{pageWidth:r,pageHeight:a,pageX:l,pageY:u}=n.rawDims;this.#y=[1,0,0,-1,-l,u+a],this.#a=r,this.#l=a,i.#O(),Ln(e,n),this.#t.promise.finally(()=>{i.#E.delete(this),this.#r=null,this.#f=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:t,isFirefox:e}=se.platform;return Ot(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){let t=()=>{this.#u.read().then(({value:e,done:n})=>{if(n){this.#t.resolve();return}this.#i??=e.lang,Object.assign(this.#f,e.styles),this.#k(e.items),t()},this.#t.reject)};return this.#u=this.#p.getReader(),i.#E.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){let n=t.scale*(globalThis.devicePixelRatio||1),r=t.rotation;if(r!==this.#d&&(e?.(),this.#d=r,Ln(this.#c,{rotation:r})),n!==this.#h){e?.(),this.#h=n;let a={div:null,properties:null,ctx:i.#I(this.#i)};for(let l of this.#m)a.properties=this.#g.get(l),a.div=l,this.#A(a)}}cancel(){let t=new Ze("TextLayer task cancelled.");this.#u?.cancel(t).catch(()=>{}),this.#u=null,this.#t.reject(t)}get textDivs(){return this.#m}get textContentItemsStr(){return this.#o}#k(t){if(this.#n)return;this.#r.ctx??=i.#I(this.#i);let e=this.#m,n=this.#o;for(let r of t){if(e.length>qb){wt("Ignoring additional textDivs for performance reasons."),this.#n=!0;return}if(r.str===void 0){if(r.type==="beginMarkedContentProps"||r.type==="beginMarkedContent"){let a=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),r.id!==null&&this.#e.setAttribute("id",`${r.id}`),a.append(this.#e)}else r.type==="endMarkedContent"&&(this.#e=this.#e.parentNode);continue}n.push(r.str),this.#R(r)}}#R(t){let e=document.createElement("span"),n={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#m.push(e);let r=St.transform(this.#y,t.transform),a=Math.atan2(r[1],r[0]),l=this.#f[t.fontName];l.vertical&&(a+=Math.PI/2);let u=this.#s&&l.fontSubstitution||l.fontFamily;u=i.fontFamilyMap.get(u)||u;let f=Math.hypot(r[2],r[3]),g=f*i.#F(u,this.#i),m,y;a===0?(m=r[4],y=r[5]-g):(m=r[4]+g*Math.sin(a),y=r[5]-g*Math.cos(a));let v="calc(var(--scale-factor)*",S=e.style;this.#e===this.#c?(S.left=`${(100*m/this.#a).toFixed(2)}%`,S.top=`${(100*y/this.#l).toFixed(2)}%`):(S.left=`${v}${m.toFixed(2)}px)`,S.top=`${v}${y.toFixed(2)}px)`),S.fontSize=`${v}${(i.#T*f).toFixed(2)}px)`,S.fontFamily=u,n.fontSize=f,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#s&&(e.dataset.fontName=l.fontSubstitutionLoadedName||t.fontName),a!==0&&(n.angle=a*(180/Math.PI));let T=!1;if(t.str.length>1)T=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){let C=Math.abs(t.transform[0]),k=Math.abs(t.transform[3]);C!==k&&Math.max(C,k)/Math.min(C,k)>1.5&&(T=!0)}if(T&&(n.canvasWidth=l.vertical?t.height:t.width),this.#g.set(e,n),this.#r.div=e,this.#r.properties=n,this.#A(this.#r),n.hasText&&this.#e.append(e),n.hasEOL){let C=document.createElement("br");C.setAttribute("role","presentation"),this.#e.append(C)}}#A(t){let{div:e,properties:n,ctx:r}=t,{style:a}=e,l="";if(i.#T>1&&(l=`scale(${1/i.#T})`),n.canvasWidth!==0&&n.hasText){let{fontFamily:u}=a,{canvasWidth:f,fontSize:g}=n;i.#w(r,g*this.#h,u);let{width:m}=r.measureText(e.textContent);m>0&&(l=`scaleX(${f*this.#h/m}) ${l}`)}n.angle!==0&&(l=`rotate(${n.angle}deg) ${l}`),l.length>0&&(a.transform=l)}static cleanup(){if(!(this.#E.size>0)){this.#x.clear();for(let{canvas:t}of this.#b.values())t.remove();this.#b.clear()}}static#I(t=null){let e=this.#b.get(t||="");if(!e){let n=document.createElement("canvas");n.className="hiddenCanvasElement",n.lang=t,document.body.append(n),e=n.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#b.set(t,e),this.#S.set(e,{size:0,family:""})}return e}static#w(t,e,n){let r=this.#S.get(t);e===r.size&&n===r.family||(t.font=`${e}px ${n}`,r.size=e,r.family=n)}static#O(){if(this.#T!==null)return;let 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),this.#T=t.getBoundingClientRect().height,t.remove()}static#F(t,e){let n=this.#x.get(t);if(n)return n;let r=this.#I(e);r.canvas.width=r.canvas.height=be,this.#w(r,be,t);let a=r.measureText(""),l=a.fontBoundingBoxAscent,u=Math.abs(a.fontBoundingBoxDescent);if(l){let m=l/(l+u);return this.#x.set(t,m),r.canvas.width=r.canvas.height=0,m}r.strokeStyle="red",r.clearRect(0,0,be,be),r.strokeText("g",0,0);let f=r.getImageData(0,0,be,be).data;u=0;for(let m=f.length-1-3;m>=0;m-=4)if(f[m]>0){u=Math.ceil(m/4/be);break}r.clearRect(0,0,be,be),r.strokeText("A",0,be),f=r.getImageData(0,0,be,be).data,l=0;for(let m=0,y=f.length;m<y;m+=4)if(f[m]>0){l=be-Math.floor(m/4/be);break}r.canvas.width=r.canvas.height=0;let g=l?l/(l+u):t0;return this.#x.set(t,g),g}},Ms=class i{static textContent(t){let e=[],n={items:e,styles:Object.create(null)};function r(a){if(!a)return;let l=null,u=a.name;if(u==="#text")l=a.value;else if(i.shouldBuildText(u))a?.attributes?.textContent?l=a.attributes.textContent:a.value&&(l=a.value);else return;if(l!==null&&e.push({str:l}),!!a.children)for(let f of a.children)r(f)}return r(t),n}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}},e0=65536,n0=100,s0=5e3,r0=ue?Lo:Po,i0=ue?Fo:Nr,o0=ue?Mo:Oo,a0=ue?Do:Gr;sa=class i{static#t=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${i.#t++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}},Vr=class{constructor(t,e,n=!1,r=null){this.length=t,this.initialData=e,this.progressiveDone=n,this.contentDispositionFilename=r,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(let n of this._rangeListeners)n(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(let n of this._progressListeners)n(t,e)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(let e of this._progressiveReadListeners)e(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(let t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){$t("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}},ra=class{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Ot(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){let{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()}},ia=class{#t=null;#e=!1;constructor(t,e,n,r=!1){this._pageIndex=t,this._pageInfo=e,this._transport=n,this._stats=r?new Ir:null,this._pdfBug=r,this.commonObjs=n.commonObjs,this.objs=new Wr,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}get trimBox(){return this._pageInfo.trimBox??null}get bleedBox(){return this._pageInfo.bleedBox??null}get colorSpaceResources(){return this._pageInfo.colorSpaceResources??{}}get imglyPatchVersion(){return this._pageInfo.imglyPatchVersion??null}getViewport({scale:t,rotation:e=this.rotate,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}={}){return new ws({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:n,offsetY:r,dontFlip:a})}getAnnotations({intent:t="display"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Ot(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:n="display",annotationMode:r=gn.ENABLE,transform:a=null,background:l=null,optionalContentConfigPromise:u=null,annotationCanvasMap:f=null,pageColors:g=null,printAnnotationStorage:m=null,isEditing:y=!1}){this._stats?.time("Overall");let v=this._transport.getRenderingIntent(n,r,m,y),{renderingIntent:S,cacheKey:T}=v;this.#e=!1,this.#s(),u||=this._transport.getOptionalContentConfig(S);let C=this._intentStates.get(T);C||(C=Object.create(null),this._intentStates.set(T,C)),C.streamReaderCancelTimeout&&(clearTimeout(C.streamReaderCancelTimeout),C.streamReaderCancelTimeout=null);let k=!!(S&Ee.PRINT);C.displayReadyCapability||(C.displayReadyCapability=Promise.withResolvers(),C.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(v));let I=_=>{C.renderTasks.delete(O),(this._maybeCleanupAfterRender||k)&&(this.#e=!0),this.#n(!k),_?(O.capability.reject(_),this._abortOperatorList({intentState:C,reason:_ instanceof Error?_:new Error(_)})):O.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},O=new ca({callback:I,params:{canvasContext:t,viewport:e,transform:a,background:l},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:f,operatorList:C.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!k,pdfBug:this._pdfBug,pageColors:g});(C.renderTasks||=new Set).add(O);let D=O.task;return Promise.all([C.displayReadyCapability.promise,u]).then(([_,M])=>{if(this.destroyed){I();return}if(this._stats?.time("Rendering"),!(M.renderingIntent&S))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");O.initializeGraphics({transparency:_,optionalContentConfig:M}),O.operatorListChanged()}).catch(I),D}getOperatorList({intent:t="display",annotationMode:e=gn.ENABLE,printAnnotationStorage:n=null,isEditing:r=!1}={}){function a(){u.operatorList.lastChunk&&(u.opListReadCapability.resolve(u.operatorList),u.renderTasks.delete(f))}let l=this._transport.getRenderingIntent(t,e,n,r,!0),u=this._intentStates.get(l.cacheKey);u||(u=Object.create(null),this._intentStates.set(l.cacheKey,u));let f;return u.opListReadCapability||(f=Object.create(null),f.operatorListChanged=a,u.opListReadCapability=Promise.withResolvers(),(u.renderTasks||=new Set).add(f),u.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(l)),u.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(r){return r.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(n=>Ms.textContent(n));let e=this.streamTextContent(t);return new Promise(function(n,r){function a(){l.read().then(function({value:f,done:g}){if(g){n(u);return}u.lang??=f.lang,Object.assign(u.styles,f.styles),u.items.push(...f.items),a()},r)}let l=e.getReader(),u={items:[],styles:Object.create(null),lang:null};a()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let t=[];for(let e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(let n of e.renderTasks)t.push(n.completed),n.cancel();return this.objs.clear(),this.#e=!1,this.#s(),Promise.all(t)}cleanup(t=!1){this.#e=!0;let e=this.#n(!1);return t&&e&&(this._stats&&=new Ir),e}#n(t=!1){if(this.#s(),!this.#e||this.destroyed)return!1;if(t)return this.#t=setTimeout(()=>{this.#t=null,this.#n(!1)},s0),!1;for(let{renderTasks:e,operatorList:n}of this._intentStates.values())if(e.size>0||!n.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#e=!1,!0}#s(){this.#t&&(clearTimeout(this.#t),this.#t=null)}_startRenderPage(t,e){let n=this._intentStates.get(e);n&&(this._stats?.timeEnd("Page Request"),n.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let n=0,r=t.length;n<r;n++)e.operatorList.fnArray.push(t.fnArray[n]),e.operatorList.argsArray.push(t.argsArray[n]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(let n of e.renderTasks)n.operatorListChanged();t.lastChunk&&this.#n(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:n,modifiedIds:r}){let{map:a,transfer:l}=n,f=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:a,modifiedIds:r},l).getReader(),g=this._intentStates.get(e);g.streamReader=f;let m=()=>{f.read().then(({value:y,done:v})=>{if(v){g.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(y,g),m())},y=>{if(g.streamReader=null,!this._transport.destroyed){if(g.operatorList){g.operatorList.lastChunk=!0;for(let v of g.renderTasks)v.operatorListChanged();this.#n(!0)}if(g.displayReadyCapability)g.displayReadyCapability.reject(y);else if(g.opListReadCapability)g.opListReadCapability.reject(y);else throw y}})};m()}_abortOperatorList({intentState:t,reason:e,force:n=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!n){if(t.renderTasks.size>0)return;if(e instanceof ks){let r=n0;e.extraDelay>0&&e.extraDelay<1e3&&(r+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},r);return}}if(t.streamReader.cancel(new Ze(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(let[r,a]of this._intentStates)if(a===t){this._intentStates.delete(r);break}this.cleanup()}}}get stats(){return this._stats}},oa=class{#t=new Map;#e=Promise.resolve();postMessage(t,e){let n={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(let[r]of this.#t)r.call(this,n)})}addEventListener(t,e,n=null){let r=null;if(n?.signal instanceof AbortSignal){let{signal:a}=n;if(a.aborted){wt("LoopbackPort - cannot use an `aborted` signal.");return}let l=()=>this.removeEventListener(t,e);r=()=>a.removeEventListener("abort",l),a.addEventListener("abort",l)}this.#t.set(e,r)}removeEventListener(t,e){this.#t.get(e)?.(),this.#t.delete(e)}terminate(){for(let[,t]of this.#t)t?.();this.#t.clear()}},ts=class i{static#t=0;static#e=!1;static#n;static{ue&&(this.#e=!0,On.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let n;try{if(n=new URL(t),!n.origin||n.origin==="null")return!1}catch{return!1}let r=new URL(e,n);return n.origin===r.origin},this._createCDNWrapper=t=>{let e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:t=null,port:e=null,verbosity:n=wb()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=n,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(i.#n?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(i.#n||=new WeakMap).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return this._readyCapability.promise}#s(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new Pn("main","worker",t),this._messageHandler.on("ready",function(){}),this.#s()}_initialize(){if(i.#e||i.#i){this._setupFakeWorker();return}let{workerSrc:t}=i;try{i._isSameOrigin(window.location.href,t)||(t=i._createCDNWrapper(new URL(t,window.location).href));let e=new Worker(t,{type:"module"}),n=new Pn("main","worker",e),r=()=>{a.abort(),n.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},a=new AbortController;e.addEventListener("error",()=>{this._webWorker||r()},{signal:a.signal}),n.on("test",u=>{if(a.abort(),this.destroyed||!u){r();return}this._messageHandler=n,this._port=e,this._webWorker=e,this.#s()}),n.on("ready",u=>{if(a.abort(),this.destroyed){r();return}try{l()}catch{this._setupFakeWorker()}});let l=()=>{let u=new Uint8Array;n.send("test",u,[u.buffer])};l();return}catch{oi("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){i.#e||(wt("Setting up fake worker."),i.#e=!0),i._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}let e=new oa;this._port=e;let n=`fake${i.#t++}`,r=new Pn(n+"_worker",n,e);t.setup(r,e),this._messageHandler=new Pn(n,n+"_worker",e),this.#s()}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,i.#n?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");let e=this.#n?.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 i(t)}static get workerSrc(){if(On.workerSrc)return On.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#i(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return Ot(this,"_setupFakeWorkerGlobal",(async()=>this.#i?this.#i:(await import(this.workerSrc)).WorkerMessageHandler)())}},aa=class{#t=new Map;#e=new Map;#n=new Map;#s=new Map;#i=null;constructor(t,e,n,r,a){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Wr,this.fontLoader=new Io({ownerDocument:r.ownerDocument,styleElement:r.styleElement}),this.loadingParams=r.loadingParams,this._params=r,this.canvasFactory=a.canvasFactory,this.filterFactory=a.filterFactory,this.cMapReaderFactory=a.cMapReaderFactory,this.standardFontDataFactory=a.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#r(t,e=null){let n=this.#t.get(t);if(n)return n;let r=this.messageHandler.sendWithPromise(t,e);return this.#t.set(t,r),r}get annotationStorage(){return Ot(this,"annotationStorage",new Rs)}getRenderingIntent(t,e=gn.ENABLE,n=null,r=!1,a=!1){let l=Ee.DISPLAY,u=ko;switch(t){case"any":l=Ee.ANY;break;case"display":break;case"print":l=Ee.PRINT;break;default:wt(`getRenderingIntent - invalid intent: ${t}`)}let f=l&Ee.PRINT&&n instanceof Fr?n:this.annotationStorage;switch(e){case gn.DISABLE:l+=Ee.ANNOTATIONS_DISABLE;break;case gn.ENABLE:break;case gn.ENABLE_FORMS:l+=Ee.ANNOTATIONS_FORMS;break;case gn.ENABLE_STORAGE:l+=Ee.ANNOTATIONS_STORAGE,u=f.serializable;break;default:wt(`getRenderingIntent - invalid annotationMode: ${e}`)}r&&(l+=Ee.IS_EDITING),a&&(l+=Ee.OPLIST);let{ids:g,hash:m}=f.modifiedIds,y=[l,u.hash,m];return{renderingIntent:l,cacheKey:y.join("_"),annotationStorageSerializable:u,modifiedIds:g}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#i?.reject(new Error("Worker was destroyed during onPassword callback"));let t=[];for(let n of this.#e.values())t.push(n._destroy());this.#e.clear(),this.#n.clear(),this.#s.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(),Os.cleanup(),this._networkStream?.cancelAllRequests(new Ze("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(n,r)=>{te(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=a=>{this._lastProgress={loaded:a.loaded,total:a.total}},r.onPull=()=>{this._fullReader.read().then(function({value:a,done:l}){if(l){r.close();return}te(a instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),r.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{r.error(a)})},r.onCancel=a=>{this._fullReader.cancel(a),r.ready.catch(l=>{if(!this.destroyed)throw l})}}),t.on("ReaderHeadersReady",async n=>{await this._fullReader.headersReady;let{isStreamingSupported:r,isRangeSupported:a,contentLength:l}=this._fullReader;return(!r||!a)&&(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=u=>{e.onProgress?.({loaded:u.loaded,total:u.total})}),{isStreamingSupported:r,isRangeSupported:a,contentLength:l}}),t.on("GetRangeReader",(n,r)=>{te(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let a=this._networkStream.getRangeReader(n.begin,n.end);if(!a){r.close();return}r.onPull=()=>{a.read().then(function({value:l,done:u}){if(u){r.close();return}te(l instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),r.enqueue(new Uint8Array(l),1,[l])}).catch(l=>{r.error(l)})},r.onCancel=l=>{a.cancel(l),r.ready.catch(u=>{if(!this.destroyed)throw u})}}),t.on("GetDoc",({pdfInfo:n})=>{this._numPages=n.numPages,this._htmlForXfa=n.htmlForXfa,delete n.htmlForXfa,e._capability.resolve(new ra(n,this))}),t.on("DocException",n=>{e._capability.reject(ve(n))}),t.on("PasswordRequest",n=>{this.#i=Promise.withResolvers();try{if(!e.onPassword)throw ve(n);let r=a=>{a instanceof Error?this.#i.reject(a):this.#i.resolve({password:a})};e.onPassword(r,n.code)}catch(r){this.#i.reject(r)}return this.#i.promise}),t.on("DataLoaded",n=>{e.onProgress?.({loaded:n.length,total:n.length}),this.downloadInfoCapability.resolve(n)}),t.on("StartRenderPage",n=>{if(this.destroyed)return;this.#e.get(n.pageIndex)._startRenderPage(n.transparency,n.cacheKey)}),t.on("commonobj",([n,r,a])=>{if(this.destroyed||this.commonObjs.has(n))return null;switch(r){case"Font":let{disableFontFace:l,fontExtraProperties:u,pdfBug:f}=this._params;if("error"in a){let v=a.error;wt(`Error during font loading: ${v}`),this.commonObjs.resolve(n,v);break}let g=f&&globalThis.FontInspector?.enabled?(v,S)=>globalThis.FontInspector.fontAdded(v,S):null,m=new Ro(a,{disableFontFace:l,fontExtraProperties:u,inspectFont:g});this.fontLoader.bind(m).catch(()=>t.sendWithPromise("FontFallback",{id:n})).finally(()=>{!u&&m.data&&(m.data=null),this.commonObjs.resolve(n,m)});break;case"CopyLocalImage":let{imageRef:y}=a;te(y,"The imageRef must be defined.");for(let v of this.#e.values())for(let[,S]of v.objs)if(S?.ref===y)return S.dataLen?(this.commonObjs.resolve(n,structuredClone(S)),S.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(n,a);break;default:throw new Error(`Got unknown common object type ${r}`)}return null}),t.on("obj",([n,r,a,l])=>{if(this.destroyed)return;let u=this.#e.get(r);if(!u.objs.has(n)){if(u._intentStates.size===0){l?.bitmap?.close();return}switch(a){case"Image":u.objs.resolve(n,l),l?.dataLen>xb&&(u._maybeCleanupAfterRender=!0);break;case"Pattern":u.objs.resolve(n,l);break;default:throw new Error(`Got unknown object type ${a}`)}}}),t.on("DocProgress",n=>{this.destroyed||e.onProgress?.({loaded:n.loaded,total:n.total})}),t.on("FetchBuiltInCMap",async n=>{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(n)}),t.on("FetchStandardFontData",async n=>{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(n)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&wt("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));let e=t-1,n=this.#n.get(e);if(n)return n;let r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(a=>{if(this.destroyed)throw new Error("Transport destroyed");a.refStr&&this.#s.set(a.refStr,t);let l=new ia(e,a,this,this._params.pdfBug);return this.#e.set(e,l),l});return this.#n.set(e,r),r}getPageIndex(t){return Au(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#r("GetFieldObjects")}hasJSActions(){return this.#r("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#r("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#r("GetOptionalContentConfig").then(e=>new Wo(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let t="GetMetadata",e=this.#t.get(t);if(e)return e;let n=this.messageHandler.sendWithPromise(t,null).then(r=>({info:r[0],metadata:r[1]?new jo(r[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#t.set(t,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(let e of this.#e.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(!0),Os.cleanup()}}cachedPageNumber(t){if(!Au(t))return null;let e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return this.#s.get(e)??null}},Ss=Symbol("INITIAL_DATA"),Wr=class{#t=Object.create(null);#e(t){return this.#t[t]||={...Promise.withResolvers(),data:Ss}}get(t,e=null){if(e){let r=this.#e(t);return r.promise.then(()=>e(r.data)),null}let n=this.#t[t];if(!n||n.data===Ss)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return n.data}has(t){let e=this.#t[t];return!!e&&e.data!==Ss}delete(t){let e=this.#t[t];return!e||e.data===Ss?!1:(delete this.#t[t],!0)}resolve(t,e=null){let n=this.#e(t);n.data=e,n.resolve()}clear(){for(let t in this.#t){let{data:e}=this.#t[t];e?.bitmap?.close()}this.#t=Object.create(null)}*[Symbol.iterator](){for(let t in this.#t){let{data:e}=this.#t[t];e!==Ss&&(yield[t,e])}}},la=class{#t=null;constructor(t){this.#t=t,this.onContinue=null}get promise(){return this.#t.capability.promise}cancel(t=0){this.#t.cancel(null,t)}get separateAnnots(){let{separateAnnots:t}=this.#t.operatorList;if(!t)return!1;let{annotationCanvasMap:e}=this.#t;return t.form||t.canvas&&e?.size>0}},ca=class i{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:n,commonObjs:r,annotationCanvasMap:a,operatorList:l,pageIndex:u,canvasFactory:f,filterFactory:g,useRequestAnimationFrame:m=!1,pdfBug:y=!1,pageColors:v=null}){this.callback=t,this.params=e,this.objs=n,this.commonObjs=r,this.annotationCanvasMap=a,this.operatorListIdx=null,this.operatorList=l,this._pageIndex=u,this.canvasFactory=f,this.filterFactory=g,this._pdfBug=y,this.pageColors=v,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=m===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new la(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(i.#e.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");i.#e.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{canvasContext:n,viewport:r,transform:a,background:l}=this.params;this.gfx=new qn(n,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:a,viewport:r,transparency:t,background:l}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#t&&(window.cancelAnimationFrame(this.#t),this.#t=null),i.#e.delete(this._canvas),this.callback(t||new ks(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#t=window.requestAnimationFrame(()=>{this.#t=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),i.#e.delete(this._canvas),this.callback())))}},h0="4.10.45",d0="18f8e0416",IS=Ft(670);$r=class{static CMYK_G([t,e,n,r]){return["G",1-Math.min(1,.3*t+.59*n+.11*e+r)]}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=As(t),[t,t,t]}static G_HTML([t]){let e=Tu(t);return`#${e}${e}${e}`}static RGB_G([t,e,n]){return["G",.3*t+.59*e+.11*n]}static RGB_rgb(t){return t.map(As)}static RGB_HTML(t){return`#${t.map(Tu).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,n,r]){return["RGB",1-Math.min(1,t+r),1-Math.min(1,n+r),1-Math.min(1,e+r)]}static CMYK_rgb([t,e,n,r]){return[As(1-Math.min(1,t+r)),As(1-Math.min(1,n+r)),As(1-Math.min(1,e+r))]}static CMYK_HTML(t){let e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,n]){let r=1-t,a=1-e,l=1-n,u=Math.min(r,a,l);return["CMYK",r,a,l,u]}},ua=class{create(t,e,n=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");let r=this._createSVG("svg:svg");return r.setAttribute("version","1.1"),n||(r.setAttribute("width",`${t}px`),r.setAttribute("height",`${e}px`)),r.setAttribute("preserveAspectRatio","none"),r.setAttribute("viewBox",`0 0 ${t} ${e}`),r}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){$t("Abstract method `_createSVG` called.")}},Ls=class extends ua{_createSVG(t){return document.createElementNS(nn,t)}},zr=class{static setupStorage(t,e,n,r,a){let l=r.getValue(e,{value:null});switch(n.name){case"textarea":if(l.value!==null&&(t.textContent=l.value),a==="print")break;t.addEventListener("input",u=>{r.setValue(e,{value:u.target.value})});break;case"input":if(n.attributes.type==="radio"||n.attributes.type==="checkbox"){if(l.value===n.attributes.xfaOn?t.setAttribute("checked",!0):l.value===n.attributes.xfaOff&&t.removeAttribute("checked"),a==="print")break;t.addEventListener("change",u=>{r.setValue(e,{value:u.target.checked?u.target.getAttribute("xfaOn"):u.target.getAttribute("xfaOff")})})}else{if(l.value!==null&&t.setAttribute("value",l.value),a==="print")break;t.addEventListener("input",u=>{r.setValue(e,{value:u.target.value})})}break;case"select":if(l.value!==null){t.setAttribute("value",l.value);for(let u of n.children)u.attributes.value===l.value?u.attributes.selected=!0:u.attributes.hasOwnProperty("selected")&&delete u.attributes.selected}t.addEventListener("input",u=>{let f=u.target.options,g=f.selectedIndex===-1?"":f[f.selectedIndex].value;r.setValue(e,{value:g})});break}}static setAttributes({html:t,element:e,storage:n=null,intent:r,linkService:a}){let{attributes:l}=e,u=t instanceof HTMLAnchorElement;l.type==="radio"&&(l.name=`${l.name}-${r}`);for(let[f,g]of Object.entries(l))if(g!=null)switch(f){case"class":g.length&&t.setAttribute(f,g.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",g);break;case"style":Object.assign(t.style,g);break;case"textContent":t.textContent=g;break;default:(!u||f!=="href"&&f!=="newWindow")&&t.setAttribute(f,g)}u&&a.addLinkAttributes(t,l.href,l.newWindow),n&&l.dataId&&this.setupStorage(t,l.dataId,e,n)}static render(t){let e=t.annotationStorage,n=t.linkService,r=t.xfaHtml,a=t.intent||"display",l=document.createElement(r.name);r.attributes&&this.setAttributes({html:l,element:r,intent:a,linkService:n});let u=a!=="richText",f=t.div;if(f.append(l),t.viewport){let y=`matrix(${t.viewport.transform.join(",")})`;f.style.transform=y}u&&f.setAttribute("class","xfaLayer xfaFont");let g=[];if(r.children.length===0){if(r.value){let y=document.createTextNode(r.value);l.append(y),u&&Ms.shouldBuildText(r.name)&&g.push(y)}return{textDivs:g}}let m=[[r,-1,l]];for(;m.length>0;){let[y,v,S]=m.at(-1);if(v+1===y.children.length){m.pop();continue}let T=y.children[++m.at(-1)[1]];if(T===null)continue;let{name:C}=T;if(C==="#text"){let I=document.createTextNode(T.value);g.push(I),S.append(I);continue}let k=T?.attributes?.xmlns?document.createElementNS(T.attributes.xmlns,C):document.createElement(C);if(S.append(k),T.attributes&&this.setAttributes({html:k,element:T,storage:e,intent:a,linkService:n}),T.children?.length>0)m.push([T,-1,k]);else if(T.value){let I=document.createTextNode(T.value);u&&Ms.shouldBuildText(C)&&g.push(I),k.append(I)}}for(let y of f.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))y.setAttribute("readOnly",!0);return{textDivs:g}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}},Us=1e3,f0=9,_n=new WeakSet;ha=class{static create(t){switch(t.data.annotationType){case ee.LINK:return new Xr(t);case ee.TEXT:return new da(t);case ee.WIDGET:switch(t.data.fieldType){case"Tx":return new fa(t);case"Btn":return t.data.radioButton?new Yr(t):t.data.checkBox?new ga(t):new ma(t);case"Ch":return new ya(t);case"Sig":return new pa(t)}return new sn(t);case ee.POPUP:return new Fs(t);case ee.FREETEXT:return new Kr(t);case ee.LINE:return new va(t);case ee.SQUARE:return new xa(t);case ee.CIRCLE:return new Sa(t);case ee.POLYLINE:return new Zr(t);case ee.CARET:return new Ta(t);case ee.INK:return new Ds(t);case ee.POLYGON:return new Aa(t);case ee.HIGHLIGHT:return new Qr(t);case ee.UNDERLINE:return new Ca(t);case ee.SQUIGGLY:return new Ea(t);case ee.STRIKEOUT:return new wa(t);case ee.STAMP:return new Jr(t);case ee.FILEATTACHMENT:return new ka(t);default:return new Qt(t)}}},Qt=class i{#t=null;#e=!1;#n=null;constructor(t,{isRenderable:e=!1,ignoreBorder:n=!1,createQuadrilaterals:r=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(n)),r&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:n}){return!!(t?.str||e?.str||n?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return i._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#t||={rect:this.data.rect.slice(0)};let{rect:e}=t;e&&this.#s(e),this.#n?.popup.updateEdited(t)}resetEdited(){this.#t&&(this.#s(this.#t.rect),this.#n?.popup.resetEdited(),this.#t=null)}#s(t){let{container:{style:e},data:{rect:n,rotation:r},parent:{viewport:{rawDims:{pageWidth:a,pageHeight:l,pageX:u,pageY:f}}}}=this;n?.splice(0,4,...t);let{width:g,height:m}=mn(t);e.left=`${100*(t[0]-u)/a}%`,e.top=`${100*(l-t[3]+f)/l}%`,r===0?(e.width=`${100*g/a}%`,e.height=`${100*m/l}%`):this.setRotation(r)}_createContainer(t){let{data:e,parent:{page:n,viewport:r}}=this,a=document.createElement("section");a.setAttribute("data-annotation-id",e.id),this instanceof sn||(a.tabIndex=Us);let{style:l}=a;if(l.zIndex=this.parent.zIndex++,e.alternativeText&&(a.title=e.alternativeText),e.noRotate&&a.classList.add("norotate"),!e.rect||this instanceof Fs){let{rotation:C}=e;return!e.hasOwnCanvas&&C!==0&&this.setRotation(C,a),a}let{width:u,height:f}=mn(e.rect);if(!t&&e.borderStyle.width>0){l.borderWidth=`${e.borderStyle.width}px`;let C=e.borderStyle.horizontalCornerRadius,k=e.borderStyle.verticalCornerRadius;if(C>0||k>0){let O=`calc(${C}px * var(--scale-factor)) / calc(${k}px * var(--scale-factor))`;l.borderRadius=O}else if(this instanceof Yr){let O=`calc(${u}px * var(--scale-factor)) / calc(${f}px * var(--scale-factor))`;l.borderRadius=O}switch(e.borderStyle.style){case vs.SOLID:l.borderStyle="solid";break;case vs.DASHED:l.borderStyle="dashed";break;case vs.BEVELED:wt("Unimplemented border style: beveled");break;case vs.INSET:wt("Unimplemented border style: inset");break;case vs.UNDERLINE:l.borderBottomStyle="solid";break;default:break}let I=e.borderColor||null;I?(this.#e=!0,l.borderColor=St.makeHexColor(I[0]|0,I[1]|0,I[2]|0)):l.borderWidth=0}let g=St.normalizeRect([e.rect[0],n.view[3]-e.rect[1]+n.view[1],e.rect[2],n.view[3]-e.rect[3]+n.view[1]]),{pageWidth:m,pageHeight:y,pageX:v,pageY:S}=r.rawDims;l.left=`${100*(g[0]-v)/m}%`,l.top=`${100*(g[1]-S)/y}%`;let{rotation:T}=e;return e.hasOwnCanvas||T===0?(l.width=`${100*u/m}%`,l.height=`${100*f/y}%`):this.setRotation(T,a),a}setRotation(t,e=this.container){if(!this.data.rect)return;let{pageWidth:n,pageHeight:r}=this.parent.viewport.rawDims,{width:a,height:l}=mn(this.data.rect),u,f;t%180===0?(u=100*a/n,f=100*l/r):(u=100*l/n,f=100*a/r),e.style.width=`${u}%`,e.style.height=`${f}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){let t=(e,n,r)=>{let a=r.detail[e],l=a[0],u=a.slice(1);r.target.style[n]=$r[`${l}_HTML`](u),this.annotationStorage.setValue(this.data.id,{[n]:$r[`${l}_rgb`](u)})};return Ot(this,"_commonActions",{display:e=>{let{display:n}=e.detail,r=n%2===1;this.container.style.visibility=r?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:r,noPrint:n===1||n===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{let{hidden:n}=e.detail;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:n,noView:n})},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=>{let n=e.detail.rotation;this.setRotation(n),this.annotationStorage.setValue(this.data.id,{rotation:n})}})}_dispatchEventFromSandbox(t,e){let n=this._commonActions;for(let r of Object.keys(e.detail))(t[r]||n[r])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;let e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;let n=this._commonActions;for(let[r,a]of Object.entries(e)){let l=n[r];if(l){let u={detail:{[r]:a},target:t};l(u),delete e[r]}}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:t}=this.data;if(!t)return;let[e,n,r,a]=this.data.rect.map(C=>Math.fround(C));if(t.length===8){let[C,k,I,O]=t.subarray(2,6);if(r===C&&a===k&&e===I&&n===O)return}let{style:l}=this.container,u;if(this.#e){let{borderColor:C,borderWidth:k}=l;l.borderWidth=0,u=["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="${C}" stroke-width="${k}">`],this.container.classList.add("hasBorder")}let f=r-e,g=a-n,{svgFactory:m}=this,y=m.createElement("svg");y.classList.add("quadrilateralsContainer"),y.setAttribute("width",0),y.setAttribute("height",0);let v=m.createElement("defs");y.append(v);let S=m.createElement("clipPath"),T=`clippath_${this.data.id}`;S.setAttribute("id",T),S.setAttribute("clipPathUnits","objectBoundingBox"),v.append(S);for(let C=2,k=t.length;C<k;C+=8){let I=t[C],O=t[C+1],D=t[C+2],_=t[C+3],M=m.createElement("rect"),B=(D-e)/f,H=(a-O)/g,z=(I-D)/f,W=(O-_)/g;M.setAttribute("x",B),M.setAttribute("y",H),M.setAttribute("width",z),M.setAttribute("height",W),S.append(M),u?.push(`<rect vector-effect="non-scaling-stroke" x="${B}" y="${H}" width="${z}" height="${W}"/>`)}this.#e&&(u.push("</g></svg>')"),l.backgroundImage=u.join("")),this.container.append(y),this.container.style.clipPath=`url(#${T})`}_createPopup(){let{data:t}=this,e=this.#n=new Fs({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(e.render())}render(){$t("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){let n=[];if(this._fieldObjects){let r=this._fieldObjects[t];if(r)for(let{page:a,id:l,exportValues:u}of r){if(a===-1||l===e)continue;let f=typeof u=="string"?u:null,g=document.querySelector(`[data-element-id="${l}"]`);if(g&&!_n.has(g)){wt(`_getElementsByName - element not allowed: ${l}`);continue}n.push({id:l,exportValue:f,domElement:g})}return n}for(let r of document.getElementsByName(t)){let{exportValue:a}=r,l=r.getAttribute("data-element-id");l!==e&&_n.has(r)&&n.push({id:l,exportValue:a,domElement:r})}return n}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(let e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})})}},Xr=class extends Qt{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){let{data:t,linkService:e}=this,n=document.createElement("a");n.setAttribute("data-element-id",t.id);let r=!1;return t.url?(e.addLinkAttributes(n,t.url,t.newWindow),r=!0):t.action?(this._bindNamedAction(n,t.action),r=!0):t.attachment?(this.#e(n,t.attachment,t.attachmentDest),r=!0):t.setOCGState?(this.#n(n,t.setOCGState),r=!0):t.dest?(this._bindLink(n,t.dest),r=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,t),r=!0),t.resetForm?(this._bindResetFormAction(n,t.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(n,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&this.container.append(n),this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||e==="")&&this.#t()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#t()}#e(t,e,n=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,n),!1),this.#t()}#n(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#t()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");let n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let r of Object.keys(e.actions)){let a=n.get(r);a&&(t[a]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:r}}),!1))}t.onclick||(t.onclick=()=>!1),this.#t()}_bindResetFormAction(t,e){let n=t.onclick;if(n||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects){wt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),n||(t.onclick=()=>!1);return}t.onclick=()=>{n?.();let{fields:r,refs:a,include:l}=e,u=[];if(r.length!==0||a.length!==0){let m=new Set(a);for(let y of r){let v=this._fieldObjects[y]||[];for(let{id:S}of v)m.add(S)}for(let y of Object.values(this._fieldObjects))for(let v of y)m.has(v.id)===l&&u.push(v)}else for(let m of Object.values(this._fieldObjects))u.push(...m);let f=this.annotationStorage,g=[];for(let m of u){let{id:y}=m;switch(g.push(y),m.type){case"text":{let S=m.defaultValue||"";f.setValue(y,{value:S});break}case"checkbox":case"radiobutton":{let S=m.defaultValue===m.exportValues;f.setValue(y,{value:S});break}case"combobox":case"listbox":{let S=m.defaultValue||"";f.setValue(y,{value:S});break}default:continue}let v=document.querySelector(`[data-element-id="${y}"]`);if(v){if(!_n.has(v)){wt(`_bindResetFormAction - element not allowed: ${y}`);continue}}else continue;v.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:g,name:"ResetForm"}}),!1}}},da=class extends Qt{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let 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}},sn=class extends Qt{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return se.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,n,r,a){n.includes("mouse")?t.addEventListener(n,l=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:a(l),shift:l.shiftKey,modifier:this._getKeyModifier(l)}})}):t.addEventListener(n,l=>{if(n==="blur"){if(!e.focused||!l.relatedTarget)return;e.focused=!1}else if(n==="focus"){if(e.focused)return;e.focused=!0}a&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:a(l)}})})}_setEventListeners(t,e,n,r){for(let[a,l]of n)(l==="Action"||this.data.actions?.[l])&&((l==="Focus"||l==="Blur")&&(e||={focused:!1}),this._setEventListener(t,e,a,l,r),l==="Focus"&&!this.data.actions?.Blur?this._setEventListener(t,e,"blur","Blur",null):l==="Blur"&&!this.data.actions?.Focus&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){let e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":St.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){let e=["left","center","right"],{fontColor:n}=this.data.defaultAppearanceData,r=this.data.defaultAppearanceData.fontSize||f0,a=t.style,l,u=2,f=g=>Math.round(10*g)/10;if(this.data.multiLine){let g=Math.abs(this.data.rect[3]-this.data.rect[1]-u),m=Math.round(g/(Er*r))||1,y=g/m;l=Math.min(r,f(y/Er))}else{let g=Math.abs(this.data.rect[3]-this.data.rect[1]-u);l=Math.min(r,f(g/Er))}a.fontSize=`calc(${l}px * var(--scale-factor))`,a.color=St.makeHexColor(n[0],n[1],n[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)}},fa=class extends sn{constructor(t){let e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,n,r){let a=this.annotationStorage;for(let l of this._getElementsByName(t.name,t.id))l.domElement&&(l.domElement[e]=n),a.setValue(l.id,{[r]:n})}render(){let t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let n=null;if(this.renderForms){let r=t.getValue(e,{value:this.data.fieldValue}),a=r.value||"",l=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;l&&a.length>l&&(a=a.slice(0,l));let u=r.formattedValue||this.data.textContent?.join(`
5
+ `)||null;u&&this.data.comb&&(u=u.replaceAll(/\s+/g,""));let f={userValue:a,formattedValue:u,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement("textarea"),n.textContent=u??a,this.data.doNotScroll&&(n.style.overflowY="hidden")):(n=document.createElement("input"),n.type="text",n.setAttribute("value",u??a),this.data.doNotScroll&&(n.style.overflowX="hidden")),this.data.hasOwnCanvas&&(n.hidden=!0),_n.add(n),n.setAttribute("data-element-id",e),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=Us,this._setRequired(n,this.data.required),l&&(n.maxLength=l),n.addEventListener("input",m=>{t.setValue(e,{value:m.target.value}),this.setPropertyOnSiblings(n,"value",m.target.value,"value"),f.formattedValue=null}),n.addEventListener("resetform",m=>{let y=this.data.defaultFieldValue??"";n.value=f.userValue=y,f.formattedValue=null});let g=m=>{let{formattedValue:y}=f;y!=null&&(m.target.value=y),m.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener("focus",y=>{if(f.focused)return;let{target:v}=y;f.userValue&&(v.value=f.userValue),f.lastCommittedValue=v.value,f.commitKey=1,this.data.actions?.Focus||(f.focused=!0)}),n.addEventListener("updatefromsandbox",y=>{this.showElementAndHideCanvas(y.target);let v={value(S){f.userValue=S.detail.value??"",t.setValue(e,{value:f.userValue.toString()}),S.target.value=f.userValue},formattedValue(S){let{formattedValue:T}=S.detail;f.formattedValue=T,T!=null&&S.target!==document.activeElement&&(S.target.value=T),t.setValue(e,{formattedValue:T})},selRange(S){S.target.setSelectionRange(...S.detail.selRange)},charLimit:S=>{let{charLimit:T}=S.detail,{target:C}=S;if(T===0){C.removeAttribute("maxLength");return}C.setAttribute("maxLength",T);let k=f.userValue;!k||k.length<=T||(k=k.slice(0,T),C.value=f.userValue=k,t.setValue(e,{value:k}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:k,willCommit:!0,commitKey:1,selStart:C.selectionStart,selEnd:C.selectionEnd}}))}};this._dispatchEventFromSandbox(v,y)}),n.addEventListener("keydown",y=>{f.commitKey=1;let v=-1;if(y.key==="Escape"?v=0:y.key==="Enter"&&!this.data.multiLine?v=2:y.key==="Tab"&&(f.commitKey=3),v===-1)return;let{value:S}=y.target;f.lastCommittedValue!==S&&(f.lastCommittedValue=S,f.userValue=S,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:S,willCommit:!0,commitKey:v,selStart:y.target.selectionStart,selEnd:y.target.selectionEnd}}))});let m=g;g=null,n.addEventListener("blur",y=>{if(!f.focused||!y.relatedTarget)return;this.data.actions?.Blur||(f.focused=!1);let{value:v}=y.target;f.userValue=v,f.lastCommittedValue!==v&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,willCommit:!0,commitKey:f.commitKey,selStart:y.target.selectionStart,selEnd:y.target.selectionEnd}}),m(y)}),this.data.actions?.Keystroke&&n.addEventListener("beforeinput",y=>{f.lastCommittedValue=null;let{data:v,target:S}=y,{value:T,selectionStart:C,selectionEnd:k}=S,I=C,O=k;switch(y.inputType){case"deleteWordBackward":{let D=T.substring(0,C).match(/\w*[^\w]*$/);D&&(I-=D[0].length);break}case"deleteWordForward":{let D=T.substring(C).match(/^[^\w]*\w*/);D&&(O+=D[0].length);break}case"deleteContentBackward":C===k&&(I-=1);break;case"deleteContentForward":C===k&&(O+=1);break}y.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:T,change:v||"",willCommit:!1,selStart:I,selEnd:O}})}),this._setEventListeners(n,f,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],y=>y.target.value)}if(g&&n.addEventListener("blur",g),this.data.comb){let y=(this.data.rect[2]-this.data.rect[0])/l;n.classList.add("comb"),n.style.letterSpacing=`calc(${y}px * var(--scale-factor) - 1ch)`}}else n=document.createElement("div"),n.textContent=this.data.fieldValue,n.style.verticalAlign="middle",n.style.display="table-cell",this.data.hasOwnCanvas&&(n.hidden=!0);return this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}},pa=class extends sn{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}},ga=class extends sn{constructor(t){super(t,{isRenderable:t.renderForms})}render(){let t=this.annotationStorage,e=this.data,n=e.id,r=t.getValue(n,{value:e.exportValue===e.fieldValue}).value;typeof r=="string"&&(r=r!=="Off",t.setValue(n,{value:r})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let a=document.createElement("input");return _n.add(a),a.setAttribute("data-element-id",n),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="checkbox",a.name=e.fieldName,r&&a.setAttribute("checked",!0),a.setAttribute("exportValue",e.exportValue),a.tabIndex=Us,a.addEventListener("change",l=>{let{name:u,checked:f}=l.target;for(let g of this._getElementsByName(u,n)){let m=f&&g.exportValue===e.exportValue;g.domElement&&(g.domElement.checked=m),t.setValue(g.id,{value:m})}t.setValue(n,{value:f})}),a.addEventListener("resetform",l=>{let u=e.defaultFieldValue||"Off";l.target.checked=u===e.exportValue}),this.enableScripting&&this.hasJSActions&&(a.addEventListener("updatefromsandbox",l=>{let u={value(f){f.target.checked=f.detail.value!=="Off",t.setValue(n,{value:f.target.checked})}};this._dispatchEventFromSandbox(u,l)}),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],l=>l.target.checked)),this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}},Yr=class extends sn{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let t=this.annotationStorage,e=this.data,n=e.id,r=t.getValue(n,{value:e.fieldValue===e.buttonValue}).value;if(typeof r=="string"&&(r=r!==e.buttonValue,t.setValue(n,{value:r})),r)for(let l of this._getElementsByName(e.fieldName,n))t.setValue(l.id,{value:!1});let a=document.createElement("input");if(_n.add(a),a.setAttribute("data-element-id",n),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="radio",a.name=e.fieldName,r&&a.setAttribute("checked",!0),a.tabIndex=Us,a.addEventListener("change",l=>{let{name:u,checked:f}=l.target;for(let g of this._getElementsByName(u,n))t.setValue(g.id,{value:!1});t.setValue(n,{value:f})}),a.addEventListener("resetform",l=>{let u=e.defaultFieldValue;l.target.checked=u!=null&&u===e.buttonValue}),this.enableScripting&&this.hasJSActions){let l=e.buttonValue;a.addEventListener("updatefromsandbox",u=>{let f={value:g=>{let m=l===g.detail.value;for(let y of this._getElementsByName(g.target.name)){let v=m&&y.id===n;y.domElement&&(y.domElement.checked=v),t.setValue(y.id,{value:v})}}};this._dispatchEventFromSandbox(f,u)}),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],u=>u.target.checked)}return this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}},ma=class extends Xr{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){let t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");let e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",n=>{this._dispatchEventFromSandbox({},n)})),t}},ya=class extends sn{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let t=this.annotationStorage,e=this.data.id,n=t.getValue(e,{value:this.data.fieldValue}),r=document.createElement("select");_n.add(r),r.setAttribute("data-element-id",e),r.disabled=this.data.readOnly,this._setRequired(r,this.data.required),r.name=this.data.fieldName,r.tabIndex=Us;let a=this.data.combo&&this.data.options.length>0;this.data.combo||(r.size=this.data.options.length,this.data.multiSelect&&(r.multiple=!0)),r.addEventListener("resetform",m=>{let y=this.data.defaultFieldValue;for(let v of r.options)v.selected=v.value===y});for(let m of this.data.options){let y=document.createElement("option");y.textContent=m.displayValue,y.value=m.exportValue,n.value.includes(m.exportValue)&&(y.setAttribute("selected",!0),a=!1),r.append(y)}let l=null;if(a){let m=document.createElement("option");m.value=" ",m.setAttribute("hidden",!0),m.setAttribute("selected",!0),r.prepend(m),l=()=>{m.remove(),r.removeEventListener("input",l),l=null},r.addEventListener("input",l)}let u=m=>{let y=m?"value":"textContent",{options:v,multiple:S}=r;return S?Array.prototype.filter.call(v,T=>T.selected).map(T=>T[y]):v.selectedIndex===-1?null:v[v.selectedIndex][y]},f=u(!1),g=m=>{let y=m.target.options;return Array.prototype.map.call(y,v=>({displayValue:v.textContent,exportValue:v.value}))};return this.enableScripting&&this.hasJSActions?(r.addEventListener("updatefromsandbox",m=>{let y={value(v){l?.();let S=v.detail.value,T=new Set(Array.isArray(S)?S:[S]);for(let C of r.options)C.selected=T.has(C.value);t.setValue(e,{value:u(!0)}),f=u(!1)},multipleSelection(v){r.multiple=!0},remove(v){let S=r.options,T=v.detail.remove;S[T].selected=!1,r.remove(T),S.length>0&&Array.prototype.findIndex.call(S,k=>k.selected)===-1&&(S[0].selected=!0),t.setValue(e,{value:u(!0),items:g(v)}),f=u(!1)},clear(v){for(;r.length!==0;)r.remove(0);t.setValue(e,{value:null,items:[]}),f=u(!1)},insert(v){let{index:S,displayValue:T,exportValue:C}=v.detail.insert,k=r.children[S],I=document.createElement("option");I.textContent=T,I.value=C,k?k.before(I):r.append(I),t.setValue(e,{value:u(!0),items:g(v)}),f=u(!1)},items(v){let{items:S}=v.detail;for(;r.length!==0;)r.remove(0);for(let T of S){let{displayValue:C,exportValue:k}=T,I=document.createElement("option");I.textContent=C,I.value=k,r.append(I)}r.options.length>0&&(r.options[0].selected=!0),t.setValue(e,{value:u(!0),items:g(v)}),f=u(!1)},indices(v){let S=new Set(v.detail.indices);for(let T of v.target.options)T.selected=S.has(T.index);t.setValue(e,{value:u(!0)}),f=u(!1)},editable(v){v.target.disabled=!v.detail.editable}};this._dispatchEventFromSandbox(y,m)}),r.addEventListener("input",m=>{let y=u(!0),v=u(!1);t.setValue(e,{value:y}),m.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:f,change:v,changeEx:y,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(r,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],m=>m.target.value)):r.addEventListener("input",function(m){t.setValue(e,{value:u(!0)})}),this.data.combo&&this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}},Fs=class extends Qt{constructor(t){let{data:e,elements:n}=t;super(t,{isRenderable:Qt._hasPopupData(e)}),this.elements=n,this.popup=null}render(){this.container.classList.add("popupAnnotation");let t=this.popup=new ba({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(let n of this.elements)n.popup=t,n.container.ariaHasPopup="dialog",e.push(n.data.id),n.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(n=>`${Ha}${n}`).join(",")),this.container}},ba=class{#t=this.#k.bind(this);#e=this.#w.bind(this);#n=this.#I.bind(this);#s=this.#A.bind(this);#i=null;#r=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=!1;#f=null;#o=null;#p=null;#m=null;#g=null;#y=null;#x=!1;constructor({container:t,color:e,elements:n,titleObj:r,modificationDate:a,contentsObj:l,richText:u,parent:f,rect:g,parentRect:m,open:y}){this.#r=t,this.#g=r,this.#l=l,this.#m=u,this.#c=f,this.#i=e,this.#p=g,this.#d=m,this.#u=n,this.#a=Rr.toDateObject(a),this.trigger=n.flatMap(v=>v.getElementsToTriggerPopup());for(let v of this.trigger)v.addEventListener("click",this.#s),v.addEventListener("mouseenter",this.#n),v.addEventListener("mouseleave",this.#e),v.classList.add("popupTriggerArea");for(let v of n)v.container?.addEventListener("keydown",this.#t);this.#r.hidden=!0,y&&this.#A()}render(){if(this.#f)return;let t=this.#f=document.createElement("div");if(t.className="popup",this.#i){let a=t.style.outlineColor=St.makeHexColor(...this.#i);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${a} 30%, white)`:t.style.backgroundColor=St.makeHexColor(...this.#i.map(u=>Math.floor(.7*(255-u)+u)))}let e=document.createElement("span");e.className="header";let n=document.createElement("h1");if(e.append(n),{dir:n.dir,str:n.textContent}=this.#g,t.append(e),this.#a){let 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:this.#a.valueOf()})),e.append(a)}let r=this.#b;if(r)zr.render({xfaHtml:r,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{let a=this._formatContents(this.#l);t.append(a)}this.#r.append(t)}get#b(){let t=this.#m,e=this.#l;return t?.str&&(!e?.str||e.str===t.str)&&this.#m.html||null}get#S(){return this.#b?.attributes?.style?.fontSize||0}get#T(){return this.#b?.attributes?.style?.color||null}#E(t){let e=[],n={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},r={style:{color:this.#T,fontSize:this.#S?`calc(${this.#S}px * var(--scale-factor))`:""}};for(let a of t.split(`
6
+ `))e.push({name:"span",value:a,attributes:r});return n}_formatContents({str:t,dir:e}){let n=document.createElement("p");n.classList.add("popupContent"),n.dir=e;let r=t.split(/(?:\r\n?|\n)/);for(let a=0,l=r.length;a<l;++a){let u=r[a];n.append(document.createTextNode(u)),a<l-1&&n.append(document.createElement("br"))}return n}#k(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&this.#h)&&this.#A()}updateEdited({rect:t,popupContent:e}){this.#y||={contentsObj:this.#l,richText:this.#m},t&&(this.#o=null),e&&(this.#m=this.#E(e),this.#l=null),this.#f?.remove(),this.#f=null}resetEdited(){this.#y&&({contentsObj:this.#l,richText:this.#m}=this.#y,this.#y=null,this.#f?.remove(),this.#f=null,this.#o=null)}#R(){if(this.#o!==null)return;let{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:n,pageX:r,pageY:a}}}=this.#c,l=!!this.#d,u=l?this.#d:this.#p;for(let T of this.#u)if(!u||St.intersect(T.data.rect,u)!==null){u=T.data.rect,l=!0;break}let f=St.normalizeRect([u[0],t[3]-u[1]+t[1],u[2],t[3]-u[3]+t[1]]),m=l?u[2]-u[0]+5:0,y=f[0]+m,v=f[1];this.#o=[100*(y-r)/e,100*(v-a)/n];let{style:S}=this.#r;S.left=`${this.#o[0]}%`,S.top=`${this.#o[1]}%`}#A(){this.#h=!this.#h,this.#h?(this.#I(),this.#r.addEventListener("click",this.#s),this.#r.addEventListener("keydown",this.#t)):(this.#w(),this.#r.removeEventListener("click",this.#s),this.#r.removeEventListener("keydown",this.#t))}#I(){this.#f||this.render(),this.isVisible?this.#h&&this.#r.classList.add("focused"):(this.#R(),this.#r.hidden=!1,this.#r.style.zIndex=parseInt(this.#r.style.zIndex)+1e3)}#w(){this.#r.classList.remove("focused"),!(this.#h||!this.isVisible)&&(this.#r.hidden=!0,this.#r.style.zIndex=parseInt(this.#r.style.zIndex)-1e3)}forceHide(){this.#x=this.isVisible,this.#x&&(this.#r.hidden=!0)}maybeShow(){this.#x&&(this.#f||this.#I(),this.#x=!1,this.#r.hidden=!1)}get isVisible(){return this.#r.hidden===!1}},Kr=class extends Qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=Pt.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(let e of this.textContent){let n=document.createElement("span");n.textContent=e,t.append(n)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}},va=class extends Qt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let t=this.data,{width:e,height:n}=mn(t.rect),r=this.svgFactory.create(e,n,!0),a=this.#t=this.svgFactory.createElement("svg:line");return a.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),a.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),a.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),a.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),a.setAttribute("stroke-width",t.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),r.append(a),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},xa=class extends Qt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let t=this.data,{width:e,height:n}=mn(t.rect),r=this.svgFactory.create(e,n,!0),a=t.borderStyle.width,l=this.#t=this.svgFactory.createElement("svg:rect");return l.setAttribute("x",a/2),l.setAttribute("y",a/2),l.setAttribute("width",e-a),l.setAttribute("height",n-a),l.setAttribute("stroke-width",a||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),r.append(l),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},Sa=class extends Qt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let t=this.data,{width:e,height:n}=mn(t.rect),r=this.svgFactory.create(e,n,!0),a=t.borderStyle.width,l=this.#t=this.svgFactory.createElement("svg:ellipse");return l.setAttribute("cx",e/2),l.setAttribute("cy",n/2),l.setAttribute("rx",e/2-a/2),l.setAttribute("ry",n/2-a/2),l.setAttribute("stroke-width",a||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),r.append(l),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},Zr=class extends Qt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,vertices:e,borderStyle:n,popupRef:r}}=this;if(!e)return this.container;let{width:a,height:l}=mn(t),u=this.svgFactory.create(a,l,!0),f=[];for(let m=0,y=e.length;m<y;m+=2){let v=e[m]-t[0],S=t[3]-e[m+1];f.push(`${v},${S}`)}f=f.join(" ");let g=this.#t=this.svgFactory.createElement(this.svgElementName);return g.setAttribute("points",f),g.setAttribute("stroke-width",n.width||1),g.setAttribute("stroke","transparent"),g.setAttribute("fill","transparent"),u.append(g),this.container.append(u),!r&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},Aa=class extends Zr{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}},Ta=class extends Qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}},Ds=class extends Qt{#t=null;#e=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?Pt.HIGHLIGHT:Pt.INK}#n(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,rotation:e,inkLists:n,borderStyle:r,popupRef:a}}=this,{transform:l,width:u,height:f}=this.#n(e,t),g=this.svgFactory.create(u,f,!0),m=this.#t=this.svgFactory.createElement("svg:g");g.append(m),m.setAttribute("stroke-width",r.width||1),m.setAttribute("stroke-linecap","round"),m.setAttribute("stroke-linejoin","round"),m.setAttribute("stroke-miterlimit",10),m.setAttribute("stroke","transparent"),m.setAttribute("fill","transparent"),m.setAttribute("transform",l);for(let y=0,v=n.length;y<v;y++){let S=this.svgFactory.createElement(this.svgElementName);this.#e.push(S),S.setAttribute("points",n[y].join(",")),m.append(S)}return!a&&this.hasPopupData&&this._createPopup(),this.container.append(g),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);let{thickness:e,points:n,rect:r}=t,a=this.#t;if(e>=0&&a.setAttribute("stroke-width",e||1),n)for(let l=0,u=this.#e.length;l<u;l++)this.#e[l].setAttribute("points",n[l].join(","));if(r){let{transform:l,width:u,height:f}=this.#n(this.data.rotation,r);a.parentElement.setAttribute("viewBox",`0 0 ${u} ${f}`),a.setAttribute("transform",l)}}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}},Qr=class extends Qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=Pt.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}},Ca=class extends Qt{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}},Ea=class extends Qt{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}},wa=class extends Qt{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}},Jr=class extends Qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=Pt.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}},ka=class extends Qt{#t=null;constructor(t){super(t,{isRenderable:!0});let{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");let{container:t,data:e}=this,n;e.hasAppearance||e.fillAlpha===0?n=document.createElement("div"):(n=document.createElement("img"),n.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(n.style=`filter: opacity(${Math.round(e.fillAlpha*100)}%);`)),n.addEventListener("dblclick",this.#e.bind(this)),this.#t=n;let{isMac:r}=se.platform;return t.addEventListener("keydown",a=>{a.key==="Enter"&&(r?a.metaKey:a.ctrlKey)&&this.#e()}),!e.popupRef&&this.hasPopupData?this._createPopup():n.classList.add("popupTriggerArea"),t.append(n),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}#e(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}},Ia=class{#t=null;#e=null;#n=new Map;#s=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:n,annotationEditorUIManager:r,page:a,viewport:l,structTreeLayer:u}){this.div=t,this.#t=e,this.#e=n,this.#s=u||null,this.page=a,this.viewport=l,this.zIndex=0,this._annotationEditorUIManager=r}hasEditableAnnotations(){return this.#n.size>0}async#i(t,e){let n=t.firstChild||t,r=n.id=`${Ha}${e}`,a=await this.#s?.getAriaAttributes(r);if(a)for(let[l,u]of a)n.setAttribute(l,u);this.div.append(t),this.#t?.moveElementInDOM(this.div,t,n,!1)}async render(t){let{annotations:e}=t,n=this.div;Ln(n,this.viewport);let r=new Map,a={data:null,layer:n,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Ls,annotationStorage:t.annotationStorage||new Rs,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(let l of e){if(l.noHTML)continue;let u=l.annotationType===ee.POPUP;if(u){let m=r.get(l.id);if(!m)continue;a.elements=m}else{let{width:m,height:y}=mn(l.rect);if(m<=0||y<=0)continue}a.data=l;let f=ha.create(a);if(!f.isRenderable)continue;if(!u&&l.popupRef){let m=r.get(l.popupRef);m?m.push(f):r.set(l.popupRef,[f])}let g=f.render();l.hidden&&(g.style.visibility="hidden"),await this.#i(g,l.id),f._isEditable&&(this.#n.set(f.data.id,f),this._annotationEditorUIManager?.renderAnnotationElement(f))}this.#r()}update({viewport:t}){let e=this.div;this.viewport=t,Ln(e,{rotation:t.rotation}),this.#r(),e.hidden=!1}#r(){if(!this.#e)return;let t=this.div;for(let[e,n]of this.#e){let r=t.querySelector(`[data-annotation-id="${e}"]`);if(!r)continue;n.className="annotationContent";let{firstChild:a}=r;a?a.nodeName==="CANVAS"?a.replaceWith(n):a.classList.contains("annotationContent")?a.after(n):a.before(n):r.append(n)}this.#e.clear()}getEditableAnnotations(){return Array.from(this.#n.values())}getEditableAnnotation(t){return this.#n.get(t)}},Cr=/\r\n?|\n/g,Ra=class i extends Xt{#t;#e="";#n=`${this.id}-editor`;#s=null;#i;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=i.prototype,e=a=>a.isEmpty(),n=Dn.TRANSLATE_SMALL,r=Dn.TRANSLATE_BIG;return Ot(this,"_keyboardManager",new Fn([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-n,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-r,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[n,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[r,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-n],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-r],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,n],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,r],checker:e}]]))}static _type="freetext";static _editorType=Pt.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#t=t.color||i._defaultColor||Xt._defaultLineColor,this.#i=t.fontSize||i._defaultFontSize}static initialize(t,e){Xt.initialize(t,e);let n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case Mt.FREETEXT_SIZE:i._defaultFontSize=e;break;case Mt.FREETEXT_COLOR:i._defaultColor=e;break}}updateParams(t,e){switch(t){case Mt.FREETEXT_SIZE:this.#r(e);break;case Mt.FREETEXT_COLOR:this.#l(e);break}}static get defaultPropertiesToUpdate(){return[[Mt.FREETEXT_SIZE,i._defaultFontSize],[Mt.FREETEXT_COLOR,i._defaultColor||Xt._defaultLineColor]]}get propertiesToUpdate(){return[[Mt.FREETEXT_SIZE,this.#i],[Mt.FREETEXT_COLOR,this.#t]]}#r(t){let e=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--scale-factor))`,this.translate(0,-(r-this.#i)*this.parentScale),this.#i=r,this.#u()},n=this.#i;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Mt.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#l(t){let e=r=>{this.#t=this.editorDiv.style.color=r},n=this.#t;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Mt.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){let t=this.parentScale;return[-i._internalPadding*t,-(i._internalPadding+this.#i)*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(Pt.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#s=new AbortController;let t=this._uiManager.combinedSignal(this.#s);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#n),this._isDraggable=!0,this.#s?.abort(),this.#s=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#a(){let t=[];this.editorDiv.normalize();let e=null;for(let n of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&n.nodeName==="BR"||(t.push(i.#c(n)),e=n);return t.join(`
7
+ `)}#u(){let[t,e]=this.parentDimensions,n;if(this.isAttachedToDOM)n=this.div.getBoundingClientRect();else{let{currentLayer:r,div:a}=this,l=a.style.display,u=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",r.div.append(this.div),n=a.getBoundingClientRect(),a.remove(),a.style.display=l,a.classList.toggle("hidden",u)}this.rotation%180===this.parentRotation%180?(this.width=n.width/t,this.height=n.height/e):(this.width=n.height/t,this.height=n.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let t=this.#e,e=this.#e=this.#a().trimEnd();if(t===e)return;let n=r=>{if(this.#e=r,!r){this.remove();return}this.#d(),this._uiManager.rebuild(this),this.#u()};this.addCommands({cmd:()=>{n(e)},undo:()=>{n(t)},mustExec:!1}),this.#u()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){i._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#n),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:n}=this.editorDiv;if(n.fontSize=`calc(${this.#i}px * var(--scale-factor))`,n.color=this.#t,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Pr(this,this.div,["dblclick","keydown"]),this.width){let[r,a]=this.parentDimensions;if(this.annotationElementId){let{position:l}=this._initialData,[u,f]=this.getInitialTranslation();[u,f]=this.pageTranslationToScreen(u,f);let[g,m]=this.pageDimensions,[y,v]=this.pageTranslation,S,T;switch(this.rotation){case 0:S=t+(l[0]-y)/g,T=e+this.height-(l[1]-v)/m;break;case 90:S=t+(l[0]-y)/g,T=e-(l[1]-v)/m,[u,f]=[f,-u];break;case 180:S=t-this.width+(l[0]-y)/g,T=e-(l[1]-v)/m,[u,f]=[-u,-f];break;case 270:S=t+(l[0]-y-this.height*m)/g,T=e+(l[1]-v-this.width*g)/m,[u,f]=[-f,u];break}this.setAt(S*r,T*a,u,f)}else this.setAt(t*r,e*a,this.width*r,this.height*a);this.#d(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#c(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Cr,"")}editorDivPaste(t){let e=t.clipboardData||window.clipboardData,{types:n}=e;if(n.length===1&&n[0]==="text/plain")return;t.preventDefault();let r=i.#f(e.getData("text")||"").replaceAll(Cr,`
8
+ `);if(!r)return;let a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();let l=a.getRangeAt(0);if(!r.includes(`
9
+ `)){l.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),a.collapseToStart();return}let{startContainer:u,startOffset:f}=l,g=[],m=[];if(u.nodeType===Node.TEXT_NODE){let S=u.parentElement;if(m.push(u.nodeValue.slice(f).replaceAll(Cr,"")),S!==this.editorDiv){let T=g;for(let C of this.editorDiv.childNodes){if(C===S){T=m;continue}T.push(i.#c(C))}}g.push(u.nodeValue.slice(0,f).replaceAll(Cr,""))}else if(u===this.editorDiv){let S=g,T=0;for(let C of this.editorDiv.childNodes)T++===f&&(S=m),S.push(i.#c(C))}this.#e=`${g.join(`
10
+ `)}${r}${m.join(`
11
+ `)}`,this.#d();let y=new Range,v=g.reduce((S,T)=>S+T.length,0);for(let{firstChild:S}of this.editorDiv.childNodes)if(S.nodeType===Node.TEXT_NODE){let T=S.nodeValue.length;if(v<=T){y.setStart(S,v),y.setEnd(S,v);break}v-=T}a.removeAllRanges(),a.addRange(y)}#d(){if(this.editorDiv.replaceChildren(),!!this.#e)for(let t of this.#e.split(`
12
+ `)){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#h(){return this.#e.replaceAll("\xA0"," ")}static#f(t){return t.replaceAll(" ","\xA0")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,n){let r=null;if(t instanceof Kr){let{data:{defaultAppearanceData:{fontSize:l,fontColor:u},rect:f,rotation:g,id:m,popupRef:y},textContent:v,textPosition:S,parent:{page:{pageNumber:T}}}=t;if(!v||v.length===0)return null;r=t={annotationType:Pt.FREETEXT,color:Array.from(u),fontSize:l,value:v.join(`
13
+ `),position:S,pageIndex:T-1,rect:f.slice(0),rotation:g,id:m,deleted:!1,popupRef:y}}let a=await super.deserialize(t,e,n);return a.#i=t.fontSize,a.#t=St.makeHexColor(...t.color),a.#e=i.#f(t.value),a.annotationElementId=t.id||null,a._initialData=r,a}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let e=i._internalPadding*this.parentScale,n=this.getRect(e,e),r=Xt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#t),a={annotationType:Pt.FREETEXT,color:r,fontSize:this.#i,value:this.#h(),pageIndex:this.pageIndex,rect:n,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?a:this.annotationElementId&&!this.#o(a)?null:(a.id=this.annotationElementId,a)}#o(t){let{value:e,fontSize:n,color:r,pageIndex:a}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==n||t.color.some((l,u)=>l!==r[u])||t.pageIndex!==a}renderAnnotationElement(t){let e=super.renderAnnotationElement(t);if(this.deleted)return e;let{style:n}=e;n.fontSize=`calc(${this.#i}px * var(--scale-factor))`,n.color=this.#t,e.replaceChildren();for(let a of this.#e.split(`
14
+ `)){let l=document.createElement("div");l.append(a?document.createTextNode(a):document.createElement("br")),e.append(l)}let r=i._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(r,r),popupContent:this.#e}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}},ht=class{static PRECISION=1e-4;toSVGPath(){$t("Abstract method `toSVGPath` must be implemented.")}get box(){$t("Abstract getter `box` must be implemented.")}serialize(t,e){$t("Abstract method `serialize` must be implemented.")}static _rescale(t,e,n,r,a,l){l||=new Float32Array(t.length);for(let u=0,f=t.length;u<f;u+=2)l[u]=e+t[u]*r,l[u+1]=n+t[u+1]*a;return l}static _rescaleAndSwap(t,e,n,r,a,l){l||=new Float32Array(t.length);for(let u=0,f=t.length;u<f;u+=2)l[u]=e+t[u+1]*r,l[u+1]=n+t[u]*a;return l}static _translate(t,e,n,r){r||=new Float32Array(t.length);for(let a=0,l=t.length;a<l;a+=2)r[a]=e+t[a],r[a+1]=n+t[a+1];return r}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,n,r,a){switch(a){case 90:return[1-e/n,t/r];case 180:return[1-t/n,1-e/r];case 270:return[e/n,1-t/r];default:return[t/n,e/r]}}static _normalizePagePoint(t,e,n){switch(n){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,n,r,a,l){return[(t+5*n)/6,(e+5*r)/6,(5*n+a)/6,(5*r+l)/6,(n+a)/2,(r+l)/2]}},qr=class i{#t;#e=[];#n;#s;#i=[];#r=new Float32Array(18);#l;#a;#u;#c;#d;#h;#f=[];static#o=8;static#p=2;static#m=i.#o+i.#p;constructor({x:t,y:e},n,r,a,l,u=0){this.#t=n,this.#h=a*r,this.#s=l,this.#r.set([NaN,NaN,NaN,NaN,t,e],6),this.#n=u,this.#c=i.#o*r,this.#u=i.#m*r,this.#d=r,this.#f.push(t,e)}isEmpty(){return isNaN(this.#r[8])}#g(){let t=this.#r.subarray(4,6),e=this.#r.subarray(16,18),[n,r,a,l]=this.#t;return[(this.#l+(t[0]-e[0])/2-n)/a,(this.#a+(t[1]-e[1])/2-r)/l,(this.#l+(e[0]-t[0])/2-n)/a,(this.#a+(e[1]-t[1])/2-r)/l]}add({x:t,y:e}){this.#l=t,this.#a=e;let[n,r,a,l]=this.#t,[u,f,g,m]=this.#r.subarray(8,12),y=t-g,v=e-m,S=Math.hypot(y,v);if(S<this.#u)return!1;let T=S-this.#c,C=T/S,k=C*y,I=C*v,O=u,D=f;u=g,f=m,g+=k,m+=I,this.#f?.push(t,e);let _=-I/T,M=k/T,B=_*this.#h,H=M*this.#h;return this.#r.set(this.#r.subarray(2,8),0),this.#r.set([g+B,m+H],4),this.#r.set(this.#r.subarray(14,18),12),this.#r.set([g-B,m-H],16),isNaN(this.#r[6])?(this.#i.length===0&&(this.#r.set([u+B,f+H],2),this.#i.push(NaN,NaN,NaN,NaN,(u+B-n)/a,(f+H-r)/l),this.#r.set([u-B,f-H],14),this.#e.push(NaN,NaN,NaN,NaN,(u-B-n)/a,(f-H-r)/l)),this.#r.set([O,D,u,f,g,m],6),!this.isEmpty()):(this.#r.set([O,D,u,f,g,m],6),Math.abs(Math.atan2(D-f,O-u)-Math.atan2(I,k))<Math.PI/2?([u,f,g,m]=this.#r.subarray(2,6),this.#i.push(NaN,NaN,NaN,NaN,((u+g)/2-n)/a,((f+m)/2-r)/l),[u,f,O,D]=this.#r.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((O+u)/2-n)/a,((D+f)/2-r)/l),!0):([O,D,u,f,g,m]=this.#r.subarray(0,6),this.#i.push(((O+5*u)/6-n)/a,((D+5*f)/6-r)/l,((5*u+g)/6-n)/a,((5*f+m)/6-r)/l,((u+g)/2-n)/a,((f+m)/2-r)/l),[g,m,u,f,O,D]=this.#r.subarray(12,18),this.#e.push(((O+5*u)/6-n)/a,((D+5*f)/6-r)/l,((5*u+g)/6-n)/a,((5*f+m)/6-r)/l,((u+g)/2-n)/a,((f+m)/2-r)/l),!0))}toSVGPath(){if(this.isEmpty())return"";let t=this.#i,e=this.#e;if(isNaN(this.#r[6])&&!this.isEmpty())return this.#y();let n=[];n.push(`M${t[4]} ${t[5]}`);for(let r=6;r<t.length;r+=6)isNaN(t[r])?n.push(`L${t[r+4]} ${t[r+5]}`):n.push(`C${t[r]} ${t[r+1]} ${t[r+2]} ${t[r+3]} ${t[r+4]} ${t[r+5]}`);this.#b(n);for(let r=e.length-6;r>=6;r-=6)isNaN(e[r])?n.push(`L${e[r+4]} ${e[r+5]}`):n.push(`C${e[r]} ${e[r+1]} ${e[r+2]} ${e[r+3]} ${e[r+4]} ${e[r+5]}`);return this.#x(n),n.join(" ")}#y(){let[t,e,n,r]=this.#t,[a,l,u,f]=this.#g();return`M${(this.#r[2]-t)/n} ${(this.#r[3]-e)/r} L${(this.#r[4]-t)/n} ${(this.#r[5]-e)/r} L${a} ${l} L${u} ${f} L${(this.#r[16]-t)/n} ${(this.#r[17]-e)/r} L${(this.#r[14]-t)/n} ${(this.#r[15]-e)/r} Z`}#x(t){let e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#b(t){let[e,n,r,a]=this.#t,l=this.#r.subarray(4,6),u=this.#r.subarray(16,18),[f,g,m,y]=this.#g();t.push(`L${(l[0]-e)/r} ${(l[1]-n)/a} L${f} ${g} L${m} ${y} L${(u[0]-e)/r} ${(u[1]-n)/a}`)}newFreeDrawOutline(t,e,n,r,a,l){return new ti(t,e,n,r,a,l)}getOutlines(){let t=this.#i,e=this.#e,n=this.#r,[r,a,l,u]=this.#t,f=new Float32Array((this.#f?.length??0)+2);for(let y=0,v=f.length-2;y<v;y+=2)f[y]=(this.#f[y]-r)/l,f[y+1]=(this.#f[y+1]-a)/u;if(f[f.length-2]=(this.#l-r)/l,f[f.length-1]=(this.#a-a)/u,isNaN(n[6])&&!this.isEmpty())return this.#S(f);let g=new Float32Array(this.#i.length+24+this.#e.length),m=t.length;for(let y=0;y<m;y+=2){if(isNaN(t[y])){g[y]=g[y+1]=NaN;continue}g[y]=t[y],g[y+1]=t[y+1]}m=this.#E(g,m);for(let y=e.length-6;y>=6;y-=6)for(let v=0;v<6;v+=2){if(isNaN(e[y+v])){g[m]=g[m+1]=NaN,m+=2;continue}g[m]=e[y+v],g[m+1]=e[y+v+1],m+=2}return this.#T(g,m),this.newFreeDrawOutline(g,f,this.#t,this.#d,this.#n,this.#s)}#S(t){let e=this.#r,[n,r,a,l]=this.#t,[u,f,g,m]=this.#g(),y=new Float32Array(36);return y.set([NaN,NaN,NaN,NaN,(e[2]-n)/a,(e[3]-r)/l,NaN,NaN,NaN,NaN,(e[4]-n)/a,(e[5]-r)/l,NaN,NaN,NaN,NaN,u,f,NaN,NaN,NaN,NaN,g,m,NaN,NaN,NaN,NaN,(e[16]-n)/a,(e[17]-r)/l,NaN,NaN,NaN,NaN,(e[14]-n)/a,(e[15]-r)/l],0),this.newFreeDrawOutline(y,t,this.#t,this.#d,this.#n,this.#s)}#T(t,e){let n=this.#e;return t.set([NaN,NaN,NaN,NaN,n[4],n[5]],e),e+=6}#E(t,e){let n=this.#r.subarray(4,6),r=this.#r.subarray(16,18),[a,l,u,f]=this.#t,[g,m,y,v]=this.#g();return t.set([NaN,NaN,NaN,NaN,(n[0]-a)/u,(n[1]-l)/f,NaN,NaN,NaN,NaN,g,m,NaN,NaN,NaN,NaN,y,v,NaN,NaN,NaN,NaN,(r[0]-a)/u,(r[1]-l)/f],e),e+=24}},ti=class extends ht{#t;#e=new Float32Array(4);#n;#s;#i;#r;#l;constructor(t,e,n,r,a,l){super(),this.#l=t,this.#i=e,this.#t=n,this.#r=r,this.#n=a,this.#s=l,this.lastPoint=[NaN,NaN],this.#a(l);let[u,f,g,m]=this.#e;for(let y=0,v=t.length;y<v;y+=2)t[y]=(t[y]-u)/g,t[y+1]=(t[y+1]-f)/m;for(let y=0,v=e.length;y<v;y+=2)e[y]=(e[y]-u)/g,e[y+1]=(e[y+1]-f)/m}toSVGPath(){let t=[`M${this.#l[4]} ${this.#l[5]}`];for(let e=6,n=this.#l.length;e<n;e+=6){if(isNaN(this.#l[e])){t.push(`L${this.#l[e+4]} ${this.#l[e+5]}`);continue}t.push(`C${this.#l[e]} ${this.#l[e+1]} ${this.#l[e+2]} ${this.#l[e+3]} ${this.#l[e+4]} ${this.#l[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,n,r],a){let l=n-t,u=r-e,f,g;switch(a){case 0:f=ht._rescale(this.#l,t,r,l,-u),g=ht._rescale(this.#i,t,r,l,-u);break;case 90:f=ht._rescaleAndSwap(this.#l,t,e,l,u),g=ht._rescaleAndSwap(this.#i,t,e,l,u);break;case 180:f=ht._rescale(this.#l,n,e,-l,u),g=ht._rescale(this.#i,n,e,-l,u);break;case 270:f=ht._rescaleAndSwap(this.#l,n,r,-l,-u),g=ht._rescaleAndSwap(this.#i,n,r,-l,-u);break}return{outline:Array.from(f),points:[Array.from(g)]}}#a(t){let e=this.#l,n=e[4],r=e[5],a=n,l=r,u=n,f=r,g=n,m=r,y=t?Math.max:Math.min;for(let S=6,T=e.length;S<T;S+=6){if(isNaN(e[S]))a=Math.min(a,e[S+4]),l=Math.min(l,e[S+5]),u=Math.max(u,e[S+4]),f=Math.max(f,e[S+5]),m<e[S+5]?(g=e[S+4],m=e[S+5]):m===e[S+5]&&(g=y(g,e[S+4]));else{let C=St.bezierBoundingBox(n,r,...e.slice(S,S+6));a=Math.min(a,C[0]),l=Math.min(l,C[1]),u=Math.max(u,C[2]),f=Math.max(f,C[3]),m<C[3]?(g=C[2],m=C[3]):m===C[3]&&(g=y(g,C[2]))}n=e[S+4],r=e[S+5]}let v=this.#e;v[0]=a-this.#n,v[1]=l-this.#n,v[2]=u-a+2*this.#n,v[3]=f-l+2*this.#n,this.lastPoint=[g,m]}get box(){return this.#e}newOutliner(t,e,n,r,a,l=0){return new qr(t,e,n,r,a,l)}getNewOutline(t,e){let[n,r,a,l]=this.#e,[u,f,g,m]=this.#t,y=a*g,v=l*m,S=n*g+u,T=r*m+f,C=this.newOutliner({x:this.#i[0]*y+S,y:this.#i[1]*v+T},this.#t,this.#r,t,this.#s,e??this.#n);for(let k=2;k<this.#i.length;k+=2)C.add({x:this.#i[k]*y+S,y:this.#i[k+1]*v+T});return C.getOutlines()}},_s=class{#t;#e;#n=[];#s=[];constructor(t,e=0,n=0,r=!0){let a=1/0,l=-1/0,u=1/0,f=-1/0,m=10**-4;for(let{x:I,y:O,width:D,height:_}of t){let M=Math.floor((I-e)/m)*m,B=Math.ceil((I+D+e)/m)*m,H=Math.floor((O-e)/m)*m,z=Math.ceil((O+_+e)/m)*m,W=[M,H,z,!0],Q=[B,H,z,!1];this.#n.push(W,Q),a=Math.min(a,M),l=Math.max(l,B),u=Math.min(u,H),f=Math.max(f,z)}let y=l-a+2*n,v=f-u+2*n,S=a-n,T=u-n,C=this.#n.at(r?-1:-2),k=[C[0],C[2]];for(let I of this.#n){let[O,D,_]=I;I[0]=(O-S)/y,I[1]=(D-T)/v,I[2]=(_-T)/v}this.#t=new Float32Array([S,T,y,v]),this.#e=k}getOutlines(){this.#n.sort((e,n)=>e[0]-n[0]||e[1]-n[1]||e[2]-n[2]);let t=[];for(let e of this.#n)e[3]?(t.push(...this.#u(e)),this.#l(e)):(this.#a(e),t.push(...this.#u(e)));return this.#i(t)}#i(t){let e=[],n=new Set;for(let l of t){let[u,f,g]=l;e.push([u,f,l],[u,g,l])}e.sort((l,u)=>l[1]-u[1]||l[0]-u[0]);for(let l=0,u=e.length;l<u;l+=2){let f=e[l][2],g=e[l+1][2];f.push(g),g.push(f),n.add(f),n.add(g)}let r=[],a;for(;n.size>0;){let l=n.values().next().value,[u,f,g,m,y]=l;n.delete(l);let v=u,S=f;for(a=[u,g],r.push(a);;){let T;if(n.has(m))T=m;else if(n.has(y))T=y;else break;n.delete(T),[u,f,g,m,y]=T,v!==u&&(a.push(v,S,u,S===f?f:g),v=u),S=S===f?g:f}a.push(v,S)}return new Pa(r,this.#t,this.#e)}#r(t){let e=this.#s,n=0,r=e.length-1;for(;n<=r;){let a=n+r>>1,l=e[a][0];if(l===t)return a;l<t?n=a+1:r=a-1}return r+1}#l([,t,e]){let n=this.#r(t);this.#s.splice(n,0,[t,e])}#a([,t,e]){let n=this.#r(t);for(let r=n;r<this.#s.length;r++){let[a,l]=this.#s[r];if(a!==t)break;if(a===t&&l===e){this.#s.splice(r,1);return}}for(let r=n-1;r>=0;r--){let[a,l]=this.#s[r];if(a!==t)break;if(a===t&&l===e){this.#s.splice(r,1);return}}}#u(t){let[e,n,r]=t,a=[[e,n,r]],l=this.#r(r);for(let u=0;u<l;u++){let[f,g]=this.#s[u];for(let m=0,y=a.length;m<y;m++){let[,v,S]=a[m];if(!(g<=v||S<=f)){if(v>=f){if(S>g)a[m][1]=g;else{if(y===1)return[];a.splice(m,1),m--,y--}continue}a[m][2]=f,S>g&&a.push([e,g,S])}}}return a}},Pa=class extends ht{#t;#e;constructor(t,e,n){super(),this.#e=t,this.#t=e,this.lastPoint=n}toSVGPath(){let t=[];for(let e of this.#e){let[n,r]=e;t.push(`M${n} ${r}`);for(let a=2;a<e.length;a+=2){let l=e[a],u=e[a+1];l===n?(t.push(`V${u}`),r=u):u===r&&(t.push(`H${l}`),n=l)}t.push("Z")}return t.join(" ")}serialize([t,e,n,r],a){let l=[],u=n-t,f=r-e;for(let g of this.#e){let m=new Array(g.length);for(let y=0;y<g.length;y+=2)m[y]=t+g[y]*u,m[y+1]=r-g[y+1]*f;l.push(m)}return l}get box(){return this.#t}get classNamesForOutlining(){return["highlightOutline"]}},Ns=class extends qr{newFreeDrawOutline(t,e,n,r,a,l){return new Oa(t,e,n,r,a,l)}},Oa=class extends ti{newOutliner(t,e,n,r,a,l=0){return new Ns(t,e,n,r,a,l)}},ei=class i{#t=null;#e=null;#n;#s=null;#i=!1;#r=!1;#l=null;#a;#u=null;#c=null;#d;static#h=null;static get _keyboardManager(){return Ot(this,"_keyboardManager",new Fn([[["Escape","mac+Escape"],i.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],i.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],i.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],i.prototype._moveToPrevious],[["Home","mac+Home"],i.prototype._moveToBeginning],[["End","mac+End"],i.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#r=!1,this.#d=Mt.HIGHLIGHT_COLOR,this.#l=t):(this.#r=!0,this.#d=Mt.HIGHLIGHT_DEFAULT_COLOR),this.#c=t?._uiManager||e,this.#a=this.#c._eventBus,this.#n=t?.color||this.#c?.highlightColors.values().next().value||"#FFFF98",i.#h||=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"})}renderButton(){let t=this.#t=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);let e=this.#c._signal;t.addEventListener("click",this.#m.bind(this),{signal:e}),t.addEventListener("keydown",this.#p.bind(this),{signal:e});let n=this.#e=document.createElement("span");return n.className="swatch",n.setAttribute("aria-hidden",!0),n.style.backgroundColor=this.#n,t.append(n),t}renderMainDropdown(){let t=this.#s=this.#f();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#f(){let t=document.createElement("div"),e=this.#c._signal;t.addEventListener("contextmenu",He,{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(let[n,r]of this.#c.highlightColors){let a=document.createElement("button");a.tabIndex="0",a.role="option",a.setAttribute("data-color",r),a.title=n,a.setAttribute("data-l10n-id",i.#h[n]);let l=document.createElement("span");a.append(l),l.className="swatch",l.style.backgroundColor=r,a.setAttribute("aria-selected",r===this.#n),a.addEventListener("click",this.#o.bind(this,r),{signal:e}),t.append(a)}return t.addEventListener("keydown",this.#p.bind(this),{signal:e}),t}#o(t,e){e.stopPropagation(),this.#a.dispatch("switchannotationeditorparams",{source:this,type:this.#d,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#t){this.#m(t);return}let e=t.target.getAttribute("data-color");e&&this.#o(e,t)}_moveToNext(t){if(!this.#y){this.#m(t);return}if(t.target===this.#t){this.#s.firstChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#s?.firstChild||t.target===this.#t){this.#y&&this._hideDropdownFromKeyboard();return}this.#y||this.#m(t),t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#y){this.#m(t);return}this.#s.firstChild?.focus()}_moveToEnd(t){if(!this.#y){this.#m(t);return}this.#s.lastChild?.focus()}#p(t){i._keyboardManager.exec(this,t)}#m(t){if(this.#y){this.hideDropdown();return}if(this.#i=t.detail===0,this.#u||(this.#u=new AbortController,window.addEventListener("pointerdown",this.#g.bind(this),{signal:this.#c.combinedSignal(this.#u)})),this.#s){this.#s.classList.remove("hidden");return}let e=this.#s=this.#f();this.#t.append(e)}#g(t){this.#s?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#s?.classList.add("hidden"),this.#u?.abort(),this.#u=null}get#y(){return this.#s&&!this.#s.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#r){if(!this.#y){this.#l?.unselect();return}this.hideDropdown(),this.#t.focus({preventScroll:!0,focusVisible:this.#i})}}updateColor(t){if(this.#e&&(this.#e.style.backgroundColor=t),!this.#s)return;let e=this.#c.highlightColors.values();for(let n of this.#s.children)n.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#t?.remove(),this.#t=null,this.#e=null,this.#s?.remove(),this.#s=null}},ni=class i extends Xt{#t=null;#e=0;#n;#s=null;#i=null;#r=null;#l=null;#a=0;#u=null;#c=null;#d=null;#h=!1;#f=null;#o;#p=null;#m="";#g;#y="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=Pt.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let t=i.prototype;return Ot(this,"_keyboardManager",new Fn([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||i._defaultColor,this.#g=t.thickness||i._defaultThickness,this.#o=t.opacity||i._defaultOpacity,this.#n=t.boxes||null,this.#y=t.methodOfCreation||"",this.#m=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#h=!0,this.#b(t),this.#R()):this.#n&&(this.#t=t.anchorNode,this.#e=t.anchorOffset,this.#l=t.focusNode,this.#a=t.focusOffset,this.#x(),this.#R(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#h?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#g,methodOfCreation:this.#y}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#x(){let t=new _s(this.#n,.001);this.#c=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#c.box;let e=new _s(this.#n,.0025,.001,this._uiManager.direction==="ltr");this.#r=e.getOutlines();let{lastPoint:n}=this.#r;this.#f=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]}#b({highlightOutlines:t,highlightId:e,clipPathId:n}){this.#c=t;let r=1.5;if(this.#r=t.getNewOutline(this.#g/2+r,.0025),e>=0)this.#d=e,this.#s=n,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#p=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#r.box,path:{d:this.#r.toSVGPath()}},!0);else if(this.parent){let m=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#d,{bbox:i.#A(this.#c.box,(m-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#p,{bbox:i.#A(this.#r.box,m),path:{d:this.#r.toSVGPath()}})}let[a,l,u,f]=t.box;switch(this.rotation){case 0:this.x=a,this.y=l,this.width=u,this.height=f;break;case 90:{let[m,y]=this.parentDimensions;this.x=l,this.y=1-a,this.width=u*y/m,this.height=f*m/y;break}case 180:this.x=1-a,this.y=1-l,this.width=u,this.height=f;break;case 270:{let[m,y]=this.parentDimensions;this.x=1-l,this.y=a,this.width=u*y/m,this.height=f*m/y;break}}let{lastPoint:g}=this.#r;this.#f=[(g[0]-a)/u,(g[1]-l)/f]}static initialize(t,e){Xt.initialize(t,e),i._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case Mt.HIGHLIGHT_DEFAULT_COLOR:i._defaultColor=e;break;case Mt.HIGHLIGHT_THICKNESS:i._defaultThickness=e;break}}translateInPage(t,e){}get toolbarPosition(){return this.#f}updateParams(t,e){switch(t){case Mt.HIGHLIGHT_COLOR:this.#S(e);break;case Mt.HIGHLIGHT_THICKNESS:this.#T(e);break}}static get defaultPropertiesToUpdate(){return[[Mt.HIGHLIGHT_DEFAULT_COLOR,i._defaultColor],[Mt.HIGHLIGHT_THICKNESS,i._defaultThickness]]}get propertiesToUpdate(){return[[Mt.HIGHLIGHT_COLOR,this.color||i._defaultColor],[Mt.HIGHLIGHT_THICKNESS,this.#g||i._defaultThickness],[Mt.HIGHLIGHT_FREE,this.#h]]}#S(t){let e=(a,l)=>{this.color=a,this.#o=l,this.parent?.drawLayer.updateProperties(this.#d,{root:{fill:a,"fill-opacity":l}}),this.#i?.updateColor(a)},n=this.color,r=this.#o;this.addCommands({cmd:e.bind(this,t,i._defaultOpacity),undo:e.bind(this,n,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Mt.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#T(t){let e=this.#g,n=r=>{this.#g=r,this.#E(r)};this.addCommands({cmd:n.bind(this,t),undo:n.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Mt.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){let t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#i=new ei({editor:this}),t.addColorPicker(this.#i)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#O())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#O())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#k(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#R(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#k():t&&(this.#R(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#E(t){if(!this.#h)return;this.#b({highlightOutlines:this.#c.getNewOutline(t/2)}),this.fixAndSetPosition();let[e,n]=this.parentDimensions;this.setDims(this.width*e,this.height*n)}#k(){this.#d===null||!this.parent||(this.parent.drawLayer.remove(this.#d),this.#d=null,this.parent.drawLayer.remove(this.#p),this.#p=null)}#R(t=this.parent){this.#d===null&&({id:this.#d,clipPathId:this.#s}=t.drawLayer.draw({bbox:this.#c.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#o},rootClass:{highlight:!0,free:this.#h},path:{d:this.#c.toSVGPath()}},!1,!0),this.#p=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#h},bbox:this.#r.box,path:{d:this.#r.toSVGPath()}},this.#h),this.#u&&(this.#u.style.clipPath=this.#s))}static#A([t,e,n,r],a){switch(a){case 90:return[1-e-r,t,r,n];case 180:return[1-t-n,1-e-r,n,r];case 270:return[e,1-t-n,r,n]}return[t,e,n,r]}rotate(t){let{drawLayer:e}=this.parent,n;this.#h?(t=(t-this.rotation+360)%360,n=i.#A(this.#c.box,t)):n=i.#A([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#d,{bbox:n,root:{"data-main-rotation":t}}),e.updateProperties(this.#p,{bbox:i.#A(this.#r.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;let t=super.render();this.#m&&(t.setAttribute("aria-label",this.#m),t.setAttribute("role","mark")),this.#h?t.classList.add("free"):this.div.addEventListener("keydown",this.#I.bind(this),{signal:this._uiManager._signal});let e=this.#u=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#s;let[n,r]=this.parentDimensions;return this.setDims(this.width*n,this.height*r),Pr(this,this.#u,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1}})}#I(t){i._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#w(!0);break;case 1:case 3:this.#w(!1);break}}#w(t){if(!this.#t)return;let e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#l,this.#a)}select(){super.select(),this.#p&&this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#p&&(this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{selected:!1}}),this.#h||this.#w(!1))}get _mustFixPosition(){return!this.#h}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#d,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#p,{rootClass:{hidden:!t}}))}#O(){return this.#h?this.rotation:0}#F(){if(this.#h)return null;let[t,e]=this.pageDimensions,[n,r]=this.pageTranslation,a=this.#n,l=new Float32Array(a.length*8),u=0;for(let{x:f,y:g,width:m,height:y}of a){let v=f*t+n,S=(1-g)*e+r;l[u]=l[u+4]=v,l[u+1]=l[u+3]=S,l[u+2]=l[u+6]=v+m*t,l[u+5]=l[u+7]=S-y*e,u+=8}return l}#_(t){return this.#c.serialize(t,this.#O())}static startHighlighting(t,e,{target:n,x:r,y:a}){let{x:l,y:u,width:f,height:g}=n.getBoundingClientRect(),m=new AbortController,y=t.combinedSignal(m),v=S=>{m.abort(),this.#v(t,S)};window.addEventListener("blur",v,{signal:y}),window.addEventListener("pointerup",v,{signal:y}),window.addEventListener("pointerdown",we,{capture:!0,passive:!1,signal:y}),window.addEventListener("contextmenu",He,{signal:y}),n.addEventListener("pointermove",this.#C.bind(this,t),{signal:y}),this._freeHighlight=new Ns({x:r,y:a},[l,u,f,g],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static#C(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#v(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,n){let r=null;if(t instanceof Qr){let{data:{quadPoints:T,rect:C,rotation:k,id:I,color:O,opacity:D,popupRef:_},parent:{page:{pageNumber:M}}}=t;r=t={annotationType:Pt.HIGHLIGHT,color:Array.from(O),opacity:D,quadPoints:T,boxes:null,pageIndex:M-1,rect:C.slice(0),rotation:k,id:I,deleted:!1,popupRef:_}}else if(t instanceof Ds){let{data:{inkLists:T,rect:C,rotation:k,id:I,color:O,borderStyle:{rawWidth:D},popupRef:_},parent:{page:{pageNumber:M}}}=t;r=t={annotationType:Pt.HIGHLIGHT,color:Array.from(O),thickness:D,inkLists:T,boxes:null,pageIndex:M-1,rect:C.slice(0),rotation:k,id:I,deleted:!1,popupRef:_}}let{color:a,quadPoints:l,inkLists:u,opacity:f}=t,g=await super.deserialize(t,e,n);g.color=St.makeHexColor(...a),g.#o=f||1,u&&(g.#g=t.thickness),g.annotationElementId=t.id||null,g._initialData=r;let[m,y]=g.pageDimensions,[v,S]=g.pageTranslation;if(l){let T=g.#n=[];for(let C=0;C<l.length;C+=8)T.push({x:(l[C]-v)/m,y:1-(l[C+1]-S)/y,width:(l[C+2]-l[C])/m,height:(l[C+1]-l[C+5])/y});g.#x(),g.#R(),g.rotate(g.rotation)}else if(u){g.#h=!0;let T=u[0],C={x:T[0]-v,y:y-(T[1]-S)},k=new Ns(C,[0,0,m,y],1,g.#g/2,!0,.001);for(let D=0,_=T.length;D<_;D+=2)C.x=T[D]-v,C.y=y-(T[D+1]-S),k.add(C);let{id:I,clipPathId:O}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:g.color,"fill-opacity":g._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:k.toSVGPath()}},!0,!0);g.#b({highlightOutlines:k.getOutlines(),highlightId:I,clipPathId:O}),g.#R()}return g}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();let e=this.getRect(0,0),n=Xt._colorManager.convert(this.color),r={annotationType:Pt.HIGHLIGHT,color:n,opacity:this.#o,thickness:this.#g,quadPoints:this.#F(),outlines:this.#_(e),pageIndex:this.pageIndex,rect:e,rotation:this.#O(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#L(r)?null:(r.id=this.annotationElementId,r)}#L(t){let{color:e}=this._initialData;return t.color.some((n,r)=>n!==e[r])}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}},Ma=class{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(let[e,n]of Object.entries(t))this.updateProperty(e,n)}updateSVGProperty(t,e){this.#t[t]=e}toSVGProperties(){let t=this.#t;return this.#t=Object.create(null),{root:t}}reset(){this.#t=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){$t("Not implemented")}},La=class i extends Xt{#t=null;#e;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#n=null;static#s=null;static#i=null;static#r=NaN;static#l=null;static#a=null;static#u=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#e=t.mustBeCommitted||!1,t.drawOutlines&&(this.#c(t),this.#f())}#c({drawOutlines:t,drawId:e,drawingOptions:n}){this.#t=t,this._drawingOptions||=n,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#d(t,this.parent),this.#m(t.box)}#d(t,e){let{id:n}=e.drawLayer.draw(i._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return n}static _mergeSVGProperties(t,e){let n=new Set(Object.keys(t));for(let[r,a]of Object.entries(e))n.has(r)?Object.assign(t[r],a):t[r]=a;return t}static getDefaultDrawingOptions(t){$t("Not implemented")}static get typesMap(){$t("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){let n=this.typesMap.get(t);n&&this._defaultDrawingOptions.updateProperty(n,e),this._currentParent&&(i.#n.updateProperty(n,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){let n=this.constructor.typesMap.get(t);n&&this._updateProperty(t,n,e)}static get defaultPropertiesToUpdate(){let t=[],e=this._defaultDrawingOptions;for(let[n,r]of this.typesMap)t.push([n,e[r]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:e}=this;for(let[n,r]of this.constructor.typesMap)t.push([n,e[r]]);return t}_updateProperty(t,e,n){let r=this._drawingOptions,a=r[e],l=u=>{r.updateProperty(e,u);let f=this.#t.updateProperty(e,u);f&&this.#m(f),this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties())};this.addCommands({cmd:l.bind(this,n),undo:l.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,i._mergeSVGProperties(this.#t.getPathResizingSVGProperties(this.#p()),{bbox:this.#g()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,i._mergeSVGProperties(this.#t.getPathResizedSVGProperties(this.#p()),{bbox:this.#g()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#g(t,e)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,i._mergeSVGProperties(this.#t.getPathTranslatedSVGProperties(this.#p(),this.parentDimensions),{bbox:this.#g()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#e&&(this.#e=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#h(),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#f(),this.#m(this.#t.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#h()):t&&(this._uiManager.addShouldRescale(this),this.#f(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#h(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#f(t=this.parent){if(!(this._drawId!==null&&this.parent===t)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=this.#d(this.#t,t)}}#o([t,e,n,r]){let{parentDimensions:[a,l],rotation:u}=this;switch(u){case 90:return[e,1-t,n*(l/a),r*(a/l)];case 180:return[1-t,1-e,n,r];case 270:return[1-e,t,n*(l/a),r*(a/l)];default:return[t,e,n,r]}}#p(){let{x:t,y:e,width:n,height:r,parentDimensions:[a,l],rotation:u}=this;switch(u){case 90:return[1-e,t,n*(a/l),r*(l/a)];case 180:return[1-t,1-e,n,r];case 270:return[e,1-t,n*(a/l),r*(l/a)];default:return[t,e,n,r]}}#m(t){if([this.x,this.y,this.width,this.height]=this.#o(t),this.div){this.fixAndSetPosition();let[e,n]=this.parentDimensions;this.setDims(this.width*e,this.height*n)}this._onResized()}#g(){let{x:t,y:e,width:n,height:r,rotation:a,parentRotation:l,parentDimensions:[u,f]}=this;switch((a*4+l)/90){case 1:return[1-e-r,t,r,n];case 2:return[1-t-n,1-e-r,n,r];case 3:return[e,1-t-n,r,n];case 4:return[t,e-n*(u/f),r*(f/u),n*(u/f)];case 5:return[1-e,t,n*(u/f),r*(f/u)];case 6:return[1-t-r*(f/u),1-e,r*(f/u),n*(u/f)];case 7:return[e-n*(u/f),1-t-r*(f/u),n*(u/f),r*(f/u)];case 8:return[t-n,e-r,n,r];case 9:return[1-e,t-n,r,n];case 10:return[1-t,1-e,n,r];case 11:return[e-r,1-t,r,n];case 12:return[t-r*(f/u),e,r*(f/u),n*(u/f)];case 13:return[1-e-n*(u/f),t-r*(f/u),n*(u/f),r*(f/u)];case 14:return[1-t,1-e-n*(u/f),r*(f/u),n*(u/f)];case 15:return[e,1-t,n*(u/f),r*(f/u)];default:return[t,e,n,r]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,i._mergeSVGProperties({bbox:this.#g()},this.#t.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#m(this.#t.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t=super.render();t.classList.add("draw");let e=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal";let[n,r]=this.parentDimensions;return this.setDims(this.width*n,this.height*r),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,e,n,r,a){$t("Not implemented")}static startDrawing(t,e,n,r){let{target:a,offsetX:l,offsetY:u,pointerId:f,pointerType:g}=r;if(i.#l&&i.#l!==g)return;let{viewport:{rotation:m}}=t,{width:y,height:v}=a.getBoundingClientRect(),S=i.#s=new AbortController,T=t.combinedSignal(S);if(i.#r||=f,i.#l??=g,window.addEventListener("pointerup",C=>{i.#r===C.pointerId?this._endDraw(C):i.#a?.delete(C.pointerId)},{signal:T}),window.addEventListener("pointercancel",C=>{i.#r===C.pointerId?this._currentParent.endDrawingSession():i.#a?.delete(C.pointerId)},{signal:T}),window.addEventListener("pointerdown",C=>{i.#l===C.pointerType&&((i.#a||=new Set).add(C.pointerId),i.#n.isCancellable()&&(i.#n.removeLastElement(),i.#n.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:T}),window.addEventListener("contextmenu",He,{signal:T}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:T}),a.addEventListener("touchmove",C=>{C.timeStamp===i.#u&&we(C)},{signal:T}),t.toggleDrawing(),e._editorUndoBar?.hide(),i.#n){t.drawLayer.updateProperties(this._currentDrawId,i.#n.startNew(l,u,y,v,m));return}e.updateUIForDefaultProperties(this),i.#n=this.createDrawerInstance(l,u,y,v,m),i.#i=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(i.#i.toSVGProperties(),i.#n.defaultSVGProperties),!0,!1)}static _drawMove(t){if(i.#u=-1,!i.#n)return;let{offsetX:e,offsetY:n,pointerId:r}=t;if(i.#r===r){if(i.#a?.size>=1){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,i.#n.add(e,n)),i.#u=t.timeStamp,we(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,i.#n=null,i.#i=null,i.#l=null,i.#u=NaN),i.#s&&(i.#s.abort(),i.#s=null,i.#r=NaN,i.#a=null)}static _endDraw(t){let e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,i.#n.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){let n=i.#n,r=this._currentDrawId,a=n.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(r,n.setLastElement(a))},undo:()=>{e.drawLayer.updateProperties(r,n.removeLastElement())},mustExec:!1,type:Mt.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){let e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(Mt.DRAW_STEP),!i.#n.isEmpty()){let{pageDimensions:[n,r],scale:a}=e,l=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:i.#n.getOutlines(n*a,r*a,a,this._INNER_MARGIN),drawingOptions:i.#i,mustBeCommitted:!t});return this._cleanup(!0),l}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,n,r,a,l){$t("Not implemented")}static async deserialize(t,e,n){let{rawDims:{pageWidth:r,pageHeight:a,pageX:l,pageY:u}}=e.viewport,f=this.deserializeDraw(l,u,r,a,this._INNER_MARGIN,t),g=await super.deserialize(t,e,n);return g.createDrawingOptions(t),g.#c({drawOutlines:f}),g.#f(),g.onScaleChanging(),g.rotate(),g}serializeDraw(t){let[e,n]=this.pageTranslation,[r,a]=this.pageDimensions;return this.#t.serialize([e,n,r,a],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}},Fa=class{#t=new Float64Array(6);#e;#n;#s;#i;#r;#l="";#a=0;#u=new si;#c;#d;constructor(t,e,n,r,a,l){this.#c=n,this.#d=r,this.#s=a,this.#i=l,[t,e]=this.#h(t,e);let u=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#r=[t,e],this.#n=[{line:u,points:this.#r}],this.#t.set(u,0)}updateProperty(t,e){t==="stroke-width"&&(this.#i=e)}#h(t,e){return ht._normalizePoint(t,e,this.#c,this.#d,this.#s)}isEmpty(){return!this.#n||this.#n.length===0}isCancellable(){return this.#r.length<=10}add(t,e){[t,e]=this.#h(t,e);let[n,r,a,l]=this.#t.subarray(2,6),u=t-a,f=e-l;return Math.hypot(this.#c*u,this.#d*f)<=2?null:(this.#r.push(t,e),isNaN(n)?(this.#t.set([a,l,t,e],2),this.#e.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#t[0])&&this.#e.splice(6,6),this.#t.set([n,r,a,l,t,e],0),this.#e.push(...ht.createBezierPoints(n,r,a,l,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){let n=this.add(t,e);return n||(this.#r.length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,n,r,a){this.#c=n,this.#d=r,this.#s=a,[t,e]=this.#h(t,e);let l=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#r=[t,e];let u=this.#n.at(-1);return u&&(u.line=new Float32Array(u.line),u.points=new Float32Array(u.points)),this.#n.push({line:l,points:this.#r}),this.#t.set(l,0),this.#a=0,this.toSVGPath(),null}getLastElement(){return this.#n.at(-1)}setLastElement(t){return this.#n?(this.#n.push(t),this.#e=t.line,this.#r=t.points,this.#a=0,{path:{d:this.toSVGPath()}}):this.#u.setLastElement(t)}removeLastElement(){if(!this.#n)return this.#u.removeLastElement();this.#n.pop(),this.#l="";for(let t=0,e=this.#n.length;t<e;t++){let{line:n,points:r}=this.#n[t];this.#e=n,this.#r=r,this.#a=0,this.toSVGPath()}return{path:{d:this.#l}}}toSVGPath(){let t=ht.svgRound(this.#e[4]),e=ht.svgRound(this.#e[5]);if(this.#r.length===2)return this.#l=`${this.#l} M ${t} ${e} Z`,this.#l;if(this.#r.length<=6){let r=this.#l.lastIndexOf("M");this.#l=`${this.#l.slice(0,r)} M ${t} ${e}`,this.#a=6}if(this.#r.length===4){let r=ht.svgRound(this.#e[10]),a=ht.svgRound(this.#e[11]);return this.#l=`${this.#l} L ${r} ${a}`,this.#a=12,this.#l}let n=[];this.#a===0&&(n.push(`M ${t} ${e}`),this.#a=6);for(let r=this.#a,a=this.#e.length;r<a;r+=6){let[l,u,f,g,m,y]=this.#e.slice(r,r+6).map(ht.svgRound);n.push(`C${l} ${u} ${f} ${g} ${m} ${y}`)}return this.#l+=n.join(" "),this.#a=this.#e.length,this.#l}getOutlines(t,e,n,r){let a=this.#n.at(-1);return a.line=new Float32Array(a.line),a.points=new Float32Array(a.points),this.#u.build(this.#n,t,e,n,this.#s,this.#i,r),this.#t=null,this.#e=null,this.#n=null,this.#l=null,this.#u}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}},si=class i extends ht{#t;#e=0;#n;#s;#i;#r;#l;#a;#u;build(t,e,n,r,a,l,u){this.#i=e,this.#r=n,this.#l=r,this.#a=a,this.#u=l,this.#n=u??0,this.#s=t,this.#h()}setLastElement(t){return this.#s.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#s.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let t=[];for(let{line:e}of this.#s){if(t.push(`M${ht.svgRound(e[4])} ${ht.svgRound(e[5])}`),e.length===6){t.push("Z");continue}if(e.length===12){t.push(`L${ht.svgRound(e[10])} ${ht.svgRound(e[11])}`);continue}for(let n=6,r=e.length;n<r;n+=6){let[a,l,u,f,g,m]=e.subarray(n,n+6).map(ht.svgRound);t.push(`C${a} ${l} ${u} ${f} ${g} ${m}`)}}return t.join("")}serialize([t,e,n,r],a){let l=[],u=[],[f,g,m,y]=this.#d(),v,S,T,C,k,I,O,D,_;switch(this.#a){case 0:_=ht._rescale,v=t,S=e+r,T=n,C=-r,k=t+f*n,I=e+(1-g-y)*r,O=t+(f+m)*n,D=e+(1-g)*r;break;case 90:_=ht._rescaleAndSwap,v=t,S=e,T=n,C=r,k=t+g*n,I=e+f*r,O=t+(g+y)*n,D=e+(f+m)*r;break;case 180:_=ht._rescale,v=t+n,S=e,T=-n,C=r,k=t+(1-f-m)*n,I=e+g*r,O=t+(1-f)*n,D=e+(g+y)*r;break;case 270:_=ht._rescaleAndSwap,v=t+n,S=e+r,T=-n,C=-r,k=t+(1-g-y)*n,I=e+(1-f-m)*r,O=t+(1-g)*n,D=e+(1-f)*r;break}for(let{line:M,points:B}of this.#s)l.push(_(M,v,S,T,C,a?new Array(M.length):null)),u.push(_(B,v,S,T,C,a?new Array(B.length):null));return{lines:l,points:u,rect:[k,I,O,D]}}static deserialize(t,e,n,r,a,{paths:{lines:l,points:u},rotation:f,thickness:g}){let m=[],y,v,S,T,C;switch(f){case 0:C=ht._rescale,y=-t/n,v=e/r+1,S=1/n,T=-1/r;break;case 90:C=ht._rescaleAndSwap,y=-e/r,v=-t/n,S=1/r,T=1/n;break;case 180:C=ht._rescale,y=t/n+1,v=-e/r,S=-1/n,T=1/r;break;case 270:C=ht._rescaleAndSwap,y=e/r+1,v=t/n+1,S=-1/r,T=-1/n;break}if(!l){l=[];for(let I of u){let O=I.length;if(O===2){l.push(new Float32Array([NaN,NaN,NaN,NaN,I[0],I[1]]));continue}if(O===4){l.push(new Float32Array([NaN,NaN,NaN,NaN,I[0],I[1],NaN,NaN,NaN,NaN,I[2],I[3]]));continue}let D=new Float32Array(3*(O-2));l.push(D);let[_,M,B,H]=I.subarray(0,4);D.set([NaN,NaN,NaN,NaN,_,M],0);for(let z=4;z<O;z+=2){let W=I[z],Q=I[z+1];D.set(ht.createBezierPoints(_,M,B,H,W,Q),(z-2)*3),[_,M,B,H]=[B,H,W,Q]}}}for(let I=0,O=l.length;I<O;I++)m.push({line:C(l[I].map(D=>D??NaN),y,v,S,T),points:C(u[I].map(D=>D??NaN),y,v,S,T)});let k=new i;return k.build(m,n,r,1,f,g,a),k}#c(t=this.#u){let e=this.#n+t/2*this.#l;return this.#a%180===0?[e/this.#i,e/this.#r]:[e/this.#r,e/this.#i]}#d(){let[t,e,n,r]=this.#t,[a,l]=this.#c(0);return[t+a,e+l,n-2*a,r-2*l]}#h(){let t=this.#t=new Float32Array([1/0,1/0,-1/0,-1/0]);for(let{line:r}of this.#s){if(r.length<=12){for(let u=4,f=r.length;u<f;u+=6){let[g,m]=r.subarray(u,u+2);t[0]=Math.min(t[0],g),t[1]=Math.min(t[1],m),t[2]=Math.max(t[2],g),t[3]=Math.max(t[3],m)}continue}let a=r[4],l=r[5];for(let u=6,f=r.length;u<f;u+=6){let[g,m,y,v,S,T]=r.subarray(u,u+6);St.bezierBoundingBox(a,l,g,m,y,v,S,T,t),a=S,l=T}}let[e,n]=this.#c();t[0]=Math.min(1,Math.max(0,t[0]-e)),t[1]=Math.min(1,Math.max(0,t[1]-n)),t[2]=Math.min(1,Math.max(0,t[2]+e)),t[3]=Math.min(1,Math.max(0,t[3]+n)),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#t}updateProperty(t,e){return t==="stroke-width"?this.#f(e):null}#f(t){let[e,n]=this.#c();this.#u=t;let[r,a]=this.#c(),[l,u]=[r-e,a-n],f=this.#t;return f[0]-=l,f[1]-=u,f[2]+=2*l,f[3]+=2*u,f}updateParentDimensions([t,e],n){let[r,a]=this.#c();this.#i=t,this.#r=e,this.#l=n;let[l,u]=this.#c(),f=l-r,g=u-a,m=this.#t;return m[0]-=f,m[1]-=g,m[2]+=2*f,m[3]+=2*g,m}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(ht.svgRound).join(" ")}get defaultProperties(){let[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ht.svgRound(t)} ${ht.svgRound(e)}`}}}get rotationTransform(){let[,,t,e]=this.#t,n=0,r=0,a=0,l=0,u=0,f=0;switch(this.#e){case 90:r=e/t,a=-t/e,u=t;break;case 180:n=-1,l=-1,u=t,f=e;break;case 270:r=-e/t,a=t/e,f=e;break;default:return""}return`matrix(${n} ${r} ${a} ${l} ${ht.svgRound(u)} ${ht.svgRound(f)})`}getPathResizingSVGProperties([t,e,n,r]){let[a,l]=this.#c(),[u,f,g,m]=this.#t;if(Math.abs(g-a)<=ht.PRECISION||Math.abs(m-l)<=ht.PRECISION){let C=t+n/2-(u+g/2),k=e+r/2-(f+m/2);return{path:{"transform-origin":`${ht.svgRound(t)} ${ht.svgRound(e)}`,transform:`${this.rotationTransform} translate(${C} ${k})`}}}let y=(n-2*a)/(g-2*a),v=(r-2*l)/(m-2*l),S=g/n,T=m/r;return{path:{"transform-origin":`${ht.svgRound(u)} ${ht.svgRound(f)}`,transform:`${this.rotationTransform} scale(${S} ${T}) translate(${ht.svgRound(a)} ${ht.svgRound(l)}) scale(${y} ${v}) translate(${ht.svgRound(-a)} ${ht.svgRound(-l)})`}}}getPathResizedSVGProperties([t,e,n,r]){let[a,l]=this.#c(),u=this.#t,[f,g,m,y]=u;if(u[0]=t,u[1]=e,u[2]=n,u[3]=r,Math.abs(m-a)<=ht.PRECISION||Math.abs(y-l)<=ht.PRECISION){let k=t+n/2-(f+m/2),I=e+r/2-(g+y/2);for(let{line:O,points:D}of this.#s)ht._translate(O,k,I,O),ht._translate(D,k,I,D);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ht.svgRound(t)} ${ht.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let v=(n-2*a)/(m-2*a),S=(r-2*l)/(y-2*l),T=-v*(f+a)+t+a,C=-S*(g+l)+e+l;if(v!==1||S!==1||T!==0||C!==0)for(let{line:k,points:I}of this.#s)ht._rescale(k,T,C,v,S,k),ht._rescale(I,T,C,v,S,I);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ht.svgRound(t)} ${ht.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],n){let[r,a]=n,l=this.#t,u=t-l[0],f=e-l[1];if(this.#i===r&&this.#r===a)for(let{line:g,points:m}of this.#s)ht._translate(g,u,f,g),ht._translate(m,u,f,m);else{let g=this.#i/r,m=this.#r/a;this.#i=r,this.#r=a;for(let{line:y,points:v}of this.#s)ht._rescale(y,u,f,g,m,y),ht._rescale(v,u,f,g,m,v);l[2]*=g,l[3]*=m}return l[0]=t,l[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${ht.svgRound(t)} ${ht.svgRound(e)}`}}}get defaultSVGProperties(){let t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${ht.svgRound(t[0])} ${ht.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}},Da=class i extends Ma{#t;constructor(t){super(),this.#t=t,super.updateProperties({fill:"none",stroke:Xt._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??=this["stroke-width"],e*=this.#t.realScale),super.updateSVGProperty(t,e)}clone(){let t=new i(this.#t);return t.updateAll(this),t}},_a=class i extends La{static _type="ink";static _editorType=Pt.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(t,e){Xt.initialize(t,e),this._defaultDrawingOptions=new Da(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Ot(this,"typesMap",new Map([[Mt.INK_THICKNESS,"stroke-width"],[Mt.INK_COLOR,"stroke"],[Mt.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,n,r,a){return new Fa(t,e,n,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,n,r,a,l){return si.deserialize(t,e,n,r,a,l)}static async deserialize(t,e,n){let r=null;if(t instanceof Ds){let{data:{inkLists:l,rect:u,rotation:f,id:g,color:m,opacity:y,borderStyle:{rawWidth:v},popupRef:S},parent:{page:{pageNumber:T}}}=t;r=t={annotationType:Pt.INK,color:Array.from(m),thickness:v,opacity:y,paths:{points:l},boxes:null,pageIndex:T-1,rect:u.slice(0),rotation:f,id:g,deleted:!1,popupRef:S}}let a=await super.deserialize(t,e,n);return a.annotationElementId=t.id||null,a._initialData=r,a}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:t,_drawingOptions:e,parent:n}=this;e.updateSVGProperty("stroke-width"),n.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){let t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:n}){this._drawingOptions=i.getDefaultDrawingOptions({stroke:St.makeHexColor(...t),"stroke-width":e,"stroke-opacity":n})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:e,points:n,rect:r}=this.serializeDraw(t),{_drawingOptions:{stroke:a,"stroke-opacity":l,"stroke-width":u}}=this,f={annotationType:Pt.INK,color:Xt._colorManager.convert(a),opacity:l,thickness:u,paths:{lines:e,points:n},pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?f:this.annotationElementId&&!this.#t(f)?null:(f.id=this.annotationElementId,f)}#t(t){let{color:e,thickness:n,opacity:r,pageIndex:a}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some((l,u)=>l!==e[u])||t.thickness!==n||t.opacity!==r||t.pageIndex!==a}renderAnnotationElement(t){let{points:e,rect:n}=this.serializeDraw(!1);return t.updateEdited({rect:n,thickness:this._drawingOptions["stroke-width"],points:e}),null}},Na=class i extends Xt{#t=null;#e=null;#n=null;#s=null;#i=null;#r="";#l=null;#a=null;#u=!1;#c=!1;static _type="stamp";static _editorType=Pt.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#s=t.bitmapUrl,this.#i=t.bitmapFile}static initialize(t,e){Xt.initialize(t,e)}static get supportedTypes(){return Ot(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(e=>`image/${e}`))}static get supportedTypesStr(){return Ot(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(Pt.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){let e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#d(t,e=!1){if(!t){this.remove();return}this.#t=t.bitmap,e||(this.#e=t.id,this.#u=t.isSvg),t.file&&(this.#r=t.file.name),this.#o()}#h(){if(this.#n=null,this._uiManager.enableWaiting(!1),!!this.#l){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;let{mlManager:n}=this._uiManager;if(!n)throw new Error("No ML.");if(!await n.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");let{data:r,width:a,height:l}=t||this.copyCanvas(null,null,!0).imageData,u=await n.guess({name:"altText",request:{data:r,width:a,height:l,channels:r.length/(a*l)}});if(!u)throw new Error("No response from the AI service.");if(u.error)throw new Error("Error from the AI service.");if(u.cancel)return null;if(!u.output)throw new Error("No valid response from the AI service.");let f=u.output;return await this.setGuessedAltText(f),e&&!this.hasAltTextData()&&(this.altTextData={alt:f,decorative:!1}),f}#f(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then(n=>this.#d(n,!0)).finally(()=>this.#h());return}if(this.#s){let n=this.#s;this.#s=null,this._uiManager.enableWaiting(!0),this.#n=this._uiManager.imageManager.getFromUrl(n).then(r=>this.#d(r)).finally(()=>this.#h());return}if(this.#i){let n=this.#i;this.#i=null,this._uiManager.enableWaiting(!0),this.#n=this._uiManager.imageManager.getFromFile(n).then(r=>this.#d(r)).finally(()=>this.#h());return}let t=document.createElement("input");t.type="file",t.accept=i.supportedTypesStr;let e=this._uiManager._signal;this.#n=new Promise(n=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);let r=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#d(r)}n()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),n()},{signal:e})}).finally(()=>this.#h()),t.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#l?.remove(),this.#l=null,this.#a&&(clearTimeout(this.#a),this.#a=null)),super.remove()}rebuild(){if(!this.parent){this.#e&&this.#f();return}super.rebuild(),this.div!==null&&(this.#e&&this.#l===null&&this.#f(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#n||this.#t||this.#s||this.#i||this.#e)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#t?this.#o():this.#f(),this.width&&!this.annotationElementId){let[n,r]=this.parentDimensions;this.setAt(t*n,e*r,this.width*n,this.height*r)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#a!==null&&clearTimeout(this.#a);let t=200;this.#a=setTimeout(()=>{this.#a=null,this.#m()},t)}#o(){let{div:t}=this,{width:e,height:n}=this.#t,[r,a]=this.pageDimensions,l=.75;if(this.width)e=this.width*r,n=this.height*a;else if(e>l*r||n>l*a){let m=Math.min(l*r/e,l*a/n);e*=m,n*=m}let[u,f]=this.parentDimensions;this.setDims(e*u/r,n*f/a),this._uiManager.enableWaiting(!1);let g=this.#l=document.createElement("canvas");g.setAttribute("role","img"),this.addContainer(g),this.width=e/r,this.height=n/a,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),this.#m(),this.#c||(this.parent.addUndoableEditor(this),this.#c=!0),this._reportTelemetry({action:"inserted_image"}),this.#r&&g.setAttribute("aria-label",this.#r)}copyCanvas(t,e,n=!1){t||(t=224);let{width:r,height:a}=this.#t,l=new Is,u=this.#t,f=r,g=a,m=null;if(e){if(r>e||a>e){let B=Math.min(e/r,e/a);f=Math.floor(r*B),g=Math.floor(a*B)}m=document.createElement("canvas");let v=m.width=Math.ceil(f*l.sx),S=m.height=Math.ceil(g*l.sy);this.#u||(u=this.#p(v,S));let T=m.getContext("2d");T.filter=this._uiManager.hcmFilter;let C="white",k="#cfcfd8";this._uiManager.hcmFilter!=="none"?k="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(C="#8f8f9d",k="#42414d");let I=15,O=I*l.sx,D=I*l.sy,_=new OffscreenCanvas(O*2,D*2),M=_.getContext("2d");M.fillStyle=C,M.fillRect(0,0,O*2,D*2),M.fillStyle=k,M.fillRect(0,0,O,D),M.fillRect(O,D,O,D),T.fillStyle=T.createPattern(_,"repeat"),T.fillRect(0,0,v,S),T.drawImage(u,0,0,u.width,u.height,0,0,v,S)}let y=null;if(n){let v,S;if(l.symmetric&&u.width<t&&u.height<t)v=u.width,S=u.height;else if(u=this.#t,r>t||a>t){let k=Math.min(t/r,t/a);v=Math.floor(r*k),S=Math.floor(a*k),this.#u||(u=this.#p(v,S))}let C=new OffscreenCanvas(v,S).getContext("2d",{willReadFrequently:!0});C.drawImage(u,0,0,u.width,u.height,0,0,v,S),y={width:v,height:S,data:C.getImageData(0,0,v,S).data}}return{canvas:m,width:f,height:g,imageData:y}}#p(t,e){let{width:n,height:r}=this.#t,a=n,l=r,u=this.#t;for(;a>2*t||l>2*e;){let f=a,g=l;a>2*t&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2)),l>2*e&&(l=l>=16384?Math.floor(l/2)-1:Math.ceil(l/2));let m=new OffscreenCanvas(a,l);m.getContext("2d").drawImage(u,0,0,f,g,0,0,a,l),u=m.transferToImageBitmap()}return u}#m(){let[t,e]=this.parentDimensions,{width:n,height:r}=this,a=new Is,l=Math.ceil(n*t*a.sx),u=Math.ceil(r*e*a.sy),f=this.#l;if(!f||f.width===l&&f.height===u)return;f.width=l,f.height=u;let g=this.#u?this.#t:this.#p(l,u),m=f.getContext("2d");m.filter=this._uiManager.hcmFilter,m.drawImage(g,0,0,g.width,g.height,0,0,l,u)}getImageForAltText(){return this.#l}#g(t){if(t){if(this.#u){let r=this._uiManager.imageManager.getSvgUrl(this.#e);if(r)return r}let e=document.createElement("canvas");return{width:e.width,height:e.height}=this.#t,e.getContext("2d").drawImage(this.#t,0,0),e.toDataURL()}if(this.#u){let[e,n]=this.pageDimensions,r=Math.round(this.width*e*yn.PDF_TO_CSS_UNITS),a=Math.round(this.height*n*yn.PDF_TO_CSS_UNITS),l=new OffscreenCanvas(r,a);return l.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,r,a),l.transferToImageBitmap()}return structuredClone(this.#t)}static async deserialize(t,e,n){let r=null;if(t instanceof Jr){let{data:{rect:T,rotation:C,id:k,structParent:I,popupRef:O},container:D,parent:{page:{pageNumber:_}}}=t,M=D.querySelector("canvas"),B=n.imageManager.getFromCanvas(D.id,M);M.remove();let H=(await e._structTree.getAriaAttributes(`${Ha}${k}`))?.get("aria-label")||"";r=t={annotationType:Pt.STAMP,bitmapId:B.id,bitmap:B.bitmap,pageIndex:_-1,rect:T.slice(0),rotation:C,id:k,deleted:!1,accessibilityData:{decorative:!1,altText:H},isSvg:!1,structParent:I,popupRef:O}}let a=await super.deserialize(t,e,n),{rect:l,bitmap:u,bitmapUrl:f,bitmapId:g,isSvg:m,accessibilityData:y}=t;g&&n.imageManager.isValidId(g)?(a.#e=g,u&&(a.#t=u)):a.#s=f,a.#u=m;let[v,S]=a.pageDimensions;return a.width=(l[2]-l[0])/v,a.height=(l[3]-l[1])/S,a.annotationElementId=t.id||null,y&&(a.altTextData=y),a._initialData=r,a.#c=!!r,a}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let n={annotationType:Pt.STAMP,bitmapId:this.#e,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#u,structTreeParentId:this._structTreeParentId};if(t)return n.bitmapUrl=this.#g(!0),n.accessibilityData=this.serializeAltText(!0),n;let{decorative:r,altText:a}=this.serializeAltText(!1);if(!r&&a&&(n.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){let u=this.#y(n);if(u.isSame)return null;u.isSameAltText?delete n.accessibilityData:n.accessibilityData.structParent=this._initialData.structParent??-1}if(n.id=this.annotationElementId,e===null)return n;e.stamps||=new Map;let l=this.#u?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(!e.stamps.has(this.#e))e.stamps.set(this.#e,{area:l,serialized:n}),n.bitmap=this.#g(!1);else if(this.#u){let u=e.stamps.get(this.#e);l>u.area&&(u.area=l,u.serialized.bitmap.close(),u.serialized.bitmap=this.#g(!1))}return n}#y(t){let{pageIndex:e,accessibilityData:{altText:n}}=this._initialData,r=t.pageIndex===e,a=(t.accessibilityData?.alt||"")===n;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}},Ua=class i{#t;#e=!1;#n=null;#s=null;#i=null;#r=new Map;#l=!1;#a=!1;#u=!1;#c=null;#d=null;#h=null;#f=null;#o;static _initialized=!1;static#p=new Map([Ra,_a,Na,ni].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:n,structTreeLayer:r,accessibilityManager:a,annotationLayer:l,drawLayer:u,textLayer:f,viewport:g,l10n:m}){let y=[...i.#p.values()];if(!i._initialized){i._initialized=!0;for(let v of y)v.initialize(m,t)}t.registerEditorTypes(y),this.#o=t,this.pageIndex=e,this.div=n,this.#t=a,this.#n=l,this.viewport=g,this.#h=f,this.drawLayer=u,this._structTree=r,this.#o.addLayer(this)}get isEmpty(){return this.#r.size===0}get isInvisible(){return this.isEmpty&&this.#o.getMode()===Pt.NONE}updateToolbar(t){this.#o.updateToolbar(t)}updateMode(t=this.#o.getMode()){switch(this.#b(),t){case Pt.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case Pt.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Pt.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:e}=this.div;for(let n of i.#p.values())e.toggle(`${n._type}Editing`,t===n._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#h?.div}setEditingState(t){this.#o.setEditingState(t)}addCommands(t){this.#o.addCommands(t)}cleanUndoStack(t){this.#o.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#n?.div.classList.toggle("disabled",!t)}async enable(){this.#u=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);let t=new Set;for(let n of this.#r.values())n.enableEditing(),n.show(!0),n.annotationElementId&&(this.#o.removeChangedExistingAnnotation(n),t.add(n.annotationElementId));if(!this.#n){this.#u=!1;return}let e=this.#n.getEditableAnnotations();for(let n of e){if(n.hide(),this.#o.isDeletedAnnotationElement(n.data.id)||t.has(n.data.id))continue;let r=await this.deserialize(n);r&&(this.addOrRebuild(r),r.enableEditing())}this.#u=!1}disable(){this.#a=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);let t=new Map,e=new Map;for(let r of this.#r.values())if(r.disableEditing(),!!r.annotationElementId){if(r.serialize()!==null){t.set(r.annotationElementId,r);continue}else e.set(r.annotationElementId,r);this.getEditableAnnotation(r.annotationElementId)?.show(),r.remove()}if(this.#n){let r=this.#n.getEditableAnnotations();for(let a of r){let{id:l}=a.data;if(this.#o.isDeletedAnnotationElement(l))continue;let u=e.get(l);if(u){u.resetAnnotationElement(a),u.show(!1),a.show();continue}u=t.get(l),u&&(this.#o.addChangedExistingAnnotation(u),u.renderAnnotationElement(a)&&u.show(!1)),a.show()}}this.#b(),this.isEmpty&&(this.div.hidden=!0);let{classList:n}=this.div;for(let r of i.#p.values())n.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#a=!1}getEditableAnnotation(t){return this.#n?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#o.getActive()!==t&&this.#o.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#h?.div&&!this.#f){this.#f=new AbortController;let t=this.#o.combinedSignal(this.#f);this.#h.div.addEventListener("pointerdown",this.#m.bind(this),{signal:t}),this.#h.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#h?.div&&this.#f&&(this.#f.abort(),this.#f=null,this.#h.div.classList.remove("highlighting"))}#m(t){this.#o.unselectAll();let{target:e}=t;if(e===this.#h.div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&this.#h.div.contains(e)){let{isMac:n}=se.platform;if(t.button!==0||t.ctrlKey&&n)return;this.#o.showAllEditors("highlight",!0,!0),this.#h.div.classList.add("free"),this.toggleDrawing(),ni.startHighlighting(this,this.#o.direction==="ltr",{target:this.#h.div,x:t.x,y:t.y}),this.#h.div.addEventListener("pointerup",()=>{this.#h.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#o._signal}),t.preventDefault()}}enableClick(){if(this.#s)return;this.#s=new AbortController;let t=this.#o.combinedSignal(this.#s);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});let e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#s?.abort(),this.#s=null}attach(t){this.#r.set(t.id,t);let{annotationElementId:e}=t;e&&this.#o.isDeletedAnnotationElement(e)&&this.#o.removeDeletedAnnotationElement(t)}detach(t){this.#r.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#a&&t.annotationElementId&&this.#o.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#o.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#o.addDeletedAnnotationElement(t.annotationElementId),Xt.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.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),this.#o.addEditor(t),this.attach(t),!t.isAttachedToDOM){let e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#u),this.#o.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:e}=document;t.div.contains(e)&&!this.#i&&(t._focusEventsAllowed=!1,this.#i=setTimeout(()=>{this.#i=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#o._signal}),e.focus())},0)),t._structTreeParentId=this.#t?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){let e=()=>t._uiManager.rebuild(t),n=()=>{t.remove()};this.addCommands({cmd:e,undo:n,mustExec:!1})}getNextId(){return this.#o.getId()}get#g(){return i.#p.get(this.#o.getMode())}combinedSignal(t){return this.#o.combinedSignal(t)}#y(t){let e=this.#g;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#g?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#o.updateToolbar(t),this.#o.updateMode(t);let{offsetX:n,offsetY:r}=this.#x(),a=this.getNextId(),l=this.#y({parent:this,id:a,x:n,y:r,uiManager:this.#o,isCentered:!0,...e});l&&this.add(l)}async deserialize(t){return await i.#p.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#o)||null}createAndAddNewEditor(t,e,n={}){let r=this.getNextId(),a=this.#y({parent:this,id:r,x:t.offsetX,y:t.offsetY,uiManager:this.#o,isCentered:e,...n});return a&&this.add(a),a}#x(){let{x:t,y:e,width:n,height:r}=this.div.getBoundingClientRect(),a=Math.max(0,t),l=Math.max(0,e),u=Math.min(window.innerWidth,t+n),f=Math.min(window.innerHeight,e+r),g=(a+u)/2-t,m=(l+f)/2-e,[y,v]=this.viewport.rotation%180===0?[g,m]:[m,g];return{offsetX:y,offsetY:v}}addNewEditor(){this.createAndAddNewEditor(this.#x(),!0)}setSelected(t){this.#o.setSelected(t)}toggleSelected(t){this.#o.toggleSelected(t)}unselect(t){this.#o.unselect(t)}pointerup(t){let{isMac:e}=se.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&this.#l&&(this.#l=!1,!(this.#g?.isDrawer&&this.#g.supportMultipleDrawings))){if(!this.#e){this.#e=!0;return}if(this.#o.getMode()===Pt.STAMP){this.#o.unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(this.#o.getMode()===Pt.HIGHLIGHT&&this.enableTextSelection(),this.#l){this.#l=!1;return}let{isMac:e}=se.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(this.#l=!0,this.#g?.isDrawer){this.startDrawingSession(t);return}let n=this.#o.getActive();this.#e=!n||n.isEmpty()}startDrawingSession(t){if(this.div.focus(),this.#c){this.#g.startDrawing(this,this.#o,!1,t);return}this.#o.setCurrentDrawingSession(this),this.#c=new AbortController;let e=this.#o.combinedSignal(this.#c);this.div.addEventListener("blur",({relatedTarget:n})=>{n&&!this.div.contains(n)&&(this.#d=null,this.commitOrRemove())},{signal:e}),this.#g.startDrawing(this,this.#o,!1,t)}pause(t){if(t){let{activeElement:e}=document;this.div.contains(e)&&(this.#d=e);return}this.#d&&setTimeout(()=>{this.#d?.focus(),this.#d=null},0)}endDrawingSession(t=!1){return this.#c?(this.#o.setCurrentDrawingSession(null),this.#c.abort(),this.#c=null,this.#d=null,this.#g.endDrawing(t)):null}findNewParent(t,e,n){let r=this.#o.findParent(e,n);return r===null||r===this?!1:(r.changeParent(t),!0)}commitOrRemove(){return this.#c?(this.endDrawingSession(),!0):!1}onScaleChanging(){this.#c&&this.#g.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#o.getActive()?.parent===this&&(this.#o.commitOrRemove(),this.#o.setActiveEditor(null)),this.#i&&(clearTimeout(this.#i),this.#i=null);for(let t of this.#r.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#r.clear(),this.#o.removeLayer(this)}#b(){for(let t of this.#r.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,Ln(this.div,t);for(let e of this.#o.getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){this.#o.commitOrRemove(),this.#b();let e=this.viewport.rotation,n=t.rotation;if(this.viewport=t,Ln(this.div,{rotation:n}),e!==n)for(let r of this.#r.values())r.rotate(n)}get pageDimensions(){let{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#o.viewParameters.realScale}},Ba=class i{#t=null;#e=0;#n=new Map;#s=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(!this.#t){this.#t=t;return}if(this.#t!==t){if(this.#n.size>0)for(let e of this.#n.values())e.remove(),t.append(e);this.#t=t}}static get _svgFactory(){return Ot(this,"_svgFactory",new Ls)}static#i(t,[e,n,r,a]){let{style:l}=t;l.top=`${100*n}%`,l.left=`${100*e}%`,l.width=`${100*r}%`,l.height=`${100*a}%`}#r(){let t=i._svgFactory.create(1,1,!0);return this.#t.append(t),t.setAttribute("aria-hidden",!0),t}#l(t,e){let n=i._svgFactory.createElement("clipPath");t.append(n);let r=`clip_${e}`;n.setAttribute("id",r),n.setAttribute("clipPathUnits","objectBoundingBox");let a=i._svgFactory.createElement("use");return n.append(a),a.setAttribute("href",`#${e}`),a.classList.add("clip"),r}#a(t,e){for(let[n,r]of Object.entries(e))r===null?t.removeAttribute(n):t.setAttribute(n,r)}draw(t,e=!1,n=!1){let r=this.#e++,a=this.#r(),l=i._svgFactory.createElement("defs");a.append(l);let u=i._svgFactory.createElement("path");l.append(u);let f=`path_p${this.pageIndex}_${r}`;u.setAttribute("id",f),u.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#s.set(r,u);let g=n?this.#l(l,f):null,m=i._svgFactory.createElement("use");return a.append(m),m.setAttribute("href",`#${f}`),this.updateProperties(a,t),this.#n.set(r,a),{id:r,clipPathId:`url(#${g})`}}drawOutline(t,e){let n=this.#e++,r=this.#r(),a=i._svgFactory.createElement("defs");r.append(a);let l=i._svgFactory.createElement("path");a.append(l);let u=`path_p${this.pageIndex}_${n}`;l.setAttribute("id",u),l.setAttribute("vector-effect","non-scaling-stroke");let f;if(e){let y=i._svgFactory.createElement("mask");a.append(y),f=`mask_p${this.pageIndex}_${n}`,y.setAttribute("id",f),y.setAttribute("maskUnits","objectBoundingBox");let v=i._svgFactory.createElement("rect");y.append(v),v.setAttribute("width","1"),v.setAttribute("height","1"),v.setAttribute("fill","white");let S=i._svgFactory.createElement("use");y.append(S),S.setAttribute("href",`#${u}`),S.setAttribute("stroke","none"),S.setAttribute("fill","black"),S.setAttribute("fill-rule","nonzero"),S.classList.add("mask")}let g=i._svgFactory.createElement("use");r.append(g),g.setAttribute("href",`#${u}`),f&&g.setAttribute("mask",`url(#${f})`);let m=g.cloneNode();return r.append(m),g.classList.add("mainOutline"),m.classList.add("secondaryOutline"),this.updateProperties(r,t),this.#n.set(n,r),n}finalizeDraw(t,e){this.#s.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;let{root:n,bbox:r,rootClass:a,path:l}=e,u=typeof t=="number"?this.#n.get(t):t;if(u){if(n&&this.#a(u,n),r&&i.#i(u,r),a){let{classList:f}=u;for(let[g,m]of Object.entries(a))f.toggle(g,m)}if(l){let g=u.firstChild.firstChild;this.#a(g,l)}}}updateParent(t,e){if(e===this)return;let n=this.#n.get(t);n&&(e.#t.append(n),this.#n.delete(t),e.#n.set(t,n))}remove(t){this.#s.delete(t),this.#t!==null&&(this.#n.get(t).remove(),this.#n.delete(t))}destroy(){this.#t=null;for(let t of this.#n.values())t.remove();this.#n.clear(),this.#s.clear()}};globalThis.pdfjsTestingUtils={HighlightOutliner:_s};p0=Et.AbortException,g0=Et.AnnotationEditorLayer,m0=Et.AnnotationEditorParamsType,y0=Et.AnnotationEditorType,b0=Et.AnnotationEditorUIManager,v0=Et.AnnotationLayer,Wa=Et.AnnotationMode,x0=Et.ColorPicker,S0=Et.DOMSVGFactory,A0=Et.DrawLayer,T0=Et.FeatureTest,C0=Et.GlobalWorkerOptions,E0=Et.ImageKind,w0=Et.InvalidPDFException,k0=Et.MissingPDFException,I0=Et.OPS,R0=Et.OutputScale,P0=Et.PDFDataRangeTransport,O0=Et.PDFDateString,M0=Et.PDFWorker,L0=Et.PasswordResponses,F0=Et.PermissionFlag,D0=Et.PixelsPerInch,_0=Et.RenderingCancelledException,N0=Et.TextLayer,U0=Et.TouchManager,B0=Et.UnexpectedResponseException,G0=Et.Util,H0=Et.VerbosityLevel,j0=Et.XfaLayer,V0=Et.build,W0=Et.createValidAbsoluteUrl,$0=Et.fetchData,z0=Et.getDocument,X0=Et.getFilenameFromUrl,Y0=Et.getPdfFilenameFromUrl,K0=Et.getXfaPageViewport,Z0=Et.isDataScheme,Q0=Et.isPdfFile,J0=Et.noContextMenu,q0=Et.normalizeUnicode,tv=Et.setLayerDimensions,ev=Et.shadow,nv=Et.stopEvent,sv=Et.version});var Za=cb(($u,gi)=>{var Wu=(()=>{var i=Object.defineProperty,t=Object.getOwnPropertyDescriptor,e=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,r=(s,o)=>{for(var c in o)i(s,c,{get:o[c],enumerable:!0})},a=(s,o,c,h)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of e(o))!n.call(s,d)&&d!==c&&i(s,d,{get:()=>o[d],enumerable:!(h=t(o,d))||h.enumerable});return s},l=s=>a(i({},"__esModule",{value:!0}),s),u={};r(u,{BoundingBox:()=>yt,Font:()=>Jc,Glyph:()=>zn,Path:()=>ot,_parse:()=>rt,load:()=>tb,loadSync:()=>eb,parse:()=>qy});var f=0,g=-3;function m(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function y(s,o){this.source=s,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=o,this.destLen=0,this.ltree=new m,this.dtree=new m}var v=new m,S=new m,T=new Uint8Array(30),C=new Uint16Array(30),k=new Uint8Array(30),I=new Uint16Array(30),O=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),D=new m,_=new Uint8Array(320);function M(s,o,c,h){var d,p;for(d=0;d<c;++d)s[d]=0;for(d=0;d<30-c;++d)s[d+c]=d/c|0;for(p=h,d=0;d<30;++d)o[d]=p,p+=1<<s[d]}function B(s,o){var c;for(c=0;c<7;++c)s.table[c]=0;for(s.table[7]=24,s.table[8]=152,s.table[9]=112,c=0;c<24;++c)s.trans[c]=256+c;for(c=0;c<144;++c)s.trans[24+c]=c;for(c=0;c<8;++c)s.trans[168+c]=280+c;for(c=0;c<112;++c)s.trans[176+c]=144+c;for(c=0;c<5;++c)o.table[c]=0;for(o.table[5]=32,c=0;c<32;++c)o.trans[c]=c}var H=new Uint16Array(16);function z(s,o,c,h){var d,p;for(d=0;d<16;++d)s.table[d]=0;for(d=0;d<h;++d)s.table[o[c+d]]++;for(s.table[0]=0,p=0,d=0;d<16;++d)H[d]=p,p+=s.table[d];for(d=0;d<h;++d)o[c+d]&&(s.trans[H[o[c+d]]++]=d)}function W(s){s.bitcount--||(s.tag=s.source[s.sourceIndex++],s.bitcount=7);var o=s.tag&1;return s.tag>>>=1,o}function Q(s,o,c){if(!o)return c;for(;s.bitcount<24;)s.tag|=s.source[s.sourceIndex++]<<s.bitcount,s.bitcount+=8;var h=s.tag&65535>>>16-o;return s.tag>>>=o,s.bitcount-=o,h+c}function q(s,o){for(;s.bitcount<24;)s.tag|=s.source[s.sourceIndex++]<<s.bitcount,s.bitcount+=8;var c=0,h=0,d=0,p=s.tag;do h=2*h+(p&1),p>>>=1,++d,c+=o.table[d],h-=o.table[d];while(h>=0);return s.tag=p,s.bitcount-=d,o.trans[c+h]}function bt(s,o,c){var h,d,p,b,x,A;for(h=Q(s,5,257),d=Q(s,5,1),p=Q(s,4,4),b=0;b<19;++b)_[b]=0;for(b=0;b<p;++b){var w=Q(s,3,0);_[O[b]]=w}for(z(D,_,0,19),x=0;x<h+d;){var E=q(s,D);switch(E){case 16:var P=_[x-1];for(A=Q(s,2,3);A;--A)_[x++]=P;break;case 17:for(A=Q(s,3,3);A;--A)_[x++]=0;break;case 18:for(A=Q(s,7,11);A;--A)_[x++]=0;break;default:_[x++]=E;break}}z(o,_,0,h),z(c,_,h,d)}function et(s,o,c){for(;;){var h=q(s,o);if(h===256)return f;if(h<256)s.dest[s.destLen++]=h;else{var d,p,b,x;for(h-=257,d=Q(s,T[h],C[h]),p=q(s,c),b=s.destLen-Q(s,k[p],I[p]),x=b;x<b+d;++x)s.dest[s.destLen++]=s.dest[x]}}}function Tt(s){for(var o,c,h;s.bitcount>8;)s.sourceIndex--,s.bitcount-=8;if(o=s.source[s.sourceIndex+1],o=256*o+s.source[s.sourceIndex],c=s.source[s.sourceIndex+3],c=256*c+s.source[s.sourceIndex+2],o!==(~c&65535))return g;for(s.sourceIndex+=4,h=o;h;--h)s.dest[s.destLen++]=s.source[s.sourceIndex++];return s.bitcount=0,f}function dt(s,o){var c=new y(s,o),h,d,p;do{switch(h=W(c),d=Q(c,2,0),d){case 0:p=Tt(c);break;case 1:p=et(c,v,S);break;case 2:bt(c,c.ltree,c.dtree),p=et(c,c.ltree,c.dtree);break;default:p=g}if(p!==f)throw new Error("Data error")}while(!h);return c.destLen<c.dest.length?typeof c.dest.slice=="function"?c.dest.slice(0,c.destLen):c.dest.subarray(0,c.destLen):c.dest}B(v,S),M(T,C,4,3),M(k,I,2,1),T[28]=0,C[28]=258;function Y(s,o,c,h,d){return Math.pow(1-d,3)*s+3*Math.pow(1-d,2)*d*o+3*(1-d)*Math.pow(d,2)*c+Math.pow(d,3)*h}function Z(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}Z.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},Z.prototype.addPoint=function(s,o){typeof s=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=s,this.x2=s),s<this.x1&&(this.x1=s),s>this.x2&&(this.x2=s)),typeof o=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=o,this.y2=o),o<this.y1&&(this.y1=o),o>this.y2&&(this.y2=o))},Z.prototype.addX=function(s){this.addPoint(s,null)},Z.prototype.addY=function(s){this.addPoint(null,s)},Z.prototype.addBezier=function(s,o,c,h,d,p,b,x){let A=[s,o],w=[c,h],E=[d,p],P=[b,x];this.addPoint(s,o),this.addPoint(b,x);for(let R=0;R<=1;R++){let F=6*A[R]-12*w[R]+6*E[R],L=-3*A[R]+9*w[R]-9*E[R]+3*P[R],N=3*w[R]-3*A[R];if(L===0){if(F===0)continue;let At=-N/F;0<At&&At<1&&(R===0&&this.addX(Y(A[R],w[R],E[R],P[R],At)),R===1&&this.addY(Y(A[R],w[R],E[R],P[R],At)));continue}let $=Math.pow(F,2)-4*N*L;if($<0)continue;let vt=(-F+Math.sqrt($))/(2*L);0<vt&&vt<1&&(R===0&&this.addX(Y(A[R],w[R],E[R],P[R],vt)),R===1&&this.addY(Y(A[R],w[R],E[R],P[R],vt)));let pt=(-F-Math.sqrt($))/(2*L);0<pt&&pt<1&&(R===0&&this.addX(Y(A[R],w[R],E[R],P[R],pt)),R===1&&this.addY(Y(A[R],w[R],E[R],P[R],pt)))}},Z.prototype.addQuad=function(s,o,c,h,d,p){let b=s+.6666666666666666*(c-s),x=o+2/3*(h-o),A=b+1/3*(d-s),w=x+1/3*(p-o);this.addBezier(s,o,b,x,A,w,d,p)};var yt=Z;function it(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}var kt={};function X(s,o){let c=Math.floor(s),h=s-c;if(kt[o]||(kt[o]={}),kt[o][h]!==void 0){let p=kt[o][h];return c+p}let d=+(Math.round(h+"e+"+o)+"e-"+o);return kt[o][h]=d,c+d}function at(s){let o=[[]],c=0,h=0;for(let d=0;d<s.length;d+=1){let p=o[o.length-1],b=s[d],x=p[0],A=p[1],w=p[p.length-1],E=s[d+1];p.push(b),b.type==="M"?(c=b.x,h=b.y):b.type==="L"&&(!E||E.type==="Z")?Math.abs(b.x-c)>1||Math.abs(b.y-h)>1||p.pop():b.type==="L"&&w&&w.x===b.x&&w.y===b.y?p.pop():b.type==="Z"&&(x&&A&&w&&x.type==="M"&&A.type==="L"&&w.type==="L"&&w.x===x.x&&w.y===x.y&&(p.shift(),p[0].type="M"),d+1<s.length&&o.push([]))}return s=[].concat.apply([],o),s}function K(s){return Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0,scale:1,x:0,y:0},s)}function nt(s){return parseInt(s)===s&&(s={decimalPlaces:s,flipY:!1}),Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0},s)}it.prototype.fromSVG=function(s,o={}){typeof SVGPathElement<"u"&&s instanceof SVGPathElement&&(s=s.getAttribute("d")),o=K(o),this.commands=[];let c="0123456789",h="MmLlQqCcZzHhVv",d="SsTtAa",p="-+",b={},x=[""],A=!1;function w(L){return L.filter(N=>N.length).map(N=>{let $=parseFloat(N);return(o.decimalPlaces||o.decimalPlaces===0)&&($=X($,o.decimalPlaces)),$})}function E(L){if(!this.commands.length)return L;let N=this.commands[this.commands.length-1];for(let $=0;$<L.length;$++)L[$]+=N[$&1?"y":"x"];return L}function P(){if(b.type===void 0)return;let L=b.type.toUpperCase(),N=L!=="Z"&&b.type.toUpperCase()!==b.type,$=w(x);if(x=[""],!$.length&&L!=="Z")return;N&&L!=="H"&&L!=="V"&&($=E.apply(this,[$]));let vt=this.commands.length&&this.commands[this.commands.length-1].x||0,pt=this.commands.length&&this.commands[this.commands.length-1].y||0;switch(L){case"M":this.moveTo(...$);break;case"L":this.lineTo(...$);break;case"V":for(let At=0;At<$.length;At++){let It=0;N&&(It=this.commands.length&&this.commands[this.commands.length-1].y||0),this.lineTo(vt,$[At]+It)}break;case"H":for(let At=0;At<$.length;At++){let It=0;N&&(It=this.commands.length&&this.commands[this.commands.length-1].x||0),this.lineTo($[At]+It,pt)}break;case"C":this.bezierCurveTo(...$);break;case"Q":this.quadraticCurveTo(...$);break;case"Z":(this.commands.length<1||this.commands[this.commands.length-1].type!=="Z")&&this.close();break}if(this.commands.length)for(let At in this.commands[this.commands.length-1])this.commands[this.commands.length-1][At]===void 0&&(this.commands[this.commands.length-1][At]=0)}for(let L=0;L<s.length;L++){let N=s.charAt(L),$=x[x.length-1];if(c.indexOf(N)>-1)x[x.length-1]+=N;else if(p.indexOf(N)>-1)if(!b.type&&!this.commands.length&&(b.type="L"),N==="-")!b.type||$.indexOf("-")>0?A=!0:$.length?x.push("-"):x[x.length-1]=N;else if(!b.type||$.length>0)A=!0;else continue;else if(h.indexOf(N)>-1)b.type?(P.apply(this),b={type:N}):b.type=N;else{if(d.indexOf(N)>-1)throw new Error("Unsupported path command: "+N+". Currently supported commands are "+h.split("").join(", ")+".");` ,
15
+ \r\f\v`.indexOf(N)>-1?x.push(""):N==="."?!b.type||$.indexOf(N)>-1?A=!0:x[x.length-1]+=N:A=!0}if(A)throw new Error("Unexpected character: "+N+" at offset "+L)}P.apply(this),o.optimize&&(this.commands=at(this.commands));let R=o.flipY,F=o.flipYBase;if(R===!0&&o.flipYBase===void 0){let L=this.getBoundingBox();F=L.y1+L.y2}for(let L in this.commands){let N=this.commands[L];for(let $ in N)["x","x1","x2"].includes($)?this.commands[L][$]=o.x+N[$]*o.scale:["y","y1","y2"].includes($)&&(this.commands[L][$]=o.y+(R?F-N[$]:N[$])*o.scale)}return this},it.fromSVG=function(s,o){return new it().fromSVG(s,o)},it.prototype.moveTo=function(s,o){this.commands.push({type:"M",x:s,y:o})},it.prototype.lineTo=function(s,o){this.commands.push({type:"L",x:s,y:o})},it.prototype.curveTo=it.prototype.bezierCurveTo=function(s,o,c,h,d,p){this.commands.push({type:"C",x1:s,y1:o,x2:c,y2:h,x:d,y:p})},it.prototype.quadTo=it.prototype.quadraticCurveTo=function(s,o,c,h){this.commands.push({type:"Q",x1:s,y1:o,x:c,y:h})},it.prototype.close=it.prototype.closePath=function(){this.commands.push({type:"Z"})},it.prototype.extend=function(s){if(s.commands)s=s.commands;else if(s instanceof yt){let o=s;this.moveTo(o.x1,o.y1),this.lineTo(o.x2,o.y1),this.lineTo(o.x2,o.y2),this.lineTo(o.x1,o.y2),this.close();return}Array.prototype.push.apply(this.commands,s)},it.prototype.getBoundingBox=function(){let s=new yt,o=0,c=0,h=0,d=0;for(let p=0;p<this.commands.length;p++){let b=this.commands[p];switch(b.type){case"M":s.addPoint(b.x,b.y),o=h=b.x,c=d=b.y;break;case"L":s.addPoint(b.x,b.y),h=b.x,d=b.y;break;case"Q":s.addQuad(h,d,b.x1,b.y1,b.x,b.y),h=b.x,d=b.y;break;case"C":s.addBezier(h,d,b.x1,b.y1,b.x2,b.y2,b.x,b.y),h=b.x,d=b.y;break;case"Z":h=o,d=c;break;default:throw new Error("Unexpected path command "+b.type)}}return s.isEmpty()&&s.addPoint(0,0),s},it.prototype.draw=function(s){let o=this._layers;if(o&&o.length){for(let h=0;h<o.length;h++)this.draw.call(o[h],s);return}let c=this._image;if(c){s.drawImage(c.image,c.x,c.y,c.width,c.height);return}s.beginPath();for(let h=0;h<this.commands.length;h+=1){let d=this.commands[h];d.type==="M"?s.moveTo(d.x,d.y):d.type==="L"?s.lineTo(d.x,d.y):d.type==="C"?s.bezierCurveTo(d.x1,d.y1,d.x2,d.y2,d.x,d.y):d.type==="Q"?s.quadraticCurveTo(d.x1,d.y1,d.x,d.y):d.type==="Z"&&this.stroke&&this.strokeWidth&&s.closePath()}this.fill&&(s.fillStyle=this.fill,s.fill()),this.stroke&&(s.strokeStyle=this.stroke,s.lineWidth=this.strokeWidth,s.stroke())},it.prototype.toPathData=function(s){s=nt(s);function o(x){let A=X(x,s.decimalPlaces);return Math.round(x)===A?""+A:A.toFixed(s.decimalPlaces)}function c(){let x="";for(let A=0;A<arguments.length;A+=1){let w=arguments[A];w>=0&&A>0&&(x+=" "),x+=o(w)}return x}let h=this.commands;s.optimize&&(h=JSON.parse(JSON.stringify(this.commands)),h=at(h));let d=s.flipY,p=s.flipYBase;if(d===!0&&p===void 0){let x=new it;x.extend(h);let A=x.getBoundingBox();p=A.y1+A.y2}let b="";for(let x=0;x<h.length;x+=1){let A=h[x];A.type==="M"?b+="M"+c(A.x,d?p-A.y:A.y):A.type==="L"?b+="L"+c(A.x,d?p-A.y:A.y):A.type==="C"?b+="C"+c(A.x1,d?p-A.y1:A.y1,A.x2,d?p-A.y2:A.y2,A.x,d?p-A.y:A.y):A.type==="Q"?b+="Q"+c(A.x1,d?p-A.y1:A.y1,A.x,d?p-A.y:A.y):A.type==="Z"&&(b+="Z")}return b},it.prototype.toSVG=function(s,o){this._layers&&this._layers.length&&console.warn("toSVG() does not support colr font layers yet"),this._image&&console.warn("toSVG() does not support SVG glyphs yet"),o||(o=this.toPathData(s));let c='<path d="';return c+=o,c+='"',this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?c+=' fill="none"':c+=' fill="'+this.fill+'"'),this.stroke&&(c+=' stroke="'+this.stroke+'" stroke-width="'+this.strokeWidth+'"'),c+="/>",c},it.prototype.toDOMElement=function(s,o){this._layers&&this._layers.length&&console.warn("toDOMElement() does not support colr font layers yet"),o||(o=this.toPathData(s));let c=document.createElementNS("http://www.w3.org/2000/svg","path");return c.setAttribute("d",o),this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?c.setAttribute("fill","none"):c.setAttribute("fill",this.fill)),this.stroke&&(c.setAttribute("stroke",this.stroke),c.setAttribute("stroke-width",this.strokeWidth)),c};var ot=it;function V(s){throw new Error(s)}function j(s,o){s||V(o)}var U={fail:V,argument:j,assert:j},lt=32768,Ct=2147483648,gt=-32768,Vt=32767+1/65536,Dt={},tt={},ut={};function Nt(s){return function(){return s}}tt.BYTE=function(s){return U.argument(s>=0&&s<=255,"Byte value should be between 0 and 255."),[s]},ut.BYTE=Nt(1),tt.CHAR=function(s){return[s.charCodeAt(0)]},ut.CHAR=Nt(1),tt.CHARARRAY=function(s){(s===null||typeof s>"u")&&(s="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));let o=[];for(let c=0;c<s.length;c+=1)o[c]=s.charCodeAt(c);return o},ut.CHARARRAY=function(s){return typeof s>"u"?0:s.length},tt.USHORT=function(s){return[s>>8&255,s&255]},ut.USHORT=Nt(2),tt.SHORT=function(s){return s>=lt&&(s=-(2*lt-s)),[s>>8&255,s&255]},ut.SHORT=Nt(2),tt.UINT24=function(s){return[s>>16&255,s>>8&255,s&255]},ut.UINT24=Nt(3),tt.ULONG=function(s){return[s>>24&255,s>>16&255,s>>8&255,s&255]},ut.ULONG=Nt(4),tt.LONG=function(s){return s>=Ct&&(s=-(2*Ct-s)),[s>>24&255,s>>16&255,s>>8&255,s&255]},ut.LONG=Nt(4),tt.FLOAT=function(s){if(s>Vt||s<gt)throw new Error(`Value ${s} is outside the range of representable values in 16.16 format`);let o=Math.round(s*65536)<<0;return tt.ULONG(o)},ut.FLOAT=ut.ULONG,tt.FIXED=tt.ULONG,ut.FIXED=ut.ULONG,tt.FWORD=tt.SHORT,ut.FWORD=ut.SHORT,tt.UFWORD=tt.USHORT,ut.UFWORD=ut.USHORT,tt.F2DOT14=function(s){return tt.USHORT(s*16384)},ut.F2DOT14=ut.USHORT,tt.LONGDATETIME=function(s){return[0,0,0,0,s>>24&255,s>>16&255,s>>8&255,s&255]},ut.LONGDATETIME=Nt(8),tt.TAG=function(s){return U.argument(s.length===4,"Tag should be exactly 4 ASCII characters."),[s.charCodeAt(0),s.charCodeAt(1),s.charCodeAt(2),s.charCodeAt(3)]},ut.TAG=Nt(4),tt.Card8=tt.BYTE,ut.Card8=ut.BYTE,tt.Card16=tt.USHORT,ut.Card16=ut.USHORT,tt.OffSize=tt.BYTE,ut.OffSize=ut.BYTE,tt.SID=tt.USHORT,ut.SID=ut.USHORT,tt.NUMBER=function(s){return s>=-107&&s<=107?[s+139]:s>=108&&s<=1131?(s=s-108,[(s>>8)+247,s&255]):s>=-1131&&s<=-108?(s=-s-108,[(s>>8)+251,s&255]):s>=-32768&&s<=32767?tt.NUMBER16(s):tt.NUMBER32(s)},ut.NUMBER=function(s){return tt.NUMBER(s).length},tt.NUMBER16=function(s){return[28,s>>8&255,s&255]},ut.NUMBER16=Nt(3),tt.NUMBER32=function(s){return[29,s>>24&255,s>>16&255,s>>8&255,s&255]},ut.NUMBER32=Nt(5),tt.REAL=function(s){let o=s.toString(),c=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(o);if(c){let p=parseFloat("1e"+((c[2]?+c[2]:0)+c[1].length));o=(Math.round(s*p)/p).toString()}let h="";for(let p=0,b=o.length;p<b;p+=1){let x=o[p];x==="e"?h+=o[++p]==="-"?"c":"b":x==="."?h+="a":x==="-"?h+="e":h+=x}h+=h.length&1?"f":"ff";let d=[30];for(let p=0,b=h.length;p<b;p+=2)d.push(parseInt(h.substr(p,2),16));return d},ut.REAL=function(s){return tt.REAL(s).length},tt.NAME=tt.CHARARRAY,ut.NAME=ut.CHARARRAY,tt.STRING=tt.CHARARRAY,ut.STRING=ut.CHARARRAY,Dt.UTF8=function(s,o,c){let h=[],d=c;for(let p=0;p<d;p++,o+=1)h[p]=s.getUint8(o);return String.fromCharCode.apply(null,h)},Dt.UTF16=function(s,o,c){let h=[],d=c/2;for(let p=0;p<d;p++,o+=2)h[p]=s.getUint16(o);return String.fromCharCode.apply(null,h)},tt.UTF16=function(s){let o=[];for(let c=0;c<s.length;c+=1){let h=s.charCodeAt(c);o[o.length]=h>>8&255,o[o.length]=h&255}return o},ut.UTF16=function(s){return s.length*2};var Le={"x-mac-croatian":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\u0160\u2122\xB4\xA8\u2260\u017D\xD8\u221E\xB1\u2264\u2265\u2206\xB5\u2202\u2211\u220F\u0161\u222B\xAA\xBA\u03A9\u017E\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u0106\xAB\u010C\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u0110\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\uF8FF\xA9\u2044\u20AC\u2039\u203A\xC6\xBB\u2013\xB7\u201A\u201E\u2030\xC2\u0107\xC1\u010D\xC8\xCD\xCE\xCF\xCC\xD3\xD4\u0111\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u03C0\xCB\u02DA\xB8\xCA\xE6\u02C7","x-mac-cyrillic":"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u2020\xB0\u0490\xA3\xA7\u2022\xB6\u0406\xAE\xA9\u2122\u0402\u0452\u2260\u0403\u0453\u221E\xB1\u2264\u2265\u0456\xB5\u0491\u0408\u0404\u0454\u0407\u0457\u0409\u0459\u040A\u045A\u0458\u0405\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\u040B\u045B\u040C\u045C\u0455\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u201E\u040E\u045E\u040F\u045F\u2116\u0401\u0451\u044F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E","x-mac-gaelic":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u1E02\xB1\u2264\u2265\u1E03\u010A\u010B\u1E0A\u1E0B\u1E1E\u1E1F\u0120\u0121\u1E40\xE6\xF8\u1E41\u1E56\u1E57\u027C\u0192\u017F\u1E60\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\u1E61\u1E9B\xFF\u0178\u1E6A\u20AC\u2039\u203A\u0176\u0177\u1E6B\xB7\u1EF2\u1EF3\u204A\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\u2663\xD2\xDA\xDB\xD9\u0131\xDD\xFD\u0174\u0175\u1E84\u1E85\u1E80\u1E81\u1E82\u1E83","x-mac-greek":"\xC4\xB9\xB2\xC9\xB3\xD6\xDC\u0385\xE0\xE2\xE4\u0384\xA8\xE7\xE9\xE8\xEA\xEB\xA3\u2122\xEE\xEF\u2022\xBD\u2030\xF4\xF6\xA6\u20AC\xF9\xFB\xFC\u2020\u0393\u0394\u0398\u039B\u039E\u03A0\xDF\xAE\xA9\u03A3\u03AA\xA7\u2260\xB0\xB7\u0391\xB1\u2264\u2265\xA5\u0392\u0395\u0396\u0397\u0399\u039A\u039C\u03A6\u03AB\u03A8\u03A9\u03AC\u039D\xAC\u039F\u03A1\u2248\u03A4\xAB\xBB\u2026\xA0\u03A5\u03A7\u0386\u0388\u0153\u2013\u2015\u201C\u201D\u2018\u2019\xF7\u0389\u038A\u038C\u038E\u03AD\u03AE\u03AF\u03CC\u038F\u03CD\u03B1\u03B2\u03C8\u03B4\u03B5\u03C6\u03B3\u03B7\u03B9\u03BE\u03BA\u03BB\u03BC\u03BD\u03BF\u03C0\u03CE\u03C1\u03C3\u03C4\u03B8\u03C9\u03C2\u03C7\u03C5\u03B6\u03CA\u03CB\u0390\u03B0\xAD","x-mac-icelandic":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\xDD\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\xD0\xF0\xDE\xFE\xFD\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-inuit":"\u1403\u1404\u1405\u1406\u140A\u140B\u1431\u1432\u1433\u1434\u1438\u1439\u1449\u144E\u144F\u1450\u1451\u1455\u1456\u1466\u146D\u146E\u146F\u1470\u1472\u1473\u1483\u148B\u148C\u148D\u148E\u1490\u1491\xB0\u14A1\u14A5\u14A6\u2022\xB6\u14A7\xAE\xA9\u2122\u14A8\u14AA\u14AB\u14BB\u14C2\u14C3\u14C4\u14C5\u14C7\u14C8\u14D0\u14EF\u14F0\u14F1\u14F2\u14F4\u14F5\u1505\u14D5\u14D6\u14D7\u14D8\u14DA\u14DB\u14EA\u1528\u1529\u152A\u152B\u152D\u2026\xA0\u152E\u153E\u1555\u1556\u1557\u2013\u2014\u201C\u201D\u2018\u2019\u1558\u1559\u155A\u155D\u1546\u1547\u1548\u1549\u154B\u154C\u1550\u157F\u1580\u1581\u1582\u1583\u1584\u1585\u158F\u1590\u1591\u1592\u1593\u1594\u1595\u1671\u1672\u1673\u1674\u1675\u1676\u1596\u15A0\u15A1\u15A2\u15A3\u15A4\u15A5\u15A6\u157C\u0141\u0142","x-mac-ce":"\xC4\u0100\u0101\xC9\u0104\xD6\xDC\xE1\u0105\u010C\xE4\u010D\u0106\u0107\xE9\u0179\u017A\u010E\xED\u010F\u0112\u0113\u0116\xF3\u0117\xF4\xF6\xF5\xFA\u011A\u011B\xFC\u2020\xB0\u0118\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\u0119\xA8\u2260\u0123\u012E\u012F\u012A\u2264\u2265\u012B\u0136\u2202\u2211\u0142\u013B\u013C\u013D\u013E\u0139\u013A\u0145\u0146\u0143\xAC\u221A\u0144\u0147\u2206\xAB\xBB\u2026\xA0\u0148\u0150\xD5\u0151\u014C\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\u014D\u0154\u0155\u0158\u2039\u203A\u0159\u0156\u0157\u0160\u201A\u201E\u0161\u015A\u015B\xC1\u0164\u0165\xCD\u017D\u017E\u016A\xD3\xD4\u016B\u016E\xDA\u016F\u0170\u0171\u0172\u0173\xDD\xFD\u0137\u017B\u0141\u017C\u0122\u02C7",macintosh:"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\u2039\u203A\uFB01\uFB02\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-romanian":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\u0102\u0218\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\u0103\u0219\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\u2039\u203A\u021A\u021B\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-turkish":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u011E\u011F\u0130\u0131\u015E\u015F\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\uF8A0\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7"};Dt.MACSTRING=function(s,o,c,h){let d=Le[h];if(d===void 0)return;let p="";for(let b=0;b<c;b++){let x=s.getUint8(o+b);x<=127?p+=String.fromCharCode(x):p+=d[x&127]}return p};var rn=typeof WeakMap=="function"&&new WeakMap,Je,md=function(s){if(!Je){Je={};for(let d in Le)Je[d]=new String(d)}let o=Je[s];if(o===void 0)return;if(rn){let d=rn.get(o);if(d!==void 0)return d}let c=Le[s];if(c===void 0)return;let h={};for(let d=0;d<c.length;d++)h[c.charCodeAt(d)]=d+128;return rn&&rn.set(o,h),h};tt.MACSTRING=function(s,o){let c=md(o);if(c===void 0)return;let h=[];for(let d=0;d<s.length;d++){let p=s.charCodeAt(d);if(p>=128&&(p=c[p],p===void 0))return;h[d]=p}return h},ut.MACSTRING=function(s,o){let c=tt.MACSTRING(s,o);return c!==void 0?c.length:0};function Oi(s){return s>=-128&&s<=127}function yd(s,o,c){let h=0,d=s.length;for(;o<d&&h<64&&s[o]===0;)++o,++h;return c.push(128|h-1),o}function bd(s,o,c){let h=0,d=s.length,p=o;for(;p<d&&h<64;){let b=s[p];if(!Oi(b)||b===0&&p+1<d&&s[p+1]===0)break;++p,++h}c.push(h-1);for(let b=o;b<p;++b)c.push(s[b]+256&255);return p}function vd(s,o,c){let h=0,d=s.length,p=o;for(;p<d&&h<64;){let b=s[p];if(b===0||Oi(b)&&p+1<d&&Oi(s[p+1]))break;++p,++h}c.push(64|h-1);for(let b=o;b<p;++b){let x=s[b];c.push(x+65536>>8&255,x+256&255)}return p}tt.VARDELTAS=function(s){let o=0,c=[];for(;o<s.length;){let h=s[o];h===0?o=yd(s,o,c):h>=-128&&h<=127?o=bd(s,o,c):o=vd(s,o,c)}return c},tt.INDEX=function(s){let o=1,c=[o],h=[];for(let x=0;x<s.length;x+=1){let A=tt.OBJECT(s[x]);Array.prototype.push.apply(h,A),o+=A.length,c.push(o)}if(h.length===0)return[0,0];let d=[],p=1+Math.floor(Math.log(o)/Math.log(2))/8|0,b=[void 0,tt.BYTE,tt.USHORT,tt.UINT24,tt.ULONG][p];for(let x=0;x<c.length;x+=1){let A=b(c[x]);Array.prototype.push.apply(d,A)}return Array.prototype.concat(tt.Card16(s.length),tt.OffSize(p),d,h)},ut.INDEX=function(s){return tt.INDEX(s).length},tt.DICT=function(s){let o=[],c=Object.keys(s),h=c.length;for(let d=0;d<h;d+=1){let p=parseInt(c[d],0),b=s[p],x=tt.OPERAND(b.value,b.type),A=tt.OPERATOR(p);for(let w=0;w<x.length;w++)o.push(x[w]);for(let w=0;w<A.length;w++)o.push(A[w])}return o},ut.DICT=function(s){return tt.DICT(s).length},tt.OPERATOR=function(s){return s<1200?[s]:[12,s-1200]},tt.OPERAND=function(s,o){let c=[];if(Array.isArray(o))for(let h=0;h<o.length;h+=1){U.argument(s.length===o.length,"Not enough arguments given for type"+o);let d=tt.OPERAND(s[h],o[h]);for(let p=0;p<d.length;p++)c.push(d[p])}else if(o==="SID"){let h=tt.NUMBER(s);for(let d=0;d<h.length;d++)c.push(h[d])}else if(o==="offset"){let h=tt.NUMBER32(s);for(let d=0;d<h.length;d++)c.push(h[d])}else if(o==="number"){let h=tt.NUMBER(s);for(let d=0;d<h.length;d++)c.push(h[d])}else if(o==="real"){let h=tt.REAL(s);for(let d=0;d<h.length;d++)c.push(h[d])}else throw new Error("Unknown operand type "+o);return c},tt.OP=tt.BYTE,ut.OP=ut.BYTE;var Xs=typeof WeakMap=="function"&&new WeakMap;tt.CHARSTRING=function(s){if(Xs){let h=Xs.get(s);if(h!==void 0)return h}let o=[],c=s.length;for(let h=0;h<c;h+=1){let d=s[h],p=tt[d.type](d.value);for(let b=0;b<p.length;b++)o.push(p[b])}return Xs&&Xs.set(s,o),o},ut.CHARSTRING=function(s){return tt.CHARSTRING(s).length},tt.OBJECT=function(s){let o=tt[s.type];return U.argument(o!==void 0,"No encoding function for type "+s.type),o(s.value)},ut.OBJECT=function(s){let o=ut[s.type];return U.argument(o!==void 0,"No sizeOf function for type "+s.type),o(s.value)},tt.TABLE=function(s){let o=[],c=(s.fields||[]).length,h=[],d=[];for(let p=0;p<c;p+=1){let b=s.fields[p],x=tt[b.type];U.argument(x!==void 0,"No encoding function for field type "+b.type+" ("+b.name+")");let A=s[b.name];A===void 0&&(A=b.value);let w=x(A);if(b.type==="TABLE")A.fields!==null&&(d.push(o.length),h.push(w)),o.push(0,0);else for(let E=0;E<w.length;E++)o.push(w[E])}for(let p=0;p<h.length;p+=1){let b=d[p],x=o.length;U.argument(x<65536,"Table "+s.tableName+" too big."),o[b]=x>>8,o[b+1]=x&255;for(let A=0;A<h[p].length;A++)o.push(h[p][A])}return o},ut.TABLE=function(s){let o=0,c=(s.fields||[]).length;for(let h=0;h<c;h+=1){let d=s.fields[h],p=ut[d.type];U.argument(p!==void 0,"No sizeOf function for field type "+d.type+" ("+d.name+")");let b=s[d.name];b===void 0&&(b=d.value),o+=p(b),d.type==="TABLE"&&(o+=2)}return o},tt.RECORD=tt.TABLE,ut.RECORD=ut.TABLE,tt.LITERAL=function(s){return s},ut.LITERAL=function(s){return s.length};function Kt(s,o,c){if(o&&o.length)for(let h=0;h<o.length;h+=1){let d=o[h];this[d.name]=d.value}if(this.tableName=s,this.fields=o,c){let h=Object.keys(c);for(let d=0;d<h.length;d+=1){let p=h[d],b=c[p];this[p]!==void 0&&(this[p]=b)}}}Kt.prototype.encode=function(){return tt.TABLE(this)},Kt.prototype.sizeOf=function(){return ut.TABLE(this)};function Vn(s,o,c){c===void 0&&(c=o.length);let h=new Array(o.length+1);h[0]={name:s+"Count",type:"USHORT",value:c};for(let d=0;d<o.length;d++)h[d+1]={name:s+d,type:"USHORT",value:o[d]};return h}function Mi(s,o,c){let h=o.length,d=new Array(h+1);d[0]={name:s+"Count",type:"USHORT",value:h};for(let p=0;p<h;p++)d[p+1]={name:s+p,type:"TABLE",value:c(o[p],p)};return d}function Wn(s,o,c){let h=o.length,d=[];d[0]={name:s+"Count",type:"USHORT",value:h};for(let p=0;p<h;p++)d=d.concat(c(o[p],p));return d}function Ys(s){s.format===1?Kt.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(Vn("glyph",s.glyphs))):s.format===2?Kt.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(Wn("rangeRecord",s.ranges,function(o,c){return[{name:"startGlyphID"+c,type:"USHORT",value:o.start},{name:"endGlyphID"+c,type:"USHORT",value:o.end},{name:"startCoverageIndex"+c,type:"USHORT",value:o.index}]}))):U.assert(!1,"Coverage format must be 1 or 2.")}Ys.prototype=Object.create(Kt.prototype),Ys.prototype.constructor=Ys;function Ks(s){Kt.call(this,"scriptListTable",Wn("scriptRecord",s,function(o,c){let h=o.script,d=h.defaultLangSys;return U.assert(!!d,"Unable to write GSUB: script "+o.tag+" has no default language system."),[{name:"scriptTag"+c,type:"TAG",value:o.tag},{name:"script"+c,type:"TABLE",value:new Kt("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new Kt("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:d.reqFeatureIndex}].concat(Vn("featureIndex",d.featureIndexes)))}].concat(Wn("langSys",h.langSysRecords,function(p,b){let x=p.langSys;return[{name:"langSysTag"+b,type:"TAG",value:p.tag},{name:"langSys"+b,type:"TABLE",value:new Kt("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:x.reqFeatureIndex}].concat(Vn("featureIndex",x.featureIndexes)))}]})))}]}))}Ks.prototype=Object.create(Kt.prototype),Ks.prototype.constructor=Ks;function Zs(s){Kt.call(this,"featureListTable",Wn("featureRecord",s,function(o,c){let h=o.feature;return[{name:"featureTag"+c,type:"TAG",value:o.tag},{name:"feature"+c,type:"TABLE",value:new Kt("featureTable",[{name:"featureParams",type:"USHORT",value:h.featureParams}].concat(Vn("lookupListIndex",h.lookupListIndexes)))}]}))}Zs.prototype=Object.create(Kt.prototype),Zs.prototype.constructor=Zs;function Qs(s,o){Kt.call(this,"lookupListTable",Mi("lookup",s,function(c){let h=o[c.lookupType];return U.assert(!!h,"Unable to write GSUB lookup type "+c.lookupType+" tables."),new Kt("lookupTable",[{name:"lookupType",type:"USHORT",value:c.lookupType},{name:"lookupFlag",type:"USHORT",value:c.lookupFlag}].concat(Mi("subtable",c.subtables,h)))}))}Qs.prototype=Object.create(Kt.prototype),Qs.prototype.constructor=Qs;function Js(s){s.format===1?Kt.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:1},{name:"startGlyphID",type:"USHORT",value:s.startGlyph}].concat(Vn("glyph",s.classes))):s.format===2?Kt.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:2}].concat(Wn("rangeRecord",s.ranges,function(o,c){return[{name:"startGlyphID"+c,type:"USHORT",value:o.start},{name:"endGlyphID"+c,type:"USHORT",value:o.end},{name:"class"+c,type:"USHORT",value:o.classId}]}))):U.assert(!1,"Class format must be 1 or 2.")}Js.prototype=Object.create(Kt.prototype),Js.prototype.constructor=Js;var J={Table:Kt,Record:Kt,Coverage:Ys,ClassDef:Js,ScriptList:Ks,FeatureList:Zs,LookupList:Qs,ushortList:Vn,tableList:Mi,recordList:Wn};function yl(s,o){return s.getUint8(o)}function qs(s,o){return s.getUint16(o,!1)}function xd(s,o){return s.getInt16(o,!1)}function bl(s,o){return(s.getUint16(o)<<8)+s.getUint8(o+2)}function Li(s,o){return s.getUint32(o,!1)}function Sd(s,o){return s.getInt32(o,!1)}function vl(s,o){let c=s.getInt16(o,!1),h=s.getUint16(o+2,!1);return c+h/65535}function Ad(s,o){let c="";for(let h=o;h<o+4;h+=1)c+=String.fromCharCode(s.getInt8(h));return c}function Td(s,o,c){let h=0;for(let d=0;d<c;d+=1)h<<=8,h+=s.getUint8(o+d);return h}function Cd(s,o,c){let h=[];for(let d=o;d<c;d+=1)h.push(s.getUint8(d));return h}function Ed(s){let o="";for(let c=0;c<s.length;c+=1)o+=String.fromCharCode(s[c]);return o}var wd={byte:1,uShort:2,f2dot14:2,short:2,uInt24:3,uLong:4,fixed:4,longDateTime:8,tag:4},re={LONG_WORDS:32768,WORD_DELTA_COUNT_MASK:32767,SHARED_POINT_NUMBERS:32768,COUNT_MASK:4095,EMBEDDED_PEAK_TUPLE:32768,INTERMEDIATE_REGION:16384,PRIVATE_POINT_NUMBERS:8192,TUPLE_INDEX_MASK:4095,POINTS_ARE_WORDS:128,POINT_RUN_COUNT_MASK:127,DELTAS_ARE_ZERO:128,DELTAS_ARE_WORDS:64,DELTA_RUN_COUNT_MASK:63,INNER_INDEX_BIT_COUNT_MASK:15,MAP_ENTRY_SIZE_MASK:48};function G(s,o){this.data=s,this.offset=o,this.relativeOffset=0}G.prototype.parseByte=function(){let s=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,s},G.prototype.parseChar=function(){let s=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,s},G.prototype.parseCard8=G.prototype.parseByte,G.prototype.parseUShort=function(){let s=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,s},G.prototype.parseCard16=G.prototype.parseUShort,G.prototype.parseSID=G.prototype.parseUShort,G.prototype.parseOffset16=G.prototype.parseUShort,G.prototype.parseShort=function(){let s=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,s},G.prototype.parseF2Dot14=function(){let s=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,s},G.prototype.parseUInt24=function(){let s=bl(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=3,s},G.prototype.parseULong=function(){let s=Li(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,s},G.prototype.parseLong=function(){let s=Sd(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,s},G.prototype.parseOffset32=G.prototype.parseULong,G.prototype.parseFixed=function(){let s=vl(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,s},G.prototype.parseString=function(s){let o=this.data,c=this.offset+this.relativeOffset,h="";this.relativeOffset+=s;for(let d=0;d<s;d++)h+=String.fromCharCode(o.getUint8(c+d));return h},G.prototype.parseTag=function(){return this.parseString(4)},G.prototype.parseLongDateTime=function(){let s=Li(this.data,this.offset+this.relativeOffset+4);return s-=2082844800,this.relativeOffset+=8,s},G.prototype.parseVersion=function(s){let o=qs(this.data,this.offset+this.relativeOffset),c=qs(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,s===void 0&&(s=4096),o+c/s/10},G.prototype.skip=function(s,o){o===void 0&&(o=1),this.relativeOffset+=wd[s]*o},G.prototype.parseULongList=function(s){s===void 0&&(s=this.parseULong());let o=new Array(s),c=this.data,h=this.offset+this.relativeOffset;for(let d=0;d<s;d++)o[d]=c.getUint32(h),h+=4;return this.relativeOffset+=s*4,o},G.prototype.parseOffset16List=G.prototype.parseUShortList=function(s){s===void 0&&(s=this.parseUShort());let o=new Array(s),c=this.data,h=this.offset+this.relativeOffset;for(let d=0;d<s;d++)o[d]=c.getUint16(h),h+=2;return this.relativeOffset+=s*2,o},G.prototype.parseShortList=function(s){let o=new Array(s),c=this.data,h=this.offset+this.relativeOffset;for(let d=0;d<s;d++)o[d]=c.getInt16(h),h+=2;return this.relativeOffset+=s*2,o},G.prototype.parseByteList=function(s){let o=new Array(s),c=this.data,h=this.offset+this.relativeOffset;for(let d=0;d<s;d++)o[d]=c.getUint8(h++);return this.relativeOffset+=s,o},G.prototype.parseList=function(s,o){o||(o=s,s=this.parseUShort());let c=new Array(s);for(let h=0;h<s;h++)c[h]=o.call(this);return c},G.prototype.parseList32=function(s,o){o||(o=s,s=this.parseULong());let c=new Array(s);for(let h=0;h<s;h++)c[h]=o.call(this);return c},G.prototype.parseRecordList=function(s,o){o||(o=s,s=this.parseUShort());let c=new Array(s),h=Object.keys(o);for(let d=0;d<s;d++){let p={};for(let b=0;b<h.length;b++){let x=h[b],A=o[x];p[x]=A.call(this)}c[d]=p}return c},G.prototype.parseRecordList32=function(s,o){o||(o=s,s=this.parseULong());let c=new Array(s),h=Object.keys(o);for(let d=0;d<s;d++){let p={};for(let b=0;b<h.length;b++){let x=h[b],A=o[x];p[x]=A.call(this)}c[d]=p}return c},G.prototype.parseTupleRecords=function(s,o){let c=[];for(let h=0;h<s;h++){let d=[];for(let p=0;p<o;p++)d.push(this.parseF2Dot14());c.push(d)}return c},G.prototype.parseStruct=function(s){if(typeof s=="function")return s.call(this);{let o=Object.keys(s),c={};for(let h=0;h<o.length;h++){let d=o[h],p=s[d];c[d]=p.call(this)}return c}},G.prototype.parseValueRecord=function(s){if(s===void 0&&(s=this.parseUShort()),s===0)return;let o={};return s&1&&(o.xPlacement=this.parseShort()),s&2&&(o.yPlacement=this.parseShort()),s&4&&(o.xAdvance=this.parseShort()),s&8&&(o.yAdvance=this.parseShort()),s&16&&(o.xPlaDevice=void 0,this.parseShort()),s&32&&(o.yPlaDevice=void 0,this.parseShort()),s&64&&(o.xAdvDevice=void 0,this.parseShort()),s&128&&(o.yAdvDevice=void 0,this.parseShort()),o},G.prototype.parseValueRecordList=function(){let s=this.parseUShort(),o=this.parseUShort(),c=new Array(o);for(let h=0;h<o;h++)c[h]=this.parseValueRecord(s);return c},G.prototype.parsePointer=function(s){let o=this.parseOffset16();if(o>0)return new G(this.data,this.offset+o).parseStruct(s)},G.prototype.parsePointer32=function(s){let o=this.parseOffset32();if(o>0)return new G(this.data,this.offset+o).parseStruct(s)},G.prototype.parseListOfLists=function(s){let o=this.parseOffset16List(),c=o.length,h=this.relativeOffset,d=new Array(c);for(let p=0;p<c;p++){let b=o[p];if(b===0){d[p]=void 0;continue}if(this.relativeOffset=b,s){let x=this.parseOffset16List(),A=new Array(x.length);for(let w=0;w<x.length;w++)this.relativeOffset=b+x[w],A[w]=s.call(this);d[p]=A}else d[p]=this.parseUShortList()}return this.relativeOffset=h,d},G.prototype.parseCoverage=function(){let s=this.offset+this.relativeOffset,o=this.parseUShort(),c=this.parseUShort();if(o===1)return{format:1,glyphs:this.parseUShortList(c)};if(o===2){let h=new Array(c);for(let d=0;d<c;d++)h[d]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:h}}throw new Error("0x"+s.toString(16)+": Coverage format must be 1 or 2.")},G.prototype.parseClassDef=function(){let s=this.offset+this.relativeOffset,o=this.parseUShort();return o===1?{format:1,startGlyph:this.parseUShort(),classes:this.parseUShortList()}:o===2?{format:2,ranges:this.parseRecordList({start:G.uShort,end:G.uShort,classId:G.uShort})}:(console.warn(`0x${s.toString(16)}: This font file uses an invalid ClassDef format of ${o}. It might be corrupted and should be reacquired if it doesn't display as intended.`),{format:o})},G.list=function(s,o){return function(){return this.parseList(s,o)}},G.list32=function(s,o){return function(){return this.parseList32(s,o)}},G.recordList=function(s,o){return function(){return this.parseRecordList(s,o)}},G.recordList32=function(s,o){return function(){return this.parseRecordList32(s,o)}},G.pointer=function(s){return function(){return this.parsePointer(s)}},G.pointer32=function(s){return function(){return this.parsePointer32(s)}},G.tag=G.prototype.parseTag,G.byte=G.prototype.parseByte,G.uShort=G.offset16=G.prototype.parseUShort,G.uShortList=G.prototype.parseUShortList,G.uInt24=G.prototype.parseUInt24,G.uLong=G.offset32=G.prototype.parseULong,G.uLongList=G.prototype.parseULongList,G.fixed=G.prototype.parseFixed,G.f2Dot14=G.prototype.parseF2Dot14,G.struct=G.prototype.parseStruct,G.coverage=G.prototype.parseCoverage,G.classDef=G.prototype.parseClassDef;var xl={reserved:G.uShort,reqFeatureIndex:G.uShort,featureIndexes:G.uShortList};G.prototype.parseScriptList=function(){return this.parsePointer(G.recordList({tag:G.tag,script:G.pointer({defaultLangSys:G.pointer(xl),langSysRecords:G.recordList({tag:G.tag,langSys:G.pointer(xl)})})}))||[]},G.prototype.parseFeatureList=function(){return this.parsePointer(G.recordList({tag:G.tag,feature:G.pointer({featureParams:G.offset16,lookupListIndexes:G.uShortList})}))||[]},G.prototype.parseLookupList=function(s){return this.parsePointer(G.list(G.pointer(function(){let o=this.parseUShort();U.argument(1<=o&&o<=9,"GPOS/GSUB lookup type "+o+" unknown.");let c=this.parseUShort(),h=c&16;return{lookupType:o,lookupFlag:c,subtables:this.parseList(G.pointer(s[o])),markFilteringSet:h?this.parseUShort():void 0}})))||[]},G.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){let s=this.parseUShort(),o=this.parseUShort();return U.argument(s===1&&o<1,"GPOS/GSUB feature variations table unknown."),this.parseRecordList32({conditionSetOffset:G.offset32,featureTableSubstitutionOffset:G.offset32})})||[]},G.prototype.parseVariationStore=function(){let s=this.relativeOffset,o=this.parseUShort(),c={itemVariationStore:this.parseItemVariationStore()};return this.relativeOffset=s+o+2,c},G.prototype.parseItemVariationStore=function(){let s=this.relativeOffset,o={format:this.parseUShort(),variationRegions:[],itemVariationSubtables:[]},c=this.parseOffset32(),h=this.parseUShort(),d=this.parseULongList(h);this.relativeOffset=s+c,o.variationRegions=this.parseVariationRegionList();for(let p=0;p<h;p++){let b=d[p];this.relativeOffset=s+b,o.itemVariationSubtables.push(this.parseItemVariationSubtable())}return o},G.prototype.parseVariationRegionList=function(){let s=this.parseUShort(),o=this.parseUShort();return this.parseRecordList(o,{regionAxes:G.recordList(s,{startCoord:G.f2Dot14,peakCoord:G.f2Dot14,endCoord:G.f2Dot14})})},G.prototype.parseItemVariationSubtable=function(){let s=this.parseUShort(),o=this.parseUShort(),c=this.parseUShortList(),h=c.length;return{regionIndexes:c,deltaSets:s&&h?this.parseDeltaSets(s,o,h):[]}},G.prototype.parseDeltaSetIndexMap=function(){let s=this.parseByte(),o=this.parseByte(),c=[],h=0;switch(s){case 0:h=this.parseUShort();break;case 1:h=this.parseULong();break;default:console.error(`unsupported DeltaSetIndexMap format ${s}`)}if(!h)return{format:s,entryFormat:o};let d=(o&re.INNER_INDEX_BIT_COUNT_MASK)+1,p=((o&re.MAP_ENTRY_SIZE_MASK)>>4)+1;for(let b=0;b<h;b++){let x;if(p===1)x=this.parseByte();else if(p===2)x=this.parseUShort();else if(p===3)x=this.parseUInt24();else if(p===4)x=this.parseULong();else throw new Error(`Invalid entry size of ${p}`);let A=x>>d,w=x&(1<<d)-1;c.push({outerIndex:A,innerIndex:w})}return{format:s,entryFormat:o,map:c}},G.prototype.parseDeltaSets=function(s,o,c){let h=Array.from({length:s},()=>[]),d=o&re.LONG_WORDS,p=o&re.WORD_DELTA_COUNT_MASK;if(p>c)throw Error("wordCount must be less than or equal to regionIndexCount");let b=(d?this.parseLong:this.parseShort).bind(this),x=(d?this.parseShort:this.parseChar).bind(this);for(let A=0;A<s;A++)for(let w=0;w<c;w++)w<p?h[A].push(b()):h[A].push(x());return h},G.prototype.parseTupleVariationStoreList=function(s,o,c){let h=this.parseUShort(),p=this.parseUShort()&1,b=this.parseOffset32(),x=(p?this.parseULong:this.parseUShort).bind(this),A={},w=x();p||(w*=2);let E;for(let P=0;P<h;P++){E=x(),p||(E*=2);let R=E-w;A[P]=R?this.parseTupleVariationStore(b+w,s,o,c,P):void 0,w=E}return A},G.prototype.parseTupleVariationStore=function(s,o,c,h,d){let p=this.relativeOffset;this.relativeOffset=s,c==="cvar"&&(this.relativeOffset+=4);let b=this.parseUShort(),x=!!(b&re.SHARED_POINT_NUMBERS),A=b&re.COUNT_MASK,w=this.parseOffset16(),E=[],P=[];for(let L=0;L<A;L++){let N=this.parseTupleVariationHeader(o,c);E.push(N)}this.relativeOffset!==s+w&&(console.warn(`Unexpected offset after parsing tuple variation headers! Expected ${s+w}, actually ${this.relativeOffset}`),this.relativeOffset=s+w),x&&(P=this.parsePackedPointNumbers());let R=this.relativeOffset;for(let L=0;L<A;L++){let N=E[L];N.privatePoints=[],this.relativeOffset=R,c==="cvar"&&!N.peakTuple&&console.warn("An embedded peak tuple is required in TupleVariationHeaders for the cvar table."),N.flags.privatePointNumbers&&(N.privatePoints=this.parsePackedPointNumbers()),delete N.flags;let $=this.offset,vt=this.relativeOffset,pt=At=>{let It,Ut,Gt=()=>{let Ht=0;if(c==="gvar"){if(Ht=N.privatePoints.length||P.length,!Ht){let Jt=h.get(d);Jt.path,Ht=Jt.points.length,Ht+=4}}else c==="cvar"&&(Ht=h.length);this.offset=$,this.relativeOffset=vt,It=this.parsePackedDeltas(Ht),c==="gvar"&&(Ut=this.parsePackedDeltas(Ht))};return{configurable:!0,get:function(){return It===void 0&&Gt(),At==="deltasY"?Ut:It},set:function(Ht){It===void 0&&Gt(),At==="deltasY"?Ut=Ht:It=Ht}}};Object.defineProperty(N,"deltas",pt.call(this,"deltas")),c==="gvar"&&Object.defineProperty(N,"deltasY",pt.call(this,"deltasY")),R+=N.variationDataSize,delete N.variationDataSize}this.relativeOffset=p;let F={headers:E};return F.sharedPoints=P,F},G.prototype.parseTupleVariationHeader=function(s,o){let c=this.parseUShort(),h=this.parseUShort(),d=!!(h&re.EMBEDDED_PEAK_TUPLE),p=!!(h&re.INTERMEDIATE_REGION),b=!!(h&re.PRIVATE_POINT_NUMBERS),x=d?void 0:h&re.TUPLE_INDEX_MASK,A=d?this.parseTupleRecords(1,s)[0]:void 0,w=p?this.parseTupleRecords(1,s)[0]:void 0,E=p?this.parseTupleRecords(1,s)[0]:void 0,P={variationDataSize:c,peakTuple:A,intermediateStartTuple:w,intermediateEndTuple:E,flags:{embeddedPeakTuple:d,intermediateRegion:p,privatePointNumbers:b}};return o==="gvar"&&(P.sharedTupleRecordsIndex=x),P},G.prototype.parsePackedPointNumbers=function(){let s=this.parseByte(),o=[],c=s;if(s>=128){let d=this.parseByte();c=(s&re.POINT_RUN_COUNT_MASK)<<8|d}let h=0;for(;o.length<c;){let d=this.parseByte(),p=!!(d&re.POINTS_ARE_WORDS),b=(d&re.POINT_RUN_COUNT_MASK)+1;for(let x=0;x<b&&o.length<c;x++){let A;p?A=this.parseUShort():A=this.parseByte(),h=h+A,o.push(h)}}return o},G.prototype.parsePackedDeltas=function(s){let o=[];for(;o.length<s;){let c=this.parseByte(),h=!!(c&re.DELTAS_ARE_ZERO),d=!!(c&re.DELTAS_ARE_WORDS),p=(c&re.DELTA_RUN_COUNT_MASK)+1;for(let b=0;b<p&&o.length<s;b++)h?o.push(0):d?o.push(this.parseShort()):o.push(this.parseChar())}return o};var rt={getByte:yl,getCard8:yl,getUShort:qs,getCard16:qs,getShort:xd,getUInt24:bl,getULong:Li,getFixed:vl,getTag:Ad,getOffset:Td,getBytes:Cd,bytesToString:Ed,Parser:G},tr=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],Sl={0:"en",1:"fr",2:"de",3:"it",4:"nl",5:"sv",6:"es",7:"da",8:"pt",9:"no",10:"he",11:"ja",12:"ar",13:"fi",14:"el",15:"is",16:"mt",17:"tr",18:"hr",19:"zh-Hant",20:"ur",21:"hi",22:"th",23:"ko",24:"lt",25:"pl",26:"hu",27:"es",28:"lv",29:"se",30:"fo",31:"fa",32:"ru",33:"zh",34:"nl-BE",35:"ga",36:"sq",37:"ro",38:"cz",39:"sk",40:"si",41:"yi",42:"sr",43:"mk",44:"bg",45:"uk",46:"be",47:"uz",48:"kk",49:"az-Cyrl",50:"az-Arab",51:"hy",52:"ka",53:"mo",54:"ky",55:"tg",56:"tk",57:"mn-CN",58:"mn",59:"ps",60:"ks",61:"ku",62:"sd",63:"bo",64:"ne",65:"sa",66:"mr",67:"bn",68:"as",69:"gu",70:"pa",71:"or",72:"ml",73:"kn",74:"ta",75:"te",76:"si",77:"my",78:"km",79:"lo",80:"vi",81:"id",82:"tl",83:"ms",84:"ms-Arab",85:"am",86:"ti",87:"om",88:"so",89:"sw",90:"rw",91:"rn",92:"ny",93:"mg",94:"eo",128:"cy",129:"eu",130:"ca",131:"la",132:"qu",133:"gn",134:"ay",135:"tt",136:"ug",137:"dz",138:"jv",139:"su",140:"gl",141:"af",142:"br",143:"iu",144:"gd",145:"gv",146:"ga",147:"to",148:"el-polyton",149:"kl",150:"az",151:"nn"},kd={0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:5,11:1,12:4,13:0,14:6,15:0,16:0,17:0,18:0,19:2,20:4,21:9,22:21,23:3,24:29,25:29,26:29,27:29,28:29,29:0,30:0,31:4,32:7,33:25,34:0,35:0,36:0,37:0,38:29,39:29,40:0,41:5,42:7,43:7,44:7,45:7,46:7,47:7,48:7,49:7,50:4,51:24,52:23,53:7,54:7,55:7,56:7,57:27,58:7,59:4,60:4,61:4,62:4,63:26,64:9,65:9,66:9,67:13,68:13,69:11,70:10,71:12,72:17,73:16,74:14,75:15,76:18,77:19,78:20,79:22,80:30,81:0,82:0,83:0,84:4,85:28,86:28,87:28,88:0,89:0,90:0,91:0,92:0,93:0,94:0,128:0,129:0,130:0,131:0,132:0,133:0,134:0,135:7,136:4,137:26,138:0,139:0,140:0,141:0,142:0,143:28,144:0,145:0,146:0,147:0,148:6,149:0,150:0,151:0},Al={1078:"af",1052:"sq",1156:"gsw",1118:"am",5121:"ar-DZ",15361:"ar-BH",3073:"ar",2049:"ar-IQ",11265:"ar-JO",13313:"ar-KW",12289:"ar-LB",4097:"ar-LY",6145:"ary",8193:"ar-OM",16385:"ar-QA",1025:"ar-SA",10241:"ar-SY",7169:"aeb",14337:"ar-AE",9217:"ar-YE",1067:"hy",1101:"as",2092:"az-Cyrl",1068:"az",1133:"ba",1069:"eu",1059:"be",2117:"bn",1093:"bn-IN",8218:"bs-Cyrl",5146:"bs",1150:"br",1026:"bg",1027:"ca",3076:"zh-HK",5124:"zh-MO",2052:"zh",4100:"zh-SG",1028:"zh-TW",1155:"co",1050:"hr",4122:"hr-BA",1029:"cs",1030:"da",1164:"prs",1125:"dv",2067:"nl-BE",1043:"nl",3081:"en-AU",10249:"en-BZ",4105:"en-CA",9225:"en-029",16393:"en-IN",6153:"en-IE",8201:"en-JM",17417:"en-MY",5129:"en-NZ",13321:"en-PH",18441:"en-SG",7177:"en-ZA",11273:"en-TT",2057:"en-GB",1033:"en",12297:"en-ZW",1061:"et",1080:"fo",1124:"fil",1035:"fi",2060:"fr-BE",3084:"fr-CA",1036:"fr",5132:"fr-LU",6156:"fr-MC",4108:"fr-CH",1122:"fy",1110:"gl",1079:"ka",3079:"de-AT",1031:"de",5127:"de-LI",4103:"de-LU",2055:"de-CH",1032:"el",1135:"kl",1095:"gu",1128:"ha",1037:"he",1081:"hi",1038:"hu",1039:"is",1136:"ig",1057:"id",1117:"iu",2141:"iu-Latn",2108:"ga",1076:"xh",1077:"zu",1040:"it",2064:"it-CH",1041:"ja",1099:"kn",1087:"kk",1107:"km",1158:"quc",1159:"rw",1089:"sw",1111:"kok",1042:"ko",1088:"ky",1108:"lo",1062:"lv",1063:"lt",2094:"dsb",1134:"lb",1071:"mk",2110:"ms-BN",1086:"ms",1100:"ml",1082:"mt",1153:"mi",1146:"arn",1102:"mr",1148:"moh",1104:"mn",2128:"mn-CN",1121:"ne",1044:"nb",2068:"nn",1154:"oc",1096:"or",1123:"ps",1045:"pl",1046:"pt",2070:"pt-PT",1094:"pa",1131:"qu-BO",2155:"qu-EC",3179:"qu",1048:"ro",1047:"rm",1049:"ru",9275:"smn",4155:"smj-NO",5179:"smj",3131:"se-FI",1083:"se",2107:"se-SE",8251:"sms",6203:"sma-NO",7227:"sms",1103:"sa",7194:"sr-Cyrl-BA",3098:"sr",6170:"sr-Latn-BA",2074:"sr-Latn",1132:"nso",1074:"tn",1115:"si",1051:"sk",1060:"sl",11274:"es-AR",16394:"es-BO",13322:"es-CL",9226:"es-CO",5130:"es-CR",7178:"es-DO",12298:"es-EC",17418:"es-SV",4106:"es-GT",18442:"es-HN",2058:"es-MX",19466:"es-NI",6154:"es-PA",15370:"es-PY",10250:"es-PE",20490:"es-PR",3082:"es",1034:"es",21514:"es-US",14346:"es-UY",8202:"es-VE",2077:"sv-FI",1053:"sv",1114:"syr",1064:"tg",2143:"tzm",1097:"ta",1092:"tt",1098:"te",1054:"th",1105:"bo",1055:"tr",1090:"tk",1152:"ug",1058:"uk",1070:"hsb",1056:"ur",2115:"uz-Cyrl",1091:"uz",1066:"vi",1106:"cy",1160:"wo",1157:"sah",1144:"ii",1130:"yo"};function Id(s,o,c){switch(s){case 0:if(o===65535)return"und";if(c)return c[o];break;case 1:return Sl[o];case 3:return Al[o]}}var Fi="utf-16",Rd={0:"macintosh",1:"x-mac-japanese",2:"x-mac-chinesetrad",3:"x-mac-korean",6:"x-mac-greek",7:"x-mac-cyrillic",9:"x-mac-devanagai",10:"x-mac-gurmukhi",11:"x-mac-gujarati",12:"x-mac-oriya",13:"x-mac-bengali",14:"x-mac-tamil",15:"x-mac-telugu",16:"x-mac-kannada",17:"x-mac-malayalam",18:"x-mac-sinhalese",19:"x-mac-burmese",20:"x-mac-khmer",21:"x-mac-thai",22:"x-mac-lao",23:"x-mac-georgian",24:"x-mac-armenian",25:"x-mac-chinesesimp",26:"x-mac-tibetan",27:"x-mac-mongolian",28:"x-mac-ethiopic",29:"x-mac-ce",30:"x-mac-vietnamese",31:"x-mac-extarabic"},Pd={15:"x-mac-icelandic",17:"x-mac-turkish",18:"x-mac-croatian",24:"x-mac-ce",25:"x-mac-ce",26:"x-mac-ce",27:"x-mac-ce",28:"x-mac-ce",30:"x-mac-icelandic",37:"x-mac-romanian",38:"x-mac-ce",39:"x-mac-ce",40:"x-mac-ce",143:"x-mac-inuit",146:"x-mac-gaelic"};function Di(s,o,c){switch(s){case 0:return Fi;case 1:return Pd[c]||Rd[o];case 3:if(o===1||o===10)return Fi;break}}var Tl={0:"unicode",1:"macintosh",2:"reserved",3:"windows"};function Od(s){return Tl[s]}function Md(s,o,c){let h={},d=new rt.Parser(s,o),p=d.parseUShort(),b=d.parseUShort(),x=d.offset+d.parseUShort();for(let A=0;A<b;A++){let w=d.parseUShort(),E=d.parseUShort(),P=d.parseUShort(),R=d.parseUShort(),F=tr[R]||R,L=d.parseUShort(),N=d.parseUShort(),$=Id(w,P,c),vt=Di(w,E,P),pt=Od(w);if(vt!==void 0&&$!==void 0&&pt!==void 0){let At;if(vt===Fi?At=Dt.UTF16(s,x+N,L):At=Dt.MACSTRING(s,x+N,L,vt),At){let It=h[pt];It===void 0&&(It=h[pt]={});let Ut=It[F];Ut===void 0&&(Ut=It[F]={}),Ut[$]=At}}}return p===1&&d.parseUShort(),h}function er(s){let o={};for(let c in s)o[s[c]]=parseInt(c);return o}function Cl(s,o,c,h,d,p){return new J.Record("NameRecord",[{name:"platformID",type:"USHORT",value:s},{name:"encodingID",type:"USHORT",value:o},{name:"languageID",type:"USHORT",value:c},{name:"nameID",type:"USHORT",value:h},{name:"length",type:"USHORT",value:d},{name:"offset",type:"USHORT",value:p}])}function Ld(s,o){let c=s.length,h=o.length-c+1;t:for(let d=0;d<h;d++)for(;d<h;d++){for(let p=0;p<c;p++)if(o[d+p]!==s[p])continue t;return d}return-1}function El(s,o){let c=Ld(s,o);if(c<0){c=o.length;let h=0,d=s.length;for(;h<d;++h)o.push(s[h])}return c}function Fd(s,o){let c=er(Tl),h=er(Sl),d=er(Al),p=[],b=[];for(let A in s){let w,E=[],P={},R=er(tr),F=c[A];for(let L in s[A]){let N=R[L];if(N===void 0&&(N=L),w=parseInt(N),isNaN(w))throw new Error('Name table entry "'+L+'" does not exist, see nameTableNames for complete list.');P[w]=s[A][L],E.push(w)}for(let L=0;L<E.length;L++){w=E[L];let N=P[w];for(let $ in N){let vt=N[$];if(F===1||F===0){let pt=h[$],At=kd[pt],It=Di(F,At,pt),Ut=tt.MACSTRING(vt,It);if(F===0&&(pt=o.indexOf($),pt<0&&(pt=o.length,o.push($)),At=4,Ut=tt.UTF16(vt)),Ut!==void 0){let Gt=El(Ut,b);p.push(Cl(F,At,pt,w,Ut.length,Gt))}}if(F===3){let pt=d[$];if(pt!==void 0){let At=tt.UTF16(vt),It=El(At,b);p.push(Cl(3,1,pt,w,At.length,It))}}}}}p.sort(function(A,w){return A.platformID-w.platformID||A.encodingID-w.encodingID||A.languageID-w.languageID||A.nameID-w.nameID});let x=new J.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:p.length},{name:"stringOffset",type:"USHORT",value:6+p.length*12}]);for(let A=0;A<p.length;A++)x.fields.push({name:"record_"+A,type:"RECORD",value:p[A]});return x.fields.push({name:"strings",type:"LITERAL",value:b}),x}function nr(s,o,c=[]){if(o<256&&o in tr){if(c.length&&!c.includes(parseInt(o)))return;o=tr[o]}for(let h in s)for(let d in s[h])if(d===o||parseInt(d)===o)return s[h][d]}var wl={parse:Md,make:Fd,getNameByID:nr};function Dd(s,o,c,h){s.length=o.parseUShort(),s.language=o.parseUShort()-1;let d=o.parseByteList(s.length),p=Object.assign({},d),b=Di(c,h,s.language),x=Le[b];for(let A=0;A<x.length;A++)p[x.charCodeAt(A)]=d[128+A];s.glyphIndexMap=p}function _d(s,o,c){o.parseUShort(),s.length=o.parseULong(),s.language=o.parseULong();let h;s.groupCount=h=o.parseULong(),s.glyphIndexMap={};for(let d=0;d<h;d+=1){let p=o.parseULong(),b=o.parseULong(),x=o.parseULong();for(let A=p;A<=b;A+=1)s.glyphIndexMap[A]=x,c===12&&x++}}function Nd(s,o,c,h,d){s.length=o.parseUShort(),s.language=o.parseUShort();let p;s.segCount=p=o.parseUShort()>>1,o.skip("uShort",3),s.glyphIndexMap={};let b=new rt.Parser(c,h+d+14),x=new rt.Parser(c,h+d+16+p*2),A=new rt.Parser(c,h+d+16+p*4),w=new rt.Parser(c,h+d+16+p*6),E=h+d+16+p*8;for(let P=0;P<p-1;P+=1){let R,F=b.parseUShort(),L=x.parseUShort(),N=A.parseShort(),$=w.parseUShort();for(let vt=L;vt<=F;vt+=1)$!==0?(E=w.offset+w.relativeOffset-2,E+=$,E+=(vt-L)*2,R=rt.getUShort(c,E),R!==0&&(R=R+N&65535)):R=vt+N&65535,s.glyphIndexMap[vt]=R}}function Ud(s,o){let c={};o.skip("uLong");let h=o.parseULong();for(let d=0;d<h;d+=1){let p=o.parseUInt24(),b={varSelector:p},x=o.parseOffset32(),A=o.parseOffset32(),w=o.relativeOffset;x&&(o.relativeOffset=x,b.defaultUVS=o.parseStruct({ranges:function(){return o.parseRecordList32({startUnicodeValue:o.parseUInt24,additionalCount:o.parseByte})}})),A&&(o.relativeOffset=A,b.nonDefaultUVS=o.parseStruct({uvsMappings:function(){let E={},P=o.parseRecordList32({unicodeValue:o.parseUInt24,glyphID:o.parseUShort});for(let R=0;R<P.length;R+=1)E[P[R].unicodeValue]=P[R];return E}})),c[p]=b,o.relativeOffset=w}s.varSelectorList=c}function Bd(s,o){let c={};c.version=rt.getUShort(s,o),U.argument(c.version===0,"cmap table version should be 0."),c.numTables=rt.getUShort(s,o+2);let h=null,d=-1,p=-1,b=null,x=null,A=[0,1,2,3,4,6],w=[0,1,10];for(let P=c.numTables-1;P>=0;P-=1)if(b=rt.getUShort(s,o+4+P*8),x=rt.getUShort(s,o+4+P*8+2),b===3&&w.includes(x)||b===0&&A.includes(x)||b===1&&x===0){if(p>0)continue;if(p=rt.getULong(s,o+4+P*8+4),h)break}else if(b===0&&x===5){if(d=rt.getULong(s,o+4+P*8+4),h=new rt.Parser(s,o+d),h.parseUShort()!==14)d=-1,h=null;else if(p>0)break}if(p===-1)throw new Error("No valid cmap sub-tables found.");let E=new rt.Parser(s,o+p);if(c.format=E.parseUShort(),c.format===0)Dd(c,E,b,x);else if(c.format===12||c.format===13)_d(c,E,c.format);else if(c.format===4)Nd(c,E,s,o,p);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+c.format+", platformId "+b+", encodingId "+x+").");return h&&Ud(c,h),c}function Gd(s,o,c){s.segments.push({end:o,start:o,delta:-(o-c),offset:0,glyphIndex:c})}function Hd(s){s.segments.push({end:65535,start:65535,delta:1,offset:0})}function jd(s){if(s.length===0)return s;let o=[s[0]];for(let c=1;c<s.length;c++){let h=o[o.length-1],d=s[c];h.end+1===d.start&&h.delta===d.delta&&d.end!==65535?h.end=d.end:o.push(d)}return o}function Vd(s){let o=!0,c;for(c=s.length-1;c>0;c-=1)if(s.get(c).unicode>65535){o=!1;break}let h=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:o?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:o?12:20}];o||h.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),h.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});let d=new J.Table("cmap",h);for(d.segments=[],c=0;c<s.length;c+=1){let F=s.get(c);for(let L=0;L<F.unicodes.length;L+=1)Gd(d,F.unicodes[L],c)}d.segments.sort(function(F,L){return F.start-L.start}),d.segments=jd(d.segments),Hd(d);let p=d.segments.length,b=0,x=[],A=[],w=[],E=[],P=[],R=[];for(c=0;c<p;c+=1){let F=d.segments[c];F.end<=65535&&F.start<=65535?(x.push({name:"end_"+c,type:"USHORT",value:F.end}),A.push({name:"start_"+c,type:"USHORT",value:F.start}),w.push({name:"idDelta_"+c,type:"SHORT",value:F.delta}),E.push({name:"idRangeOffset_"+c,type:"USHORT",value:F.offset}),F.glyphId!==void 0&&P.push({name:"glyph_"+c,type:"USHORT",value:F.glyphId})):b+=1,!o&&F.glyphIndex!==void 0&&(R.push({name:"cmap12Start_"+c,type:"ULONG",value:F.start}),R.push({name:"cmap12End_"+c,type:"ULONG",value:F.end}),R.push({name:"cmap12Glyph_"+c,type:"ULONG",value:F.glyphIndex}))}d.segCountX2=(p-b)*2,d.searchRange=Math.pow(2,Math.floor(Math.log(p-b)/Math.log(2)))*2,d.entrySelector=Math.log(d.searchRange/2)/Math.log(2),d.rangeShift=d.segCountX2-d.searchRange;for(let F=0;F<x.length;F++)d.fields.push(x[F]);d.fields.push({name:"reservedPad",type:"USHORT",value:0});for(let F=0;F<A.length;F++)d.fields.push(A[F]);for(let F=0;F<w.length;F++)d.fields.push(w[F]);for(let F=0;F<E.length;F++)d.fields.push(E[F]);for(let F=0;F<P.length;F++)d.fields.push(P[F]);if(d.cmap4Length=14+x.length*2+2+A.length*2+w.length*2+E.length*2+P.length*2,!o){let F=16+R.length*4;d.cmap12Offset=20+d.cmap4Length,d.fields.push({name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:F},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:R.length/3});for(let L=0;L<R.length;L++)d.fields.push(R[L])}return d}var kl={parse:Bd,make:Vd},sr=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],Wd=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],$d=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],zd=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"],_i=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],Xd=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],Tn=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior","threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"];function Il(s){this.font=s}Il.prototype.charToGlyphIndex=function(s){let o=s.codePointAt(0),c=this.font.glyphs;if(c)for(let h=0;h<c.length;h+=1){let d=c.get(h);for(let p=0;p<d.unicodes.length;p+=1)if(d.unicodes[p]===o)return h}return null};function Rl(s){this.cmap=s}Rl.prototype.charToGlyphIndex=function(s){return this.cmap.glyphIndexMap[s.codePointAt(0)]||0};function Pl(s,o){this.encoding=s,this.charset=o}Pl.prototype.charToGlyphIndex=function(s){let o=s.codePointAt(0),c=this.encoding[o];return this.charset.indexOf(c)};function Ni(s){switch(s.version){case 1:this.names=Tn.slice();break;case 2:this.names=new Array(s.numberOfGlyphs);for(let o=0;o<s.numberOfGlyphs;o++)s.glyphNameIndex[o]<Tn.length?this.names[o]=Tn[s.glyphNameIndex[o]]:this.names[o]=s.names[s.glyphNameIndex[o]-Tn.length];break;case 2.5:this.names=new Array(s.numberOfGlyphs);for(let o=0;o<s.numberOfGlyphs;o++)this.names[o]=Tn[o+s.glyphNameIndex[o]];break;case 3:this.names=[];break;default:this.names=[];break}}Ni.prototype.nameToGlyphIndex=function(s){return this.names.indexOf(s)},Ni.prototype.glyphIndexToName=function(s){return this.names[s]};function Yd(s){let o,c=s.tables.cmap.glyphIndexMap,h=Object.keys(c);for(let d=0;d<h.length;d+=1){let p=h[d],b=c[p];o=s.glyphs.get(b),o.addUnicode(parseInt(p))}for(let d=0;d<s.glyphs.length;d+=1)o=s.glyphs.get(d),s.cffEncoding?o.name=s.cffEncoding.charset[d]:s.glyphNames.names&&(o.name=s.glyphNames.glyphIndexToName(d))}function Kd(s){s._IndexToUnicodeMap={};let o=s.tables.cmap.glyphIndexMap,c=Object.keys(o);for(let h=0;h<c.length;h+=1){let d=c[h],p=o[d];s._IndexToUnicodeMap[p]===void 0?s._IndexToUnicodeMap[p]={unicodes:[parseInt(d)]}:s._IndexToUnicodeMap[p].unicodes.push(parseInt(d))}}function Zd(s,o){o.lowMemory?Kd(s):Yd(s)}function Qd(s,o,c,h,d){s.beginPath(),s.moveTo(o,c),s.lineTo(h,d),s.stroke()}var Cn={line:Qd};function Jd(s,o){let c=new G(s,o),h=c.parseShort();h!==0&&console.warn("Only CPALv0 is currently fully supported.");let d=c.parseShort(),p=c.parseShort(),b=c.parseShort(),x=c.parseOffset32(),A=c.parseUShortList(p);c.relativeOffset=x;let w=c.parseULongList(b);return c.relativeOffset=x,{version:h,numPaletteEntries:d,colorRecords:w,colorRecordIndices:A}}function qd({version:s=0,numPaletteEntries:o=0,colorRecords:c=[],colorRecordIndices:h=[0]}){return U.argument(s===0,"Only CPALv0 are supported."),U.argument(c.length,"No colorRecords given."),U.argument(h.length,"No colorRecordIndices given."),h.length>1&&U.argument(o,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new J.Table("CPAL",[{name:"version",type:"USHORT",value:s},{name:"numPaletteEntries",type:"USHORT",value:o||c.length},{name:"numPalettes",type:"USHORT",value:h.length},{name:"numColorRecords",type:"USHORT",value:c.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*h.length},...h.map((d,p)=>({name:"colorRecordIndices_"+p,type:"USHORT",value:d})),...c.map((d,p)=>({name:"colorRecords_"+p,type:"ULONG",value:d}))])}function Ol(s){var o=(s&4278190080)>>24,c=(s&16711680)>>16,h=(s&65280)>>8,d=s&255;return o=o+256&255,c=c+256&255,h=h+256&255,d=(d+256&255)/255,{b:o,g:c,r:h,a:d}}function Ui(s,o,c=0,h="hexa"){if(o==65535)return"currentColor";let d=s&&s.tables&&s.tables.cpal;if(!d)return"currentColor";if(c>d.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${d.colorRecordIndices.length}, index: ${o})`);if(o>d.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${d.numPaletteEntries}, index: ${o})`);let p=d.colorRecordIndices[c]+o;if(p>d.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${d.colorRecords.length}, lookupIndex: ${p})`);let b=Ol(d.colorRecords[p]);return h==="bgra"?b:$n(b,h)}function Fe(s){return("0"+parseInt(s).toString(16)).slice(-2)}function tf(s){let o=s.r/255,c=s.g/255,h=s.b/255,d=Math.max(o,c,h),p=Math.min(o,c,h),b,x,A=(d+p)/2;if(d===p)b=x=0;else{let w=d-p;switch(x=A>.5?w/(2-d-p):w/(d+p),d){case o:b=(c-h)/w+(c<h?6:0);break;case c:b=(h-o)/w+2;break;case h:b=(o-c)/w+4;break}b/=6}return{h:b*360,s:x*100,l:A*100}}function ef(s){let{h:o,s:c,l:h,a:d}=s;o=o%360,c/=100,h/=100;let p=(1-Math.abs(2*h-1))*c,b=p*(1-Math.abs(o/60%2-1)),x=h-p/2,A=0,w=0,E=0;return 0<=o&&o<60?(A=p,w=b,E=0):60<=o&&o<120?(A=b,w=p,E=0):120<=o&&o<180?(A=0,w=p,E=b):180<=o&&o<240?(A=0,w=b,E=p):240<=o&&o<300?(A=b,w=0,E=p):300<=o&&o<=360&&(A=p,w=0,E=b),{r:Math.round((A+x)*255),g:Math.round((w+x)*255),b:Math.round((E+x)*255),a:d}}function Ml(s){return parseInt(`0x${Fe(s.b)}${Fe(s.g)}${Fe(s.r)}${Fe(s.a*255)}`,16)}function rr(s,o="hexa"){let c=o=="raw"||o=="cpal",h=Number.isInteger(s),d=!0;if(h&&c||s==="currentColor")return s;if(typeof s=="object"){if(o=="bgra")return s;if(c)return Ml(s)}else if(!h&&/^#([a-f0-9]{3}|[a-f0-9]{4}|[a-f0-9]{6}|[a-f0-9]{8})$/i.test(s.trim())){switch(s=s.trim().substring(1),s.length){case 3:s={r:parseInt(s[0].repeat(2),16),g:parseInt(s[1].repeat(2),16),b:parseInt(s[2].repeat(2),16),a:1};break;case 4:s={r:parseInt(s[0].repeat(2),16),g:parseInt(s[1].repeat(2),16),b:parseInt(s[2].repeat(2),16),a:parseInt(s[3].repeat(2),16)/255};break;case 6:s={r:parseInt(s[0]+s[1],16),g:parseInt(s[2]+s[3],16),b:parseInt(s[4]+s[5],16),a:1};break;case 8:s={r:parseInt(s[0]+s[1],16),g:parseInt(s[2]+s[3],16),b:parseInt(s[4]+s[5],16),a:parseInt(s[6]+s[7],16)/255};break}if(o=="bgra")return s}else if(typeof document<"u"&&/^[a-z]+$/i.test(s)){let p=document.createElement("canvas").getContext("2d");p.fillStyle=s;let b=$n(p.fillStyle,"hexa");b==="#000000ff"&&s.toLowerCase()!=="black"?d=!1:s=b}else{s=s.trim();let p=/rgba?\(\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(p.test(s)){let b=s.match(p).filter(x=>typeof x<"u");s={r:Math.round(parseFloat(b[1])/(b[2]?.39215686274509803:1)),g:Math.round(parseFloat(b[3])/(b[4]?.39215686274509803:1)),b:Math.round(parseFloat(b[5])/(b[6]?.39215686274509803:1)),a:b[7]?parseFloat(b[7])/(b[8]?100:1):1}}else{let b=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(b.test(s)){let x=s.match(b).filter(A=>typeof A<"u");s=ef({h:parseFloat(x[1])*(x[2]==="turn"?360:1),s:parseFloat(x[3]),l:parseFloat(x[4]),a:x[5]?parseFloat(x[5])/(x[6]?100:1):1})}else d=!1}}if(!d)throw new Error(`Invalid color format: ${s}`);return $n(s,o)}function $n(s,o="hexa"){if(s==="currentColor")return s;if(Number.isInteger(s)){if(o=="raw"||o=="cpal")return s;s=Ol(s)}else typeof s!="object"&&(s=rr(s,"bgra"));let c=["hsl","hsla"].includes(o)?tf(s):null;switch(o){case"rgba":return`rgba(${s.r}, ${s.g}, ${s.b}, ${parseFloat(s.a.toFixed(3))})`;case"rgb":return`rgb(${s.r}, ${s.g}, ${s.b})`;case"hex":case"hex6":case"hex-6":return`#${Fe(s.r)}${Fe(s.g)}${Fe(s.b)}`;case"hexa":case"hex8":case"hex-8":return`#${Fe(s.r)}${Fe(s.g)}${Fe(s.b)}${Fe(s.a*255)}`;case"hsl":return`hsl(${c.h.toFixed(2)}, ${c.s.toFixed(2)}%, ${c.l.toFixed(2)}%)`;case"hsla":return`hsla(${c.h.toFixed(2)}, ${c.s.toFixed(2)}%, ${c.l.toFixed(2)}%, ${parseFloat(s.a.toFixed(3))})`;case"bgra":return s;case"raw":case"cpal":return Ml(s);default:throw new Error("Unknown color format: "+o)}}var Ll={parse:Jd,make:qd,getPaletteColor:Ui,parseColor:rr,formatColor:$n};function nf(s,o){let c=o||new ot;return{configurable:!0,get:function(){return typeof c=="function"&&(c=c()),c},set:function(h){c=h}}}function ie(s){this.bindConstructorValues(s)}ie.prototype.bindConstructorValues=function(s){if(this.index=s.index||0,s.name===".notdef"?s.unicode=void 0:s.name===".null"&&(s.unicode=0),s.unicode===0&&s.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=s.name||null,this.unicode=s.unicode,this.unicodes=s.unicodes||(s.unicode!==void 0?[s.unicode]:[]),"xMin"in s&&(this.xMin=s.xMin),"yMin"in s&&(this.yMin=s.yMin),"xMax"in s&&(this.xMax=s.xMax),"yMax"in s&&(this.yMax=s.yMax),"advanceWidth"in s&&(this.advanceWidth=s.advanceWidth),"leftSideBearing"in s&&(this.leftSideBearing=s.leftSideBearing),"points"in s&&(this.points=s.points),Object.defineProperty(this,"path",nf(this,s.path))},ie.prototype.addUnicode=function(s){this.unicodes.length===0&&(this.unicode=s),this.unicodes.push(s)},ie.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},ie.prototype.getPath=function(s,o,c,h,d){s=s!==void 0?s:0,o=o!==void 0?o:0,c=c!==void 0?c:72,h=Object.assign({},d&&d.defaultRenderOptions,h);let p,b,x=h.xScale,A=h.yScale,w=1/(this.path.unitsPerEm||1e3)*c,E=this;d&&d.variation&&(E=d.variation.getTransform(this,h.variation),p=E.path.commands),h.hinting&&d&&d.hinting&&(b=E.path&&d.hinting.exec(E,c,h)),b?(p=d.hinting.getCommands(b),s=Math.round(s),o=Math.round(o),x=A=1):(p=E.path.commands,x===void 0&&(x=w),A===void 0&&(A=w));let P=new ot;if(h.drawSVG){let R=this.getSvgImage(d);if(R){let F=new ot;return F._image={image:R.image,x:s+R.leftSideBearing*w,y:o-R.baseline*w,width:R.image.width*w,height:R.image.height*w},P._layers=[F],P}}if(h.drawLayers){let R=this.getLayers(d);if(R&&R.length){P._layers=[];for(let F=0;F<R.length;F+=1){let L=R[F],N=Ui(d,L.paletteIndex,h.usePalette);N==="currentColor"?N=h.fill||"black":N=$n(N,h.colorFormat||"rgba"),h=Object.assign({},h,{fill:N}),P._layers.push(this.getPath.call(L.glyph,s,o,c,h,d))}return P}}P.fill=h.fill||this.path.fill,P.stroke=this.path.stroke,P.strokeWidth=this.path.strokeWidth*w;for(let R=0;R<p.length;R+=1){let F=p[R];F.type==="M"?P.moveTo(s+F.x*x,o+-F.y*A):F.type==="L"?P.lineTo(s+F.x*x,o+-F.y*A):F.type==="Q"?P.quadraticCurveTo(s+F.x1*x,o+-F.y1*A,s+F.x*x,o+-F.y*A):F.type==="C"?P.curveTo(s+F.x1*x,o+-F.y1*A,s+F.x2*x,o+-F.y2*A,s+F.x*x,o+-F.y*A):F.type==="Z"&&P.stroke&&P.strokeWidth&&P.closePath()}return P},ie.prototype.getLayers=function(s){if(!s)throw new Error("The font object is required to read the colr/cpal tables in order to get the layers.");return s.layers.get(this.index)},ie.prototype.getSvgImage=function(s){if(!s)throw new Error("The font object is required to read the svg table in order to get the image.");return s.svgImages.get(this.index)},ie.prototype.getContours=function(s=null){if(this.points===void 0&&!s)return[];let o=[],c=[],h=s||this.points;for(let d=0;d<h.length;d+=1){let p=h[d];c.push(p),p.lastPointOfContour&&(o.push(c),c=[])}return U.argument(c.length===0,"There are still points left in the current contour."),o},ie.prototype.getMetrics=function(){let s=this.path.commands,o=[],c=[];for(let d=0;d<s.length;d+=1){let p=s[d];p.type!=="Z"&&(o.push(p.x),c.push(p.y)),(p.type==="Q"||p.type==="C")&&(o.push(p.x1),c.push(p.y1)),p.type==="C"&&(o.push(p.x2),c.push(p.y2))}let h={xMin:Math.min.apply(null,o),yMin:Math.min.apply(null,c),xMax:Math.max.apply(null,o),yMax:Math.max.apply(null,c),leftSideBearing:this.leftSideBearing};return isFinite(h.xMin)||(h.xMin=0),isFinite(h.xMax)||(h.xMax=this.advanceWidth),isFinite(h.yMin)||(h.yMin=0),isFinite(h.yMax)||(h.yMax=0),h.rightSideBearing=this.advanceWidth-h.leftSideBearing-(h.xMax-h.xMin),h},ie.prototype.draw=function(s,o,c,h,d,p){d=Object.assign({},p&&p.defaultRenderOptions,d),this.getPath(o,c,h,d,p).draw(s)},ie.prototype.drawPoints=function(s,o,c,h,d,p){if(d=Object.assign({},p&&p.defaultRenderOptions,d),d.drawLayers){let R=this.getLayers(p);if(R&&R.length){for(let F=0;F<R.length;F+=1)R[F].glyph.index!==this.index&&this.drawPoints.call(R[F].glyph,s,o,c,h);return}}function b(R,F,L,N){s.beginPath();for(let $=0;$<R.length;$+=1)s.moveTo(F+R[$].x*N,L+R[$].y*N),s.arc(F+R[$].x*N,L+R[$].y*N,2,0,Math.PI*2,!1);s.fill()}o=o!==void 0?o:0,c=c!==void 0?c:0,h=h!==void 0?h:24;let x=1/this.path.unitsPerEm*h,A=[],w=[],P=this.path.commands;p&&p.variation&&(P=p.variation.getTransform(this,d.variation).path.commands);for(let R=0;R<P.length;R+=1){let F=P[R];F.x!==void 0&&A.push({x:F.x,y:-F.y}),F.x1!==void 0&&w.push({x:F.x1,y:-F.y1}),F.x2!==void 0&&w.push({x:F.x2,y:-F.y2})}s.fillStyle="blue",b(A,o,c,x),s.fillStyle="red",b(w,o,c,x)},ie.prototype.drawMetrics=function(s,o,c,h){let d;o=o!==void 0?o:0,c=c!==void 0?c:0,h=h!==void 0?h:24,d=1/this.path.unitsPerEm*h,s.lineWidth=1,s.strokeStyle="black",Cn.line(s,o,-1e4,o,1e4),Cn.line(s,-1e4,c,1e4,c);let p=this.xMin||0,b=this.yMin||0,x=this.xMax||0,A=this.yMax||0,w=this.advanceWidth||0;s.strokeStyle="blue",Cn.line(s,o+p*d,-1e4,o+p*d,1e4),Cn.line(s,o+x*d,-1e4,o+x*d,1e4),Cn.line(s,-1e4,c+-b*d,1e4,c+-b*d),Cn.line(s,-1e4,c+-A*d,1e4,c+-A*d),s.strokeStyle="green",Cn.line(s,o+w*d,-1e4,o+w*d,1e4)},ie.prototype.toPathData=function(s,o){s=Object.assign({},{variation:o&&o.defaultRenderOptions.variation},s);let c=this;o&&o.variation&&(c=o.variation.getTransform(this,s.variation));let h=c.points&&s.pointsTransform?s.pointsTransform(c.points):c.path;return s.pathTransform&&(h=s.pathTransform(h)),h.toPathData(s)},ie.prototype.fromSVG=function(s,o={}){return this.path.fromSVG(s,o)},ie.prototype.toSVG=function(s,o){let c=this.toPathData.apply(this,[s,o]);return this.path.toSVG(s,c)},ie.prototype.toDOMElement=function(s,o){s=Object.assign({},{variation:o&&o.defaultRenderOptions.variation},s);let c=this.path;return o&&o.variation&&(c=o.variation.getTransform(this,s.variation).path),c.toDOMElement(s)};var zn=ie;function Xn(s,o,c){Object.defineProperty(s,o,{get:function(){return typeof s[c]>"u"&&s.path,s[c]},set:function(h){s[c]=h},enumerable:!0,configurable:!0})}function ir(s,o){if(this.font=s,this.glyphs={},Array.isArray(o))for(let c=0;c<o.length;c++){let h=o[c];h.path.unitsPerEm=s.unitsPerEm,this.glyphs[c]=h}this.length=o&&o.length||0}typeof Symbol<"u"&&Symbol.iterator&&(ir.prototype[Symbol.iterator]=function(){let s=-1;return{next:function(){s++;let o=s>=this.length-1;return{value:this.get(s),done:o}}.bind(this)}}),ir.prototype.get=function(s){if(this.font._push&&this.glyphs[s]===void 0){this.font._push(s),typeof this.glyphs[s]=="function"&&(this.glyphs[s]=this.glyphs[s]());let o=this.glyphs[s],c=this.font._IndexToUnicodeMap[s];if(c)for(let h=0;h<c.unicodes.length;h++)o.addUnicode(c.unicodes[h]);this.font.cffEncoding?o.name=this.font.cffEncoding.charset[s]:this.font.glyphNames.names&&(o.name=this.font.glyphNames.glyphIndexToName(s)),this.glyphs[s].advanceWidth=this.font._hmtxTableData[s].advanceWidth,this.glyphs[s].leftSideBearing=this.font._hmtxTableData[s].leftSideBearing}else typeof this.glyphs[s]=="function"&&(this.glyphs[s]=this.glyphs[s]());return this.glyphs[s]},ir.prototype.push=function(s,o){this.glyphs[s]=o,this.length++};function sf(s,o){return new zn({index:o,font:s})}function rf(s,o,c,h,d,p){return function(){let b=new zn({index:o,font:s});return b.path=function(){c(b,h,d);let x=p(s.glyphs,b);return x.unitsPerEm=s.unitsPerEm,x},Xn(b,"numberOfContours","_numberOfContours"),Xn(b,"xMin","_xMin"),Xn(b,"xMax","_xMax"),Xn(b,"yMin","_yMin"),Xn(b,"yMax","_yMax"),Xn(b,"points","_points"),b}}function of(s,o,c,h,d){return function(){let p=new zn({index:o,font:s});return p.path=function(){let b=c(s,p,h,d);return b.unitsPerEm=s.unitsPerEm,b},p}}var We={GlyphSet:ir,glyphLoader:sf,ttfGlyphLoader:rf,cffGlyphLoader:of};function Fl(s,o){if(s===o)return!0;if(Array.isArray(s)&&Array.isArray(o)){if(s.length!==o.length)return!1;for(let c=0;c<s.length;c+=1)if(!Fl(s[c],o[c]))return!1;return!0}else return!1}var Dl=10;function or(s){let o;return s.length<1240?o=107:s.length<33900?o=1131:o=32768,o}function $e(s,o,c,h){let d=[],p=[],b=h>1?rt.getULong(s,o):rt.getCard16(s,o),x=h>1?4:2,A,w;if(b!==0){let E=rt.getByte(s,o+x);A=o+(b+1)*E+x;let P=o+x+1;for(let R=0;R<b+1;R+=1)d.push(rt.getOffset(s,P,E)),P+=E;w=A+d[b]}else w=o+x;for(let E=0;E<d.length-1;E+=1){let P=rt.getBytes(s,A+d[E],A+d[E+1]);c&&(P=c(P,s,o,h)),p.push(P)}return{objects:p,startOffset:o,endOffset:w}}function af(s,o,c){let h=[],d=c>1?rt.getULong(s,o):rt.getCard16(s,o),p=c>1?4:2,b,x;if(d!==0){let A=rt.getByte(s,o+p);b=o+(d+1)*A+p;let w=o+p+1;for(let E=0;E<d+1;E+=1)h.push(rt.getOffset(s,w,A)),w+=A;x=b+h[d]}else x=o+p;return{offsets:h,startOffset:o,endOffset:x}}function lf(s,o,c,h,d,p){let b=p>1?rt.getULong(c,h):rt.getCard16(c,h),x=p>1?4:2,A=0;if(b!==0){let E=rt.getByte(c,h+x);A=h+(b+1)*E+x}let w=rt.getBytes(c,A+o[s],A+o[s+1]);return d&&(w=d(w)),w}function cf(s){let o="",h=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){let d=s.parseByte(),p=d>>4,b=d&15;if(p===15||(o+=h[p],b===15))break;o+=h[b]}return parseFloat(o)}function uf(s,o){let c,h,d,p;if(o===28)return c=s.parseByte(),h=s.parseByte(),c<<8|h;if(o===29)return c=s.parseByte(),h=s.parseByte(),d=s.parseByte(),p=s.parseByte(),c<<24|h<<16|d<<8|p;if(o===30)return cf(s);if(o>=32&&o<=246)return o-139;if(o>=247&&o<=250)return c=s.parseByte(),(o-247)*256+c+108;if(o>=251&&o<=254)return c=s.parseByte(),-(o-251)*256-c-108;throw new Error("Invalid b0 "+o)}function hf(s){let o={};for(let c=0;c<s.length;c+=1){let h=s[c][0],d=s[c][1],p;if(d.length===1?p=d[0]:p=d,Object.prototype.hasOwnProperty.call(o,h)&&!isNaN(o[h]))throw new Error("Object "+o+" already has key "+h);o[h]=p}return o}function Bi(s,o,c,h){o=o!==void 0?o:0;let d=new rt.Parser(s,o),p=[],b=[];c=c!==void 0?c:s.byteLength;let x=h<2?22:28;for(;d.relativeOffset<c;){let A=d.parseByte();if(A<x){if(A===12&&(A=1200+d.parseByte()),h>1&&A===23){vf(b);continue}p.push([A,b]),b=[]}else b.push(uf(d,A,h))}return hf(p)}function cs(s,o){return o<=390?o=sr[o]:s?o=s[o-391]:o=void 0,o}function Gi(s,o,c){let h={},d;for(let p=0;p<o.length;p+=1){let b=o[p];if(Array.isArray(b.type)){let x=[];x.length=b.type.length;for(let A=0;A<b.type.length;A++)d=s[b.op]!==void 0?s[b.op][A]:void 0,d===void 0&&(d=b.value!==void 0&&b.value[A]!==void 0?b.value[A]:null),b.type[A]==="SID"&&(d=cs(c,d)),x[A]=d;h[b.name]=x}else d=s[b.op],d===void 0&&(d=b.value!==void 0?b.value:null),b.type==="SID"&&(d=cs(c,d)),h[b.name]=d}return h}function df(s,o){let c={};if(c.formatMajor=rt.getCard8(s,o),c.formatMinor=rt.getCard8(s,o+1),c.formatMajor>2)throw new Error(`Unsupported CFF table version ${c.formatMajor}.${c.formatMinor}`);return c.size=rt.getCard8(s,o+2),c.formatMajor<2?(c.offsetSize=rt.getCard8(s,o+3),c.startOffset=o,c.endOffset=o+4):(c.topDictLength=rt.getCard16(s,o+3),c.endOffset=o+8),c}var _l=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],Nl=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],Ul=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],Bl=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],ff=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function pf(s,o,c,h){let d=Bi(s,o,s.byteLength,h);return Gi(d,h>1?Nl:_l,c)}function Hi(s,o,c,h,d){let p=Bi(s,o,c,d);return Gi(p,d>1?Bl:Ul,h)}function gf(s,o,c){let h=Bi(s,o,void 0,c);return Gi(h,ff)}function mf(s,o,c){let h=[];for(let d=0;d<c.length;d++){let p=new DataView(new Uint8Array(c[d]).buffer),b=gf(p,0,2),x=b.private[0],A=b.private[1];if(x!==0&&A!==0){let w=Hi(s,A+o,x,[],2);if(w.subrs){let E=A+w.subrs,P=$e(s,E+o,void 0,2);b._subrs=P.objects,b._subrsBias=or(b._subrs)}b._privateDict=w}h.push(b)}return h}function ji(s,o,c,h,d){let p=[];for(let b=0;b<c.length;b+=1){let x=new DataView(new Uint8Array(c[b]).buffer),A=pf(x,0,h,d);A._subrs=[],A._subrsBias=0,A._defaultWidthX=0,A._nominalWidthX=0;let w=d<2?A.private[0]:0,E=d<2?A.private[1]:0;if(w!==0&&E!==0){let P=Hi(s,E+o,w,h,d);if(A._defaultWidthX=P.defaultWidthX,A._nominalWidthX=P.nominalWidthX,P.subrs!==0){let R=E+P.subrs,F=$e(s,R+o,void 0,d);A._subrs=F.objects,A._subrsBias=or(A._subrs)}A._privateDict=P}p.push(A)}return p}function yf(s,o,c,h,d){let p,b,x=new rt.Parser(s,o);c-=1;let A=[".notdef"],w=x.parseCard8();if(w===0)for(let E=0;E<c;E+=1)p=x.parseSID(),d?A.push(p):A.push(cs(h,p)||p);else if(w===1)for(;A.length<=c;){p=x.parseSID(),b=x.parseCard8();for(let E=0;E<=b;E+=1)d?A.push("cid"+("00000"+p).slice(-5)):A.push(cs(h,p)||p),p+=1}else if(w===2)for(;A.length<=c;){p=x.parseSID(),b=x.parseCard16();for(let E=0;E<=b;E+=1)d?A.push("cid"+("00000"+p).slice(-5)):A.push(cs(h,p)||p),p+=1}else throw new Error("Unknown charset format "+w);return A}function bf(s,o){let c,h={},d=new rt.Parser(s,o),p=d.parseCard8();if(p===0){let b=d.parseCard8();for(let x=0;x<b;x+=1)c=d.parseCard8(),h[c]=x}else if(p===1){let b=d.parseCard8();c=1;for(let x=0;x<b;x+=1){let A=d.parseCard8(),w=d.parseCard8();for(let E=A;E<=A+w;E+=1)h[E]=c,c+=1}}else throw new Error("Unknown encoding format "+p);return h}function vf(s){let o=s.pop();for(;s.length>o;)s.pop()}function Gl(s,o){let c=s.tables.cff&&s.tables.cff.topDict&&s.tables.cff.topDict.paintType||0;return c===2&&(o.fill=null,o.stroke="black",o.strokeWidth=s.tables.cff.topDict.strokeWidth||0),c}function Vi(s,o,c,h,d){let p,b,x,A,w=new ot,E=[],P=0,R=!1,F=!1,L=0,N=0,$,vt,pt,At,It=0,Ut=[],Gt,Ht=0,Jt=s.tables.cff2||s.tables.cff;if(pt=Jt.topDict._defaultWidthX,At=Jt.topDict._nominalWidthX,d=d||s.variation&&s.variation.get(),o.getBlendPath||(o.getBlendPath=function(ct){return Vi(s,o,c,h,ct)}),s.isCIDFont||h>1){let ct=Jt.topDict._fdSelect?Jt.topDict._fdSelect[o.index]:0,ft=Jt.topDict._fdArray[ct];$=ft._subrs,vt=ft._subrsBias,h>1?(Ut=Jt.topDict._vstore.itemVariationStore,It=ft._privateDict.vsindex):(pt=ft._defaultWidthX,At=ft._nominalWidthX)}else $=Jt.topDict._subrs,vt=Jt.topDict._subrsBias;let Ne=Gl(s,w),Rt=pt;function Te(ct,ft){F&&Ne!==2&&w.closePath(),w.moveTo(ct,ft),F=!0}function de(){let ct;ct=(E.length&1)!==0,ct&&!R&&(Rt=E.shift()+At),P+=E.length>>1,E.length=0,R=!0}function xt(ct){let ft,oe,fn,mr,In,Ue,fe,Ie,ae,Ce,pe,ge,Zt=0;for(;Zt<ct.length;){let Pe=ct[Zt];switch(Zt+=1,Pe){case 1:de();break;case 3:de();break;case 4:E.length>1&&!R&&(Rt=E.shift()+At,R=!0),N+=E.pop(),Te(L,N);break;case 5:for(;E.length>0;)L+=E.shift(),N+=E.shift(),w.lineTo(L,N);break;case 6:for(;E.length>0&&(L+=E.shift(),w.lineTo(L,N),E.length!==0);)N+=E.shift(),w.lineTo(L,N);break;case 7:for(;E.length>0&&(N+=E.shift(),w.lineTo(L,N),E.length!==0);)L+=E.shift(),w.lineTo(L,N);break;case 8:for(;E.length>0;)p=L+E.shift(),b=N+E.shift(),x=p+E.shift(),A=b+E.shift(),L=x+E.shift(),N=A+E.shift(),w.curveTo(p,b,x,A,L,N);break;case 10:if(In=E.pop()+vt,Ue=$[In],Ue){if(Ht>=Dl){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}Ht++,xt(Ue),Ht--}break;case 11:if(h>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(Pe=ct[Zt],Zt+=1,Pe){case 35:p=L+E.shift(),b=N+E.shift(),x=p+E.shift(),A=b+E.shift(),fe=x+E.shift(),Ie=A+E.shift(),ae=fe+E.shift(),Ce=Ie+E.shift(),pe=ae+E.shift(),ge=Ce+E.shift(),L=pe+E.shift(),N=ge+E.shift(),E.shift(),w.curveTo(p,b,x,A,fe,Ie),w.curveTo(ae,Ce,pe,ge,L,N);break;case 34:p=L+E.shift(),b=N,x=p+E.shift(),A=b+E.shift(),fe=x+E.shift(),Ie=A,ae=fe+E.shift(),Ce=A,pe=ae+E.shift(),ge=N,L=pe+E.shift(),w.curveTo(p,b,x,A,fe,Ie),w.curveTo(ae,Ce,pe,ge,L,N);break;case 36:p=L+E.shift(),b=N+E.shift(),x=p+E.shift(),A=b+E.shift(),fe=x+E.shift(),Ie=A,ae=fe+E.shift(),Ce=A,pe=ae+E.shift(),ge=Ce+E.shift(),L=pe+E.shift(),w.curveTo(p,b,x,A,fe,Ie),w.curveTo(ae,Ce,pe,ge,L,N);break;case 37:p=L+E.shift(),b=N+E.shift(),x=p+E.shift(),A=b+E.shift(),fe=x+E.shift(),Ie=A+E.shift(),ae=fe+E.shift(),Ce=Ie+E.shift(),pe=ae+E.shift(),ge=Ce+E.shift(),Math.abs(pe-L)>Math.abs(ge-N)?L=pe+E.shift():N=ge+E.shift(),w.curveTo(p,b,x,A,fe,Ie),w.curveTo(ae,Ce,pe,ge,L,N);break;default:console.log("Glyph "+o.index+": unknown operator 1200"+Pe),E.length=0}break;case 14:if(h>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(E.length>=4){let Rn=_i[E.pop()],Qn=_i[E.pop()],yr=E.pop(),br=E.pop();if(Rn&&Qn){o.isComposite=!0,o.components=[];let eu=s.cffEncoding.charset.indexOf(Rn),nu=s.cffEncoding.charset.indexOf(Qn);o.components.push({glyphIndex:nu,dx:0,dy:0}),o.components.push({glyphIndex:eu,dx:br,dy:yr}),w.extend(s.glyphs.get(nu).path);let nb=s.glyphs.get(eu),ao=JSON.parse(JSON.stringify(nb.path.commands));for(let lo=0;lo<ao.length;lo+=1){let Xe=ao[lo];Xe.type!=="Z"&&(Xe.x+=br,Xe.y+=yr),(Xe.type==="Q"||Xe.type==="C")&&(Xe.x1+=br,Xe.y1+=yr),Xe.type==="C"&&(Xe.x2+=br,Xe.y2+=yr)}w.extend(ao)}}else E.length>0&&!R&&(Rt=E.shift()+At,R=!0);F&&Ne!==2&&(w.closePath(),F=!1);break;case 15:if(h<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}It=E.pop();break;case 16:if(h<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}Gt||(Gt=s.variation&&d&&s.variation.process.getBlendVector(Ut,It,d));var Wt=E.pop(),ye=Gt?Gt.length:Ut.itemVariationSubtables[It].regionIndexes.length,Re=Wt*ye,Be=E.length-Re,en=Be-Wt;if(Gt)for(let Rn=0;Rn<Wt;Rn++){var tu=E[en+Rn];for(let Qn=0;Qn<ye;Qn++)tu+=Gt[Qn]*E[Be++];E[en+Rn]=tu}for(;Re--;)E.pop();break;case 18:de();break;case 19:case 20:de(),Zt+=P+7>>3;break;case 21:E.length>2&&!R&&(Rt=E.shift()+At,R=!0),N+=E.pop(),L+=E.pop(),Te(L,N);break;case 22:E.length>1&&!R&&(Rt=E.shift()+At,R=!0),L+=E.pop(),Te(L,N);break;case 23:de();break;case 24:for(;E.length>2;)p=L+E.shift(),b=N+E.shift(),x=p+E.shift(),A=b+E.shift(),L=x+E.shift(),N=A+E.shift(),w.curveTo(p,b,x,A,L,N);L+=E.shift(),N+=E.shift(),w.lineTo(L,N);break;case 25:for(;E.length>6;)L+=E.shift(),N+=E.shift(),w.lineTo(L,N);p=L+E.shift(),b=N+E.shift(),x=p+E.shift(),A=b+E.shift(),L=x+E.shift(),N=A+E.shift(),w.curveTo(p,b,x,A,L,N);break;case 26:for(E.length&1&&(L+=E.shift());E.length>0;)p=L,b=N+E.shift(),x=p+E.shift(),A=b+E.shift(),L=x,N=A+E.shift(),w.curveTo(p,b,x,A,L,N);break;case 27:for(E.length&1&&(N+=E.shift());E.length>0;)p=L+E.shift(),b=N,x=p+E.shift(),A=b+E.shift(),L=x+E.shift(),N=A,w.curveTo(p,b,x,A,L,N);break;case 28:ft=ct[Zt],oe=ct[Zt+1],E.push((ft<<24|oe<<16)>>16),Zt+=2;break;case 29:if(In=E.pop()+s.gsubrsBias,Ue=s.gsubrs[In],Ue){if(Ht>=Dl){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}Ht++,xt(Ue),Ht--}break;case 30:for(;E.length>0&&(p=L,b=N+E.shift(),x=p+E.shift(),A=b+E.shift(),L=x+E.shift(),N=A+(E.length===1?E.shift():0),w.curveTo(p,b,x,A,L,N),E.length!==0);)p=L+E.shift(),b=N,x=p+E.shift(),A=b+E.shift(),N=A+E.shift(),L=x+(E.length===1?E.shift():0),w.curveTo(p,b,x,A,L,N);break;case 31:for(;E.length>0&&(p=L+E.shift(),b=N,x=p+E.shift(),A=b+E.shift(),N=A+E.shift(),L=x+(E.length===1?E.shift():0),w.curveTo(p,b,x,A,L,N),E.length!==0);)p=L,b=N+E.shift(),x=p+E.shift(),A=b+E.shift(),L=x+E.shift(),N=A+(E.length===1?E.shift():0),w.curveTo(p,b,x,A,L,N);break;default:Pe<32?console.log("Glyph "+o.index+": unknown operator "+Pe):Pe<247?E.push(Pe-139):Pe<251?(ft=ct[Zt],Zt+=1,E.push((Pe-247)*256+ft+108)):Pe<255?(ft=ct[Zt],Zt+=1,E.push(-(Pe-251)*256-ft-108)):(ft=ct[Zt],oe=ct[Zt+1],fn=ct[Zt+2],mr=ct[Zt+3],Zt+=4,E.push((ft<<24|oe<<16|fn<<8|mr)/65536))}}}return xt(c),s.variation&&d&&(w.commands=w.commands.map(ct=>{let ft=Object.keys(ct);for(let oe=0;oe<ft.length;oe++){let fn=ft[oe];fn!=="type"&&(ct[fn]=Math.round(ct[fn]))}return ct})),R&&(o.advanceWidth=Rt),w}function Hl(s,o,c,h,d){let p=[],b,x=new rt.Parser(s,o),A=x.parseCard8();if(A===0)for(let w=0;w<c;w++){if(b=x.parseCard8(),b>=h)throw new Error("CFF table CID Font FDSelect has bad FD index value "+b+" (FD count "+h+")");p.push(b)}else if(A===3||d>1&&A===4){let w=A===4?x.parseULong():x.parseCard16(),E=A===4?x.parseULong():x.parseCard16();if(E!==0)throw new Error(`CFF Table CID Font FDSelect format ${A} range has bad initial GID ${E}`);let P;for(let R=0;R<w;R++){if(b=A===4?x.parseUShort():x.parseCard8(),P=A===4?x.parseULong():x.parseCard16(),b>=h)throw new Error("CFF table CID Font FDSelect has bad FD index value "+b+" (FD count "+h+")");if(P>c)throw new Error(`CFF Table CID Font FDSelect format ${d} range has bad GID ${P}`);for(;E<P;E++)p.push(b);E=P}if(P!==c)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final (Sentinal) GID "+P)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+A);return p}function xf(s,o,c,h){let d,p=df(s,o);p.formatMajor===2?d=c.tables.cff2={}:d=c.tables.cff={};let b=p.formatMajor>1?null:$e(s,p.endOffset,rt.bytesToString),x=p.formatMajor>1?null:$e(s,b.endOffset),A=p.formatMajor>1?null:$e(s,x.endOffset,rt.bytesToString),w=$e(s,p.formatMajor>1?o+p.size+p.topDictLength:A.endOffset,void 0,p.formatMajor);c.gsubrs=w.objects,c.gsubrsBias=or(c.gsubrs);let E;if(p.formatMajor>1){let R=o+p.size,F=rt.getBytes(s,R,R+p.topDictLength);E=ji(s,0,[F],void 0,p.formatMajor)[0]}else{let R=ji(s,o,x.objects,A.objects,p.formatMajor);if(R.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+R.length);E=R[0]}if(d.topDict=E,E._privateDict&&(c.defaultWidthX=E._privateDict.defaultWidthX,c.nominalWidthX=E._privateDict.nominalWidthX),p.formatMajor<2&&E.ros[0]!==void 0&&E.ros[1]!==void 0&&(c.isCIDFont=!0),p.formatMajor>1){let R=E.fdArray,F=E.fdSelect;if(!R)throw new Error("This is a CFF2 font, but FDArray information is missing");let L=$e(s,o+R,null,p.formatMajor),N=mf(s,o,L.objects);E._fdArray=N,F&&(E._fdSelect=Hl(s,o+F,c.numGlyphs,N.length,p.formatMajor))}else if(c.isCIDFont){let R=E.fdArray,F=E.fdSelect;if(R===0||F===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");R+=o;let L=$e(s,R),N=ji(s,o,L.objects,A.objects,p.formatMajor);E._fdArray=N,F+=o,E._fdSelect=Hl(s,F,c.numGlyphs,N.length,p.formatMajor)}if(p.formatMajor<2){let R=o+E.private[1],F=Hi(s,R,E.private[0],A.objects,p.formatMajor);if(c.defaultWidthX=F.defaultWidthX,c.nominalWidthX=F.nominalWidthX,F.subrs!==0){let L=R+F.subrs,N=$e(s,L);c.subrs=N.objects,c.subrsBias=or(c.subrs)}else c.subrs=[],c.subrsBias=0}let P;if(h.lowMemory?(P=af(s,o+E.charStrings,p.formatMajor),c.nGlyphs=P.offsets.length-(p.formatMajor>1?1:0)):(P=$e(s,o+E.charStrings,null,p.formatMajor),c.nGlyphs=P.objects.length),p.formatMajor>1&&c.tables.maxp&&c.nGlyphs!==c.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${c.nGlyphs}) must correspond to the glyph count in the maxp table (${c.tables.maxp.numGlyphs})`),p.formatMajor<2){let R=[],F=[];E.charset===0?R=Wd:E.charset===1?R=$d:E.charset===2?R=zd:R=yf(s,o+E.charset,c.nGlyphs,A.objects,c.isCIDFont),E.encoding===0?F=_i:E.encoding===1?F=Xd:F=bf(s,o+E.encoding),c.cffEncoding=new Pl(F,R),c.encoding=c.encoding||c.cffEncoding}if(c.glyphs=new We.GlyphSet(c),h.lowMemory)c._push=function(R){let F=lf(R,P.offsets,s,o+E.charStrings,void 0,p.formatMajor);c.glyphs.push(R,We.cffGlyphLoader(c,R,Vi,F,p.formatMajor))};else for(let R=0;R<c.nGlyphs;R+=1){let F=P.objects[R];c.glyphs.push(R,We.cffGlyphLoader(c,R,Vi,F,p.formatMajor))}if(E.vstore){let R=new rt.Parser(s,o+E.vstore);E._vstore=R.parseVariationStore()}}function jl(s,o){let c,h=sr.indexOf(s);return h>=0&&(c=h),h=o.indexOf(s),h>=0?c=h+sr.length:(c=sr.length+o.length,o.push(s)),c}function Sf(){return new J.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function Af(s){let o=new J.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);o.names=[];for(let c=0;c<s.length;c+=1)o.names.push({name:"name_"+c,type:"NAME",value:s[c]});return o}function Vl(s,o,c){let h={};for(let d=0;d<s.length;d+=1){let p=s[d],b=o[p.name];b!==void 0&&!Fl(b,p.value)&&(p.type==="SID"&&(b=jl(b,c)),h[p.op]={name:p.name,type:p.type,value:b})}return h}function Wl(s,o,c){let h=new J.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return h.dict=Vl(c>1?Nl:_l,s,o),h}function $l(s){let o=new J.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return o.topDicts=[{name:"topDict_0",type:"TABLE",value:s}],o}function Tf(s){let o=new J.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);o.strings=[];for(let c=0;c<s.length;c+=1)o.strings.push({name:"string_"+c,type:"STRING",value:s[c]});return o}function Cf(){return new J.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function Ef(s,o){let c=new J.Record("Charsets",[{name:"format",type:"Card8",value:0}]);for(let h=0;h<s.length;h+=1){let d=s[h],p=jl(d,o);c.fields.push({name:"glyph_"+h,type:"SID",value:p})}return c}function wf(s,o){let c=[],h=s.path;o<2&&c.push({name:"width",type:"NUMBER",value:s.advanceWidth});let d=0,p=0;for(let b=0;b<h.commands.length;b+=1){let x,A,w=h.commands[b];if(w.type==="Q"){let E=.3333333333333333,P=2/3;w={type:"C",x:w.x,y:w.y,x1:Math.round(E*d+P*w.x1),y1:Math.round(E*p+P*w.y1),x2:Math.round(E*w.x+P*w.x1),y2:Math.round(E*w.y+P*w.y1)}}if(w.type==="M")x=Math.round(w.x-d),A=Math.round(w.y-p),c.push({name:"dx",type:"NUMBER",value:x}),c.push({name:"dy",type:"NUMBER",value:A}),c.push({name:"rmoveto",type:"OP",value:21}),d=Math.round(w.x),p=Math.round(w.y);else if(w.type==="L")x=Math.round(w.x-d),A=Math.round(w.y-p),c.push({name:"dx",type:"NUMBER",value:x}),c.push({name:"dy",type:"NUMBER",value:A}),c.push({name:"rlineto",type:"OP",value:5}),d=Math.round(w.x),p=Math.round(w.y);else if(w.type==="C"){let E=Math.round(w.x1-d),P=Math.round(w.y1-p),R=Math.round(w.x2-w.x1),F=Math.round(w.y2-w.y1);x=Math.round(w.x-w.x2),A=Math.round(w.y-w.y2),c.push({name:"dx1",type:"NUMBER",value:E}),c.push({name:"dy1",type:"NUMBER",value:P}),c.push({name:"dx2",type:"NUMBER",value:R}),c.push({name:"dy2",type:"NUMBER",value:F}),c.push({name:"dx",type:"NUMBER",value:x}),c.push({name:"dy",type:"NUMBER",value:A}),c.push({name:"rrcurveto",type:"OP",value:8}),d=Math.round(w.x),p=Math.round(w.y)}}return o<2&&c.push({name:"endchar",type:"OP",value:14}),c}function kf(s,o){let c=new J.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]);for(let h=0;h<s.length;h+=1){let d=s.get(h),p=wf(d,o);c.charStrings.push({name:d.name,type:"CHARSTRING",value:p})}return c}function If(s,o,c){let h=new J.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return h.dict=Vl(c>1?Bl:Ul,s,o),h}function Rf(s,o){let h=new J.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),d=1/o.unitsPerEm,p={version:o.version,fullName:o.fullName,familyName:o.familyName,weight:o.weightName,fontBBox:o.fontBBox||[0,0,0,0],fontMatrix:[d,0,0,d,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},b=o&&o.topDict||{};b.paintType&&(p.paintType=b.paintType,p.strokeWidth=b.strokeWidth||0);let x={},A=[],w;for(let F=1;F<s.length;F+=1)w=s.get(F),A.push(w.name);let E=[];h.header=Sf(),h.nameIndex=Af([o.postScriptName]);let P=Wl(p,E);h.topDictIndex=$l(P),h.globalSubrIndex=Cf(),h.charsets=Ef(A,E),h.charStringsIndex=kf(s,1),h.privateDict=If(x,E),h.stringIndex=Tf(E);let R=h.header.sizeOf()+h.nameIndex.sizeOf()+h.topDictIndex.sizeOf()+h.stringIndex.sizeOf()+h.globalSubrIndex.sizeOf();return p.charset=R,p.encoding=0,p.charStrings=p.charset+h.charsets.sizeOf(),p.private[1]=p.charStrings+h.charStringsIndex.sizeOf(),P=Wl(p,E),h.topDictIndex=$l(P),h}var Wi={parse:xf,make:Rf};function Pf(s,o){let c={},h=new rt.Parser(s,o);return c.version=h.parseVersion(),c.fontRevision=Math.round(h.parseFixed()*1e3)/1e3,c.checkSumAdjustment=h.parseULong(),c.magicNumber=h.parseULong(),U.argument(c.magicNumber===1594834165,"Font header has wrong magic number."),c.flags=h.parseUShort(),c.unitsPerEm=h.parseUShort(),c.created=h.parseLongDateTime(),c.modified=h.parseLongDateTime(),c.xMin=h.parseShort(),c.yMin=h.parseShort(),c.xMax=h.parseShort(),c.yMax=h.parseShort(),c.macStyle=h.parseUShort(),c.lowestRecPPEM=h.parseUShort(),c.fontDirectionHint=h.parseShort(),c.indexToLocFormat=h.parseShort(),c.glyphDataFormat=h.parseShort(),c}function Of(s){let o=Math.round(new Date().getTime()/1e3)+2082844800,c=o,h=s.macStyle||0;return s.createdTimestamp&&(c=s.createdTimestamp+2082844800),new J.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:c},{name:"modified",type:"LONGDATETIME",value:o},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value:h},{name:"lowestRecPPEM",type:"USHORT",value:0},{name:"fontDirectionHint",type:"SHORT",value:2},{name:"indexToLocFormat",type:"SHORT",value:0},{name:"glyphDataFormat",type:"SHORT",value:0}],s)}var zl={parse:Pf,make:Of};function Mf(s,o){let c={},h=new rt.Parser(s,o);return c.version=h.parseVersion(),c.ascender=h.parseShort(),c.descender=h.parseShort(),c.lineGap=h.parseShort(),c.advanceWidthMax=h.parseUShort(),c.minLeftSideBearing=h.parseShort(),c.minRightSideBearing=h.parseShort(),c.xMaxExtent=h.parseShort(),c.caretSlopeRise=h.parseShort(),c.caretSlopeRun=h.parseShort(),c.caretOffset=h.parseShort(),h.relativeOffset+=8,c.metricDataFormat=h.parseShort(),c.numberOfHMetrics=h.parseUShort(),c}function Lf(s){return new J.Table("hhea",[{name:"version",type:"FIXED",value:65536},{name:"ascender",type:"FWORD",value:0},{name:"descender",type:"FWORD",value:0},{name:"lineGap",type:"FWORD",value:0},{name:"advanceWidthMax",type:"UFWORD",value:0},{name:"minLeftSideBearing",type:"FWORD",value:0},{name:"minRightSideBearing",type:"FWORD",value:0},{name:"xMaxExtent",type:"FWORD",value:0},{name:"caretSlopeRise",type:"SHORT",value:1},{name:"caretSlopeRun",type:"SHORT",value:0},{name:"caretOffset",type:"SHORT",value:0},{name:"reserved1",type:"SHORT",value:0},{name:"reserved2",type:"SHORT",value:0},{name:"reserved3",type:"SHORT",value:0},{name:"reserved4",type:"SHORT",value:0},{name:"metricDataFormat",type:"SHORT",value:0},{name:"numberOfHMetrics",type:"USHORT",value:0}],s)}var Xl={parse:Mf,make:Lf};function Ff(s,o,c,h,d){let p,b,x=new rt.Parser(s,o);for(let A=0;A<h;A+=1){A<c&&(p=x.parseUShort(),b=x.parseShort());let w=d.get(A);w.advanceWidth=p,w.leftSideBearing=b}}function Df(s,o,c,h,d){s._hmtxTableData={};let p,b,x=new rt.Parser(o,c);for(let A=0;A<d;A+=1)A<h&&(p=x.parseUShort(),b=x.parseShort()),s._hmtxTableData[A]={advanceWidth:p,leftSideBearing:b}}function _f(s,o,c,h,d,p,b){b.lowMemory?Df(s,o,c,h,d):Ff(o,c,h,d,p)}function Nf(s){let o=new J.Table("hmtx",[]);for(let c=0;c<s.length;c+=1){let h=s.get(c),d=h.advanceWidth||0,p=h.leftSideBearing||0;o.fields.push({name:"advanceWidth_"+c,type:"USHORT",value:d}),o.fields.push({name:"leftSideBearing_"+c,type:"SHORT",value:p})}return o}var Yl={parse:_f,make:Nf};function Uf(s){let o=new J.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:s.length}]),c="",h=12+s.length*4;for(let d=0;d<s.length;++d){let p=c.indexOf(s[d]);p<0&&(p=c.length,c+=s[d]),o.fields.push({name:"offset "+d,type:"USHORT",value:h+p}),o.fields.push({name:"length "+d,type:"USHORT",value:s[d].length})}return o.fields.push({name:"stringPool",type:"CHARARRAY",value:c}),o}function Bf(s,o){let c=new rt.Parser(s,o),h=c.parseULong();U.argument(h===1,"Unsupported ltag table version."),c.skip("uLong",1);let d=c.parseULong(),p=[];for(let b=0;b<d;b++){let x="",A=o+c.parseUShort(),w=c.parseUShort();for(let E=A;E<A+w;++E)x+=String.fromCharCode(s.getInt8(E));p.push(x)}return p}var Kl={make:Uf,parse:Bf};function Gf(s,o){let c={},h=new rt.Parser(s,o);return c.version=h.parseVersion(),c.numGlyphs=h.parseUShort(),c.version===1&&(c.maxPoints=h.parseUShort(),c.maxContours=h.parseUShort(),c.maxCompositePoints=h.parseUShort(),c.maxCompositeContours=h.parseUShort(),c.maxZones=h.parseUShort(),c.maxTwilightPoints=h.parseUShort(),c.maxStorage=h.parseUShort(),c.maxFunctionDefs=h.parseUShort(),c.maxInstructionDefs=h.parseUShort(),c.maxStackElements=h.parseUShort(),c.maxSizeOfInstructions=h.parseUShort(),c.maxComponentElements=h.parseUShort(),c.maxComponentDepth=h.parseUShort()),c}function Hf(s){return new J.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:s}])}var Zl={parse:Gf,make:Hf},$i=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}];function jf(s){for(let o=0;o<$i.length;o+=1){let c=$i[o];if(s>=c.begin&&s<c.end)return o}return-1}function Vf(s,o){let c={},h=new rt.Parser(s,o);c.version=h.parseUShort(),c.xAvgCharWidth=h.parseShort(),c.usWeightClass=h.parseUShort(),c.usWidthClass=h.parseUShort(),c.fsType=h.parseUShort(),c.ySubscriptXSize=h.parseShort(),c.ySubscriptYSize=h.parseShort(),c.ySubscriptXOffset=h.parseShort(),c.ySubscriptYOffset=h.parseShort(),c.ySuperscriptXSize=h.parseShort(),c.ySuperscriptYSize=h.parseShort(),c.ySuperscriptXOffset=h.parseShort(),c.ySuperscriptYOffset=h.parseShort(),c.yStrikeoutSize=h.parseShort(),c.yStrikeoutPosition=h.parseShort(),c.sFamilyClass=h.parseShort(),c.panose=[];for(let d=0;d<10;d++)c.panose[d]=h.parseByte();return c.ulUnicodeRange1=h.parseULong(),c.ulUnicodeRange2=h.parseULong(),c.ulUnicodeRange3=h.parseULong(),c.ulUnicodeRange4=h.parseULong(),c.achVendID=String.fromCharCode(h.parseByte(),h.parseByte(),h.parseByte(),h.parseByte()),c.fsSelection=h.parseUShort(),c.usFirstCharIndex=h.parseUShort(),c.usLastCharIndex=h.parseUShort(),c.sTypoAscender=h.parseShort(),c.sTypoDescender=h.parseShort(),c.sTypoLineGap=h.parseShort(),c.usWinAscent=h.parseUShort(),c.usWinDescent=h.parseUShort(),c.version>=1&&(c.ulCodePageRange1=h.parseULong(),c.ulCodePageRange2=h.parseULong()),c.version>=2&&(c.sxHeight=h.parseShort(),c.sCapHeight=h.parseShort(),c.usDefaultChar=h.parseUShort(),c.usBreakChar=h.parseUShort(),c.usMaxContent=h.parseUShort()),c}function Wf(s){return new J.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],s)}var zi={parse:Vf,make:Wf,unicodeRanges:$i,getUnicodeRange:jf};function $f(s,o){let c={},h=new rt.Parser(s,o);switch(c.version=h.parseVersion(),c.italicAngle=h.parseFixed(),c.underlinePosition=h.parseShort(),c.underlineThickness=h.parseShort(),c.isFixedPitch=h.parseULong(),c.minMemType42=h.parseULong(),c.maxMemType42=h.parseULong(),c.minMemType1=h.parseULong(),c.maxMemType1=h.parseULong(),c.version){case 1:c.names=Tn.slice();break;case 2:c.numberOfGlyphs=h.parseUShort(),c.glyphNameIndex=new Array(c.numberOfGlyphs);for(let d=0;d<c.numberOfGlyphs;d++)c.glyphNameIndex[d]=h.parseUShort();c.names=[];for(let d=0;d<c.numberOfGlyphs;d++)if(c.glyphNameIndex[d]>=Tn.length){let p=h.parseChar();c.names.push(h.parseString(p))}break;case 2.5:c.numberOfGlyphs=h.parseUShort(),c.offset=new Array(c.numberOfGlyphs);for(let d=0;d<c.numberOfGlyphs;d++)c.offset[d]=h.parseChar();break}return c}function zf(s){let{italicAngle:o=Math.round((s.italicAngle||0)*65536),underlinePosition:c=0,underlineThickness:h=0,isFixedPitch:d=0,minMemType42:p=0,maxMemType42:b=0,minMemType1:x=0,maxMemType1:A=0}=s.tables.post||{};return new J.Table("post",[{name:"version",type:"FIXED",value:196608},{name:"italicAngle",type:"FIXED",value:o},{name:"underlinePosition",type:"FWORD",value:c},{name:"underlineThickness",type:"FWORD",value:h},{name:"isFixedPitch",type:"ULONG",value:d},{name:"minMemType42",type:"ULONG",value:p},{name:"maxMemType42",type:"ULONG",value:b},{name:"minMemType1",type:"ULONG",value:x},{name:"maxMemType1",type:"ULONG",value:A}])}var Ql={parse:$f,make:zf},De=new Array(9);De[1]=function(){let o=this.offset+this.relativeOffset,c=this.parseUShort();if(c===1)return{substFormat:1,coverage:this.parsePointer(G.coverage),deltaGlyphId:this.parseShort()};if(c===2)return{substFormat:2,coverage:this.parsePointer(G.coverage),substitute:this.parseOffset16List()};U.assert(!1,"0x"+o.toString(16)+": lookup type 1 format must be 1 or 2.")},De[2]=function(){let o=this.parseUShort();return U.argument(o===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:o,coverage:this.parsePointer(G.coverage),sequences:this.parseListOfLists()}},De[3]=function(){let o=this.parseUShort();return U.argument(o===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:o,coverage:this.parsePointer(G.coverage),alternateSets:this.parseListOfLists()}},De[4]=function(){let o=this.parseUShort();return U.argument(o===1,"GSUB ligature table identifier-format must be 1"),{substFormat:o,coverage:this.parsePointer(G.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var Yn={sequenceIndex:G.uShort,lookupListIndex:G.uShort};De[5]=function(){let o=this.offset+this.relativeOffset,c=this.parseUShort();if(c===1)return{substFormat:c,coverage:this.parsePointer(G.coverage),ruleSets:this.parseListOfLists(function(){let h=this.parseUShort(),d=this.parseUShort();return{input:this.parseUShortList(h-1),lookupRecords:this.parseRecordList(d,Yn)}})};if(c===2)return{substFormat:c,coverage:this.parsePointer(G.coverage),classDef:this.parsePointer(G.classDef),classSets:this.parseListOfLists(function(){let h=this.parseUShort(),d=this.parseUShort();return{classes:this.parseUShortList(h-1),lookupRecords:this.parseRecordList(d,Yn)}})};if(c===3){let h=this.parseUShort(),d=this.parseUShort();return{substFormat:c,coverages:this.parseList(h,G.pointer(G.coverage)),lookupRecords:this.parseRecordList(d,Yn)}}U.assert(!1,"0x"+o.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},De[6]=function(){let o=this.offset+this.relativeOffset,c=this.parseUShort();if(c===1)return{substFormat:1,coverage:this.parsePointer(G.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Yn)}})};if(c===2)return{substFormat:2,coverage:this.parsePointer(G.coverage),backtrackClassDef:this.parsePointer(G.classDef),inputClassDef:this.parsePointer(G.classDef),lookaheadClassDef:this.parsePointer(G.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Yn)}})};if(c===3)return{substFormat:3,backtrackCoverage:this.parseList(G.pointer(G.coverage)),inputCoverage:this.parseList(G.pointer(G.coverage)),lookaheadCoverage:this.parseList(G.pointer(G.coverage)),lookupRecords:this.parseRecordList(Yn)};U.assert(!1,"0x"+o.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},De[7]=function(){let o=this.parseUShort();U.argument(o===1,"GSUB Extension Substitution subtable identifier-format must be 1");let c=this.parseUShort(),h=new G(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:c,extension:De[c].call(h)}},De[8]=function(){let o=this.parseUShort();return U.argument(o===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:o,coverage:this.parsePointer(G.coverage),backtrackCoverage:this.parseList(G.pointer(G.coverage)),lookaheadCoverage:this.parseList(G.pointer(G.coverage)),substitutes:this.parseUShortList()}};function Xf(s,o){o=o||0;let c=new G(s,o),h=c.parseVersion(1);return U.argument(h===1||h===1.1,"Unsupported GSUB table version."),h===1?{version:h,scripts:c.parseScriptList(),features:c.parseFeatureList(),lookups:c.parseLookupList(De)}:{version:h,scripts:c.parseScriptList(),features:c.parseFeatureList(),lookups:c.parseLookupList(De),variations:c.parseFeatureVariationsList()}}var En=new Array(9);En[1]=function(o){if(o.substFormat===1)return new J.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new J.Coverage(o.coverage)},{name:"deltaGlyphID",type:"SHORT",value:o.deltaGlyphId}]);if(o.substFormat===2)return new J.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new J.Coverage(o.coverage)}].concat(J.ushortList("substitute",o.substitute)));U.fail("Lookup type 1 substFormat must be 1 or 2.")},En[2]=function(o){return U.assert(o.substFormat===1,"Lookup type 2 substFormat must be 1."),new J.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new J.Coverage(o.coverage)}].concat(J.tableList("seqSet",o.sequences,function(c){return new J.Table("sequenceSetTable",J.ushortList("sequence",c))})))},En[3]=function(o){return U.assert(o.substFormat===1,"Lookup type 3 substFormat must be 1."),new J.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new J.Coverage(o.coverage)}].concat(J.tableList("altSet",o.alternateSets,function(c){return new J.Table("alternateSetTable",J.ushortList("alternate",c))})))},En[4]=function(o){return U.assert(o.substFormat===1,"Lookup type 4 substFormat must be 1."),new J.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new J.Coverage(o.coverage)}].concat(J.tableList("ligSet",o.ligatureSets,function(c){return new J.Table("ligatureSetTable",J.tableList("ligature",c,function(h){return new J.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:h.ligGlyph}].concat(J.ushortList("component",h.components,h.components.length+1)))}))})))},En[5]=function(o){if(o.substFormat===1)return new J.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:o.substFormat},{name:"coverage",type:"TABLE",value:new J.Coverage(o.coverage)}].concat(J.tableList("sequenceRuleSet",o.ruleSets,function(c){return c?new J.Table("sequenceRuleSetTable",J.tableList("sequenceRule",c,function(h){let d=J.ushortList("seqLookup",[],h.lookupRecords.length).concat(J.ushortList("inputSequence",h.input,h.input.length+1));[d[0],d[1]]=[d[1],d[0]];for(let p=0;p<h.lookupRecords.length;p++){let b=h.lookupRecords[p];d=d.concat({name:"sequenceIndex"+p,type:"USHORT",value:b.sequenceIndex}).concat({name:"lookupListIndex"+p,type:"USHORT",value:b.lookupListIndex})}return new J.Table("sequenceRuleTable",d)})):new J.Table("NULL",null)})));if(o.substFormat===2)return new J.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:o.substFormat},{name:"coverage",type:"TABLE",value:new J.Coverage(o.coverage)},{name:"classDef",type:"TABLE",value:new J.ClassDef(o.classDef)}].concat(J.tableList("classSeqRuleSet",o.classSets,function(c){return c?new J.Table("classSeqRuleSetTable",J.tableList("classSeqRule",c,function(h){let d=J.ushortList("classes",h.classes,h.classes.length+1).concat(J.ushortList("seqLookupCount",[],h.lookupRecords.length));for(let p=0;p<h.lookupRecords.length;p++){let b=h.lookupRecords[p];d=d.concat({name:"sequenceIndex"+p,type:"USHORT",value:b.sequenceIndex}).concat({name:"lookupListIndex"+p,type:"USHORT",value:b.lookupListIndex})}return new J.Table("classSeqRuleTable",d)})):new J.Table("NULL",null)})));if(o.substFormat===3){let c=[{name:"substFormat",type:"USHORT",value:o.substFormat}];c.push({name:"inputGlyphCount",type:"USHORT",value:o.coverages.length}),c.push({name:"substitutionCount",type:"USHORT",value:o.lookupRecords.length});for(let d=0;d<o.coverages.length;d++){let p=o.coverages[d];c.push({name:"inputCoverage"+d,type:"TABLE",value:new J.Coverage(p)})}for(let d=0;d<o.lookupRecords.length;d++){let p=o.lookupRecords[d];c=c.concat({name:"sequenceIndex"+d,type:"USHORT",value:p.sequenceIndex}).concat({name:"lookupListIndex"+d,type:"USHORT",value:p.lookupListIndex})}return new J.Table("contextualSubstitutionTable",c)}U.assert(!1,"lookup type 5 format must be 1, 2 or 3.")},En[6]=function(o){if(o.substFormat===1)return new J.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:o.substFormat},{name:"coverage",type:"TABLE",value:new J.Coverage(o.coverage)}].concat(J.tableList("chainRuleSet",o.chainRuleSets,function(h){return new J.Table("chainRuleSetTable",J.tableList("chainRule",h,function(d){let p=J.ushortList("backtrackGlyph",d.backtrack,d.backtrack.length).concat(J.ushortList("inputGlyph",d.input,d.input.length+1)).concat(J.ushortList("lookaheadGlyph",d.lookahead,d.lookahead.length)).concat(J.ushortList("substitution",[],d.lookupRecords.length));for(let b=0;b<d.lookupRecords.length;b++){let x=d.lookupRecords[b];p=p.concat({name:"sequenceIndex"+b,type:"USHORT",value:x.sequenceIndex}).concat({name:"lookupListIndex"+b,type:"USHORT",value:x.lookupListIndex})}return new J.Table("chainRuleTable",p)}))})));if(o.substFormat===2)U.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(o.substFormat===3){let c=[{name:"substFormat",type:"USHORT",value:o.substFormat}];c.push({name:"backtrackGlyphCount",type:"USHORT",value:o.backtrackCoverage.length});for(let d=0;d<o.backtrackCoverage.length;d++){let p=o.backtrackCoverage[d];c.push({name:"backtrackCoverage"+d,type:"TABLE",value:new J.Coverage(p)})}c.push({name:"inputGlyphCount",type:"USHORT",value:o.inputCoverage.length});for(let d=0;d<o.inputCoverage.length;d++){let p=o.inputCoverage[d];c.push({name:"inputCoverage"+d,type:"TABLE",value:new J.Coverage(p)})}c.push({name:"lookaheadGlyphCount",type:"USHORT",value:o.lookaheadCoverage.length});for(let d=0;d<o.lookaheadCoverage.length;d++){let p=o.lookaheadCoverage[d];c.push({name:"lookaheadCoverage"+d,type:"TABLE",value:new J.Coverage(p)})}c.push({name:"substitutionCount",type:"USHORT",value:o.lookupRecords.length});for(let d=0;d<o.lookupRecords.length;d++){let p=o.lookupRecords[d];c=c.concat({name:"sequenceIndex"+d,type:"USHORT",value:p.sequenceIndex}).concat({name:"lookupListIndex"+d,type:"USHORT",value:p.lookupListIndex})}return new J.Table("chainContextTable",c)}U.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function Yf(s){return new J.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new J.ScriptList(s.scripts)},{name:"features",type:"TABLE",value:new J.FeatureList(s.features)},{name:"lookups",type:"TABLE",value:new J.LookupList(s.lookups,En)}])}var Jl={parse:Xf,make:Yf};function Kf(s,o){let c=new rt.Parser(s,o),h=c.parseULong();U.argument(h===1,"Unsupported META table version."),c.parseULong(),c.parseULong();let d=c.parseULong(),p={};for(let b=0;b<d;b++){let x=c.parseTag(),A=c.parseULong(),w=c.parseULong();if(x==="appl"||x==="bild")continue;let E=Dt.UTF8(s,o+A,w);p[x]=E}return p}function Zf(s){let o=Object.keys(s).length,c="",h=16+o*12,d=new J.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:h},{name:"numTags",type:"ULONG",value:o}]);for(let p in s){let b=c.length;c+=s[p],d.fields.push({name:"tag "+p,type:"TAG",value:p}),d.fields.push({name:"offset "+p,type:"ULONG",value:h+b}),d.fields.push({name:"length "+p,type:"ULONG",value:s[p].length})}return d.fields.push({name:"stringPool",type:"CHARARRAY",value:c}),d}var ql={parse:Kf,make:Zf};function Qf(s,o){let c=new G(s,o),h=c.parseUShort();h!==0&&console.warn("Only COLRv0 is currently fully supported. A subset of color glyphs might be available in this font if provided in the v0 format.");let d=c.parseUShort(),p=c.parseOffset32(),b=c.parseOffset32(),x=c.parseUShort();c.relativeOffset=p;let A=c.parseRecordList(d,{glyphID:G.uShort,firstLayerIndex:G.uShort,numLayers:G.uShort});c.relativeOffset=b;let w=c.parseRecordList(x,{glyphID:G.uShort,paletteIndex:G.uShort});return{version:h,baseGlyphRecords:A,layerRecords:w}}function Jf({version:s=0,baseGlyphRecords:o=[],layerRecords:c=[]}){U.argument(s===0,"Only COLRv0 supported.");let h=14,d=h+o.length*6;return new J.Table("COLR",[{name:"version",type:"USHORT",value:s},{name:"numBaseGlyphRecords",type:"USHORT",value:o.length},{name:"baseGlyphRecordsOffset",type:"ULONG",value:h},{name:"layerRecordsOffset",type:"ULONG",value:d},{name:"numLayerRecords",type:"USHORT",value:c.length},...o.map((p,b)=>[{name:"glyphID_"+b,type:"USHORT",value:p.glyphID},{name:"firstLayerIndex_"+b,type:"USHORT",value:p.firstLayerIndex},{name:"numLayers_"+b,type:"USHORT",value:p.numLayers}]).flat(),...c.map((p,b)=>[{name:"LayerGlyphID_"+b,type:"USHORT",value:p.glyphID},{name:"paletteIndex_"+b,type:"USHORT",value:p.paletteIndex}]).flat()])}var tc={parse:Qf,make:Jf};function qf(s,o){return[{name:"tag_"+s,type:"TAG",value:o.tag},{name:"minValue_"+s,type:"FIXED",value:o.minValue<<16},{name:"defaultValue_"+s,type:"FIXED",value:o.defaultValue<<16},{name:"maxValue_"+s,type:"FIXED",value:o.maxValue<<16},{name:"flags_"+s,type:"USHORT",value:0},{name:"nameID_"+s,type:"USHORT",value:o.axisNameID}]}function tp(s,o,c){let h={},d=new rt.Parser(s,o);h.tag=d.parseTag(),h.minValue=d.parseFixed(),h.defaultValue=d.parseFixed(),h.maxValue=d.parseFixed(),d.skip("uShort",1);let p=d.parseUShort();return h.axisNameID=p,h.name=nr(c,p),h}function ep(s,o,c,h={}){let d=[{name:"nameID_"+s,type:"USHORT",value:o.subfamilyNameID},{name:"flags_"+s,type:"USHORT",value:0}];for(let p=0;p<c.length;++p){let b=c[p].tag;d.push({name:"axis_"+s+" "+b,type:"FIXED",value:o.coordinates[b]<<16})}return h&&h.postScriptNameID&&d.push({name:"postScriptNameID_",type:"USHORT",value:o.postScriptNameID!==void 0?o.postScriptNameID:65535}),d}function np(s,o,c,h,d){let p={},b=new rt.Parser(s,o),x=b.parseUShort();p.subfamilyNameID=x,p.name=nr(h,x,[2,17]),b.skip("uShort",1),p.coordinates={};for(let w=0;w<c.length;++w)p.coordinates[c[w].tag]=b.parseFixed();if(b.relativeOffset===d)return p.postScriptNameID=void 0,p.postScriptName=void 0,p;let A=b.parseUShort();return p.postScriptNameID=A==65535?void 0:A,p.postScriptName=p.postScriptNameID!==void 0?nr(h,A,[6]):"",p}function sp(s,o){let c=new J.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:s.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:s.instances.length},{name:"instanceSize",type:"USHORT",value:4+s.axes.length*4}]);c.offsetToData=c.sizeOf();for(let d=0;d<s.axes.length;d++)c.fields=c.fields.concat(qf(d,s.axes[d],o));let h={};for(let d=0;d<s.instances.length;d++)if(s.instances[d].postScriptNameID!==void 0){c.instanceSize+=2,h.postScriptNameID=!0;break}for(let d=0;d<s.instances.length;d++)c.fields=c.fields.concat(ep(d,s.instances[d],s.axes,h));return c}function rp(s,o,c){let h=new rt.Parser(s,o),d=h.parseULong();U.argument(d===65536,"Unsupported fvar table version.");let p=h.parseOffset16();h.skip("uShort",1);let b=h.parseUShort(),x=h.parseUShort(),A=h.parseUShort(),w=h.parseUShort(),E=[];for(let F=0;F<b;F++)E.push(tp(s,o+p+F*x,c));let P=[],R=o+p+b*x;for(let F=0;F<A;F++)P.push(np(s,R+F*w,E,c,w));return{axes:E,instances:P}}var ec={make:sp,parse:rp},ip={tag:G.tag,nameID:G.uShort,ordering:G.uShort},us=new Array(5);us[1]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed()}},us[2]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),nominalValue:this.parseFixed(),rangeMinValue:this.parseFixed(),rangeMaxValue:this.parseFixed()}},us[3]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed(),linkedValue:this.parseFixed()}},us[4]=function(){let o=this.parseUShort();return{flags:this.parseUShort(),valueNameID:this.parseUShort(),axisValues:this.parseList(o,function(){return{axisIndex:this.parseUShort(),value:this.parseFixed()}})}};function op(){let s=this.parseUShort(),o=us[s],c={format:s};return o===void 0?(console.warn(`Unknown axis value table format ${s}`),c):Object.assign(c,this.parseStruct(o.bind(this)))}function ap(s,o,c){o||(o=0);let h=new rt.Parser(s,o),d=h.parseUShort(),p=h.parseUShort();d!==1&&console.warn(`Unsupported STAT table version ${d}.${p}`);let b=[d,p],x=h.parseUShort(),A=h.parseUShort(),w=h.parseOffset32(),E=h.parseUShort(),P=h.parseOffset32(),R=d>1||p>0?h.parseUShort():void 0;c!==void 0&&U.argument(A>=c.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),E>0&&U.argument(A>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");let F=[];for(let $=0;$<A;$++)h.offset=o+w,h.relativeOffset=$*x,F.push(h.parseStruct(ip));h.offset=o,h.relativeOffset=P;let L=h.parseUShortList(E),N=[];for(let $=0;$<E;$++)h.offset=o+P,h.relativeOffset=L[$],N.push(op.apply(h));return{version:b,axes:F,values:N,elidedFallbackNameID:R}}var hs=new Array(5);hs[1]=function(o,c){return[{name:`format${o}`,type:"USHORT",value:1},{name:`axisIndex${o}`,type:"USHORT",value:c.axisIndex},{name:`flags${o}`,type:"USHORT",value:c.flags},{name:`valueNameID${o}`,type:"USHORT",value:c.valueNameID},{name:`value${o}`,type:"FLOAT",value:c.value}]},hs[2]=function(o,c){return[{name:`format${o}`,type:"USHORT",value:2},{name:`axisIndex${o}`,type:"USHORT",value:c.axisIndex},{name:`flags${o}`,type:"USHORT",value:c.flags},{name:`valueNameID${o}`,type:"USHORT",value:c.valueNameID},{name:`nominalValue${o}`,type:"FLOAT",value:c.nominalValue},{name:`rangeMinValue${o}`,type:"FLOAT",value:c.rangeMinValue},{name:`rangeMaxValue${o}`,type:"FLOAT",value:c.rangeMaxValue}]},hs[3]=function(o,c){return[{name:`format${o}`,type:"USHORT",value:3},{name:`axisIndex${o}`,type:"USHORT",value:c.axisIndex},{name:`flags${o}`,type:"USHORT",value:c.flags},{name:`valueNameID${o}`,type:"USHORT",value:c.valueNameID},{name:`value${o}`,type:"FLOAT",value:c.value},{name:`linkedValue${o}`,type:"FLOAT",value:c.linkedValue}]},hs[4]=function(o,c){let h=[{name:`format${o}`,type:"USHORT",value:4},{name:`axisCount${o}`,type:"USHORT",value:c.axisValues.length},{name:`flags${o}`,type:"USHORT",value:c.flags},{name:`valueNameID${o}`,type:"USHORT",value:c.valueNameID}];for(let d=0;d<c.axisValues.length;d++)h=h.concat([{name:`format${o}axisIndex${d}`,type:"USHORT",value:c.axisValues[d].axisIndex},{name:`format${o}value${d}`,type:"FLOAT",value:c.axisValues[d].value}]);return h};function lp(s,o){return new J.Record("axisRecord_"+s,[{name:"axisTag_"+s,type:"TAG",value:o.tag},{name:"axisNameID_"+s,type:"USHORT",value:o.nameID},{name:"axisOrdering_"+s,type:"USHORT",value:o.ordering}])}function cp(s,o){let c=o.format,h=hs[c];U.argument(h!==void 0,`Unknown axis value table format ${c}`);let d=h(s,o);return new J.Table("axisValueTable_"+s,d)}function up(s){let o=new J.Table("STAT",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:2},{name:"designAxisSize",type:"USHORT",value:8},{name:"designAxisCount",type:"USHORT",value:s.axes.length},{name:"designAxesOffset",type:"ULONG",value:0},{name:"axisValueCount",type:"USHORT",value:s.values.length},{name:"offsetToAxisValueOffsets",type:"ULONG",value:0},{name:"elidedFallbackNameID",type:"USHORT",value:s.elidedFallbackNameID}]);o.designAxesOffset=o.offsetToAxisValueOffsets=o.sizeOf();for(let p=0;p<s.axes.length;p++){let b=lp(p,s.axes[p]);o.offsetToAxisValueOffsets+=b.sizeOf(),o.fields=o.fields.concat(b.fields)}let c=[],h=[],d=s.values.length*2;for(let p=0;p<s.values.length;p++){let b=cp(p,s.values[p]);c.push({name:"offset_"+p,type:"USHORT",value:d}),d+=b.sizeOf(),h=h.concat(b.fields)}return o.fields=o.fields.concat(c),o.fields=o.fields.concat(h),o}var nc={make:up,parse:ap};function hp(s,o){return new J.Record("axisValueMap_"+s,[{name:"fromCoordinate_"+s,type:"F2DOT14",value:o.fromCoordinate},{name:"toCoordinate_"+s,type:"F2DOT14",value:o.toCoordinate}])}function dp(s,o){let c=new J.Record("segmentMap_"+s,[{name:"positionMapCount_"+s,type:"USHORT",value:o.axisValueMaps.length}]),h=[];for(let d=0;d<o.axisValueMaps.length;d++){let p=hp(`${s}_${d}`,o.axisValueMaps[d]);h=h.concat(p.fields)}return c.fields=c.fields.concat(h),c}function fp(s,o){U.argument(s.axisSegmentMaps.length===o.axes.length,"avar axis count must correspond to fvar axis count");let c=new J.Table("avar",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:0},{name:"reserved",type:"USHORT",value:0},{name:"axisCount",type:"USHORT",value:s.axisSegmentMaps.length}]);for(let h=0;h<s.axisSegmentMaps.length;h++){let d=dp(h,s.axisSegmentMaps[h]);c.fields=c.fields.concat(d.fields)}return c}function pp(s,o,c){o||(o=0);let h=new G(s,o),d=h.parseUShort(),p=h.parseUShort();d!==1&&console.warn(`Unsupported avar table version ${d}.${p}`),h.skip("uShort",1);let b=h.parseUShort();U.argument(b===c.axes.length,"avar axis count must correspond to fvar axis count");let x=[];for(let A=0;A<b;A++){let w=[],E=h.parseUShort();for(let P=0;P<E;P++){let R=h.parseF2Dot14(),F=h.parseF2Dot14();w.push({fromCoordinate:R,toCoordinate:F})}x.push({axisValueMaps:w})}return{version:[d,p],axisSegmentMaps:x}}var sc={make:fp,parse:pp};function gp(s,o,c,h){let d=new rt.Parser(s,o),p=d.parseTupleVariationStore(d.relativeOffset,c.axes.length,"cvar",h),b=d.parseUShort(),x=d.parseUShort();return b!==1&&console.warn(`Unsupported cvar table version ${b}.${x}`),{version:[b,x],...p}}function mp(){console.warn("Writing of cvar tables is not yet supported.")}var rc={make:mp,parse:gp};function yp(s,o,c,h){let d=new rt.Parser(s,o),p=d.parseUShort(),b=d.parseUShort();p!==1&&console.warn(`Unsupported gvar table version ${p}.${b}`);let x=d.parseUShort();x!==c.axes.length&&console.warn(`axisCount ${x} in gvar table does not match the number of axes ${c.axes.length} in the fvar table!`);let A=d.parseUShort(),w=d.parsePointer32(function(){return this.parseTupleRecords(A,x)}),E=d.parseTupleVariationStoreList(x,"gvar",h);return{version:[p,b],sharedTuples:w,glyphVariations:E}}function bp(){console.warn("Writing of gvar tables is not yet supported.")}var ic={make:bp,parse:yp};function vp(s,o){let c={},h=new rt.Parser(s,o);c.version=h.parseUShort(),U.argument(c.version<=1,"Unsupported gasp table version."),c.numRanges=h.parseUShort(),c.gaspRanges=[];for(let d=0;d<c.numRanges;d++)c.gaspRanges[d]={rangeMaxPPEM:h.parseUShort(),rangeGaspBehavior:h.parseUShort()};return c}function xp(s){let o=new J.Table("gasp",[{name:"version",type:"USHORT",value:1},{name:"numRanges",type:"USHORT",value:s.numRanges}]);for(let c in s.gaspRanges)o.fields.push({name:"rangeMaxPPEM",type:"USHORT",value:s.gaspRanges[c].rangeMaxPPEM}),o.fields.push({name:"rangeGaspBehavior",type:"USHORT",value:s.gaspRanges[c].rangeGaspBehavior});return o}var oc={parse:vp,make:xp};function Sp(s,o){let c=new Map,h=s.buffer,d=new G(s,o);if(d.parseUShort()!==0)return c;d.relativeOffset=d.parseOffset32();let b=s.byteOffset+o+d.relativeOffset,x=d.parseUShort(),A=new Map;for(let w=0;w<x;w++){let E=d.parseUShort(),P=d.parseUShort(),R=b+d.parseOffset32(),F=d.parseULong(),L=A.get(R);L===void 0&&(L=new Uint8Array(h,R,F),A.set(R,L));for(let N=E;N<=P;N++)c.set(N,L)}return c}function Ap(s){let o=Array.from(s.keys()).sort(),c=[],h=[],d=new Map,p=0,b={endGlyphID:null};for(let R=0,F=o.length;R<F;R++){let L=o[R],N=s.get(L),$=d.get(N);$===void 0&&($=p,h.push(N),d.set(N,$),p+=N.byteLength),L-1===b.endGlyphID&&$===b.svgDocOffset?b.endGlyphID=L:(b={startGlyphID:L,endGlyphID:L,svgDocOffset:$,svgDocLength:N.byteLength},c.push(b))}let x=c.length,A=h.length,w=2+x*12,E=new Array(4+x*4+A),P=0;E[P++]={name:"version",type:"USHORT",value:0},E[P++]={name:"svgDocumentListOffset",type:"ULONG",value:10},E[P++]={name:"reserved",type:"ULONG",value:0},E[P++]={name:"numEntries",type:"USHORT",value:x};for(let R=0;R<x;R++){let F="documentRecord_"+R,{startGlyphID:L,endGlyphID:N,svgDocOffset:$,svgDocLength:vt}=c[R];E[P++]={name:F+"_startGlyphID",type:"USHORT",value:L},E[P++]={name:F+"_endGlyphID",type:"USHORT",value:N},E[P++]={name:F+"_svgDocOffset",type:"ULONG",value:w+$},E[P++]={name:F+"_svgDocLength",type:"ULONG",value:vt}}for(let R=0;R<A;R++)E[P++]={name:"svgDoc_"+R,type:"LITERAL",value:h[R]};return new J.Table("SVG ",E)}var ac={make:Ap,parse:Sp};function lc(s){return Math.log(s)/Math.log(2)|0}function Xi(s){for(;s.length%4!==0;)s.push(0);let o=0;for(let c=0;c<s.length;c+=4)o+=(s[c]<<24)+(s[c+1]<<16)+(s[c+2]<<8)+s[c+3];return o%=Math.pow(2,32),o}function cc(s,o,c,h){return new J.Record("Table Record",[{name:"tag",type:"TAG",value:s!==void 0?s:""},{name:"checkSum",type:"ULONG",value:o!==void 0?o:0},{name:"offset",type:"ULONG",value:c!==void 0?c:0},{name:"length",type:"ULONG",value:h!==void 0?h:0}])}function uc(s){let o=new J.Table("sfnt",[{name:"version",type:"TAG",value:"OTTO"},{name:"numTables",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);o.tables=s,o.numTables=s.length;let c=Math.pow(2,lc(o.numTables));o.searchRange=16*c,o.entrySelector=lc(c),o.rangeShift=o.numTables*16-o.searchRange;let h=[],d=[],p=o.sizeOf()+cc().sizeOf()*o.numTables;for(;p%4!==0;)p+=1,d.push({name:"padding",type:"BYTE",value:0});for(let b=0;b<s.length;b+=1){let x=s[b];U.argument(x.tableName.length===4,"Table name"+x.tableName+" is invalid.");let A=x.sizeOf(),w=cc(x.tableName,Xi(x.encode()),p,A);for(h.push({name:w.tag+" Table Record",type:"RECORD",value:w}),d.push({name:x.tableName+" table",type:"RECORD",value:x}),p+=A,U.argument(!isNaN(p),"Something went wrong calculating the offset.");p%4!==0;)p+=1,d.push({name:"padding",type:"BYTE",value:0})}return h.sort(function(b,x){return b.value.tag>x.value.tag?1:-1}),o.fields=o.fields.concat(h),o.fields=o.fields.concat(d),o}function hc(s,o,c){for(let h=0;h<o.length;h+=1){let d=s.charToGlyphIndex(o[h]);if(d>0)return s.glyphs.get(d).getMetrics()}return c}function Tp(s){let o=0;for(let c=0;c<s.length;c+=1)o+=s[c];return o/s.length}function Cp(s){let o=[],c=[],h=[],d=[],p=[],b=[],x=[],A,w=0,E=0,P=0,R=0,F=0;for(let Wt=0;Wt<s.glyphs.length;Wt+=1){let ye=s.glyphs.get(Wt),Re=ye.unicode|0;if(isNaN(ye.advanceWidth))throw new Error("Glyph "+ye.name+" ("+Wt+"): advanceWidth is not a number.");(A>Re||A===void 0)&&Re>0&&(A=Re),w<Re&&(w=Re);let Be=zi.getUnicodeRange(Re);if(Be<32)E|=1<<Be;else if(Be<64)P|=1<<Be-32;else if(Be<96)R|=1<<Be-64;else if(Be<123)F|=1<<Be-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(ye.name===".notdef")continue;let en=ye.getMetrics();o.push(en.xMin),c.push(en.yMin),h.push(en.xMax),d.push(en.yMax),b.push(en.leftSideBearing),x.push(en.rightSideBearing),p.push(ye.advanceWidth)}let L={xMin:Math.min.apply(null,o),yMin:Math.min.apply(null,c),xMax:Math.max.apply(null,h),yMax:Math.max.apply(null,d),advanceWidthMax:Math.max.apply(null,p),advanceWidthAvg:Tp(p),minLeftSideBearing:Math.min.apply(null,b),maxLeftSideBearing:Math.max.apply(null,b),minRightSideBearing:Math.min.apply(null,x)};L.ascender=s.ascender,L.descender=s.descender;let N=0;s.weightClass>=600&&(N|=s.macStyleValues.BOLD),s.italicAngle<0&&(N|=s.macStyleValues.ITALIC);let $=zl.make({flags:3,unitsPerEm:s.unitsPerEm,xMin:L.xMin,yMin:L.yMin,xMax:L.xMax,yMax:L.yMax,lowestRecPPEM:3,macStyle:N,createdTimestamp:s.createdTimestamp}),vt=Xl.make({ascender:L.ascender,descender:L.descender,advanceWidthMax:L.advanceWidthMax,minLeftSideBearing:L.minLeftSideBearing,minRightSideBearing:L.minRightSideBearing,xMaxExtent:L.maxLeftSideBearing+(L.xMax-L.xMin),numberOfHMetrics:s.glyphs.length}),pt=Zl.make(s.glyphs.length),At=zi.make(Object.assign({xAvgCharWidth:Math.round(L.advanceWidthAvg),usFirstCharIndex:A,usLastCharIndex:w,ulUnicodeRange1:E,ulUnicodeRange2:P,ulUnicodeRange3:R,ulUnicodeRange4:F,sTypoAscender:L.ascender,sTypoDescender:L.descender,sTypoLineGap:0,usWinAscent:L.yMax,usWinDescent:Math.abs(L.yMin),ulCodePageRange1:1,sxHeight:hc(s,"xyvw",{yMax:Math.round(L.ascender/2)}).yMax,sCapHeight:hc(s,"HIKLEFJMNTZBDPRAGOQSUVWXY",L).yMax,usDefaultChar:s.hasChar(" ")?32:0,usBreakChar:s.hasChar(" ")?32:0},s.tables.os2)),It=Yl.make(s.glyphs),Ut=kl.make(s.glyphs),Gt=s.getEnglishName("fontFamily"),Ht=s.getEnglishName("fontSubfamily"),Jt=Gt+" "+Ht,Ne=s.getEnglishName("postScriptName");Ne||(Ne=Gt.replace(/\s/g,"")+"-"+Ht);let Rt={};for(let Wt in s.names)Rt[Wt]=s.names[Wt];Rt.unicode=Rt.unicode||{},Rt.macintosh=Rt.macintosh||{},Rt.windows=Rt.windows||{};let Te=s.names.unicode||{},de=s.names.macintosh||{},xt=s.names.windows||{};for(let Wt in Rt){if(Rt[Wt]=Rt[Wt]||{},!Rt[Wt].uniqueID){let ye=s.getEnglishName("manufacturer")||"";Rt[Wt].uniqueID={en:`${ye}: ${Jt}`}}Rt[Wt].postScriptName||(Rt[Wt].postScriptName={en:Ne})}Rt.unicode.preferredFamily||(Rt.unicode.preferredFamily=Te.fontFamily||de.fontFamily||xt.fontFamily),Rt.macintosh.preferredFamily||(Rt.macintosh.preferredFamily=de.fontFamily||Te.fontFamily||xt.fontFamily),Rt.windows.preferredFamily||(Rt.windows.preferredFamily=xt.fontFamily||Te.fontFamily||de.fontFamily),Rt.unicode.preferredSubfamily||(Rt.unicode.preferredSubfamily=Te.fontSubfamily||de.fontSubfamily||xt.fontSubfamily),Rt.macintosh.preferredSubfamily||(Rt.macintosh.preferredSubfamily=de.fontSubfamily||Te.fontSubfamily||xt.fontSubfamily),Rt.windows.preferredSubfamily||(Rt.windows.preferredSubfamily=xt.fontSubfamily||Te.fontSubfamily||de.fontSubfamily);let ct=[],ft=wl.make(Rt,ct),oe=ct.length>0?Kl.make(ct):void 0,fn=Ql.make(s),mr=Wi.make(s.glyphs,{version:s.getEnglishName("version"),fullName:Jt,familyName:Gt,weightName:Ht,postScriptName:Ne,unitsPerEm:s.unitsPerEm,fontBBox:[0,L.yMin,L.ascender,L.advanceWidthMax],topDict:s.tables.cff&&s.tables.cff.topDict||{}}),In=s.metas&&Object.keys(s.metas).length>0?ql.make(s.metas):void 0,Ue=[$,vt,pt,At,ft,Ut,fn,mr,It];oe&&Ue.push(oe);let fe={gsub:Jl,cpal:Ll,colr:tc,stat:nc,avar:sc,cvar:rc,fvar:ec,gvar:ic,gasp:oc,svg:ac},Ie={avar:[s.tables.fvar],fvar:[s.names]};for(let Wt in fe){let ye=s.tables[Wt];if(ye){let Re=fe[Wt].make.call(s,ye,...Ie[Wt]||[]);Re&&Ue.push(Re)}}In&&Ue.push(In);let ae=uc(Ue),Ce=ae.encode(),pe=Xi(Ce),ge=ae.fields,Zt=!1;for(let Wt=0;Wt<ge.length;Wt+=1)if(ge[Wt].name==="head table"){ge[Wt].value.checkSumAdjustment=2981146554-pe,Zt=!0;break}if(!Zt)throw new Error("Could not find head table with checkSum to adjust.");return ae}var Ep={make:uc,fontToTable:Cp,computeCheckSum:Xi};function Yi(s,o){let c=0,h=s.length-1;for(;c<=h;){let d=c+h>>>1,p=s[d].tag;if(p===o)return d;p<o?c=d+1:h=d-1}return-c-1}function dc(s,o){let c=0,h=s.length-1;for(;c<=h;){let d=c+h>>>1,p=s[d];if(p===o)return d;p<o?c=d+1:h=d-1}return-c-1}function fc(s,o){let c,h=0,d=s.length-1;for(;h<=d;){let p=h+d>>>1;c=s[p];let b=c.start;if(b===o)return c;b<o?h=p+1:d=p-1}if(h>0)return c=s[h-1],o>c.end?0:c}function pc(s,o){this.font=s,this.tableName=o}pc.prototype={searchTag:Yi,binSearch:dc,getTable:function(s){let o=this.font.tables[this.tableName];return!o&&s&&(o=this.font.tables[this.tableName]=this.createDefaultTable()),o},getScriptNames:function(){let s=this.getTable();return s?s.scripts.map(function(o){return o.tag}):[]},getDefaultScriptName:function(){let s=this.getTable();if(!s)return;let o=!1;for(let c=0;c<s.scripts.length;c++){let h=s.scripts[c].tag;if(h==="DFLT")return h;h==="latn"&&(o=!0)}if(o)return"latn"},getScriptTable:function(s,o){let c=this.getTable(o);if(c){s=s||"DFLT";let h=c.scripts,d=Yi(c.scripts,s);if(d>=0)return h[d].script;if(o){let p={tag:s,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return h.splice(-1-d,0,p),p.script}}},getLangSysTable:function(s,o,c){let h=this.getScriptTable(s,c);if(h){if(!o||o==="dflt"||o==="DFLT")return h.defaultLangSys;let d=Yi(h.langSysRecords,o);if(d>=0)return h.langSysRecords[d].langSys;if(c){let p={tag:o,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return h.langSysRecords.splice(-1-d,0,p),p.langSys}}},getFeatureTable:function(s,o,c,h){let d=this.getLangSysTable(s,o,h);if(d){let p,b=d.featureIndexes,x=this.font.tables[this.tableName].features;for(let A=0;A<b.length;A++)if(p=x[b[A]],p.tag===c)return p.feature;if(h){let A=x.length;return U.assert(A===0||c>=x[A-1].tag,"Features must be added in alphabetical order."),p={tag:c,feature:{params:0,lookupListIndexes:[]}},x.push(p),b.push(A),p.feature}}},getLookupTables:function(s,o,c,h,d){let p=this.getFeatureTable(s,o,c,d),b=[];if(p){let x,A=p.lookupListIndexes,w=this.font.tables[this.tableName].lookups;for(let E=0;E<A.length;E++)x=w[A[E]],x.lookupType===h&&b.push(x);if(b.length===0&&d){x={lookupType:h,lookupFlag:0,subtables:[],markFilteringSet:void 0};let E=w.length;return w.push(x),A.push(E),[x]}}return b},getGlyphClass:function(s,o){switch(s.format){case 1:return s.startGlyph<=o&&o<s.startGlyph+s.classes.length?s.classes[o-s.startGlyph]:0;case 2:{let c=fc(s.ranges,o);return c?c.classId:0}}},getCoverageIndex:function(s,o){switch(s.format){case 1:{let c=dc(s.glyphs,o);return c>=0?c:-1}case 2:{let c=fc(s.ranges,o);return c?c.index+o-c.start:-1}}},expandCoverage:function(s){if(s.format===1)return s.glyphs;{let o=[],c=s.ranges;for(let h=0;h<c.length;h++){let d=c[h],p=d.start,b=d.end;for(let x=p;x<=b;x++)o.push(x)}return o}}};var ar=pc;function ds(s){ar.call(this,s,"gpos")}ds.prototype=ar.prototype,ds.prototype.init=function(){let s=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(s)},ds.prototype.getKerningValue=function(s,o,c){for(let h=0;h<s.length;h++){let d=s[h].subtables;for(let p=0;p<d.length;p++){let b=d[p],x=this.getCoverageIndex(b.coverage,o);if(!(x<0))switch(b.posFormat){case 1:{let A=b.pairSets[x];for(let w=0;w<A.length;w++){let E=A[w];if(E.secondGlyph===c)return E.value1&&E.value1.xAdvance||0}break}case 2:{let A=this.getGlyphClass(b.classDef1,o),w=this.getGlyphClass(b.classDef2,c),E=b.classRecords[A][w];return E.value1&&E.value1.xAdvance||0}}}}return 0},ds.prototype.getKerningTables=function(s,o){if(this.font.tables.gpos)return this.getLookupTables(s,o,"kern",2)};var wp=ds;function kp(s,o){let c=s.length;if(c!==o.length)return!1;for(let h=0;h<c;h++)if(s[h]!==o[h])return!1;return!0}function Ip(s,o,c){let h=0,d=s.length-1,p=null;for(;h<=d;){let b=Math.floor((h+d)/2),x=s[b],A=x[o];if(A<c)h=b+1;else if(A>c)d=b-1;else{p=x;break}}return p}function Rp(s,o,c){let h=0,d=s.length-1;for(;h<=d;){let p=Math.floor((h+d)/2),b=s[p];if(b[o]<c)h=p+1;else if(b[o]>c)d=p-1;else return p}return-1}function Pp(s,o,c){let h=0,d=s.length,p=(b,x)=>b[o]-x[o];for(;h<d;){let b=h+d>>>1;p(s[b],c)<0?h=b+1:d=b}return s.splice(h,0,c),h}function gc(s){return s[0]===31&&s[1]===139&&s[2]===8}function Op(s){let o=new DataView(s.buffer,s.byteOffset,s.byteLength),c=10,h=s.byteLength-8,d=o.getInt8(3);if(d&4&&(c+=2+o.getUint16(c,!0)),d&8)for(;c<h&&s[c++]!==0;);if(d&16)for(;c<h&&s[c++]!==0;);if(d&2&&(c+=2),c>=h)throw new Error("Can't find compressed blocks");let p=o.getUint32(o.byteLength-4,!0);return dt(s.subarray(c,h),new Uint8Array(p))}function mc(s){return{x:s.x,y:s.y,onCurve:s.onCurve,lastPointOfContour:s.lastPointOfContour}}function Mp(s){return{glyphIndex:s.glyphIndex,xScale:s.xScale,scale01:s.scale01,scale10:s.scale10,yScale:s.yScale,dx:s.dx,dy:s.dy}}function Se(s){ar.call(this,s,"gsub")}function Ki(s,o,c){let h=s.subtables;for(let d=0;d<h.length;d++){let p=h[d];if(p.substFormat===o)return p}if(c)return h.push(c),c}Se.prototype=ar.prototype,Se.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},Se.prototype.getSingle=function(s,o,c){let h=[],d=this.getLookupTables(o,c,s,1);for(let p=0;p<d.length;p++){let b=d[p].subtables;for(let x=0;x<b.length;x++){let A=b[x],w=this.expandCoverage(A.coverage),E;if(A.substFormat===1){let P=A.deltaGlyphId;for(E=0;E<w.length;E++){let R=w[E];h.push({sub:R,by:R+P})}}else{let P=A.substitute;for(E=0;E<w.length;E++)h.push({sub:w[E],by:P[E]})}}}return h},Se.prototype.getMultiple=function(s,o,c){let h=[],d=this.getLookupTables(o,c,s,2);for(let p=0;p<d.length;p++){let b=d[p].subtables;for(let x=0;x<b.length;x++){let A=b[x],w=this.expandCoverage(A.coverage),E;for(E=0;E<w.length;E++){let P=w[E],R=A.sequences[E];h.push({sub:P,by:R})}}}return h},Se.prototype.getAlternates=function(s,o,c){let h=[],d=this.getLookupTables(o,c,s,3);for(let p=0;p<d.length;p++){let b=d[p].subtables;for(let x=0;x<b.length;x++){let A=b[x],w=this.expandCoverage(A.coverage),E=A.alternateSets;for(let P=0;P<w.length;P++)h.push({sub:w[P],by:E[P]})}}return h},Se.prototype.getLigatures=function(s,o,c){let h=[],d=this.getLookupTables(o,c,s,4);for(let p=0;p<d.length;p++){let b=d[p].subtables;for(let x=0;x<b.length;x++){let A=b[x],w=this.expandCoverage(A.coverage),E=A.ligatureSets;for(let P=0;P<w.length;P++){let R=w[P],F=E[P];for(let L=0;L<F.length;L++){let N=F[L];h.push({sub:[R].concat(N.components),by:N.ligGlyph})}}}}return h},Se.prototype.addSingle=function(s,o,c,h){let d=this.getLookupTables(c,h,s,1,!0)[0],p=Ki(d,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});U.assert(p.coverage.format===1,"Single: unable to modify coverage table format "+p.coverage.format);let b=o.sub,x=this.binSearch(p.coverage.glyphs,b);x<0&&(x=-1-x,p.coverage.glyphs.splice(x,0,b),p.substitute.splice(x,0,0)),p.substitute[x]=o.by},Se.prototype.addMultiple=function(s,o,c,h){U.assert(o.by instanceof Array&&o.by.length>1,'Multiple: "by" must be an array of two or more ids');let d=this.getLookupTables(c,h,s,2,!0)[0],p=Ki(d,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});U.assert(p.coverage.format===1,"Multiple: unable to modify coverage table format "+p.coverage.format);let b=o.sub,x=this.binSearch(p.coverage.glyphs,b);x<0&&(x=-1-x,p.coverage.glyphs.splice(x,0,b),p.sequences.splice(x,0,0)),p.sequences[x]=o.by},Se.prototype.addAlternate=function(s,o,c,h){let d=this.getLookupTables(c,h,s,3,!0)[0],p=Ki(d,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});U.assert(p.coverage.format===1,"Alternate: unable to modify coverage table format "+p.coverage.format);let b=o.sub,x=this.binSearch(p.coverage.glyphs,b);x<0&&(x=-1-x,p.coverage.glyphs.splice(x,0,b),p.alternateSets.splice(x,0,0)),p.alternateSets[x]=o.by},Se.prototype.addLigature=function(s,o,c,h){let d=this.getLookupTables(c,h,s,4,!0)[0],p=d.subtables[0];p||(p={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},d.subtables[0]=p),U.assert(p.coverage.format===1,"Ligature: unable to modify coverage table format "+p.coverage.format);let b=o.sub[0],x=o.sub.slice(1),A={ligGlyph:o.by,components:x},w=this.binSearch(p.coverage.glyphs,b);if(w>=0){let E=p.ligatureSets[w];for(let P=0;P<E.length;P++)if(kp(E[P].components,x))return;E.push(A)}else w=-1-w,p.coverage.glyphs.splice(w,0,b),p.ligatureSets.splice(w,0,[A])},Se.prototype.getFeature=function(s,o,c){if(/ss\d\d/.test(s))return this.getSingle(s,o,c);switch(s){case"aalt":case"salt":return this.getSingle(s,o,c).concat(this.getAlternates(s,o,c));case"dlig":case"liga":case"rlig":return this.getLigatures(s,o,c);case"ccmp":return this.getMultiple(s,o,c).concat(this.getLigatures(s,o,c));case"stch":return this.getMultiple(s,o,c)}},Se.prototype.add=function(s,o,c,h){if(/ss\d\d/.test(s))return this.addSingle(s,o,c,h);switch(s){case"aalt":case"salt":return typeof o.by=="number"?this.addSingle(s,o,c,h):this.addAlternate(s,o,c,h);case"dlig":case"liga":case"rlig":return this.addLigature(s,o,c,h);case"ccmp":return o.by instanceof Array?this.addMultiple(s,o,c,h):this.addLigature(s,o,c,h)}};var Lp=Se,yc=class{constructor(s){this.defaultValue=255,this.font=s}cpal(){return this.font.tables&&this.font.tables.cpal?this.font.tables.cpal:!1}getAll(s){let o=[],c=this.cpal();if(!c)return o;for(let h=0;h<c.colorRecordIndices.length;h++){let d=c.colorRecordIndices[h],p=[];for(let b=d;b<d+c.numPaletteEntries;b++)p.push($n(c.colorRecords[b],s||"hexa"));o.push(p)}return o}toCPALcolor(s){return Array.isArray(s)?s.map(o=>rr(o,"raw")):rr(s,"raw")}fillPalette(s,o=[],c=this.cpal().numPaletteEntries){return s=Number.isInteger(s)?this.get(s,"raw"):s,Object.assign(Array(c).fill(this.defaultValue),this.toCPALcolor(s).concat(this.toCPALcolor(o)))}extend(s){if(this.ensureCPAL(Array(s).fill(this.defaultValue)))return;let o=this.cpal(),c=o.numPaletteEntries+s,h=this.getAll().map(d=>this.fillPalette(d,[],c));o.numPaletteEntries=c,o.colorRecords=this.toCPALcolor(h.flat()),this.updateIndices()}get(s,o="hexa"){return this.getAll(o)[s]||null}getColor(s,o=0,c="hexa"){return Ui(this.font,s,o,c)}setColor(s,o,c=0){s=parseInt(s),c=parseInt(c);let h=this.getAll("raw"),d=h[c];if(!d)throw Error(`paletteIndex ${c} out of range`);let p=this.cpal(),b=p.numPaletteEntries;Array.isArray(o)||(o=[o]),o.length+s>b&&(this.extend(o.length+s-b),h=this.getAll("raw"),d=h[c]);for(let x=0;x<o.length;x++)d[x+s]=this.toCPALcolor(o[x]);p.colorRecords=h.flat(),this.updateIndices()}add(s){if(this.ensureCPAL(s))return;let o=this.cpal(),c=o.numPaletteEntries;s&&s.length?(s=this.toCPALcolor(s),s.length>c?this.extend(s.length-c):s.length<c&&(s=this.fillPalette(s)),o.colorRecordIndices.push(o.colorRecords.length),o.colorRecords.push(...s)):(o.colorRecordIndices.push(o.colorRecords.length),o.colorRecords.push(...Array(c).fill(this.defaultValue)))}delete(s){let o=this.getAll("raw");delete o[s];let c=this.cpal();c.colorRecordIndices.pop(),c.colorRecords=o.flat()}deleteColor(s,o){if(s===o)throw Error("replacementIndex cannot be the same as colorIndex");let c=this.cpal(),h=this.getAll("raw"),d=[];if(o>c.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${c.numPaletteEntries-1}, replacementIndex: ${o})`);for(let x=0;x<h.length;x++){let w=h[x].filter((E,P)=>P!==s);d.push(w)}let p=this.font.tables.colr;if(p){let x=p.layerRecords;for(let A=0;A<x.length;A++){let w=x[A].paletteIndex;if(w>s)x[A].paletteIndex-=1;else if(w===s){let E=0;for(let P=0;P<h.length;P++)if(o>s&&o<=s+h[P].length){E++;break}x[A].paletteIndex=o-E}}this.font.tables.colr={...p,layerRecords:x}}let b=d.flat();for(let x=0;x<h.length;x++)c.colorRecordIndices[x]-=x;c.numPaletteEntries=Math.max(0,c.numPaletteEntries-1),c.colorRecords=this.toCPALcolor(b)}ensureCPAL(s){return this.cpal()?!1:(!s||!s.length?s=[this.defaultValue]:s=this.toCPALcolor(s),this.font.tables.cpal={version:0,numPaletteEntries:s.length,colorRecords:s,colorRecordIndices:[0]},!0)}updateIndices(){let s=this.cpal(),o=Math.ceil(s.colorRecords.length/s.numPaletteEntries);s.colorRecordIndices=[];for(let c=0;c<o;c++)s.colorRecordIndices.push(c*s.numPaletteEntries)}},Fp=class{constructor(s){this.font=s}ensureCOLR(){return this.font.tables.colr||(this.font.tables.colr={version:0,baseGlyphRecords:[],layerRecords:[]}),this.font}get(s){let o=this.font,c=[],h=o.tables.colr,d=o.tables.cpal;if(!h||!d)return c;let p=Ip(h.baseGlyphRecords,"glyphID",s);if(!p)return c;let b=p.firstLayerIndex,x=p.numLayers;for(let A=0;A<x;A++){let w=h.layerRecords[b+A];c.push({glyph:o.glyphs.get(w.glyphID),paletteIndex:w.paletteIndex})}return c}add(s,o,c){let h=this.get(s);o=Array.isArray(o)?o:[o],c===void 0||c===1/0||c>h.length?c=h.length:c<0&&(c=h.length+1+c%(h.length+1),c>=h.length+1&&(c-=h.length+1));let d=[];for(let p=0;p<c;p++){let b=Number.isInteger(h[p].glyph)?h[p].glyph:h[p].glyph.index;d.push({glyphID:b,paletteIndex:h[p].paletteIndex})}for(let p of o){let b=Number.isInteger(p.glyph)?p.glyph:p.glyph.index;d.push({glyphID:b,paletteIndex:p.paletteIndex})}for(let p=c;p<h.length;p++){let b=Number.isInteger(h[p].glyph)?h[p].glyph:h[p].glyph.index;d.push({glyphID:b,paletteIndex:h[p].paletteIndex})}this.updateColrTable(s,d)}setPaletteIndex(s,o,c){let h=this.get(s);h[o]?(h=h.map((d,p)=>({glyphID:d.glyph.index,paletteIndex:p===o?c:d.paletteIndex})),this.updateColrTable(s,h)):console.error("Invalid layer index")}remove(s,o,c=o){let h=this.get(s);h=h.map(d=>({glyphID:d.glyph.index,paletteIndex:d.paletteIndex})),h.splice(o,c-o+1),this.updateColrTable(s,h)}updateColrTable(s,o){this.ensureCOLR();let h=this.font.tables.colr,d=Rp(h.baseGlyphRecords,"glyphID",s);if(d===-1){let E={glyphID:s,firstLayerIndex:h.layerRecords.length,numLayers:0};d=Pp(h.baseGlyphRecords,"glyphID",E)}let b=h.baseGlyphRecords[d],x=b.numLayers,A=o.length,w=A-x;if(w>0){let E=o.slice(x).map(P=>({glyphID:P.glyphID,paletteIndex:P.paletteIndex}));h.layerRecords.splice(b.firstLayerIndex+x,0,...E)}else w<0&&h.layerRecords.splice(b.firstLayerIndex+A,-w);for(let E=0;E<Math.min(x,A);E++)h.layerRecords[b.firstLayerIndex+E]={glyphID:o[E].glyphID,paletteIndex:o[E].paletteIndex};if(b.numLayers=A,w!==0)for(let E=0;E<h.baseGlyphRecords.length;E++){let P=h.baseGlyphRecords[E];E===d||P.firstLayerIndex<b.firstLayerIndex||(h.baseGlyphRecords[E].firstLayerIndex+=w)}}},Dp=class{constructor(s){this.font=s,this.cache=new WeakMap}get(s){let o=this.getOrCreateSvgImageCacheEntry(s);return o&&o.image}getAsync(s){let o=this.getOrCreateSvgImageCacheEntry(s);return o&&o.promise}getOrCreateSvgImageCacheEntry(s){let o=this.font.tables.svg;if(o===void 0)return;let c=o.get(s);if(c===void 0)return;let h=this.cache.get(c);h===void 0&&(h=_p(c),this.cache.set(c,h));let d=h.images.get(s);return d===void 0&&(d=Np(this.font,h.template,s),d.promise.then(p=>{if(d.image=p,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(s)}catch(b){console.error("font.onGlyphUpdated",s,b)}}),h.images.set(s,d)),d}};function _p(s){return{template:Up(s).then(Hp),images:new Map}}function Np(s,o,c){return{promise:o.then(h=>{let d;typeof h=="string"?d=h:(h[4]=c,d=h.join(""));let p=jp(d,s.unitsPerEm);return p.image.decode().then(()=>p)}),image:void 0}}var Up=typeof DecompressionStream=="function"?Gp:Bp;function Bp(s){try{return Promise.resolve(new TextDecoder().decode(gc(s)?Op(s):s))}catch(o){return Promise.reject(o)}}function Gp(s){if(gc(s))return new Response(new Response(s).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(s))}catch(o){return Promise.reject(o)}}function Hp(s){let o=s.indexOf("<svg"),c=s.indexOf(">",o+4)+1;if(/ id=['"]glyph\d+['"]/.test(s.substring(o,c)))return s;let h=s.lastIndexOf("</svg>");return[s.substring(0,c),"<defs>",s.substring(c,h),'</defs><use href="#glyph',"",'"/>',s.substring(h)]}function jp(s,o){let h=new DOMParser().parseFromString(s,"image/svg+xml").documentElement,d=h.viewBox.baseVal,p=h.width.baseVal,b=h.height.baseVal,x=1,A=1;d.width>0&&d.height>0&&(p.unitType===1?(x=p.valueInSpecifiedUnits/d.width,A=b.unitType===1?b.valueInSpecifiedUnits/d.height:x):b.unitType===1?(A=b.valueInSpecifiedUnits/d.height,x=A):o&&(x=o/d.width,A=o/d.height));let w=document.createElement("div");w.style.position="fixed",w.style.visibility="hidden",w.appendChild(h),document.body.appendChild(w);let E=h.getBBox();document.body.removeChild(w);let P=(E.x-d.x)*x,R=(d.y-E.y)*A,F=E.width*x,L=E.height*A;h.setAttribute("viewBox",[E.x,E.y,E.width,E.height].join(" ")),x!==1&&h.setAttribute("width",F),A!==1&&h.setAttribute("height",L);let N=new Image(F,L);return N.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(h.outerHTML),{leftSideBearing:P,baseline:R,image:N}}var Zi=new WeakMap;function bc(s,o,c,h,d){let p;return(o&h)>0?(p=s.parseByte(),(o&d)===0&&(p=-p),p=c+p):(o&d)>0?p=c:p=c+s.parseShort(),p}function vc(s,o,c){let h=new rt.Parser(o,c);s._numberOfContours=h.parseShort(),s._xMin=h.parseShort(),s._yMin=h.parseShort(),s._xMax=h.parseShort(),s._yMax=h.parseShort();let d,p;if(s._numberOfContours>0){let b=s.endPointIndices=[];for(let A=0;A<s._numberOfContours;A+=1)b.push(h.parseUShort());s.instructionLength=h.parseUShort(),s.instructions=[];for(let A=0;A<s.instructionLength;A+=1)s.instructions.push(h.parseByte());let x=b[b.length-1]+1;d=[];for(let A=0;A<x;A+=1)if(p=h.parseByte(),d.push(p),(p&8)>0){let w=h.parseByte();for(let E=0;E<w;E+=1)d.push(p),A+=1}if(U.argument(d.length===x,"Bad flags."),b.length>0){let A=[],w;if(x>0){for(let R=0;R<x;R+=1)p=d[R],w={},w.onCurve=!!(p&1),w.lastPointOfContour=b.indexOf(R)>=0,A.push(w);let E=0;for(let R=0;R<x;R+=1)p=d[R],w=A[R],w.x=bc(h,p,E,2,16),E=w.x;let P=0;for(let R=0;R<x;R+=1)p=d[R],w=A[R],w.y=bc(h,p,P,4,32),P=w.y}s.points=A}else s.points=[]}else if(s._numberOfContours===0)s.points=[];else{s.isComposite=!0,s.points=[],s.components=[];let b=!0;for(;b;){d=h.parseUShort();let x={glyphIndex:h.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(d&1)>0?(d&2)>0?(x.dx=h.parseShort(),x.dy=h.parseShort()):x.matchedPoints=[h.parseUShort(),h.parseUShort()]:(d&2)>0?(x.dx=h.parseChar(),x.dy=h.parseChar()):x.matchedPoints=[h.parseByte(),h.parseByte()],(d&8)>0?x.xScale=x.yScale=h.parseF2Dot14():(d&64)>0?(x.xScale=h.parseF2Dot14(),x.yScale=h.parseF2Dot14()):(d&128)>0&&(x.xScale=h.parseF2Dot14(),x.scale01=h.parseF2Dot14(),x.scale10=h.parseF2Dot14(),x.yScale=h.parseF2Dot14()),s.components.push(x),b=!!(d&32)}if(d&256){s.instructionLength=h.parseUShort(),s.instructions=[];for(let x=0;x<s.instructionLength;x+=1)s.instructions.push(h.parseByte())}}}function lr(s,o){let c=[];for(let h=0;h<s.length;h+=1){let d=s[h],p={x:o.xScale*d.x+o.scale10*d.y+o.dx,y:o.scale01*d.x+o.yScale*d.y+o.dy,onCurve:d.onCurve,lastPointOfContour:d.lastPointOfContour};c.push(p)}return c}function Vp(s){let o=[],c=[];for(let h=0;h<s.length;h+=1){let d=s[h];c.push(d),d.lastPointOfContour&&(o.push(c),c=[])}return U.argument(c.length===0,"There are still points left in the current contour."),o}function Qi(s){let o=new ot;if(!s)return o;let c=Vp(s);for(let h=0;h<c.length;++h){let d=c[h],p=d[d.length-1],b=d[0];if(p.onCurve)o.moveTo(p.x,p.y);else if(b.onCurve)o.moveTo(b.x,b.y);else{let x={x:(p.x+b.x)*.5,y:(p.y+b.y)*.5};o.moveTo(x.x,x.y)}for(let x=0;x<d.length;++x)if(p=b,b=d[(x+1)%d.length],p.onCurve)o.lineTo(p.x,p.y);else{let A=b;b.onCurve||(A={x:(p.x+b.x)*.5,y:(p.y+b.y)*.5}),o.quadraticCurveTo(p.x,p.y,A.x,A.y)}o.closePath()}return o}function xc(s,o){if(o.isComposite){Zi.has(s)||Zi.set(s,new Set);let c=Zi.get(s);c.add(o.index);try{for(let h=0;h<o.components.length;h+=1){let d=o.components[h];if(c.has(d.glyphIndex))continue;let p=s.get(d.glyphIndex);if(p.getPath(),p.points){let b;if(d.matchedPoints===void 0)b=lr(p.points,d);else{if(d.matchedPoints[0]>o.points.length-1||d.matchedPoints[1]>p.points.length-1)throw Error("Matched points out of range in "+o.name);let x=o.points[d.matchedPoints[0]],A=p.points[d.matchedPoints[1]],w={xScale:d.xScale,scale01:d.scale01,scale10:d.scale10,yScale:d.yScale,dx:0,dy:0};A=lr([A],w)[0],w.dx=x.x-A.x,w.dy=x.y-A.y,b=lr(p.points,w)}o.points=o.points.concat(b)}}}finally{c.delete(o.index)}}return Qi(o.points)}function Wp(s,o,c,h){let d=new We.GlyphSet(h);for(let p=0;p<c.length-1;p+=1){let b=c[p],x=c[p+1];b!==x?d.push(p,We.ttfGlyphLoader(h,p,vc,s,o+b,xc)):d.push(p,We.glyphLoader(h,p))}return d}function $p(s,o,c,h){let d=new We.GlyphSet(h);return h._push=function(p){let b=c[p],x=c[p+1];b!==x?d.push(p,We.ttfGlyphLoader(h,p,vc,s,o+b,xc)):d.push(p,We.glyphLoader(h,p))},d}function zp(s,o,c,h,d){return d.lowMemory?$p(s,o,c,h):Wp(s,o,c,h)}var Sc={getPath:Qi,parse:zp},Xp=class{constructor(s){this.font=s}normalizeCoordTags(s){for(let o in s)if(o.length<4){let c=o.padEnd(4," ");s[c]===void 0&&(s[c]=s[o]),delete s[o]}}getNormalizedCoords(s){s||(s=this.font.variation.get());let o=[];this.normalizeCoordTags(s);for(let c=0;c<this.fvar().axes.length;c++){let h=this.fvar().axes[c],d=s[h.tag];d===void 0&&(d=h.defaultValue),d<h.defaultValue?o.push((d-h.defaultValue+Number.EPSILON)/(h.defaultValue-h.minValue+Number.EPSILON)):o.push((d-h.defaultValue+Number.EPSILON)/(h.maxValue-h.defaultValue+Number.EPSILON))}if(this.avar())for(let c=0;c<this.avar().axisSegmentMaps.length;c++){let h=this.avar().axisSegmentMaps[c];for(let d=0;d<h.axisValueMaps.length;d++){let p=h.axisValueMaps[d];if(d>=1&&o[c]<p.fromCoordinate){let b=h.axisValueMaps[d-1];o[c]=((o[c]-b.fromCoordinate)*(p.toCoordinate-b.toCoordinate)+Number.EPSILON)/(p.fromCoordinate-b.fromCoordinate+Number.EPSILON)+b.toCoordinate;break}}}return o}interpolatePoints(s,o,c){if(s.length===0)return;let h=0;for(;h<s.length;){let d=h,p=h,b=s[p];for(;!b.lastPointOfContour;)b=s[++p];for(;h<=p&&!c[h];)h++;if(h>p)continue;let x=h,A=h;for(h++;h<=p;)c[h]&&(this.deltaInterpolate(A+1,h-1,A,h,o,s),A=h),h++;A===x?this.deltaShift(d,p,A,o,s):(this.deltaInterpolate(A+1,p,A,x,o,s),x>0&&this.deltaInterpolate(d,x-1,A,x,o,s)),h=p+1}}deltaInterpolate(s,o,c,h,d,p){if(s>o)return;let b=["x","y"];for(let A=0;A<b.length;A++){let w=b[A];if(d[c][w]>d[h][w]){var x=c;c=h,h=x}let E=d[c][w],P=d[h][w],R=p[c][w],F=p[h][w];if(E!==P||R===F){let L=E===P?0:(F-R)/(P-E);for(let N=s;N<=o;N++){let $=d[N][w];$<=E?$+=R-E:$>=P?$+=F-P:$=R+($-E)*L,p[N][w]=$}}}}deltaShift(s,o,c,h,d){let p=d[c].x-h[c].x,b=d[c].y-h[c].y;if(!(p===0&&b===0))for(let x=s;x<=o;x++)x!==c&&(d[x].x+=p,d[x].y+=b)}transformComponents(s,o,c,h,d,p){let b=0;for(let x=0;x<s.components.length;x++){let A=s.components[x],w=this.font.glyphs.get(A.glyphIndex),E=Mp(A),P=h.indexOf(x);P>-1&&(E.dx+=Math.round(d.deltas[P]*p),E.dy+=Math.round(d.deltasY[P]*p));let R=lr(this.getTransform(w,c).points,E);o.splice(b,R.length,...R),b+=w.points.length}}applyTupleVariationStore(s,o,c,h="gvar",d={}){c||(c=this.font.variation.get());let p=this.getNormalizedCoords(c),{headers:b,sharedPoints:x}=s,A=this.fvar().axes.length,w;h==="gvar"?w=o.map(mc):h==="cvar"&&(w=[...o]);for(let E=0;E<b.length;E++){let P=b[E],R=1;for(let L=0;L<A;L++){let N=[0];switch(h){case"gvar":N=P.peakTuple?P.peakTuple:this.gvar().sharedTuples[P.sharedTupleRecordsIndex];break;case"cvar":N=P.peakTuple;break}if(N[L]!==0){if(p[L]===0){R=0;break}if(P.intermediateStartTuple)if(p[L]<P.intermediateStartTuple[L]||p[L]>P.intermediateEndTuple[L]){R=0;break}else p[L]<N[L]?R=R*(p[L]-P.intermediateStartTuple[L]+Number.EPSILON)/(N[L]-P.intermediateStartTuple[L]+Number.EPSILON):R=R*(P.intermediateEndTuple[L]-p[L]+Number.EPSILON)/(P.intermediateEndTuple[L]-N[L]+Number.EPSILON);else{if(p[L]<Math.min(0,N[L])||p[L]>Math.max(0,N[L])){R=0;break}R=(R*p[L]+Number.EPSILON)/(N[L]+Number.EPSILON)}}}if(R===0)continue;let F=P.privatePoints.length?P.privatePoints:x;if(h==="gvar"&&d.glyph&&d.glyph.isComposite)this.transformComponents(d.glyph,w,c,F,P,R);else if(F.length===0)for(let L=0;L<w.length;L++){let N=w[L];h==="gvar"?w[L]={x:Math.round(N.x+P.deltas[L]*R),y:Math.round(N.y+P.deltasY[L]*R),onCurve:N.onCurve,lastPointOfContour:N.lastPointOfContour}:h==="cvar"&&(w[L]=Math.round(N+P.deltas[L]*R))}else{let L;h==="gvar"?L=w.map(mc):h==="cvar"&&(L=w);let N=Array(o.length).fill(!1);for(let $=0;$<F.length;$++){let vt=F[$];if(vt<o.length){let pt=L[vt];h==="gvar"?(N[vt]=!0,pt.x+=P.deltas[$]*R,pt.y+=P.deltasY[$]*R):h==="cvar"&&(w[vt]=Math.round(pt+P.deltas[$]*R))}}if(h==="gvar"){this.interpolatePoints(L,w,N);for(let $=0;$<o.length;$++){let vt=L[$].x-w[$].x,pt=L[$].y-w[$].y;w[$].x=Math.round(w[$].x+vt),w[$].y=Math.round(w[$].y+pt)}}}}return w}getTransform(s,o){Number.isInteger(s)&&(s=this.font.glyphs.get(s));let c=s.getBlendPath,h=!!(s.points&&s.points.length),d=s;if(c||h){if(o||(o=this.font.variation.get()),h){let p=this.gvar()&&this.gvar().glyphVariations[s.index];if(p){let b=s.points,x=this.applyTupleVariationStore(p,b,o,"gvar",{glyph:s});d=new zn(Object.assign({},s,{points:x,path:Qi(x)}))}}else if(c){let p=s.getBlendPath(o);d=new zn(Object.assign({},s,{path:p}))}}return this.font.tables.hvar&&(s._advanceWidth=typeof s._advanceWidth<"u"?s._advanceWidth:s.advanceWidth,s.advanceWidth=d.advanceWidth=Math.round(s._advanceWidth+this.getVariableAdjustment(d.index,"hvar","advanceWidth",o)),s._leftSideBearing=typeof s._leftSideBearing<"u"?s._leftSideBearing:s.leftSideBearing,s.leftSideBearing=d.leftSideBearing=Math.round(s._leftSideBearing+this.getVariableAdjustment(d.index,"hvar","lsb",o))),d}getCvarTransform(s){let o=this.font.tables.cvt,c=this.cvar();return!o||!o.length||!c||!c.headers.length?o:this.applyTupleVariationStore(c,o,s,"cvar")}getVariableAdjustment(s,o,c,h){h=h||this.font.variation.get();let d,p,b=this.font.tables[o];if(!b)throw Error(`trying to get variation adjustment from non-existent table "${b}"`);if(!b.itemVariationStore)throw Error(`trying to get variation adjustment from table "${b}" which does not have an itemVariationStore`);let x=b[c]&&b[c].map.length;if(x){let A=s;A>=x&&(A=x-1),{outerIndex:d,innerIndex:p}=b[c].map[A]}else d=0,p=s;return this.getDelta(b.itemVariationStore,d,p,h)}getDelta(s,o,c,h){if(o>=s.itemVariationSubtables.length)return 0;let d=s.itemVariationSubtables[o];if(c>=d.deltaSets.length)return 0;let p=d.deltaSets[c],b=this.getBlendVector(s,o,h),x=0;for(let A=0;A<d.regionIndexes.length;A++)x+=p[A]*b[A];return x}getBlendVector(s,o,c){c||(c=this.font.variation.get());let h=s.itemVariationSubtables[o],d=this.getNormalizedCoords(c),p=[];for(let b=0;b<h.regionIndexes.length;b++){let x=1,A=h.regionIndexes[b],w=s.variationRegions[A].regionAxes;for(let E=0;E<w.length;E++){let P=w[E],R;P.startCoord>P.peakCoord||P.peakCoord>P.endCoord||P.startCoord<0&&P.endCoord>0&&P.peakCoord!==0||P.peakCoord===0?R=1:d[E]<P.startCoord||d[E]>P.endCoord?R=0:d[E]===P.peakCoord?R=1:d[E]<P.peakCoord?R=(d[E]-P.startCoord+Number.EPSILON)/(P.peakCoord-P.startCoord+Number.EPSILON):R=(P.endCoord-d[E]+Number.EPSILON)/(P.endCoord-P.peakCoord+Number.EPSILON),x*=R}p[b]=x}return p}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},Yp=class{constructor(s){this.font=s,this.process=new Xp(this.font),this.activateDefaultVariation(),this.getTransform=this.process.getTransform.bind(this.process)}activateDefaultVariation(){let s=this.getDefaultInstanceIndex();s>-1?this.set(s):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((s,o)=>(s[o.tag]=o.defaultValue,s),{})}getDefaultInstanceIndex(){let s=this.getDefaultCoordinates(),o=this.getInstanceIndex(s);return o<0&&(o=this.fvar().instances.findIndex(c=>c.name&&c.name.en==="Regular")),o}getInstanceIndex(s){return this.fvar().instances.findIndex(o=>Object.keys(s).every(c=>o.coordinates[c]===s[c]))}getInstance(s){return this.fvar().instances&&this.fvar().instances[s]}set(s){let o;if(Number.isInteger(s)){let c=this.getInstance(s);if(!c)throw Error(`Invalid instance index ${s}`);o={...c.coordinates}}else o=s,this.process.normalizeCoordTags(o);o=Object.assign({},this.font.defaultRenderOptions.variation,o),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:o})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},Ac=1e6,cr=64,ur=1e4,Tc,wn,Cc,Ji;function Ec(s){this.font=s,this.getCommands=function(o){return Sc.getPath(o).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function Kp(s){return s}function wc(s){return Math.sign(s)*Math.round(Math.abs(s))}function Zp(s){return Math.sign(s)*Math.round(Math.abs(s*2))/2}function Qp(s){return Math.sign(s)*(Math.round(Math.abs(s)+.5)-.5)}function Jp(s){return Math.sign(s)*Math.ceil(Math.abs(s))}function qp(s){return Math.sign(s)*Math.floor(Math.abs(s))}var kc=function(s){let o=this.srPeriod,c=this.srPhase,h=this.srThreshold,d=1;return s<0&&(s=-s,d=-1),s+=h-c,s=Math.trunc(s/o)*o,s+=c,s<0?c*d:s*d},ze={x:1,y:0,axis:"x",distance:function(s,o,c,h){return(c?s.xo:s.x)-(h?o.xo:o.x)},interpolate:function(s,o,c,h){let d,p,b,x,A,w,E;if(!h||h===this){if(d=s.xo-o.xo,p=s.xo-c.xo,A=o.x-o.xo,w=c.x-c.xo,b=Math.abs(d),x=Math.abs(p),E=b+x,E===0){s.x=s.xo+(A+w)/2;return}s.x=s.xo+(A*x+w*b)/E;return}if(d=h.distance(s,o,!0,!0),p=h.distance(s,c,!0,!0),A=h.distance(o,o,!1,!0),w=h.distance(c,c,!1,!0),b=Math.abs(d),x=Math.abs(p),E=b+x,E===0){ze.setRelative(s,s,(A+w)/2,h,!0);return}ze.setRelative(s,s,(A*x+w*b)/E,h,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(s,o,c,h,d){if(!h||h===this){s.x=(d?o.xo:o.x)+c;return}let p=d?o.xo:o.x,b=d?o.yo:o.y,x=p+c*h.x,A=b+c*h.y;s.x=x+(s.y-A)/h.normalSlope},slope:0,touch:function(s){s.xTouched=!0},touched:function(s){return s.xTouched},untouch:function(s){s.xTouched=!1}},qe={x:0,y:1,axis:"y",distance:function(s,o,c,h){return(c?s.yo:s.y)-(h?o.yo:o.y)},interpolate:function(s,o,c,h){let d,p,b,x,A,w,E;if(!h||h===this){if(d=s.yo-o.yo,p=s.yo-c.yo,A=o.y-o.yo,w=c.y-c.yo,b=Math.abs(d),x=Math.abs(p),E=b+x,E===0){s.y=s.yo+(A+w)/2;return}s.y=s.yo+(A*x+w*b)/E;return}if(d=h.distance(s,o,!0,!0),p=h.distance(s,c,!0,!0),A=h.distance(o,o,!1,!0),w=h.distance(c,c,!1,!0),b=Math.abs(d),x=Math.abs(p),E=b+x,E===0){qe.setRelative(s,s,(A+w)/2,h,!0);return}qe.setRelative(s,s,(A*x+w*b)/E,h,!0)},normalSlope:0,setRelative:function(s,o,c,h,d){if(!h||h===this){s.y=(d?o.yo:o.y)+c;return}let p=d?o.xo:o.x,b=d?o.yo:o.y,x=p+c*h.x,A=b+c*h.y;s.y=A+h.normalSlope*(s.x-x)},slope:Number.POSITIVE_INFINITY,touch:function(s){s.yTouched=!0},touched:function(s){return s.yTouched},untouch:function(s){s.yTouched=!1}};Object.freeze(ze),Object.freeze(qe);function fs(s,o){this.x=s,this.y=o,this.axis=void 0,this.slope=o/s,this.normalSlope=-s/o,Object.freeze(this)}fs.prototype.distance=function(s,o,c,h){return this.x*ze.distance(s,o,c,h)+this.y*qe.distance(s,o,c,h)},fs.prototype.interpolate=function(s,o,c,h){let d,p,b,x,A,w,E;if(b=h.distance(s,o,!0,!0),x=h.distance(s,c,!0,!0),d=h.distance(o,o,!1,!0),p=h.distance(c,c,!1,!0),A=Math.abs(b),w=Math.abs(x),E=A+w,E===0){this.setRelative(s,s,(d+p)/2,h,!0);return}this.setRelative(s,s,(d*w+p*A)/E,h,!0)},fs.prototype.setRelative=function(s,o,c,h,d){h=h||this;let p=d?o.xo:o.x,b=d?o.yo:o.y,x=p+c*h.x,A=b+c*h.y,w=h.normalSlope,E=this.slope,P=s.x,R=s.y;s.x=(E*P-w*x+A-R)/(E-w),s.y=E*(s.x-P)+R},fs.prototype.touch=function(s){s.xTouched=!0,s.yTouched=!0};function ps(s,o){let c=Math.sqrt(s*s+o*o);return s/=c,o/=c,s===1&&o===0?ze:s===0&&o===1?qe:new fs(s,o)}function tn(s,o,c,h){this.x=this.xo=Math.round(s*64)/64,this.y=this.yo=Math.round(o*64)/64,this.lastPointOfContour=c,this.onCurve=h,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}tn.prototype.nextTouched=function(s){let o=this.nextPointOnContour;for(;!s.touched(o)&&o!==this;)o=o.nextPointOnContour;return o},tn.prototype.prevTouched=function(s){let o=this.prevPointOnContour;for(;!s.touched(o)&&o!==this;)o=o.prevPointOnContour;return o};var gs=Object.freeze(new tn(0,0)),tg={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function on(s,o){switch(this.env=s,this.stack=[],this.prog=o,s){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=ze,this.round=wc}}Ec.prototype.exec=function(s,o){if(typeof o!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;let c=this.font,h=this._prepState;if(!h||h.ppem!==o){let d=this._fpgmState;if(!d){on.prototype=tg,d=this._fpgmState=new on("fpgm",c.tables.fpgm),d.funcs=[],d.font=c,d.instructionCount=0,d.callDepth=0;try{wn(d)}catch(b){console.log("Hinting error in FPGM:"+b),this._errorState=3;return}}on.prototype=d,h=this._prepState=new on("prep",c.tables.prep),h.ppem=o,h.instructionCount=0,h.callDepth=0;let p=c.variation&&c.variation.process.getCvarTransform()||c.tables.cvt;if(p){let b=h.cvt=new Array(p.length),x=o/c.unitsPerEm;for(let A=0;A<p.length;A++)b[A]=p[A]*x}else h.cvt=[];try{wn(h)}catch(b){this._errorState<2&&console.log("Hinting error in PREP:"+b),this._errorState=2}}if(!(this._errorState>1))try{return Cc(s,h)}catch(d){this._errorState<1&&(console.log("Hinting error:"+d),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}},Cc=function(s,o){let c=o.ppem/o.font.unitsPerEm,h=c,d=s.components,p,b,x;if(on.prototype=o,!d)x=new on("glyf",s.instructions),x.instructionCount=0,x.callDepth=0,Ji(s,x,c,h),b=x.gZone;else{let A=o.font;b=[],p=[];for(let w=0;w<d.length;w++){let E=d[w],P=A.glyphs.get(E.glyphIndex);x=new on("glyf",P.instructions),x.instructionCount=0,x.callDepth=0,Ji(P,x,c,h);let R=Math.round(E.dx*c),F=Math.round(E.dy*h),L=x.gZone,N=x.contours;for(let vt=0;vt<L.length;vt++){let pt=L[vt];pt.xTouched=pt.yTouched=!1,pt.xo=pt.x=pt.x+R,pt.yo=pt.y=pt.y+F}let $=b.length;b.push.apply(b,L);for(let vt=0;vt<N.length;vt++)p.push(N[vt]+$)}s.instructions&&!x.inhibitGridFit&&(x=new on("glyf",s.instructions),x.gZone=x.z0=x.z1=x.z2=b,x.contours=p,b.push(new tn(0,0),new tn(Math.round(s.advanceWidth*c),0)),wn(x),b.length-=2)}return b},Ji=function(s,o,c,h){let d=s.points||[],p=d.length,b=o.gZone=o.z0=o.z1=o.z2=[],x=o.contours=[],A;for(let P=0;P<p;P++)A=d[P],b[P]=new tn(A.x*c,A.y*h,A.lastPointOfContour,A.onCurve);let w,E;for(let P=0;P<p;P++)A=b[P],w||(w=A,x.push(P)),A.lastPointOfContour?(A.nextPointOnContour=w,w.prevPointOnContour=A,w=void 0):(E=b[P+1],A.nextPointOnContour=E,E.prevPointOnContour=A);o.inhibitGridFit||(b.push(new tn(0,0),new tn(Math.round(s.advanceWidth*c),0)),wn(o),b.length-=2)},wn=function(s){let o=s.prog;if(!o)return;let c=o.length,h;for(s.ip=0;s.ip<c;s.ip++){if(++s.instructionCount>Ac)throw new Error("Hinting instructions exceeded maximum of "+Ac);if(h=Tc[o[s.ip]],!h)throw new Error("unknown instruction: 0x"+Number(o[s.ip]).toString(16));h(s)}};function hr(s){let o=s.tZone=new Array(s.gZone.length);for(let c=0;c<o.length;c++)o[c]=new tn(0,0)}function Ic(s,o){let c=s.prog,h=s.ip,d=1,p;do if(p=c[++h],p===88)d++;else if(p===89)d--;else if(p===64)h+=c[h+1]+1;else if(p===65)h+=2*c[h+1]+1;else if(p>=176&&p<=183)h+=p-176+1;else if(p>=184&&p<=191)h+=(p-184+1)*2;else if(o&&d===1&&p===27)break;while(d>0);s.ip=h}function Rc(s,o){o.fv=o.pv=o.dpv=s}function Pc(s,o){o.pv=o.dpv=s}function Oc(s,o){o.fv=s}function Mc(s,o){let c=o.stack,h=c.pop(),d=c.pop(),p=o.z2[h],b=o.z1[d],x,A;s?(x=p.y-b.y,A=b.x-p.x):(x=b.x-p.x,A=b.y-p.y),o.pv=o.dpv=ps(x,A)}function Lc(s,o){let c=o.stack,h=c.pop(),d=c.pop(),p=o.z2[h],b=o.z1[d],x,A;s?(x=p.y-b.y,A=b.x-p.x):(x=b.x-p.x,A=b.y-p.y),o.fv=ps(x,A)}function eg(s){let o=s.stack,c=o.pop(),h=o.pop();s.pv=s.dpv=ps(h,c)}function ng(s){let o=s.stack,c=o.pop(),h=o.pop();s.fv=ps(h,c)}function sg(s){let o=s.stack,c=s.pv;o.push(c.x*16384),o.push(c.y*16384)}function rg(s){let o=s.stack,c=s.fv;o.push(c.x*16384),o.push(c.y*16384)}function ig(s){s.fv=s.pv}function og(s){let o=s.stack,c=o.pop(),h=o.pop(),d=o.pop(),p=o.pop(),b=o.pop(),x=s.z0,A=s.z1,w=x[c],E=x[h],P=A[d],R=A[p],F=s.z2[b],L=w.x,N=w.y,$=E.x,vt=E.y,pt=P.x,At=P.y,It=R.x,Ut=R.y,Gt=(L-$)*(At-Ut)-(N-vt)*(pt-It),Ht=L*vt-N*$,Jt=pt*Ut-At*It;F.x=(Ht*(pt-It)-Jt*(L-$))/Gt,F.y=(Ht*(At-Ut)-Jt*(N-vt))/Gt}function ag(s){s.rp0=s.stack.pop()}function lg(s){s.rp1=s.stack.pop()}function cg(s){s.rp2=s.stack.pop()}function ug(s){let o=s.stack.pop();switch(s.zp0=o,o){case 0:s.tZone||hr(s),s.z0=s.tZone;break;case 1:s.z0=s.gZone;break;default:throw new Error("Invalid zone pointer")}}function hg(s){let o=s.stack.pop();switch(s.zp1=o,o){case 0:s.tZone||hr(s),s.z1=s.tZone;break;case 1:s.z1=s.gZone;break;default:throw new Error("Invalid zone pointer")}}function dg(s){let o=s.stack.pop();switch(s.zp2=o,o){case 0:s.tZone||hr(s),s.z2=s.tZone;break;case 1:s.z2=s.gZone;break;default:throw new Error("Invalid zone pointer")}}function fg(s){let o=s.stack.pop();switch(s.zp0=s.zp1=s.zp2=o,o){case 0:s.tZone||hr(s),s.z0=s.z1=s.z2=s.tZone;break;case 1:s.z0=s.z1=s.z2=s.gZone;break;default:throw new Error("Invalid zone pointer")}}function pg(s){s.loop=s.stack.pop(),s.loop>ur&&(s.loop=ur)}function gg(s){s.round=wc}function mg(s){s.round=Qp}function yg(s){let o=s.stack.pop();s.minDis=o/64}function bg(s){Ic(s,!1)}function vg(s){let o=s.stack.pop();s.ip+=o-1}function xg(s){let o=s.stack.pop();s.cvCutIn=o/64}function Sg(s){let o=s.stack;o.push(o[o.length-1])}function qi(s){s.stack.pop()}function Ag(s){s.stack.length=0}function Tg(s){let o=s.stack,c=o.pop(),h=o.pop();o.push(c),o.push(h)}function Cg(s){let o=s.stack;o.push(o.length)}function Eg(s){let o=s.stack,c=o.pop(),h=o.pop();if(h>ur&&(h=ur),++s.callDepth>cr)throw new Error("Hinting call depth exceeded maximum of "+cr);let d=s.ip,p=s.prog;s.prog=s.funcs[c];for(let b=0;b<h;b++)wn(s);s.ip=d,s.prog=p,s.callDepth--}function wg(s){let o=s.stack.pop();if(++s.callDepth>cr)throw new Error("Hinting call depth exceeded maximum of "+cr);let c=s.ip,h=s.prog;s.prog=s.funcs[o],wn(s),s.ip=c,s.prog=h,s.callDepth--}function kg(s){let o=s.stack,c=o.pop();o.push(o[o.length-c])}function Ig(s){let o=s.stack,c=o.pop();o.push(o.splice(o.length-c,1)[0])}function Rg(s){if(s.env!=="fpgm")throw new Error("FDEF not allowed here");let o=s.stack,c=s.prog,h=s.ip,d=o.pop(),p=h;for(;c[++h]!==45;);s.ip=h,s.funcs[d]=c.slice(p+1,h)}function Fc(s,o){let c=o.stack.pop(),h=o.z0[c],d=o.fv,p=o.pv,b=p.distance(h,gs);s&&(b=o.round(b)),d.setRelative(h,gs,b,p),d.touch(h),o.rp0=o.rp1=c}function Dc(s,o){let c=o.z2,h=c.length-2,d,p,b;for(let x=0;x<h;x++)d=c[x],!s.touched(d)&&(p=d.prevTouched(s),p!==d&&(b=d.nextTouched(s),p===b&&s.setRelative(d,d,s.distance(p,p,!1,!0),s,!0),s.interpolate(d,p,b,s)))}function _c(s,o){let c=o.stack,h=s?o.rp1:o.rp2,d=(s?o.z0:o.z1)[h],p=o.fv,b=o.pv,x=o.loop,A=o.z2;for(;x--;){let w=c.pop(),E=A[w],P=b.distance(d,d,!1,!0);p.setRelative(E,E,P,b),p.touch(E)}o.loop=1}function Nc(s,o){let c=o.stack,h=s?o.rp1:o.rp2,d=(s?o.z0:o.z1)[h],p=o.fv,b=o.pv,x=c.pop(),A=o.z2[o.contours[x]],w=A,E=b.distance(d,d,!1,!0);do w!==d&&p.setRelative(w,w,E,b),w=w.nextPointOnContour;while(w!==A)}function Uc(s,o){let c=o.stack,h=s?o.rp1:o.rp2,d=(s?o.z0:o.z1)[h],p=o.fv,b=o.pv,x=c.pop(),A;switch(x){case 0:A=o.tZone;break;case 1:A=o.gZone;break;default:throw new Error("Invalid zone")}let w,E=b.distance(d,d,!1,!0),P=A.length-2;for(let R=0;R<P;R++)w=A[R],p.setRelative(w,w,E,b)}function Pg(s){let o=s.stack,c=s.loop,h=s.fv,d=o.pop()/64,p=s.z2;for(;c--;){let b=o.pop(),x=p[b];h.setRelative(x,x,d),h.touch(x)}s.loop=1}function Og(s){let o=s.stack,c=s.rp1,h=s.rp2,d=s.loop,p=s.z0[c],b=s.z1[h],x=s.fv,A=s.dpv,w=s.z2;for(;d--;){let E=o.pop(),P=w[E];x.interpolate(P,p,b,A),x.touch(P)}s.loop=1}function Bc(s,o){let c=o.stack,h=c.pop()/64,d=c.pop(),p=o.z1[d],b=o.z0[o.rp0],x=o.fv,A=o.pv;x.setRelative(p,b,h,A),x.touch(p),o.rp1=o.rp0,o.rp2=d,s&&(o.rp0=d)}function Mg(s){let o=s.stack,c=s.rp0,h=s.z0[c],d=s.loop,p=s.fv,b=s.pv,x=s.z1;for(;d--;){let A=o.pop(),w=x[A];p.setRelative(w,h,0,b),p.touch(w)}s.loop=1}function Lg(s){s.round=Zp}function Gc(s,o){let c=o.stack,h=c.pop(),d=c.pop(),p=o.z0[d],b=o.fv,x=o.pv,A=o.cvt[h],w=x.distance(p,gs);s&&(Math.abs(w-A)<o.cvCutIn&&(w=A),w=o.round(w)),b.setRelative(p,gs,w,x),o.zp0===0&&(p.xo=p.x,p.yo=p.y),b.touch(p),o.rp0=o.rp1=d}function Fg(s){let o=s.prog,c=s.ip,h=s.stack,d=o[++c];for(let p=0;p<d;p++)h.push(o[++c]);s.ip=c}function Dg(s){let o=s.ip,c=s.prog,h=s.stack,d=c[++o];for(let p=0;p<d;p++){let b=c[++o]<<8|c[++o];b&32768&&(b=-((b^65535)+1)),h.push(b)}s.ip=o}function _g(s){let o=s.stack,c=s.store;c||(c=s.store=[]);let h=o.pop(),d=o.pop();c[d]=h}function Ng(s){let o=s.stack,c=s.store,h=o.pop(),d=c&&c[h]||0;o.push(d)}function Ug(s){let o=s.stack,c=o.pop(),h=o.pop();s.cvt[h]=c/64}function Bg(s){let o=s.stack,c=o.pop();o.push(s.cvt[c]*64)}function Hc(s,o){let c=o.stack,h=c.pop(),d=o.z2[h];c.push(o.dpv.distance(d,gs,s,!1)*64)}function jc(s,o){let c=o.stack,h=c.pop(),d=c.pop(),p=o.z1[h],b=o.z0[d],x=o.dpv.distance(b,p,s,s);o.stack.push(Math.round(x*64))}function Gg(s){s.stack.push(s.ppem)}function Hg(s){s.autoFlip=!0}function jg(s){let o=s.stack,c=o.pop(),h=o.pop();o.push(h<c?1:0)}function Vg(s){let o=s.stack,c=o.pop(),h=o.pop();o.push(h<=c?1:0)}function Wg(s){let o=s.stack,c=o.pop(),h=o.pop();o.push(h>c?1:0)}function $g(s){let o=s.stack,c=o.pop(),h=o.pop();o.push(h>=c?1:0)}function zg(s){let o=s.stack,c=o.pop(),h=o.pop();o.push(c===h?1:0)}function Xg(s){let o=s.stack,c=o.pop(),h=o.pop();o.push(c!==h?1:0)}function Yg(s){let o=s.stack,c=o.pop();o.push(Math.trunc(c)&1?1:0)}function Kg(s){let o=s.stack,c=o.pop();o.push(Math.trunc(c)&1?0:1)}function Zg(s){let o=s.stack.pop(),c;o||Ic(s,!0)}function Qg(s){}function Jg(s){let o=s.stack,c=o.pop(),h=o.pop();o.push(c&&h?1:0)}function qg(s){let o=s.stack,c=o.pop(),h=o.pop();o.push(c||h?1:0)}function tm(s){let o=s.stack,c=o.pop();o.push(c?0:1)}function to(s,o){let c=o.stack,h=c.pop(),d=o.fv,p=o.pv,b=o.ppem,x=o.deltaBase+(s-1)*16,A=o.deltaShift,w=o.z0;for(let E=0;E<h;E++){let P=c.pop(),R=c.pop();if(x+((R&240)>>4)!==b)continue;let L=(R&15)-8;L>=0&&L++;let N=w[P];d.setRelative(N,N,L*A,p)}}function em(s){let c=s.stack.pop();s.deltaBase=c}function nm(s){let c=s.stack.pop();s.deltaShift=Math.pow(.5,c)}function sm(s){let o=s.stack,c=o.pop(),h=o.pop();o.push(h+c)}function rm(s){let o=s.stack,c=o.pop(),h=o.pop();o.push(h-c)}function im(s){let o=s.stack,c=o.pop(),h=o.pop();o.push(h*64/c)}function om(s){let o=s.stack,c=o.pop(),h=o.pop();o.push(h*c/64)}function am(s){let o=s.stack,c=o.pop();o.push(Math.abs(c))}function lm(s){let o=s.stack,c=o.pop();o.push(-c)}function cm(s){let o=s.stack,c=o.pop();o.push(Math.floor(c/64)*64)}function um(s){let o=s.stack,c=o.pop();o.push(Math.ceil(c/64)*64)}function dr(s,o){let c=o.stack,h=c.pop();c.push(o.round(h/64)*64)}function hm(s){let o=s.stack,c=o.pop(),h=o.pop();s.cvt[h]=c*s.ppem/s.font.unitsPerEm}function eo(s,o){let c=o.stack,h=c.pop(),d=o.ppem,p=o.deltaBase+(s-1)*16,b=o.deltaShift;for(let x=0;x<h;x++){let A=c.pop(),w=c.pop();if(p+((w&240)>>4)!==d)continue;let P=(w&15)-8;P>=0&&P++;let R=P*b;o.cvt[A]+=R}}function dm(s){let o=s.stack.pop();s.round=kc;let c;switch(o&192){case 0:c=.5;break;case 64:c=1;break;case 128:c=2;break;default:throw new Error("invalid SROUND value")}switch(s.srPeriod=c,o&48){case 0:s.srPhase=0;break;case 16:s.srPhase=.25*c;break;case 32:s.srPhase=.5*c;break;case 48:s.srPhase=.75*c;break;default:throw new Error("invalid SROUND value")}o&=15,o===0?s.srThreshold=0:s.srThreshold=(o/8-.5)*c}function fm(s){let o=s.stack.pop();s.round=kc;let c;switch(o&192){case 0:c=Math.sqrt(2)/2;break;case 64:c=Math.sqrt(2);break;case 128:c=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(s.srPeriod=c,o&48){case 0:s.srPhase=0;break;case 16:s.srPhase=.25*c;break;case 32:s.srPhase=.5*c;break;case 48:s.srPhase=.75*c;break;default:throw new Error("invalid S45ROUND value")}o&=15,o===0?s.srThreshold=0:s.srThreshold=(o/8-.5)*c}function pm(s){s.round=Kp}function gm(s){s.round=Jp}function mm(s){s.round=qp}function ym(s){let o=s.stack.pop()}function Vc(s,o){let c=o.stack,h=c.pop(),d=c.pop(),p=o.z2[h],b=o.z1[d],x,A;s?(x=p.y-b.y,A=b.x-p.x):(x=b.x-p.x,A=b.y-p.y),o.dpv=ps(x,A)}function bm(s){let o=s.stack,c=o.pop(),h=0;c&1&&(h=35),c&32&&(h|=4096),o.push(h)}function vm(s){let o=s.stack,c=o.pop(),h=o.pop(),d=o.pop();o.push(h),o.push(c),o.push(d)}function xm(s){let o=s.stack,c=o.pop(),h=o.pop();o.push(Math.max(h,c))}function Sm(s){let o=s.stack,c=o.pop(),h=o.pop();o.push(Math.min(h,c))}function Am(s){let o=s.stack.pop()}function Tm(s){let o=s.stack.pop(),c=s.stack.pop();switch(o){case 1:s.inhibitGridFit=!!c;return;case 2:s.ignoreCvt=!!c;return;default:throw new Error("invalid INSTCTRL[] selector")}}function an(s,o){let c=o.stack,h=o.prog,d=o.ip;for(let p=0;p<s;p++)c.push(h[++d]);o.ip=d}function ln(s,o){let c=o.ip,h=o.prog,d=o.stack;for(let p=0;p<s;p++){let b=h[++c]<<8|h[++c];b&32768&&(b=-((b^65535)+1)),d.push(b)}o.ip=c}function mt(s,o,c,h,d,p){let b=p.stack,x=s&&b.pop(),A=b.pop(),w=p.rp0,E=p.z0[w],P=p.z1[A],R=p.minDis,F=p.fv,L=p.dpv,N,$,vt,pt;$=N=L.distance(P,E,!0,!0),vt=$>=0?1:-1,$=Math.abs($),s&&(pt=p.cvt[x],h&&Math.abs($-pt)<p.cvCutIn&&($=pt)),c&&$<R&&($=R),h&&($=p.round($)),F.setRelative(P,E,vt*$,L),F.touch(P),p.rp1=p.rp0,p.rp2=A,o&&(p.rp0=A)}Tc=[Rc.bind(void 0,qe),Rc.bind(void 0,ze),Pc.bind(void 0,qe),Pc.bind(void 0,ze),Oc.bind(void 0,qe),Oc.bind(void 0,ze),Mc.bind(void 0,0),Mc.bind(void 0,1),Lc.bind(void 0,0),Lc.bind(void 0,1),eg,ng,sg,rg,ig,og,ag,lg,cg,ug,hg,dg,fg,pg,gg,mg,yg,bg,vg,xg,void 0,void 0,Sg,qi,Ag,Tg,Cg,kg,Ig,void 0,void 0,void 0,Eg,wg,Rg,void 0,Fc.bind(void 0,0),Fc.bind(void 0,1),Dc.bind(void 0,qe),Dc.bind(void 0,ze),_c.bind(void 0,0),_c.bind(void 0,1),Nc.bind(void 0,0),Nc.bind(void 0,1),Uc.bind(void 0,0),Uc.bind(void 0,1),Pg,Og,Bc.bind(void 0,0),Bc.bind(void 0,1),Mg,Lg,Gc.bind(void 0,0),Gc.bind(void 0,1),Fg,Dg,_g,Ng,Ug,Bg,Hc.bind(void 0,0),Hc.bind(void 0,1),void 0,jc.bind(void 0,0),jc.bind(void 0,1),Gg,void 0,Hg,void 0,void 0,jg,Vg,Wg,$g,zg,Xg,Yg,Kg,Zg,Qg,Jg,qg,tm,to.bind(void 0,1),em,nm,sm,rm,im,om,am,lm,cm,um,dr.bind(void 0,0),dr.bind(void 0,1),dr.bind(void 0,2),dr.bind(void 0,3),void 0,void 0,void 0,void 0,hm,to.bind(void 0,2),to.bind(void 0,3),eo.bind(void 0,1),eo.bind(void 0,2),eo.bind(void 0,3),dm,fm,void 0,void 0,pm,void 0,gm,mm,qi,qi,void 0,void 0,void 0,void 0,void 0,ym,Vc.bind(void 0,0),Vc.bind(void 0,1),bm,void 0,vm,xm,Sm,Am,Tm,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,an.bind(void 0,1),an.bind(void 0,2),an.bind(void 0,3),an.bind(void 0,4),an.bind(void 0,5),an.bind(void 0,6),an.bind(void 0,7),an.bind(void 0,8),ln.bind(void 0,1),ln.bind(void 0,2),ln.bind(void 0,3),ln.bind(void 0,4),ln.bind(void 0,5),ln.bind(void 0,6),ln.bind(void 0,7),ln.bind(void 0,8),mt.bind(void 0,0,0,0,0,0),mt.bind(void 0,0,0,0,0,1),mt.bind(void 0,0,0,0,0,2),mt.bind(void 0,0,0,0,0,3),mt.bind(void 0,0,0,0,1,0),mt.bind(void 0,0,0,0,1,1),mt.bind(void 0,0,0,0,1,2),mt.bind(void 0,0,0,0,1,3),mt.bind(void 0,0,0,1,0,0),mt.bind(void 0,0,0,1,0,1),mt.bind(void 0,0,0,1,0,2),mt.bind(void 0,0,0,1,0,3),mt.bind(void 0,0,0,1,1,0),mt.bind(void 0,0,0,1,1,1),mt.bind(void 0,0,0,1,1,2),mt.bind(void 0,0,0,1,1,3),mt.bind(void 0,0,1,0,0,0),mt.bind(void 0,0,1,0,0,1),mt.bind(void 0,0,1,0,0,2),mt.bind(void 0,0,1,0,0,3),mt.bind(void 0,0,1,0,1,0),mt.bind(void 0,0,1,0,1,1),mt.bind(void 0,0,1,0,1,2),mt.bind(void 0,0,1,0,1,3),mt.bind(void 0,0,1,1,0,0),mt.bind(void 0,0,1,1,0,1),mt.bind(void 0,0,1,1,0,2),mt.bind(void 0,0,1,1,0,3),mt.bind(void 0,0,1,1,1,0),mt.bind(void 0,0,1,1,1,1),mt.bind(void 0,0,1,1,1,2),mt.bind(void 0,0,1,1,1,3),mt.bind(void 0,1,0,0,0,0),mt.bind(void 0,1,0,0,0,1),mt.bind(void 0,1,0,0,0,2),mt.bind(void 0,1,0,0,0,3),mt.bind(void 0,1,0,0,1,0),mt.bind(void 0,1,0,0,1,1),mt.bind(void 0,1,0,0,1,2),mt.bind(void 0,1,0,0,1,3),mt.bind(void 0,1,0,1,0,0),mt.bind(void 0,1,0,1,0,1),mt.bind(void 0,1,0,1,0,2),mt.bind(void 0,1,0,1,0,3),mt.bind(void 0,1,0,1,1,0),mt.bind(void 0,1,0,1,1,1),mt.bind(void 0,1,0,1,1,2),mt.bind(void 0,1,0,1,1,3),mt.bind(void 0,1,1,0,0,0),mt.bind(void 0,1,1,0,0,1),mt.bind(void 0,1,1,0,0,2),mt.bind(void 0,1,1,0,0,3),mt.bind(void 0,1,1,0,1,0),mt.bind(void 0,1,1,0,1,1),mt.bind(void 0,1,1,0,1,2),mt.bind(void 0,1,1,0,1,3),mt.bind(void 0,1,1,1,0,0),mt.bind(void 0,1,1,1,0,1),mt.bind(void 0,1,1,1,0,2),mt.bind(void 0,1,1,1,0,3),mt.bind(void 0,1,1,1,1,0),mt.bind(void 0,1,1,1,1,1),mt.bind(void 0,1,1,1,1,2),mt.bind(void 0,1,1,1,1,3)];var Cm=Ec;function Kn(s){this.char=s,this.state={},this.activeState=null}function no(s,o,c){this.contextName=c,this.startIndex=s,this.endOffset=o}function Em(s,o,c){this.contextName=s,this.openRange=null,this.ranges=[],this.checkStart=o,this.checkEnd=c}function he(s,o){this.context=s,this.index=o,this.length=s.length,this.current=s[o],this.backtrack=s.slice(0,o),this.lookahead=s.slice(o+1)}function fr(s){this.eventId=s,this.subscribers=[]}function wm(s){let o=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];for(let h=0;h<o.length;h++){let d=o[h];Object.defineProperty(this.events,d,{value:new fr(d)})}if(s)for(let h=0;h<o.length;h++){let d=o[h],p=s[d];typeof p=="function"&&this.events[d].subscribe(p)}let c=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];for(let h=0;h<c.length;h++){let d=c[h];this.events[d].subscribe(this.updateContextsRanges)}}function Yt(s){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],wm.call(this,s)}Kn.prototype.setState=function(s,o){return this.state[s]=o,this.activeState={key:s,value:this.state[s]},this.activeState},Kn.prototype.getState=function(s){return this.state[s]||null},Yt.prototype.inboundIndex=function(s){return s>=0&&s<this.tokens.length},Yt.prototype.composeRUD=function(s){let c=s.map(d=>this[d[0]].apply(this,d.slice(1).concat(!0))),h=d=>typeof d=="object"&&Object.prototype.hasOwnProperty.call(d,"FAIL");if(c.every(h))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:c.filter(h)};this.dispatch("composeRUD",[c.filter(d=>!h(d))])},Yt.prototype.replaceRange=function(s,o,c,h){o=o!==null?o:this.tokens.length;let d=c.every(p=>p instanceof Kn);if(!isNaN(s)&&this.inboundIndex(s)&&d){let p=this.tokens.splice.apply(this.tokens,[s,o].concat(c));return h||this.dispatch("replaceToken",[s,o,c]),[p,c]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}},Yt.prototype.replaceToken=function(s,o,c){if(!isNaN(s)&&this.inboundIndex(s)&&o instanceof Kn){let h=this.tokens.splice(s,1,o);return c||this.dispatch("replaceToken",[s,o]),[h[0],o]}else return{FAIL:"replaceToken: invalid token or index."}},Yt.prototype.removeRange=function(s,o,c){o=isNaN(o)?this.tokens.length:o;let h=this.tokens.splice(s,o);return c||this.dispatch("removeRange",[h,s,o]),h},Yt.prototype.removeToken=function(s,o){if(!isNaN(s)&&this.inboundIndex(s)){let c=this.tokens.splice(s,1);return o||this.dispatch("removeToken",[c,s]),c}else return{FAIL:"removeToken: invalid token index."}},Yt.prototype.insertToken=function(s,o,c){return s.every(d=>d instanceof Kn)?(this.tokens.splice.apply(this.tokens,[o,0].concat(s)),c||this.dispatch("insertToken",[s,o]),s):{FAIL:"insertToken: invalid token(s)."}},Yt.prototype.registerModifier=function(s,o,c){this.events.newToken.subscribe(function(h,d){let p=[h,d],b=o===null||o.apply(this,p)===!0,x=[h,d];if(b){let A=c.apply(this,x);h.setState(s,A)}}),this.registeredModifiers.push(s)},fr.prototype.subscribe=function(s){return typeof s=="function"?this.subscribers.push(s)-1:{FAIL:`invalid '${this.eventId}' event handler`}},fr.prototype.unsubscribe=function(s){this.subscribers.splice(s,1)},he.prototype.setCurrentIndex=function(s){this.index=s,this.current=this.context[s],this.backtrack=this.context.slice(0,s),this.lookahead=this.context.slice(s+1)},he.prototype.get=function(s){switch(!0){case s===0:return this.current;case(s<0&&Math.abs(s)<=this.backtrack.length):return this.backtrack.slice(s)[0];case(s>0&&s<=this.lookahead.length):return this.lookahead[s-1];default:return null}},Yt.prototype.rangeToText=function(s){if(s instanceof no)return this.getRangeTokens(s).map(o=>o.char).join("")},Yt.prototype.getText=function(){return this.tokens.map(s=>s.char).join("")},Yt.prototype.getContext=function(s){let o=this.registeredContexts[s];return o||null},Yt.prototype.on=function(s,o){let c=this.events[s];return c?c.subscribe(o):null},Yt.prototype.dispatch=function(s,o){let c=this.events[s];if(c instanceof fr)for(let h=0;h<c.subscribers.length;h++)c.subscribers[h].apply(this,o||[])},Yt.prototype.registerContextChecker=function(s,o,c){if(this.getContext(s))return{FAIL:`context name '${s}' is already registered.`};if(typeof o!="function")return{FAIL:"missing context start check."};if(typeof c!="function")return{FAIL:"missing context end check."};let h=new Em(s,o,c);return this.registeredContexts[s]=h,this.contextCheckers.push(h),h},Yt.prototype.getRangeTokens=function(s){let o=s.startIndex+s.endOffset;return[].concat(this.tokens.slice(s.startIndex,o))},Yt.prototype.getContextRanges=function(s){let o=this.getContext(s);return o?o.ranges:{FAIL:`context checker '${s}' is not registered.`}},Yt.prototype.resetContextsRanges=function(){let s=this.registeredContexts;for(let o in s)if(Object.prototype.hasOwnProperty.call(s,o)){let c=s[o];c.ranges=[]}},Yt.prototype.updateContextsRanges=function(){this.resetContextsRanges();let s=this.tokens.map(o=>o.char);for(let o=0;o<s.length;o++){let c=new he(s,o);this.runContextCheck(c)}this.dispatch("updateContextsRanges",[this.registeredContexts])},Yt.prototype.setEndOffset=function(s,o){let c=this.getContext(o).openRange.startIndex,h=new no(c,s,o),d=this.getContext(o).ranges;return h.rangeId=`${o}.${d.length}`,d.push(h),this.getContext(o).openRange=null,h},Yt.prototype.runContextCheck=function(s){let o=s.index;for(let c=0;c<this.contextCheckers.length;c++){let h=this.contextCheckers[c],d=h.contextName,p=this.getContext(d).openRange;if(!p&&h.checkStart(s)&&(p=new no(o,null,d),this.getContext(d).openRange=p,this.dispatch("contextStart",[d,o])),p&&h.checkEnd(s)){let b=o-p.startIndex+1,x=this.setEndOffset(b,d);this.dispatch("contextEnd",[d,x])}}},Yt.prototype.tokenize=function(s){this.tokens=[],this.resetContextsRanges();let o=Array.from(s);this.dispatch("start");for(let c=0;c<o.length;c++){let h=o[c],d=new he(o,c);this.dispatch("next",[d]),this.runContextCheck(d);let p=new Kn(h);this.tokens.push(p),this.dispatch("newToken",[p,d])}return this.dispatch("end",[this.tokens]),this.tokens};var km=Yt;function cn(s){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(s)}function Wc(s){return/[\u0630\u0690\u0621\u0631\u0661\u0671\u0622\u0632\u0672\u0692\u06C2\u0623\u0673\u0693\u06C3\u0624\u0694\u06C4\u0625\u0675\u0695\u06C5\u06E5\u0676\u0696\u06C6\u0627\u0677\u0697\u06C7\u0648\u0688\u0698\u06C8\u0689\u0699\u06C9\u068A\u06CA\u066B\u068B\u06CB\u068C\u068D\u06CD\u06FD\u068E\u06EE\u06FE\u062F\u068F\u06CF\u06EF]/.test(s)}function un(s){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(s)}function pr(s){return/[\u0E00-\u0E7F]/.test(s)}function gr(s){return/[A-z]/.test(s)}function Im(s){return/\s/.test(s)}function Ae(s){this.font=s,this.features={}}function hn(s){this.id=s.id,this.tag=s.tag,this.substitution=s.substitution}function dn(s,o){if(!s)return-1;switch(o.format){case 1:return o.glyphs.indexOf(s);case 2:{let c=o.ranges;for(let h=0;h<c.length;h++){let d=c[h];if(s>=d.start&&s<=d.end){let p=s-d.start;return d.index+p}}break}default:return-1}return-1}function Rm(s,o){return dn(s,o.coverage)===-1?null:s+o.deltaGlyphId}function Pm(s,o){let c=dn(s,o.coverage);return c===-1?null:o.substitute[c]}function so(s,o){let c=[];for(let h=0;h<s.length;h++){let d=s[h],p=o.current;p=Array.isArray(p)?p[0]:p;let b=dn(p,d);b!==-1&&c.push(b)}return c.length!==s.length?-1:c}function Om(s,o){let c=o.inputCoverage.length+o.lookaheadCoverage.length+o.backtrackCoverage.length;if(s.context.length<c)return[];let h=so(o.inputCoverage,s);if(h===-1)return[];let d=o.inputCoverage.length-1;if(s.lookahead.length<o.lookaheadCoverage.length)return[];let p=s.lookahead.slice(d);for(;p.length&&un(p[0].char);)p.shift();let b=new he(p,0),x=so(o.lookaheadCoverage,b),A=[].concat(s.backtrack);for(A.reverse();A.length&&un(A[0].char);)A.shift();if(A.length<o.backtrackCoverage.length)return[];let w=new he(A,0),E=so(o.backtrackCoverage,w),P=h.length===o.inputCoverage.length&&x.length===o.lookaheadCoverage.length&&E.length===o.backtrackCoverage.length,R=[];if(P)for(let F=0;F<o.lookupRecords.length;F++){let L=o.lookupRecords[F],N=L.lookupListIndex,$=this.getLookupByIndex(N);for(let vt=0;vt<$.subtables.length;vt++){let pt=$.subtables[vt],At,It=this.getSubstitutionType($,pt);if(It==="71"?(It=this.getSubstitutionType(pt,pt.extension),At=this.getLookupMethod(pt,pt.extension),pt=pt.extension):At=this.getLookupMethod($,pt),It==="12"){let Ut=s.get(L.sequenceIndex),Gt=At(Ut);Gt&&R.push(Gt)}else if(It==="21"){let Ut=s.get(L.sequenceIndex),Gt=At(Ut);Gt&&R.push(Gt)}else throw new Error(`Substitution type ${It} is not supported in chaining substitution`)}}return R}function Mm(s,o){let c=s.current,h=dn(c,o.coverage);if(h===-1)return null;let d,p=o.ligatureSets[h];for(let b=0;b<p.length;b++){d=p[b];for(let x=0;x<d.components.length;x++){let A=s.lookahead[x],w=d.components[x];if(A!==w)break;if(x===d.components.length-1)return d}}return null}function Lm(s,o){let c=s.current;if(dn(c,o.coverage)===-1)return null;for(let d of o.ruleSets)for(let p of d){let b=!0;for(let x=0;x<p.input.length;x++)if(s.lookahead[x]!==p.input[x]){b=!1;break}if(b){let x=[];x.push(c);for(let w=0;w<p.input.length;w++)x.push(p.input[w]);let A=(w,E)=>{let{lookupListIndex:P,sequenceIndex:R}=E,{subtables:F}=this.getLookupByIndex(P);for(let L of F)dn(w[R],L.coverage)!==-1&&(w[R]=L.deltaGlyphId)};for(let w=0;w<p.lookupRecords.length;w++){let E=p.lookupRecords[w];A(x,E)}return x}}return null}function Fm(s,o){if(s.context.length<o.coverages.length)return[];for(let h=0;h<o.coverages.length;h++){let d=s.get(h);if(d=Array.isArray(d)?d[0]:d,dn(d,o.coverages[h])===-1)return[]}let c=[];for(let h=0;h<o.lookupRecords.length;h++){let d=o.lookupRecords[h],p=d.lookupListIndex,b=this.getLookupByIndex(p);for(let x=0;x<b.subtables.length;x++){let A=b.subtables[x],w,E=this.getSubstitutionType(b,A);if(E==="71"?(E=this.getSubstitutionType(A,A.extension),w=this.getLookupMethod(A,A.extension),A=A.extension):w=this.getLookupMethod(b,A),E==="12"){let P=s.get(d.sequenceIndex),R=w(P);R&&c.push(R)}else if(E==="21"){let P=s.get(d.sequenceIndex),R=w(P);R&&c.push(R)}}}return c}function Dm(s,o){let c=dn(s,o.coverage);return c===-1?null:o.sequences[c]}Ae.prototype.getDefaultScriptFeaturesIndexes=function(){let s=this.font.tables.gsub.scripts;for(let o=0;o<s.length;o++){let c=s[o];if(c.tag==="DFLT")return c.script.defaultLangSys.featureIndexes}return[]},Ae.prototype.getScriptFeaturesIndexes=function(s){if(!this.font.tables.gsub)return[];if(!s)return this.getDefaultScriptFeaturesIndexes();let c=this.font.tables.gsub.scripts;for(let h=0;h<c.length;h++){let d=c[h];if(d.tag===s&&d.script.defaultLangSys)return d.script.defaultLangSys.featureIndexes;{let p=d.langSysRecords;if(p)for(let b=0;b<p.length;b++){let x=p[b];if(x.tag===s)return x.langSys.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()},Ae.prototype.mapTagsToFeatures=function(s,o){let c={};for(let h=0;h<s.length;h++){let d=s[h].tag,p=s[h].feature;c[d]=p}this.features[o].tags=c},Ae.prototype.getScriptFeatures=function(s){let o=this.features[s];if(Object.prototype.hasOwnProperty.call(this.features,s))return o;let c=this.getScriptFeaturesIndexes(s);if(!c)return null;let h=this.font.tables.gsub;return o=c.map(d=>h.features[d]),this.features[s]=o,this.mapTagsToFeatures(o,s),o},Ae.prototype.getSubstitutionType=function(s,o){let c=s.lookupType.toString(),h=o.substFormat.toString();return c+h},Ae.prototype.getLookupMethod=function(s,o){let c=this.getSubstitutionType(s,o);switch(c){case"11":return h=>Rm.apply(this,[h,o]);case"12":return h=>Pm.apply(this,[h,o]);case"63":return h=>Om.apply(this,[h,o]);case"41":return h=>Mm.apply(this,[h,o]);case"21":return h=>Dm.apply(this,[h,o]);case"51":return h=>Lm.apply(this,[h,o]);case"53":return h=>Fm.apply(this,[h,o]);default:throw new Error(`substitutionType : ${c} lookupType: ${s.lookupType} - substFormat: ${o.substFormat} is not yet supported`)}},Ae.prototype.lookupFeature=function(s){let o=s.contextParams,c=o.index,h=this.getFeature({tag:s.tag,script:s.script});if(!h)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${s.tag}' for script '${s.script}'.`);let d=this.getFeatureLookups(h),p=[].concat(o.context);for(let b=0;b<d.length;b++){let x=d[b],A=this.getLookupSubtables(x);for(let w=0;w<A.length;w++){let E=A[w],P=this.getSubstitutionType(x,E),R;P==="71"?(P=this.getSubstitutionType(E,E.extension),R=this.getLookupMethod(E,E.extension),E=E.extension):R=this.getLookupMethod(x,E);let F;switch(P){case"11":F=R(o.current),F&&p.splice(c,1,new hn({id:11,tag:s.tag,substitution:F}));break;case"12":F=R(o.current),F&&p.splice(c,1,new hn({id:12,tag:s.tag,substitution:F}));break;case"63":F=R(o),Array.isArray(F)&&F.length&&p.splice(c,1,new hn({id:63,tag:s.tag,substitution:F}));break;case"41":F=R(o),F&&p.splice(c,1,new hn({id:41,tag:s.tag,substitution:F}));break;case"21":F=R(o.current),F&&p.splice(c,1,new hn({id:21,tag:s.tag,substitution:F}));break;case"51":case"53":F=R(o),Array.isArray(F)&&F.length&&p.splice(c,1,new hn({id:parseInt(P),tag:s.tag,substitution:F}));break}o=new he(p,c),!(Array.isArray(F)&&!F.length)&&(F=null)}}return p.length?p:null},Ae.prototype.supports=function(s){if(!s.script)return!1;this.getScriptFeatures(s.script);let o=Object.prototype.hasOwnProperty.call(this.features,s.script);if(!s.tag)return o;let c=this.features[s.script].some(h=>h.tag===s.tag);return o&&c},Ae.prototype.getLookupSubtables=function(s){return s.subtables||null},Ae.prototype.getLookupByIndex=function(s){return this.font.tables.gsub.lookups[s]||null},Ae.prototype.getFeatureLookups=function(s){return s.lookupListIndexes.map(this.getLookupByIndex.bind(this))},Ae.prototype.getFeature=function(o){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,o.script)||this.getScriptFeatures(o.script);let c=this.features[o.script];return c?c.tags[o.tag]?this.features[o.script].tags[o.tag]:null:{FAIL:`No feature for script ${o.script}`}};var _m=Ae;function Nm(s){let o=s.current,c=s.get(-1);return c===null&&cn(o)||!cn(c)&&cn(o)}function Um(s){let o=s.get(1);return o===null||!cn(o)}var Bm={startCheck:Nm,endCheck:Um};function Gm(s){let o=s.current,c=s.get(-1);return(cn(o)||un(o))&&!cn(c)}function Hm(s){let o=s.get(1);switch(!0){case o===null:return!0;case(!cn(o)&&!un(o)):{let c=Im(o);if(!c)return!0;if(c){let h=!1;if(h=s.lookahead.some(d=>cn(d)||un(d)),!h)return!0}break}default:return!1}}var jm={startCheck:Gm,endCheck:Hm};function Vm(s,o,c){o[c].setState(s.tag,s.substitution)}function Wm(s,o,c){o[c].setState(s.tag,s.substitution)}function ro(s,o,c){for(let h=0;h<s.substitution.length;h++){let d=s.substitution[h],p=o[c+h];if(Array.isArray(d)){d.length?p.setState(s.tag,d[0]):p.setState("deleted",!0);continue}p.setState(s.tag,d)}}function $m(s,o,c){let h=o[c];h.setState(s.tag,s.substitution.ligGlyph);let d=s.substitution.components.length;for(let p=0;p<d;p++)h=o[c+p+1],h.setState("deleted",!0)}var $c={11:Vm,12:Wm,63:ro,41:$m,51:ro,53:ro};function zm(s,o,c){s instanceof hn&&$c[s.id]&&$c[s.id](s,o,c)}var kn=zm;function Xm(s){let o=[].concat(s.backtrack);for(let c=o.length-1;c>=0;c--){let h=o[c],d=Wc(h),p=un(h);if(!d&&!p)return!0;if(d)return!1}return!1}function Ym(s){if(Wc(s.current))return!1;for(let o=0;o<s.lookahead.length;o++){let c=s.lookahead[o];if(!un(c))return!0}return!1}function Km(s){let o="arab",c=this.featuresTags[o],h=this.tokenizer.getRangeTokens(s);if(h.length===1)return;let d=new he(h.map(b=>b.getState("glyphIndex")),0),p=new he(h.map(b=>b.char),0);for(let b=0;b<h.length;b++){let x=h[b];if(un(x.char))continue;d.setCurrentIndex(b),p.setCurrentIndex(b);let A=0;Xm(p)&&(A|=1),Ym(p)&&(A|=2);let w;switch(A){case 1:w="fina";break;case 2:w="init";break;case 3:w="medi";break}if(c.indexOf(w)===-1)continue;let E=this.query.lookupFeature({tag:w,script:o,contextParams:d});if(E instanceof Error){console.info(E.message);continue}for(let P=0;P<E.length;P++){let R=E[P];R instanceof hn&&(kn(R,h,P),d.context[P]=R.substitution)}}}var Zm=Km;function zc(s,o){let c=s.map(h=>h.activeState.value);return new he(c,o||0)}function Qm(s){let o="arab",c=this.tokenizer.getRangeTokens(s),h=zc(c);for(let d=0;d<h.context.length;d++){h.setCurrentIndex(d);let p=this.query.lookupFeature({tag:"rlig",script:o,contextParams:h});if(p.length){for(let b=0;b<p.length;b++){let x=p[b];kn(x,c,d)}h=zc(c)}}}var Jm=Qm;function qm(s){return s.index===0&&s.context.length>1}function ty(s){return s.index===s.context.length-1}var ey={startCheck:qm,endCheck:ty};function Xc(s,o){let c=s.map(h=>h.activeState.value);return new he(c,o||0)}function ny(s){let o="delf",c="ccmp",h=this.tokenizer.getRangeTokens(s),d=Xc(h);for(let p=0;p<d.context.length;p++){if(!this.query.getFeature({tag:c,script:o,contextParams:d}))continue;d.setCurrentIndex(p);let b=this.query.lookupFeature({tag:c,script:o,contextParams:d});if(b.length){for(let x=0;x<b.length;x++){let A=b[x];kn(A,h,p)}d=Xc(h)}}}var sy=ny;function ry(s){let o=s.current,c=s.get(-1);return c===null&&gr(o)||!gr(c)&&gr(o)}function iy(s){let o=s.get(1);return o===null||!gr(o)}var oy={startCheck:ry,endCheck:iy};function Yc(s,o){let c=s.map(h=>h.activeState.value);return new he(c,o||0)}function ay(s){let o="latn",c=this.tokenizer.getRangeTokens(s),h=Yc(c);for(let d=0;d<h.context.length;d++){h.setCurrentIndex(d);let p=this.query.lookupFeature({tag:"liga",script:o,contextParams:h});if(p.length){for(let b=0;b<p.length;b++){let x=p[b];kn(x,c,d)}h=Yc(c)}}}var ly=ay;function cy(s){let o=s.current,c=s.get(-1);return c===null&&pr(o)||!pr(c)&&pr(o)}function uy(s){let o=s.get(1);return o===null||!pr(o)}var hy={startCheck:cy,endCheck:uy};function Kc(s,o){let c=s.map(h=>h.activeState.value);return new he(c,o||0)}function dy(s){let o="thai",c=this.tokenizer.getRangeTokens(s),h=Kc(c,0);for(let d=0;d<h.context.length;d++){h.setCurrentIndex(d);let p=this.query.lookupFeature({tag:"ccmp",script:o,contextParams:h});if(p.length){for(let b=0;b<p.length;b++){let x=p[b];kn(x,c,d)}h=Kc(c,d)}}}var fy=dy;function Zc(s,o){let c=s.map(h=>h.activeState.value);return new he(c,o||0)}function py(s){let o="thai",c=this.tokenizer.getRangeTokens(s),h=Zc(c,0);for(let d=0;d<h.context.length;d++){h.setCurrentIndex(d);let p=this.query.lookupFeature({tag:"liga",script:o,contextParams:h});if(p.length){for(let b=0;b<p.length;b++){let x=p[b];kn(x,c,d)}h=Zc(c,d)}}}var gy=py;function Qc(s,o){let c=s.map(h=>h.activeState.value);return new he(c,o||0)}function my(s){let o="thai",c=this.tokenizer.getRangeTokens(s),h=Qc(c,0);for(let d=0;d<h.context.length;d++){h.setCurrentIndex(d);let p=this.query.lookupFeature({tag:"rlig",script:o,contextParams:h});if(p.length){for(let b=0;b<p.length;b++){let x=p[b];kn(x,c,d)}h=Qc(c,d)}}}var yy=my;function io(s){if(s===null)return!1;let o=s.codePointAt(0);return o>=6155&&o<=6157||o>=65024&&o<=65039||o>=917760&&o<=917999}function by(s){let o=s.current,c=s.get(1);return c===null&&io(o)||io(c)}function vy(s){let o=s.get(1);return o===null||!io(o)}var xy={startCheck:by,endCheck:vy};function Sy(s){let o=this.query.font,c=this.tokenizer.getRangeTokens(s);if(c[1].setState("deleted",!0),o.tables.cmap&&o.tables.cmap.varSelectorList){let h=c[0].char.codePointAt(0),d=c[1].char.codePointAt(0),p=o.tables.cmap.varSelectorList[d];if(p!==void 0&&p.nonDefaultUVS){let b=p.nonDefaultUVS.uvsMappings;if(b[h]){let x=b[h].glyphID;o.glyphs.glyphs[x]!==void 0&&c[0].setState("glyphIndex",x)}}}}var Ay=Sy;function ke(s){this.baseDir=s||"ltr",this.tokenizer=new km,this.featuresTags={}}ke.prototype.setText=function(s){this.text=s},ke.prototype.contextChecks={ccmpReplacementCheck:ey,latinWordCheck:oy,arabicWordCheck:Bm,arabicSentenceCheck:jm,thaiWordCheck:hy,unicodeVariationSequenceCheck:xy};function Zn(s){let o=this.contextChecks[`${s}Check`];return this.tokenizer.registerContextChecker(s,o.startCheck,o.endCheck)}function Ty(){return Zn.call(this,"ccmpReplacement"),Zn.call(this,"latinWord"),Zn.call(this,"arabicWord"),Zn.call(this,"arabicSentence"),Zn.call(this,"thaiWord"),Zn.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function Cy(){let s=this.tokenizer.getContextRanges("arabicSentence");for(let o=0;o<s.length;o++){let c=s[o],h=this.tokenizer.getRangeTokens(c);this.tokenizer.replaceRange(c.startIndex,c.endOffset,h.reverse())}}ke.prototype.registerFeatures=function(s,o){let c=o.filter(h=>this.query.supports({script:s,tag:h}));Object.prototype.hasOwnProperty.call(this.featuresTags,s)?this.featuresTags[s]=this.featuresTags[s].concat(c):this.featuresTags[s]=c},ke.prototype.applyFeatures=function(s,o){if(!s)throw new Error("No valid font was provided to apply features");this.query||(this.query=new _m(s));for(let c=0;c<o.length;c++){let h=o[c];this.query.supports({script:h.script})&&this.registerFeatures(h.script,h.tags)}},ke.prototype.registerModifier=function(s,o,c){this.tokenizer.registerModifier(s,o,c)};function ms(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function Ey(){if(!Object.prototype.hasOwnProperty.call(this.featuresTags,"arab"))return;ms.call(this);let o=this.tokenizer.getContextRanges("arabicWord");for(let c=0;c<o.length;c++){let h=o[c];Zm.call(this,h)}}function wy(){ms.call(this);let s=this.tokenizer.getContextRanges("ccmpReplacement");for(let o=0;o<s.length;o++){let c=s[o];sy.call(this,c)}}function ky(){if(!this.hasFeatureEnabled("arab","rlig"))return;ms.call(this);let s=this.tokenizer.getContextRanges("arabicWord");for(let o=0;o<s.length;o++){let c=s[o];Jm.call(this,c)}}function Iy(){if(!this.hasFeatureEnabled("latn","liga"))return;ms.call(this);let s=this.tokenizer.getContextRanges("latinWord");for(let o=0;o<s.length;o++){let c=s[o];ly.call(this,c)}}function Ry(){let s=this.tokenizer.getContextRanges("unicodeVariationSequence");for(let o=0;o<s.length;o++){let c=s[o];Ay.call(this,c)}}function Py(){ms.call(this);let s=this.tokenizer.getContextRanges("thaiWord");for(let o=0;o<s.length;o++){let c=s[o];this.hasFeatureEnabled("thai","liga")&&gy.call(this,c),this.hasFeatureEnabled("thai","rlig")&&yy.call(this,c),this.hasFeatureEnabled("thai","ccmp")&&fy.call(this,c)}}ke.prototype.checkContextReady=function(s){return!!this.tokenizer.getContext(s)},ke.prototype.applyFeaturesToContexts=function(){this.checkContextReady("ccmpReplacement")&&wy.call(this),this.checkContextReady("arabicWord")&&(Ey.call(this),ky.call(this)),this.checkContextReady("latinWord")&&Iy.call(this),this.checkContextReady("arabicSentence")&&Cy.call(this),this.checkContextReady("thaiWord")&&Py.call(this),this.checkContextReady("unicodeVariationSequence")&&Ry.call(this)},ke.prototype.hasFeatureEnabled=function(s,o){return(this.featuresTags[s]||[]).indexOf(o)!==-1},ke.prototype.processText=function(s){(!this.text||this.text!==s)&&(this.setText(s),Ty.call(this),this.applyFeaturesToContexts())},ke.prototype.getBidiText=function(s){return this.processText(s),this.tokenizer.getText()},ke.prototype.getTextGlyphs=function(s){this.processText(s);let o=[];for(let c=0;c<this.tokenizer.tokens.length;c++){let h=this.tokenizer.tokens[c];if(h.state.deleted)continue;let d=h.activeState.value;o.push(Array.isArray(d)?d[0]:d)}return o};var Oy=ke;function oo(s){return{fontFamily:{en:s.familyName||" "},fontSubfamily:{en:s.styleName||" "},fullName:{en:s.fullName||s.familyName+" "+s.styleName},postScriptName:{en:s.postScriptName||(s.familyName+s.styleName).replace(/\s/g,"")},designer:{en:s.designer||" "},designerURL:{en:s.designerURL||" "},manufacturer:{en:s.manufacturer||" "},manufacturerURL:{en:s.manufacturerURL||" "},license:{en:s.license||" "},licenseURL:{en:s.licenseURL||" "},version:{en:s.version||"Version 0.1"},description:{en:s.description||" "},copyright:{en:s.copyright||" "},trademark:{en:s.trademark||" "}}}function Bt(s){if(s=s||{},s.tables=s.tables||{},!s.empty){if(!s.familyName)throw new Error("When creating a new Font object, familyName is required.");if(!s.styleName)throw new Error("When creating a new Font object, styleName is required.");if(!s.unitsPerEm)throw new Error("When creating a new Font object, unitsPerEm is required.");if(!s.ascender)throw new Error("When creating a new Font object, ascender is required.");if(s.descender>0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=oo(s),this.names.macintosh=oo(s),this.names.windows=oo(s),this.unitsPerEm=s.unitsPerEm||1e3,this.ascender=s.ascender,this.descender=s.descender,this.createdTimestamp=s.createdTimestamp,this.italicAngle=s.italicAngle||0,this.weightClass=s.weightClass||0;let o=0;s.fsSelection?o=s.fsSelection:(this.italicAngle<0?o|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(o|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(o|=this.fsSelectionValues.BOLD),o===0&&(o=this.fsSelectionValues.REGULAR)),(!s.panose||!Array.isArray(s.panose))&&(s.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(s.tables,{os2:Object.assign({usWeightClass:s.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:s.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:s.panose[0]||0,bSerifStyle:s.panose[1]||0,bWeight:s.panose[2]||0,bProportion:s.panose[3]||0,bContrast:s.panose[4]||0,bStrokeVariation:s.panose[5]||0,bArmStyle:s.panose[6]||0,bLetterform:s.panose[7]||0,bMidline:s.panose[8]||0,bXHeight:s.panose[9]||0,fsSelection:o},s.tables.os2)})}this.supported=!0,this.glyphs=new We.GlyphSet(this,s.glyphs||[]),this.encoding=new Il(this),this.position=new wp(this),this.substitution=new Lp(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(o,c,h)=>(o[c]=h,o.fvar&&(o.gvar||o.cff2)&&!this.variation&&(this.variation=new Yp(this)),!0)}),this.palettes=new yc(this),this.layers=new Fp(this),this.svgImages=new Dp(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new Cm(this):null}})}Bt.prototype.hasChar=function(s){return this.encoding.charToGlyphIndex(s)>0},Bt.prototype.charToGlyphIndex=function(s){return this.encoding.charToGlyphIndex(s)},Bt.prototype.charToGlyph=function(s){let o=this.charToGlyphIndex(s),c=this.glyphs.get(o);return c||(c=this.glyphs.get(0)),c},Bt.prototype.updateFeatures=function(s){return this.defaultRenderOptions.features.map(o=>o.script==="latn"?{script:"latn",tags:o.tags.filter(c=>s[c])}:o)},Bt.prototype.stringToGlyphIndexes=function(s,o){let c=new Oy,h=p=>this.charToGlyphIndex(p.char);c.registerModifier("glyphIndex",null,h);let d=o?this.updateFeatures(o.features):this.defaultRenderOptions.features;return c.applyFeatures(this,d),c.getTextGlyphs(s)},Bt.prototype.stringToGlyphs=function(s,o){let c=this.stringToGlyphIndexes(s,o),h=c.length,d=new Array(h),p=this.glyphs.get(0);for(let b=0;b<h;b+=1)d[b]=this.glyphs.get(c[b])||p;return d},Bt.prototype.nameToGlyphIndex=function(s){return this.glyphNames.nameToGlyphIndex(s)},Bt.prototype.nameToGlyph=function(s){let o=this.nameToGlyphIndex(s),c=this.glyphs.get(o);return c||(c=this.glyphs.get(0)),c},Bt.prototype.glyphIndexToName=function(s){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(s):""},Bt.prototype.getKerningValue=function(s,o){s=s.index||s,o=o.index||o;let c=this.position.defaultKerningTables;return c?this.position.getKerningValue(c,s,o):this.kerningPairs[s+","+o]||0},Bt.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]},{script:"thai",tags:["liga","rlig","ccmp"]}],hinting:!1,usePalette:0,drawLayers:!0,drawSVG:!0},Bt.prototype.forEachGlyph=function(s,o,c,h,d,p){o=o!==void 0?o:0,c=c!==void 0?c:0,h=h!==void 0?h:72,d=Object.assign({},this.defaultRenderOptions,d);let b=1/this.unitsPerEm*h,x=this.stringToGlyphs(s,d),A;if(d.kerning){let w=d.script||this.position.getDefaultScriptName();A=this.position.getKerningTables(w,d.language)}for(let w=0;w<x.length;w+=1){let E=x[w];if(p.call(this,E,o,c,h,d),E.advanceWidth&&(o+=E.advanceWidth*b),d.kerning&&w<x.length-1){let P=A?this.position.getKerningValue(A,E.index,x[w+1].index):this.getKerningValue(E,x[w+1]);o+=P*b}d.letterSpacing?o+=d.letterSpacing*h:d.tracking&&(o+=d.tracking/1e3*h)}return o},Bt.prototype.getPath=function(s,o,c,h,d){d=Object.assign({},this.defaultRenderOptions,d);let p=new ot;if(p._layers=[],Gl(this,p,h),p.stroke){let b=1/(p.unitsPerEm||1e3)*h;p.strokeWidth*=b}return this.forEachGlyph(s,o,c,h,d,(b,x,A,w)=>{let E=b.getPath(x,A,w,d,this);if(d.drawSVG||d.drawLayers){let P=E._layers;if(P&&P.length){for(let R=0;R<P.length;R++){let F=P[R];p._layers.push(F)}return}}p.extend(E)}),p},Bt.prototype.getPaths=function(s,o,c,h,d){d=Object.assign({},this.defaultRenderOptions,d);let p=[];return this.forEachGlyph(s,o,c,h,d,function(b,x,A,w){let E=b.getPath(x,A,w,d,this);p.push(E)}),p},Bt.prototype.getAdvanceWidth=function(s,o,c){return c=Object.assign({},this.defaultRenderOptions,c),this.forEachGlyph(s,0,0,o,c,function(){})},Bt.prototype.draw=function(s,o,c,h,d,p){this.getPath(o,c,h,d,p).draw(s)},Bt.prototype.drawPoints=function(s,o,c,h,d,p){p=Object.assign({},this.defaultRenderOptions,p),this.forEachGlyph(o,c,h,d,p,function(b,x,A,w){b.drawPoints(s,x,A,w,p,this)})},Bt.prototype.drawMetrics=function(s,o,c,h,d,p){p=Object.assign({},this.defaultRenderOptions,p),this.forEachGlyph(o,c,h,d,p,function(b,x,A,w){b.drawMetrics(s,x,A,w)})},Bt.prototype.getEnglishName=function(s){let o=(this.names.unicode||this.names.macintosh||this.names.windows)[s];if(o)return o.en},Bt.prototype.validate=function(){let s=[],o=this;function c(d,p){d||(console.warn(`[opentype.js] ${p}`),s.push(p))}function h(d){let p=o.getEnglishName(d);c(p&&p.trim().length>0,"No English "+d+" specified.")}if(h("fontFamily"),h("weightName"),h("manufacturer"),h("copyright"),h("version"),c(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){let d=this.tables.colr.baseGlyphRecords,p=-1;for(let b=0;b<d.length;b++){let x=d[b].glyphID;if(c(p<d[b].glyphID,`baseGlyphs must be sorted by GlyphID in ascending order, but glyphID ${x} comes after ${p}`),p>d[b].glyphID)break;p=x}}return s},Bt.prototype.toTables=function(){return Ep.fontToTable(this)},Bt.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},Bt.prototype.toArrayBuffer=function(){let o=this.toTables().encode(),c=new ArrayBuffer(o.length),h=new Uint8Array(c);for(let d=0;d<o.length;d++)h[d]=o[d];return c},Bt.prototype.download=function(){console.error("DEPRECATED: platform-specific actions are to be implemented on user-side")},Bt.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},Bt.prototype.macStyleValues={BOLD:1,ITALIC:2,UNDERLINE:4,OUTLINED:8,SHADOW:16,CONDENSED:32,EXTENDED:64},Bt.prototype.usWidthClasses={ULTRA_CONDENSED:1,EXTRA_CONDENSED:2,CONDENSED:3,SEMI_CONDENSED:4,MEDIUM:5,SEMI_EXPANDED:6,EXPANDED:7,EXTRA_EXPANDED:8,ULTRA_EXPANDED:9},Bt.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};var Jc=Bt;function My(s,o){let c=new rt.Parser(s,o),h=c.parseUShort(),d=c.parseUShort();h!==1&&console.warn(`Unsupported hvar table version ${h}.${d}`);let p=[h,d],b=c.parsePointer32(function(){return this.parseItemVariationStore()}),x=c.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),A=c.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),w=c.parsePointer32(function(){return this.parseDeltaSetIndexMap()});return{version:p,itemVariationStore:b,advanceWidth:x,lsb:A,rsb:w}}function Ly(){console.warn("Writing of hvar tables is not yet supported.")}var Fy={make:Ly,parse:My},Dy=function(){return{coverage:this.parsePointer(G.coverage),attachPoints:this.parseList(G.pointer(G.uShortList))}},_y=function(){var s=this.parseUShort();if(U.argument(s===1||s===2||s===3,"Unsupported CaretValue table version."),s===1)return{coordinate:this.parseShort()};if(s===2)return{pointindex:this.parseShort()};if(s===3)return{coordinate:this.parseShort()}},Ny=function(){return this.parseList(G.pointer(_y))},Uy=function(){return{coverage:this.parsePointer(G.coverage),ligGlyphs:this.parseList(G.pointer(Ny))}},By=function(){return this.parseUShort(),this.parseList(G.pointer(G.coverage))};function Gy(s,o){o=o||0;let c=new G(s,o),h=c.parseVersion(1);U.argument(h===1||h===1.2||h===1.3,"Unsupported GDEF table version.");var d={version:h,classDef:c.parsePointer(G.classDef),attachList:c.parsePointer(Dy),ligCaretList:c.parsePointer(Uy),markAttachClassDef:c.parsePointer(G.classDef)};return h>=1.2&&(d.markGlyphSets=c.parsePointer(By)),d}var Hy={parse:Gy},_e=new Array(10);_e[1]=function(){let o=this.offset+this.relativeOffset,c=this.parseUShort();if(c===1)return{posFormat:1,coverage:this.parsePointer(G.coverage),value:this.parseValueRecord()};if(c===2)return{posFormat:2,coverage:this.parsePointer(G.coverage),values:this.parseValueRecordList()};U.assert(!1,"0x"+o.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},_e[2]=function(){let o=this.offset+this.relativeOffset,c=this.parseUShort();U.assert(c===1||c===2,"0x"+o.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");let h=this.parsePointer(G.coverage),d=this.parseUShort(),p=this.parseUShort();if(c===1)return{posFormat:c,coverage:h,valueFormat1:d,valueFormat2:p,pairSets:this.parseList(G.pointer(G.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(d),value2:this.parseValueRecord(p)}})))};if(c===2){let b=this.parsePointer(G.classDef),x=this.parsePointer(G.classDef),A=this.parseUShort(),w=this.parseUShort();return{posFormat:c,coverage:h,valueFormat1:d,valueFormat2:p,classDef1:b,classDef2:x,class1Count:A,class2Count:w,classRecords:this.parseList(A,G.list(w,function(){return{value1:this.parseValueRecord(d),value2:this.parseValueRecord(p)}}))}}},_e[3]=function(){return{error:"GPOS Lookup 3 not supported"}},_e[4]=function(){return{error:"GPOS Lookup 4 not supported"}},_e[5]=function(){return{error:"GPOS Lookup 5 not supported"}},_e[6]=function(){return{error:"GPOS Lookup 6 not supported"}},_e[7]=function(){return{error:"GPOS Lookup 7 not supported"}},_e[8]=function(){return{error:"GPOS Lookup 8 not supported"}},_e[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function jy(s,o){o=o||0;let c=new G(s,o),h=c.parseVersion(1);return U.argument(h===1||h===1.1,"Unsupported GPOS table version "+h),h===1?{version:h,scripts:c.parseScriptList(),features:c.parseFeatureList(),lookups:c.parseLookupList(_e)}:{version:h,scripts:c.parseScriptList(),features:c.parseFeatureList(),lookups:c.parseLookupList(_e),variations:c.parseFeatureVariationsList()}}var Vy=new Array(10);function Wy(s){return new J.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new J.ScriptList(s.scripts)},{name:"features",type:"TABLE",value:new J.FeatureList(s.features)},{name:"lookups",type:"TABLE",value:new J.LookupList(s.lookups,Vy)}])}var $y={parse:jy,make:Wy};function zy(s){let o={};s.skip("uShort");let c=s.parseUShort();U.argument(c===0,"Unsupported kern sub-table version."),s.skip("uShort",2);let h=s.parseUShort();s.skip("uShort",3);for(let d=0;d<h;d+=1){let p=s.parseUShort(),b=s.parseUShort(),x=s.parseShort();o[p+","+b]=x}return o}function Xy(s){let o={};s.skip("uShort"),s.parseULong()>1&&console.warn("Only the first kern subtable is supported."),s.skip("uLong");let d=s.parseUShort()&255;if(s.skip("uShort"),d===0){let p=s.parseUShort();s.skip("uShort",3);for(let b=0;b<p;b+=1){let x=s.parseUShort(),A=s.parseUShort(),w=s.parseShort();o[x+","+A]=w}}return o}function Yy(s,o){let c=new rt.Parser(s,o),h=c.parseUShort();if(h===0)return zy(c);if(h===1)return Xy(c);throw new Error("Unsupported kern table version ("+h+").")}var Ky={parse:Yy};function Zy(s,o,c,h){let d=new rt.Parser(s,o),p=h?d.parseUShort:d.parseULong,b=[];for(let x=0;x<c+1;x+=1){let A=p.call(d);h&&(A*=2),b.push(A)}return b}var Qy={parse:Zy};function qc(s,o){let c=[],h=12;for(let d=0;d<o;d+=1){let p=rt.getTag(s,h),b=rt.getULong(s,h+4),x=rt.getULong(s,h+8),A=rt.getULong(s,h+12);c.push({tag:p,checksum:b,offset:x,length:A,compression:!1}),h+=16}return c}function Jy(s,o){let c=[],h=44;for(let d=0;d<o;d+=1){let p=rt.getTag(s,h),b=rt.getULong(s,h+4),x=rt.getULong(s,h+8),A=rt.getULong(s,h+12),w;x<A?w="WOFF":w=!1,c.push({tag:p,offset:b,compression:w,compressedLength:x,length:A}),h+=20}return c}function _t(s,o){if(o.compression==="WOFF"){let c=new Uint8Array(s.buffer,o.offset+2,o.compressedLength-2),h=new Uint8Array(o.length);if(dt(c,h),h.byteLength!==o.length)throw new Error("Decompression error: "+o.tag+" decompressed length doesn't match recorded length");return{data:new DataView(h.buffer,0),offset:0}}else return{data:s,offset:o.offset}}function qy(s,o={}){let c,h,d=new Jc({empty:!0});s.constructor!==ArrayBuffer&&(s=new Uint8Array(s).buffer);let p=new DataView(s,0),b,x=[],A=rt.getTag(p,0);if(A==="\0\0\0"||A==="true"||A==="typ1")d.outlinesFormat="truetype",b=rt.getUShort(p,4),x=qc(p,b);else if(A==="OTTO")d.outlinesFormat="cff",b=rt.getUShort(p,4),x=qc(p,b);else if(A==="wOFF"){let xt=rt.getTag(p,4);if(xt==="\0\0\0")d.outlinesFormat="truetype";else if(xt==="OTTO")d.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+A);b=rt.getUShort(p,12),x=Jy(p,b)}else if(A==="wOF2"){let xt="https://github.com/opentypejs/opentype.js/issues/183#issuecomment-1147228025";throw new Error("WOFF2 require an external decompressor library, see examples at: "+xt)}else throw new Error("Unsupported OpenType signature "+A);let w,E,P,R,F,L,N,$,vt,pt,At,It,Ut,Gt,Ht,Jt,Ne,Rt;for(let xt=0;xt<b;xt+=1){let ct=x[xt],ft;switch(ct.tag){case"avar":N=ct;break;case"cmap":ft=_t(p,ct),d.tables.cmap=kl.parse(ft.data,ft.offset),d.encoding=new Rl(d.tables.cmap);break;case"cvt ":ft=_t(p,ct),Rt=new rt.Parser(ft.data,ft.offset),d.tables.cvt=Rt.parseShortList(ct.length/2);break;case"fvar":P=ct;break;case"STAT":R=ct;break;case"gvar":F=ct;break;case"cvar":L=ct;break;case"fpgm":ft=_t(p,ct),Rt=new rt.Parser(ft.data,ft.offset),d.tables.fpgm=Rt.parseByteList(ct.length);break;case"head":ft=_t(p,ct),d.tables.head=zl.parse(ft.data,ft.offset),d.unitsPerEm=d.tables.head.unitsPerEm,c=d.tables.head.indexToLocFormat;break;case"hhea":ft=_t(p,ct),d.tables.hhea=Xl.parse(ft.data,ft.offset),d.ascender=d.tables.hhea.ascender,d.descender=d.tables.hhea.descender,d.numberOfHMetrics=d.tables.hhea.numberOfHMetrics;break;case"HVAR":Ut=ct;break;case"hmtx":It=ct;break;case"ltag":ft=_t(p,ct),h=Kl.parse(ft.data,ft.offset);break;case"COLR":ft=_t(p,ct),d.tables.colr=tc.parse(ft.data,ft.offset);break;case"CPAL":ft=_t(p,ct),d.tables.cpal=Ll.parse(ft.data,ft.offset);break;case"maxp":ft=_t(p,ct),d.tables.maxp=Zl.parse(ft.data,ft.offset),d.numGlyphs=d.tables.maxp.numGlyphs;break;case"name":Jt=ct;break;case"OS/2":ft=_t(p,ct),d.tables.os2=zi.parse(ft.data,ft.offset);break;case"post":ft=_t(p,ct),d.tables.post=Ql.parse(ft.data,ft.offset),d.glyphNames=new Ni(d.tables.post);break;case"prep":ft=_t(p,ct),Rt=new rt.Parser(ft.data,ft.offset),d.tables.prep=Rt.parseByteList(ct.length);break;case"glyf":$=ct;break;case"loca":Ht=ct;break;case"CFF ":w=ct;break;case"CFF2":E=ct;break;case"kern":Gt=ct;break;case"GDEF":vt=ct;break;case"GPOS":pt=ct;break;case"GSUB":At=ct;break;case"meta":Ne=ct;break;case"gasp":try{ft=_t(p,ct),d.tables.gasp=oc.parse(ft.data,ft.offset)}catch(oe){console.warn("Failed to parse gasp table, skipping."),console.warn(oe)}break;case"SVG ":ft=_t(p,ct),d.tables.svg=ac.parse(ft.data,ft.offset);break;default:break}}let Te=_t(p,Jt);if(d.tables.name=wl.parse(Te.data,Te.offset,h),d.names=d.tables.name,$&&Ht){let xt=c===0,ct=_t(p,Ht),ft=Qy.parse(ct.data,ct.offset,d.numGlyphs,xt),oe=_t(p,$);d.glyphs=Sc.parse(oe.data,oe.offset,ft,d,o)}else if(w){let xt=_t(p,w);Wi.parse(xt.data,xt.offset,d,o)}else if(E){let xt=_t(p,E);Wi.parse(xt.data,xt.offset,d,o)}else throw new Error("Font doesn't contain TrueType, CFF or CFF2 outlines.");let de=_t(p,It);if(Yl.parse(d,de.data,de.offset,d.numberOfHMetrics,d.numGlyphs,d.glyphs,o),Zd(d,o),Gt){let xt=_t(p,Gt);d.kerningPairs=Ky.parse(xt.data,xt.offset)}else d.kerningPairs={};if(vt){let xt=_t(p,vt);d.tables.gdef=Hy.parse(xt.data,xt.offset)}if(pt){let xt=_t(p,pt);d.tables.gpos=$y.parse(xt.data,xt.offset),d.position.init()}if(At){let xt=_t(p,At);d.tables.gsub=Jl.parse(xt.data,xt.offset)}if(P){let xt=_t(p,P);d.tables.fvar=ec.parse(xt.data,xt.offset,d.names)}if(R){let xt=_t(p,R);d.tables.stat=nc.parse(xt.data,xt.offset,d.tables.fvar)}if(F){P||console.warn("This font provides a gvar table, but no fvar table, which is required for variable fonts."),$||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");let xt=_t(p,F);d.tables.gvar=ic.parse(xt.data,xt.offset,d.tables.fvar,d.glyphs)}if(L){P||console.warn("This font provides a cvar table, but no fvar table, which is required for variable fonts."),d.tables.cvt||console.warn("This font provides a cvar table, but no cvt table which could be made variable."),$||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");let xt=_t(p,L);d.tables.cvar=rc.parse(xt.data,xt.offset,d.tables.fvar,d.tables.cvt||[])}if(N){P||console.warn("This font provides an avar table, but no fvar table, which is required for variable fonts.");let xt=_t(p,N);d.tables.avar=sc.parse(xt.data,xt.offset,d.tables.fvar)}if(Ut){P||console.warn("This font provides an HVAR table, but no fvar table, which is required for variable fonts."),It||console.warn("This font provides an HVAR table, but no hmtx table to vary.");let xt=_t(p,Ut);d.tables.hvar=Fy.parse(xt.data,xt.offset,d.tables.fvar)}if(Ne){let xt=_t(p,Ne);d.tables.meta=ql.parse(xt.data,xt.offset),d.metas=d.tables.meta}return d.palettes=new yc(d),d}function tb(){console.error("DEPRECATED! migrate to: opentype.parse(buffer, opt) See: https://github.com/opentypejs/opentype.js/issues/675")}function eb(){console.error('DEPRECATED! migrate to: opentype.parse(require("fs").readFileSync(url), opt)')}return l(u)})();(function(i,t){typeof define=="function"&&define.amd?define(t):typeof gi=="object"&&gi.exports?gi.exports=t():i.opentype=t()})(typeof self<"u"?self:$u,()=>({...Wu,default:Wu}))});var X1={};su(X1,{Logger:()=>xr,PDFParser:()=>Pi,addGfontsAssetLibrary:()=>co,anyMatchResolverStage:()=>Vs,assetLibraryStrategy:()=>Wh,createFontCascade:()=>Ws,createFontStrategy:()=>$s,defaultEmission:()=>ls,defaultStrategy:()=>jn,editableFirstStrategy:()=>pl,embeddedSubsetStage:()=>js,exactFidelityStrategy:()=>Vh,perfectMatchResolverStage:()=>as});module.exports=ub(X1);function hb(i,t){return i.replace(/\{(\w+)\}/g,(e,n)=>{if(!(n in t))throw new Error(`Missing param "${n}" for warning template: ${i}`);return String(t[n])})}var xr=class{constructor(i){this.registry=i}messages=[];emit(i,t={}){let e=this.registry[i];this.messages.push({code:i,type:e.severity,message:hb(e.template,t),params:t})}getMessages(){return this.messages}},db="0.1.0",ou=`https://staticimgly.com/imgly/gfonts/${db}/dist`,ys="ly.img.gfonts",bs="ly.img.gfonts-fallbacks";async function co(i){let t=i.asset.findAllSources();t.includes(ys)||await i.asset.addLocalAssetSourceFromJSONURI(`${ou}/${ys}/content.json`),t.includes(bs)||await i.asset.addLocalAssetSourceFromJSONURI(`${ou}/${bs}/content.json`)}async function uo(i,t,e){let n=t.asset.findAllSources();if(!n.includes(ys)||!n.includes(bs))throw new Error(`The gfonts asset sources (${ys}, ${bs}) are not available. Call addGfontsAssetLibrary() first.`);let r,a=await yb(t,i.family);if(a?r=i.family:a=await mb(t,ys,i.family),!a)return null;let l=a.fonts.find(u=>fb(u,i));if(!l&&i.weight&&e?.closestWeightMatch){let u=i.style!==void 0?a.fonts.filter(f=>f.style?.toLowerCase()===i.style.toLowerCase()):a.fonts;u.length>0&&(l=gb(u,i.weight))}return l?{typeface:a,font:l,substitutedFrom:r}:null}var ho={100:"thin",200:"extraLight",300:"light",regular:"normal",400:"normal",500:"medium",600:"semiBold",700:"bold",800:"extraBold",900:"heavy"},pn=["thin","extraLight","light","normal","medium","semiBold","bold","extraBold","heavy"];function fb(i,t){return!(t.style!==void 0&&i.style?.toLowerCase()!==t.style.toLowerCase()||t.weight!==void 0&&!pb(t.weight,i.weight))}function pb(i,t){if(!t)return!1;if(i===t)return!0;let e=i.toLowerCase();if(e===t)return!0;let n=ho[e];return n!==void 0&&n===t}function au(i){let t=i.toLowerCase();for(let e of pn)if(e.toLowerCase()===t)return e;return ho[t]??null}function gb(i,t){let e=au(t);if(e===null)return;let n=pn.indexOf(e);if(n===-1)return;let r=new Map;for(let f of i){if(!f.weight)continue;let g=au(f.weight);if(g===null)continue;let m=pn.indexOf(g);m>=0&&!r.has(m)&&r.set(m,f)}if(r.size===0)return;let a=pn.indexOf("normal"),l=pn.indexOf("medium"),u=[];if(n===a||n===l){for(let f=n;f<=l;f++)u.push(f);for(let f=a-1;f>=0;f--)u.push(f);for(let f=l+1;f<pn.length;f++)u.push(f)}else if(n<a){for(let f=n;f>=0;f--)u.push(f);for(let f=n+1;f<pn.length;f++)u.push(f)}else{for(let f=n;f<pn.length;f++)u.push(f);for(let f=n-1;f>=0;f--)u.push(f)}for(let f of u){let g=r.get(f);if(g)return g}}async function mb(i,t,e){let n=await i.asset.findAssets(t,{page:0,query:e,perPage:1});if(!n||n.assets.length===0){let r=bb(e);for(let a of r)if(n=await i.asset.findAssets(t,{page:0,query:a,perPage:1}),n&&n.assets.length>0)break}return!n||n.assets.length===0?null:n.assets[0].payload?.typeface??null}async function yb(i,t){let e=await i.asset.findAssets(bs,{page:0,query:t,perPage:1});if(!e||e.assets.length===0)return null;let n=e.assets[0],r=t.toLowerCase().trim(),a=(n.id??"").toLowerCase().trim(),l=(n.label??"").toLowerCase().trim();return a!==r&&l!==r?null:n.payload?.typeface??null}function bb(i){let e=i.replace(/([A-Z])/g," $1").trim().split(" ");if(e.length<2)return[];let n=[];for(let r=e.length;r>0;r--)n.push(e.slice(0,r).join(" "));return n}var lu={DOC_PAGE_COUNT:{severity:"info",template:"PDF has {count} page(s)"},DOC_PAGE_BLOCK_COUNT:{severity:"info",template:"Page {page}: {imageCount} image, {vectorCount} vector, {textCount} text, {outlineCount} outline"},DOC_PAGE_ROTATION_DROPPED:{severity:"warning",template:"{prefix}PDF declares /Rotate {pageRotation}; the importer does not apply page rotation, so the imported page is in its un-rotated (native) orientation. Viewer-rendered output may differ from the source's display orientation."},BLOCK_KIND_UNKNOWN:{severity:"error",template:'An unknown block kind "{kind}" was encountered and was skipped.'},PAGE_INDEX_OUT_OF_RANGE:{severity:"warning",template:"Requested page index {requested} is out of range; PDF has {available} page(s). No blocks were emitted."},FONT_OPENTYPE_PARSE_FAILED:{severity:"warning",template:'{prefix}font "{fontName}" could not be parsed as OpenType{reason}. Glyph outlines will fall back to pdf.js raster paths \u2014 some shapes may render without stroke/anti-aliasing detail.'},FONT_CMAP_AUGMENTED:{severity:"info",template:'Font "{fontName}" character map was augmented (cmap patches={cmapPatches}, injected glyphs={injectedGlyphs}).'},FONT_CMAP_AUGMENT_FAILED:{severity:"warning",template:'Font "{fontName}" character map could not be augmented. Using the original font data \u2014 some glyphs may render incorrectly.'},FONT_RESOLVER_MISS:{severity:"warning",template:'Font "{fontFamily}" could not be resolved. The text was rendered as a vector outline.'},FONT_NOT_FOUND_IN_ASSETS:{severity:"warning",template:'Font "{fontFamily}" was not found in the asset library. The text was rendered as a vector outline.'},FONT_SUBSTITUTED:{severity:"info",template:'Font "{fontFamily}" was substituted with "{substitutedName}" from the asset library.'},FONT_REF_NOT_EXTRACTED:{severity:"error",template:'Text run references font "{fontRef}" which was not extracted. The text was skipped.'},FONT_SUBSTITUTIONS:{severity:"warning",template:"Substituted {count} font famil{plural} during import: {pairs}."},FONT_SUBSET_FALLBACK:{severity:"warning",template:`Used PDF-embedded subset bytes for {count} font famil{plural} not in the asset library: {families}. Subset fonts render the PDF's exact glyphs but their CMap / OpenType-feature tables can produce ligature or kerning artifacts (e.g. "f\xFCr" \u2192 "fi\xFCr"). Add the families to the asset library to use clean asset-library fonts instead.`},TEXT_OUTLINE_NO_FONT_FAMILY:{severity:"warning",template:"Text outline has no declared font family. The run was skipped."},TEXT_RUN_SKIPPED_NO_RESOLUTION:{severity:"warning",template:'No typeface or glyph outlines for "{fontFamily}"; run skipped.'},TEXT_RENDER_MODE_SKIPPED:{severity:"warning",template:'Text item{pageTag}: skipped "{text}" \u2014 PDF text rendering mode {modeLabel}. This text paints no ink; for mode 7 it acts as a clipping mask for following images, an effect the importer does not currently reproduce.'},TEXT_OVERFLOW_AFTER_AUTOSIZE:{severity:"warning",template:'Text "{text}" did not fit after auto-sizing; it still overflows by {overflowLines} line(s). The text was kept; some content may be clipped.'},TEXT_CLIP_MODE_7_DROPPED:{severity:"warning",template:"{prefix}{label} at ({bbox}) {bboxSize} pt: dropped because the surrounding region was clipped by text in PDF render mode 7 (text-as-clipping-mask). The masked artwork cannot be reproduced as text-clipped content."},IMAGE_ENCODER_MISS:{severity:"warning",template:"{prefix}an image{idLabel} ({width}\xD7{height} raw pixels{kind}) could not be encoded ({reason}). The image was dropped from the imported design."},IMAGE_PDFJS_UNRESOLVED:{severity:"error",template:"{prefix}image placement {idLabel} at ({bboxX}, {bboxY}) {bboxW}\xD7{bboxH} pt could not be resolved by pdf.js (reason={reason}) and was dropped."},IMAGE_NO_PIXELS:{severity:"warning",template:"An image element has no pixel data and was skipped."},IMAGE_FLIP_UNSUPPORTED:{severity:"warning",template:"Image flip could not be applied (engine version too old). The image will display without flip."},IMAGE_SKEW_DROPPED:{severity:"warning",template:"{prefix}an image{idLabel} at ({bboxX}, {bboxY}) {bboxW}\xD7{bboxH} pt has a skewed transform ctm={ctm}{residualStr} that cannot be represented. Placed axis-aligned \u2014 image content will appear un-skewed."},IMAGE_CLIPPED_NO_BYTES:{severity:"warning",template:"{prefix}a clipped image at {bbox} had no decoded bytes; the placement was dropped before combining clip shapes."},IMAGE_CLIP_UNUSABLE:{severity:"warning",template:"{prefix}a clipped image at {bbox} with {clipCount} clip path(s) has no usable clip \u2014 {degenerateCount} degenerate, {disjointCount} disjoint from the image. The image was dropped."},IMAGE_CLIP_EMPTY_INTERSECTION:{severity:"warning",template:"{prefix}a clipped image at {bbox} with {clipCount} clip path(s) had an empty intersection. The image was dropped."},IMAGE_CLIP_COMBINE_FAILED:{severity:"error",template:"{prefix}a clipped image at {bbox} with {clipCount} clip path(s) could not be combined. The image was dropped from the imported design."},IMAGE_MASK_NO_FILL_COLOR:{severity:"warning",template:"{prefix}a stencil ImageMask paint (objId={objId}) had no current fill colour to composite with. The mask was dropped from the imported design."},IMAGE_MASK_COMPOSITE_FAIL:{severity:"warning",template:"{prefix}a stencil ImageMask (objId={objId}) at ({bboxX}, {bboxY}) {bboxW}\xD7{bboxH} pt could not be composited with the current fill colour (space={colourSpace}). The mask was dropped from the imported design."},IMAGE_MASK_GROUP_UNSUPPORTED:{severity:"warning",template:"{prefix}a paintImageMaskXObjectGroup batch of {count} stencil paints is not supported by the importer. The masks were dropped."},IMAGE_MASK_REPEAT_UNSUPPORTED:{severity:"warning",template:"{prefix}a paintImageMaskXObjectRepeat tiling {count} stencil paints is not supported by the importer. The masks were dropped."},CLIP_DEGENERATE_FALLBACK:{severity:"warning",template:"{prefix}a clipped vector path at {bbox} with {clipCount} clip path(s) has no usable clip \u2014 {degenerateCount} degenerate (zero width or height). Falling back to the unclipped path."},CLIP_COMBINE_STROKE_ONLY:{severity:"warning",template:"{prefix}a clipped vector path at {bbox} with {clipCount} clip path(s) has no fill color (stroke-only) which cannot survive combine. Falling back to the unclipped path."},CLIP_COMBINE_FAILED:{severity:"warning",template:"{prefix}a vector path at {bbox} with {clipCount} clip path(s) could not be combined. Rendered without its clip \u2014 some content may extend beyond the intended mask."},CLIP_COMBINE_TOO_FEW_INPUTS:{severity:"warning",template:"{prefix}clip combine was called with {inputCount} input block(s) (need at least 2). The owner block was emitted without its clips."},CLIP_COMBINE_NOT_COMBINABLE:{severity:"warning",template:"{prefix}clip combine rejected {inputCount} input block(s) as not combinable (nested or incompatible shapes). The owner block was emitted without its clips."},CLIP_COMBINE_THREW:{severity:"warning",template:"{prefix}clip combine of {inputCount} input block(s) failed ({reason}). The owner block was emitted without its clips."},COLOR_TYPE_UNSUPPORTED:{severity:"warning",template:'{prefix}{subject}color of type "{colorType}" is not supported. Rendered as black.'},COLOR_SPACE_UNSUPPORTED:{severity:"warning",template:'{prefix}{elementLabel}color space "{space}" ({color}) at {bbox} is not supported. Rendered as black.'},SPOT_COLOR_NO_ALTERNATE:{severity:"warning",template:'Spot color "{name}" has no resolvable alternate; leaving at engine default.'},SPOT_COLOR_REGISTER_FAILED:{severity:"warning",template:'Failed to register spot color "{name}": {error}'},VECTOR_PATH_FILL_RULE_UNSUPPORTED:{severity:"warning",template:"CE.SDK does not expose `{property}` on `vector_path` shapes (added in CE.SDK {sinceVersion}); the source PDF used non-zero winding fill, but imported paths render with the engine default (even-odd) winding. Self-overlapping or compound paths may render with holes inverted. Upgrade `@cesdk/engine` to {sinceVersion} or newer to preserve the source winding rule."},BLEND_MODE_UNSUPPORTED:{severity:"warning",template:'Blend mode "{mode}" is not supported. Using "Normal" as the default.'},SHADING_UNRESOLVED:{severity:"error",template:"{prefix}gradient shading could not be resolved by pdf.js and was removed. The painted region will be missing in the imported scene."},SHADING_MESH_UNSUPPORTED:{severity:"warning",template:"{prefix}gradient shading uses an unsupported mesh variant (PDF ShadingType 4\u20137). The region was dropped because mesh gradients can't be represented as a CE.SDK gradient fill."},SHADING_UNKNOWN_IR_TAG:{severity:"error",template:'{prefix}gradient shading reported unknown IR tag "{tag}" and was dropped.'},SHADING_INSUFFICIENT_STOPS:{severity:"warning",template:"{prefix}gradient shading produced fewer than two color stops and was dropped."},SHADING_NO_CLIP_FALLBACK_BBOX:{severity:"info",template:"{prefix}gradient shading was painted without an active clip path. Falling back to the shading /BBox; if this scene shows gradient bands outside the intended shape, file a bug."},SHADING_CLIP_DEGENERATE:{severity:"warning",template:"{prefix}gradient shading clip path was degenerate and the region was dropped."},SHADING_RADIAL_FOCAL_DROPPED:{severity:"info",template:"{prefix}radial gradient declared a non-zero inner radius (PDF Shading Type 3 focal point). It was approximated as a centered radial; the focal offset was dropped."},SHADING_UNKNOWN_RADIAL_SUBTYPE:{severity:"error",template:'{prefix}gradient shading reported unknown RadialAxial subtype "{kind}" and was dropped.'},SHADING_NO_PATTERN_REF:{severity:"error",template:"{prefix}gradient shading was emitted without a pattern reference and was dropped."},TILING_PATTERN_AS_IMAGE:{severity:"info",template:'{prefix}tiling pattern "{patternId}" was imported as an image (single-image tiling pattern, e.g. Skia/Chrome PDF export of an embedded bitmap).'},TILING_PATTERN_UNSUPPORTED:{severity:"warning",template:'{prefix}tiling pattern "{patternId}" contains {imageCount} image XObject(s) and {otherOpCount} other paint op(s); only single-image tiling patterns are imported. The pattern fill was dropped.'},TILING_PATTERN_UNRESOLVED:{severity:"error",template:'{prefix}tiling pattern "{patternId}" could not be resolved by pdf.js and was dropped.'},TILING_PATTERN_IMAGE_DECODE_FAILED:{severity:"warning",template:'{prefix}tiling pattern "{patternId}" referenced image "{imageObjId}" but the image bytes could not be decoded. The pattern fill was dropped.'}};$a();var di=require("@napi-rs/canvas");async function Qe(i,t){return{canvas:(0,di.createCanvas)(i,t),ImageData:di.ImageData}}async function Nn(i){return new Uint8Array(i.toBuffer("image/png"))}async function Fu(i){return{opList:await i.getOperatorList({annotationMode:Wa.DISABLE})}}function Un(i,t){return Du(i.objs,t)}function ns(i,t){return Du(i.commonObjs,t)}function Du(i,t){return t==null?Promise.resolve({data:null,reason:"cb-null"}):new Promise(e=>{let n=!1,r=(l,u)=>{n||(n=!0,e({data:l,reason:u}))};try{i.get(t,l=>r(l,l==null?"cb-null":"ok"))}catch{r(null,"throw");return}setTimeout(()=>r(null,"timeout"),1e4).unref?.()})}async function pi(i,t,e={}){if(i==null)return null;let n=i.width,r=i.height;if(!n||!r)return fi("missing width/height",i,t,e),null;let{canvas:a,ImageData:l}=await Qe(n,r),u=a.getContext("2d");if(i.bitmap)try{u.drawImage(i.bitmap,0,0)}catch(f){let g=f&&typeof f=="object"&&"message"in f?String(f.message):String(f);return fi(`bitmap drawImage failed: ${g}`,i,t,e),null}else if(i.data){let f=Ya(i);if(!f)return fi(`unknown data kind=${i.kind}`,i,t,e),null;let g=new l(f,n,r);u.putImageData(g,0,0)}else return fi("no bitmap and no data",i,t,e),null;return Nn(a)}async function _u(i,t,e,n={}){if(i==null)return null;let r=i.width,a=i.height;if(!r||!a)return null;let l=Xa(t);if(l==null)return null;let[u,f,g]=l,m=await za(i);if(m==null)return null;let{canvas:y,ImageData:v}=await Qe(r,a),S=y.getContext("2d"),T=new Uint8ClampedArray(r*a*4);for(let k=0;k<r*a;k++)T[k*4]=u,T[k*4+1]=f,T[k*4+2]=g,T[k*4+3]=m[k];let C=new v(T,r,a);return S.putImageData(C,0,0),Nn(y)}async function za(i){let t=i.width,e=i.height,n=t*e;if(i.data){let{kind:r,data:a}=i;if(r===1){if(a.length>=n)return new Uint8ClampedArray(a.buffer,a.byteOffset,n);let l=new Uint8ClampedArray(n),u=Math.ceil(t/8);for(let f=0;f<e;f++)for(let g=0;g<t;g++){let y=a[f*u+(g>>3)]>>7-(g&7)&1;l[f*t+g]=y?255:0}return l}if(r===2){let l=new Uint8ClampedArray(n);for(let u=0;u<n;u++)l[u]=Math.round(a[u*3]*.299+a[u*3+1]*.587+a[u*3+2]*.114);return l}if(r===3){let l=new Uint8ClampedArray(n);for(let u=0;u<n;u++)l[u]=Math.round(a[u*4]*.299+a[u*4+1]*.587+a[u*4+2]*.114);return l}return null}if(i.bitmap){let{canvas:r}=await Qe(t,e),a=r.getContext("2d");try{a.drawImage(i.bitmap,0,0)}catch{return null}let u=a.getImageData(0,0,t,e).data,f=new Uint8ClampedArray(n);for(let g=0;g<n;g++)f[g]=Math.round(u[g*4]*.299+u[g*4+1]*.587+u[g*4+2]*.114);return f}return null}function Xa(i){if(!i||typeof i!="object")return null;let{space:t,values:e}=i;if(t==="rgb"&&Array.isArray(e)&&e.length>=3)return[Math.round(vn(e[0])*255),Math.round(vn(e[1])*255),Math.round(vn(e[2])*255)];if(t==="gray"&&Array.isArray(e)&&e.length>=1){let n=Math.round(vn(e[0])*255);return[n,n,n]}if(t==="cmyk"&&Array.isArray(e)&&e.length>=4){let n=vn(e[0]),r=vn(e[1]),a=vn(e[2]),l=vn(e[3]);return[Math.round(255*(1-n)*(1-l)),Math.round(255*(1-r)*(1-l)),Math.round(255*(1-a)*(1-l))]}return null}function vn(i){return typeof i!="number"||Number.isNaN(i)||i<0?0:i>1?1:i}function fi(i,t,e,n={}){if(!e?.emit)return;let r=n.pageIndex!=null?`Page ${n.pageIndex}: `:"",a=n.objId?` objId="${n.objId}"`:"",l=t?.width??"?",u=t?.height??"?",f=t?.kind!=null?`, kind=${t.kind}`:"";e.emit("IMAGE_ENCODER_MISS",{prefix:r,idLabel:a,width:l,height:u,kind:f,reason:i,page:n.pageIndex,objId:n.objId??null})}function Ya(i){let t=i.width,e=i.height,n=i.kind,r=i.data,a=t*e,l=new Uint8ClampedArray(a*4);if(n===1){if(r.length>=a){for(let f=0;f<a;f++){let g=r[f];l[f*4]=g,l[f*4+1]=g,l[f*4+2]=g,l[f*4+3]=255}return l}let u=Math.ceil(t/8);for(let f=0;f<e;f++)for(let g=0;g<t;g++){let v=r[f*u+(g>>3)]>>7-(g&7)&1?255:0,S=(f*t+g)*4;l[S]=v,l[S+1]=v,l[S+2]=v,l[S+3]=255}return l}if(n===2){for(let u=0;u<a;u++)l[u*4]=r[u*3],l[u*4+1]=r[u*3+1],l[u*4+2]=r[u*3+2],l[u*4+3]=255;return l}return n===3?new Uint8ClampedArray(r.buffer,r.byteOffset,r.byteLength):null}async function rv(i){if(i==null)return null;let{width:t,height:e}=i;if(!t||!e)return null;let n=t*e;if(i.data){let r=new Uint8ClampedArray(n),a=Math.ceil(t/8);for(let l=0;l<e;l++)for(let u=0;u<t;u++){let g=i.data[l*a+(u>>3)]>>7-(u&7)&1;r[l*t+u]=g?0:255}return r}if(i.bitmap){let{canvas:r}=await Qe(t,e),a=r.getContext("2d");try{a.drawImage(i.bitmap,0,0)}catch{return null}let l=a.getImageData(0,0,t,e),u=new Uint8ClampedArray(n);for(let f=0;f<n;f++)u[f]=l.data[f*4+3];return u}return null}async function Nu(i,t,e,n={}){if(i==null)return null;let r=i.width,a=i.height;if(!r||!a)return null;let l=Xa(t);if(l==null)return null;let[u,f,g]=l,m=await rv(i);if(m==null)return null;let{canvas:y,ImageData:v}=await Qe(r,a),S=y.getContext("2d"),T=new Uint8ClampedArray(r*a*4);for(let k=0;k<r*a;k++)T[k*4]=u,T[k*4+1]=f,T[k*4+2]=g,T[k*4+3]=m[k];let C=new v(T,r,a);return S.putImageData(C,0,0),Nn(y)}async function Bu(i){let{imageObj:t,imageCtm:e,maskSource:n,modulatedAlpha:r}=i;if(t==null)return null;let a=t.width,l=t.height;if(!a||!l)return null;let u=Hu(r??1);if(n.kind==="shading"){let f=iv(n.ir,n.ctm);return f==null?null:Uu(a,l,e,f,u)}if(n.kind==="image"){if(n.obj==null)return null;let f=n.obj.width,g=n.obj.height;if(!f||!g)return null;let m=await za(n.obj);if(m==null)return null;let y=ov(n.ctm,m,f,g);return y==null?null:Uu(a,l,e,y,u)}return null}async function Gu(i,t){if(i==null)return null;let e=i.width,n=i.height;if(!e||!n||t.length!==e*n)return null;let r=null;if(i.bitmap){let{canvas:m}=await Qe(e,n),y=m.getContext("2d");try{y.drawImage(i.bitmap,0,0)}catch{return null}let v=y.getImageData(0,0,e,n);r=new Uint8ClampedArray(v.data.buffer.slice(0))}else i.data&&(r=Ya(i));if(!r)return null;let a=new Uint8ClampedArray(e*n*4);for(let m=0;m<e*n;m++){a[m*4]=r[m*4],a[m*4+1]=r[m*4+1],a[m*4+2]=r[m*4+2];let y=r[m*4+3];a[m*4+3]=Math.round(y*t[m]/255)}let{canvas:l,ImageData:u}=await Qe(e,n),f=l.getContext("2d"),g=new u(a,e,n);return f.putImageData(g,0,0),Nn(l)}function Uu(i,t,e,n,r){let a=new Uint8ClampedArray(i*t),[l,u,f,g,m,y]=e;for(let v=0;v<t;v++)for(let S=0;S<i;S++){let T=(S+.5)/i,C=1-(v+.5)/t,k=l*T+f*C+m,I=u*T+g*C+y,O=n(k,I);a[v*i+S]=Math.round(O*255*r)}return a}function iv(i,t){if(!Array.isArray(i)||i[0]!=="RadialAxial")return null;let e=i[1],n=i[3],r=i[4],a=i[5],l=i[6],u=i[7],f=av(n);if(f==null)return null;let g=ju(t);if(g==null)return null;if(e==="axial"){if(!Array.isArray(r)||!Array.isArray(a))return null;let[m,y]=r,[v,S]=a,T=v-m,C=S-y,k=T*T+C*C;return k<=0?null:(I,O)=>{let[D,_]=Ka(g,I,O),M=((D-m)*T+(_-y)*C)/k,B=Math.max(0,Math.min(1,M));return f[Math.round(B*255)]/255}}if(e==="radial"){if(!Array.isArray(a)||typeof u!="number"||u<=0||Math.abs(typeof l=="number"?l:0)>.001)return null;let[y,v]=a;return(S,T)=>{let[C,k]=Ka(g,S,T),I=C-y,O=k-v,_=Math.sqrt(I*I+O*O)/u,M=Math.max(0,Math.min(1,_));return f[Math.round(M*255)]/255}}return null}function ov(i,t,e,n){let r=ju(i);return r==null?null:(a,l)=>{let[u,f]=Ka(r,a,l);if(u<0||u>1||f<0||f>1)return 0;let g=Math.min(e-1,Math.floor(u*e)),m=Math.min(n-1,Math.floor((1-f)*n));return t[m*e+g]/255}}function av(i){if(!Array.isArray(i)||i.length<2)return null;let t=[];for(let n of i){if(!Array.isArray(n)||n.length<2)continue;let r=Hu(n[0]),a=lv(n[1]);a&&t.push({offset:r,r:a[0],g:a[1],b:a[2]})}if(t.length<2)return null;t.sort((n,r)=>n.offset-r.offset);let e=new Uint8Array(256);for(let n=0;n<256;n++){let r=n/255,a=t[0],l=t[t.length-1];for(let v=0;v<t.length-1;v++)if(r>=t[v].offset&&r<=t[v+1].offset){a=t[v],l=t[v+1];break}let u=l.offset-a.offset,f=u>0?(r-a.offset)/u:0,g=a.r+(l.r-a.r)*f,m=a.g+(l.g-a.g)*f,y=a.b+(l.b-a.b)*f;e[n]=Math.round(.299*g+.587*m+.114*y)}return e}function lv(i){if(typeof i!="string")return null;if(i==="transparent")return[255,255,255];let t=/^#([0-9a-fA-F]{6})$/.exec(i.trim());if(!t)return null;let e=parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255]}function Hu(i){return typeof i!="number"||!Number.isFinite(i)||i<0?0:i>1?1:i}function Ka(i,t,e){return[i[0]*t+i[2]*e+i[4],i[1]*t+i[3]*e+i[5]]}function ju(i){let[t,e,n,r,a,l]=i,u=t*r-e*n;if(!Number.isFinite(u)||Math.abs(u)<1e-12)return null;let f=1/u;return[r*f,-e*f,-n*f,t*f,(n*l-r*a)*f,(e*a-t*l)*f]}var cv=/^[A-Z]{6}\+/,uv=[["ultracondensed","ultraCondensed"],["extracondensed","extraCondensed"],["semicondensed","semiCondensed"],["condensed","condensed"],["compressed","condensed"],["narrow","condensed"],["cond","condensed"],["comp","condensed"],["ultraexpanded","ultraExpanded"],["extraexpanded","extraExpanded"],["semiexpanded","semiExpanded"],["expanded","expanded"],["extended","expanded"],["wide","expanded"]],hv=["italic","oblique"],Vu={bd:700,lt:300,md:500,rg:400,bk:900,blk:900,hv:900,th:100,hl:100};function Bs(i){let t=i.replace(cv,""),e=t.lastIndexOf("-"),n=t.lastIndexOf(","),r=Math.max(e,n);if(r<0)return{fullName:t,family:t,weight:null,style:"normal",width:null,styleSuffix:null};let a=t.slice(0,r),l=t.slice(r+1),u=dv(l);return u?{fullName:t,family:a,weight:u.weight,style:u.style,width:u.width,styleSuffix:l}:{fullName:t,family:t,weight:null,style:"normal",width:null,styleSuffix:null}}function dv(i){let t=i.toLowerCase(),e=!1,n="normal";for(let l of hv)if(t.includes(l)){n="italic",e=!0;break}let r=null;for(let[l,u]of uv)if(t.includes(l)){r=u,e=!0;break}let a=fv(t);return a!==null&&(e=!0),e?{weight:a,style:n,width:r}:null}function fv(i){return i.includes("extrabold")||i.includes("ultrabold")?800:i.includes("semibold")||i.includes("demibold")?600:i.includes("extralight")||i.includes("ultralight")?200:i.includes("thin")||i.includes("hairline")?100:i.includes("light")?300:i.includes("medium")?500:i.includes("bold")?700:i.includes("black")||i.includes("heavy")?900:i.includes("regular")||i==="normal"||i.includes("book")||i.includes("roman")?400:Object.prototype.hasOwnProperty.call(Vu,i)?Vu[i]:null}var pv=/^[A-Z]{6}\+/;async function Qa(i,t){if(!i||!i.data||i.data.length===0)return null;let e=Bs(i.name??"");if(!e.fullName)return null;let n=i.loadedName?`${e.fullName}#${i.loadedName}`:e.fullName,r=i._parsed??null,a=r?.names,l=(a?.fontFamily?.en?.trim()||a?.fontFamily?.und?.trim()||e.family).replace(pv,""),u=r?.tables?.os2,f=e.weight??u?.usWeightClass??(i.black?900:i.bold?700:400),g=i.italic?"italic":e.style,m=e.width??gv(u?.usWidthClass),y=i.data instanceof Uint8Array?i.data:new Uint8Array(i.data),v=await vv(r,y,i.toFontChar??null,t),S=mv(v);return{postScriptName:n,family:l,weight:f,style:g,...m?{width:m}:{},data:v,mimeType:S}}function gv(i){if(typeof i=="number")switch(i){case 1:return"ultraCondensed";case 2:return"extraCondensed";case 3:return"condensed";case 4:return"semiCondensed";case 5:return"normal";case 6:return"semiExpanded";case 7:return"expanded";case 8:return"extraExpanded";case 9:return"ultraExpanded";default:return}}function zu(i,t){if(!yi(i)||!t||t.length===0)return!1;for(let e of t){let n=e.unicode;if(!n||yv(n))return!1}return!0}function yi(i){return!(!i||i.isType3Font||!i.data||i.data.length===0||!i._parsed)}function xn(i){let t=Number(i)||400;return t<=150?"thin":t<=250?"extraLight":t<=350?"light":t<=450?"normal":t<=550?"medium":t<=650?"semiBold":t<=750?"bold":t<=850?"extraBold":"heavy"}function Xu(i){let t=Bs(i?.name??""),e=i?._parsed?.tables?.os2,n=t.weight??e?.usWeightClass??(i?.black?900:i?.bold?700:400);return{style:i?.italic?"italic":t.style,weight:xn(n)}}function mv(i){return i.length>=4&&i[0]===79&&i[1]===84&&i[2]===84&&i[3]===79?"font/otf":"font/ttf"}function yv(i){for(let t of i){let e=t.codePointAt(0);if(e!=null&&(e>=57344&&e<=63743||e>=983040&&e<=1048573||e>=1048576&&e<=1114109))return!0}return!1}var bv=[32,160];async function vv(i,t,e,n){if(!i)return t;let r=mi.get(i);if(r)return r;try{let{default:a}=await Promise.resolve().then(()=>iu(Za(),1)),l=xv(i,e);for(let{glyphIndex:C,unicode:k}of l){let I=i.glyphs.get(C);if(!I)continue;let O=I;O.unicodes||(O.unicodes=O.unicode!=null?[O.unicode]:[]),O.unicodes.includes(k)||O.unicodes.push(k)}let u=[],f=i.unitsPerEm||1e3,g=Math.round(f*.25),m=i.glyphs;for(let C of bv){if(Av(i,C))continue;let k=m.length,I=new a.Glyph({name:C===32?"space":`uni${C.toString(16).toUpperCase()}`,unicode:C,advanceWidth:g,path:new a.Path});I.index=k,m.glyphs[k]=I,m.length=k+1,u.push(C)}if(l.length===0&&u.length===0)return mi.set(i,t),t;for(let C=0;C<m.length;C+=1){let k=i.glyphs.get(C);k&&(typeof k.name!="string"||k.name==="")&&(k.name=C===0?".notdef":`gid${C}`)}i.numGlyphs=m.length;let y=i.toArrayBuffer(),S=a.parse(y).toArrayBuffer(),T=new Uint8Array(S);if(mi.set(i,T),Sv()){let C=i.names?.postScriptName?.en??"<unknown>",k=u.map(I=>"U+"+I.toString(16).toUpperCase()).join(",")||"none";n?.emit?.("FONT_CMAP_AUGMENTED",{fontName:C,cmapPatches:l.length,injectedGlyphs:k})}return T}catch(a){let l=i.names?.postScriptName?.en??"<unknown>",u=a&&typeof a=="object"&&"message"in a?String(a.message):String(a);return n?.emit?.("FONT_CMAP_AUGMENT_FAILED",{fontName:l,error:u}),mi.set(i,t),t}}function xv(i,t){let e=[];if(!t)return e;let r=i.tables?.cmap?.glyphIndexMap;if(!r)return e;for(let[a,l]of Object.entries(t)){let u=Number(a);if(!Number.isFinite(u)||u===l||r[u])continue;let f=r[l];f&&e.push({unicode:u,glyphIndex:f})}return e}var mi=new WeakMap;function Sv(){return!!(typeof process<"u"&&process.env?.PDF2CESDK_DEBUG_FONTS||typeof globalThis<"u"&&globalThis.PDF2CESDK_DEBUG_FONTS)}function Av(i,t){try{let e=i.charToGlyphIndex(String.fromCodePoint(t));if(!e)return!1;let n=i.glyphs.get(e);return!!n&&(n.advanceWidth??0)>0}catch{return!1}}function Qu(i,t,e,n){if(!i||i.length===0)return[];let r=i.map(u=>Cv(u,t,e,n)),a=[],l=null;for(let u of r)if(u){if(l&&Tv(l,u)){l.items.push(u);continue}l&&a.push(Yu(l,t)),l={items:[u]}}return l&&a.push(Yu(l,t)),a}function Tv(i,t){let e=i.items[i.items.length-1];return!(t.fontObjId!==e.fontObjId||Math.abs(t.fontSizePt-e.fontSizePt)>1||Math.abs(t.baselineYPt-e.baselineYPt)>2||t.originXPt-(e.originXPt+e.advancePt)>.5*t.fontSizePt)}function Cv(i,t,e,n){let r=t[i.fontObjId];if(!r)return null;let a=Zu(e,i.textMatrix),l=[i.fontSize,0,0,i.fontSize,0,0],u=Zu(a,l),f=Math.hypot(u[2],u[3]),g=a[4],m=n-a[5],y=Ev(i,r,f);return{glyph:i,fontObjId:i.fontObjId,fontSizePt:f,originXPt:g,baselineYPt:m,advancePt:y}}function Ev(i,t,e){let n=t._parsed;if(n&&i.unicode)try{let r=n.charToGlyph?.(i.unicode);if(r&&r.advanceWidth&&n.unitsPerEm)return r.advanceWidth/n.unitsPerEm*e}catch{}return .5*e}function Yu(i,t){let e=i.items,n=e[0],r=e[e.length-1],l=t[n.fontObjId]?._parsed,u=Ku(e.map(I=>I.fontSizePt)),f=l?.unitsPerEm??1e3,g=l?.ascender?l.ascender/f*u:.8*u,m=l?.descender?Math.abs(l.descender/f)*u:.2*u,y=n.originXPt,v=Ku(e.map(I=>I.baselineYPt)),T=r.originXPt+r.advancePt-y+.05*u*e.length,C="",k=null;for(let I of e){let O=I.glyph.unicode??"";if(k){let D=k.originXPt+k.advancePt;I.originXPt-D>.2*I.fontSizePt&&!O.startsWith(" ")&&!C.endsWith(" ")&&(C+=" ")}C+=O,k=I}return{glyphs:e.map(I=>I.glyph),fontObjId:n.fontObjId,fontSizePt:u,originXPt:y,baselineYPt:v,widthPt:T,ascenderPt:g,descenderPt:m,text:C}}function Ku(i){return i.length===0?0:i.reduce((t,e)=>t+e,0)/i.length}function Zu(i,t){let[e,n,r,a,l,u]=i,[f,g,m,y,v,S]=t;return[e*f+r*g,n*f+a*g,e*m+r*y,n*m+a*y,e*v+r*S+l,n*v+a*S+u]}function jt(i){return Number.isFinite(i)?i.toFixed(1):String(i)}function Me(i){if(!i)return"(unknown position)";let t=typeof i.x=="number"?jt(i.x):"?",e=typeof i.y=="number"?jt(i.y):"?",n=typeof i.width=="number"?jt(i.width):"?",r=typeof i.height=="number"?jt(i.height):"?";return`(${t}, ${e}) ${n}\xD7${r} pt`}function Ju(i){if(!i||i.length<6)return"[invalid]";let[t,e,n,r,a,l]=i;return`[a=${jt(t)}, b=${jt(e)}, c=${jt(n)}, d=${jt(r)}, e=${jt(a)}, f=${jt(l)}]`}function qu(i){if(i==null)return"none";if(typeof i!="object")return String(i);let t=i;if("type"in t)switch(t.type){case"rgb":return`rgb(${me(t.r)}, ${me(t.g)}, ${me(t.b)})`;case"cmyk":return`cmyk(${me(t.c)}, ${me(t.m)}, ${me(t.y)}, ${me(t.k)})`;case"spot":{let e=typeof t.name=="string"?`"${t.name}"`:"(unnamed)",n=typeof t.tint=="number"?`, tint=${me(t.tint)}`:"",r=t.fallback_rgb,a=Array.isArray(r)?`, fallback=rgb(${me(r[0])}, ${me(r[1])}, ${me(r[2])})`:", no fallback";return`spot ${e}${n}${a}`}default:return`type="${String(t.type)}"`}if("space"in t&&Array.isArray(t.values)){let e=t.values.map(n=>me(n)).join(", ");return`${String(t.space)}(${e})`}return"r"in t&&"g"in t&&"b"in t?`rgb(${me(t.r)}, ${me(t.g)}, ${me(t.b)})`:"(opaque)"}function me(i){return Number.isFinite(i)?i.toFixed(2):String(i)}function Ja(){return[]}function th(i,t,e,n){return[...i,{path:t,fillRule:e,ctm:n.slice()}]}function eh(i){return i.slice()}function nh(i){return i.pop()??Ja()}function ss(i){return i.length===0}var Bn=Object.freeze({moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19}),ZS=Object.freeze([1,0,0,1,0,0]);function wv(i,t,e){let n=i.ops??[],r=i.coords??[],a=[],l=[],u=0,f=null,[g,m,y,v,S,T]=t,C=(k,I)=>[g*k+y*I+S,e-(m*k+v*I+T)];for(let k=0;k<n.length;k++)switch(n[k]){case Bn.rectangle:{let I=r[u++],O=r[u++],D=r[u++],_=r[u++],M=C(I,O),B=C(I+D,O),H=C(I+D,O+_),z=C(I,O+_);a.push({cmd:"M",pts:[M]}),a.push({cmd:"L",pts:[B]}),a.push({cmd:"L",pts:[H]}),a.push({cmd:"L",pts:[z]}),a.push({cmd:"Z"}),l.push(M,B,H,z);break}case Bn.moveTo:{let I=C(r[u++],r[u++]);a.push({cmd:"M",pts:[I]}),l.push(I),f=I;break}case Bn.lineTo:{let I=C(r[u++],r[u++]);a.push({cmd:"L",pts:[I]}),l.push(I),f=I;break}case Bn.curveTo:{let I=C(r[u++],r[u++]),O=C(r[u++],r[u++]),D=C(r[u++],r[u++]);a.push({cmd:"C",pts:[I,O,D]}),l.push(I,O,D),f=D;break}case Bn.curveTo2:{let I=C(r[u++],r[u++]),O=C(r[u++],r[u++]),D=f??I;a.push({cmd:"C",pts:[D,I,O]}),l.push(I,O),f=O;break}case Bn.curveTo3:{let I=C(r[u++],r[u++]),O=C(r[u++],r[u++]);a.push({cmd:"C",pts:[I,O,O]}),l.push(I,O),f=O;break}case Bn.closePath:a.push({cmd:"Z"});break;default:break}return{cmds:a,devPoints:l}}function kv(i){if(i.length===0)return{x:0,y:0,width:0,height:0};let t=1/0,e=1/0,n=-1/0,r=-1/0;for(let[a,l]of i)a<t&&(t=a),l<e&&(e=l),a>n&&(n=a),l>r&&(r=l);return{x:t,y:e,width:n-t,height:r-e}}function Iv(i,t,e){let n=a=>`${Math.round(a*100)/100}`,r=[];for(let a of i){if(a.cmd==="Z"){r.push("Z");continue}let l=a.pts.map(([u,f])=>`${n(u-t)} ${n(f-e)}`).join(" ");r.push(`${a.cmd} ${l}`)}return r.join(" ")}function bi(i,t,e){let{cmds:n,devPoints:r}=wv(i,t,e);if(r.length===0)return null;let a=kv(r);return{...a,d:Iv(n,a.x,a.y),cmds:n,devPoints:r}}function Sn(i,t){let e=[];for(let n of i){let r=Rv(n,t);r&&e.push(r)}return e}function Rv(i,t){let e=bi(i.path,i.ctm,t.heightPt);return!e||e.width<=0&&e.height<=0?null:{d:e.d,x:e.x,y:e.y,width:e.width,height:e.height,fillRule:i.fillRule}}function sh({shadingIR:i,ctm:t,clipEntry:e,remainingClips:n,pageBox:r,opacity:a,blendMode:l,logger:u,pageIndex:f}){let g=Array.isArray(i)?i[0]:null,m=f!=null?`Page ${f}: `:"";if(g==="Dummy"||g==null)return u?.emit?.("SHADING_UNRESOLVED",{prefix:m,page:f}),null;if(g==="Mesh")return u?.emit?.("SHADING_MESH_UNSUPPORTED",{prefix:m,page:f}),null;if(g!=="RadialAxial")return u?.emit?.("SHADING_UNKNOWN_IR_TAG",{prefix:m,tag:String(g),page:f}),null;let y=i,v=y[1],S=y[3],T=y[4],C=y[5],k=y[6],I=y[7],O=Pv(S);if(O.length<2)return u?.emit?.("SHADING_INSUFFICIENT_STOPS",{prefix:m,page:f}),null;e==null&&u?.emit?.("SHADING_NO_CLIP_FALLBACK_BBOX",{prefix:m,page:f});let D=e?bi(e.path,e.ctm,r.heightPt):null;if(!D||D.width<=0&&D.height<=0)return u?.emit?.("SHADING_CLIP_DEGENERATE",{prefix:m,page:f}),null;let _={kind:"vector-path",x:D.x,y:D.y,width:D.width,height:D.height,d:D.d,fill:null,stroke:null,strokeWidth:0,fillRule:e?.fillRule??"nonzero",opacity:1,blendMode:l??void 0};if(v==="axial"){let M=qa(T,t,r.heightPt),B=qa(C,t,r.heightPt);_.fill={kind:"linearGradient",start:M,end:B,stops:O}}else if(v==="radial"){typeof k=="number"&&k>.001&&u?.emit?.("SHADING_RADIAL_FOCAL_DROPPED",{prefix:m,page:f,innerRadius:k});let M=qa(C,t,r.heightPt),B=Lv(t);_.fill={kind:"radialGradient",center:M,radius:Math.max(.001,Math.abs((I??0)*B)),stops:O}}else return u?.emit?.("SHADING_UNKNOWN_RADIAL_SUBTYPE",{prefix:m,kind:String(v),page:f}),null;if(a!=null&&a<1&&(_.opacity=a),n&&n.length>0){let M=Sn(n,r);M.length>0&&(_.clips=M)}return _}function Pv(i){if(!Array.isArray(i))return[];let t=[];for(let e of i){if(!Array.isArray(e)||e.length<2)continue;let n=Mv(e[0]),r=Ov(e[1]);if(!r)continue;let a={space:"rgb",values:r};t.push({offset:n,color:a})}return t}function Ov(i){if(typeof i!="string")return null;if(i==="transparent")return[1,1,1];let t=/^#([0-9a-fA-F]{6})$/.exec(i.trim());if(!t)return null;let e=parseInt(t[1],16);return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]}function Mv(i){return typeof i!="number"||!Number.isFinite(i)||i<0?0:i>1?1:i}function qa(i,t,e){let n=Array.isArray(i)?i[0]:0,r=Array.isArray(i)?i[1]:0,[a,l,u,f,g,m]=t;return{x:a*n+u*r+g,y:e-(l*n+f*r+m)}}function Lv([i,t,e,n]){return Math.sqrt(Math.abs(i*n-t*e))}var Fv=12,Dv=85,_v=10,Nv=11,Uv=91,Bv=22,Gv=23,Hv=24,jv=25,Vv=28,Wv=29,$v=30,zv=new Set([1,9,31,32,37,2,50,51,53,55,56,57,58,59,60,61]);async function rh({page:i,pattern:t,logger:e,pageIndex:n}){let r=n!=null?`Page ${n}: `:"",{fnArray:a,argsArray:l}=t.operatorList,u=0,f=0,g=0,m=[],y=null,v=[1,0,0,1,0,0],S=[];for(let H=0;H<a.length;H++){let z=a[H],W=l[H]??[];switch(z){case _v:S.push(v.slice());break;case Nv:v=S.pop()??[1,0,0,1,0,0];break;case Fv:v=Xv(v,W);break;case Dv:{u++;let Q=W[0],q=Number(W[1]??0)||0,bt=Number(W[2]??0)||0;typeof Q=="string"&&m.push({objId:Q,ctm:v.slice(),w:q,h:bt});break}case Uv:{let Q=W,q=Q[2];if(q&&q.length>=4)y={w:q[2]-q[0],h:q[3]-q[1]};else{let bt=Q[1];y=Kv(bt)}break}case Bv:case Gv:case Hv:case jv:y!=null?(g+=Yv(y,v),y=null):f++;break;case Vv:case Wv:case $v:y=null;break;default:zv.has(z)||f++}}if(m.length===0)return e?.emit?.("TILING_PATTERN_UNSUPPORTED",{prefix:r,patternId:t.patternId,imageCount:u,otherOpCount:f,page:n,reason:"no-images"}),null;m.sort((H,z)=>z.w*z.h-H.w*H.h);let T=m[0],C=10,k=T.w*T.h,I=m.slice(1).reduce((H,z)=>H+z.w*z.h,0),O=Math.abs(T.ctm[0]*T.ctm[3]-T.ctm[1]*T.ctm[2]);if(!(f===0&&k>0&&k>=C*I&&O>=g))return e?.emit?.("TILING_PATTERN_UNSUPPORTED",{prefix:r,patternId:t.patternId,imageCount:u,otherOpCount:f,page:n,reason:"not-image-dominant",primarySrcArea:k,otherSrcArea:I,primaryPaintedArea:O,rectFillArea:g}),null;let M=(await(T.objId.startsWith("g_")?ns(i,T.objId):Un(i,T.objId))).data;if(!M)return e?.emit?.("TILING_PATTERN_IMAGE_DECODE_FAILED",{prefix:r,patternId:t.patternId,imageObjId:T.objId,page:n}),null;let B=await pi(M,e,{objId:T.objId,pageIndex:n??void 0});return B?{bytes:B,width:M.width??0,height:M.height??0}:(e?.emit?.("TILING_PATTERN_IMAGE_DECODE_FAILED",{prefix:r,patternId:t.patternId,imageObjId:T.objId,page:n}),null)}function Xv(i,t){let[e,n,r,a,l,u]=i,[f,g,m,y,v,S]=t;return[e*f+r*g,n*f+a*g,e*m+r*y,n*m+a*y,e*v+r*S+l,n*v+a*S+u]}function Yv(i,t){return Math.abs(t[0]*t[3]-t[1]*t[2])*i.w*i.h}function Kv(i){if(!i||i.length<2)return null;let t=1/0,e=1/0,n=-1/0,r=-1/0;for(let a=0;a+1<i.length;a+=2){let l=i[a],u=i[a+1];l<t&&(t=l),u<e&&(e=u),l>n&&(n=l),u>r&&(r=u)}return!Number.isFinite(t)||!Number.isFinite(e)?null:{w:n-t,h:r-e}}var Zv={0:"Butt",1:"Round",2:"Square"},st={setLineWidth:2,setLineCap:3,setDash:6,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,beginText:31,endText:32,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,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColorN:53,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,paintImageXObject:85,paintInlineImageXObject:86,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,shadingFill:62},vi=[1,0,0,1,0,0];async function dh(i,t,e={}){let n=e.textMode??"outline",r=e.docFonts??new Map,a=e.logger,l=e.pageIndex,{opList:u}=await Fu(i),f=await Qv(i,u,{logger:a,pageIndex:l}),g=i.colorSpaceResources??{},{out:m,colorSnapshots:y}=await qv(u,t,i,f,{textMode:n,docFonts:r,logger:a,pageIndex:l,colorSpaceResources:g});return{out:m,colorSnapshots:y,finalize:()=>gx(tx(m),t)}}async function Qv(i,t,e={}){let n=new Set,r=t.fnArray,a=t.argsArray;for(let u=0;u<r.length;u++)r[u]===st.setFont&&n.add(a[u][0]);let l={};for(let u of n){let f=(await ns(i,u)).data;if(f&&!f.isType3Font&&f.data){let g=f.name||f.loadedName||f.fallbackName||`(font object ${u})`;f._parsed=await Jv(f.data,g,e)}l[u]=f}return l}async function Jv(i,t,e={}){try{let{default:n}=await Promise.resolve().then(()=>iu(Za(),1)),r=i instanceof Uint8Array?i:new Uint8Array(i),a=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);return n.parse(a)}catch(n){let r=e.pageIndex!=null?`Page ${e.pageIndex}: `:"",a=n&&typeof n=="object"&&"message"in n?String(n.message):null,l=a?` (${a})`:"";return e.logger?.emit?.("FONT_OPENTYPE_PARSE_FAILED",{prefix:r,fontName:t,reason:l,page:e.pageIndex,error:a}),null}}async function qv(i,t,e,n,r){let a=i.fnArray,l=i.argsArray,u=[],f=r?.colorSpaceResources??{},g=[],m=t.originShiftPt??{x:0,y:0},y=uh(m),v=[],S=null,T=Ja(),C=[],k=null,I=[],O=[],D=[],_=null,M=[],B=[],H=[],z=[],W=0,Q=!1,q=[],bt=()=>q.some(X=>X.suppressing),et=null,Tt=null,dt=null,Y=X=>{let at=r.pageIndex!=null?`Page ${r.pageIndex}: `:"";r.logger?.log?.(`${at}${X}`,"warning")},Z=X=>{if(!Array.isArray(X)||X.length<4)return"(unknown bbox)";let[at,K,nt,ot]=X,V=at/72,j=(t.heightPt-ot)/72,U=Math.abs(nt-at)/72,lt=Math.abs(ot-K)/72;return`(${V.toFixed(2)} in, ${j.toFixed(2)} in) ${U.toFixed(2)}\xD7${lt.toFixed(2)} in`},yt=()=>{if(y.blendMode!=null&&y.blendMode!=="source-over")return y.blendMode;for(let X=M.length-1;X>=0;X--){let at=M[X];if(at!=null&&at!=="source-over")return at}return y.blendMode},it=()=>{if(y.fillAlpha!=null&&y.fillAlpha<1)return y.fillAlpha;for(let X=B.length-1;X>=0;X--){let at=B[X];if(at!=null&&at<1)return at}return y.fillAlpha},kt=()=>{_&&_.glyphs.length>0?ex(_,n,t,r):_&&je(_.placeholder),_=null};for(let X=0;X<a.length;X++){let at=a[X],K=l[X];switch(at){case st.save:v.push(y),y=hx(y),C.push(eh(T));break;case st.restore:y=v.pop()??uh(m),T=nh(C);break;case st.paintFormXObjectBegin:M.push(y.blendMode),B.push(y.fillAlpha),H.push({blendMode:y.blendMode,fillAlpha:y.fillAlpha});break;case st.paintFormXObjectEnd:{M.pop(),B.pop();let nt=H.pop();nt&&(y.blendMode=nt.blendMode,nt.fillAlpha!=null&&(y.fillAlpha=nt.fillAlpha));break}case st.beginGroup:{let nt=K?.[0]??{},ot=nt.smask!=null;z.push(ot),ot&&W++,q.push({candidate:Q&&!ot,suppressing:!1}),ot&&nt.smask?.subtype==="Luminosity"&&(et={groupBbox:Array.isArray(nt.bbox)?nt.bbox.slice():null,captured:null,abort:!1,abortReason:null}),Q&&!ot&&Tt!=null&&dt==null&&(dt={mask:Tt,target:y.fillColor!=null?{kind:"solid",color:y.fillColor}:null,formBbox:Array.isArray(nt.bbox)?nt.bbox.slice():null,alpha:null,aborted:!1},Tt=null),Q=!1;break}case st.endGroup:{let nt=z.pop();nt&&W--;let ot=q.pop();if(nt&&et!=null&&(et.abort?Y(`a luminosity SMask group at ${Z(et.groupBbox)} ${et.abortReason}. The shadow was dropped from the imported design.`):et.captured==null?Y(`a luminosity SMask group at ${Z(et.groupBbox)} has no grayscale image content. The shadow was dropped from the imported design.`):Tt={groupBbox:et.groupBbox,captured:et.captured},et=null),ot&&ot.candidate&&dt!=null){let{mask:V,target:j,formBbox:U,alpha:lt,aborted:Ct}=dt;if(dt=null,Ct)Y(`a luminosity SMask at ${Z(U)} modulates multiple images in one paint group (only single-paint targets are supported). The shadow was dropped from the imported design.`);else if(j==null)Y(`a luminosity SMask at ${Z(U)} modulates an unsupported paint shape (no solid fill colour or image was captured). The shadow was dropped from the imported design.`);else if(j.kind==="solid"){let gt=j.color;if(gt.space!=="rgb"&&gt.space!=="cmyk"&&gt.space!=="gray")Y(`a luminosity SMask at ${Z(U)} modulates a non-solid fill (${gt.space}); compositing isn't supported. The shadow was dropped from the imported design.`);else if(V.captured.kind!=="image")Y(`a luminosity SMask at ${Z(U)} uses a shading mask against a solid fill (only image masks are supported for solid targets). The shadow was dropped from the imported design.`);else{let Vt={kind:"image",_placeholderIndex:u.length};u.push(Vt);let Dt=lt??1;I.push({placeholder:Vt,objId:V.captured.objId,inline:null,ctm:V.captured.ctm,opacity:Dt,blendMode:null,clips:null,compositeWith:gt})}}else{let gt={kind:"image",_placeholderIndex:u.length};u.push(gt),I.push({placeholder:gt,objId:j.objId,inline:null,ctm:j.ctm,opacity:1,blendMode:null,clips:null,compositeWithMask:{mask:V.captured,maskGroupBbox:V.groupBbox,modulatedAlpha:lt??1}})}}break}case st.transform:y.ctm=Ve(y.ctm,K);break;case st.setLineWidth:y.lineWidth=K[0];break;case st.setLineCap:typeof K[0]=="number"&&(y.lineCap=K[0]);break;case st.setDash:y.lineDash=Array.isArray(K[0])?K[0].slice():[];break;case st.setFillRGBColor:y.fillColor=oh(K);break;case st.setStrokeRGBColor:y.strokeColor=oh(K);break;case st.setFillCMYKColor:y.fillColor={space:"cmyk",values:[K[0],K[1],K[2],K[3]]};break;case st.setStrokeCMYKColor:y.strokeColor={space:"cmyk",values:[K[0],K[1],K[2],K[3]]};break;case st.setFillGray:y.fillColor={space:"gray",values:[K[0]]};break;case st.setStrokeGray:y.strokeColor={space:"gray",values:[K[0]]};break;case st.setFillColorSpace:y.fillColorSpaceName=K?.[0]??null,y.fillColorSpaceName!=="Pattern"&&(y.fillPattern=null);break;case st.setStrokeColorSpace:y.strokeColorSpaceName=K?.[0]??null;break;case st.setFillColorN:{let nt=dx(K);if(nt){y.fillPattern=nt;break}let{key:ot,components:V}=ah(K);y.fillColor=lh(ot??y.fillColorSpaceName,V,f,y.fillColor);break}case st.setStrokeColorN:{let{key:nt,components:ot}=ah(K);y.strokeColor=lh(nt??y.strokeColorSpaceName,ot,f,y.strokeColor);break}case st.setGState:{let nt=!1,ot=!1,V=null;for(let[j,U]of K[0]??[])j==="BM"&&U==="multiply"&&(nt=!0),j==="ca"&&typeof U=="number"&&(U<1&&(ot=!0),V=U);if(nt&&ot&&q.length>0){let j=q[q.length-1];j.candidate&&!j.suppressing&&(j.suppressing=!0)}dt!=null&&V!=null&&V<(dt.alpha??1)&&(dt.alpha=V);for(let[j,U]of K[0]??[])if(j==="SMask"&&(U===!0?Q=!0:(U===!1||U==null)&&(Q=!1)),j==="ca"&&typeof U=="number")y.fillAlpha=U;else if(j==="CA"&&typeof U=="number")y.strokeAlpha=U;else if(j==="LW"&&typeof U=="number")y.lineWidth=U;else if(j==="LC"&&typeof U=="number")y.lineCap=U;else if(j==="D"&&Array.isArray(U))y.lineDash=Array.isArray(U[0])?U[0].slice():[];else if(j==="BM"){if(typeof U=="string"&&U!=="")y.blendMode=U;else if(Array.isArray(U)){for(let lt of U)if(typeof lt=="string"&&lt!==""){y.blendMode=lt;break}}}break}case st.constructPath:S={ops:K[0],coords:K[1],minMax:K[2]};break;case st.clip:k="nonzero";break;case st.eoClip:k="evenodd";break;case st.fill:case st.eoFill:case st.stroke:case st.closeStroke:case st.fillStroke:case st.eoFillStroke:case st.closeFillStroke:case st.closeEOFillStroke:case st.endPath:{if(k&&S!=null&&(T=th(T,S,k,y.ctm),k=null),S==null)break;let nt=rx(at);if(nt){if(y.textClipActive){rs(r,y.ctm,t,`vector ${nt}`),S=null;break}if(W>0&&et!=null&&(et.abort=!0,et.abortReason="contains vector paint operations (only single-paint image or shading masks are supported)"),W>0||bt()){S=null;break}if(nt.fill&&y.fillPattern){let V=fx(S);if(V){let j=px(y.ctm,V),U={kind:"image",_placeholderIndex:u.length};u.push(U),D.push({placeholder:U,pattern:y.fillPattern,placementCtm:j,opacity:it(),blendMode:yt(),clips:ss(T)?null:Sn(T,t)})}S=null;break}let ot=ch(S,nt,y,t);if(ot){ot.blendMode=yt();let V=it();V!=null&&V<1&&(ot.opacity=V),ih(ot,T,t),u.push(ot)}}S=null;break}case st.paintImageXObject:{if(W>0&&et!=null&&(et.captured!=null?(et.abort=!0,et.abortReason="contains multiple paint operations; only single-paint masks are supported"):et.captured={kind:"image",objId:K[0],ctm:y.ctm.slice()}),W>0||bt())break;if(dt!=null){dt.target?.kind==="image"?(dt.target=null,dt.aborted=!0):!dt.aborted&&(dt.target==null||dt.target.kind==="solid")&&(dt.target={kind:"image",objId:K[0],ctm:y.ctm.slice()});break}if(y.textClipActive){rs(r,y.ctm,t,`image objId="${K[0]}"`);break}let nt={kind:"image",_placeholderIndex:u.length};u.push(nt),I.push({placeholder:nt,objId:K[0],inline:null,ctm:y.ctm.slice(),opacity:it(),blendMode:yt(),clips:ss(T)?null:Sn(T,t)});break}case st.paintInlineImageXObject:{if(W>0&&et!=null&&(et.abort=!0,et.abortReason="contains an inline image (only image-xobject masks are supported)"),W>0||bt())break;if(y.textClipActive){rs(r,y.ctm,t,"inline image");break}let nt={kind:"image",_placeholderIndex:u.length};u.push(nt),I.push({placeholder:nt,objId:null,inline:K[0],ctm:y.ctm.slice(),opacity:it(),blendMode:yt(),clips:ss(T)?null:Sn(T,t)});break}case st.paintImageMaskXObject:{if(W>0&&et!=null&&(et.abort=!0,et.abortReason="contains a paintImageMaskXObject (only single-paint image or shading masks are supported)"),W>0||bt())break;let ot=(K[0]??{}).data;if(y.textClipActive){rs(r,y.ctm,t,`image mask objId="${ot}"`);break}if(y.fillColor==null){let j=r.pageIndex!=null?`Page ${r.pageIndex}: `:"";r.logger?.emit?.("IMAGE_MASK_NO_FILL_COLOR",{prefix:j,objId:ot??null,page:r.pageIndex});break}let V={kind:"image",_placeholderIndex:u.length};u.push(V),I.push({placeholder:V,objId:ot,inline:null,stencilFill:y.fillColor,ctm:y.ctm.slice(),opacity:it(),blendMode:yt(),clips:ss(T)?null:Sn(T,t)});break}case st.paintSolidColorImageMask:{if(W>0&&et!=null&&(et.abort=!0,et.abortReason="contains a paintSolidColorImageMask (only single-paint image or shading masks are supported)"),W>0||bt())break;if(y.textClipActive){rs(r,y.ctm,t,"solid-colour image mask");break}if(y.fillColor==null){let V=r.pageIndex!=null?`Page ${r.pageIndex}: `:"";r.logger?.emit?.("IMAGE_MASK_NO_FILL_COLOR",{prefix:V,objId:null,page:r.pageIndex});break}let nt={ops:[st.rectangle],coords:[0,0,1,1]},ot=ch(nt,{fill:!0,stroke:!1,fillRule:"nonzero"},y,t);if(ot){ot.blendMode=yt();let V=it();V!=null&&V<1&&(ot.opacity=V),ih(ot,T,t),u.push(ot)}break}case st.paintImageMaskXObjectGroup:{if(W>0&&et!=null&&(et.abort=!0,et.abortReason="contains a paintImageMaskXObjectGroup (only single-paint image or shading masks are supported)"),W>0||bt())break;let nt=r.pageIndex!=null?`Page ${r.pageIndex}: `:"",ot=Array.isArray(K[0])?K[0].length:0;r.logger?.emit?.("IMAGE_MASK_GROUP_UNSUPPORTED",{prefix:nt,count:ot,page:r.pageIndex});break}case st.paintImageMaskXObjectRepeat:{if(W>0&&et!=null&&(et.abort=!0,et.abortReason="contains a paintImageMaskXObjectRepeat (only single-paint image or shading masks are supported)"),W>0||bt())break;let nt=r.pageIndex!=null?`Page ${r.pageIndex}: `:"",ot=K[5],V=Array.isArray(ot)?Math.floor(ot.length/2):0;r.logger?.emit?.("IMAGE_MASK_REPEAT_UNSUPPORTED",{prefix:nt,count:V,page:r.pageIndex});break}case st.shadingFill:{if(W>0&&et!=null&&(et.captured!=null?(et.abort=!0,et.abortReason="contains a shading fill plus another paint (only single-paint masks are supported)"):et.captured={kind:"shading",patternId:K?.[0],ctm:y.ctm.slice()}),W>0||bt())break;if(y.textClipActive){rs(r,y.ctm,t,"shading fill");break}let nt={kind:"vector-path",_placeholderIndex:u.length};u.push(nt);let ot=T.length>0?T[T.length-1]:null,V=T.length>1?T.slice(0,-1):[];O.push({placeholder:nt,patternId:K?.[0],ctm:y.ctm.slice(),clipEntry:ot??null,remainingClips:V,opacity:it(),blendMode:yt()});break}case st.beginText:y.textMatrix=vi.slice(),y.textLineMatrix=vi.slice();break;case st.endText:kt();break;case st.setFont:y.fontObjId=K[0],y.fontSize=K[1];break;case st.setTextMatrix:y.textMatrix=[K[0],K[1],K[2],K[3],K[4],K[5]],y.textLineMatrix=y.textMatrix.slice();break;case st.moveText:{y.textLineMatrix=Ve(y.textLineMatrix,[1,0,0,1,K[0],K[1]]),y.textMatrix=y.textLineMatrix.slice();break}case st.setLeadingMoveText:{y.textLeading=-K[1],y.textLineMatrix=Ve(y.textLineMatrix,[1,0,0,1,K[0],K[1]]),y.textMatrix=y.textLineMatrix.slice();break}case st.nextLine:{y.textLineMatrix=Ve(y.textLineMatrix,[1,0,0,1,0,-y.textLeading]),y.textMatrix=y.textLineMatrix.slice();break}case st.setLeading:y.textLeading=K[0];break;case st.setCharSpacing:y.charSpacing=K[0];break;case st.setWordSpacing:y.wordSpacing=K[0];break;case st.setHScale:y.textHScale=K[0]/100;break;case st.setTextRise:y.textRise=K[0];break;case st.setTextRenderingMode:y.textRenderingMode=K[0]??0;break;case st.showText:case st.nextLineShowText:case st.nextLineSetSpacingShowText:case st.showSpacedText:{let nt=(at===st.showText||at===st.nextLineShowText,K[0]);if(y.textRenderingMode===7&&(y.textClipActive=!0),!_){let V={_placeholder:!0};u.push(V),_={placeholder:V,ctm:y.ctm.slice(),fillColor:y.fillColor,fillAlpha:y.fillAlpha,fontObjIdFirst:y.fontObjId,textString:"",glyphs:[]}}let ot=(()=>{let V=Ve(y.ctm,y.textMatrix),j={fontObjId:y.fontObjId??"",baselineX:V[4],baselineY:V[5],fill:xi(y.fillColor,it()),text:"",placeholder:_.placeholder,renderMode:y.textRenderingMode};return g.push(j),j})();for(let V of nt){if(typeof V=="number"){let gt=-V*.001*y.fontSize*y.textHScale;y.textMatrix[4]+=gt*y.textMatrix[0],y.textMatrix[5]+=gt*y.textMatrix[1];continue}_.textString+=V.unicode??"",ot.text+=V.unicode??"",V.isInFont!==!1&&_.glyphs.push({operatorListId:V.operatorListId,fontChar:V.fontChar,unicode:V.unicode,fontObjId:y.fontObjId??"",fontSize:y.fontSize,textMatrix:y.textMatrix.slice()});let U=(y.fontObjId!=null?n[y.fontObjId]:null)?.fontMatrix?.[0]??.001,Ct=((V.width??0)*U*y.fontSize+y.charSpacing+(V.isSpace?y.wordSpacing:0))*y.textHScale;y.textMatrix[4]+=Ct*y.textMatrix[0],y.textMatrix[5]+=Ct*y.textMatrix[1]}break}default:break}}kt();for(let X of I){let at=X.inline,K="ok";if(!at){let V=typeof X.objId=="string"&&X.objId.startsWith("g_"),j=typeof X.objId=="string"?X.objId:null,U=await(V?ns(e,j):Un(e,j));at=U.data,K=U.reason}if(!at){let V=r.pageIndex!=null?`Page ${r.pageIndex}: `:"",j=An(X.ctm,t.heightPt),U=X.objId?`objId="${X.objId}"`:"inline image";r.logger?.emit?.("IMAGE_PDFJS_UNRESOLVED",{prefix:V,idLabel:U,bboxX:jt(j.x),bboxY:jt(j.y),bboxW:jt(j.w),bboxH:jt(j.h),page:r.pageIndex,objId:X.objId??null,reason:K}),je(X.placeholder);continue}let nt=null;if(X.stencilFill){if(nt=await Nu(at,X.stencilFill,r.logger,{objId:typeof X.objId=="string"?X.objId:null,pageIndex:r.pageIndex}),!nt){let V=r.pageIndex!=null?`Page ${r.pageIndex}: `:"",j=An(X.ctm,t.heightPt),U=X.stencilFill?.space??"unknown";r.logger?.emit?.("IMAGE_MASK_COMPOSITE_FAIL",{prefix:V,objId:X.objId??null,bboxX:jt(j.x),bboxY:jt(j.y),bboxW:jt(j.w),bboxH:jt(j.h),colourSpace:U,page:r.pageIndex}),je(X.placeholder);continue}}else if(X.compositeWith){if(nt=await _u(at,X.compositeWith,r.logger,{objId:typeof X.objId=="string"?X.objId:null,pageIndex:r.pageIndex}),!nt){let V=r.pageIndex!=null?`Page ${r.pageIndex}: `:"",j=An(X.ctm,t.heightPt),U=X.compositeWith?.space??"unknown",lt=at?.kind,Ct=lt!=null?`kind=${lt}`:"bitmap";r.logger?.log?.(`${V}a luminosity SMask at (${j.x.toFixed(2)} in, ${j.y.toFixed(2)} in) ${j.w.toFixed(2)}\xD7${j.h.toFixed(2)} in could not be composited (mask ${Ct}, fill colour space "${U}"). The shadow was dropped from the imported design.`,"warning"),je(X.placeholder);continue}}else if(X.compositeWithMask){let V=X.compositeWithMask.mask,j=null;if(V.kind==="image"){let lt=typeof V.objId=="string"?V.objId:null,gt=await(typeof lt=="string"&&lt.startsWith("g_")?ns(e,lt):Un(e,lt));gt.data!=null&&(j={kind:"image",obj:gt.data,ctm:V.ctm})}else{let lt=typeof V.patternId=="string"?V.patternId:null;if(lt!=null){let Ct=await Un(e,lt);Ct.data!=null&&(j={kind:"shading",ir:Ct.data,ctm:V.ctm})}}if(j==null){let lt=r.pageIndex!=null?`Page ${r.pageIndex}: `:"",Ct=An(X.ctm,t.heightPt);r.logger?.log?.(`${lt}a luminosity SMask at (${Ct.x.toFixed(2)} in, ${Ct.y.toFixed(2)} in) could not resolve its mask source (${V.kind}). The shadow was dropped from the imported design.`,"warning"),je(X.placeholder);continue}let U=await Bu({maskSource:j,imageObj:at,imageCtm:X.ctm,modulatedAlpha:X.compositeWithMask.modulatedAlpha,pageBox:t,logger:r.logger,pageIndex:r.pageIndex});if(!U){let lt=r.pageIndex!=null?`Page ${r.pageIndex}: `:"",Ct=An(X.ctm,t.heightPt);r.logger?.log?.(`${lt}a luminosity SMask at (${Ct.x.toFixed(2)} in, ${Ct.y.toFixed(2)} in) failed to rasterize (${V.kind} mask shape unsupported). The shadow was dropped from the imported design.`,"warning"),je(X.placeholder);continue}if(nt=await Gu(at,U),!nt){je(X.placeholder);continue}}else if(nt=await pi(at,r.logger,{objId:typeof X.objId=="string"?X.objId:null,ctm:X.ctm,pageIndex:r.pageIndex}),!nt){je(X.placeholder);continue}let ot=An(X.ctm,t.heightPt,{logger:r.logger,pageIndex:r.pageIndex,objId:X.objId});Object.assign(X.placeholder,{kind:"image",x:ot.x,y:ot.y,width:ot.w,height:ot.h,mimeType:"image/png",bytes:nt,opacity:X.opacity??1,...Math.abs(ot.rotation)>1e-6?{rotation:ot.rotation}:{},...ot.flipHorizontal?{flipHorizontal:!0}:{},...ot.flipVertical?{flipVertical:!0}:{},...X.blendMode?{blendMode:X.blendMode}:{},...X.clips&&X.clips.length>0?{clips:X.clips}:{}})}for(let X of D){let at=await rh({page:e,pattern:X.pattern,logger:r.logger,pageIndex:r.pageIndex});if(!at){je(X.placeholder);continue}let K=r.pageIndex!=null?`Page ${r.pageIndex}: `:"";r.logger?.emit?.("TILING_PATTERN_AS_IMAGE",{prefix:K,patternId:X.pattern.patternId,page:r.pageIndex});let nt=An(X.placementCtm,t.heightPt,{logger:r.logger,pageIndex:r.pageIndex,objId:X.pattern.patternId});Object.assign(X.placeholder,{kind:"image",x:nt.x,y:nt.y,width:nt.w,height:nt.h,mimeType:"image/png",bytes:at.bytes,opacity:X.opacity??1,...Math.abs(nt.rotation)>1e-6?{rotation:nt.rotation}:{},...nt.flipHorizontal?{flipHorizontal:!0}:{},...nt.flipVertical?{flipVertical:!0}:{},...X.blendMode?{blendMode:X.blendMode}:{},...X.clips&&X.clips.length>0?{clips:X.clips}:{}})}for(let X of O){let at=r.pageIndex!=null?`Page ${r.pageIndex}: `:"";if(typeof X.patternId!="string"){r.logger?.emit?.("SHADING_NO_PATTERN_REF",{prefix:at,page:r.pageIndex}),je(X.placeholder);continue}let K=(await Un(e,X.patternId)).data,nt=sh({shadingIR:K,ctm:X.ctm,clipEntry:X.clipEntry,remainingClips:X.remainingClips,pageBox:t,opacity:X.opacity,blendMode:X.blendMode,logger:r.logger,pageIndex:r.pageIndex});if(!nt){je(X.placeholder);continue}Object.assign(X.placeholder,nt)}return{out:u,colorSnapshots:g}}function tx(i){let t=[];for(let e of i)if(!e._removed){if(e._placeholder){Array.isArray(e._replacements)&&t.push(...e._replacements);continue}t.push(e)}return t}function ex(i,t,e,n){let r=n?.textMode??"outline",a=[];if(i.placeholder._replacements=a,r==="outline"){let f=tl(i,i.glyphs,t,e);f&&a.push(f);return}let l=Qu(i.glyphs,t,i.ctm,e.heightPt),u=[];i.placeholder._lazyGlyphOutlines=u;for(let f of l){let g=t[f.fontObjId];if(zu(g,f.glyphs)){let y=f;u.push(()=>{let v=tl(i,y.glyphs,t,e);return!v||v.kind!=="text-outline"?null:{d:v.d,x:v.x,y:v.y,width:v.width,height:v.height}});continue}if(r==="editable"){let y=g?.name??f.fontObjId;throw new Error(`textMode 'editable': embeddability gate failed for font ${y} (text: ${JSON.stringify(f.text)})`)}let m=tl(i,f.glyphs,t,e);m&&a.push(m)}}function tl(i,t,e,n){if(!t||t.length===0)return null;let r=[],a=[],l=0,u=0,f="";for(let dt of t){let Y=e[dt.fontObjId];if(!Y)continue;let Z=Y.fontMatrix??[.001,0,0,.001,0,0],yt=[dt.fontSize,0,0,dt.fontSize,0,0],it=Ve(yt,Z);it=Ve(dt.textMatrix,it),it=Ve(i.ctm,it);let kt=null;if(Y.isType3Font?kt=nx(Y,dt.operatorListId):Y._parsed&&(kt=sx(Y,dt)),kt){let at=fh(kt,it,n.heightPt);r.push(...at.cmds),a.push(...at.devPoints)}let X=Ve(i.ctm,Ve(dt.textMatrix,yt));l+=Math.hypot(X[2],X[3]),u+=1,f+=dt.unicode??""}let g=u>0?l/u:0,m=1/0,y=1/0,v=-1/0,S=-1/0;for(let[dt,Y]of a)dt<m&&(m=dt),Y<y&&(y=Y),dt>v&&(v=dt),Y>S&&(S=Y);Number.isFinite(m)||(m=y=v=S=0);let T=e[t[0].fontObjId],{style:C,weight:k}=Xu(T),I=Bs(T?.name??""),O=I.family||I.fullName,D=Ve(i.ctm,t[0].textMatrix),_=D[4],M=n.heightPt-D[5],B=-Math.atan2(D[1],D[0]),H=Math.cos(-B),z=Math.sin(-B),W=1/0,Q=1/0,q=-1/0,bt=-1/0;for(let[dt,Y]of a){let Z=dt*H-Y*z,yt=dt*z+Y*H;Z<W&&(W=Z),yt<Q&&(Q=yt),Z>q&&(q=Z),yt>bt&&(bt=yt)}let et=Number.isFinite(W)?Math.max(0,q-W):0,Tt=Number.isFinite(Q)?Math.max(0,bt-Q):0;return{kind:"text-outline",x:m,y,width:Math.max(0,v-m),height:Math.max(0,S-y),d:ph(r,m,y),text:f,fontFamily:O,fontSize:g,fontStyle:C,fontWeight:k,fill:xi(i.fillColor,i.fillAlpha),opacity:i.fillAlpha!=null&&i.fillAlpha<1?i.fillAlpha:1,textOriginX:_,textOriginY:M,rotation:B,unrotWidth:et,unrotHeight:Tt}}function nx(i,t){let e=i?.charProcOperatorList?.[t];if(!e)return null;let n=e.fnArray,r=e.argsArray,a={ops:[],coords:[]};for(let l=0;l<n.length;l++)if(n[l]===st.constructPath){let u=r[l];a.ops.push(...u[0]),a.coords.push(...u[1])}return a.ops.length===0?null:a}function sx(i,t){let e=i._parsed;if(!e)return null;let n=null,r=e.encoding,a=m=>{if(m==null)return-1;let y=r?.cmap?.glyphIndexMap?.[m];if(typeof y=="number")return y;try{let v=r?.charToGlyphIndex?.(m);return typeof v=="number"?v:-1}catch{return-1}},l=t.fontChar?t.fontChar.codePointAt(0):null,u=a(l);if(u>0&&(n=e.glyphs.get(u)),!n)try{t.fontChar&&(n=e.charToGlyph(t.fontChar))}catch{}if((!n||n.index===0)&&t.unicode)try{let m=e.charToGlyph(t.unicode);m&&m.index>0&&(n=m)}catch{}if(!n||!n.path||n.index===0)return null;let f=[],g=[];for(let m of n.path.commands)switch(m.type){case"M":f.push(st.moveTo),g.push(m.x,m.y);break;case"L":f.push(st.lineTo),g.push(m.x,m.y);break;case"C":f.push(st.curveTo),g.push(m.x1,m.y1,m.x2,m.y2,m.x,m.y);break;case"Q":{f.push(st.curveTo),g.push(m.x1,m.y1,m.x1,m.y1,m.x,m.y);break}case"Z":f.push(st.closePath);break;default:break}return f.length===0?null:{ops:f,coords:g}}function je(i){i._removed=!0}function ih(i,t,e){if(ss(t))return;let n=Sn(t,e);n.length>0&&(i.clips=n)}function oh(i){return{space:"rgb",values:[i[0]/255,i[1]/255,i[2]/255]}}function ah(i){if(!Array.isArray(i)||i.length===0)return{key:null,components:[]};let t=i[i.length-1];return typeof t=="string"||t===null?{key:typeof t=="string"?t:null,components:i.slice(0,-1)}:{key:null,components:i}}function lh(i,t,e,n){if(i==null)return n;switch(i){case"DeviceGray":return{space:"gray",values:[t?.[0]??0]};case"DeviceRGB":return{space:"rgb",values:[t?.[0]??0,t?.[1]??0,t?.[2]??0]};case"DeviceCMYK":return{space:"cmyk",values:[t?.[0]??0,t?.[1]??0,t?.[2]??0,t?.[3]??0]}}let r=e[i];if(!r)return n;if(r.kind==="separation"){let a=t?.[0]??1,l=Array.isArray(r.solid)?r.solid:[],u=l.map(f=>f*a);return{space:"spot",name:r.name,tint:a,alternateSpace:r.alternateSpace,solid:l,values:u}}if(r.kind==="deviceN"){let a=Array.isArray(r.solid)?r.solid:[];return r.alternateSpace==="DeviceCMYK"?{space:"cmyk",values:a.slice(0,4)}:r.alternateSpace==="DeviceGray"?{space:"gray",values:a.slice(0,1)}:{space:"rgb",values:a.slice(0,3)}}return n}function rx(i){switch(i){case st.fill:return{fill:!0,stroke:!1,fillRule:"nonzero"};case st.eoFill:return{fill:!0,stroke:!1,fillRule:"evenodd"};case st.stroke:case st.closeStroke:return{fill:!1,stroke:!0,fillRule:"nonzero"};case st.fillStroke:case st.closeFillStroke:return{fill:!0,stroke:!0,fillRule:"nonzero"};case st.eoFillStroke:case st.closeEOFillStroke:return{fill:!0,stroke:!0,fillRule:"evenodd"};default:return null}}function ch(i,t,e,n){let r=ax(i,e.ctm,n.heightPt);if(!r)return null;let{devPoints:a,cmds:l}=r;if(a.length===0)return null;let u=1/0,f=1/0,g=-1/0,m=-1/0;for(let[H,z]of a)H<u&&(u=H),z<f&&(f=z),H>g&&(g=H),z>m&&(m=z);let y=g-u,v=m-f;if(y<=0&&v<=0)return null;let S=t.stroke?Math.abs(hh(e.ctm)*e.lineWidth):0,T=Math.abs(hh(e.ctm)),C=t.stroke&&e.lineDash.length>0?e.lineDash.map(H=>H*T):void 0,k=t.stroke?Zv[e.lineCap]:void 0,I=t.stroke&&y<=0?S:0,O=t.stroke&&v<=0?S:0,D=u-I/2,_=f-O/2,M=y+I,B=v+O;return{kind:"vector-path",x:D,y:_,width:M,height:B,d:ph(l,D,_),fill:t.fill?xi(e.fillColor,e.fillAlpha):null,stroke:t.stroke?xi(e.strokeColor,e.strokeAlpha):null,strokeWidth:S,strokeDashArray:C,strokeCap:k,fillRule:ix(t,l),opacity:1,blendMode:e.blendMode}}function ix(i,t){return i.fill?i.fillRule==="evenodd"?"evenodd":ox(t)?"nonzero":"evenodd":i.fillRule}function ox(i){let t=[],e=null;for(let a of i)if(a.cmd==="M"){e&&t.push(e);let l=a.pts?.[0];e=l?[l[0],l[1],l[0],l[1]]:null}else if(a.pts&&e)for(let[l,u]of a.pts)l<e[0]&&(e[0]=l),u<e[1]&&(e[1]=u),l>e[2]&&(e[2]=l),u>e[3]&&(e[3]=u);e&&t.push(e);let n=t.length;if(n<2||n>1e3)return!1;let r=(a,l)=>a[0]<=l[0]&&a[1]<=l[1]&&a[2]>=l[2]&&a[3]>=l[3];for(let a=0;a<n;a++)for(let l=a+1;l<n;l++){let u=t[a],f=t[l];if(!(u[2]<f[0]||f[2]<u[0]||u[3]<f[1]||f[3]<u[1])&&!(r(u,f)||r(f,u)))return!0}return!1}function ax(i,t,e){return fh(i,t,e)}function fh(i,t,e){let n=i.ops??[],r=i.coords??[],a=[],l=[],u=0,f=null,g=(m,y)=>{let[v,S,T,C,k,I]=t;return[v*m+T*y+k,e-(S*m+C*y+I)]};for(let m=0;m<n.length;m++)switch(n[m]){case st.rectangle:{let v=r[u++],S=r[u++],T=r[u++],C=r[u++],k=g(v,S),I=g(v+T,S),O=g(v+T,S+C),D=g(v,S+C);l.push({cmd:"M",pts:[k]}),l.push({cmd:"L",pts:[I]}),l.push({cmd:"L",pts:[O]}),l.push({cmd:"L",pts:[D]}),l.push({cmd:"Z"}),a.push(k,I,O,D);break}case st.moveTo:{let v=g(r[u++],r[u++]);l.push({cmd:"M",pts:[v]}),a.push(v),f=v;break}case st.lineTo:{let v=g(r[u++],r[u++]);l.push({cmd:"L",pts:[v]}),a.push(v),f=v;break}case st.curveTo:{let v=g(r[u++],r[u++]),S=g(r[u++],r[u++]),T=g(r[u++],r[u++]);l.push({cmd:"C",pts:[v,S,T]}),a.push(v,S,T),f=T;break}case st.curveTo2:{let v=g(r[u++],r[u++]),S=g(r[u++],r[u++]),T=f??v;l.push({cmd:"C",pts:[T,v,S]}),a.push(v,S),f=S;break}case st.curveTo3:{let v=g(r[u++],r[u++]),S=g(r[u++],r[u++]);l.push({cmd:"C",pts:[v,S,S]}),a.push(v,S),f=S;break}case st.closePath:l.push({cmd:"Z"});break;default:break}return{devPoints:a,cmds:l}}function ph(i,t,e){let n=a=>`${Math.round(a*100)/100}`,r=[];for(let a of i){if(a.cmd==="Z"){r.push("Z");continue}let l=(a.pts??[]).map(([u,f])=>`${n(u-t)} ${n(f-e)}`).join(" ");r.push(`${a.cmd} ${l}`)}return r.join(" ")}var lx=.01;function rs(i,t,e,n){let r=i?.pageIndex!=null?`Page ${i.pageIndex}: `:"",a=An(t,e.heightPt);i?.logger?.emit?.("TEXT_CLIP_MODE_7_DROPPED",{prefix:r,label:n,bbox:`${jt(a.x)}, ${jt(a.y)}`,bboxSize:`${jt(a.w)}\xD7${jt(a.h)}`,page:i?.pageIndex})}function An(i,t,e=null){let[n,r,a,l,u,f]=i,g=Math.hypot(n,r),m=Math.hypot(a,l);if(Math.abs(r)<1e-6&&Math.abs(a)<1e-6)return cx(i,t);let v=g>0&&m>0?(n*a+r*l)/(g*m):0;if(!(Math.abs(v)<lx)||!(g>0&&m>0))return ux(i,t,e,v);let S=u+(n+a)*.5,T=f+(r+l)*.5,C=Math.atan2(-r,n),k=n*l-r*a<0;return{x:S-g*.5,y:t-T-m*.5,w:g,h:m,rotation:C,flipHorizontal:!1,flipVertical:k}}function cx(i,t){let[e,n,r,a,l,u]=i,f=Math.hypot(e,n),g=Math.hypot(r,a),m=l+(e+r)*.5,y=u+(n+a)*.5;return{x:m-f*.5,y:t-y-g*.5,w:f,h:g,rotation:0,flipHorizontal:e<0,flipVertical:a<0}}function ux(i,t,e=null,n=null){let[r,a,l,u,f,g]=i,m=[f,f+r,f+l,f+r+l],y=[g,g+a,g+u,g+a+u],v=Math.min(...m),S=Math.max(...m),T=Math.min(...y),C=Math.max(...y),k={x:v,y:t-C,w:S-v,h:C-T,rotation:0,flipHorizontal:!1,flipVertical:!1};if(e?.logger?.emit){let I=e.pageIndex!=null?`Page ${e.pageIndex}: `:"",O=n!=null?`, residual=${jt(n)}`:"",D=e.objId?` objId="${e.objId}"`:"";e.logger.emit("IMAGE_SKEW_DROPPED",{prefix:I,idLabel:D,bboxX:jt(k.x),bboxY:jt(k.y),bboxW:jt(k.w),bboxH:jt(k.h),ctm:Ju(i),residualStr:O,page:e.pageIndex,objId:e.objId??null})}return k}function xi(i,t){return i==null?null:t==null||t===1?i:{...i,alpha:t}}function uh(i={x:0,y:0}){return{ctm:[1,0,0,1,-i.x,-i.y],fillColor:{space:"gray",values:[0]},strokeColor:{space:"gray",values:[0]},fillColorSpaceName:null,strokeColorSpaceName:null,fillPattern:null,fillAlpha:1,strokeAlpha:1,lineWidth:1,lineDash:[],lineCap:0,blendMode:null,textMatrix:vi.slice(),textLineMatrix:vi.slice(),fontObjId:null,fontSize:0,charSpacing:0,wordSpacing:0,textHScale:1,textRise:0,textLeading:0,textRenderingMode:0,textClipActive:!1}}function hx(i){return{ctm:i.ctm.slice(),fillColor:i.fillColor,strokeColor:i.strokeColor,fillColorSpaceName:i.fillColorSpaceName,strokeColorSpaceName:i.strokeColorSpaceName,fillPattern:i.fillPattern,fillAlpha:i.fillAlpha,strokeAlpha:i.strokeAlpha,lineWidth:i.lineWidth,lineDash:i.lineDash,lineCap:i.lineCap,blendMode:i.blendMode,textMatrix:i.textMatrix.slice(),textLineMatrix:i.textLineMatrix.slice(),fontObjId:i.fontObjId,fontSize:i.fontSize,charSpacing:i.charSpacing,wordSpacing:i.wordSpacing,textHScale:i.textHScale,textRise:i.textRise,textLeading:i.textLeading,textRenderingMode:i.textRenderingMode,textClipActive:i.textClipActive}}function hh([i,t,e,n]){return(Math.hypot(i,t)+Math.hypot(e,n))/2}function dx(i){if(!Array.isArray(i)||i.length<5||i[0]!=="TilingPattern")return null;let t=i[2];if(!t||!Array.isArray(t.fnArray)||!Array.isArray(t.argsArray))return null;let e=i[3]??[1,0,0,1,0,0],n=i[4]??[0,0,0,0],r="pattern";for(let a=0;a<t.fnArray.length;a++)if(t.fnArray[a]===st.paintImageXObject){let u=t.argsArray[a]?.[0];if(typeof u=="string"){r=`pattern[${u}]`;break}}return{patternId:r,operatorList:{fnArray:t.fnArray,argsArray:t.argsArray},matrix:e,bbox:n}}function fx(i){let t=i.coords??[];if(t.length<2)return null;let e=1/0,n=1/0,r=-1/0,a=-1/0;for(let l=0;l+1<t.length;l+=2){let u=t[l],f=t[l+1];u<e&&(e=u),f<n&&(n=f),u>r&&(r=u),f>a&&(a=f)}return!Number.isFinite(e)||!Number.isFinite(n)?null:{x:e,y:n,w:r-e,h:a-n}}function px(i,t){let[e,n,r,a,l,u]=i,f=t.y+t.h;return[e*t.w,n*t.w,-r*t.h,-a*t.h,e*t.x+r*f+l,n*t.x+a*f+u]}function Ve(i,t){let[e,n,r,a,l,u]=i,[f,g,m,y,v,S]=t;return[e*f+r*g,n*f+a*g,e*m+r*y,n*m+a*y,e*v+r*S+l,n*v+a*S+u]}function gx(i,t){return i.filter(e=>{if(e.kind!=="vector-path")return!0;let n=e.fill;return!(n&&"alpha"in n&&n.alpha===0&&!e.stroke||mx(e,t))})}function mx(i,t){if(i.kind!=="vector-path"||i.stroke||!i.fill||i.fill.space!=="rgb")return!1;let[e,n,r]=i.fill.values;if(!(e>=.98&&n>=.98&&r>=.98))return!1;let a=1;return Math.abs(i.x)<=a&&Math.abs(i.y)<=a&&Math.abs(i.width-t.widthPt)<=a&&Math.abs(i.height-t.heightPt)<=a?yx(i.d,i.x,i.y,i.width,i.height):!1}function yx(i,t,e,n,r){if(/[cqstaCQSTA]/.test(i))return!1;let a=bx(i);if(a.length===0)return!1;let l=.5,u=[[t,e],[t+n,e],[t+n,e+r],[t,e+r]];for(let[g,m]of a)if(!u.some(([v,S])=>Math.abs(g-v)<=l&&Math.abs(m-S)<=l))return!1;return u.filter(([g,m])=>a.some(([y,v])=>Math.abs(y-g)<=l&&Math.abs(v-m)<=l)).length>=3}function bx(i){let t=[],e=i.match(/[a-zA-Z]|-?\d*\.?\d+(?:[eE][+-]?\d+)?/g)??[],n="",r=0,a=0,l=0;for(;l<e.length;){let u=e[l];if(/[a-zA-Z]/.test(u)){if(n=u,l++,n==="Z"||n==="z")continue;continue}n==="M"||n==="L"?(r=parseFloat(e[l]),a=parseFloat(e[l+1]),t.push([r,a]),l+=2,n==="M"&&(n="L")):n==="m"||n==="l"?(r+=parseFloat(e[l]),a+=parseFloat(e[l+1]),t.push([r,a]),l+=2,n==="m"&&(n="l")):n==="H"?(r=parseFloat(e[l]),t.push([r,a]),l+=1):n==="h"?(r+=parseFloat(e[l]),t.push([r,a]),l+=1):n==="V"?(a=parseFloat(e[l]),t.push([r,a]),l+=1):(n==="v"&&(a+=parseFloat(e[l]),t.push([r,a])),l+=1)}return t}var vx=.05,xx=1.5,Si=1;async function mh(i,t){let e=await i.getTextContent({includeMarkedContent:!1,disableNormalization:!0}),n=[],r={cursor:0,consumed:new Set};for(let a of e.items){if(a.type||Px(a.str))continue;if(a.str&&a.str.length>0&&a.str.trim()===""){let m=t.pageBox.originShiftPt??{x:0,y:0};Ex({fontObjId:a.fontName,baselineX:a.transform[4]-m.x,baselineY:a.transform[5]-m.y,widthPt:a.width,str:a.str,dirSignX:a.transform[0]<0?-1:1},t.colorSnapshots,r);continue}if(!a.str)continue;let l=bh(i,a.fontName);if(!yi(l))continue;let u=e.styles?.[a.fontName],f=await Sx(a,l,u,t,r);if(!f||!f.run)continue;let g=f.placeholder;if(g&&Array.isArray(g._replacements)){let m=g._lazyGlyphOutlines;Array.isArray(m)&&m.length>0&&(f.run._buildGlyphOutline=m.shift()),g._replacements.push(f.run)}else n.push(f.run)}return n}async function Sx(i,t,e,n,r){let[a,l,u,f,g,m]=i.transform,y=Math.hypot(u,f);if(!(y>0))return null;let v=Math.atan2(l,a),S=n.pageBox.originShiftPt??{x:0,y:0},T=g-S.x,C=m-S.y,{ascentRatio:k,descentRatio:I}=Rx(e,t),O=y*k,D=y*I,_=i.width+y*vx,M=O+D,B=Math.cos(v),H=Math.sin(v),z=_/2,W=(O-D)/2,Q=T+z*B-W*H,q=C+z*H+W*B,bt=Q-z,et=n.pageBox.heightPt-q-M/2,Tt=M/2,dt=bt-Tt*H,Y=et+Tt*(1-B),Z=await Qa(t,n.logger);if(!Z)return null;n.docFonts.has(Z.postScriptName)||n.docFonts.set(Z.postScriptName,Z);let yt=Tx({fontObjId:i.fontName,baselineX:T,baselineY:C,widthPt:i.width,str:i.str,dirSignX:a<0?-1:1},n.colorSnapshots,r);if(yt==null)return null;let it=Z,kt=yt.walkerFontObjId;if(kt&&kt!==i.fontName&&n.page){let V=bh(n.page,kt);if(V&&yi(V)){let j=await Qa(V,n.logger);j&&(it=j,n.docFonts.has(j.postScriptName)||n.docFonts.set(j.postScriptName,j))}}if(yt.renderMode===3||yt.renderMode===7){let V=n.pageIndex!=null?` on page ${n.pageIndex}`:"",j=yt.renderMode===7?"7 (add to clipping path)":"3 (invisible)";return n.logger?.emit?.("TEXT_RENDER_MODE_SKIPPED",{pageTag:V,text:Ax(i.str,60),modeLabel:j,page:n.pageIndex,renderMode:yt.renderMode}),null}let{fill:X,colorSpans:at}=yt,K=X?.alpha,nt=K!=null&&K<1?K:1,ot={kind:"text-run",x:dt,y:Y,width:_,height:M,text:i.str,fontRef:it.postScriptName,family:it.family,...it.weight!=null?{fontWeight:it.weight}:{},...it.style?{fontStyle:it.style}:{},...it.width?{fontWidth:it.width}:{},fontSize:y,rotation:-v,fill:X,...at?{colorSpans:at}:{},baselineXPt:T,baselineYPt:C,advanceWidthPt:i.width};return ot.opacity=nt,{run:ot,placeholder:yt.placeholder??null}}function Ax(i,t){return typeof i!="string"?"":i.length>t?`${i.slice(0,t)}\u2026`:i}function Tx(i,t,e){let n=[],r=[],a=e.cursor,l=i.str.length,u=0;for(let T=e.cursor;T<t.length;T++){if(e.consumed.has(T)||!Ai(t[T])||!Ti(t[T],i))continue;let C=t[T].text?.length??0;if(u>=l)break;n.push(t[T]),r.push(T),u+=C,a=T+1}if(n.length===0)for(let T=0;T<t.length;T++){if(e.consumed.has(T)||!Ai(t[T])||!Ti(t[T],i))continue;let C=t[T].text?.length??0;if(u>=l)break;n.push(t[T]),r.push(T),u+=C}else e.cursor=a;if(n.length===0){for(let T=0;T<t.length;T++)if(e.consumed.has(T)&&Ai(t[T])&&Ti(t[T],i)&&kx(t[T].text,i.str))return null;return{fill:null,colorSpans:void 0,renderMode:0,placeholder:null,walkerFontObjId:null}}for(let T of r)e.consumed.add(T);let f=n[0].renderMode??0,g=n[0].placeholder??null,m=wx(n,i.str),y=n[0].fill??null;if(n.every(T=>yh(T.fill??null,y)))return{fill:y,colorSpans:void 0,renderMode:f,placeholder:g,walkerFontObjId:m};let S=Cx(i.str,n);return S.length===0?{fill:y,colorSpans:void 0,renderMode:f,placeholder:g,walkerFontObjId:m}:{fill:S[0].fill,colorSpans:S,renderMode:f,placeholder:g,walkerFontObjId:m}}function Cx(i,t){if(i.length===0||t.length===0)return[];let e="",n=[];for(let g=0;g<t.length;g++){let m=t[g].text??"";for(let y=0;y<m.length;y++)e+=m[y],n.push(g)}if(e.length===0)return[];let r=new Array(i.length),a=0,l=0,u=n[0];for(;a<i.length&&l<e.length;){let g=i[a],m=e[l];g===m?(r[a]=n[l],u=n[l],a++,l++):gh(m)?l++:gh(g)?(r[a]=u,a++):(r[a]=n[l],u=n[l],a++,l++)}for(;a<i.length;)r[a]=u,a++;let f=[];for(let g=0;g<i.length;g++){let m=t[r[g]]?.fill??null,y=f[f.length-1];y&&yh(y.fill,m)?y.to=g+1:f.push({from:g,to:g+1,fill:m})}return f}function gh(i){return i===" "||i===" "||i===`
16
+ `||i==="\r"||i==="\xA0"}function Ex(i,t,e){let n=[],r=e.cursor,a=i.str.length,l=0;for(let u=e.cursor;u<t.length;u++){if(e.consumed.has(u)||!Ai(t[u])||!Ti(t[u],i))continue;let f=t[u].text??"";if(f.length>a-l||f.length>0&&f.trim()!==""||(n.push(u),l+=f.length,r=u+1,l>=a))break}if(n.length!==0){e.cursor=r;for(let u of n)e.consumed.add(u)}}function wx(i,t){if(i.length===0)return null;let e=t.trim();if(i.length===1&&e.length>0&&i[0].text!=null&&i[0].text.trim().length===0)return null;if(i.length===1&&i[0].fontObjId)return i[0].fontObjId;if(e.length===0)return i[0].fontObjId||null;for(let n of i){if(!n.fontObjId||!n.text)continue;let r=n.text.replace(/^\s+/,"");if(r===e||r.startsWith(e)||e.startsWith(r)&&r.length>=2)return n.fontObjId}return null}function kx(i,t){if(!i)return!1;let e=i.trim(),n=t.trim();return e.length===0||n.length===0?!1:e.includes(n)||n.includes(e)}function Ai(i){if(!i)return!1;let t=i.fill;return t?(t.alpha??1)>0:!1}function yh(i,t){if(i==null&&t==null)return!0;if(i==null||t==null||i.space!==t.space||(i.alpha??1)!==(t.alpha??1)||!i.values||!t.values||i.values.length!==t.values.length)return!1;for(let e=0;e<i.values.length;e++)if(Math.abs(i.values[e]-t.values[e])>1e-6)return!1;return!0}function Ti(i,t){if(Math.abs(i.baselineY-t.baselineY)>xx)return!1;let e=Ix(i.text),n,r;return t.dirSignX<0?(n=t.baselineX-t.widthPt-Si,r=t.baselineX+Si+e):(n=t.baselineX-Si-e,r=t.baselineX+t.widthPt+Si),!(i.baselineX<n||i.baselineX>r)}function Ix(i){if(!i)return 0;let t=0;for(let e of i)if(e===" "||e===" "||e==="\xA0")t++;else break;return t*5}function Rx(i,t){if(Number.isFinite(i?.ascent)&&Number.isFinite(i?.descent))return{ascentRatio:i.ascent,descentRatio:Math.abs(i.descent)};let e=t?._parsed,n=e?.unitsPerEm,r=e?.tables?.hhea,a=r?.ascender,l=r?.descender;return typeof n=="number"&&Number.isFinite(n)&&n>0&&Number.isFinite(a)&&Number.isFinite(l)?{ascentRatio:a/n,descentRatio:Math.abs(l)/n}:{ascentRatio:.8,descentRatio:.2}}function bh(i,t){if(!t)return null;try{if(i.commonObjs.has(t))return i.commonObjs.get(t)}catch{}return null}function Px(i){for(let t of i){let e=t.codePointAt(0);if(e!=null&&(e>=57344&&e<=63743||e>=983040&&e<=1048573||e>=1048576&&e<=1114109))return!0}return!1}var el=require("node:fs"),nl=require("node:url"),sl=require("node:module");async function vh(){let i=new URL("./pdf.worker.mjs",__import_meta_url__);return(0,el.existsSync)(i)?(0,nl.fileURLToPath)(i):(0,sl.createRequire)(__import_meta_url__).resolve("@imgly/pdfjs-dist/legacy/build/pdf.worker.mjs")}async function xh(){let i=new URL("./standard_fonts/FoxitFixed.pfb",__import_meta_url__),t=new URL("./standard_fonts/",__import_meta_url__);if((0,el.existsSync)(i))return(0,nl.fileURLToPath)(t);let e=(0,sl.createRequire)(__import_meta_url__).resolve("@imgly/pdfjs-dist/standard_fonts/FoxitFixed.pfb");return e.slice(0,e.lastIndexOf("/")+1)}var rl=2;function Ox(i){let t=i?.imglyPatchVersion??null;if(t!==rl)throw new Error(`[@imgly/pdf-importer] @imgly/pdfjs-dist patch missing or outdated (got ${t??"none"}, expected ${rl}). The patched APIs (trimBox, bleedBox, colorSpaceResources, native CMYK args) are required for correct color and geometry import. Pin @imgly/pdfjs-dist to 4.10.38-imgly.${rl} or newer and reinstall.`)}async function Sh(i,t={}){let e=t.pdfjsModule??await Promise.resolve().then(()=>($a(),Lu));e.GlobalWorkerOptions.workerSrc=t.workerSrc??await vh();let n=t.standardFontDataUrl??await xh(),r=t.textMode??"outline",a=i instanceof Uint8Array?i:(()=>{let m=i;return new Uint8Array(m.buffer??i,m.byteOffset??0,m.byteLength??m.length)})(),u=await e.getDocument({data:a,password:t.password,disableFontFace:!0,useSystemFonts:!1,isEvalSupported:!1,fontExtraProperties:!0,standardFontDataUrl:n}).promise,f=new Map,g=[];for(let m=1;m<=u.numPages;m++){let y=await u.getPage(m);m===1&&Ox(y),g.push(await Mx(y,{textMode:r,docFonts:f,logger:t.logger,pageIndex:m})),y.cleanup()}return await u.destroy(),{source:t.source??"unknown",pages:g,fonts:f}}async function Mx(i,t){let e=i.trimBox,n=i.bleedBox,r=i.view??[0,0,0,0],a=r[2]-r[0],l=r[3]-r[1],u={x:r[0],y:r[1]},f={widthPt:a,heightPt:l,originShiftPt:u},g=null,m={left:0,top:0,right:0,bottom:0},y=!1;e&&(g={xPt:e[0]-r[0],yPt:r[3]-e[3],widthPt:e[2]-e[0],heightPt:e[3]-e[1]},n&&(m={left:Math.max(0,e[0]-n[0]),bottom:Math.max(0,e[1]-n[1]),right:Math.max(0,n[2]-e[2]),top:Math.max(0,n[3]-e[3])},y=!0));let{colorSnapshots:v,finalize:S}=await dh(i,f,t),T=t.textMode==="outline"?[]:await mh(i,{pageBox:f,docFonts:t.docFonts,colorSnapshots:v,logger:t.logger,pageIndex:t.pageIndex,page:i}),C=S();T.length>0&&C.push(...T);let k=i.rotate??0;if(k!==0){let I=t.pageIndex!=null?`Page ${t.pageIndex}: `:"";t.logger?.emit?.("DOC_PAGE_ROTATION_DROPPED",{prefix:I,pageRotation:k,page:t.pageIndex})}return{widthPt:a,heightPt:l,rotation:k,trimPt:g,bleedPt:m,hasBleed:y,blocks:C}}var Ah=new WeakMap;function Th(i,t,e,n){let r=i.block;if(typeof r.setTypeface=="function"&&r.setTypeface(t,e),typeof r.setTextFontStyle=="function"&&n?.style)try{r.setTextFontStyle(t,n.style)}catch{}if(typeof r.setTextFontWeight=="function"&&n?.weight)try{r.setTextFontWeight(t,n.weight)}catch{}let a=n?.uri,l=i.editor;a&&typeof l?.getFontMetrics=="function"&&l.getFontMetrics(a).catch(()=>{})}function Ci(i,t){let e=Ah.get(i);e||(e=new Map,Ah.set(i,e));let n=e.get(t.postScriptName);if(n)return n;let r=i.editor.createBuffer(),a=t.data instanceof Uint8Array?t.data:new Uint8Array(t.data);i.editor.setBufferData(r,0,a);let l={name:t.postScriptName,fonts:[{uri:r,subFamily:t.family,weight:xn(t.weight),style:t.style??"normal"}]},u={uri:r,typeface:l};return e.set(t.postScriptName,u),u}function Ch(i,t,e){let{uri:n,typeface:r}=Ci(i,e);typeof i.block.setFont=="function"&&i.block.setFont(t,n,r)}var ne=Object.freeze({IMAGE:"image",VECTOR_PATH:"vector-path",TEXT_OUTLINE:"text-outline",TEXT_RUN:"text-run"}),Lx=72,Lt=i=>i/Lx;var Eh=Object.freeze({"source-over":null,normal:null,multiply:"Multiply",screen:"Screen",overlay:"Overlay",darken:"Darken",lighten:"Lighten","color-dodge":"ColorDodge","color-burn":"ColorBurn","hard-light":"HardLight","soft-light":"SoftLight",difference:"Difference",exclusion:"Exclusion",hue:"Hue",saturation:"Saturation",color:"Color",luminosity:"Luminosity"});function Ei(i,t){return i==null||i===""?null:Object.prototype.hasOwnProperty.call(Eh,i)?Eh[i]:(t?.emit?.("BLEND_MODE_UNSUPPORTED",{mode:i}),null)}var Fx=6;function Dx(i,t){return i.replace(/-?\d*\.?\d+(?:[eE][-+]?\d+)?/g,e=>{let r=(parseFloat(e)*t).toFixed(Fx).replace(/\.?0+$/,"");return r==="-0"||r===""?"0":r})}function is(i,t,e,n){let r=i.block.createShape("vector_path");i.block.setString(r,"vector_path/path",Dx(t,Lt(1)));try{i.block.setFloat(r,"vector_path/width",Lt(e)),i.block.setFloat(r,"vector_path/height",Lt(n))}catch{}return r}var ol=()=>({state:"unknown",warned:!1}),il="shape/vector_path/fillRule",_x="1.75.0",Nx=i=>i==="nonzero"?"NonZero":"EvenOdd";function Ux(i,t,e){if(e.state==="unknown"){let n=!1;try{n=i.block.findAllProperties(t).includes(il)}catch{n=!1}e.state=n?"supported":"unsupported"}return e.state==="supported"}function wh(i,t,e,n){if(!(e==null||e==="evenodd")){if(!Ux(i,t,n.support)){n.support.warned||(n.support.warned=!0,n.logger?.emit?.("VECTOR_PATH_FILL_RULE_UNSUPPORTED",{property:il,sinceVersion:_x}));return}try{i.block.setEnum(t,il,Nx(e))}catch{}}}var wi=Symbol("COMBINE_EMPTY_INTERSECTION");function ll(i,t,e){if(!Array.isArray(t)||t.length<2)return e?.logger?.emit?.("CLIP_COMBINE_TOO_FEW_INPUTS",{prefix:al(e),inputCount:t?.length??0,label:e?.label??null}),null;if(!i.block.isCombinable(t))return e?.logger?.emit?.("CLIP_COMBINE_NOT_COMBINABLE",{prefix:al(e),inputCount:t.length,label:e?.label??null}),null;try{return i.block.combine(t,"Intersection")}catch(n){let r=n&&typeof n=="object"&&"message"in n?String(n.message):String(n);return Bx(r)?wi:(e?.logger?.emit?.("CLIP_COMBINE_THREW",{prefix:al(e),inputCount:t.length,reason:r,label:e?.label??null}),null)}}function Bx(i){return typeof i=="string"&&i.includes("empty shape")}function al(i){return i?.label?`${i.label}: `:""}function Gs(i,t){for(let e of t)try{i.block.isValid?.(e)!==!1&&i.block.destroy(e)}catch{}}function Gx(){return{scaleRatio:1,translationX:0,translationY:0,rotation:0}}function kh(i){return i.scaleRatio===1&&i.translationX===0&&i.translationY===0&&i.rotation===0}function Ih(i,t){if(Hx(i,t))return Gx();let n=1/Math.max(t.width/i.width,t.height/i.height),r=i.x+i.width/2,a=i.y+i.height/2,l=t.x+t.width/2,u=t.y+t.height/2,f=t.width/2,g=t.height/2,m=f===0?0:(r-l)/f,y=g===0?0:(a-u)/g;return{scaleRatio:n,translationX:m,translationY:y,rotation:0}}function Rh(i,t){let e=Math.max(i.x,t.x),n=Math.max(i.y,t.y),r=Math.min(i.x+i.width,t.x+t.width),a=Math.min(i.y+i.height,t.y+t.height);return{x:e,y:n,width:r-e,height:a-n}}function Hx(i,t){return i.x===t.x&&i.y===t.y&&i.width===t.width&&i.height===t.height}function os(i,t,e,n){if(!e?.bytes||e.bytes.length===0)return n?.logger?.emit?.("IMAGE_NO_PIXELS",{}),!1;let r=i.block.createFill("image"),a=i.editor.createBuffer(),l=e.bytes instanceof Uint8Array?e.bytes:new Uint8Array(e.bytes);return i.editor.setBufferData(a,0,l),i.block.setString(r,"fill/image/imageFileURI",a),i.block.setFill(t,r),!0}function cl(i,t,e,n){if(!(!e?.flipHorizontal&&!e?.flipVertical))try{i.block.getGlobalBoundingBoxX(t),e.flipHorizontal&&i.block.flipCropHorizontal(t),e.flipVertical&&i.block.flipCropVertical(t)}catch{n?.logger?.emit?.("IMAGE_FLIP_UNSUPPORTED",{})}}var Hn=Symbol("EMITTED_DROPPED");function Fh(i,t,e,n,r){if(!t?.bytes||t.bytes.length===0)return r?.logger?.emit?.("IMAGE_CLIPPED_NO_BYTES",{prefix:Gn(r),bbox:Me(t),page:r?.pageIndex}),null;let a=e.filter(g=>Hs(g)),l=e.filter(g=>!Hs(g)&&!Lh(g,t)),u=e.filter(g=>!Hs(g)&&Lh(g,t));if(u.length===0)return r?.logger?.emit?.("IMAGE_CLIP_UNUSABLE",{prefix:Gn(r),bbox:Me(t),clipCount:e.length,degenerateCount:a.length,disjointCount:l.length,page:r?.pageIndex}),Hn;let f=jx(u,t);return f.length===1?_h(i,t,f[0],r):Xx(i,t,f,n,r)}function jx(i,t){let e=[],n=new Set;for(let r of i)Vx(r,t)||n.has(r.d)||(n.add(r.d),e.push(r));return e.length>0?e:[i[0]]}function Vx(i,t){if(!Wx(i.d))return!1;let e=.001;return i.x<=t.x+e&&i.y<=t.y+e&&i.x+i.width+e>=t.x+t.width&&i.y+i.height+e>=t.y+t.height}function Wx(i){if(typeof i!="string")return!1;let t=i.split(/\s+/),e=[],n=[],r=0;for(;r<t.length;){let u=t[r++];if(!(u==="Z"||u==="z")){if(u==="M"||u==="L"){let f=parseFloat(t[r++]),g=parseFloat(t[r++]);if(Number.isNaN(f)||Number.isNaN(g))return!1;e.push(f),n.push(g);continue}return!1}}if(e.length!==4&&e.length!==5)return!1;let a=.001,l=u=>{let f=[];for(let g of u)f.some(m=>Math.abs(m-g)<=a)||f.push(g);return f};return l(e).length===2&&l(n).length===2}function Dh(i,t,e,n,r){let a=e.filter(y=>Hs(y)),l=e.filter(y=>!Hs(y));if(l.length===0)return r?.logger?.emit?.("CLIP_DEGENERATE_FALLBACK",{prefix:Gn(r),bbox:Me(t),clipCount:e.length,degenerateCount:a.length,page:r?.pageIndex}),null;if(!t.fill)return r?.logger?.emit?.("CLIP_COMBINE_STROKE_ONLY",{prefix:Gn(r),bbox:Me(t),clipCount:e.length,page:r?.pageIndex}),null;let u=[];for(let y of l){let v=Uh(i,y);i.block.appendChild(n,v),u.push(v)}let f={x:t.x,y:t.y,width:t.width,height:t.height},g=t1(i,t.d,f,t.fill,t.opacity);i.block.appendChild(n,g);let m=ll(i,[g,...u],{logger:r?.logger,label:`${Gn(r)}vector path at ${Me(t)}`});return m===wi?(Gs(i,[g,...u]),Hn):m==null?(Gs(i,[g,...u]),null):($x(i,m,t),t.opacity!=null&&t.opacity!==1&&i.block.setOpacity(m,t.opacity),ul(i,m,t.blendMode,r?.logger),m)}function $x(i,t,e){let n=e.fill,r=n?.kind;if(r==="linearGradient"||r==="radialGradient"){zx(i,t,e);return}let a=i.block.createFill("color");i.block.setColor(a,"fill/color/value",hl(n)),i.block.setFill(t,a)}function zx(i,t,e){let n=e.fill,r=n.kind==="linearGradient"?"gradient/linear":"gradient/radial",a=i.block.createFill(r),l=(n.stops??[]).map(g=>({color:hl(g.color),stop:g.offset}));i.block.setGradientColorStops(a,"fill/gradient/colors",l);let u=e.width>0?e.width:1,f=e.height>0?e.height:1;if(n.kind==="linearGradient")i.block.setFloat(a,"fill/gradient/linear/startPointX",(n.start.x-e.x)/u),i.block.setFloat(a,"fill/gradient/linear/startPointY",(n.start.y-e.y)/f),i.block.setFloat(a,"fill/gradient/linear/endPointX",(n.end.x-e.x)/u),i.block.setFloat(a,"fill/gradient/linear/endPointY",(n.end.y-e.y)/f);else{let g=Math.max(.001,Math.min(u,f));i.block.setFloat(a,"fill/gradient/radial/centerPointX",(n.center.x-e.x)/u),i.block.setFloat(a,"fill/gradient/radial/centerPointY",(n.center.y-e.y)/f),i.block.setFloat(a,"fill/gradient/radial/radius",n.radius/g)}i.block.setFill(t,a)}function ul(i,t,e,n){let r=Ei(e,n);r!=null&&(typeof i.block.supportsBlendMode=="function"&&!i.block.supportsBlendMode(t)||i.block.setBlendMode(t,r))}function _h(i,t,e,n){let r=i.block.create("graphic"),a=n1(e,t),l=is(i,a,t.width,t.height);return i.block.setShape(r,l),os(i,r,t),Ii(i,r,t),t.rotation&&Math.abs(t.rotation)>1e-6&&i.block.setRotation(r,t.rotation),t.opacity!=null&&t.opacity!==1&&i.block.setOpacity(r,t.opacity),ul(i,r,t.blendMode,n?.logger),r}function Xx(i,t,e,n,r){if(t.rotation&&Math.abs(t.rotation)>1e-6){let g=Yx(i,t,e,n,r);if(g!==Nh)return g}let l=qx(i,t);i.block.appendChild(n,l);let u=[];for(let g of e){let m=Uh(i,g);i.block.appendChild(n,m),u.push(m)}let f=ll(i,[l,...u],{logger:r?.logger,label:`${Gn(r)}clipped image at ${Me(t)}`});return f===wi?(Gs(i,[l,...u]),Hn):f==null?(Gs(i,[l,...u]),null):(os(i,f,t),e1(i,f,t),t.opacity!=null&&t.opacity!==1&&i.block.setOpacity(f,t.opacity),ul(i,f,t.blendMode,r?.logger),f)}var Nh=Symbol("UNHANDLED");function Yx(i,t,e,n,r){let a=Kx(e);if(a==null)return Nh;if(a.points.length<3)return r?.logger?.emit?.("IMAGE_CLIP_EMPTY_INTERSECTION",{prefix:Gn(r),bbox:Me(t),clipCount:e.length,page:r?.pageIndex}),Hn;let l=Jx(a.points);return _h(i,t,l,r)}function Kx(i){if(i.length===0)return null;let t=Ph(i[0]);if(t==null)return null;for(let e=1;e<i.length;e++){let n=Ph(i[e]);if(n==null)return null;if(t=Zx(t,n),t.length===0)return{points:[]}}return{points:t}}function Ph(i){let t=i.d.split(/\s+/),e=[],n=0;for(;n<t.length;){let r=t[n++];if(!(r==="Z"||r==="z")){if(r==="M"||r==="L"){let a=parseFloat(t[n++]),l=parseFloat(t[n++]);if(Number.isNaN(a)||Number.isNaN(l))return null;let u=i.x+a,f=i.y+l,g=e[e.length-1];if(g&&Math.abs(g[0]-u)<1e-6&&Math.abs(g[1]-f)<1e-6)continue;e.push([u,f]);continue}return null}}return e}function Zx(i,t){if(t.length<3)return[];let e=Math.sign(Qx(t))||1,n=i.slice();for(let r=0;r<t.length&&n.length!==0;r++){let a=t[r],l=t[(r+1)%t.length],u=n;n=[];let f=u[u.length-1];for(let g of u){let m=Oh(g,a,l)*e>=-1e-9,y=Oh(f,a,l)*e>=-1e-9;m?(y||n.push(Mh(f,g,a,l)),n.push(g)):y&&n.push(Mh(f,g,a,l)),f=g}}return n}function Qx(i){let t=0;for(let e=0;e<i.length;e++){let[n,r]=i[e],[a,l]=i[(e+1)%i.length];t+=n*l-a*r}return t*.5}function Oh(i,t,e){return(e[0]-t[0])*(i[1]-t[1])-(e[1]-t[1])*(i[0]-t[0])}function Mh(i,t,e,n){let r=n[0]-e[0],a=n[1]-e[1],l=t[0]-i[0],u=t[1]-i[1],f=r*u-l*a;if(Math.abs(f)<1e-12)return t.slice();let g=(r*(e[1]-i[1])-a*(e[0]-i[0]))/f;return[i[0]+g*l,i[1]+g*u]}function Jx(i){let t=1/0,e=1/0,n=-1/0,r=-1/0;for(let[u,f]of i)u<t&&(t=u),f<e&&(e=f),u>n&&(n=u),f>r&&(r=f);let a=u=>`${Math.round(u*100)/100}`,l=[];for(let u=0;u<i.length;u++){let[f,g]=i[u];l.push(`${u===0?"M":"L"} ${a(f-t)} ${a(g-e)}`)}return l.push("Z"),{d:l.join(" "),x:t,y:e,width:n-t,height:r-e,fillRule:"nonzero"}}function qx(i,t){let e=i.block.create("graphic");return i.block.setShape(e,i.block.createShape("rect")),os(i,e,t),Ii(i,e,t),t.rotation&&Math.abs(t.rotation)>1e-6&&i.block.setRotation(e,t.rotation),e}function Uh(i,t){let e=i.block.create("graphic"),n=is(i,t.d,t.width,t.height);return i.block.setShape(e,n),i.block.setFill(e,Bh(i)),Ii(i,e,t),e}function t1(i,t,e,n,r){let a=i.block.create("graphic"),l=is(i,t,e.width,e.height);i.block.setShape(a,l);let u=n?.kind;if(n&&!(u==="linearGradient"||u==="radialGradient")){let g=i.block.createFill("color");i.block.setColor(g,"fill/color/value",hl(n)),i.block.setFill(a,g)}else i.block.setFill(a,Bh(i));return Ii(i,a,e),r!=null&&r!==1&&i.block.setOpacity(a,r),a}function Bh(i){let t=i.block.createFill("color");return i.block.setColor(t,"fill/color/value",{r:0,g:0,b:0,a:0}),t}function e1(i,t,e){let n={x:ki(i.block.getPositionX(t)),y:ki(i.block.getPositionY(t)),width:ki(i.block.getWidth(t)),height:ki(i.block.getHeight(t))},r={x:e.x,y:e.y,width:e.width,height:e.height},a=Ih(r,n);if(!kh(a))try{i.block.setContentFillMode(t,"Crop"),i.block.setCropScaleRatio(t,a.scaleRatio),i.block.setCropTranslationX(t,a.translationX),i.block.setCropTranslationY(t,a.translationY),a.rotation!==0&&i.block.setCropRotation(t,a.rotation)}catch{}}function Ii(i,t,e){i.block.setPositionX(t,Lt(e.x)),i.block.setPositionY(t,Lt(e.y)),i.block.setWidth(t,Lt(e.width)),i.block.setHeight(t,Lt(e.height))}function ki(i){return i*72}function n1(i,t){let e=t.rotation??0;if(Math.abs(e)<1e-6)return r1(i.d,i.x-t.x,i.y-t.y);let n=t.x+t.width*.5,r=t.y+t.height*.5,a=Math.cos(e),l=Math.sin(e),u=(f,g)=>{let m=f+i.x-n,y=g+i.y-r,v=a*m+l*y,S=-l*m+a*y;return[v+t.width*.5,S+t.height*.5]};return s1(i.d,u)}function s1(i,t){let e=l=>`${Math.round(l*100)/100}`,n=i.split(/\s+/),r=[],a=0;for(;a<n.length;){let l=n[a++];if(l==="Z"||l==="z"){r.push("Z");continue}if(l==="M"||l==="L"){let[u,f]=t(parseFloat(n[a++]),parseFloat(n[a++]));r.push(`${l} ${e(u)} ${e(f)}`);continue}if(l==="C"){let[u,f]=t(parseFloat(n[a++]),parseFloat(n[a++])),[g,m]=t(parseFloat(n[a++]),parseFloat(n[a++])),[y,v]=t(parseFloat(n[a++]),parseFloat(n[a++]));r.push(`C ${e(u)} ${e(f)} ${e(g)} ${e(m)} ${e(y)} ${e(v)}`);continue}r.push(l)}return r.join(" ")}function r1(i,t,e){let n=u=>`${Math.round(u*100)/100}`,r=i.split(/\s+/),a=[],l=0;for(;l<r.length;){let u=r[l++];if(u==="Z"||u==="z"){a.push("Z");continue}if(u==="M"||u==="L"){let f=parseFloat(r[l++]),g=parseFloat(r[l++]);a.push(`${u} ${n(f+t)} ${n(g+e)}`);continue}if(u==="C"){let f=parseFloat(r[l++]),g=parseFloat(r[l++]),m=parseFloat(r[l++]),y=parseFloat(r[l++]),v=parseFloat(r[l++]),S=parseFloat(r[l++]);a.push(`C ${n(f+t)} ${n(g+e)} ${n(m+t)} ${n(y+e)} ${n(v+t)} ${n(S+e)}`);continue}a.push(u)}return a.join(" ")}function Hs(i){return!(i.width>0&&i.height>0)}function Lh(i,t){let e=Rh({x:i.x,y:i.y,width:i.width,height:i.height},{x:t.x,y:t.y,width:t.width,height:t.height});return e.width>0&&e.height>0}function Gn(i){return i?.pageIndex!=null?`Page ${i.pageIndex}: `:""}function hl(i){if(!i)return{r:0,g:0,b:0,a:1};if(i.space==="rgb"){let[e,n,r]=i.values;return{r:e,g:n,b:r,a:1}}if(i.space==="gray"){let[e]=i.values;return{r:e,g:e,b:e,a:1}}if(i.space==="cmyk"){let[e,n,r,a]=i.values;return{c:e,m:n,y:r,k:a,tint:1}}let t=i;return t.space==="spot"?{name:t.name,tint:t.tint??1,externalReference:""}:{r:0,g:0,b:0,a:1}}async function Ri(i,t,e,n){let r=`${t.family}|${t.style??"normal"}|${t.weight??"normal"}`,a=e.get(r);if(a!==void 0)return a;let l=null;try{l=await i(t,n)}catch{l=null}return e.set(r,l),l}function Gh(i,t){if(i.substitutedFrom!=null)return!1;let n=(i.typeface?.name??"").toLowerCase().trim(),r=t.toLowerCase().trim();if(n===r)return!0;let a=l=>l.replace(/\s+/g,"");return a(n)===a(r)}var i1={name:"perfect-match-resolver",async resolve(i,t){if(!t.resolver)return{kind:"pass",reason:"no-resolver-configured"};if(!i.family)return{kind:"pass",reason:"no-font-family"};let e=await Ri(t.resolver,{family:i.family,style:i.style,weight:i.weight},t.resolverCache,t.engine);return e?Gh(e,i.family)?{kind:"typeface",typeface:e.typeface,font:e.font,provenance:"perfect-match",substitutedFrom:e.substitutedFrom}:{kind:"pass",reason:"not-perfect-match"}:{kind:"pass",reason:"resolver-miss"}}},as=i1;var o1={name:"embedded-subset",async resolve(i){return i.embeddedFont?{kind:"subset",embeddedFont:i.embeddedFont,provenance:"embedded-subset"}:{kind:"pass",reason:"no-embedded-font"}}},js=o1;var a1={name:"any-match-resolver",async resolve(i,t){if(!t.resolver)return{kind:"pass",reason:"no-resolver-configured"};if(!i.family)return{kind:"pass",reason:"no-font-family"};let e=await Ri(t.resolver,{family:i.family,style:i.style,weight:i.weight},t.resolverCache,t.engine);return e?{kind:"typeface",typeface:e.typeface,font:e.font,provenance:"any-match",substitutedFrom:e.substitutedFrom}:{kind:"pass",reason:"resolver-miss"}}},Vs=a1;var Hh="ly.img.pdf-importer.text";function dl(i,t,e,n){if(typeof i.block?.setMetadata!="function")return;let r=(l,u)=>{if(!(u==null||u===""))try{i.block.setMetadata(t,`${Hh}.${l}`,String(u))}catch{}};r("content",e.text),r("fontFamily",e.family);let a=e.source;"fontSize"in a&&typeof a.fontSize=="number"&&Number.isFinite(a.fontSize)&&r("fontSize",a.fontSize),r("fontStyle",e.style),r("fontWeight",e.weight),r("fallbackReason",n)}function jh(i,t){return t?i.family?"resolver-miss":"no-font-family":"resolver-disabled"}var ls={name:"default",async emit(i,t,e){if(t?.kind==="typeface"){let n=await e.helpers.resolveLayoutForSubstitution(i,t),r=e.helpers.createEditableText(i,n,(l,u)=>{Th(l,u,t.typeface,t.font)}),a=t.substitutedFrom!=null;return{blocks:[r],substituted:a,resolvedFamily:t.typeface.name}}if(t?.kind==="subset")return{blocks:[e.helpers.createEditableText(i,i.source,(r,a)=>{Ch(r,a,t.embeddedFont)})],substituted:!1,resolvedFamily:i.family};if(i.glyphPaths!=null||i.buildGlyphOutline!=null){let n=e.helpers.emitGlyphsAsVectorPath(i);if(n!=null){let r=jh(i,!0);return dl(e.engine,n,i,r),{blocks:[n],substituted:!1}}}return e.logger?.emit?.("TEXT_RUN_SKIPPED_NO_RESOLUTION",{fontFamily:i.family}),{blocks:[],substituted:!1}}};function fl(i,t){if(i.kind===ne.TEXT_RUN){let e=t.fonts?.get?.(i.fontRef);return e?{family:e.family,style:e.style??"normal",weight:e.weight!=null?l1(e.weight):"normal",text:i.text,embeddedFont:e,buildGlyphOutline:i._buildGlyphOutline,source:i}:null}return i.fontFamily?{family:i.fontFamily,style:i.fontStyle??"normal",weight:i.fontWeight??"normal",text:i.text,glyphPaths:i.d,source:i}:null}function l1(i){let t=Number(i)||400;return t<=150?"thin":t<=250?"extraLight":t<=350?"light":t<=450?"normal":t<=550?"medium":t<=650?"semiBold":t<=750?"bold":t<=850?"extraBold":"heavy"}function Ws(i){return{stages:i,async resolve(t,e){for(let n of i){let r=await n.resolve(t,e);if(r.kind!=="pass")return r}return null}}}function $s(i){return{cascade:i.cascade,emission:i.emission}}var pl=$s({cascade:Ws([as,js,Vs]),emission:ls}),Vh=$s({cascade:Ws([as,js]),emission:ls}),Wh=$s({cascade:Ws([as,Vs]),emission:ls}),jn=pl;function $h(i,t={}){let e=i(0);return e>1?c1(i):t.allowWiden===!1?{ls:0,lines:e,direction:"unchanged"}:u1(i)}function c1(i){let t=0,e=2;for(let n=0;n<15;n++){let r=Math.max(-.15,t-.01);if(r===t)break;if(t=r,e=i(t),e<=1)return{ls:t,lines:e,direction:"tightened"}}return{ls:t,lines:e,direction:"tightened"}}function u1(i){let t=0,e=1;for(let r=0;r<15;r++){let a=Math.min(.03,t+.01);if(a===t)break;let l=i(a);if(l>1)break;t=a,e=l}let n=Math.max(0,t-2*.01);return n!==t&&(e=i(n)),{ls:n,lines:e,direction:n>0?"widened":"unchanged"}}async function Yh(i,t,e={}){let n=i.scene.create("VerticalStack");i.scene.setDesignUnit("Inch");let r=i.block.findByType("stack")[0];i.block.setFloat(r,"stack/spacing",I1),i.block.setBool(r,"stack/spacingInScreenspace",R1);let a=[],l={fontResolver:e.fontResolver??null,fontStrategy:e.fontStrategy??jn,logger:e.logger??null,resolverCache:new Map,textRuns:a,substitutions:new Map,subsetFallbacks:new Set,vectorPathFillRuleSupport:ol(),irFonts:t.fonts},u=e.pageBounds??"trim";ad(i,t,l.logger);for(let f=0;f<t.pages.length;f++){let g=t.pages[f];l.pageIndex=f+1;let m=i.block.create("page");i.block.setWidth(m,Lt(g.widthPt)),i.block.setHeight(m,Lt(g.heightPt)),i.block.appendChild(r,m);for(let y of g.blocks){let v=await td(i,y,t,m,l);v!=null&&(i.block.appendChild(m,v),y.kind===ne.IMAGE&&cl(i,v,y,{logger:l.logger??void 0}))}qh(i,m,g,u)}return await Zh(i,a.map(({id:f})=>f)),id(i,a,l),Qh(l),Jh(l),n}async function Kh(i,t,e={}){let n=[],r={fontResolver:e.fontResolver??null,fontStrategy:e.fontStrategy??jn,logger:e.logger??null,resolverCache:new Map,textRuns:n,substitutions:new Map,subsetFallbacks:new Set,vectorPathFillRuleSupport:ol(),irFonts:t.fonts};ad(i,t,r.logger);let a=e.pageBounds??"media",l=e.pageIndex!=null?[e.pageIndex]:t.pages.map((f,g)=>g),u=[];for(let f of l){let g=t.pages[f];if(g==null)continue;r.pageIndex=f+1;let m=i.block.create("page");i.block.setWidth(m,Lt(g.widthPt)),i.block.setHeight(m,Lt(g.heightPt));for(let C of g.blocks){let k=await td(i,C,t,m,r);k!=null&&(i.block.appendChild(m,k),C.kind===ne.IMAGE&&cl(i,k,C,{logger:r.logger??void 0}),C.kind===ne.TEXT_RUN&&n.push({id:k,ir:C}))}if(qh(i,m,g,a),i.block.getChildren(m).length===0)continue;let v=h1(i,g);i.block.appendChild(m,v);let S=i.block.getChildren(m);if(S.length===1){i.block.destroy(v);continue}let T=i.block.group(S);i.block.destroy(v),u.push(T)}return await Zh(i,n.map(({id:f})=>f)),id(i,n,r),Qh(r),Jh(r),u}function h1(i,t){let e=i.block.create("graphic");i.block.setShape(e,i.block.createShape("rect")),i.block.setWidth(e,Lt(t.widthPt)),i.block.setHeight(e,Lt(t.heightPt)),i.block.setPositionX(e,0),i.block.setPositionY(e,0);let n=i.block.createFill("color");return i.block.setColor(n,"fill/color/value",{r:0,g:0,b:0,a:0}),i.block.setFill(e,n),i.block.setBool(e,"fill/enabled",!1),e}async function Zh(i,t,e=1e4){if(typeof i.block.getState!="function"||typeof i.block.onStateChanged!="function")return;let n=a=>{try{let l=i.block.getState(a);return l.type==="Ready"||l.type==="Error"}catch{return!0}},r=t.filter(a=>!n(a));r.length!==0&&await new Promise(a=>{let l=new Set(r),u=null,f=()=>{u?.(),clearTimeout(g),a()},g=setTimeout(f,e);u=i.block.onStateChanged(r,m=>{for(let y of m)n(y)&&l.delete(y);l.size===0&&f()});for(let m of r)n(m)&&l.delete(m);l.size===0&&f()})}function Qh(i){if(i.substitutions.size===0)return;let t=Array.from(i.substitutions.entries()).map(([n,r])=>`${n} \u2192 ${r}`).join(", "),e=i.substitutions.size;i.logger?.emit?.("FONT_SUBSTITUTIONS",{count:e,plural:e===1?"y":"ies",pairs:t})}function Jh(i){if(i.subsetFallbacks.size===0)return;let t=Array.from(i.subsetFallbacks).sort().join(", "),e=i.subsetFallbacks.size;i.logger?.emit?.("FONT_SUBSET_FALLBACK",{count:e,plural:e===1?"y":"ies",families:t})}function qh(i,t,e,n){if(n==="media"||!e.trimPt)return;let{xPt:r,yPt:a,widthPt:l,heightPt:u}=e.trimPt,f=Lt(r),g=Lt(a);if(f!==0||g!==0)for(let m of i.block.getChildren(t))i.block.setPositionX(m,i.block.getPositionX(m)-f),i.block.setPositionY(m,i.block.getPositionY(m)-g);i.block.setWidth(t,Lt(l)),i.block.setHeight(t,Lt(u)),e.hasBleed&&(i.block.setBool(t,"page/marginEnabled",!0),i.block.setFloat(t,"page/margin/top",Lt(e.bleedPt.top)),i.block.setFloat(t,"page/margin/bottom",Lt(e.bleedPt.bottom)),i.block.setFloat(t,"page/margin/left",Lt(e.bleedPt.left)),i.block.setFloat(t,"page/margin/right",Lt(e.bleedPt.right)))}async function td(i,t,e,n,r){switch(t.kind){case ne.IMAGE:return d1(i,t,n,r);case ne.VECTOR_PATH:return ed(i,t,n,r);case ne.TEXT_OUTLINE:case ne.TEXT_RUN:return await m1(i,t,e,r);default:return r?.logger?.emit?.("BLOCK_KIND_UNKNOWN",{kind:t.kind}),null}}function d1(i,t,e,n){if(t.clips?.length){let l=Fh(i,t,t.clips,e,{logger:n?.logger??void 0,pageIndex:n?.pageIndex});return l===Hn?null:l??(n?.logger?.emit?.("IMAGE_CLIP_COMBINE_FAILED",{prefix:gl(n),bbox:Me(t),clipCount:t.clips.length,page:n?.pageIndex}),null)}let r=i.block.create("graphic"),a=i.block.createShape("rect");if(i.block.setShape(r,a),!os(i,r,t,{logger:n?.logger??void 0})){try{i.block.destroy(r)}catch{}return null}return od(i,r,t),t.rotation&&Math.abs(t.rotation)>1e-6&&i.block.setRotation(r,t.rotation),t.opacity!=null&&t.opacity!==1&&i.block.setOpacity(r,t.opacity),nd(i,r,t.blendMode,n),r}function f1(i){let t=i.block;return typeof t.setStrokeDashArray=="function"&&typeof t.setStrokeCap=="function"&&typeof t.setStrokeDashStartCap=="function"&&typeof t.setStrokeDashEndCap=="function"?t:null}function p1(i,t){if(!(i.x<=t.x+.5&&i.y<=t.y+.5&&i.x+i.width>=t.x+t.width-.5&&i.y+i.height>=t.y+t.height-.5)||/[CcQqSsTtAaHhVv]/.test(i.d))return!1;let r=i.x,a=i.y,l=i.x+i.width,u=i.y+i.height,f=.01,g=(y,v)=>(Math.abs(y-r)<f||Math.abs(y-l)<f)&&(Math.abs(v-a)<f||Math.abs(v-u)<f),m=i.d.match(/-?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!m||m.length<8)return!1;for(let y=0;y+1<m.length;y+=2)if(!g(parseFloat(m[y]),parseFloat(m[y+1])))return!1;return!0}function ed(i,t,e,n){let r=t.clips?.filter(u=>!p1(u,t));if(r?.length){let u=Dh(i,t,r,e,{logger:n?.logger??void 0,pageIndex:n?.pageIndex,vectorPathFillRuleSupport:n.vectorPathFillRuleSupport});if(u===Hn)return null;if(u!=null)return u;n?.logger?.emit?.("CLIP_COMBINE_FAILED",{prefix:gl(n),bbox:Me(t),clipCount:r.length,page:n?.pageIndex})}let a=i.block.create("graphic"),l=is(i,t.d,t.width,t.height);if(wh(i,l,t.fillRule,{logger:n?.logger??null,support:n.vectorPathFillRuleSupport}),i.block.setShape(a,l),t.fill){let u=t.fill.kind;if(u==="linearGradient"||u==="radialGradient")g1(i,a,t,n);else{let f=i.block.createFill("color");i.block.setColor(f,"fill/color/value",zs(t.fill,n,t,"vector path fill")),i.block.setFill(a,f)}}else i.block.setFillEnabled(a,!1);if(t.stroke){i.block.setStrokeEnabled(a,!0),i.block.setStrokeColor(a,zs(t.stroke,n,t,"vector path stroke")),t.strokeWidth!=null&&i.block.setStrokeWidth(a,Lt(t.strokeWidth));let u=f1(i);u!=null&&(t.strokeDashArray!=null&&t.strokeDashArray.length>0&&(u.setStrokeDashArray(a,t.strokeDashArray.map(f=>Lt(f))),t.strokeCap!=null&&(u.setStrokeDashStartCap(a,t.strokeCap),u.setStrokeDashEndCap(a,t.strokeCap))),t.strokeCap!=null&&u.setStrokeCap(a,t.strokeCap))}return od(i,a,t),t.opacity!=null&&t.opacity!==1&&i.block.setOpacity(a,t.opacity),nd(i,a,t.blendMode,n),a}function nd(i,t,e,n){let r=Ei(e,n?.logger??void 0);r!=null&&(typeof i.block.supportsBlendMode=="function"&&!i.block.supportsBlendMode(t)||i.block.setBlendMode(t,r))}function g1(i,t,e,n){let r=e.fill,a=r.kind==="linearGradient"?"gradient/linear":"gradient/radial",l=i.block.createFill(a),u=(r.stops??[]).map(m=>({color:zs(m.color,n,e,"vector path gradient stop"),stop:m.offset}));i.block.setGradientColorStops(l,"fill/gradient/colors",u);let f=e.width>0?e.width:1,g=e.height>0?e.height:1;if(r.kind==="linearGradient")i.block.setFloat(l,"fill/gradient/linear/startPointX",(r.start.x-e.x)/f),i.block.setFloat(l,"fill/gradient/linear/startPointY",(r.start.y-e.y)/g),i.block.setFloat(l,"fill/gradient/linear/endPointX",(r.end.x-e.x)/f),i.block.setFloat(l,"fill/gradient/linear/endPointY",(r.end.y-e.y)/g);else{let m=Math.max(.001,Math.min(f,g));i.block.setFloat(l,"fill/gradient/radial/centerPointX",(r.center.x-e.x)/f),i.block.setFloat(l,"fill/gradient/radial/centerPointY",(r.center.y-e.y)/g),i.block.setFloat(l,"fill/gradient/radial/radius",r.radius/m)}i.block.setFill(t,l)}async function m1(i,t,e,n){let r=fl(t,e);if(!r)return n.logger?.emit?.(t.kind===ne.TEXT_RUN?"FONT_REF_NOT_EXTRACTED":"TEXT_OUTLINE_NO_FONT_FAMILY",{fontRef:t.kind===ne.TEXT_RUN?t.fontRef:""}),null;let a=await n.fontStrategy.cascade.resolve(r,{engine:i,resolver:n.fontResolver,resolverCache:n.resolverCache,logger:n.logger}),l=y1(i,n),u=await n.fontStrategy.emission.emit(r,a,{engine:i,logger:n.logger,pageIndex:n.pageIndex,helpers:l});if(u.substituted&&a?.kind==="typeface"){let g=a.typeface.name??"?";n.substitutions.has(r.family)||n.substitutions.set(r.family,g)}if(a?.kind==="subset"&&n.subsetFallbacks.add(r.family),u.blocks.length===0)return null;let f=u.blocks[0];return n.textRuns&&(a?.kind==="typeface"||a?.kind==="subset")&&(t.kind===ne.TEXT_RUN?n.textRuns.push({id:f,ir:t}):n.textRuns.push({id:f,ir:{kind:ne.TEXT_RUN,x:t.x,y:t.y,width:t.width,height:t.height,text:t.text,fontRef:t.fontFamily,fontSize:t.fontSize,rotation:0,fill:t.fill}})),f}function y1(i,t){return{createEditableText(e,n,r){return v1(i,e.source,r,n,t)},emitGlyphsAsVectorPath(e){let n=null;if(e.glyphPaths){let l=e.source;n={d:e.glyphPaths,x:l.x,y:l.y,width:l.width,height:l.height}}else e.buildGlyphOutline&&(n=e.buildGlyphOutline());if(!n)return null;let r=e.source,a="opacity"in r&&typeof r.opacity=="number"?r.opacity:1;return ed(i,{kind:ne.VECTOR_PATH,x:n.x,y:n.y,width:n.width,height:n.height,d:n.d,fill:r.fill,stroke:null,strokeWidth:0,opacity:a},0,t)},async resolveLayoutForSubstitution(e,n){return e.source.kind!==ne.TEXT_OUTLINE||n.kind!=="typeface"?e.source:x1(i,e.source,{typeface:n.typeface,font:n.font},t)}}}async function b1(i,t,e,n){let r=t?.font?.uri,a=i.editor;if(!r||typeof a?.getFontMetrics!="function"||!n)return null;n.fontMetricsCache||(n.fontMetricsCache=new Map);let l=n.fontMetricsCache.get(r);if(l===void 0){try{l=await a.getFontMetrics(r)}catch{l=null}n.fontMetricsCache.set(r,l)}return!l||!l.unitsPerEm||l.ascender==null?null:l.ascender/l.unitsPerEm*e}function v1(i,t,e,n,r){let a=i.block.create("text");return S1(i,a,n),e(i,a),A1(i,a,t,r),t.rotation&&i.block.setRotation(a,t.rotation),a}async function x1(i,t,e,n){if(!(Math.abs(t.rotation??0)>1e-6)){if(!Number.isFinite(t.textOriginX)&&!Number.isFinite(t.textOriginY))return t;let T={};if(Number.isFinite(t.textOriginX)&&(T.x=t.textOriginX),Number.isFinite(t.textOriginY)){let C=await b1(i,e,t.fontSize,n);C!=null&&(T.y=(t.textOriginY??0)-C)}return{...t,...T}}let a=t.unrotWidth!=null&&Number.isFinite(t.unrotWidth)&&t.unrotWidth>0?t.unrotWidth:t.width,l=t.unrotHeight!=null&&Number.isFinite(t.unrotHeight)&&t.unrotHeight>0?t.unrotHeight:t.height,u=t.rotation??0,f=Math.sin(u),g=Math.cos(u),m=t.x+t.width/2,y=t.y+t.height/2,v=m-a/2+l/2*f,S=y-l/2*g;return{...t,x:v,y:S,width:a,height:l}}function S1(i,t,e){i.block.setPositionX(t,Lt(e.x)),i.block.setPositionY(t,Lt(e.y)),i.block.setWidth(t,Lt(e.width)),typeof i.block.setWidthMode=="function"&&i.block.setWidthMode(t,"Absolute"),typeof i.block.setHeightMode=="function"&&i.block.setHeightMode(t,"Auto")}function A1(i,t,e,n){typeof i.block.setTextFontSize=="function"?i.block.setTextFontSize(t,e.fontSize):i.block.setFloat(t,"text/fontSize",e.fontSize),typeof i.block.replaceText=="function"?i.block.replaceText(t,e.text):i.block.setString(t,"text/text",e.text),rd(i,t,e,n),sd(i,t,e,n);let r=e.opacity;r!=null&&r!==1&&i.block.setOpacity(t,r)}function T1(i){if(!i||i==="normal")return null;switch(i){case"ultraCondensed":return"Ultra Condensed";case"extraCondensed":return"Extra Condensed";case"condensed":return"Condensed";case"semiCondensed":return"Semi Condensed";case"semiExpanded":return"Semi Expanded";case"expanded":return"Expanded";case"extraExpanded":return"Extra Expanded";case"ultraExpanded":return"Ultra Expanded";default:return null}}function sd(i,t,e,n){let r=e.styleSpans;if(!Array.isArray(r)||r.length===0||!n.irFonts)return;let a=i.block;if(typeof a.setTypeface!="function"||typeof a.setTextFontWeight!="function"||typeof a.setTextFontStyle!="function")return;let l="";try{l=i.block.getString(t,"text/fontFileUri")}catch{}if(l.startsWith("https://")){for(let M of r){if(M.fontWeight!=null)try{a.setTextFontWeight(t,xn(M.fontWeight),M.from,M.to)}catch{}if(M.fontStyle)try{a.setTextFontStyle(t,M.fontStyle,M.from,M.to)}catch{}}return}let u=new Map;for(let M of r){if(!M.fontRef||u.has(M.fontRef))continue;let B=n.irFonts.get(M.fontRef);if(!B){n.logger?.emit?.("TEXT_STYLE_SPAN_FONT_MISSING",{fontRef:M.fontRef,text:(e.text??"").slice(0,40)});return}let H=Ci(i,B);u.set(M.fontRef,{fontRef:M.fontRef,ef:B,uri:H.uri})}if(u.size===0)return;let f=[...u.values()][0],g=f.ef.family??"PDF Imported Font",m=f.ef.width,y=new Map(u),v=new Set,S=M=>`${xn(M.weight)}|${M.style??"normal"}`;for(let M of u.values())v.add(S(M.ef));for(let[M,B]of n.irFonts){if(y.has(M)||B.family!==g||B.width!==m)continue;let H=S(B);if(v.has(H))continue;v.add(H);let z=Ci(i,B);y.set(M,{fontRef:M,ef:B,uri:z.uri})}let T=T1(m),k={name:T?`${g} ${T}`:g,fonts:[...y.values()].map(M=>({uri:M.uri,subFamily:M.ef.family,weight:xn(M.ef.weight),style:M.ef.style??"normal"}))},I=u,O=r[0],_=(O?.fontRef?I.get(O.fontRef):void 0)?.uri??[...I.values()][0].uri;try{typeof a.setFont=="function"?a.setFont(t,_,k):a.setTypeface(t,k)}catch{return}for(let M of r){if(M.fontWeight!=null)try{a.setTextFontWeight(t,xn(M.fontWeight),M.from,M.to)}catch{}if(M.fontStyle)try{a.setTextFontStyle(t,M.fontStyle,M.from,M.to)}catch{}}}function rd(i,t,e,n){let r=e.colorSpans;if(Array.isArray(r)&&r.length>0){if(typeof i.block.setTextColor=="function")for(let a of r){if(!a.fill)continue;let l=zs(a.fill,n,e,"text");i.block.setTextColor(t,l,a.from,a.to)}}else if(e.fill){let a=zs(e.fill,n,e,"text");if(typeof i.block.setTextColor=="function")i.block.setTextColor(t,a);else try{i.block.setColor(t,"fill/color/value",a)}catch{}}}var C1=!0,E1=1.05,zh=1.5,w1=9,k1=.7,I1=32,R1=!0;function id(i,t,e){if(C1&&typeof i.block.getTextVisibleLineCount=="function")for(let{id:n,ir:r}of t)P1(i,n,r,e)}function P1(i,t,e,n){let r=e.width;if(r<e.fontSize){let g=Math.max(1,e.text.length)*e.fontSize*k1;g>r&&(r=g,i.block.setWidth(t,Lt(r)))}let l=$h(g=>(i.block.setFloat(t,"text/letterSpacing",g),Xh(i,t,e,n)),{allowWiden:!1}).lines;if(l<=1)return;let u=Lt(r),f=1;for(let g=0;g<w1&&(f=Math.min(zh,f*E1),i.block.setWidth(t,u*f),l=Xh(i,t,e,n),!(l<=1||f>=zh));g++);l>1&&n?.logger?.emit?.("TEXT_OVERFLOW_AFTER_AUTOSIZE",{text:O1(e.text,30),overflowLines:l-1})}function Xh(i,t,e,n){typeof i.block.replaceText=="function"?i.block.replaceText(t,e.text):i.block.setString(t,"text/text",e.text),rd(i,t,e,n),sd(i,t,e,n);try{return i.block.getTextVisibleLineCount(t)}catch{return 1}}function O1(i,t){return i.length>t?i.slice(0,t-1)+"\u2026":i}function od(i,t,e){i.block.setPositionX(t,Lt(e.x)),i.block.setPositionY(t,Lt(e.y)),i.block.setWidth(t,Lt(e.width)),i.block.setHeight(t,Lt(e.height))}function ad(i,t,e){if(!i?.editor?.setSpotColorCMYK)return;let n=new Map,r=a=>{let l=a;!l||l.space!=="spot"||!l.name||n.has(l.name)||n.set(l.name,{alt:l.alternateSpace??"DeviceCMYK",solid:Array.isArray(l.solid)?l.solid:[]})};for(let a of t.pages??[])for(let l of a.blocks??[])r(l.fill),r(l.stroke);for(let[a,l]of n)try{if(l.alt==="DeviceCMYK"&&l.solid.length>=4){let[u,f,g,m]=l.solid;i.editor.setSpotColorCMYK(a,u,f,g,m)}else if(l.alt==="DeviceGray"&&l.solid.length>=1){let u=l.solid[0];i.editor.setSpotColorRGB(a,u,u,u)}else if(l.alt==="DeviceRGB"&&l.solid.length>=3){let[u,f,g]=l.solid;i.editor.setSpotColorRGB(a,u,f,g)}else e?.emit?.("SPOT_COLOR_NO_ALTERNATE",{name:a})}catch(u){let f=u&&typeof u=="object"&&"message"in u?String(u.message):String(u);e?.emit?.("SPOT_COLOR_REGISTER_FAILED",{name:a,error:f})}}function zs(i,t,e,n){if(!i)return{r:0,g:0,b:0,a:1};if(i.space==="rgb"){let[a,l,u]=i.values;return{r:a,g:l,b:u,a:1}}if(i.space==="gray"){let[a]=i.values;return{r:a,g:a,b:a,a:1}}if(i.space==="cmyk"){let[a,l,u,f]=i.values;return{c:a,m:l,y:u,k:f,tint:1}}let r=i;return r.space==="spot"?{name:r.name,tint:r.tint??1,externalReference:""}:(t?.logger?.emit?.("COLOR_SPACE_UNSUPPORTED",{prefix:gl(t),elementLabel:M1(n),space:r.space,color:qu(i),bbox:Me(e),page:t?.pageIndex,element:n??null}),{r:0,g:0,b:0,a:1})}function gl(i){return i?.pageIndex!=null?`Page ${i.pageIndex}: `:""}function M1(i){return i?`${i} `:""}function hd(i){let t=[],e=null,n=()=>{if(e){if(e.runs.length===1)t.push(e.runs[0]);else if(D1(e.runs))for(let r of e.runs)t.push(r);else t.push(G1(e.runs));e=null}};for(let r of i){if(r.kind!==ne.TEXT_RUN){n(),t.push(r);continue}let a=r;if(!e){e={runs:[a]};continue}let l=e.runs[e.runs.length-1];_1(l,a)?e.runs.push(a):(n(),e={runs:[a]})}return n(),t}var dd=.15,fd=.35,L1=.5,F1=.5;function D1(i){let t=new Map;for(let e of i){if(!e.family)continue;let n=`${e.family}|${e.fontWeight??""}|${e.fontStyle??""}|${e.fontWidth??""}`,r=t.get(n);if(r!==void 0&&r!==e.fontRef)return!0;r===void 0&&t.set(n,e.fontRef)}return!1}function _1(i,t){let e=!1;if(i.fontRef!==t.fontRef){if(!i.family||!t.family||i.family!==t.family||!i.fontWidth||!t.fontWidth||i.fontWidth!==t.fontWidth)return!1;e=!0}return Math.abs(i.fontSize-t.fontSize)>.5||Math.abs((i.rotation??0)-(t.rotation??0))>.001?!1:i.baselineXPt!=null&&i.baselineYPt!=null&&i.advanceWidthPt!=null&&t.baselineXPt!=null&&t.baselineYPt!=null?N1(i,t,e):U1(i,t,e)}function N1(i,t,e){let n=i.fontSize||10,r=i.rotation??0,a=Math.cos(r),l=Math.sin(r),u=i.baselineXPt,f=i.baselineYPt,g=i.advanceWidthPt,m=t.baselineXPt,y=t.baselineYPt,v=u+g*a,S=f+g*l,T=m-v,C=y-S,k=T*a+C*l,I=-T*l+C*a,O=(e?fd:dd)*n;return!(Math.abs(I)>L1*n||k<-F1*n||k>O)}function U1(i,t,e){let n=i.fontSize||10,r=i.rotation??0,a=Math.cos(r),l=Math.sin(r),u=t.x+t.width/2-(i.x+i.width/2),f=t.y+t.height/2-(i.y+i.height/2);if(Math.abs(u*-l+f*a)>.5*n)return!1;let m=Math.abs(u*a+f*l),y=(i.width+t.width)/2,v=e?fd*n:0;return!(m>y+v)}function B1(i,t){if(i.fontRef===t.fontRef||!i.family||!t.family||i.family!==t.family)return!1;let e=i.fontSize||10,n=dd*e;if(i.baselineXPt!=null&&i.advanceWidthPt!=null&&t.baselineXPt!=null){let l=i.rotation??0,u=Math.cos(l),f=Math.sin(l),g=i.baselineXPt+i.advanceWidthPt*u,m=(i.baselineYPt??0)+i.advanceWidthPt*f,y=t.baselineXPt-g,v=(t.baselineYPt??0)-m;return y*u+v*f>n}let r=Math.abs(t.x+t.width/2-(i.x+i.width/2)),a=(i.width+t.width)/2;return r-a>n}function ld(i){for(let t=1;t<i.length;t++){let e=i[t-1],n=i[t];n.from>e.to&&(e.to=n.from)}}function G1(i){let t=i[0],e=Math.min(...i.map(C=>C.x)),n=Math.min(...i.map(C=>C.y)),r=Math.max(...i.map(C=>C.x+C.width)),a=Math.max(...i.map(C=>C.y+C.height)),l="",u=[],f=[];for(let C=0;C<i.length;C++){let k=i[C];if(C>0){let O=i[C-1];B1(O,k)&&(l+=" ")}let I=l.length;if(Array.isArray(k.colorSpans)&&k.colorSpans.length>0)for(let O of k.colorSpans)u.push({from:I+O.from,to:I+O.to,fill:O.fill??null});else u.push({from:I,to:I+k.text.length,fill:k.fill??null});f.push({from:I,to:I+k.text.length,fontWeight:k.fontWeight,fontStyle:k.fontStyle,fontRef:k.fontRef}),l+=k.text}ld(u),ld(f);let g=[];for(let C of u){let k=g[g.length-1];k&&ml(k.fill,C.fill)&&k.to===C.from?k.to=C.to:g.push({...C})}let m=g.every(C=>ml(C.fill,g[0].fill)),y=[];for(let C of f){let k=y[y.length-1];k&&k.fontWeight===C.fontWeight&&k.fontStyle===C.fontStyle&&k.fontRef===C.fontRef&&k.to===C.from?k.to=C.to:y.push({...C})}let v=y.every(C=>C.fontWeight===y[0].fontWeight&&C.fontStyle===y[0].fontStyle&&C.fontRef===y[0].fontRef),S=y.map(C=>({from:C.from,to:C.to,...C.fontWeight!=null?{fontWeight:C.fontWeight}:{},...C.fontStyle!=null?{fontStyle:C.fontStyle}:{},fontRef:C.fontRef})),T=H1(i);return{...t,x:e,y:n,width:r-e,height:a-n,text:l,...m?{}:{colorSpans:g},...v?{}:{styleSpans:S},...T?{_buildGlyphOutline:T}:{}}}function H1(i){let t=i.map(e=>e._buildGlyphOutline).filter(e=>e!=null);if(t.length!==0)return()=>{let e=t.map(f=>f()).filter(f=>f!=null);if(e.length===0)return null;let n=1/0,r=1/0,a=-1/0,l=-1/0;for(let f of e)f.x<n&&(n=f.x),f.y<r&&(r=f.y),f.x+f.width>a&&(a=f.x+f.width),f.y+f.height>l&&(l=f.y+f.height);return{d:e.map(f=>gd(f.d,f.x-n,f.y-r)).filter(f=>f.length>0).join(" "),x:n,y:r,width:a-n,height:l-r}}}var j1=.5,cd=.3;function pd(i){let t=[],e=null,n=()=>{e&&(e.length===1?t.push(e[0]):t.push(W1(e)),e=null)};for(let r of i){if(r.kind!==ne.TEXT_OUTLINE){n(),t.push(r);continue}let a=r;if(!e){e=[a];continue}let l=e[e.length-1];V1(l,a)?e.push(a):(n(),e=[a])}return n(),t}function V1(i,t){if(!i.fontFamily||!t.fontFamily||i.fontFamily!==t.fontFamily||Math.abs((i.fontSize??0)-(t.fontSize??0))>.5||(i.fontStyle??"normal")!==(t.fontStyle??"normal")||(i.fontWeight??"normal")!==(t.fontWeight??"normal")||!ml(i.fill,t.fill))return!1;let e=i.fontSize||10;if(Math.abs(i.y-t.y)>e*cd||Math.abs(i.y+i.height-(t.y+t.height))>e*cd)return!1;let n=i.x+i.width,r=t.x-n,a=e*j1;return!(r>a||r<-a)}function ml(i,t){if(i==null&&t==null)return!0;if(i==null||t==null||i.space!==t.space||(i.alpha??1)!==(t.alpha??1)||!i.values||!t.values||i.values.length!==t.values.length)return!1;for(let e=0;e<i.values.length;e++)if(Math.abs(i.values[e]-t.values[e])>1e-6)return!1;return!0}function W1(i){let t=i[0],e=Math.min(...i.map(m=>m.x)),n=Math.min(...i.map(m=>m.y)),r=Math.max(...i.map(m=>m.x+m.width)),a=Math.max(...i.map(m=>m.y+m.height)),l=i.map(m=>m.text??"").join(""),u=i.map(m=>gd(m.d??"",m.x-e,m.y-n)).filter(m=>m.length>0).join(" "),f=i.map(m=>m.textOriginX).filter(m=>Number.isFinite(m)),g=f.length>0?Math.min(...f):void 0;return{...t,x:e,y:n,width:r-e,height:a-n,text:l,d:u,textOriginX:g}}function gd(i,t,e){if(!i)return"";if(Math.abs(t)<1e-9&&Math.abs(e)<1e-9)return i;let n=i.trim().split(/\s+/),r=[],a=0;for(;a<n.length;){let l=n[a];if(l==="Z"||l==="z"){r.push(l),a++;continue}if(/^[A-Za-z]$/.test(l)){let u=l,f=$1(u);r.push(u);for(let g=0;g<f;g++){let m=Number(n[a+1+g*2]),y=Number(n[a+2+g*2]);if(!Number.isFinite(m)||!Number.isFinite(y)){r.push(n[a+1+g*2],n[a+2+g*2]);continue}r.push(ud(m+t),ud(y+e))}a+=1+f*2;continue}r.push(l),a++}return r.join(" ")}function $1(i){switch(i){case"M":case"m":case"L":case"l":case"T":case"t":return 1;case"Q":case"q":case"S":case"s":return 2;case"C":case"c":return 3;default:return 0}}function ud(i){return`${Math.round(i*100)/100}`}var Pi=class i{engine;pdfBytes;fontResolver;fontStrategy;pageBounds;logger=new xr(lu);ir;constructor(t,e,n,r="trim",a=jn){this.engine=t,this.pdfBytes=e,this.fontResolver=n??uo,this.fontStrategy=a,this.pageBounds=r}static async fromFile(t,e,n){let r;e instanceof ArrayBuffer?r=e:r=await e.arrayBuffer();let a=new Uint8Array(r);return typeof n=="function"?new i(t,a,n):new i(t,a,n?.fontResolver,n?.pageBounds,n?.fontStrategy)}async parse(){let t=await this.ensureIR();return{scene:await Yh(this.engine,t,{fontResolver:this.fontResolver,fontStrategy:this.fontStrategy,logger:this.logger,pageBounds:this.pageBounds}),logger:this.logger}}async loadAsBlocks(t){let e=await this.ensureIR();return t?.pageIndex!=null&&(t.pageIndex<0||t.pageIndex>=e.pages.length)?(this.logger.emit("PAGE_INDEX_OUT_OF_RANGE",{requested:t.pageIndex,available:e.pages.length}),{blocks:[],logger:this.logger}):{blocks:await Kh(this.engine,e,{fontResolver:this.fontResolver,fontStrategy:this.fontStrategy,logger:this.logger,pageBounds:"media",pageIndex:t?.pageIndex}),logger:this.logger}}async getPageCount(){return(await this.ensureIR()).pages.length}getLogger(){return this.logger}async ensureIR(){if(this.ir)return this.ir;let t=await Sh(this.pdfBytes,{textMode:"auto",logger:this.logger});this.logger.emit("DOC_PAGE_COUNT",{count:t.pages.length});for(let e=0;e<t.pages.length;e++){let n=z1(t.pages[e].blocks);this.logger.emit("DOC_PAGE_BLOCK_COUNT",{page:e,imageCount:n.image,vectorCount:n.vector,textCount:n.text,outlineCount:n.outline})}for(let e of t.pages)e.blocks=pd(e.blocks),e.blocks=hd(e.blocks);return this.ir=t,t}};function z1(i){let t={image:0,vector:0,text:0,outline:0};for(let e of i)e.kind==="image"?t.image++:e.kind==="vector-path"?t.vector++:e.kind==="text-run"?t.text++:e.kind==="text-outline"&&t.outline++;return t}0&&(module.exports={Logger,PDFParser,addGfontsAssetLibrary,anyMatchResolverStage,assetLibraryStrategy,createFontCascade,createFontStrategy,defaultEmission,defaultStrategy,editableFirstStrategy,embeddedSubsetStage,exactFidelityStrategy,perfectMatchResolverStage});